From 68e78b291f8aa571c674bdc119fec61f46ed3e50 Mon Sep 17 00:00:00 2001 From: Jonathan Watt Date: Fri, 23 Mar 2018 16:01:34 +0000 Subject: [PATCH] Bug 1449321 - Remove the IsServo and IsGecko methods from the style system code. r=emilio --HG-- extra : source : 763277b299e42d8ee7eafede027ee690b66a7a2a --- dom/animation/EffectCompositor.cpp | 39 +++++------ dom/base/nsDocument.cpp | 12 +--- dom/base/nsIDocument.h | 24 ++----- dom/canvas/CanvasRenderingContext2D.cpp | 26 ++----- dom/html/nsGenericHTMLElement.cpp | 8 +-- dom/smil/nsSMILAnimationController.cpp | 2 - dom/svg/nsSVGElement.cpp | 2 +- dom/xbl/nsXBLResourceLoader.cpp | 8 +-- editor/libeditor/HTMLEditor.cpp | 8 +-- layout/base/PresShell.cpp | 33 ++------- layout/base/RestyleManager.cpp | 21 ++---- layout/base/ServoRestyleManager.cpp | 2 +- layout/base/ServoRestyleManager.h | 3 - layout/base/nsCSSFrameConstructor.cpp | 12 +--- layout/base/nsFrameManager.cpp | 14 ++-- layout/base/nsPresContext.cpp | 4 +- layout/base/nsStyleChangeList.cpp | 35 ++++------ layout/base/nsStyleChangeList.h | 11 +-- layout/generic/nsFrame.cpp | 8 --- layout/style/DeclarationBlockInlines.h | 12 +--- layout/style/ErrorReporter.cpp | 39 ++--------- layout/style/ErrorReporter.h | 17 ++--- layout/style/GenericSpecifiedValuesInlines.h | 17 ++--- layout/style/Loader.cpp | 7 +- layout/style/MediaList.h | 4 -- layout/style/ServoBindings.cpp | 12 ---- layout/style/ServoMediaList.h | 4 -- layout/style/ServoStyleRule.cpp | 2 - layout/style/ServoStyleSheet.cpp | 5 -- layout/style/ServoUtils.h | 17 ++--- layout/style/StreamLoader.cpp | 1 - layout/style/StyleSetHandle.h | 34 ++------- layout/style/StyleSetHandleInlines.h | 27 -------- layout/style/StyleSheet.cpp | 31 +++------ layout/style/nsCSSCounterStyleRule.cpp | 13 +--- layout/style/nsDOMCSSDeclaration.cpp | 39 +++++------ layout/style/nsHTMLStyleSheet.cpp | 12 ++-- layout/style/nsLayoutStylesheetCache.cpp | 73 ++------------------ layout/style/nsLayoutStylesheetCache.h | 3 - layout/style/nsStyleStruct.cpp | 6 -- 40 files changed, 133 insertions(+), 514 deletions(-) diff --git a/dom/animation/EffectCompositor.cpp b/dom/animation/EffectCompositor.cpp index 41645ce6a6ae..71f58cfa8e37 100644 --- a/dom/animation/EffectCompositor.cpp +++ b/dom/animation/EffectCompositor.cpp @@ -311,27 +311,26 @@ EffectCompositor::PostRestyleForAnimation(dom::Element* aElement, eRestyle_CSSTransitions : eRestyle_CSSAnimations; - if (mPresContext->StyleSet()->IsServo()) { - MOZ_ASSERT(NS_IsMainThread(), - "Restyle request during restyling should be requested only on " - "the main-thread. e.g. after the parallel traversal"); - if (ServoStyleSet::IsInServoTraversal() || mIsInPreTraverse) { - MOZ_ASSERT(hint == eRestyle_CSSAnimations || - hint == eRestyle_CSSTransitions); + MOZ_ASSERT(NS_IsMainThread(), + "Restyle request during restyling should be requested only on " + "the main-thread. e.g. after the parallel traversal"); + if (ServoStyleSet::IsInServoTraversal() || mIsInPreTraverse) { + MOZ_ASSERT(hint == eRestyle_CSSAnimations || + hint == eRestyle_CSSTransitions); - // We can't call Servo_NoteExplicitHints here since AtomicRefCell does not - // allow us mutate ElementData of the |aElement| in SequentialTask. - // Instead we call Servo_NoteExplicitHints for the element in PreTraverse() - // which will be called right before the second traversal that we do for - // updating CSS animations. - // In that case PreTraverse() will return true so that we know to do the - // second traversal so we don't need to post any restyle requests to the - // PresShell. - return; - } else { - MOZ_ASSERT(!mPresContext->RestyleManager()->IsInStyleRefresh()); - } + // We can't call Servo_NoteExplicitHints here since AtomicRefCell does not + // allow us mutate ElementData of the |aElement| in SequentialTask. + // Instead we call Servo_NoteExplicitHints for the element in PreTraverse() + // which will be called right before the second traversal that we do for + // updating CSS animations. + // In that case PreTraverse() will return true so that we know to do the + // second traversal so we don't need to post any restyle requests to the + // PresShell. + return; } + + MOZ_ASSERT(!mPresContext->RestyleManager()->IsInStyleRefresh()); + mPresContext->PresShell()->RestyleForAnimation(element, hint); } @@ -812,7 +811,6 @@ EffectCompositor::PreTraverseInSubtree(ServoTraversalFlags aFlags, Element* aRoot) { MOZ_ASSERT(NS_IsMainThread()); - MOZ_ASSERT(mPresContext->RestyleManager()->IsServo()); MOZ_ASSERT(!aRoot || nsContentUtils::GetPresShellForContent(aRoot), "Traversal root, if provided, should be bound to a display " "document"); @@ -961,7 +959,6 @@ EffectCompositor::PreTraverse(dom::Element* aElement, CSSPseudoElementType aPseudoType) { MOZ_ASSERT(NS_IsMainThread()); - MOZ_ASSERT(mPresContext->RestyleManager()->IsServo()); // If |aElement|'s document does not have a pres shell, e.g. it is document // without a browsing context such as we might get from an XMLHttpRequest, we diff --git a/dom/base/nsDocument.cpp b/dom/base/nsDocument.cpp index 630ecfa13442..88d56f121824 100644 --- a/dom/base/nsDocument.cpp +++ b/dom/base/nsDocument.cpp @@ -1314,15 +1314,9 @@ nsIDocument::SelectorCache::~SelectorCache() void nsIDocument::SelectorCache::SelectorList::Reset() { - if (mIsServo) { - if (mServo) { - Servo_SelectorList_Drop(mServo); - mServo = nullptr; - } - } else { - if (mGecko) { - MOZ_CRASH("old style system disabled"); - } + if (mServo) { + Servo_SelectorList_Drop(mServo); + mServo = nullptr; } } diff --git a/dom/base/nsIDocument.h b/dom/base/nsIDocument.h index 7e97b2593610..f1a98ebb4d18 100644 --- a/dom/base/nsIDocument.h +++ b/dom/base/nsIDocument.h @@ -1505,8 +1505,7 @@ public: { public: SelectorList() - : mIsServo(false) - , mGecko(nullptr) + : mGecko(nullptr) {} SelectorList(SelectorList&& aOther) @@ -1517,21 +1516,15 @@ public: SelectorList& operator=(SelectorList&& aOther) { Reset(); - mIsServo = aOther.mIsServo; - if (mIsServo) { - mServo = aOther.mServo; - aOther.mServo = nullptr; - } else { - MOZ_CRASH("old style system disabled"); - } + mServo = aOther.mServo; + aOther.mServo = nullptr; return *this; } SelectorList(const SelectorList& aOther) = delete; explicit SelectorList(mozilla::UniquePtr&& aList) - : mIsServo(true) - , mServo(aList.release()) + : mServo(aList.release()) {} @@ -1539,31 +1532,24 @@ public: Reset(); } - bool IsServo() const { return mIsServo; } - bool IsGecko() const { return !IsServo(); } - explicit operator bool() const { - return IsServo() ? !!AsServo() : !!AsGecko(); + return !!AsServo(); } nsCSSSelectorList* AsGecko() const { - MOZ_ASSERT(IsGecko()); return mGecko; } RawServoSelectorList* AsServo() const { - MOZ_ASSERT(IsServo()); return mServo; } private: void Reset(); - bool mIsServo; - union { nsCSSSelectorList* mGecko; RawServoSelectorList* mServo; diff --git a/dom/canvas/CanvasRenderingContext2D.cpp b/dom/canvas/CanvasRenderingContext2D.cpp index e277f1776dc4..e6faa976d9e3 100644 --- a/dom/canvas/CanvasRenderingContext2D.cpp +++ b/dom/canvas/CanvasRenderingContext2D.cpp @@ -2689,8 +2689,6 @@ GetFontStyleForServo(Element* aElement, const nsAString& aFont, nsAString& aOutUsedFont, ErrorResult& aError) { - MOZ_ASSERT(aPresShell->StyleSet()->IsServo()); - RefPtr declarations = CreateFontDeclarationForServo(aFont, aPresShell->GetDocument()); if (!declarations) { @@ -2760,8 +2758,6 @@ ResolveFilterStyleForServo(const nsAString& aFilterString, nsIPresShell* aPresShell, ErrorResult& aError) { - MOZ_ASSERT(aPresShell->StyleSet()->IsServo()); - RefPtr declarations = CreateFilterDeclarationForServo(aFilterString, aPresShell->GetDocument()); if (!declarations) { @@ -2800,14 +2796,7 @@ CanvasRenderingContext2D::ParseFilter(const nsAString& aString, return false; } - nsString usedFont; - if (presShell->StyleSet()->IsGecko()) { - MOZ_CRASH("old style system disabled"); - return false; - } - - // For stylo - MOZ_ASSERT(presShell->StyleSet()->IsServo()); + nsString usedFont; // unused RefPtr parentStyle = GetFontStyleForServo(mCanvasElement, @@ -3735,14 +3724,9 @@ CanvasRenderingContext2D::SetFontInternal(const nsAString& aFont, return false; } - RefPtr sc; nsString usedFont; - if (presShell->StyleSet()->IsServo()) { - sc = - GetFontStyleForServo(mCanvasElement, aFont, presShell, usedFont, aError); - } else { - MOZ_CRASH("old style system disabled"); - } + RefPtr sc = + GetFontStyleForServo(mCanvasElement, aFont, presShell, usedFont, aError); if (!sc) { return false; } @@ -3755,8 +3739,8 @@ CanvasRenderingContext2D::SetFontInternal(const nsAString& aFont, // size (fontStyle->mSize). See // https://bugzilla.mozilla.org/show_bug.cgi?id=698652. // FIXME: Nobody initializes mAllowZoom for servo? - MOZ_ASSERT(presShell->StyleSet()->IsServo() || !fontStyle->mAllowZoom, - "expected text zoom to be disabled on this nsStyleFont"); + //MOZ_ASSERT(!fontStyle->mAllowZoom, + // "expected text zoom to be disabled on this nsStyleFont"); nsFont resizedFont(fontStyle->mFont); // Create a font group working in units of CSS pixels instead of the usual // device pixels, to avoid being affected by page zoom. nsFontMetrics will diff --git a/dom/html/nsGenericHTMLElement.cpp b/dom/html/nsGenericHTMLElement.cpp index c64af3f9001a..bdeed6ff456b 100644 --- a/dom/html/nsGenericHTMLElement.cpp +++ b/dom/html/nsGenericHTMLElement.cpp @@ -2959,13 +2959,7 @@ nsGenericHTMLElement::NewURIFromString(const nsAString& aURISpec, static bool IsOrHasAncestorWithDisplayNone(Element* aElement, nsIPresShell* aPresShell) { - if (aPresShell->StyleSet()->IsServo()) { - return !aElement->HasServoData() || Servo_Element_IsDisplayNone(aElement); - } - - MOZ_CRASH("Old style system disabled"); - - return false; + return !aElement->HasServoData() || Servo_Element_IsDisplayNone(aElement); } void diff --git a/dom/smil/nsSMILAnimationController.cpp b/dom/smil/nsSMILAnimationController.cpp index d406636a8eff..dde96c2a6d43 100644 --- a/dom/smil/nsSMILAnimationController.cpp +++ b/dom/smil/nsSMILAnimationController.cpp @@ -715,8 +715,6 @@ nsSMILAnimationController::PreTraverseInSubtree(Element* aRoot) if (!context) { return false; } - MOZ_ASSERT(context->RestyleManager()->IsServo(), - "PreTraverse should only be called for the servo style system"); bool foundElementsNeedingRestyle = false; for (auto iter = mAnimationElementTable.Iter(); !iter.Done(); iter.Next()) { diff --git a/dom/svg/nsSVGElement.cpp b/dom/svg/nsSVGElement.cpp index e25db7ab9d52..34817456fc85 100644 --- a/dom/svg/nsSVGElement.cpp +++ b/dom/svg/nsSVGElement.cpp @@ -118,7 +118,7 @@ nsSVGElement::DidAnimateClass() nsIPresShell* shell = OwnerDoc()->GetShell(); if (shell) { nsPresContext* presContext = shell->GetPresContext(); - if (presContext && presContext->RestyleManager()->IsServo()) { + if (presContext) { presContext->RestyleManager() ->AsServo() ->ClassAttributeWillBeChangedBySMIL(this); diff --git a/dom/xbl/nsXBLResourceLoader.cpp b/dom/xbl/nsXBLResourceLoader.cpp index 6fd3a13b5183..74900eb42382 100644 --- a/dom/xbl/nsXBLResourceLoader.cpp +++ b/dom/xbl/nsXBLResourceLoader.cpp @@ -182,12 +182,8 @@ nsXBLResourceLoader::StyleSheetLoaded(StyleSheet* aSheet, if (mPendingSheets == 0) { // All stylesheets are loaded. - if (aSheet->IsGecko()) { - MOZ_CRASH("old style system disabled"); - } else { - mResources->ComputeServoStyles( - *mBoundDocument->GetShell()->StyleSet()->AsServo()); - } + mResources->ComputeServoStyles( + *mBoundDocument->GetShell()->StyleSet()->AsServo()); // XXX Check for mPendingScripts when scripts also come online. if (!mInLoadResourcesFunc) diff --git a/editor/libeditor/HTMLEditor.cpp b/editor/libeditor/HTMLEditor.cpp index 4648614643da..cdc87d091c5d 100644 --- a/editor/libeditor/HTMLEditor.cpp +++ b/editor/libeditor/HTMLEditor.cpp @@ -3013,12 +3013,8 @@ HTMLEditor::EnableExistingStyleSheet(const nsAString& aURL) nsCOMPtr document = GetDocument(); sheet->SetAssociatedDocument(document, StyleSheet::NotOwnedByDocument); - if (sheet->IsServo()) { - // XXXheycam ServoStyleSheets don't support being enabled/disabled yet. - NS_ERROR("stylo: ServoStyleSheets can't be disabled yet"); - return true; - } - MOZ_CRASH("old style system disabled"); + // FIXME: This used to do sheet->SetDisabled(false), figure out if we can + // just remove all this code in bug 1449522, since it seems unused. return true; } diff --git a/layout/base/PresShell.cpp b/layout/base/PresShell.cpp index 7030db072a5a..41a98434ae47 100644 --- a/layout/base/PresShell.cpp +++ b/layout/base/PresShell.cpp @@ -604,11 +604,7 @@ static void VerifyStyleTree(nsPresContext* aPresContext, nsFrameManager* aFrameManager) { if (nsFrame::GetVerifyStyleTreeEnable()) { - if (aPresContext->RestyleManager()->IsServo()) { - NS_ERROR("stylo: cannot verify style tree with a ServoRestyleManager"); - return; - } - MOZ_CRASH("old style system disabled"); + NS_ERROR("stylo: cannot verify style tree with a ServoRestyleManager"); } } #define VERIFY_STYLE_TREE ::VerifyStyleTree(mPresContext, mFrameConstructor) @@ -4372,11 +4368,7 @@ PresShell::DocumentStatesChanged(nsIDocument* aDocument, EventStates aStateMask) MOZ_ASSERT(!aStateMask.IsEmpty()); if (mDidInitialize) { - if (mStyleSet->IsServo()) { - mStyleSet->AsServo()->InvalidateStyleForDocumentStateChanges(aStateMask); - } else { - MOZ_CRASH("old style system disabled"); - } + mStyleSet->AsServo()->InvalidateStyleForDocumentStateChanges(aStateMask); } if (aStateMask.HasState(NS_DOCUMENT_STATE_WINDOW_INACTIVE)) { @@ -4596,7 +4588,6 @@ PresShell::RecordStyleSheetChange(StyleSheet* aStyleSheet, { // too bad we can't check that the update is UPDATE_STYLE NS_ASSERTION(mUpdateCount != 0, "must be in an update"); - MOZ_ASSERT(aStyleSheet->IsServo() == mStyleSet->IsServo()); mStyleSet->RecordStyleSheetChange(aStyleSheet, aChangeType); } @@ -9642,14 +9633,9 @@ PresShell::VerifyIncrementalReflow() // Create a new presentation shell to view the document. Use the // exact same style information that this document has. - nsAutoPtr newServoSet; - StyleSetHandle newSet; - if (mStyleSet->IsServo()) { - newServoSet = CloneStyleSet(mStyleSet->AsServo()); - newSet = newServoSet; - } else { - MOZ_CRASH("old style system disabled"); - } + nsAutoPtr newServoSet(CloneStyleSet(mStyleSet->AsServo())); + StyleSetHandle newSet(newServoSet); + nsCOMPtr sh = mDocument->CreateShell(cx, vm, newSet); NS_ENSURE_TRUE(sh, false); newServoSet.forget(); @@ -10380,11 +10366,7 @@ PresShell::AddSizeOfIncludingThis(nsWindowSizes& aSizes) const mApproximatelyVisibleFrames.ShallowSizeOfExcludingThis(mallocSizeOf) + mFramesToDirty.ShallowSizeOfExcludingThis(mallocSizeOf); - if (StyleSet()->IsGecko()) { - MOZ_CRASH("old style system disabled"); - } else { - StyleSet()->AsServo()->AddSizeOfIncludingThis(aSizes); - } + StyleSet()->AsServo()->AddSizeOfIncludingThis(aSizes); aSizes.mLayoutTextRunsSize += SizeOfTextRuns(mallocSizeOf); @@ -10581,9 +10563,6 @@ nsIPresShell::HasRuleProcessorUsedByMultipleStyleSets(uint32_t aSheetType, bool* aRetVal) { *aRetVal = false; - if (mStyleSet->IsGecko()) { - MOZ_CRASH("old style system disabled"); - } return NS_OK; } diff --git a/layout/base/RestyleManager.cpp b/layout/base/RestyleManager.cpp index 39a4d226d70f..144eb65f8847 100644 --- a/layout/base/RestyleManager.cpp +++ b/layout/base/RestyleManager.cpp @@ -374,7 +374,7 @@ RestyleManager::ContentRemoved(nsINode* aContainer, { // Computed style data isn't useful for detached nodes, and we'll need to // recompute it anyway if we ever insert the nodes back into a document. - if (IsServo() && aOldChild->IsElement()) { + if (aOldChild->IsElement()) { ServoRestyleManager::ClearServoDataFromSubtree(aOldChild->AsElement()); } @@ -629,13 +629,9 @@ static bool gInApplyRenderingChangeToTree = false; void RestyleManager::DebugVerifyStyleTree(nsIFrame* aFrame) { - if (IsServo()) { - // XXXheycam For now, we know that we don't use the same inheritance - // hierarchy for certain cases, so just skip these assertions until - // we work out what we want to assert (bug 1322570). - return; - } - MOZ_CRASH("old style system disabled"); + // XXXheycam For now, we know that we don't use the same inheritance + // hierarchy for certain cases, so just skip these assertions until + // we work out what we want to assert (bug 1322570). } #endif // DEBUG @@ -1750,14 +1746,9 @@ RestyleManager::IncrementAnimationGeneration() // We update the animation generation at start of each call to // ProcessPendingRestyles so we should ignore any subsequent (redundant) // calls that occur while we are still processing restyles. - if (IsGecko()) { - MOZ_CRASH("old style system disabled"); - } else { - if (mInStyleRefresh) { - return; - } + if (!mInStyleRefresh) { + ++mAnimationGeneration; } - ++mAnimationGeneration; } /* static */ void diff --git a/layout/base/ServoRestyleManager.cpp b/layout/base/ServoRestyleManager.cpp index 3b3a3ae6c8ad..fbb6bb6e47c1 100644 --- a/layout/base/ServoRestyleManager.cpp +++ b/layout/base/ServoRestyleManager.cpp @@ -1151,7 +1151,7 @@ ServoRestyleManager::DoProcessPendingRestyles(ServoTraversalFlags aFlags) while (styleSet->StyleDocument(aFlags)) { ClearSnapshots(); - nsStyleChangeList currentChanges(StyleBackendType::Servo); + nsStyleChangeList currentChanges; bool anyStyleChanged = false; // Recreate styles , and queue up change hints (which also handle lazy frame diff --git a/layout/base/ServoRestyleManager.h b/layout/base/ServoRestyleManager.h index 854041f8d6fa..c93988fd4327 100644 --- a/layout/base/ServoRestyleManager.h +++ b/layout/base/ServoRestyleManager.h @@ -305,9 +305,6 @@ private: inline ServoStyleSet* StyleSet() const { - MOZ_ASSERT(PresContext()->StyleSet()->IsServo(), - "ServoRestyleManager should only be used with a Servo-flavored " - "style backend"); return PresContext()->StyleSet()->AsServo(); } diff --git a/layout/base/nsCSSFrameConstructor.cpp b/layout/base/nsCSSFrameConstructor.cpp index 9666c1150887..d34dd9251edc 100644 --- a/layout/base/nsCSSFrameConstructor.cpp +++ b/layout/base/nsCSSFrameConstructor.cpp @@ -471,12 +471,7 @@ ReparentFrame(RestyleManager* aRestyleManager, aFrame->SetParent(aNewParentFrame); // We reparent frames for two reasons: to put them inside ::first-line, and to // put them inside some wrapper anonymous boxes. - // - // The latter shouldn't affect any styles in practice, so only needs style - // context reparenting in the Gecko backend. - // - // FIXME(emilio): Remove old Gecko stuff. - if (aForceStyleReparent || aRestyleManager->IsGecko()) { + if (aForceStyleReparent) { aRestyleManager->ReparentComputedStyle(aFrame); } } @@ -10632,11 +10627,6 @@ nsCSSFrameConstructor::CheckForFirstLineInsertion(nsIFrame* aParentFrame, } class RestyleManager* restyleManager = RestyleManager(); - if (!restyleManager->IsServo()) { - // Gecko's style resolution is frame-based, so already has the right styles - // even in the ::first-line case. - return; - } // Check whether there's a ::first-line on the path up from aParentFrame. // Note that we can't stop until we've run out of ancestors with diff --git a/layout/base/nsFrameManager.cpp b/layout/base/nsFrameManager.cpp index 129741f8303c..091b3083e9dc 100644 --- a/layout/base/nsFrameManager.cpp +++ b/layout/base/nsFrameManager.cpp @@ -85,7 +85,7 @@ public: */ static nsIContent* GetApplicableParent(nsIContent* aParent); - void AddSizeOfIncludingThis(nsWindowSizes& aSizes, bool aIsServo) const; + void AddSizeOfIncludingThis(nsWindowSizes& aSizes) const; protected: LinkedList* GetListFor(nsIContent* aParentContent); @@ -693,13 +693,12 @@ nsFrameManager::DestroyAnonymousContent(already_AddRefed aContent) void nsFrameManager::AddSizeOfIncludingThis(nsWindowSizes& aSizes) const { - bool isServo = mPresShell->StyleSet()->IsServo(); aSizes.mLayoutPresShellSize += aSizes.mState.mMallocSizeOf(this); if (mDisplayNoneMap) { - mDisplayNoneMap->AddSizeOfIncludingThis(aSizes, isServo); + mDisplayNoneMap->AddSizeOfIncludingThis(aSizes); } if (mDisplayContentsMap) { - mDisplayContentsMap->AddSizeOfIncludingThis(aSizes, isServo); + mDisplayContentsMap->AddSizeOfIncludingThis(aSizes); } } @@ -840,7 +839,7 @@ nsFrameManager::UndisplayedMap::RemoveNodesFor(nsIContent* aParentContent) void nsFrameManager::UndisplayedMap:: -AddSizeOfIncludingThis(nsWindowSizes& aSizes, bool aIsServo) const +AddSizeOfIncludingThis(nsWindowSizes& aSizes) const { MallocSizeOf mallocSizeOf = aSizes.mState.mMallocSizeOf; aSizes.mLayoutPresShellSize += ShallowSizeOfIncludingThis(mallocSizeOf); @@ -849,11 +848,6 @@ AddSizeOfIncludingThis(nsWindowSizes& aSizes, bool aIsServo) const for (auto iter = ConstIter(); !iter.Done(); iter.Next()) { const LinkedList* list = iter.UserData(); aSizes.mLayoutPresShellSize += list->sizeOfExcludingThis(mallocSizeOf); - if (!aIsServo) { - // Computed values and style structs can only be stale when using - // Servo style system. - continue; - } for (const UndisplayedNode* node = list->getFirst(); node; node = node->getNext()) { ComputedStyle* computedStyle = node->mStyle; diff --git a/layout/base/nsPresContext.cpp b/layout/base/nsPresContext.cpp index 5283af09d7a9..7e50d178ce0f 100644 --- a/layout/base/nsPresContext.cpp +++ b/layout/base/nsPresContext.cpp @@ -1207,9 +1207,7 @@ nsPresContext::CompatibilityModeChanged() } StyleSetHandle styleSet = mShell->StyleSet(); - if (styleSet->IsServo()) { - styleSet->AsServo()->CompatibilityModeChanged(); - } + styleSet->AsServo()->CompatibilityModeChanged(); if (doc->IsSVGDocument()) { // SVG documents never load quirk.css. diff --git a/layout/base/nsStyleChangeList.cpp b/layout/base/nsStyleChangeList.cpp index 6f8ce925bff6..541fe073e089 100644 --- a/layout/base/nsStyleChangeList.cpp +++ b/layout/base/nsStyleChangeList.cpp @@ -45,30 +45,21 @@ nsStyleChangeList::AppendChange(nsIFrame* aFrame, nsIContent* aContent, nsChange if (aHint & nsChangeHint_ReconstructFrame) { // If Servo fires reconstruct at a node, it is the only change hint fired at // that node. - if (IsServo()) { - // Note: Because we check whether |aHint| is a reconstruct above (which is - // necessary to avoid debug test timeouts on certain crashtests), this check - // will not find bugs where we add a non-reconstruct hint for an element after - // adding a reconstruct. This is ok though, since ProcessRestyledFrames will - // handle that case via mDestroyedFrames. + + // Note: Because we check whether |aHint| is a reconstruct above (which is + // necessary to avoid debug test timeouts on certain crashtests), this check + // will not find bugs where we add a non-reconstruct hint for an element after + // adding a reconstruct. This is ok though, since ProcessRestyledFrames will + // handle that case via mDestroyedFrames. #ifdef DEBUG - for (size_t i = 0; i < Length(); ++i) { - MOZ_ASSERT(aContent != (*this)[i].mContent || - !((*this)[i].mHint & nsChangeHint_ReconstructFrame), - "Should not append a non-ReconstructFrame hint after \ - appending a ReconstructFrame hint for the same \ - content."); - } -#endif - } else { - // Filter out all other changes for same content for Gecko (Servo asserts against this - // case above). - // NOTE: This is captured by reference to please static analysis. - // Capturing it by value as a pointer should be fine in this case. - RemoveElementsBy([&](const nsStyleChangeData& aData) { - return aData.mContent == aContent; - }); + for (size_t i = 0; i < Length(); ++i) { + MOZ_ASSERT(aContent != (*this)[i].mContent || + !((*this)[i].mHint & nsChangeHint_ReconstructFrame), + "Should not append a non-ReconstructFrame hint after \ + appending a ReconstructFrame hint for the same \ + content."); } +#endif } if (!IsEmpty() && aFrame && aFrame == LastElement().mFrame) { diff --git a/layout/base/nsStyleChangeList.h b/layout/base/nsStyleChangeList.h index f45160968557..7b737f38bb95 100644 --- a/layout/base/nsStyleChangeList.h +++ b/layout/base/nsStyleChangeList.h @@ -41,8 +41,9 @@ public: using base_type::Length; using base_type::operator[]; - explicit nsStyleChangeList(mozilla::StyleBackendType aType) : - mType(aType) { MOZ_COUNT_CTOR(nsStyleChangeList); } + nsStyleChangeList() { + MOZ_COUNT_CTOR(nsStyleChangeList); + } ~nsStyleChangeList() { MOZ_COUNT_DTOR(nsStyleChangeList); } void AppendChange(nsIFrame* aFrame, nsIContent* aContent, nsChangeHint aHint); @@ -54,12 +55,6 @@ public: RemoveLastElement(); } } - - bool IsGecko() const { return mType == mozilla::StyleBackendType::Gecko; } - bool IsServo() const { return mType == mozilla::StyleBackendType::Servo; } - -private: - mozilla::StyleBackendType mType; }; #endif /* nsStyleChangeList_h___ */ diff --git a/layout/generic/nsFrame.cpp b/layout/generic/nsFrame.cpp index 30b966cf8e0e..8d490b2d263a 100644 --- a/layout/generic/nsFrame.cpp +++ b/layout/generic/nsFrame.cpp @@ -768,14 +768,6 @@ nsFrame::DestroyFrom(nsIFrame* aDestructRoot, PostDestroyData& aPostDestroyData) if (IsPrimaryFrame()) { // This needs to happen before we clear our Properties() table. ActiveLayerTracker::TransferActivityToContent(this, mContent); - - // Unfortunately, we need to do this for all frames being reframed - // and not only those whose current style involves CSS transitions, - // because what matters is whether the new style (not the old) - // specifies CSS transitions. - if (presContext->RestyleManager()->IsGecko()) { - MOZ_CRASH("old style system disabled"); - } } if (HasCSSAnimations() || HasCSSTransitions() || diff --git a/layout/style/DeclarationBlockInlines.h b/layout/style/DeclarationBlockInlines.h index 2b3333e3e82e..e773e4fdbc6d 100644 --- a/layout/style/DeclarationBlockInlines.h +++ b/layout/style/DeclarationBlockInlines.h @@ -28,21 +28,13 @@ DeclarationBlock::Release() already_AddRefed DeclarationBlock::Clone() const { - RefPtr result; - if (IsGecko()) { - MOZ_CRASH("old style system disabled"); - } else { - result = new ServoDeclarationBlock(*AsServo()); - } - return result.forget(); + return do_AddRef(new ServoDeclarationBlock(*AsServo())); } already_AddRefed DeclarationBlock::EnsureMutable() { -#ifdef DEBUG -#endif - if (IsServo() && !IsDirty()) { + if (!IsDirty()) { // In stylo, the old DeclarationBlock is stored in element's rule node tree // directly, to avoid new values replacing the DeclarationBlock in the tree // directly, we need to copy the old one here if we haven't yet copied. diff --git a/layout/style/ErrorReporter.cpp b/layout/style/ErrorReporter.cpp index 405999b061d7..33ffbe9053c1 100644 --- a/layout/style/ErrorReporter.cpp +++ b/layout/style/ErrorReporter.cpp @@ -138,20 +138,12 @@ ErrorReporter::ReleaseGlobals() NS_IF_RELEASE(sSpecCache); } -ErrorReporter::ErrorReporter(const nsCSSScanner& aScanner, - const StyleSheet* aSheet, +ErrorReporter::ErrorReporter(const StyleSheet* aSheet, const Loader* aLoader, nsIURI* aURI) - : mScanner(&aScanner), mSheet(aSheet), mLoader(aLoader), mURI(aURI), - mInnerWindowID(0), mErrorLineNumber(0), mPrevErrorLineNumber(0), - mErrorColNumber(0) -{ -} - -ErrorReporter::ErrorReporter(const ServoStyleSheet* aSheet, - const Loader* aLoader, - nsIURI* aURI) - : mScanner(nullptr), mSheet(aSheet), mLoader(aLoader), mURI(aURI), + : mSheet(aSheet) + , mLoader(aLoader) + , mURI(aURI), mInnerWindowID(0), mErrorLineNumber(0), mPrevErrorLineNumber(0), mErrorColNumber(0) { @@ -288,23 +280,6 @@ ErrorReporter::AddToError(const nsString &aErrorText) if (mError.IsEmpty()) { mError = aErrorText; - // If this error reporter is being used from Stylo, the equivalent operation occurs - // in the OutputError variant that provides source information. - if (!IsServo()) { - mErrorLineNumber = mScanner->GetLineNumber(); - mErrorColNumber = mScanner->GetColumnNumber(); - // Retrieve the error line once per line, and reuse the same nsString - // for all errors on that line. That causes the text of the line to - // be shared among all the nsIScriptError objects. - if (mErrorLine.IsEmpty() || mErrorLineNumber != mPrevErrorLineNumber) { - // Be careful here: the error line might be really long and OOM - // when we try to make a copy here. If so, just leave it empty. - if (!mErrorLine.Assign(mScanner->GetCurrentLine(), fallible)) { - mErrorLine.Truncate(); - } - mPrevErrorLineNumber = mErrorLineNumber; - } - } } else { mError.AppendLiteral(" "); mError.Append(aErrorText); @@ -428,12 +403,6 @@ ErrorReporter::ReportUnexpectedEOF(char16_t aExpected) AddToError(str); } -bool -ErrorReporter::IsServo() const -{ - return !mScanner; -} - } // namespace css } // namespace mozilla diff --git a/layout/style/ErrorReporter.h b/layout/style/ErrorReporter.h index b66c19fa3e33..5c31b1b55d7e 100644 --- a/layout/style/ErrorReporter.h +++ b/layout/style/ErrorReporter.h @@ -15,7 +15,6 @@ #include "nsString.h" struct nsCSSToken; -class nsCSSScanner; class nsIURI; namespace mozilla { @@ -30,13 +29,9 @@ class Loader; // methods become inline stubs. class ErrorReporter { public: - ErrorReporter(const nsCSSScanner &aScanner, - const StyleSheet *aSheet, - const Loader *aLoader, - nsIURI *aURI); - ErrorReporter(const ServoStyleSheet *aSheet, - const Loader *aLoader, - nsIURI *aURI); + ErrorReporter(const StyleSheet* aSheet, + const Loader* aLoader, + nsIURI* aURI); ~ErrorReporter(); static void ReleaseGlobals(); @@ -75,13 +70,10 @@ public: private: void AddToError(const nsString &aErrorText); - bool IsServo() const; - #ifdef CSS_REPORT_PARSE_ERRORS nsAutoString mError; nsString mErrorLine; nsString mFileName; - const nsCSSScanner *mScanner; const StyleSheet *mSheet; const Loader *mLoader; nsIURI *mURI; @@ -93,8 +85,7 @@ private: }; #ifndef CSS_REPORT_PARSE_ERRORS -inline ErrorReporter::ErrorReporter(const nsCSSScanner&, - const StyleSheet*, +inline ErrorReporter::ErrorReporter(const StyleSheet*, const Loader*, nsIURI*) {} inline ErrorReporter::~ErrorReporter() {} diff --git a/layout/style/GenericSpecifiedValuesInlines.h b/layout/style/GenericSpecifiedValuesInlines.h index c20e305236b2..8be0a8f82f55 100644 --- a/layout/style/GenericSpecifiedValuesInlines.h +++ b/layout/style/GenericSpecifiedValuesInlines.h @@ -26,14 +26,10 @@ MOZ_DEFINE_STYLO_METHODS(GenericSpecifiedValues, bool GenericSpecifiedValues::ShouldIgnoreColors() const { - if (IsServo()) { - // Servo handles this during cascading. - // - // FIXME(emilio): We should eventually move it to the document though. - return false; - } - - MOZ_CRASH("old style system disabled"); + // Servo handles this during cascading. + // + // FIXME(emilio): We should eventually move it to the document though. + return false; } bool @@ -77,10 +73,7 @@ void GenericSpecifiedValues::SetKeywordValue(nsCSSPropertyID aId, int32_t aValue) { - if (IsServo()) { - return AsServo()->SetKeywordValue(aId, aValue); - } - MOZ_CRASH("old style system disabled"); + return AsServo()->SetKeywordValue(aId, aValue); } void diff --git a/layout/style/Loader.cpp b/layout/style/Loader.cpp index 0323c2bedf99..d08b438cb510 100644 --- a/layout/style/Loader.cpp +++ b/layout/style/Loader.cpp @@ -1204,7 +1204,7 @@ Loader::InsertChildSheet(StyleSheet* aSheet, LOG(("css::Loader::InsertChildSheet")); MOZ_ASSERT(aSheet, "Nothing to insert"); MOZ_ASSERT(aParentSheet, "Need a parent to insert into"); - MOZ_ASSERT(aSheet->IsGecko() == !!aGeckoParentRule); + MOZ_ASSERT(!aGeckoParentRule, "TODO remove this param"); // child sheets should always start out enabled, even if they got // cloned off of top-level sheets which were disabled @@ -2092,7 +2092,7 @@ Loader::LoadChildSheet(StyleSheet* aParentSheet, LOG(("css::Loader::LoadChildSheet")); NS_PRECONDITION(aURL, "Must have a URI to load"); NS_PRECONDITION(aParentSheet, "Must have a parent sheet"); - MOZ_ASSERT(aParentSheet->IsGecko() == !!aGeckoParentRule); + MOZ_ASSERT(!aGeckoParentRule, "TODO remove this param"); if (!mEnabled) { LOG_WARN((" Not enabled")); @@ -2158,9 +2158,6 @@ Loader::LoadChildSheet(StyleSheet* aParentSheet, RefPtr sheet; StyleSheetState state; if (aReusableSheets && aReusableSheets->FindReusableStyleSheet(aURL, sheet)) { - if (aParentSheet->IsGecko()) { - MOZ_CRASH("old style system disabled"); - } state = eSheetComplete; } else { bool isAlternate; diff --git a/layout/style/MediaList.h b/layout/style/MediaList.h index d5cedd6d7b58..deefece12bc4 100644 --- a/layout/style/MediaList.h +++ b/layout/style/MediaList.h @@ -57,10 +57,6 @@ public: virtual void SetText(const nsAString& aMediaText) = 0; virtual bool Matches(nsPresContext* aPresContext) const = 0; -#ifdef DEBUG - virtual bool IsServo() const = 0; -#endif - void SetStyleSheet(StyleSheet* aSheet); // WebIDL diff --git a/layout/style/ServoBindings.cpp b/layout/style/ServoBindings.cpp index ac7c54c2cce2..89e50d91b9a6 100644 --- a/layout/style/ServoBindings.cpp +++ b/layout/style/ServoBindings.cpp @@ -405,12 +405,6 @@ Gecko_GetStyleAttrDeclarationBlock(RawGeckoElementBorrowed aElement) if (!decl) { return nullptr; } - if (decl->IsGecko()) { - // XXX This can happen when nodes are adopted from a Gecko-style-backend - // document into a Servo-style-backend document. See bug 1330051. - NS_WARNING("stylo: requesting a Gecko declaration block?"); - return nullptr; - } return decl->AsServo()->RefRawStrong(); } @@ -421,12 +415,6 @@ Gecko_UnsetDirtyStyleAttr(RawGeckoElementBorrowed aElement) if (!decl) { return; } - if (decl->IsGecko()) { - // XXX This can happen when nodes are adopted from a Gecko-style-backend - // document into a Servo-style-backend document. See bug 1330051. - NS_WARNING("stylo: requesting a Gecko declaration block?"); - return; - } decl->UnsetDirty(); } diff --git a/layout/style/ServoMediaList.h b/layout/style/ServoMediaList.h index 4a4bae33348d..4e188b7c24c5 100644 --- a/layout/style/ServoMediaList.h +++ b/layout/style/ServoMediaList.h @@ -33,10 +33,6 @@ public: bool Matches(nsPresContext*) const final; -#ifdef DEBUG - bool IsServo() const final { return true; } -#endif - RawServoMediaList& RawList() { return *mRawList; } protected: diff --git a/layout/style/ServoStyleRule.cpp b/layout/style/ServoStyleRule.cpp index 2cd2464aeeea..cecd671132c6 100644 --- a/layout/style/ServoStyleRule.cpp +++ b/layout/style/ServoStyleRule.cpp @@ -72,8 +72,6 @@ ServoStyleRuleDeclaration::SetCSSDeclaration(DeclarationBlock* aDecl) { ServoStyleRule* rule = Rule(); if (RefPtr sheet = rule->GetStyleSheet()) { - MOZ_ASSERT(sheet->IsServo(), "Servo style rules should have " - "servo stylesheets."); nsCOMPtr doc = sheet->GetAssociatedDocument(); mozAutoDocUpdate updateBatch(doc, UPDATE_STYLE, true); if (aDecl != mDecls) { diff --git a/layout/style/ServoStyleSheet.cpp b/layout/style/ServoStyleSheet.cpp index f3d19d4d064c..46e1b1d6f802 100644 --- a/layout/style/ServoStyleSheet.cpp +++ b/layout/style/ServoStyleSheet.cpp @@ -208,7 +208,6 @@ ServoStyleSheet::ParseSheet(css::Loader* aLoader, { MOZ_ASSERT(mParsePromise.IsEmpty()); RefPtr p = mParsePromise.Ensure(__func__); - MOZ_ASSERT(!mMedia || mMedia->IsServo()); Inner()->mURLData = new URLExtraData(aBaseURI, aSheetURI, aSheetPrincipal); // RefPtr Inner()->mContents = Servo_StyleSheet_FromUTF8Bytes(aLoader, this, @@ -237,7 +236,6 @@ ServoStyleSheet::ParseSheetSync(css::Loader* aLoader, nsCompatibility aCompatMode, css::LoaderReusableStyleSheets* aReusableSheets) { - MOZ_ASSERT(!mMedia || mMedia->IsServo()); Inner()->mURLData = new URLExtraData(aBaseURI, aSheetURI, aSheetPrincipal); // RefPtr Inner()->mContents = Servo_StyleSheet_FromUTF8Bytes(aLoader, @@ -375,9 +373,6 @@ ServoStyleSheet::StyleSheetLoaded(StyleSheet* aSheet, bool aWasAlternate, nsresult aStatus) { - MOZ_ASSERT(aSheet->IsServo(), - "why we were called back with a CSSStyleSheet?"); - ServoStyleSheet* sheet = aSheet->AsServo(); if (!sheet->GetParentSheet()) { return NS_OK; // ignore if sheet has been detached already diff --git a/layout/style/ServoUtils.h b/layout/style/ServoUtils.h index 2fa12bfad68d..56021c7531fc 100644 --- a/layout/style/ServoUtils.h +++ b/layout/style/ServoUtils.h @@ -35,10 +35,6 @@ inline bool IsInServoTraversal() } } // namespace mozilla -# define MOZ_DECL_STYLO_CHECK_METHODS \ - bool IsGecko() const { return false; } \ - bool IsServo() const { return true; } - #define MOZ_DECL_STYLO_CONVERT_METHODS_SERVO(servotype_) \ inline servotype_* AsServo(); \ inline const servotype_* AsServo() const; \ @@ -59,39 +55,34 @@ inline bool IsInServoTraversal() * The class should define |StyleBackendType mType;| itself. */ #define MOZ_DECL_STYLO_METHODS(geckotype_, servotype_) \ - MOZ_DECL_STYLO_CHECK_METHODS \ MOZ_DECL_STYLO_CONVERT_METHODS(geckotype_, servotype_) #define MOZ_DEFINE_STYLO_METHODS_GECKO(type_, geckotype_) \ geckotype_* type_::AsGecko() { \ - MOZ_ASSERT(IsGecko()); \ return static_cast(this); \ } \ const geckotype_* type_::AsGecko() const { \ - MOZ_ASSERT(IsGecko()); \ return static_cast(this); \ } \ geckotype_* type_::GetAsGecko() { \ - return IsGecko() ? AsGecko() : nullptr; \ + return nullptr; \ } \ const geckotype_* type_::GetAsGecko() const { \ - return IsGecko() ? AsGecko() : nullptr; \ + return nullptr; \ } #define MOZ_DEFINE_STYLO_METHODS_SERVO(type_, servotype_) \ servotype_* type_::AsServo() { \ - MOZ_ASSERT(IsServo()); \ return static_cast(this); \ } \ const servotype_* type_::AsServo() const { \ - MOZ_ASSERT(IsServo()); \ return static_cast(this); \ } \ servotype_* type_::GetAsServo() { \ - return IsServo() ? AsServo() : nullptr; \ + return AsServo(); \ } \ const servotype_* type_::GetAsServo() const { \ - return IsServo() ? AsServo() : nullptr; \ + return AsServo(); \ } diff --git a/layout/style/StreamLoader.cpp b/layout/style/StreamLoader.cpp index 8cb5a8cfa101..9e7051896560 100644 --- a/layout/style/StreamLoader.cpp +++ b/layout/style/StreamLoader.cpp @@ -20,7 +20,6 @@ StreamLoader::StreamLoader(mozilla::css::SheetLoadData* aSheetLoadData) : mSheetLoadData(aSheetLoadData) , mStatus(NS_OK) { - MOZ_ASSERT(!aSheetLoadData->mSheet->IsGecko()); } StreamLoader::~StreamLoader() diff --git a/layout/style/StyleSetHandle.h b/layout/style/StyleSetHandle.h index 73f9e4dc00ab..727a669dd790 100644 --- a/layout/style/StyleSetHandle.h +++ b/layout/style/StyleSetHandle.h @@ -43,8 +43,6 @@ namespace css { class Rule; } // namespace css -#define SERVO_BIT 0x1 - /** * Smart pointer class that can hold a pointer to either an nsStyleSet * or a ServoStyleSet. @@ -61,40 +59,26 @@ public: public: friend class ::mozilla::StyleSetHandle; - bool IsGecko() const - { - return false; - } - - bool IsServo() const - { - MOZ_ASSERT(mValue, "StyleSetHandle null pointer dereference"); - return mValue & SERVO_BIT; - } - StyleBackendType BackendType() const { - return IsGecko() ? StyleBackendType::Gecko : - StyleBackendType::Servo; + return StyleBackendType::Servo; } ServoStyleSet* AsServo() { - MOZ_ASSERT(IsServo()); - return reinterpret_cast(mValue & ~SERVO_BIT); + return reinterpret_cast(mValue); } - ServoStyleSet* GetAsServo() { return IsServo() ? AsServo() : nullptr; } + ServoStyleSet* GetAsServo() { return AsServo(); } const ServoStyleSet* AsServo() const { - MOZ_ASSERT(IsServo()); return const_cast(this)->AsServo(); } - const ServoStyleSet* GetAsServo() const { return IsServo() ? AsServo() : nullptr; } + const ServoStyleSet* GetAsServo() const { return AsServo(); } // These inline methods are defined in StyleSetHandleInlines.h. inline void Delete(); @@ -178,8 +162,6 @@ public: inline already_AddRefed ProbePseudoElementStyle(dom::Element* aParentElement, mozilla::CSSPseudoElementType aType); - inline void RootComputedStyleAdded(); - inline void RootComputedStyleRemoved(); inline bool AppendFontFaceRules(nsTArray& aArray); inline nsCSSCounterStyleRule* CounterStyleRuleForName(nsAtom* aName); @@ -203,18 +185,14 @@ public: StyleSetHandle& operator=(nsStyleSet* aStyleSet) { - MOZ_ASSERT(!(reinterpret_cast(aStyleSet) & SERVO_BIT), - "least significant bit shouldn't be set; we use it for state"); mPtr.mValue = reinterpret_cast(aStyleSet); return *this; } StyleSetHandle& operator=(ServoStyleSet* aStyleSet) { - MOZ_ASSERT(!(reinterpret_cast(aStyleSet) & SERVO_BIT), - "least significant bit shouldn't be set; we use it for state"); mPtr.mValue = - aStyleSet ? (reinterpret_cast(aStyleSet) | SERVO_BIT) : 0; + aStyleSet ? reinterpret_cast(aStyleSet) : 0; return *this; } @@ -235,8 +213,6 @@ private: Ptr mPtr; }; -#undef SERVO_BIT - } // namespace mozilla #endif // mozilla_StyleSetHandle_h diff --git a/layout/style/StyleSetHandleInlines.h b/layout/style/StyleSetHandleInlines.h index dffa5aad45c5..462d157c8333 100644 --- a/layout/style/StyleSetHandleInlines.h +++ b/layout/style/StyleSetHandleInlines.h @@ -25,9 +25,6 @@ void StyleSetHandle::Ptr::Delete() { if (mValue) { - if (IsGecko()) { - MOZ_CRASH("old style system disabled"); - } delete AsServo(); } } @@ -161,10 +158,6 @@ nsresult StyleSetHandle::Ptr::ReplaceSheets(SheetType aType, const nsTArray>& aNewSheets) { - if (IsGecko()) { - MOZ_CRASH("old style system disabled"); - } - nsTArray> newSheets(aNewSheets.Length()); for (auto& sheet : aNewSheets) { newSheets.AppendElement(sheet->AsServo()); @@ -276,26 +269,6 @@ StyleSetHandle::Ptr::ProbePseudoElementStyle(dom::Element* aParentElement, FORWARD(ProbePseudoElementStyle, (aParentElement, aType, aParentStyle)); } -void -StyleSetHandle::Ptr::RootComputedStyleAdded() -{ - if (IsGecko()) { - MOZ_CRASH("old style system disabled"); - } - - // Not needed. -} - -void -StyleSetHandle::Ptr::RootComputedStyleRemoved() -{ - if (IsGecko()) { - MOZ_CRASH("old style system disabled"); - } - - // Not needed. -} - bool StyleSetHandle::Ptr:: AppendFontFaceRules(nsTArray& aArray) diff --git a/layout/style/StyleSheet.cpp b/layout/style/StyleSheet.cpp index eade1a50e586..d301842232cd 100644 --- a/layout/style/StyleSheet.cpp +++ b/layout/style/StyleSheet.cpp @@ -80,11 +80,7 @@ StyleSheet::LastRelease() MOZ_ASSERT(mInner->mSheets.Contains(this), "Our mInner should include us."); UnparentChildren(); - if (IsGecko()) { - MOZ_CRASH("old style system disabled"); - } else { - AsServo()->LastRelease(); - } + AsServo()->LastRelease(); mInner->RemoveSheet(this); mInner = nullptr; @@ -397,14 +393,10 @@ StyleSheet::EnsureUniqueInner() mInner->RemoveSheet(this); mInner = clone; - if (IsGecko()) { - MOZ_CRASH("old style system disabled"); - } else { - // Fixup the child lists and parent links in the Servo sheet. This is done - // here instead of in StyleSheetInner::CloneFor, because it's just more - // convenient to do so instead. - AsServo()->BuildChildListAfterInnerClone(); - } + // Fixup the child lists and parent links in the Servo sheet. This is done + // here instead of in StyleSheetInner::CloneFor, because it's just more + // convenient to do so instead. + AsServo()->BuildChildListAfterInnerClone(); // let our containing style sets know that if we call // nsPresContext::EnsureSafeToHandOutCSSRules we will need to restyle the @@ -425,10 +417,7 @@ StyleSheet::AppendAllChildSheets(nsTArray& aArray) // WebIDL CSSStyleSheet API #define FORWARD_INTERNAL(method_, args_) \ - if (IsServo()) { \ - return AsServo()->method_ args_; \ - } \ - MOZ_CRASH("old style system disabled"); + return AsServo()->method_ args_; dom::CSSRuleList* StyleSheet::GetCssRules(nsIPrincipal& aSubjectPrincipal, @@ -604,12 +593,8 @@ StyleSheet::InsertRuleIntoGroup(const nsAString& aRule, WillDirty(); - nsresult result; - if (IsGecko()) { - MOZ_CRASH("old style system disabled"); - } else { - result = AsServo()->InsertRuleIntoGroupInternal(aRule, aGroup, aIndex); - } + nsresult result = + AsServo()->InsertRuleIntoGroupInternal(aRule, aGroup, aIndex); NS_ENSURE_SUCCESS(result, result); RuleAdded(*aGroup->GetStyleRuleAt(aIndex)); diff --git a/layout/style/nsCSSCounterStyleRule.cpp b/layout/style/nsCSSCounterStyleRule.cpp index c6385c690130..94c1908bc97d 100644 --- a/layout/style/nsCSSCounterStyleRule.cpp +++ b/layout/style/nsCSSCounterStyleRule.cpp @@ -383,19 +383,12 @@ nsCSSCounterStyleRule::SetDescriptor(nsCSSCounterDesc aDescID, const nsAString& aValue) { nsCSSValue value; - bool ok; StyleSheet* sheet = GetStyleSheet(); - bool useServo = !sheet || sheet->IsServo(); - - if (useServo) { - URLExtraData* data = sheet ? sheet->AsServo()->URLData() : nullptr; - ok = ServoCSSParser::ParseCounterStyleDescriptor(aDescID, aValue, data, - value); - } else { - MOZ_CRASH("old style system disabled"); - } + URLExtraData* data = sheet ? sheet->AsServo()->URLData() : nullptr; + bool ok = ServoCSSParser::ParseCounterStyleDescriptor(aDescID, aValue, data, + value); if (ok && CheckDescValue(GetSystem(), aDescID, value)) { SetDesc(aDescID, value); diff --git a/layout/style/nsDOMCSSDeclaration.cpp b/layout/style/nsDOMCSSDeclaration.cpp index bab0a9cc7892..260a70a3c59d 100644 --- a/layout/style/nsDOMCSSDeclaration.cpp +++ b/layout/style/nsDOMCSSDeclaration.cpp @@ -121,21 +121,17 @@ nsDOMCSSDeclaration::SetCssText(const nsAString& aCssText, // rule (see stack in bug 209575). mozAutoDocConditionalContentUpdateBatch autoUpdate(DocToUpdate(), true); - RefPtr newdecl; - if (olddecl->IsServo()) { - ServoCSSParsingEnvironment servoEnv = GetServoCSSParsingEnvironment( - aSubjectPrincipal); - if (!servoEnv.mUrlExtraData) { - aRv.Throw(NS_ERROR_NOT_AVAILABLE); - return; - } - - newdecl = ServoDeclarationBlock::FromCssText(aCssText, servoEnv.mUrlExtraData, - servoEnv.mCompatMode, servoEnv.mLoader); - } else { - MOZ_CRASH("old style system disabled"); + ServoCSSParsingEnvironment servoEnv = + GetServoCSSParsingEnvironment(aSubjectPrincipal); + if (!servoEnv.mUrlExtraData) { + aRv.Throw(NS_ERROR_NOT_AVAILABLE); + return; } + RefPtr newdecl = + ServoDeclarationBlock::FromCssText(aCssText, servoEnv.mUrlExtraData, + servoEnv.mCompatMode, servoEnv.mLoader); + aRv = SetCSSDeclaration(newdecl); } @@ -295,17 +291,14 @@ nsDOMCSSDeclaration::ModifyDeclaration(nsIPrincipal* aSubjectPrincipal, RefPtr decl = olddecl->EnsureMutable(); bool changed; - if (decl->IsGecko()) { - MOZ_CRASH("old style system disabled"); - } else { - ServoCSSParsingEnvironment servoEnv = GetServoCSSParsingEnvironment( - aSubjectPrincipal); - if (!servoEnv.mUrlExtraData) { - return NS_ERROR_NOT_AVAILABLE; - } - - changed = aServoFunc(decl->AsServo(), servoEnv); + ServoCSSParsingEnvironment servoEnv = GetServoCSSParsingEnvironment( + aSubjectPrincipal); + if (!servoEnv.mUrlExtraData) { + return NS_ERROR_NOT_AVAILABLE; } + + changed = aServoFunc(decl->AsServo(), servoEnv); + if (!changed) { // Parsing failed -- but we don't throw an exception for that. return NS_OK; diff --git a/layout/style/nsHTMLStyleSheet.cpp b/layout/style/nsHTMLStyleSheet.cpp index 9e13015c5fc4..d52176a540cd 100644 --- a/layout/style/nsHTMLStyleSheet.cpp +++ b/layout/style/nsHTMLStyleSheet.cpp @@ -116,14 +116,10 @@ nsHTMLStyleSheet::ImplLinkColorSetter( RestyleManager* restyle = mDocument->GetPresContext()->RestyleManager(); - if (restyle->IsServo()) { - MOZ_ASSERT(!ServoStyleSet::IsInServoTraversal()); - aDecl = Servo_DeclarationBlock_CreateEmpty().Consume(); - Servo_DeclarationBlock_SetColorValue(aDecl.get(), eCSSProperty_color, - aColor); - } else { - MOZ_CRASH("old style system disabled"); - } + MOZ_ASSERT(!ServoStyleSet::IsInServoTraversal()); + aDecl = Servo_DeclarationBlock_CreateEmpty().Consume(); + Servo_DeclarationBlock_SetColorValue(aDecl.get(), eCSSProperty_color, + aColor); // Now make sure we restyle any links that might need it. This // shouldn't happen often, so just rebuilding everything is ok. diff --git a/layout/style/nsLayoutStylesheetCache.cpp b/layout/style/nsLayoutStylesheetCache.cpp index 99a524326bdf..d5116a0256fb 100644 --- a/layout/style/nsLayoutStylesheetCache.cpp +++ b/layout/style/nsLayoutStylesheetCache.cpp @@ -820,67 +820,6 @@ nsLayoutStylesheetCache::LoadSheet(nsIURI* aURI, } } -/* static */ void -nsLayoutStylesheetCache::InvalidateSheet(RefPtr* aGeckoSheet, - RefPtr* aServoSheet) -{ - MOZ_ASSERT(gCSSLoader_Gecko || gCSSLoader_Servo, - "pref changed before we loaded a sheet?"); - - const bool gotGeckoSheet = aGeckoSheet && *aGeckoSheet; - const bool gotServoSheet = aServoSheet && *aServoSheet; - - // Make sure sheets have the expected types - MOZ_ASSERT(!gotGeckoSheet || (*aGeckoSheet)->IsGecko()); - MOZ_ASSERT(!gotServoSheet || (*aServoSheet)->IsServo()); - // Make sure the URIs match - MOZ_ASSERT(!gotServoSheet || !gotGeckoSheet || - (*aGeckoSheet)->GetSheetURI() == (*aServoSheet)->GetSheetURI(), - "Sheets passed should have the same URI"); - - nsIURI* uri; - if (gotGeckoSheet) { - uri = (*aGeckoSheet)->GetSheetURI(); - } else if (gotServoSheet) { - uri = (*aServoSheet)->GetSheetURI(); - } else { - return; - } - - if (gCSSLoader_Gecko) { - gCSSLoader_Gecko->ObsoleteSheet(uri); - } - if (gCSSLoader_Servo) { - gCSSLoader_Servo->ObsoleteSheet(uri); - } - if (gotGeckoSheet) { - *aGeckoSheet = nullptr; - } - if (gotServoSheet) { - *aServoSheet = nullptr; - } -} - -/* static */ void -nsLayoutStylesheetCache::DependentPrefChanged(const char* aPref, void* aData) -{ - MOZ_ASSERT(gStyleCache_Gecko || gStyleCache_Servo, - "pref changed after shutdown?"); - - // Cause any UA style sheets whose parsing depends on the value of prefs - // to be re-parsed by dropping the sheet from gCSSLoader_{Gecko,Servo}'s cache - // then setting our cached sheet pointer to null. This will only work for - // sheets that are loaded lazily. - -#define INVALIDATE(sheet_) \ - InvalidateSheet(gStyleCache_Gecko ? &gStyleCache_Gecko->sheet_ : nullptr, \ - gStyleCache_Servo ? &gStyleCache_Servo->sheet_ : nullptr); - - // INVALIDATE(mUASheet); // for layout.css.example-pref.enabled - -#undef INVALIDATE -} - /* static */ void nsLayoutStylesheetCache::InvalidatePreferenceSheets() { @@ -998,14 +937,10 @@ nsLayoutStylesheetCache::BuildPreferenceSheet(RefPtr* aSheet, "kPreallocSize should be big enough to build preference style " "sheet without reallocation"); - if (sheet->IsGecko()) { - MOZ_CRASH("old style system disabled"); - } else { - ServoStyleSheet* servoSheet = sheet->AsServo(); - // NB: The pref sheet never has @import rules. - servoSheet->ParseSheetSync( - nullptr, sheetText, uri, uri, nullptr, /* aLoadData = */ nullptr, 0, eCompatibility_FullStandards); - } + ServoStyleSheet* servoSheet = sheet->AsServo(); + // NB: The pref sheet never has @import rules. + servoSheet->ParseSheetSync( + nullptr, sheetText, uri, uri, nullptr, /* aLoadData = */ nullptr, 0, eCompatibility_FullStandards); #undef NS_GET_R_G_B } diff --git a/layout/style/nsLayoutStylesheetCache.h b/layout/style/nsLayoutStylesheetCache.h index 3f618e729ca8..0cbeba4025c6 100644 --- a/layout/style/nsLayoutStylesheetCache.h +++ b/layout/style/nsLayoutStylesheetCache.h @@ -100,9 +100,6 @@ private: void LoadSheet(nsIURI* aURI, RefPtr* aSheet, mozilla::css::SheetParsingMode aParsingMode, mozilla::css::FailureAction aFailureAction); - static void InvalidateSheet(RefPtr* aGeckoSheet, - RefPtr* aServoSheet); - static void DependentPrefChanged(const char* aPref, void* aData); void BuildPreferenceSheet(RefPtr* aSheet, nsPresContext* aPresContext); diff --git a/layout/style/nsStyleStruct.cpp b/layout/style/nsStyleStruct.cpp index f8a230a380f3..21a7f05fda07 100644 --- a/layout/style/nsStyleStruct.cpp +++ b/layout/style/nsStyleStruct.cpp @@ -396,7 +396,6 @@ void nsStyleBorder::FinishStyle(nsPresContext* aPresContext, const nsStyleBorder* aOldStyle) { MOZ_ASSERT(NS_IsMainThread()); - MOZ_ASSERT(aPresContext->StyleSet()->IsServo()); mBorderImageSource.ResolveImage( aPresContext, aOldStyle ? &aOldStyle->mBorderImageSource : nullptr); @@ -617,7 +616,6 @@ void nsStyleList::FinishStyle(nsPresContext* aPresContext, const nsStyleList* aOldStyle) { MOZ_ASSERT(NS_IsMainThread()); - MOZ_ASSERT(aPresContext->StyleSet()->IsServo()); if (mListStyleImage && !mListStyleImage->IsResolved()) { mListStyleImage->Resolve( @@ -1305,7 +1303,6 @@ void nsStyleSVGReset::FinishStyle(nsPresContext* aPresContext, const nsStyleSVGReset* aOldStyle) { MOZ_ASSERT(NS_IsMainThread()); - MOZ_ASSERT(aPresContext->StyleSet()->IsServo()); NS_FOR_VISIBLE_IMAGE_LAYERS_BACK_TO_FRONT(i, mMask) { nsStyleImage& image = mMask.mLayers[i].mImage; @@ -3373,7 +3370,6 @@ nsStyleBackground::FinishStyle( nsPresContext* aPresContext, const nsStyleBackground* aOldStyle) { MOZ_ASSERT(NS_IsMainThread()); - MOZ_ASSERT(aPresContext->StyleSet()->IsServo()); mImage.ResolveImages(aPresContext, aOldStyle ? &aOldStyle->mImage : nullptr); } @@ -3753,7 +3749,6 @@ nsStyleDisplay::FinishStyle( nsPresContext* aPresContext, const nsStyleDisplay* aOldStyle) { MOZ_ASSERT(NS_IsMainThread()); - MOZ_ASSERT(aPresContext->StyleSet()->IsServo()); if (mShapeOutside.GetType() == StyleShapeSourceType::Image) { const UniquePtr& shapeImage = mShapeOutside.GetShapeImage(); @@ -4677,7 +4672,6 @@ nsStyleUserInterface::FinishStyle( nsPresContext* aPresContext, const nsStyleUserInterface* aOldStyle) { MOZ_ASSERT(NS_IsMainThread()); - MOZ_ASSERT(aPresContext->StyleSet()->IsServo()); for (size_t i = 0; i < mCursorImages.Length(); ++i) { nsCursorImage& cursor = mCursorImages[i];