Bug 1844755 - Consider to not create ServoStyleSet for data documents, r=emilio

Differential Revision: https://phabricator.services.mozilla.com/D191485
This commit is contained in:
Olli Pettay
2023-10-23 16:10:41 +00:00
parent 882584cc9e
commit 09966ae20f
9 changed files with 81 additions and 57 deletions

View File

@@ -7,6 +7,7 @@
#include "mozilla/dom/KeyframeEffect.h" #include "mozilla/dom/KeyframeEffect.h"
#include "mozilla/dom/Animation.h" #include "mozilla/dom/Animation.h"
#include "mozilla/dom/DocumentInlines.h"
#include "mozilla/dom/KeyframeAnimationOptionsBinding.h" #include "mozilla/dom/KeyframeAnimationOptionsBinding.h"
// For UnrestrictedDoubleOrKeyframeAnimationOptions; // For UnrestrictedDoubleOrKeyframeAnimationOptions;
#include "mozilla/dom/KeyframeEffectBinding.h" #include "mozilla/dom/KeyframeEffectBinding.h"
@@ -1146,7 +1147,7 @@ static void CreatePropertyValue(
void KeyframeEffect::GetProperties( void KeyframeEffect::GetProperties(
nsTArray<AnimationPropertyDetails>& aProperties, ErrorResult& aRv) const { nsTArray<AnimationPropertyDetails>& aProperties, ErrorResult& aRv) const {
const StylePerDocumentStyleData* rawData = const StylePerDocumentStyleData* rawData =
mDocument->StyleSetForPresShellOrMediaQueryEvaluation()->RawData(); mDocument->EnsureStyleSet().RawData();
for (const AnimationProperty& property : mProperties) { for (const AnimationProperty& property : mProperties) {
AnimationPropertyDetails propertyDetails; AnimationPropertyDetails propertyDetails;
@@ -1252,7 +1253,7 @@ void KeyframeEffect::GetKeyframes(JSContext* aCx, nsTArray<JSObject*>& aResult,
} }
const StylePerDocumentStyleData* rawData = const StylePerDocumentStyleData* rawData =
mDocument->StyleSetForPresShellOrMediaQueryEvaluation()->RawData(); mDocument->EnsureStyleSet().RawData();
for (const Keyframe& keyframe : mKeyframes) { for (const Keyframe& keyframe : mKeyframes) {
// Set up a dictionary object for the explicit members // Set up a dictionary object for the explicit members

View File

@@ -106,7 +106,6 @@
#include "mozilla/ScopeExit.h" #include "mozilla/ScopeExit.h"
#include "mozilla/Components.h" #include "mozilla/Components.h"
#include "mozilla/ServoStyleConsts.h" #include "mozilla/ServoStyleConsts.h"
#include "mozilla/ServoStyleSet.h"
#include "mozilla/ServoTypes.h" #include "mozilla/ServoTypes.h"
#include "mozilla/SizeOfState.h" #include "mozilla/SizeOfState.h"
#include "mozilla/Span.h" #include "mozilla/Span.h"
@@ -2785,8 +2784,6 @@ nsresult Document::Init(nsIPrincipal* aPrincipal,
mFeaturePolicy = new dom::FeaturePolicy(this); mFeaturePolicy = new dom::FeaturePolicy(this);
mFeaturePolicy->SetDefaultOrigin(NodePrincipal()); mFeaturePolicy->SetDefaultOrigin(NodePrincipal());
mStyleSet = MakeUnique<ServoStyleSet>(*this);
if (aPrincipal) { if (aPrincipal) {
SetPrincipals(aPrincipal, aPartitionedPrincipal); SetPrincipals(aPrincipal, aPartitionedPrincipal);
} else { } else {
@@ -3051,14 +3048,15 @@ already_AddRefed<nsIPrincipal> Document::MaybeDowngradePrincipal(
size_t Document::FindDocStyleSheetInsertionPoint(const StyleSheet& aSheet) { size_t Document::FindDocStyleSheetInsertionPoint(const StyleSheet& aSheet) {
nsStyleSheetService* sheetService = nsStyleSheetService::GetInstance(); nsStyleSheetService* sheetService = nsStyleSheetService::GetInstance();
ServoStyleSet& styleSet = EnsureStyleSet();
// lowest index first // lowest index first
int32_t newDocIndex = StyleOrderIndexOfSheet(aSheet); int32_t newDocIndex = StyleOrderIndexOfSheet(aSheet);
size_t count = mStyleSet->SheetCount(StyleOrigin::Author); size_t count = styleSet.SheetCount(StyleOrigin::Author);
size_t index = 0; size_t index = 0;
for (; index < count; index++) { for (; index < count; index++) {
auto* sheet = mStyleSet->SheetAt(StyleOrigin::Author, index); auto* sheet = styleSet.SheetAt(StyleOrigin::Author, index);
MOZ_ASSERT(sheet); MOZ_ASSERT(sheet);
int32_t sheetDocIndex = StyleOrderIndexOfSheet(*sheet); int32_t sheetDocIndex = StyleOrderIndexOfSheet(*sheet);
if (sheetDocIndex > newDocIndex) { if (sheetDocIndex > newDocIndex) {
@@ -3089,12 +3087,13 @@ void Document::ResetStylesheetsToURI(nsIURI* aURI) {
MOZ_ASSERT(aURI); MOZ_ASSERT(aURI);
ClearAdoptedStyleSheets(); ClearAdoptedStyleSheets();
ServoStyleSet& styleSet = EnsureStyleSet();
auto ClearSheetList = [&](nsTArray<RefPtr<StyleSheet>>& aSheetList) { auto ClearSheetList = [&](nsTArray<RefPtr<StyleSheet>>& aSheetList) {
for (auto& sheet : Reversed(aSheetList)) { for (auto& sheet : Reversed(aSheetList)) {
sheet->ClearAssociatedDocumentOrShadowRoot(); sheet->ClearAssociatedDocumentOrShadowRoot();
if (mStyleSetFilled) { if (mStyleSetFilled) {
mStyleSet->RemoveStyleSheet(*sheet); styleSet.RemoveStyleSheet(*sheet);
} }
} }
aSheetList.Clear(); aSheetList.Clear();
@@ -3108,7 +3107,7 @@ void Document::ResetStylesheetsToURI(nsIURI* aURI) {
for (auto& sheet : Reversed(*ss->AuthorStyleSheets())) { for (auto& sheet : Reversed(*ss->AuthorStyleSheets())) {
MOZ_ASSERT(!sheet->GetAssociatedDocumentOrShadowRoot()); MOZ_ASSERT(!sheet->GetAssociatedDocumentOrShadowRoot());
if (sheet->IsApplicable()) { if (sheet->IsApplicable()) {
mStyleSet->RemoveStyleSheet(*sheet); styleSet.RemoveStyleSheet(*sheet);
} }
} }
} }
@@ -3125,7 +3124,7 @@ void Document::ResetStylesheetsToURI(nsIURI* aURI) {
if (mStyleSetFilled) { if (mStyleSetFilled) {
FillStyleSetDocumentSheets(); FillStyleSetDocumentSheets();
if (mStyleSet->StyleSheetsHaveChanged()) { if (styleSet.StyleSheetsHaveChanged()) {
ApplicableStylesChanged(); ApplicableStylesChanged();
} }
} }
@@ -3150,49 +3149,50 @@ void Document::FillStyleSetUserAndUASheets() {
"should never be creating a StyleSet after the style sheet " "should never be creating a StyleSet after the style sheet "
"service has gone"); "service has gone");
ServoStyleSet& styleSet = EnsureStyleSet();
for (StyleSheet* sheet : *sheetService->UserStyleSheets()) { for (StyleSheet* sheet : *sheetService->UserStyleSheets()) {
mStyleSet->AppendStyleSheet(*sheet); styleSet.AppendStyleSheet(*sheet);
} }
StyleSheet* sheet = IsInChromeDocShell() ? cache->GetUserChromeSheet() StyleSheet* sheet = IsInChromeDocShell() ? cache->GetUserChromeSheet()
: cache->GetUserContentSheet(); : cache->GetUserContentSheet();
if (sheet) { if (sheet) {
mStyleSet->AppendStyleSheet(*sheet); styleSet.AppendStyleSheet(*sheet);
} }
mStyleSet->AppendStyleSheet(*cache->UASheet()); styleSet.AppendStyleSheet(*cache->UASheet());
if (MOZ_LIKELY(NodeInfoManager()->MathMLEnabled())) { if (MOZ_LIKELY(NodeInfoManager()->MathMLEnabled())) {
mStyleSet->AppendStyleSheet(*cache->MathMLSheet()); styleSet.AppendStyleSheet(*cache->MathMLSheet());
} }
if (MOZ_LIKELY(NodeInfoManager()->SVGEnabled())) { if (MOZ_LIKELY(NodeInfoManager()->SVGEnabled())) {
mStyleSet->AppendStyleSheet(*cache->SVGSheet()); styleSet.AppendStyleSheet(*cache->SVGSheet());
} }
mStyleSet->AppendStyleSheet(*cache->HTMLSheet()); styleSet.AppendStyleSheet(*cache->HTMLSheet());
if (nsLayoutUtils::ShouldUseNoFramesSheet(this)) { if (nsLayoutUtils::ShouldUseNoFramesSheet(this)) {
mStyleSet->AppendStyleSheet(*cache->NoFramesSheet()); styleSet.AppendStyleSheet(*cache->NoFramesSheet());
} }
mStyleSet->AppendStyleSheet(*cache->CounterStylesSheet()); styleSet.AppendStyleSheet(*cache->CounterStylesSheet());
// Only load the full XUL sheet if we'll need it. // Only load the full XUL sheet if we'll need it.
if (LoadsFullXULStyleSheetUpFront()) { if (LoadsFullXULStyleSheetUpFront()) {
mStyleSet->AppendStyleSheet(*cache->XULSheet()); styleSet.AppendStyleSheet(*cache->XULSheet());
} }
mStyleSet->AppendStyleSheet(*cache->FormsSheet()); styleSet.AppendStyleSheet(*cache->FormsSheet());
mStyleSet->AppendStyleSheet(*cache->ScrollbarsSheet()); styleSet.AppendStyleSheet(*cache->ScrollbarsSheet());
for (StyleSheet* sheet : *sheetService->AgentStyleSheets()) { for (StyleSheet* sheet : *sheetService->AgentStyleSheets()) {
mStyleSet->AppendStyleSheet(*sheet); styleSet.AppendStyleSheet(*sheet);
} }
MOZ_ASSERT(!mQuirkSheetAdded); MOZ_ASSERT(!mQuirkSheetAdded);
if (NeedsQuirksSheet()) { if (NeedsQuirksSheet()) {
mStyleSet->AppendStyleSheet(*cache->QuirkSheet()); styleSet.AppendStyleSheet(*cache->QuirkSheet());
mQuirkSheetAdded = true; mQuirkSheetAdded = true;
} }
} }
@@ -3207,15 +3207,16 @@ void Document::FillStyleSet() {
void Document::RemoveContentEditableStyleSheets() { void Document::RemoveContentEditableStyleSheets() {
MOZ_ASSERT(IsHTMLOrXHTML()); MOZ_ASSERT(IsHTMLOrXHTML());
ServoStyleSet& styleSet = EnsureStyleSet();
auto* cache = GlobalStyleSheetCache::Singleton(); auto* cache = GlobalStyleSheetCache::Singleton();
bool changed = false; bool changed = false;
if (mDesignModeSheetAdded) { if (mDesignModeSheetAdded) {
mStyleSet->RemoveStyleSheet(*cache->DesignModeSheet()); styleSet.RemoveStyleSheet(*cache->DesignModeSheet());
mDesignModeSheetAdded = false; mDesignModeSheetAdded = false;
changed = true; changed = true;
} }
if (mContentEditableSheetAdded) { if (mContentEditableSheetAdded) {
mStyleSet->RemoveStyleSheet(*cache->ContentEditableSheet()); styleSet.RemoveStyleSheet(*cache->ContentEditableSheet());
mContentEditableSheetAdded = false; mContentEditableSheetAdded = false;
changed = true; changed = true;
} }
@@ -3230,18 +3231,19 @@ void Document::AddContentEditableStyleSheetsToStyleSet(bool aDesignMode) {
MOZ_DIAGNOSTIC_ASSERT(mStyleSetFilled, MOZ_DIAGNOSTIC_ASSERT(mStyleSetFilled,
"Caller should ensure we're being rendered"); "Caller should ensure we're being rendered");
ServoStyleSet& styleSet = EnsureStyleSet();
auto* cache = GlobalStyleSheetCache::Singleton(); auto* cache = GlobalStyleSheetCache::Singleton();
bool changed = false; bool changed = false;
if (!mContentEditableSheetAdded) { if (!mContentEditableSheetAdded) {
mStyleSet->AppendStyleSheet(*cache->ContentEditableSheet()); styleSet.AppendStyleSheet(*cache->ContentEditableSheet());
mContentEditableSheetAdded = true; mContentEditableSheetAdded = true;
changed = true; changed = true;
} }
if (mDesignModeSheetAdded != aDesignMode) { if (mDesignModeSheetAdded != aDesignMode) {
if (mDesignModeSheetAdded) { if (mDesignModeSheetAdded) {
mStyleSet->RemoveStyleSheet(*cache->DesignModeSheet()); styleSet.RemoveStyleSheet(*cache->DesignModeSheet());
} else { } else {
mStyleSet->AppendStyleSheet(*cache->DesignModeSheet()); styleSet.AppendStyleSheet(*cache->DesignModeSheet());
} }
mDesignModeSheetAdded = !mDesignModeSheetAdded; mDesignModeSheetAdded = !mDesignModeSheetAdded;
changed = true; changed = true;
@@ -3252,7 +3254,8 @@ void Document::AddContentEditableStyleSheetsToStyleSet(bool aDesignMode) {
} }
void Document::FillStyleSetDocumentSheets() { void Document::FillStyleSetDocumentSheets() {
MOZ_ASSERT(mStyleSet->SheetCount(StyleOrigin::Author) == 0, ServoStyleSet& styleSet = EnsureStyleSet();
MOZ_ASSERT(styleSet.SheetCount(StyleOrigin::Author) == 0,
"Style set already has document sheets?"); "Style set already has document sheets?");
// Sheets are added in reverse order to avoid worst-case time complexity when // Sheets are added in reverse order to avoid worst-case time complexity when
@@ -3263,39 +3266,44 @@ void Document::FillStyleSetDocumentSheets() {
// styleset from scratch anyway. // styleset from scratch anyway.
for (StyleSheet* sheet : Reversed(mStyleSheets)) { for (StyleSheet* sheet : Reversed(mStyleSheets)) {
if (sheet->IsApplicable()) { if (sheet->IsApplicable()) {
mStyleSet->AddDocStyleSheet(*sheet); styleSet.AddDocStyleSheet(*sheet);
} }
} }
EnumerateUniqueAdoptedStyleSheetsBackToFront([&](StyleSheet& aSheet) { EnumerateUniqueAdoptedStyleSheetsBackToFront([&](StyleSheet& aSheet) {
if (aSheet.IsApplicable()) { if (aSheet.IsApplicable()) {
mStyleSet->AddDocStyleSheet(aSheet); styleSet.AddDocStyleSheet(aSheet);
} }
}); });
nsStyleSheetService* sheetService = nsStyleSheetService::GetInstance(); nsStyleSheetService* sheetService = nsStyleSheetService::GetInstance();
for (StyleSheet* sheet : *sheetService->AuthorStyleSheets()) { for (StyleSheet* sheet : *sheetService->AuthorStyleSheets()) {
mStyleSet->AppendStyleSheet(*sheet); styleSet.AppendStyleSheet(*sheet);
} }
AppendSheetsToStyleSet(mStyleSet.get(), mAdditionalSheets[eAgentSheet]); AppendSheetsToStyleSet(&styleSet, mAdditionalSheets[eAgentSheet]);
AppendSheetsToStyleSet(mStyleSet.get(), mAdditionalSheets[eUserSheet]); AppendSheetsToStyleSet(&styleSet, mAdditionalSheets[eUserSheet]);
AppendSheetsToStyleSet(mStyleSet.get(), mAdditionalSheets[eAuthorSheet]); AppendSheetsToStyleSet(&styleSet, mAdditionalSheets[eAuthorSheet]);
} }
void Document::CompatibilityModeChanged() { void Document::CompatibilityModeChanged() {
MOZ_ASSERT(IsHTMLOrXHTML()); MOZ_ASSERT(IsHTMLOrXHTML());
CSSLoader()->SetCompatibilityMode(mCompatMode); CSSLoader()->SetCompatibilityMode(mCompatMode);
mStyleSet->CompatibilityModeChanged();
if (PresShell* presShell = GetPresShell()) { if (mStyleSet) {
// Selectors may have become case-sensitive / case-insensitive, the stylist mStyleSet->CompatibilityModeChanged();
// has already performed the relevant invalidation.
presShell->EnsureStyleFlush();
} }
if (!mStyleSetFilled) { if (!mStyleSetFilled) {
MOZ_ASSERT(!mQuirkSheetAdded); MOZ_ASSERT(!mQuirkSheetAdded);
return; return;
} }
MOZ_ASSERT(mStyleSet);
if (PresShell* presShell = GetPresShell()) {
// Selectors may have become case-sensitive / case-insensitive, the stylist
// has already performed the relevant invalidation.
presShell->EnsureStyleFlush();
}
if (mQuirkSheetAdded == NeedsQuirksSheet()) { if (mQuirkSheetAdded == NeedsQuirksSheet()) {
return; return;
} }
@@ -7318,13 +7326,13 @@ void Document::RemoveChildNode(nsIContent* aKid, bool aNotify) {
void Document::AddStyleSheetToStyleSets(StyleSheet& aSheet) { void Document::AddStyleSheetToStyleSets(StyleSheet& aSheet) {
if (mStyleSetFilled) { if (mStyleSetFilled) {
mStyleSet->AddDocStyleSheet(aSheet); EnsureStyleSet().AddDocStyleSheet(aSheet);
ApplicableStylesChanged(); ApplicableStylesChanged();
} }
} }
void Document::RecordShadowStyleChange(ShadowRoot& aShadowRoot) { void Document::RecordShadowStyleChange(ShadowRoot& aShadowRoot) {
mStyleSet->RecordShadowStyleChange(aShadowRoot); EnsureStyleSet().RecordShadowStyleChange(aShadowRoot);
ApplicableStylesChanged(/* aKnownInShadowTree= */ true); ApplicableStylesChanged(/* aKnownInShadowTree= */ true);
} }
@@ -7492,7 +7500,7 @@ nsresult Document::AddAdditionalStyleSheet(additionalSheetType aType,
mAdditionalSheets[aType].AppendElement(aSheet); mAdditionalSheets[aType].AppendElement(aSheet);
if (mStyleSetFilled) { if (mStyleSetFilled) {
mStyleSet->AppendStyleSheet(*aSheet); EnsureStyleSet().AppendStyleSheet(*aSheet);
ApplicableStylesChanged(); ApplicableStylesChanged();
} }
return NS_OK; return NS_OK;
@@ -7512,7 +7520,7 @@ void Document::RemoveAdditionalStyleSheet(additionalSheetType aType,
if (!mIsGoingAway) { if (!mIsGoingAway) {
MOZ_ASSERT(sheetRef->IsApplicable()); MOZ_ASSERT(sheetRef->IsApplicable());
if (mStyleSetFilled) { if (mStyleSetFilled) {
mStyleSet->RemoveStyleSheet(*sheetRef); EnsureStyleSet().RemoveStyleSheet(*sheetRef);
ApplicableStylesChanged(); ApplicableStylesChanged();
} }
} }
@@ -8803,7 +8811,7 @@ void Document::EnableStyleSheetsForSetInternal(const nsAString& aSheetSet,
if (aUpdateCSSLoader) { if (aUpdateCSSLoader) {
CSSLoader()->DocumentStyleSheetSetChanged(); CSSLoader()->DocumentStyleSheetSetChanged();
} }
if (mStyleSet->StyleSheetsHaveChanged()) { if (EnsureStyleSet().StyleSheetsHaveChanged()) {
ApplicableStylesChanged(); ApplicableStylesChanged();
} }
} }
@@ -15731,7 +15739,9 @@ void Document::DocAddSizeOfExcludingThis(nsWindowSizes& aWindowSizes) const {
mPresShell->AddSizeOfIncludingThis(aWindowSizes); mPresShell->AddSizeOfIncludingThis(aWindowSizes);
} }
mStyleSet->AddSizeOfIncludingThis(aWindowSizes); if (mStyleSet) {
mStyleSet->AddSizeOfIncludingThis(aWindowSizes);
}
aWindowSizes.mPropertyTablesSize += aWindowSizes.mPropertyTablesSize +=
mPropertyTable.SizeOfExcludingThis(aWindowSizes.mState.mMallocSizeOf); mPropertyTable.SizeOfExcludingThis(aWindowSizes.mState.mMallocSizeOf);
@@ -16579,7 +16589,7 @@ void Document::FlushUserFontSet() {
RefPtr<PresShell> presShell = GetPresShell(); RefPtr<PresShell> presShell = GetPresShell();
if (presShell) { if (presShell) {
MOZ_ASSERT(mStyleSetFilled); MOZ_ASSERT(mStyleSetFilled);
mStyleSet->AppendFontFaceRules(rules); EnsureStyleSet().AppendFontFaceRules(rules);
} }
if (!mFontFaceSet && !rules.IsEmpty()) { if (!mFontFaceSet && !rules.IsEmpty()) {

View File

@@ -1590,10 +1590,13 @@ class Document : public nsINode,
// Get the "head" element in the sense of document.head. // Get the "head" element in the sense of document.head.
HTMLSharedElement* GetHead(); HTMLSharedElement* GetHead();
ServoStyleSet* StyleSetForPresShellOrMediaQueryEvaluation() const { ServoStyleSet* StyleSetForPresShell() const {
MOZ_ASSERT(!!mStyleSet.get());
return mStyleSet.get(); return mStyleSet.get();
} }
inline ServoStyleSet& EnsureStyleSet() const;
// ShadowRoot has APIs that can change styles. This notifies the shell that // ShadowRoot has APIs that can change styles. This notifies the shell that
// stlyes applicable in the shadow tree have potentially changed. // stlyes applicable in the shadow tree have potentially changed.
void RecordShadowStyleChange(ShadowRoot&); void RecordShadowStyleChange(ShadowRoot&);

View File

@@ -9,6 +9,7 @@
#include "mozilla/dom/Document.h" #include "mozilla/dom/Document.h"
#include "mozilla/PresShell.h" #include "mozilla/PresShell.h"
#include "mozilla/ServoStyleSet.h"
#include "mozilla/dom/HTMLBodyElement.h" #include "mozilla/dom/HTMLBodyElement.h"
#include "nsContentUtils.h" #include "nsContentUtils.h"
#include "nsPresContext.h" #include "nsPresContext.h"
@@ -52,6 +53,15 @@ inline void Document::SetServoRestyleRootDirtyBits(uint32_t aDirtyBits) {
mServoRestyleRootDirtyBits = aDirtyBits; mServoRestyleRootDirtyBits = aDirtyBits;
} }
inline ServoStyleSet& Document::EnsureStyleSet() const {
MOZ_ASSERT(NS_IsMainThread());
if (!mStyleSet) {
Document* doc = const_cast<Document*>(this);
doc->mStyleSet = MakeUnique<ServoStyleSet>(*doc);
}
return *(mStyleSet.get());
}
} // namespace mozilla::dom } // namespace mozilla::dom
#endif // mozilla_dom_DocumentInlines_h #endif // mozilla_dom_DocumentInlines_h

View File

@@ -67,7 +67,7 @@ void PresShell::SetNeedThrottledAnimationFlush() {
} }
ServoStyleSet* PresShell::StyleSet() const { ServoStyleSet* PresShell::StyleSet() const {
return mDocument->StyleSetForPresShellOrMediaQueryEvaluation(); return mDocument->StyleSetForPresShell();
} }
/* static */ /* static */

View File

@@ -12,7 +12,7 @@
#include "nsCSSFrameConstructor.h" #include "nsCSSFrameConstructor.h"
inline mozilla::ServoStyleSet* nsPresContext::StyleSet() const { inline mozilla::ServoStyleSet* nsPresContext::StyleSet() const {
return mDocument->StyleSetForPresShellOrMediaQueryEvaluation(); return mDocument->StyleSetForPresShell();
} }
inline nsCSSFrameConstructor* nsPresContext::FrameConstructor() const { inline nsCSSFrameConstructor* nsPresContext::FrameConstructor() const {

View File

@@ -16,6 +16,7 @@
#include "nsIContentInlines.h" #include "nsIContentInlines.h"
#include "nsIScrollableFrame.h" #include "nsIScrollableFrame.h"
#include "mozilla/dom/Document.h" #include "mozilla/dom/Document.h"
#include "mozilla/dom/DocumentInlines.h"
#include "mozilla/dom/HTMLTemplateElement.h" #include "mozilla/dom/HTMLTemplateElement.h"
#include "ChildIterator.h" #include "ChildIterator.h"
#include "nsComputedDOMStyle.h" #include "nsComputedDOMStyle.h"
@@ -860,9 +861,8 @@ void InspectorUtils::GetCSSRegisteredProperties(
GlobalObject& aGlobalObject, Document& aDocument, GlobalObject& aGlobalObject, Document& aDocument,
nsTArray<InspectorCSSPropertyDefinition>& aResult) { nsTArray<InspectorCSSPropertyDefinition>& aResult) {
nsTArray<StylePropDef> result; nsTArray<StylePropDef> result;
Servo_GetRegisteredCustomProperties( Servo_GetRegisteredCustomProperties(aDocument.EnsureStyleSet().RawData(),
aDocument.StyleSetForPresShellOrMediaQueryEvaluation()->RawData(), &result);
&result);
for (const auto& propDef : result) { for (const auto& propDef : result) {
InspectorCSSPropertyDefinition& property = *aResult.AppendElement(); InspectorCSSPropertyDefinition& property = *aResult.AppendElement();

View File

@@ -12,6 +12,7 @@
#include "mozilla/dom/HighlightRegistry.h" #include "mozilla/dom/HighlightRegistry.h"
#include "mozilla/ServoBindings.h" #include "mozilla/ServoBindings.h"
#include "mozilla/dom/Document.h" #include "mozilla/dom/Document.h"
#include "mozilla/dom/DocumentInlines.h"
#include "nsStyleUtil.h" #include "nsStyleUtil.h"
#include "xpcpublic.h" #include "xpcpublic.h"
@@ -64,8 +65,7 @@ void CSS::RegisterProperty(const GlobalObject& aGlobal,
if (!doc) { if (!doc) {
return aRv.ThrowUnknownError("No document associated to this global?"); return aRv.ThrowUnknownError("No document associated to this global?");
} }
doc->StyleSetForPresShellOrMediaQueryEvaluation()->RegisterProperty( doc->EnsureStyleSet().RegisterProperty(aDefinition, aRv);
aDefinition, aRv);
} }
} // namespace mozilla::dom } // namespace mozilla::dom

View File

@@ -10,6 +10,7 @@
#include "mozAutoDocUpdate.h" #include "mozAutoDocUpdate.h"
#include "mozilla/dom/Document.h" #include "mozilla/dom/Document.h"
#include "mozilla/dom/DocumentInlines.h"
#include "mozilla/dom/MediaListBinding.h" #include "mozilla/dom/MediaListBinding.h"
#include "mozilla/ServoBindings.h" #include "mozilla/ServoBindings.h"
#include "mozilla/ServoStyleSet.h" #include "mozilla/ServoStyleSet.h"
@@ -124,8 +125,7 @@ void MediaList::Delete(const nsACString& aOldMedium, ErrorResult& aRv) {
} }
bool MediaList::Matches(const Document& aDocument) const { bool MediaList::Matches(const Document& aDocument) const {
const auto* rawData = const auto* rawData = aDocument.EnsureStyleSet().RawData();
aDocument.StyleSetForPresShellOrMediaQueryEvaluation()->RawData();
MOZ_ASSERT(rawData, "The per doc data should be valid!"); MOZ_ASSERT(rawData, "The per doc data should be valid!");
return Servo_MediaList_Matches(mRawList, rawData); return Servo_MediaList_Matches(mRawList, rawData);
} }