Bug 1348665 part 4 - Remove some params to SyncFrameViewProperties and make it a member function instead. Make the aView param optional, use the frame's view if none provided. r=tnikkel draft
authorMats Palmgren <mats@mozilla.com>
Tue, 21 Mar 2017 00:05:04 +0100
changeset 501760 1e474b43de0fa2027f735fbfd0129244e439f2d3
parent 501759 dae805bbae6f261f55e82f98d9dc760f2207aa8d
child 501761 f51e3f3477e0c6dc357fbaacfc89c7a109ba3565
push id50115
push usermpalmgren@mozilla.com
push dateMon, 20 Mar 2017 23:15:02 +0000
reviewerstnikkel
bugs1348665
milestone55.0a1
Bug 1348665 part 4 - Remove some params to SyncFrameViewProperties and make it a member function instead. Make the aView param optional, use the frame's view if none provided. r=tnikkel MozReview-Commit-ID: KTUaiqr0cmT
layout/base/RestyleManager.cpp
layout/base/nsCSSFrameConstructor.cpp
layout/generic/nsFrame.cpp
layout/generic/nsIFrame.h
layout/xul/nsMenuPopupFrame.cpp
--- a/layout/base/RestyleManager.cpp
+++ b/layout/base/RestyleManager.cpp
@@ -1167,22 +1167,18 @@ SyncViewsAndInvalidateDescendants(nsIFra
                   "should only be called within ApplyRenderingChangeToTree");
   NS_ASSERTION(nsChangeHint_size_t(aChange) ==
                           (aChange & (nsChangeHint_RepaintFrame |
                                       nsChangeHint_SyncFrameView |
                                       nsChangeHint_UpdateOpacityLayer |
                                       nsChangeHint_SchedulePaint)),
                "Invalid change flag");
 
