Bug 1676778 - Remove StyleFrame() in nsComputedDOMStyle.cpp. r=emilio
authorTing-Yu Lin <tlin@mozilla.com>
Thu, 12 Nov 2020 11:12:37 +0000
changeset 556970 0e0cb4886c95ad42a296fe34ad47b5c229689b76
parent 556969 b66d6544ad5a4c380c9a9808d243710571627df2
child 556971 9ab0b2a4396373c9e16bd2dd66225bc2bcbe69fd
push id37946
push userdluca@mozilla.com
push dateFri, 13 Nov 2020 09:59:41 +0000
treeherdermozilla-central@7bc610418605 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersemilio
bugs1676778
milestone84.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 1676778 - Remove StyleFrame() in nsComputedDOMStyle.cpp. r=emilio `StyleFrame()` is equivalent to `nsLayoutUtils::GetStyleFrame()`. Differential Revision: https://phabricator.services.mozilla.com/D96799
layout/base/nsLayoutUtils.cpp
layout/style/nsComputedDOMStyle.cpp
--- a/layout/base/nsLayoutUtils.cpp
+++ b/layout/base/nsLayoutUtils.cpp
@@ -904,16 +904,17 @@ nsIFrame* nsLayoutUtils::GetClosestFrame
 
 /* static */
 nsIFrame* nsLayoutUtils::GetPageFrame(nsIFrame* aFrame) {
   return GetClosestFrameOfType(aFrame, LayoutFrameType::Page);
 }
 
 /* static */
 nsIFrame* nsLayoutUtils::GetStyleFrame(nsIFrame* aPrimaryFrame) {
+  MOZ_ASSERT(aPrimaryFrame);
   if (aPrimaryFrame->IsTableWrapperFrame()) {
     nsIFrame* inner = aPrimaryFrame->PrincipalChildList().FirstChild();
     // inner may be null, if aPrimaryFrame is mid-destruction
     return inner;
   }
 
   return aPrimaryFrame;
 }
--- a/layout/style/nsComputedDOMStyle.cpp
+++ b/layout/style/nsComputedDOMStyle.cpp
@@ -824,31 +824,16 @@ bool nsComputedDOMStyle::NeedsToFlushSty
       return true;
     }
     doc = parentDocument;
   }
 
   return false;
 }
 
-static nsIFrame* StyleFrame(nsIFrame* aOuterFrame) {
-  MOZ_ASSERT(aOuterFrame);
-  if (!aOuterFrame->IsTableWrapperFrame()) {
-    return aOuterFrame;
-  }
-  // If the frame is a table wrapper frame then we should get the style from the
-  // inner table frame.
-  nsIFrame* inner = aOuterFrame->PrincipalChildList().FirstChild();
-  NS_ASSERTION(inner, "table wrapper must have an inner");
-  NS_ASSERTION(!inner->GetNextSibling(),
-               "table wrapper frames should have just one child, the inner "
-               "table");
-  return inner;
-}
-
 static bool IsNonReplacedInline(nsIFrame* aFrame) {
   // FIXME: this should be IsInlineInsideStyle() since width/height
   // doesn't apply to ruby boxes.
   return aFrame->StyleDisplay()->IsInlineFlow() &&
          !aFrame->IsFrameOfType(nsIFrame::eReplaced);
 }
 
 static Side SideForPaddingOrMarginOrInsetProperty(nsCSSPropertyID aPropID) {
@@ -884,17 +869,17 @@ bool nsComputedDOMStyle::NeedsToFlushLay
   MOZ_ASSERT(aPropID != eCSSProperty_UNKNOWN);
   if (aPropID == eCSSPropertyExtra_variable) {
     return false;
   }
   nsIFrame* outerFrame = GetOuterFrame();
   if (!outerFrame) {
     return false;
   }
-  nsIFrame* frame = StyleFrame(outerFrame);
+  nsIFrame* frame = nsLayoutUtils::GetStyleFrame(outerFrame);
   auto* style = frame->Style();
   if (nsCSSProps::PropHasFlags(aPropID, CSSPropFlags::IsLogical)) {
     aPropID = Servo_ResolveLogicalProperty(aPropID, style);
   }
 
   switch (aPropID) {
     case eCSSProperty_width:
     case eCSSProperty_height:
@@ -1055,17 +1040,17 @@ void nsComputedDOMStyle::UpdateCurrentSt
 
   // XXX the !mElement->IsHTMLElement(nsGkAtoms::area)
   // check is needed due to bug 135040 (to avoid using
   // mPrimaryFrame). Remove it once that's fixed.
   if (mStyleType == eAll && !mElement->IsHTMLElement(nsGkAtoms::area)) {
     mOuterFrame = GetOuterFrame();
     mInnerFrame = mOuterFrame;
     if (mOuterFrame) {
-      mInnerFrame = StyleFrame(mOuterFrame);
+      mInnerFrame = nsLayoutUtils::GetStyleFrame(mOuterFrame);
       SetFrameComputedStyle(mInnerFrame->Style(), currentGeneration);
       NS_ASSERTION(mComputedStyle, "Frame without style?");
     }
   }
 
   if (!mComputedStyle || MustReresolveStyle(mComputedStyle)) {
     PresShell* presShellForContent = mElement->OwnerDoc()->GetPresShell();
     // Need to resolve a style.