From dff4e17b141cbb295f149ddb1e7d66d9247b7d2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Fri, 23 Mar 2018 18:47:05 +0100 Subject: [PATCH] Bug 1448413: Do a bit of misc cleanup. r=jwatt Summary: Mostly removing unneeded AsServo() and such. Reviewers: jwatt Bug #: 1448413 Differential Revision: https://phabricator.services.mozilla.com/D798 MozReview-Commit-ID: 8muHF7uMA53 --- dom/smil/nsSMILCSSProperty.cpp | 2 +- layout/base/ServoRestyleManager.cpp | 95 +++++++++++++-------------- layout/base/nsCSSFrameConstructor.cpp | 8 +-- layout/generic/nsFrame.cpp | 3 +- layout/generic/nsInlineFrame.cpp | 2 +- layout/style/StyleSetHandleInlines.h | 33 ++++------ layout/tables/nsTableFrame.cpp | 8 +-- 7 files changed, 72 insertions(+), 79 deletions(-) diff --git a/dom/smil/nsSMILCSSProperty.cpp b/dom/smil/nsSMILCSSProperty.cpp index f6041894d081..c678beb6563f 100644 --- a/dom/smil/nsSMILCSSProperty.cpp +++ b/dom/smil/nsSMILCSSProperty.cpp @@ -69,7 +69,7 @@ nsSMILCSSProperty::GetBaseValue() const AnimationValue computedValue; if (mElement->IsStyledByServo()) { computedValue.mServo = - Servo_ComputedValues_ExtractAnimationValue(mBaseComputedStyle->AsServo(), mPropID) + Servo_ComputedValues_ExtractAnimationValue(mBaseComputedStyle, mPropID) .Consume(); if (!computedValue.mServo) { return baseValue; diff --git a/layout/base/ServoRestyleManager.cpp b/layout/base/ServoRestyleManager.cpp index 2d061972667c..da664bd9aa06 100644 --- a/layout/base/ServoRestyleManager.cpp +++ b/layout/base/ServoRestyleManager.cpp @@ -507,17 +507,17 @@ public: void ComputeHintIfNeeded(nsIContent* aContent, nsIFrame* aTextFrame, - ComputedStyle& aNewContext) + ComputedStyle& aNewStyle) { MOZ_ASSERT(aTextFrame); - MOZ_ASSERT(aNewContext.GetPseudo() == nsCSSAnonBoxes::mozText); + MOZ_ASSERT(aNewStyle.GetPseudo() == nsCSSAnonBoxes::mozText); if (MOZ_LIKELY(!mShouldPostHints)) { return; } - ComputedStyle* oldContext = aTextFrame->Style()->AsServo(); - MOZ_ASSERT(oldContext->GetPseudo() == nsCSSAnonBoxes::mozText); + ComputedStyle* oldStyle = aTextFrame->Style(); + MOZ_ASSERT(oldStyle->GetPseudo() == nsCSSAnonBoxes::mozText); // We rely on the fact that all the text children for the same element share // style to avoid recomputing style differences for all of them. @@ -528,9 +528,9 @@ public: mShouldComputeHints = false; uint32_t equalStructs, samePointerStructs; mComputedHint = - oldContext->CalcStyleDifference(&aNewContext, - &equalStructs, - &samePointerStructs); + oldStyle->CalcStyleDifference(&aNewStyle, + &equalStructs, + &samePointerStructs); mComputedHint = NS_RemoveSubsumedHints( mComputedHint, mParentRestyleState.ChangesHandledFor(*aTextFrame)); } @@ -588,10 +588,10 @@ UpdateBackdropIfNeeded(nsIFrame* aFrame, MOZ_ASSERT(backdropFrame->Style()->GetPseudoType() == CSSPseudoElementType::backdrop); - RefPtr newContext = + RefPtr newStyle = aStyleSet.ResolvePseudoElementStyle(aFrame->GetContent()->AsElement(), CSSPseudoElementType::backdrop, - aFrame->Style()->AsServo(), + aFrame->Style(), /* aPseudoElement = */ nullptr); // NOTE(emilio): We can't use the changes handled for the owner of the @@ -601,7 +601,7 @@ UpdateBackdropIfNeeded(nsIFrame* aFrame, backdropFrame->GetParent()->IsCanvasFrame()); nsTArray wrappersToRestyle; ServoRestyleState state(aStyleSet, aChangeList, wrappersToRestyle); - nsIFrame::UpdateStyleOfOwnedChildFrame(backdropFrame, newContext, state); + nsIFrame::UpdateStyleOfOwnedChildFrame(backdropFrame, newStyle, state); } static void @@ -636,16 +636,16 @@ UpdateOneAdditionalComputedStyle(nsIFrame* aFrame, MOZ_ASSERT( !nsCSSPseudoElements::PseudoElementSupportsUserActionState(pseudoType)); - RefPtr newContext = + RefPtr newStyle = aRestyleState.StyleSet().ResolvePseudoElementStyle( aFrame->GetContent()->AsElement(), pseudoType, - aFrame->Style()->AsServo(), + aFrame->Style(), /* aPseudoElement = */ nullptr); uint32_t equalStructs, samePointerStructs; // Not used, actually. nsChangeHint childHint = aOldContext.CalcStyleDifference( - newContext, + newStyle, &equalStructs, &samePointerStructs); if (!aFrame->HasAnyStateBits(NS_FRAME_OUT_OF_FLOW)) { @@ -663,7 +663,7 @@ UpdateOneAdditionalComputedStyle(nsIFrame* aFrame, aFrame, aFrame->GetContent(), childHint); } - aFrame->SetAdditionalComputedStyle(aIndex, newContext); + aFrame->SetAdditionalComputedStyle(aIndex, newStyle); } static void @@ -676,9 +676,9 @@ UpdateAdditionalComputedStyles(nsIFrame* aFrame, // FIXME(emilio): Consider adding a bit or something to avoid the initial // virtual call? uint32_t index = 0; - while (auto* oldContext = aFrame->GetAdditionalComputedStyle(index)) { + while (auto* oldStyle = aFrame->GetAdditionalComputedStyle(index)) { UpdateOneAdditionalComputedStyle( - aFrame, index++, *oldContext->AsServo(), aRestyleState); + aFrame, index++, *oldStyle, aRestyleState); } } @@ -854,7 +854,7 @@ ServoRestyleManager::ProcessPostTraversal( // during the replacement. In practice it's not a huge deal, but better not // playing with dangling pointers if not needed. RefPtr oldComputedStyle = - styleFrame ? styleFrame->Style()->AsServo() : nullptr; + styleFrame ? styleFrame->Style() : nullptr; ComputedStyle* displayContentsStyle = nullptr; // FIXME(emilio, bug 1303605): This can be simpler for Servo. @@ -863,7 +863,7 @@ ServoRestyleManager::ProcessPostTraversal( displayContentsStyle = PresContext()->FrameConstructor()->GetDisplayContentsStyleFor(aElement); if (displayContentsStyle) { - oldComputedStyle = displayContentsStyle->AsServo(); + oldComputedStyle = displayContentsStyle; } } @@ -899,7 +899,7 @@ ServoRestyleManager::ProcessPostTraversal( // We want to walk all the continuations here, even the ones with different // styles. In practice, the only reason we get continuations with different // styles here is ::first-line (::first-letter never affects element - // styles). But in that case, newContext is the right context for the + // styles). But in that case, newStyle is the right context for the // _later_ continuations anyway (the ones not affected by ::first-line), not // the earlier ones, so there is no point stopping right at the point when // we'd actually be setting the right ComputedStyle. @@ -938,7 +938,7 @@ ServoRestyleManager::ProcessPostTraversal( // // We can sometimes reach this when the animated style is being removed. // Since AddLayerChangesForAnimation checks if |styleFrame| has a transform - // style or not, we need to call it *after* setting |newContext| to + // style or not, we need to call it *after* setting |newStyle| to // |styleFrame| to ensure the animated transform has been removed first. AddLayerChangesForAnimation( styleFrame, aElement, aRestyleState.ChangeList()); @@ -1045,13 +1045,13 @@ ServoRestyleManager::ProcessPostTraversalForText( ServoRestyleState::TableAwareParentFor(primaryFrame)); } - ComputedStyle& newContext = aPostTraversalState.ComputeStyle(aTextNode); - aPostTraversalState.ComputeHintIfNeeded(aTextNode, primaryFrame, newContext); + ComputedStyle& newStyle = aPostTraversalState.ComputeStyle(aTextNode); + aPostTraversalState.ComputeHintIfNeeded(aTextNode, primaryFrame, newStyle); // We want to walk all the continuations here, even the ones with different // styles. In practice, the only reasons we get continuations with different // styles are ::first-line and ::first-letter. But in those cases, - // newContext is the right context for the _later_ continuations anyway (the + // newStyle is the right context for the _later_ continuations anyway (the // ones not affected by ::first-line/::first-letter), not the earlier ones, // so there is no point stopping right at the point when we'd actually be // setting the right ComputedStyle. @@ -1060,7 +1060,7 @@ ServoRestyleManager::ProcessPostTraversalForText( // initial continuations; ::first-line/::first-letter fix that up after the // fact. for (nsIFrame* f = primaryFrame; f; f = f->GetNextContinuation()) { - f->SetComputedStyle(&newContext); + f->SetComputedStyle(&newStyle); } return true; @@ -1591,7 +1591,7 @@ ServoRestyleManager::DoReparentComputedStyle(nsIFrame* aFrame, } nsIFrame* providerFrame; - ComputedStyle* newParentContext = + ComputedStyle* newParentStyle = aFrame->GetParentComputedStyle(&providerFrame); // If our provider is our child, we want to reparent it first, because we // inherit style from it. @@ -1601,13 +1601,13 @@ ServoRestyleManager::DoReparentComputedStyle(nsIFrame* aFrame, DoReparentComputedStyle(providerFrame, aStyleSet); // Get the style again after ReparentComputedStyle() which might have // changed it. - newParentContext = providerFrame->Style(); + newParentStyle = providerFrame->Style(); providerChild = providerFrame; MOZ_ASSERT(!providerFrame->HasAnyStateBits(NS_FRAME_OUT_OF_FLOW), "Out of flow provider?"); } - if (!newParentContext) { + if (!newParentStyle) { // No need to do anything here for this frame, but we should still reparent // its descendants, because those may have styles that inherit from the // parent of this frame (e.g. non-anonymous columns in an anonymous @@ -1629,13 +1629,13 @@ ServoRestyleManager::DoReparentComputedStyle(nsIFrame* aFrame, // We don't try to do the fancy copying from previous continuations that // GeckoRestyleManager does here, because that relies on knowing the parents // of ComputedStyles, and we don't know those. - ComputedStyle* oldContext = aFrame->Style()->AsServo(); + ComputedStyle* oldStyle = aFrame->Style(); Element* ourElement = - oldContext->GetPseudoType() == CSSPseudoElementType::NotPseudo && + oldStyle->GetPseudoType() == CSSPseudoElementType::NotPseudo && isElement ? aFrame->GetContent()->AsElement() : nullptr; - ComputedStyle* newParent = newParentContext->AsServo(); + ComputedStyle* newParent = newParentStyle; ComputedStyle* newParentIgnoringFirstLine; if (newParent->GetPseudoType() == CSSPseudoElementType::firstLine) { @@ -1648,8 +1648,8 @@ ServoRestyleManager::DoReparentComputedStyle(nsIFrame* aFrame, // Use the resulting style for the "parent style ignoring ::first-line". nsIFrame* blockFrame = providerFrame->GetParent(); nsIFrame* correctedFrame = - nsFrame::CorrectStyleParentFrame(blockFrame, oldContext->GetPseudo()); - newParentIgnoringFirstLine = correctedFrame->Style()->AsServo(); + nsFrame::CorrectStyleParentFrame(blockFrame, oldStyle->GetPseudo()); + newParentIgnoringFirstLine = correctedFrame->Style(); } else { newParentIgnoringFirstLine = newParent; } @@ -1663,18 +1663,18 @@ ServoRestyleManager::DoReparentComputedStyle(nsIFrame* aFrame, aFrame->GetPlaceholderFrame()->GetLayoutParentStyleForOutOfFlow(&providerFrame); } else { providerFrame = nsFrame::CorrectStyleParentFrame(aFrame->GetParent(), - oldContext->GetPseudo()); + oldStyle->GetPseudo()); } } - ComputedStyle* layoutParent = providerFrame->Style()->AsServo(); + ComputedStyle* layoutParent = providerFrame->Style(); - RefPtr newContext = - aStyleSet.ReparentComputedStyle(oldContext, - newParent, - newParentIgnoringFirstLine, - layoutParent, - ourElement); - aFrame->SetComputedStyle(newContext); + RefPtr newStyle = + aStyleSet.ReparentComputedStyle(oldStyle, + newParent, + newParentIgnoringFirstLine, + layoutParent, + ourElement); + aFrame->SetComputedStyle(newStyle); // This logic somewhat mirrors the logic in // ServoRestyleManager::ProcessPostTraversal. @@ -1683,14 +1683,13 @@ ServoRestyleManager::DoReparentComputedStyle(nsIFrame* aFrame, // ServoRestyleState and maintaining one of those during a _frametree_ // traversal is basically impossible. uint32_t index = 0; - while (ComputedStyle* oldAdditionalContext = - aFrame->GetAdditionalComputedStyle(index)) { + while (auto* oldAdditionalStyle = aFrame->GetAdditionalComputedStyle(index)) { RefPtr newAdditionalContext = - aStyleSet.ReparentComputedStyle(oldAdditionalContext->AsServo(), - newContext, - newContext, - newContext, - nullptr); + aStyleSet.ReparentComputedStyle(oldAdditionalStyle, + newStyle, + newStyle, + newStyle, + nullptr); aFrame->SetAdditionalComputedStyle(index, newAdditionalContext); ++index; } diff --git a/layout/base/nsCSSFrameConstructor.cpp b/layout/base/nsCSSFrameConstructor.cpp index 85a7314448da..aef591a2daa5 100644 --- a/layout/base/nsCSSFrameConstructor.cpp +++ b/layout/base/nsCSSFrameConstructor.cpp @@ -10877,10 +10877,10 @@ nsCSSFrameConstructor::CreateLetterFrame(nsContainerFrame* aBlockFrame, sc = mPresShell->StyleSet()->AsServo()->ReparentComputedStyle( - sc->AsServo(), - parentComputedStyle->AsServo(), - parentIgnoringFirstLine->Style()->AsServo(), - parentComputedStyle->AsServo(), + sc, + parentComputedStyle, + parentIgnoringFirstLine->Style(), + parentComputedStyle, blockContent->AsElement()); } diff --git a/layout/generic/nsFrame.cpp b/layout/generic/nsFrame.cpp index 285678b468ef..41efd93196d0 100644 --- a/layout/generic/nsFrame.cpp +++ b/layout/generic/nsFrame.cpp @@ -10720,8 +10720,7 @@ nsIFrame::UpdateStyleOfChildAnonBox(nsIFrame* aChildFrame, // Anon boxes inherit from their parent; that's us. RefPtr newContext = - aRestyleState.StyleSet().ResolveInheritingAnonymousBoxStyle(pseudo, - Style()->AsServo()); + aRestyleState.StyleSet().ResolveInheritingAnonymousBoxStyle(pseudo, Style()); nsChangeHint childHint = UpdateStyleOfOwnedChildFrame(aChildFrame, newContext, aRestyleState); diff --git a/layout/generic/nsInlineFrame.cpp b/layout/generic/nsInlineFrame.cpp index 4d11de4f11a2..db98c4839778 100644 --- a/layout/generic/nsInlineFrame.cpp +++ b/layout/generic/nsInlineFrame.cpp @@ -957,7 +957,7 @@ nsInlineFrame::UpdateStyleOfOwnedAnonBoxesForIBSplit( MOZ_ASSERT(blockFrame, "Why did we have an IB split?"); // The later inlines need to get our style. - ComputedStyle* ourStyle = Style()->AsServo(); + ComputedStyle* ourStyle = Style(); // The anonymous block's style inherits from ours, and we already have our new // style context. diff --git a/layout/style/StyleSetHandleInlines.h b/layout/style/StyleSetHandleInlines.h index d6e4f2ae2916..bc8daf53f9a6 100644 --- a/layout/style/StyleSetHandleInlines.h +++ b/layout/style/StyleSetHandleInlines.h @@ -16,10 +16,6 @@ #define FORWARD_CONCRETE(method_, geckoargs_, servoargs_) \ return AsServo()->method_ servoargs_; -#define FORWARD_WITH_PARENT(method_, parent_, args_) \ - auto* parent = parent_ ? parent_->AsServo() : nullptr; \ - return AsServo()->method_ args_; - #define FORWARD(method_, args_) FORWARD_CONCRETE(method_, args_, args_) @@ -81,17 +77,17 @@ StyleSetHandle::Ptr::EndUpdate() // resolve a style context already_AddRefed StyleSetHandle::Ptr::ResolveStyleFor(dom::Element* aElement, - ComputedStyle* aParentContext, + ComputedStyle* aParentStyle, LazyComputeBehavior aMayCompute) { - FORWARD_WITH_PARENT(ResolveStyleFor, aParentContext, (aElement, parent, aMayCompute)); + FORWARD(ResolveStyleFor, (aElement, aParentStyle, aMayCompute)); } already_AddRefed StyleSetHandle::Ptr::ResolveStyleForText(nsIContent* aTextNode, - ComputedStyle* aParentContext) + ComputedStyle* aParentStyle) { - FORWARD_WITH_PARENT(ResolveStyleForText, aParentContext, (aTextNode, parent)); + FORWARD(ResolveStyleForText, (aTextNode, aParentStyle)); } already_AddRefed @@ -101,25 +97,25 @@ StyleSetHandle::Ptr::ResolveStyleForPlaceholder() } already_AddRefed -StyleSetHandle::Ptr::ResolveStyleForFirstLetterContinuation(ComputedStyle* aParentContext) +StyleSetHandle::Ptr::ResolveStyleForFirstLetterContinuation(ComputedStyle* aParentStyle) { - FORWARD_WITH_PARENT(ResolveStyleForFirstLetterContinuation, aParentContext, (parent)); + FORWARD(ResolveStyleForFirstLetterContinuation, (aParentStyle)); } already_AddRefed StyleSetHandle::Ptr::ResolvePseudoElementStyle(dom::Element* aParentElement, CSSPseudoElementType aType, - ComputedStyle* aParentContext, + ComputedStyle* aParentStyle, dom::Element* aPseudoElement) { - FORWARD_WITH_PARENT(ResolvePseudoElementStyle, aParentContext, (aParentElement, aType, parent, aPseudoElement)); + FORWARD(ResolvePseudoElementStyle, (aParentElement, aType, aParentStyle, aPseudoElement)); } already_AddRefed StyleSetHandle::Ptr::ResolveInheritingAnonymousBoxStyle(nsAtom* aPseudoTag, - ComputedStyle* aParentContext) + ComputedStyle* aParentStyle) { - FORWARD_WITH_PARENT(ResolveInheritingAnonymousBoxStyle, aParentContext, (aPseudoTag, parent)); + FORWARD(ResolveInheritingAnonymousBoxStyle, (aPseudoTag, aParentStyle)); } already_AddRefed @@ -132,11 +128,10 @@ StyleSetHandle::Ptr::ResolveNonInheritingAnonymousBoxStyle(nsAtom* aPseudoTag) already_AddRefed StyleSetHandle::Ptr::ResolveXULTreePseudoStyle(dom::Element* aParentElement, nsICSSAnonBoxPseudo* aPseudoTag, - ComputedStyle* aParentContext, + ComputedStyle* aParentStyle, const AtomArray& aInputWord) { - FORWARD_WITH_PARENT(ResolveXULTreePseudoStyle, aParentContext, - (aParentElement, aPseudoTag, parent, aInputWord)); + FORWARD(ResolveXULTreePseudoStyle, (aParentElement, aPseudoTag, aParentStyle, aInputWord)); } #endif @@ -276,9 +271,9 @@ StyleSetHandle::Ptr::InvalidateStyleForCSSRuleChanges() already_AddRefed StyleSetHandle::Ptr::ProbePseudoElementStyle(dom::Element* aParentElement, CSSPseudoElementType aType, - ComputedStyle* aParentContext) + ComputedStyle* aParentStyle) { - FORWARD_WITH_PARENT(ProbePseudoElementStyle, aParentContext, (aParentElement, aType, parent)); + FORWARD(ProbePseudoElementStyle, (aParentElement, aType, aParentStyle)); } void diff --git a/layout/tables/nsTableFrame.cpp b/layout/tables/nsTableFrame.cpp index e2a723b57d6e..292cf5bfbbd6 100644 --- a/layout/tables/nsTableFrame.cpp +++ b/layout/tables/nsTableFrame.cpp @@ -8182,9 +8182,9 @@ nsTableFrame::UpdateStyleOfOwnedAnonBoxesForTableWrapper( nsCSSAnonBoxes::tableWrapper, "What happened to our parent?"); - RefPtr newContext = + RefPtr newStyle = aRestyleState.StyleSet().ResolveInheritingAnonymousBoxStyle( - nsCSSAnonBoxes::tableWrapper, aOwningFrame->Style()->AsServo()); + nsCSSAnonBoxes::tableWrapper, aOwningFrame->Style()); // Figure out whether we have an actual change. It's important that we do // this, even though all the wrapper's changes are due to properties it @@ -8201,7 +8201,7 @@ nsTableFrame::UpdateStyleOfOwnedAnonBoxesForTableWrapper( // compared to the owner frame. uint32_t equalStructs, samePointerStructs; // Not used, actually. nsChangeHint wrapperHint = aWrapperFrame->Style()->CalcStyleDifference( - newContext, + newStyle, &equalStructs, &samePointerStructs, /* aIgnoreVariables = */ true); @@ -8219,7 +8219,7 @@ nsTableFrame::UpdateStyleOfOwnedAnonBoxesForTableWrapper( } for (nsIFrame* cur = aWrapperFrame; cur; cur = cur->GetNextContinuation()) { - cur->SetComputedStyle(newContext); + cur->SetComputedStyle(newStyle); } MOZ_ASSERT(!(aWrapperFrame->GetStateBits() & NS_FRAME_OWNS_ANON_BOXES),