Bug 1348665 part 5 - Remove the aFrame param to ReparentFrameViewTo and make it a member function instead. r=dholbert draft
authorMats Palmgren <mats@mozilla.com>
Sun, 19 Mar 2017 19:15:02 +0100
changeset 501306 fbfa2177d25a105ded84060080284230b1baea6f
parent 501305 26967ca69d69e1d43257050372341f4b24fca794
child 549826 ce9ad1ab7260dcabd71a8ba68f26f51084769be5
push id49924
push usermpalmgren@mozilla.com
push dateSun, 19 Mar 2017 18:19:42 +0000
reviewersdholbert
bugs1348665
milestone55.0a1
Bug 1348665 part 5 - Remove the aFrame param to ReparentFrameViewTo and make it a member function instead. r=dholbert MozReview-Commit-ID: 4bHvQnu9SRD
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,
                ("nsContainerFrame::CreateView: frame=%p view=%p",
                 this, view));
 }
--- a/layout/generic/nsIFrame.h
+++ b/layout/generic/nsIFrame.h
@@ -3626,20 +3626,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