-  nsView* view = aFrame->GetView();
-  if (view) {
-    if (aChange & nsChangeHint_SyncFrameView) {
-      nsContainerFrame::SyncFrameViewProperties(aFrame->PresContext(), aFrame,
-                                                nullptr, view);
-    }
+  if (aChange & nsChangeHint_SyncFrameView) {
+    aFrame->SyncFrameViewProperties();
   }
 
   nsIFrame::ChildListIterator lists(aFrame);
   for (; !lists.IsDone(); lists.Next()) {
     for (nsIFrame* child : lists.CurrentList()) {
       if (!(child->GetStateBits() & NS_FRAME_OUT_OF_FLOW)) {
         // only do frames that don't have placeholders
         if (nsGkAtoms::placeholderFrame == child->GetType()) {
--- a/layout/base/nsCSSFrameConstructor.cpp
+++ b/layout/base/nsCSSFrameConstructor.cpp
@@ -2727,18 +2727,17 @@ nsCSSFrameConstructor::ConstructRootFram
   // Would it really kill us to pass in the root element or something?
   // What would that break?
   viewportFrame->Init(nullptr, nullptr, nullptr);
 
   // Bind the viewport frame to the root view
   nsView* rootView = mPresShell->GetViewManager()->GetRootView();
   viewportFrame->SetView(rootView);
 
-  nsContainerFrame::SyncFrameViewProperties(mPresShell->GetPresContext(), viewportFrame,
-                                            viewportPseudoStyle, rootView);
+  viewportFrame->SyncFrameViewProperties(rootView);
   nsContainerFrame::SyncWindowProperties(mPresShell->GetPresContext(), viewportFrame,
                                          rootView, nullptr, nsContainerFrame::SET_ASYNC);
 
   // Make it an absolute container for fixed-pos elements
   viewportFrame->AddStateBits(NS_FRAME_CAN_HAVE_ABSPOS_CHILDREN);
   viewportFrame->MarkAsAbsoluteContainingBlock();
 
   return viewportFrame;
--- a/layout/generic/nsFrame.cpp
+++ b/layout/generic/nsFrame.cpp
@@ -1013,49 +1013,43 @@ nsIFrame::ReparentFrameViewTo(nsIFrame* 
         ReparentFrameViewTo(childFrames.get(), aViewManager,
                             aNewParentView, aOldParentView);
       }
     }
   }
 }
 
 void
-nsIFrame::SyncFrameViewProperties(nsPresContext*  aPresContext,
-                                 nsIFrame*        aFrame,
-                                 nsStyleContext*  aStyleContext,
-                                 nsView*          aView)
-{
-  NS_ASSERTION(!aStyleContext || aFrame->StyleContext() == aStyleContext,
-               "Wrong style context for frame?");
-
+nsIFrame::SyncFrameViewProperties(nsView* aView)
+{
   if (!aView) {
-    return;
+    aView = GetView();
+    if (!aView) {
+      return;
+    }
   }
 
   nsViewManager* vm = aView->GetViewManager();
 
-  if (nullptr == aStyleContext) {
-    aStyleContext = aFrame->StyleContext();
-  }
-
-  // Make sure visibility is correct. This only affects nsSubdocumentFrame.
-  if (!aFrame->SupportsVisibilityHidden()) {
+  // Make sure visibility is correct. This only affects nsSubDocumentFrame.
+  if (!SupportsVisibilityHidden()) {
     // See if the view should be hidden or visible
+    nsStyleContext* sc = StyleContext();
     vm->SetViewVisibility(aView,
-        aStyleContext->StyleVisibility()->IsVisible()
+        sc->StyleVisibility()->IsVisible()
             ? nsViewVisibility_kShow : nsViewVisibility_kHide);
   }
 
   int32_t zIndex = 0;
   bool    autoZIndex = false;
 
-  if (aFrame->IsAbsPosContainingBlock()) {
+  if (IsAbsPosContainingBlock()) {
     // Make sure z-index is correct
-    const nsStylePosition* position = aStyleContext->StylePosition();
-
+    nsStyleContext* sc = StyleContext();
+    const nsStylePosition* position = sc->StylePosition();
     if (position->mZIndex.GetUnit() == eStyleUnit_Integer) {
       zIndex = position->mZIndex.GetIntValue();
     } else if (position->mZIndex.GetUnit() == eStyleUnit_Auto) {
       autoZIndex = true;
     }
   } else {
     autoZIndex = true;
   }
@@ -1064,25 +1058,23 @@ nsIFrame::SyncFrameViewProperties(nsPres
 }
 
 void
 nsFrame::CreateView()
 {
   MOZ_ASSERT(!HasView());
 
   nsView* parentView = GetParent()->GetClosestView();
-  NS_ASSERTION(parentView, "no parent with view");
+  MOZ_ASSERT(parentView, "no parent with view");
 
   nsViewManager* viewManager = parentView->GetViewManager();
-  NS_ASSERTION(viewManager, "null view manager");
-
-  // Create a view
+  MOZ_ASSERT(viewManager, "null view manager");
+
   nsView* view = viewManager->CreateView(GetRect(), parentView);
-
-  SyncFrameViewProperties(PresContext(), this, nullptr, view);
+  SyncFrameViewProperties(view);
 
   nsView* insertBefore = nsLayoutUtils::FindSiblingViewFor(parentView, this);
   // we insert this view 'above' the insertBefore view, unless insertBefore is null,
   // in which case we want to call with aAbove == false to insert at the beginning
   // in document order
   viewManager->InsertChild(parentView, view, insertBefore, insertBefore != nullptr);
 
   // REVIEW: Don't create a widget for fixed-pos elements anymore.
--- a/layout/generic/nsIFrame.h
+++ b/layout/generic/nsIFrame.h
@@ -2473,26 +2473,23 @@ public:
    */
   nsView* GetClosestView(nsPoint* aOffset = nullptr) const;
 
   /**
    * Find the closest ancestor (excluding |this| !) that has a view
    */
   nsIFrame* GetAncestorWithView() const;
 
-  // Sets the view's attributes from the frame style.
-  // - visibility
-  // - clip
-  // Call this when one of these styles changes or when the view has just
-  // been created.
-  // @param aStyleContext can be null, in which case the frame's style context is used
-  static void SyncFrameViewProperties(nsPresContext*  aPresContext,
-                                      nsIFrame*        aFrame,
-                                      nsStyleContext*  aStyleContext,
-                                      nsView*         aView);
+  /**
+   * Sets the view's attributes from the frame style.
+   * Call this for nsChangeHint_SyncFrameView style changes or when the view
+   * has just been created.
+   * @param aView the frame's view or use GetView() if nullptr is given
+   */
+  void SyncFrameViewProperties(nsView* aView = nullptr);
 
   /**
    * Get the offset between the coordinate systems of |this| and aOther.
    * Adding the return value to a point in the coordinate system of |this|
    * will transform the point to the coordinate system of aOther.
    *
    * aOther must be non-null.
    *
--- a/layout/xul/nsMenuPopupFrame.cpp
+++ b/layout/xul/nsMenuPopupFrame.cpp
@@ -525,17 +525,17 @@ nsMenuPopupFrame::LayoutPopup(nsBoxLayou
     rect.x = rect.y = 0;
     viewManager->ResizeView(view, rect);
 
     if (mPopupState == ePopupOpening) {
       mPopupState = ePopupVisible;
     }
 
     viewManager->SetViewVisibility(view, nsViewVisibility_kShow);
-    nsContainerFrame::SyncFrameViewProperties(pc, this, nullptr, view);
+    SyncFrameViewProperties(view);
   }
 
   // finally, if the popup just opened, send a popupshown event
   if (mIsOpenChanged) {
     mIsOpenChanged = false;
 
     // Make sure the current selection in a menulist is visible.
     if (IsMenuList() && mCurrentMenu) {