From 406398810f983f28b45f1a16145626f493de3642 Mon Sep 17 00:00:00 2001 From: Timothy Nikkel Date: Wed, 26 Oct 2011 18:57:55 -0500 Subject: [PATCH] Bug 655263. Remove views from decks. r=roc --- layout/xul/base/src/nsDeckFrame.cpp | 77 +++-------------------------- layout/xul/base/src/nsDeckFrame.h | 16 +----- 2 files changed, 10 insertions(+), 83 deletions(-) diff --git a/layout/xul/base/src/nsDeckFrame.cpp b/layout/xul/base/src/nsDeckFrame.cpp index 9e70d2caae31..68d6a13b4ea6 100644 --- a/layout/xul/base/src/nsDeckFrame.cpp +++ b/layout/xul/base/src/nsDeckFrame.cpp @@ -96,7 +96,7 @@ nsDeckFrame::AttributeChanged(PRInt32 aNameSpaceID, // if the index changed hide the old element and make the new element visible if (aAttribute == nsGkAtoms::selectedIndex) { - IndexChanged(PresContext()); + IndexChanged(); } return rv; @@ -114,68 +114,14 @@ nsDeckFrame::Init(nsIContent* aContent, return rv; } -static void -CreateViewsForFrames(const nsFrameList& aFrames) +void +nsDeckFrame::HideBox(nsIBox* aBox) { - for (nsFrameList::Enumerator f(aFrames); !f.AtEnd(); f.Next()) { - nsContainerFrame::CreateViewForFrame(f.get(), true); - } -} - -NS_IMETHODIMP -nsDeckFrame::SetInitialChildList(ChildListID aListID, - nsFrameList& aChildList) -{ - CreateViewsForFrames(aChildList); - return nsBoxFrame::SetInitialChildList(aListID, aChildList); -} - -NS_IMETHODIMP -nsDeckFrame::AppendFrames(ChildListID aListID, - nsFrameList& aFrameList) -{ - CreateViewsForFrames(aFrameList); - return nsBoxFrame::AppendFrames(aListID, aFrameList); -} - -NS_IMETHODIMP -nsDeckFrame::InsertFrames(ChildListID aListID, - nsIFrame* aPrevFrame, - nsFrameList& aFrameList) -{ - CreateViewsForFrames(aFrameList); - return nsBoxFrame::InsertFrames(aListID, aPrevFrame, aFrameList); + nsIPresShell::ClearMouseCapture(aBox); } void -nsDeckFrame::HideBox(nsPresContext* aPresContext, nsIBox* aBox) -{ - nsIView* view = aBox->GetView(); - - if (view) { - nsIViewManager* viewManager = view->GetViewManager(); - viewManager->SetViewVisibility(view, nsViewVisibility_kHide); - viewManager->ResizeView(view, nsRect(0, 0, 0, 0)); - - nsIPresShell::ClearMouseCapture(aBox); - } -} - -void -nsDeckFrame::ShowBox(nsPresContext* aPresContext, nsIBox* aBox) -{ - nsRect rect = aBox->GetRect(); - nsIView* view = aBox->GetView(); - if (view) { - nsIViewManager* viewManager = view->GetViewManager(); - rect.x = rect.y = 0; - viewManager->ResizeView(view, rect); - viewManager->SetViewVisibility(view, nsViewVisibility_kShow); - } -} - -void -nsDeckFrame::IndexChanged(nsPresContext* aPresContext) +nsDeckFrame::IndexChanged() { //did the index change? PRInt32 index = GetSelectedIndex(); @@ -188,14 +134,9 @@ nsDeckFrame::IndexChanged(nsPresContext* aPresContext) // hide the currently showing box nsIBox* currentBox = GetSelectedBox(); if (currentBox) // only hide if it exists - HideBox(aPresContext, currentBox); + HideBox(currentBox); mIndex = index; - - // show the new box - nsIBox* newBox = GetSelectedBox(); - if (newBox) // only show if it exists - ShowBox(aPresContext, newBox); } PRInt32 @@ -271,10 +212,8 @@ nsDeckFrame::DoLayout(nsBoxLayoutState& aState) while (box) { // make collapsed children not show up - if (count == mIndex) - ShowBox(aState.PresContext(), box); - else - HideBox(aState.PresContext(), box); + if (count != mIndex) + HideBox(box); box = box->GetNextBox(); count++; diff --git a/layout/xul/base/src/nsDeckFrame.h b/layout/xul/base/src/nsDeckFrame.h index 869b34736d7b..e845c21359de 100644 --- a/layout/xul/base/src/nsDeckFrame.h +++ b/layout/xul/base/src/nsDeckFrame.h @@ -76,16 +76,6 @@ public: nsIFrame* aParent, nsIFrame* aPrevInFlow); - // Override SetInitialChildList/AppendFrames/InsertFrames to - // create views for our child frames if necessary - NS_IMETHOD SetInitialChildList(ChildListID aListID, - nsFrameList& aChildList); - NS_IMETHOD AppendFrames(ChildListID aListID, - nsFrameList& aFrameList); - NS_IMETHOD InsertFrames(ChildListID aListID, - nsIFrame* aPrevFrame, - nsFrameList& aFrameList); - virtual nsIAtom* GetType() const; #ifdef NS_DEBUG @@ -101,11 +91,9 @@ public: protected: - // REVIEW: Sorry, I couldn't resist devirtualizing these. - void IndexChanged(nsPresContext* aPresContext); + void IndexChanged(); PRInt32 GetSelectedIndex(); - void HideBox(nsPresContext* aPresContext, nsIBox* aBox); - void ShowBox(nsPresContext* aPresContext, nsIBox* aBox); + void HideBox(nsIBox* aBox); private: