From 994e392924e8247f239c84329251eddc49c385b9 Mon Sep 17 00:00:00 2001 From: "enndeakin@sympatico.ca" Date: Sun, 16 Sep 2007 08:51:27 -0700 Subject: [PATCH] Bug 394887, create widgets for popups lazily, second attempt with a slight change to see if performance is ok --- layout/xul/base/src/nsMenuPopupFrame.cpp | 22 ++++++++++++++++++++++ layout/xul/base/src/nsMenuPopupFrame.h | 17 +---------------- 2 files changed, 23 insertions(+), 16 deletions(-) diff --git a/layout/xul/base/src/nsMenuPopupFrame.cpp b/layout/xul/base/src/nsMenuPopupFrame.cpp index e0405c199a3a..04537301c6a9 100644 --- a/layout/xul/base/src/nsMenuPopupFrame.cpp +++ b/layout/xul/base/src/nsMenuPopupFrame.cpp @@ -254,6 +254,28 @@ nsMenuPopupFrame::SetInitialChildList(nsIAtom* aListName, return nsBoxFrame::SetInitialChildList(aListName, aChildList); } +PRBool +nsMenuPopupFrame::IsLeaf() const +{ + if (mGeneratedChildren) + return PR_FALSE; + + if (mPopupType != ePopupTypeMenu) { + // any panel with a type attribute, such as the autocomplete popup, + // is always generated right away. + return !mContent->HasAttr(kNameSpaceID_None, nsGkAtoms::type); + } + + // menu popups generate their child frames lazily only when opened, so + // behave like a leaf frame. However, generate child frames normally if + // the parent menu has a sizetopopup attribute. In this case the size of + // the parent menu is dependant on the size of the popup, so the frames + // need to exist in order to calculate this size. + nsIContent* parentContent = mContent->GetParent(); + return (parentContent && + !parentContent->HasAttr(kNameSpaceID_None, nsGkAtoms::sizetopopup)); +} + void nsMenuPopupFrame::AdjustView() { diff --git a/layout/xul/base/src/nsMenuPopupFrame.h b/layout/xul/base/src/nsMenuPopupFrame.h index 531d23872124..02b15d2409bd 100644 --- a/layout/xul/base/src/nsMenuPopupFrame.h +++ b/layout/xul/base/src/nsMenuPopupFrame.h @@ -183,22 +183,7 @@ public: NS_IMETHOD SetInitialChildList(nsIAtom* aListName, nsIFrame* aChildList); - virtual PRBool IsLeaf() const - { - if (!mGeneratedChildren && mPopupType == ePopupTypeMenu) { - // menu popups generate their child frames lazily only when opened, so - // behave like a leaf frame. However, generate child frames normally if - // the parent menu has a sizetopopup attribute. In this case the size of - // the parent menu is dependant on the size of the popup, so the frames - // need to exist in order to calculate this size. - nsIContent* parentContent = mContent->GetParent(); - if (parentContent && - !parentContent->HasAttr(kNameSpaceID_None, nsGkAtoms::sizetopopup)) - return PR_TRUE; - } - - return PR_FALSE; - } + virtual PRBool IsLeaf() const; // AdjustView should be called by the parent frame after the popup has been // laid out, so that the view can be shown.