Bug 1348665 part 5 - Remove the aFrame param to ReparentFrameViewTo and make it a member function instead. r=tnikkel draft
authorMats Palmgren <mats@mozilla.com>
Tue, 21 Mar 2017 00:05:04 +0100
changeset 501761 f51e3f3477e0c6dc357fbaacfc89c7a109ba3565
parent 501760 1e474b43de0fa2027f735fbfd0129244e439f2d3
child 549999 ec060da30e121d5b6828cc8d84f2c0f6f30ab3c4
push id50115
push usermpalmgren@mozilla.com
push dateMon, 20 Mar 2017 23:15:02 +0000
reviewerstnikkel
bugs1348665
milestone55.0a1
Bug 1348665 part 5 - Remove the aFrame param to ReparentFrameViewTo and make it a member function instead. r=tnikkel MozReview-Commit-ID: HStZiMcSOZa
layout/generic/nsContainerFrame.cpp
layout/generic/nsFrame.cpp
layout/generic/nsIFrame.h
--- a/layout/generic/nsContainerFrame.cpp
+++ b/layout/generic/nsContainerFrame.cpp
@@ -452,18 +452,19 @@ nsContainerFrame::ReparentFrameView(nsIF
   nsView* oldParentView = aOldParentFrame->GetClosestView();
   nsView* newParentView = aNewParentFrame->GetClosestView();
   
   // See if the old parent frame and the new parent frame are in the
   // same view sub-hierarchy. If they are then we don't have to do
   // anything
   if (oldParentView != newParentView) {
     // They're not so we need to reparent any child views
-    ReparentFrameViewTo(aChildFrame, oldParentView->GetViewManager(), newParentView,
-                        oldParentView);
+    aChildFrame->ReparentFrameViewTo(oldParentView->GetViewManager(),
+                                     newParentView,
+                                     oldParentView);
   }
 
   return NS_OK;
 }
 
 nsresult
 nsContainerFrame::ReparentFrameViewList(const nsFrameList& aChildFrameList,
                                         nsIFrame*          aOldParentFrame,
@@ -514,17 +515,17 @@ nsContainerFrame::ReparentFrameViewList(
   // See if the old parent frame and the new parent frame are in the
   // same view sub-hierarchy. If they are then we don't have to do
   // anything
   if (oldParentView != newParentView) {
     nsViewManager* viewManager = oldParentView->GetViewManager();
 
     // They're not so we need to reparent any child views
     for (nsFrameList::Enumerator e(aChildFrameList); !e.AtEnd(); e.Next()) {
-      ReparentFrameViewTo(e.get(), viewManager, newParentView, oldParentView);
+      e.get()->ReparentFrameViewTo(viewManager, newParentView, oldParentView);
     }
   }
 
   return NS_OK;
 }
 
 static nsIWidget*
 GetPresContextContainerWidget(nsPresContext* aPresContext)
--- a/layout/generic/nsFrame.cpp
+++ b/layout/generic/nsFrame.cpp
@@ -976,47 +976,46 @@ nsFrame::DidSetStyleContext(nsStyleConte
   if (StyleVisibility()->mDirection == NS_STYLE_DIRECTION_RTL) {
     PresContext()->SetBidiEnabled();
   }
 
   RemoveStateBits(NS_FRAME_SIMPLE_EVENT_REGIONS);
 }
 
 void
-nsIFrame::ReparentFrameViewTo(nsIFrame* aFrame,
-                              nsViewManager* aViewManager,
+nsIFrame::ReparentFrameViewTo(nsViewManager* aViewManager,
                               nsView*        aNewParentView,
                               nsView*        aOldParentView)
 {
-  if (aFrame->HasView()) {
+  if (HasView()) {
 #ifdef MOZ_XUL
-    if (aFrame->GetType() == nsGkAtoms::menuPopupFrame) {
+    if (GetType() == nsGkAtoms::menuPopupFrame) {
       // This view must be parented by the root view, don't reparent it.
       return;
     }
 #endif
-    nsView* view = aFrame->GetView();
+    nsView* view = GetView();
     // Verify that the current parent view is what we think it is
     //nsView*  parentView;
     //NS_ASSERTION(parentView == aOldParentView, "unexpected parent view");
 
     aViewManager->RemoveChild(view);
     
     // The view will remember the Z-order and other attributes that have been set on it.
-    nsView* insertBefore = nsLayoutUtils::FindSiblingViewFor(aNewParentView, aFrame);
+    nsView* insertBefore = nsLayoutUtils::FindSiblingViewFor(aNewParentView, this);
     aViewManager->InsertChild(aNewParentView, view, insertBefore, insertBefore != nullptr);
-  } else if (aFrame->GetStateBits() & NS_FRAME_HAS_CHILD_WITH_VIEW) {
-    nsIFrame::ChildListIterator lists(aFrame);
+  } else if (GetStateBits() & NS_FRAME_HAS_CHILD_WITH_VIEW) {
+    nsIFrame::ChildListIterator lists(this);
     for (; !lists.IsDone(); lists.Next()) {
       // Iterate the child frames, and check each child frame to see if it has
       // a view
       nsFrameList::Enumerator childFrames(lists.CurrentList());
       for (; !childFrames.AtEnd(); childFrames.Next()) {
-        ReparentFrameViewTo(childFrames.get(), aViewManager,
-                            aNewParentView, aOldParentView);
+        childFrames.get()->ReparentFrameViewTo(aViewManager, aNewParentView,
+                                               aOldParentView);
       }
     }
   }
 }
 
 void
 nsIFrame::SyncFrameViewProperties(nsView* aView)
 {
@@ -1080,17 +1079,17 @@ nsFrame::CreateView()
   // REVIEW: Don't create a widget for fixed-pos elements anymore.
   // ComputeRepaintRegionForCopy will calculate the right area to repaint
   // when we scroll.
   // Reparent views on any child frames (or their descendants) to this
   // view. We can just call ReparentFrameViewTo on this frame because
   // we know this frame has no view, so it will crawl the children. Also,
   // we know that any descendants with views must have 'parentView' as their
   // parent view.
-  ReparentFrameViewTo(this, viewManager, view, parentView);
+  ReparentFrameViewTo(viewManager, view, parentView);
 
   // Remember our view
   SetView(view);
 
   NS_FRAME_LOG(NS_FRAME_TRACE_CALLS,
                ("nsFrame::CreateView: frame=%p view=%p",
                 this, view));
 }
--- a/layout/generic/nsIFrame.h
+++ b/layout/generic/nsIFrame.h
@@ -3631,20 +3631,22 @@ public:
    */
   nscoord ComputeISizeValue(nsRenderingContext* aRenderingContext,
                             nscoord             aContainingBlockISize,
                             nscoord             aContentEdgeToBoxSizing,
                             nscoord             aBoxSizingToMarginEdge,
                             const nsStyleCoord& aCoord,
                             ComputeSizeFlags    aFlags = eDefault);
 protected:
-  static void ReparentFrameViewTo(nsIFrame* aFrame,
-                                  nsViewManager* aViewManager,
-                                  nsView*        aNewParentView,
-                                  nsView*        aOldParentView);
+  /**
+   * Reparent this frame's view if it has one.
+   */
+  void ReparentFrameViewTo(nsViewManager* aViewManager,
+                           nsView*        aNewParentView,
+                           nsView*        aOldParentView);
 
   // Members
   nsRect           mRect;
   nsIContent*      mContent;
   nsStyleContext*  mStyleContext;
 private:
   nsContainerFrame* mParent;
   nsIFrame*        mNextSibling;  // doubly-linked list of frames