From 425dc7f02b6cc488e32c8ec762c100d3313d7ea7 Mon Sep 17 00:00:00 2001 From: FranklinDM Date: Mar 25 2024 17:25:53 +0000 Subject: Issue #2112 - Part 9: Remove handling for multiple style backends --- diff --git a/dom/animation/KeyframeUtils.cpp b/dom/animation/KeyframeUtils.cpp index a89e954..1285611 100644 --- a/dom/animation/KeyframeUtils.cpp +++ b/dom/animation/KeyframeUtils.cpp @@ -318,7 +318,7 @@ public: // ------------------------------------------------------------------ inline bool -IsInvalidValuePair(const PropertyValuePair& aPair, StyleBackendType aBackend) +IsInvalidValuePair(const PropertyValuePair& aPair) { // There are three types of values we store as token streams: // @@ -595,8 +595,6 @@ KeyframeUtils::GetComputedKeyframeValues(const nsTArray& aKeyframes, MOZ_ASSERT(aStyleContext); MOZ_ASSERT(aElement); - StyleBackendType styleBackend = aElement->OwnerDoc()->GetStyleBackendType(); - const size_t len = aKeyframes.Length(); nsTArray result(len); @@ -605,7 +603,7 @@ KeyframeUtils::GetComputedKeyframeValues(const nsTArray& aKeyframes, ComputedKeyframeValues* computedValues = result.AppendElement(); for (const PropertyValuePair& pair : PropertyPriorityIterator(frame.mPropertyValues)) { - if (IsInvalidValuePair(pair, styleBackend)) { + if (IsInvalidValuePair(pair)) { continue; } @@ -1363,8 +1361,6 @@ HasImplicitKeyframeValues(const nsTArray& aKeyframes, } }; - StyleBackendType styleBackend = aDocument->GetStyleBackendType(); - for (size_t i = 0, len = aKeyframes.Length(); i < len; i++) { const Keyframe& frame = aKeyframes[i]; @@ -1380,7 +1376,7 @@ HasImplicitKeyframeValues(const nsTArray& aKeyframes, : computedOffset; for (const PropertyValuePair& pair : frame.mPropertyValues) { - if (IsInvalidValuePair(pair, styleBackend)) { + if (IsInvalidValuePair(pair)) { continue; } diff --git a/dom/base/nsDocument.cpp b/dom/base/nsDocument.cpp index 844f298..a4c2b48 100644 --- a/dom/base/nsDocument.cpp +++ b/dom/base/nsDocument.cpp @@ -2108,21 +2108,16 @@ nsDocument::ResetStylesheetsToURI(nsIURI* aURI) mozAutoDocUpdate upd(this, UPDATE_STYLE, true); if (mStyleSetFilled) { // Skip removing style sheets from the style set if we know we haven't - // filled the style set. (This allows us to avoid calling - // GetStyleBackendType() too early.) + // filled the style set. RemoveDocStyleSheetsFromStyleSets(); RemoveStyleSheetsFromStyleSets(mOnDemandBuiltInUASheets, SheetType::Agent); RemoveStyleSheetsFromStyleSets(mAdditionalSheets[eAgentSheet], SheetType::Agent); RemoveStyleSheetsFromStyleSets(mAdditionalSheets[eUserSheet], SheetType::User); RemoveStyleSheetsFromStyleSets(mAdditionalSheets[eAuthorSheet], SheetType::Doc); - if (GetStyleBackendType() == StyleBackendType::Gecko) { - nsStyleSheetService *sheetService = nsStyleSheetService::GetInstance(); - if (sheetService) { - RemoveStyleSheetsFromStyleSets(*sheetService->AuthorStyleSheets(), SheetType::Doc); - } - } else { - NS_ERROR("stylo: nsStyleSheetService doesn't handle ServoStyleSheets yet"); + nsStyleSheetService *sheetService = nsStyleSheetService::GetInstance(); + if (sheetService) { + RemoveStyleSheetsFromStyleSets(*sheetService->AuthorStyleSheets(), SheetType::Doc); } mStyleSetFilled = false; @@ -12211,16 +12206,6 @@ nsIDocument::ReportHasScrollLinkedEffect() "ScrollLinkedEffectFound2"); } -void -nsIDocument::UpdateStyleBackendType() -{ - MOZ_ASSERT(mStyleBackendType == StyleBackendType(0), - "no need to call UpdateStyleBackendType now"); - - // Assume Gecko by default. - mStyleBackendType = StyleBackendType::Gecko; -} - Selection* nsIDocument::GetSelection(ErrorResult& aRv) { diff --git a/dom/base/nsIDocument.h b/dom/base/nsIDocument.h index e6def66..5608973 100644 --- a/dom/base/nsIDocument.h +++ b/dom/base/nsIDocument.h @@ -34,7 +34,6 @@ #include "mozilla/CORSMode.h" #include "mozilla/dom/DocumentOrShadowRoot.h" #include "mozilla/LinkedList.h" -#include "mozilla/StyleBackendType.h" #include "mozilla/StyleSheet.h" #include "mozilla/TimeStamp.h" #include // for member @@ -1148,16 +1147,6 @@ public: return mCSSLoader; } - mozilla::StyleBackendType GetStyleBackendType() const { - if (mStyleBackendType == mozilla::StyleBackendType(0)) { - const_cast(this)->UpdateStyleBackendType(); - } - MOZ_ASSERT(mStyleBackendType != mozilla::StyleBackendType(0)); - return mStyleBackendType; - } - - void UpdateStyleBackendType(); - /** * Get this document's StyleImageLoader. This is guaranteed to not return null. */ @@ -2975,10 +2964,6 @@ protected: uint32_t mDummy; #endif - // Whether this document has (or will have, once we have a pres shell) a - // Gecko- or Servo-backed style system. - mozilla::StyleBackendType mStyleBackendType; - // True if BIDI is enabled. bool mBidiEnabled : 1; // True if a MathML element has ever been owned by this document. diff --git a/layout/base/RestyleManagerHandle.h b/layout/base/RestyleManagerHandle.h index 2f6467a..9087347 100644 --- a/layout/base/RestyleManagerHandle.h +++ b/layout/base/RestyleManagerHandle.h @@ -10,7 +10,6 @@ #include "mozilla/EventStates.h" #include "mozilla/HandleRefPtr.h" #include "mozilla/RefCountType.h" -#include "mozilla/StyleBackendType.h" #include "nsChangeHint.h" namespace mozilla { @@ -48,11 +47,6 @@ public: public: friend class ::mozilla::RestyleManagerHandle; - StyleBackendType BackendType() const - { - return StyleBackendType::Gecko; - } - RestyleManager* AsGecko() { return reinterpret_cast(mValue); diff --git a/layout/base/nsLayoutUtils.cpp b/layout/base/nsLayoutUtils.cpp index 62b3d89..4f78acb 100644 --- a/layout/base/nsLayoutUtils.cpp +++ b/layout/base/nsLayoutUtils.cpp @@ -9115,14 +9115,6 @@ nsLayoutUtils::GetCumulativeApzCallbackTransform(nsIFrame* aFrame) return delta; } -/* static */ bool -nsLayoutUtils::SupportsServoStyleBackend(nsIDocument* aDocument) -{ - return StyloEnabled() && - aDocument->IsHTMLOrXHTML() && - static_cast(aDocument)->IsContentDocument(); -} - static bool LineHasNonEmptyContentWorker(nsIFrame* aFrame) diff --git a/layout/base/nsLayoutUtils.h b/layout/base/nsLayoutUtils.h index 29cd655..7d2b6f6 100644 --- a/layout/base/nsLayoutUtils.h +++ b/layout/base/nsLayoutUtils.h @@ -2379,13 +2379,6 @@ public: return sTextCombineUprightDigitsEnabled; } - // Stylo (the Servo backend for Gecko's style system) is generally enabled - // or disabled at compile-time. However, we provide the additional capability - // to disable it dynamically in stylo-enabled builds via a pref. - static bool StyloEnabled() { - return false; - } - static uint32_t IdlePeriodDeadlineLimit() { return sIdlePeriodDeadlineLimit; } @@ -2814,14 +2807,6 @@ public: static CSSPoint GetCumulativeApzCallbackTransform(nsIFrame* aFrame); /* - * Returns whether the given document supports being rendered with a - * Servo-backed style system. This checks whether Stylo is enabled - * globally, that the document is an HTML document, and that it is - * being presented in a content docshell. - */ - static bool SupportsServoStyleBackend(nsIDocument* aDocument); - - /* * Checks whether a node is an invisible break. * If not, returns the first frame on the next line if such a next line exists. * diff --git a/layout/base/nsPresContext.cpp b/layout/base/nsPresContext.cpp index ef62a32..92fab43 100644 --- a/layout/base/nsPresContext.cpp +++ b/layout/base/nsPresContext.cpp @@ -891,7 +891,7 @@ nsPresContext::Init(nsDeviceContext* aDeviceContext) // Note: We don't hold a reference on the shell; it has a reference to // us void -nsPresContext::AttachShell(nsIPresShell* aShell, StyleBackendType aBackendType) +nsPresContext::AttachShell(nsIPresShell* aShell) { MOZ_ASSERT(!mShell); mShell = aShell; diff --git a/layout/base/nsPresContext.h b/layout/base/nsPresContext.h index 05edfc0..062ebff 100644 --- a/layout/base/nsPresContext.h +++ b/layout/base/nsPresContext.h @@ -42,7 +42,6 @@ #include "mozilla/RestyleManagerHandle.h" #include "prenv.h" #include "mozilla/StaticPresData.h" -#include "mozilla/StyleBackendType.h" class nsAString; class nsIPrintSettings; @@ -169,7 +168,7 @@ public: * Set and detach presentation shell that this context is bound to. * A presentation context may only be bound to a single shell. */ - void AttachShell(nsIPresShell* aShell, mozilla::StyleBackendType aBackendType); + void AttachShell(nsIPresShell* aShell); void DetachShell(); diff --git a/layout/base/nsPresShell.cpp b/layout/base/nsPresShell.cpp index 122e3ae..cd40bd2 100644 --- a/layout/base/nsPresShell.cpp +++ b/layout/base/nsPresShell.cpp @@ -34,7 +34,6 @@ #include "mozilla/TouchEvents.h" #include "mozilla/UniquePtr.h" #include "mozilla/Unused.h" -#include "mozilla/StyleBackendType.h" #include #ifdef XP_WIN @@ -887,8 +886,7 @@ PresShell::Init(nsIDocument* aDocument, // Bind the context to the presentation shell. mPresContext = aPresContext; - StyleBackendType backend = StyleBackendType::Gecko; - aPresContext->AttachShell(this, backend); + aPresContext->AttachShell(this); // Now we can initialize the style set. Make sure to set the member before // calling Init, since various subroutines need to find the style set off diff --git a/layout/style/CSS.cpp b/layout/style/CSS.cpp index 1078945..49ea6ee 100644 --- a/layout/style/CSS.cpp +++ b/layout/style/CSS.cpp @@ -24,7 +24,6 @@ struct SupportsParsingInfo nsIURI* mDocURI; nsIURI* mBaseURI; nsIPrincipal* mPrincipal; - StyleBackendType mStyleBackendType; }; static nsresult @@ -44,7 +43,6 @@ GetParsingInfo(const GlobalObject& aGlobal, aInfo.mDocURI = nsCOMPtr(doc->GetDocumentURI()).get(); aInfo.mBaseURI = nsCOMPtr(doc->GetBaseURI()).get(); aInfo.mPrincipal = win->GetPrincipal(); - aInfo.mStyleBackendType = doc->GetStyleBackendType(); return NS_OK; } diff --git a/layout/style/CSSStyleSheet.cpp b/layout/style/CSSStyleSheet.cpp index 7c9e433..1cb99ec 100644 --- a/layout/style/CSSStyleSheet.cpp +++ b/layout/style/CSSStyleSheet.cpp @@ -1083,7 +1083,7 @@ CSSStyleSheetInner::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const CSSStyleSheet::CSSStyleSheet(css::SheetParsingMode aParsingMode, CORSMode aCORSMode, ReferrerPolicy aReferrerPolicy) - : StyleSheet(StyleBackendType::Gecko, aParsingMode), + : StyleSheet(aParsingMode), mParent(nullptr), mOwnerRule(nullptr), mDirty(false), @@ -1099,7 +1099,7 @@ CSSStyleSheet::CSSStyleSheet(css::SheetParsingMode aParsingMode, CORSMode aCORSMode, ReferrerPolicy aReferrerPolicy, const SRIMetadata& aIntegrity) - : StyleSheet(StyleBackendType::Gecko, aParsingMode), + : StyleSheet(aParsingMode), mParent(nullptr), mOwnerRule(nullptr), mDirty(false), diff --git a/layout/style/Declaration.h b/layout/style/Declaration.h index a18c38b..e3ab955 100644 --- a/layout/style/Declaration.h +++ b/layout/style/Declaration.h @@ -92,7 +92,7 @@ public: * |mData|) and cannot be used until its |CompressFrom| method or * |InitializeEmpty| method is called. */ - Declaration() : DeclarationBlock(StyleBackendType::Gecko) {} + Declaration() : DeclarationBlock() {} Declaration(const Declaration& aCopy); diff --git a/layout/style/DeclarationBlock.h b/layout/style/DeclarationBlock.h index 6a10c59..9a0c9db 100644 --- a/layout/style/DeclarationBlock.h +++ b/layout/style/DeclarationBlock.h @@ -12,7 +12,6 @@ #define mozilla_DeclarationBlock_h #include "mozilla/ServoUtils.h" -#include "mozilla/StyleBackendType.h" #include "nsCSSPropertyID.h" @@ -30,11 +29,11 @@ class Rule; class DeclarationBlock { protected: - explicit DeclarationBlock(StyleBackendType aType) - : mImmutable(false), mType(aType) { mContainer.mRaw = 0; } + explicit DeclarationBlock() + : mImmutable(false) { mContainer.mRaw = 0; } DeclarationBlock(const DeclarationBlock& aCopy) - : DeclarationBlock(aCopy.mType) {} + : DeclarationBlock() {} public: MOZ_DECL_STYLO_METHODS(css::Declaration) @@ -136,8 +135,6 @@ private: // set when declaration put in the rule tree; // also by ToString (hence the 'mutable'). mutable bool mImmutable; - - const StyleBackendType mType; }; } // namespace mozilla diff --git a/layout/style/ServoDeclarationBlock.h b/layout/style/ServoDeclarationBlock.h index 2cf7b16..ccc05d6 100644 --- a/layout/style/ServoDeclarationBlock.h +++ b/layout/style/ServoDeclarationBlock.h @@ -59,7 +59,7 @@ public: protected: explicit ServoDeclarationBlock( already_AddRefed aRaw) - : DeclarationBlock(StyleBackendType::Servo), mRaw(aRaw) {} + : DeclarationBlock(), mRaw(aRaw) {} private: ~ServoDeclarationBlock() {} diff --git a/layout/style/ServoStyleSheet.cpp b/layout/style/ServoStyleSheet.cpp index dc9fc34..daec2f8 100644 --- a/layout/style/ServoStyleSheet.cpp +++ b/layout/style/ServoStyleSheet.cpp @@ -5,7 +5,6 @@ #include "ServoBindings.h" #include "mozilla/ServoStyleSheet.h" -#include "mozilla/StyleBackendType.h" #include "CSSRuleList.h" using namespace mozilla::dom; @@ -16,7 +15,7 @@ ServoStyleSheet::ServoStyleSheet(css::SheetParsingMode aParsingMode, CORSMode aCORSMode, net::ReferrerPolicy aReferrerPolicy, const dom::SRIMetadata& aIntegrity) - : StyleSheet(StyleBackendType::Servo, aParsingMode) + : StyleSheet(aParsingMode) , mSheetInfo(aCORSMode, aReferrerPolicy, aIntegrity) { } diff --git a/layout/style/StyleBackendType.h b/layout/style/StyleBackendType.h deleted file mode 100644 index 99d5c15..0000000 --- a/layout/style/StyleBackendType.h +++ /dev/null @@ -1,22 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef mozilla_StyleBackendType_h -#define mozilla_StyleBackendType_h - -namespace mozilla { - -/** - * Enumeration that represents one of the two supported style system backends. - */ -enum class StyleBackendType : uint8_t -{ - Gecko = 1, - Servo -}; - -} // namespace mozilla - -#endif // mozilla_StyleBackendType_h diff --git a/layout/style/StyleSetHandle.h b/layout/style/StyleSetHandle.h index 1095824..6d17c71 100644 --- a/layout/style/StyleSetHandle.h +++ b/layout/style/StyleSetHandle.h @@ -9,7 +9,6 @@ #include "mozilla/EventStates.h" #include "mozilla/RefPtr.h" #include "mozilla/SheetType.h" -#include "mozilla/StyleBackendType.h" #include "mozilla/StyleSheet.h" #include "nsChangeHint.h" #include "nsCSSPseudoElements.h" @@ -46,11 +45,6 @@ public: public: friend class ::mozilla::StyleSetHandle; - StyleBackendType BackendType() const - { - return StyleBackendType::Gecko; - } - nsStyleSet* AsGecko() { return reinterpret_cast(mValue); diff --git a/layout/style/StyleSheet.cpp b/layout/style/StyleSheet.cpp index 7109f73..9af37c4 100644 --- a/layout/style/StyleSheet.cpp +++ b/layout/style/StyleSheet.cpp @@ -20,11 +20,10 @@ using namespace mozilla::dom; namespace mozilla { -StyleSheet::StyleSheet(StyleBackendType aType, css::SheetParsingMode aParsingMode) +StyleSheet::StyleSheet(css::SheetParsingMode aParsingMode) : mDocument(nullptr) , mOwningNode(nullptr) , mParsingMode(aParsingMode) - , mType(aType) , mDisabled(false) , mDocumentAssociationMode(NotOwnedByDocument) { @@ -37,7 +36,6 @@ StyleSheet::StyleSheet(const StyleSheet& aCopy, , mDocument(aDocumentToUse) , mOwningNode(aOwningNodeToUse) , mParsingMode(aCopy.mParsingMode) - , mType(aCopy.mType) , mDisabled(aCopy.mDisabled) // We only use this constructor during cloning. It's the cloner's // responsibility to notify us if we end up being owned by a document. diff --git a/layout/style/StyleSheet.h b/layout/style/StyleSheet.h index e40d8f6..94ff05c 100644 --- a/layout/style/StyleSheet.h +++ b/layout/style/StyleSheet.h @@ -9,7 +9,6 @@ #include "mozilla/css/SheetParsingMode.h" #include "mozilla/dom/CSSStyleSheetBinding.h" #include "mozilla/net/ReferrerPolicy.h" -#include "mozilla/StyleBackendType.h" #include "mozilla/CORSMode.h" #include "mozilla/ServoUtils.h" @@ -39,7 +38,7 @@ class StyleSheet : public nsIDOMCSSStyleSheet , public nsWrapperCache { protected: - StyleSheet(StyleBackendType aType, css::SheetParsingMode aParsingMode); + StyleSheet(css::SheetParsingMode aParsingMode); StyleSheet(const StyleSheet& aCopy, nsIDocument* aDocumentToUse, nsINode* aOwningNodeToUse); @@ -218,7 +217,6 @@ protected: // and/or useful in user sheets. css::SheetParsingMode mParsingMode; - const StyleBackendType mType; bool mDisabled; // mDocumentAssociationMode determines whether mDocument directly owns us (in diff --git a/layout/style/moz.build b/layout/style/moz.build index 48072b0..1d221bd 100644 --- a/layout/style/moz.build +++ b/layout/style/moz.build @@ -97,7 +97,6 @@ EXPORTS.mozilla += [ 'ServoUtils.h', 'SheetType.h', 'StyleAnimationValue.h', - 'StyleBackendType.h', 'StyleComplexColor.h', 'StyleContextSource.h', 'StyleSetHandle.h',