Bug 655263. Remove views from decks. r=roc
authorTimothy Nikkel <tnikkel@gmail.com>
Wed, 26 Oct 2011 18:57:55 -0500
changeset 79262 90c31d55b8b5a59a2764dc7ebcfb51f64af027b0
parent 79261 36c457f93e0f1e063f1035622ee93aab1e7c4974
child 79263 5b8e29b39c7f9c43864ee200ce44cedd3388f8b8
push id2938
push usertnikkel@gmail.com
push dateWed, 26 Oct 2011 23:59:21 +0000
treeherdermozilla-inbound@90c31d55b8b5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc
bugs655263
milestone10.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 655263. Remove views from decks. r=roc
layout/xul/base/src/nsDeckFrame.cpp
layout/xul/base/src/nsDeckFrame.h
--- a/layout/xul/base/src/nsDeckFrame.cpp
+++ b/layout/xul/base/src/nsDeckFrame.cpp
@@ -91,17 +91,17 @@ nsDeckFrame::AttributeChanged(PRInt32   
                               PRInt32         aModType)
 {
   nsresult rv = nsBoxFrame::AttributeChanged(aNameSpaceID, aAttribute,
                                              aModType);
 
 
    // if the index changed hide the old element and make the new element visible
   if (aAttribute == nsGkAtoms::selectedIndex) {
-    IndexChanged(PresContext());
+    IndexChanged();
   }
 
   return rv;
 }
 
 NS_IMETHODIMP
 nsDeckFrame::Init(nsIContent*     aContent,
                   nsIFrame*       aParent,
@@ -109,98 +109,39 @@ nsDeckFrame::Init(nsIContent*     aConte
 {
   nsresult rv = nsBoxFrame::Init(aContent, aParent, aPrevInFlow);
 
   mIndex = GetSelectedIndex();
 
   return rv;
 }
 
-static void
-CreateViewsForFrames(const nsFrameList& aFrames)
-{
-  for (nsFrameList::Enumerator f(aFrames); !f.AtEnd(); f.Next()) {
-    nsContainerFrame::CreateViewForFrame(f.get(), true);
-  }
-}
-
-NS_IMETHODIMP
-nsDeckFrame::SetInitialChildList(ChildListID     aListID,
-                                 nsFrameList&    aChildList)
+void
+nsDeckFrame::HideBox(nsIBox* aBox)
 {
-  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();
   if (index == mIndex)
     return;
 
   // redraw
   InvalidateOverflowRect();
 
   // 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
 nsDeckFrame::GetSelectedIndex()
 {
   // default index is 0
   PRInt32 index = 0;
 
@@ -266,20 +207,18 @@ nsDeckFrame::DoLayout(nsBoxLayoutState& 
 
   // run though each child. Hide all but the selected one
   nsIBox* box = GetChildBox();
 
   nscoord count = 0;
   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++;
   }
 
   aState.SetLayoutFlags(oldFlags);
 
   return rv;
--- a/layout/xul/base/src/nsDeckFrame.h
+++ b/layout/xul/base/src/nsDeckFrame.h
@@ -71,46 +71,34 @@ public:
   NS_IMETHOD BuildDisplayListForChildren(nsDisplayListBuilder*   aBuilder,
                                          const nsRect&           aDirtyRect,
                                          const nsDisplayListSet& aLists);
                                          
   NS_IMETHOD Init(nsIContent*      aContent,
                   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
   NS_IMETHOD GetFrameName(nsAString& aResult) const
   {
       return MakeFrameName(NS_LITERAL_STRING("Deck"), aResult);
   }
 #endif
 
   nsDeckFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
 
   nsIFrame* GetSelectedBox();
 
 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:
 
   PRInt32 mIndex;
 
 }; // class nsDeckFrame
 
 #endif