diff --git a/chrome/nsChromeRegistry.cpp b/chrome/nsChromeRegistry.cpp index 31d1945e80fe..bfd1be490b84 100644 --- a/chrome/nsChromeRegistry.cpp +++ b/chrome/nsChromeRegistry.cpp @@ -39,6 +39,7 @@ nsChromeRegistry* nsChromeRegistry::gChromeRegistry; // DO NOT use namespace mozilla; it'll break due to a naming conflict between // mozilla::TextRange and a TextRange in OSX headers. +using mozilla::ServoStyleSheet; using mozilla::StyleSheet; using mozilla::dom::IsChromeURI; using mozilla::dom::Location; @@ -403,12 +404,12 @@ nsresult nsChromeRegistry::RefreshWindow(nsPIDOMWindowOuter* aWindow) nsCOMPtr shell = document->GetShell(); if (shell) { // Reload only the chrome URL agent style sheets. - nsTArray> agentSheets; + nsTArray> agentSheets; rv = shell->GetAgentStyleSheets(agentSheets); NS_ENSURE_SUCCESS(rv, rv); - nsTArray> newAgentSheets; - for (StyleSheet* sheet : agentSheets) { + nsTArray> newAgentSheets; + for (ServoStyleSheet* sheet : agentSheets) { nsIURI* uri = sheet->GetSheetURI(); if (IsChromeURI(uri)) { @@ -417,7 +418,8 @@ nsresult nsChromeRegistry::RefreshWindow(nsPIDOMWindowOuter* aWindow) rv = document->LoadChromeSheetSync(uri, true, &newSheet); if (NS_FAILED(rv)) return rv; if (newSheet) { - rv = newAgentSheets.AppendElement(newSheet) ? NS_OK : NS_ERROR_FAILURE; + rv = newAgentSheets.AppendElement(newSheet->AsServo()) + ? NS_OK : NS_ERROR_FAILURE; if (NS_FAILED(rv)) return rv; } } diff --git a/dom/animation/KeyframeEffectReadOnly.cpp b/dom/animation/KeyframeEffectReadOnly.cpp index ea5a48df9ab0..419339b8466b 100644 --- a/dom/animation/KeyframeEffectReadOnly.cpp +++ b/dom/animation/KeyframeEffectReadOnly.cpp @@ -408,10 +408,8 @@ KeyframeEffectReadOnly::EnsureBaseStyle( Element* animatingElement = EffectCompositor::GetElementToRestyle(mTarget->mElement, mTarget->mPseudoType); - aBaseComputedStyle = - aPresContext->StyleSet()->AsServo()->GetBaseContextForElement( - animatingElement, - aComputedStyle); + aBaseComputedStyle = aPresContext->StyleSet()-> + GetBaseContextForElement(animatingElement, aComputedStyle); } RefPtr baseValue = Servo_ComputedValues_ExtractAnimationValue(aBaseComputedStyle, @@ -1488,8 +1486,7 @@ KeyframeEffectReadOnly::CreateComputedStyleForAnimationValue( "CreateComputedStyleForAnimationValue needs to be called " "with a valid ComputedStyle"); - ServoStyleSet* styleSet = - aBaseComputedStyle->PresContext()->StyleSet()->AsServo(); + ServoStyleSet* styleSet = aBaseComputedStyle->PresContext()->StyleSet(); Element* elementForResolve = EffectCompositor::GetElementToRestyle(mTarget->mElement, mTarget->mPseudoType); diff --git a/dom/animation/KeyframeUtils.cpp b/dom/animation/KeyframeUtils.cpp index 8baedba2b495..bf77fe0193b6 100644 --- a/dom/animation/KeyframeUtils.cpp +++ b/dom/animation/KeyframeUtils.cpp @@ -930,8 +930,8 @@ GetComputedKeyframeValues(const nsTArray& aKeyframes, return result; } - result = presContext->StyleSet()->AsServo() - ->GetComputedKeyframeValuesFor(aKeyframes, aElement, aComputedStyle); + result = presContext->StyleSet()-> + GetComputedKeyframeValuesFor(aKeyframes, aElement, aComputedStyle); return result; } diff --git a/dom/base/ResponsiveImageSelector.cpp b/dom/base/ResponsiveImageSelector.cpp index 1f8fb0c70627..36d8dd97b6c2 100644 --- a/dom/base/ResponsiveImageSelector.cpp +++ b/dom/base/ResponsiveImageSelector.cpp @@ -440,9 +440,8 @@ ResponsiveImageSelector::ComputeFinalWidthForCurrentViewport(double *aWidth) if (!pctx) { return false; } - nscoord effectiveWidth = - presShell->StyleSet()->AsServo()->EvaluateSourceSizeList( - mServoSourceSizeList.get()); + nscoord effectiveWidth = presShell->StyleSet()-> + EvaluateSourceSizeList(mServoSourceSizeList.get()); *aWidth = nsPresContext::AppUnitsToDoubleCSSPixels(std::max(effectiveWidth, 0)); return true; diff --git a/dom/base/nsDocument.cpp b/dom/base/nsDocument.cpp index 9ffea09eef07..7271aefbeb0c 100644 --- a/dom/base/nsDocument.cpp +++ b/dom/base/nsDocument.cpp @@ -246,8 +246,7 @@ #include "mozilla/dom/FontFaceSet.h" #include "gfxPrefs.h" #include "nsISupportsPrimitives.h" -#include "mozilla/StyleSetHandle.h" -#include "mozilla/StyleSetHandleInlines.h" +#include "mozilla/ServoStyleSet.h" #include "mozilla/StyleSheet.h" #include "mozilla/StyleSheetInlines.h" #include "mozilla/dom/SVGSVGElement.h" @@ -2457,7 +2456,7 @@ nsIDocument::RemoveDocStyleSheetsFromStyleSets() if (sheet->IsApplicable()) { nsCOMPtr shell = GetShell(); if (shell) { - shell->StyleSet()->RemoveDocStyleSheet(sheet); + shell->StyleSet()->RemoveDocStyleSheet(sheet->AsServo()); } } // XXX Tell observers? @@ -2476,7 +2475,7 @@ nsIDocument::RemoveStyleSheetsFromStyleSets( if (sheet->IsApplicable()) { nsCOMPtr shell = GetShell(); if (shell) { - shell->StyleSet()->RemoveStyleSheet(aType, sheet); + shell->StyleSet()->RemoveStyleSheet(aType, sheet->AsServo()); } } // XXX Tell observers? @@ -2538,18 +2537,18 @@ nsIDocument::ResetStylesheetsToURI(nsIURI* aURI) } static void -AppendSheetsToStyleSet(StyleSetHandle aStyleSet, +AppendSheetsToStyleSet(ServoStyleSet* aStyleSet, const nsTArray>& aSheets, SheetType aType) { for (StyleSheet* sheet : Reversed(aSheets)) { - aStyleSet->AppendStyleSheet(aType, sheet); + aStyleSet->AppendStyleSheet(aType, sheet->AsServo()); } } void -nsIDocument::FillStyleSet(StyleSetHandle aStyleSet) +nsIDocument::FillStyleSet(ServoStyleSet* aStyleSet) { NS_PRECONDITION(aStyleSet, "Must have a style set"); NS_PRECONDITION(aStyleSet->SheetCount(SheetType::Doc) == 0, @@ -2559,7 +2558,7 @@ nsIDocument::FillStyleSet(StyleSetHandle aStyleSet) for (StyleSheet* sheet : Reversed(mStyleSheets)) { if (sheet->IsApplicable()) { - aStyleSet->AddDocStyleSheet(sheet, this); + aStyleSet->AddDocStyleSheet(sheet->AsServo(), this); } } @@ -2567,14 +2566,14 @@ nsIDocument::FillStyleSet(StyleSetHandle aStyleSet) nsTArray>& sheets = *sheetService->AuthorStyleSheets(); for (StyleSheet* sheet : sheets) { - aStyleSet->AppendStyleSheet(SheetType::Doc, sheet); + aStyleSet->AppendStyleSheet(SheetType::Doc, sheet->AsServo()); } } // Iterate backwards to maintain order for (StyleSheet* sheet : Reversed(mOnDemandBuiltInUASheets)) { if (sheet->IsApplicable()) { - aStyleSet->PrependStyleSheet(SheetType::Agent, sheet); + aStyleSet->PrependStyleSheet(SheetType::Agent, sheet->AsServo()); } } @@ -3878,19 +3877,19 @@ AssertNoStaleServoDataIn(const nsINode& aSubtreeRoot) already_AddRefed nsIDocument::CreateShell(nsPresContext* aContext, nsViewManager* aViewManager, - StyleSetHandle aStyleSet) + UniquePtr aStyleSet) { NS_ASSERTION(!mPresShell, "We have a presshell already!"); NS_ENSURE_FALSE(GetBFCacheEntry(), nullptr); - FillStyleSet(aStyleSet); + FillStyleSet(aStyleSet.get()); AssertNoStaleServoDataIn(static_cast(*this)); RefPtr shell = new PresShell; // Note: we don't hold a ref to the shell (it holds a ref to us) mPresShell = shell; - shell->Init(this, aContext, aViewManager, aStyleSet); + shell->Init(this, aContext, aViewManager, Move(aStyleSet)); // Make sure to never paint if we belong to an invisible DocShell. nsCOMPtr docShell(mDocumentContainer); @@ -4311,7 +4310,7 @@ nsIDocument::AddOnDemandBuiltInUASheet(StyleSheet* aSheet) // do not override Firefox OS/Mobile's content.css sheet. Maybe we should // have an insertion point to match the order of // nsDocumentViewer::CreateStyleSet though? - shell->StyleSet()->PrependStyleSheet(SheetType::Agent, aSheet); + shell->StyleSet()->PrependStyleSheet(SheetType::Agent, aSheet->AsServo()); } } @@ -4323,7 +4322,7 @@ nsIDocument::AddStyleSheetToStyleSets(StyleSheet* aSheet) { nsCOMPtr shell = GetShell(); if (shell) { - shell->StyleSet()->AddDocStyleSheet(aSheet, this); + shell->StyleSet()->AddDocStyleSheet(aSheet->AsServo(), this); } } @@ -4390,7 +4389,7 @@ nsIDocument::RemoveStyleSheetFromStyleSets(StyleSheet* aSheet) { nsCOMPtr shell = GetShell(); if (shell) { - shell->StyleSet()->RemoveDocStyleSheet(aSheet); + shell->StyleSet()->RemoveDocStyleSheet(aSheet->AsServo()); } } @@ -4611,7 +4610,7 @@ nsIDocument::AddAdditionalStyleSheet(additionalSheetType aType, StyleSheet* aShe nsCOMPtr shell = GetShell(); if (shell) { SheetType type = ConvertAdditionalSheetType(aType); - shell->StyleSet()->AppendStyleSheet(type, aSheet); + shell->StyleSet()->AppendStyleSheet(type, aSheet->AsServo()); } // Passing false, so documet.styleSheets.length will not be affected by @@ -4639,7 +4638,7 @@ nsIDocument::RemoveAdditionalStyleSheet(additionalSheetType aType, nsIURI* aShee nsCOMPtr shell = GetShell(); if (shell) { SheetType type = ConvertAdditionalSheetType(aType); - shell->StyleSet()->RemoveStyleSheet(type, sheetRef); + shell->StyleSet()->RemoveStyleSheet(type, sheetRef->AsServo()); } } diff --git a/dom/base/nsDocument.h b/dom/base/nsDocument.h index 9ce5e631ea7c..5d0d6e3c5e7c 100644 --- a/dom/base/nsDocument.h +++ b/dom/base/nsDocument.h @@ -41,7 +41,6 @@ #include "nsCycleCollectionParticipant.h" #include "nsContentList.h" #include "nsGkAtoms.h" -#include "mozilla/StyleSetHandle.h" #include "PLDHashTable.h" #include "nsDOMAttributeMap.h" #include "imgIRequest.h" diff --git a/dom/base/nsIDocument.h b/dom/base/nsIDocument.h index eebf02f9c38c..e607ce1b4045 100644 --- a/dom/base/nsIDocument.h +++ b/dom/base/nsIDocument.h @@ -130,7 +130,7 @@ class ErrorResult; class EventStates; class EventListenerManager; class PendingAnimationTracker; -class StyleSetHandle; +class ServoStyleSet; template class OwningNonNull; struct URLExtraData; @@ -1181,9 +1181,10 @@ class nsIDocument : public nsINode, * method is responsible for calling BeginObservingDocument() on the * presshell if the presshell should observe document mutations. */ - already_AddRefed CreateShell(nsPresContext* aContext, - nsViewManager* aViewManager, - mozilla::StyleSetHandle aStyleSet); + already_AddRefed CreateShell( + nsPresContext* aContext, + nsViewManager* aViewManager, + mozilla::UniquePtr aStyleSet); void DeleteShell(); nsIPresShell* GetShell() const @@ -3715,7 +3716,7 @@ class nsIDocument : public nsINode, const nsTArray>& aSheets, mozilla::SheetType aType); void ResetStylesheetsToURI(nsIURI* aURI); - void FillStyleSet(mozilla::StyleSetHandle aStyleSet); + void FillStyleSet(mozilla::ServoStyleSet* aStyleSet); void AddStyleSheetToStyleSets(mozilla::StyleSheet* aSheet); void RemoveStyleSheetFromStyleSets(mozilla::StyleSheet* aSheet); void NotifyStyleSheetAdded(mozilla::StyleSheet* aSheet, bool aDocumentSheet); diff --git a/dom/canvas/CanvasRenderingContext2D.cpp b/dom/canvas/CanvasRenderingContext2D.cpp index e6faa976d9e3..c2127989d4d9 100644 --- a/dom/canvas/CanvasRenderingContext2D.cpp +++ b/dom/canvas/CanvasRenderingContext2D.cpp @@ -119,8 +119,7 @@ #include "Units.h" #include "CanvasUtils.h" #include "mozilla/CycleCollectedJSRuntime.h" -#include "mozilla/StyleSetHandle.h" -#include "mozilla/StyleSetHandleInlines.h" +#include "mozilla/ServoStyleSet.h" #include "mozilla/layers/CanvasClient.h" #include "mozilla/layers/WebRenderUserData.h" #include "mozilla/layers/WebRenderCanvasRenderer.h" @@ -743,23 +742,12 @@ CanvasGradient::AddColorStop(float aOffset, const nsAString& aColorstr, ErrorRes return; } - nscolor color; - bool ok; - nsIPresShell* shell = mContext ? mContext->GetPresShell() : nullptr; - ServoStyleSet* servoStyleSet = shell && shell->StyleSet() - ? shell->StyleSet()->GetAsServo() - : nullptr; + ServoStyleSet* styleSet = shell ? shell->StyleSet() : nullptr; - bool useServoParser = - true; - - if (useServoParser) { - ok = ServoCSSParser::ComputeColor(servoStyleSet, NS_RGB(0, 0, 0), aColorstr, - &color); - } else { - MOZ_CRASH("old style system disabled"); - } + nscolor color; + bool ok = ServoCSSParser::ComputeColor(styleSet, NS_RGB(0, 0, 0), + aColorstr, &color); if (!ok) { aRv.Throw(NS_ERROR_DOM_SYNTAX_ERR); @@ -1158,34 +1146,27 @@ CanvasRenderingContext2D::ParseColor(const nsAString& aString, nsIDocument* document = mCanvasElement ? mCanvasElement->OwnerDoc() : nullptr; css::Loader* loader = document ? document->CSSLoader() : nullptr; - bool useServoParser = - true; + nsIPresShell* presShell = GetPresShell(); + ServoStyleSet* set = presShell ? presShell->StyleSet() : nullptr; - if (useServoParser) { - nsIPresShell* presShell = GetPresShell(); - ServoStyleSet* set = presShell ? presShell->StyleSet()->AsServo() : nullptr; - - // First, try computing the color without handling currentcolor. - bool wasCurrentColor = false; - if (!ServoCSSParser::ComputeColor(set, NS_RGB(0, 0, 0), aString, aColor, - &wasCurrentColor, loader)) { - return false; - } + // First, try computing the color without handling currentcolor. + bool wasCurrentColor = false; + if (!ServoCSSParser::ComputeColor(set, NS_RGB(0, 0, 0), aString, aColor, + &wasCurrentColor, loader)) { + return false; + } - if (wasCurrentColor && mCanvasElement) { - // Otherwise, get the value of the color property, flushing style - // if necessary. - RefPtr canvasStyle = - nsComputedDOMStyle::GetComputedStyle(mCanvasElement, nullptr); - if (canvasStyle) { - *aColor = canvasStyle->StyleColor()->mColor; - } - // Beware that the presShell could be gone here. + if (wasCurrentColor && mCanvasElement) { + // Otherwise, get the value of the color property, flushing style + // if necessary. + RefPtr canvasStyle = + nsComputedDOMStyle::GetComputedStyle(mCanvasElement, nullptr); + if (canvasStyle) { + *aColor = canvasStyle->StyleColor()->mColor; } - return true; + // Beware that the presShell could be gone here. } - - MOZ_CRASH("old style system disabled"); + return true; } nsresult @@ -2704,7 +2685,7 @@ GetFontStyleForServo(Element* aElement, const nsAString& aFont, return nullptr; } - ServoStyleSet* styleSet = aPresShell->StyleSet()->AsServo(); + ServoStyleSet* styleSet = aPresShell->StyleSet(); RefPtr parentStyle; // have to get a parent ComputedStyle for inherit-like relative @@ -2723,7 +2704,7 @@ GetFontStyleForServo(Element* aElement, const nsAString& aFont, aPresShell->GetDocument()); MOZ_ASSERT(declarations); - parentStyle = aPresShell->StyleSet()->AsServo()-> + parentStyle = aPresShell->StyleSet()-> ResolveForDeclarations(nullptr, declarations); } @@ -2772,7 +2753,7 @@ ResolveFilterStyleForServo(const nsAString& aFilterString, return nullptr; } - ServoStyleSet* styleSet = aPresShell->StyleSet()->AsServo(); + ServoStyleSet* styleSet = aPresShell->StyleSet(); RefPtr computedValues = styleSet->ResolveForDeclarations(aParentStyle, declarations); diff --git a/dom/html/nsGenericHTMLElement.cpp b/dom/html/nsGenericHTMLElement.cpp index dcd454e3d4a2..a46982a61118 100644 --- a/dom/html/nsGenericHTMLElement.cpp +++ b/dom/html/nsGenericHTMLElement.cpp @@ -99,8 +99,6 @@ #include "mozilla/dom/HTMLBodyElement.h" #include "imgIContainer.h" #include "nsComputedDOMStyle.h" -#include "mozilla/StyleSetHandle.h" -#include "mozilla/StyleSetHandleInlines.h" #include "ReferrerPolicy.h" #include "mozilla/dom/HTMLLabelElement.h" #include "mozilla/dom/HTMLInputElement.h" diff --git a/dom/html/nsHTMLDocument.cpp b/dom/html/nsHTMLDocument.cpp index 8574906301f3..5d12f8f451d2 100644 --- a/dom/html/nsHTMLDocument.cpp +++ b/dom/html/nsHTMLDocument.cpp @@ -2257,7 +2257,7 @@ nsHTMLDocument::TearingDownEditor() if (!presShell) return; - nsTArray> agentSheets; + nsTArray> agentSheets; presShell->GetAgentStyleSheets(agentSheets); auto cache = nsLayoutStylesheetCache::Singleton(); @@ -2402,13 +2402,14 @@ nsHTMLDocument::EditingStateChanged() // Before making this window editable, we need to modify UA style sheet // because new style may change whether focused element will be focusable // or not. - nsTArray> agentSheets; + nsTArray> agentSheets; rv = presShell->GetAgentStyleSheets(agentSheets); NS_ENSURE_SUCCESS(rv, rv); auto cache = nsLayoutStylesheetCache::Singleton(); - StyleSheet* contentEditableSheet = cache->ContentEditableSheet(); + ServoStyleSheet* contentEditableSheet = + cache->ContentEditableSheet()->AsServo(); if (!agentSheets.Contains(contentEditableSheet)) { agentSheets.AppendElement(contentEditableSheet); @@ -2419,7 +2420,7 @@ nsHTMLDocument::EditingStateChanged() // specific states on the elements. if (designMode) { // designMode is being turned on (overrides contentEditable). - StyleSheet* designModeSheet = cache->DesignModeSheet(); + ServoStyleSheet* designModeSheet = cache->DesignModeSheet()->AsServo(); if (!agentSheets.Contains(designModeSheet)) { agentSheets.AppendElement(designModeSheet); } @@ -2429,7 +2430,7 @@ nsHTMLDocument::EditingStateChanged() } else if (oldState == eDesignMode) { // designMode is being turned off (contentEditable is still on). - agentSheets.RemoveElement(cache->DesignModeSheet()); + agentSheets.RemoveElement(cache->DesignModeSheet()->AsServo()); updateState = true; } diff --git a/dom/smil/nsSMILCSSValueType.cpp b/dom/smil/nsSMILCSSValueType.cpp index 7cf7e46744b1..8c105379e301 100644 --- a/dom/smil/nsSMILCSSValueType.cpp +++ b/dom/smil/nsSMILCSSValueType.cpp @@ -19,7 +19,7 @@ #include "mozilla/ServoBindings.h" #include "mozilla/StyleAnimationValue.h" // For AnimationValue #include "mozilla/ServoCSSParser.h" -#include "mozilla/StyleSetHandleInlines.h" +#include "mozilla/ServoStyleSet.h" #include "mozilla/dom/BaseKeyframeTypesBinding.h" // For CompositeOperation #include "mozilla/dom/Element.h" #include "nsDebug.h" @@ -518,10 +518,9 @@ ValueFromStringHelper(nsCSSPropertyID aPropID, } // Compute value - aPresContext->StyleSet()->AsServo()->GetAnimationValues(servoDeclarationBlock, - aTargetElement, - aComputedStyle, - result); + aPresContext->StyleSet()-> + GetAnimationValues(servoDeclarationBlock, aTargetElement, + aComputedStyle, result); return result; } diff --git a/dom/xbl/nsBindingManager.cpp b/dom/xbl/nsBindingManager.cpp index 6fb71783f948..750a0c6c6b19 100644 --- a/dom/xbl/nsBindingManager.cpp +++ b/dom/xbl/nsBindingManager.cpp @@ -51,7 +51,6 @@ #include "nsThreadUtils.h" #include "mozilla/dom/NodeListBinding.h" #include "mozilla/dom/ScriptSettings.h" -#include "mozilla/ServoStyleSet.h" #include "mozilla/Unused.h" using namespace mozilla; diff --git a/dom/xbl/nsXBLPrototypeResources.cpp b/dom/xbl/nsXBLPrototypeResources.cpp index 75edbdc470ea..0d9ed74121ee 100644 --- a/dom/xbl/nsXBLPrototypeResources.cpp +++ b/dom/xbl/nsXBLPrototypeResources.cpp @@ -108,7 +108,7 @@ nsXBLPrototypeResources::FlushSkinSheets() // There may be no shell during unlink. if (auto* shell = doc->GetShell()) { MOZ_ASSERT(shell->GetPresContext()); - ComputeServoStyles(*shell->StyleSet()->AsServo()); + ComputeServoStyles(*shell->StyleSet()); } return NS_OK; diff --git a/dom/xbl/nsXBLResourceLoader.cpp b/dom/xbl/nsXBLResourceLoader.cpp index 3a38ad2cc5e2..84949d6b7c88 100644 --- a/dom/xbl/nsXBLResourceLoader.cpp +++ b/dom/xbl/nsXBLResourceLoader.cpp @@ -180,7 +180,7 @@ nsXBLResourceLoader::StyleSheetLoaded(StyleSheet* aSheet, if (mPendingSheets == 0) { // All stylesheets are loaded. mResources->ComputeServoStyles( - *mBoundDocument->GetShell()->StyleSet()->AsServo()); + *mBoundDocument->GetShell()->StyleSet()); // XXX Check for mPendingScripts when scripts also come online. if (!mInLoadResourcesFunc) diff --git a/dom/xbl/nsXBLService.cpp b/dom/xbl/nsXBLService.cpp index cb8412bfaca4..0f65e6ec4102 100644 --- a/dom/xbl/nsXBLService.cpp +++ b/dom/xbl/nsXBLService.cpp @@ -402,7 +402,7 @@ EnsureSubtreeStyled(Element* aElement) return; } - ServoStyleSet* servoSet = presShell->StyleSet()->AsServo(); + ServoStyleSet* servoSet = presShell->StyleSet(); StyleChildrenIterator iter(aElement); for (nsIContent* child = iter.GetNextChild(); child; @@ -465,7 +465,7 @@ class MOZ_RAII AutoStyleElement if (*mResolveStyle) { mElement->ClearServoData(); - ServoStyleSet* servoSet = presShell->StyleSet()->AsServo(); + ServoStyleSet* servoSet = presShell->StyleSet(); servoSet->StyleNewSubtree(mElement); } } diff --git a/editor/libeditor/HTMLAnonymousNodeEditor.cpp b/editor/libeditor/HTMLAnonymousNodeEditor.cpp index 5e2127c4cf4f..7defe0303648 100644 --- a/editor/libeditor/HTMLAnonymousNodeEditor.cpp +++ b/editor/libeditor/HTMLAnonymousNodeEditor.cpp @@ -208,12 +208,11 @@ HTMLEditor::CreateAnonymousElement(nsAtom* aTag, // Must style the new element, otherwise the PostRecreateFramesFor call // below will do nothing. - if (ServoStyleSet* styleSet = ps->StyleSet()->GetAsServo()) { - // Sometimes editor likes to append anonymous content to elements - // in display:none subtrees, so avoid styling in those cases. - if (ServoStyleSet::MayTraverseFrom(newContent)) { - styleSet->StyleNewSubtree(newContent); - } + ServoStyleSet* styleSet = ps->StyleSet(); + // Sometimes editor likes to append anonymous content to elements + // in display:none subtrees, so avoid styling in those cases. + if (ServoStyleSet::MayTraverseFrom(newContent)) { + styleSet->StyleNewSubtree(newContent); } ElementDeletionObserver* observer = diff --git a/gfx/layers/apz/util/ActiveElementManager.cpp b/gfx/layers/apz/util/ActiveElementManager.cpp index 48cbd9786226..096235f1ec38 100644 --- a/gfx/layers/apz/util/ActiveElementManager.cpp +++ b/gfx/layers/apz/util/ActiveElementManager.cpp @@ -7,8 +7,6 @@ #include "ActiveElementManager.h" #include "mozilla/EventStateManager.h" #include "mozilla/EventStates.h" -#include "mozilla/StyleSetHandle.h" -#include "mozilla/StyleSetHandleInlines.h" #include "mozilla/Preferences.h" #include "base/message_loop.h" #include "base/task.h" diff --git a/layout/base/PresShell.cpp b/layout/base/PresShell.cpp index b294eed0612f..e5e85298ba82 100644 --- a/layout/base/PresShell.cpp +++ b/layout/base/PresShell.cpp @@ -181,8 +181,7 @@ #include "nsLayoutStylesheetCache.h" #include "mozilla/layers/InputAPZContext.h" #include "mozilla/layers/FocusTarget.h" -#include "mozilla/StyleSetHandle.h" -#include "mozilla/StyleSetHandleInlines.h" +#include "mozilla/ServoStyleSet.h" #include "mozilla/StyleSheet.h" #include "mozilla/StyleSheetInlines.h" #include "mozilla/dom/ImageTracker.h" @@ -905,7 +904,7 @@ PresShell::~PresShell() MOZ_ASSERT(mAllocatedPointers.IsEmpty(), "Some pres arena objects were not freed"); - mStyleSet->Delete(); + mStyleSet = nullptr; delete mFrameConstructor; mCurrentEventContent = nullptr; @@ -921,7 +920,7 @@ void PresShell::Init(nsIDocument* aDocument, nsPresContext* aPresContext, nsViewManager* aViewManager, - StyleSetHandle aStyleSet) + UniquePtr aStyleSet) { NS_PRECONDITION(aDocument, "null ptr"); NS_PRECONDITION(aPresContext, "null ptr"); @@ -957,7 +956,7 @@ PresShell::Init(nsIDocument* aDocument, // 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 // the PresContext during initialization. - mStyleSet = aStyleSet; + mStyleSet = Move(aStyleSet); mStyleSet->Init(aPresContext); // Notify our prescontext that it now has a compatibility mode. Note that @@ -1513,7 +1512,7 @@ PresShell::UpdatePreferenceStyles() RemovePreferenceStyles(); - mStyleSet->AppendStyleSheet(SheetType::User, newPrefSheet); + mStyleSet->AppendStyleSheet(SheetType::User, newPrefSheet->AsServo()); mPrefStyleSheet = newPrefSheet; mStyleSet->EndUpdate(); @@ -1523,7 +1522,7 @@ void PresShell::RemovePreferenceStyles() { if (mPrefStyleSheet) { - mStyleSet->RemoveStyleSheet(SheetType::User, mPrefStyleSheet); + mStyleSet->RemoveStyleSheet(SheetType::User, mPrefStyleSheet->AsServo()); mPrefStyleSheet = nullptr; } } @@ -1546,13 +1545,13 @@ PresShell::AddUserSheet(StyleSheet* aSheet) // Iterate forwards when removing so the searches for RemoveStyleSheet are as // short as possible. for (StyleSheet* sheet : userSheets) { - mStyleSet->RemoveStyleSheet(SheetType::User, sheet); + mStyleSet->RemoveStyleSheet(SheetType::User, sheet->AsServo()); } // Now iterate backwards, so that the order of userSheets will be the same as // the order of sheets from it in the style set. for (StyleSheet* sheet : Reversed(userSheets)) { - mStyleSet->PrependStyleSheet(SheetType::User, sheet); + mStyleSet->PrependStyleSheet(SheetType::User, sheet->AsServo()); } mStyleSet->EndUpdate(); @@ -1564,7 +1563,7 @@ PresShell::AddAgentSheet(StyleSheet* aSheet) { // Make sure this does what nsDocumentViewer::CreateStyleSet does // wrt ordering. - mStyleSet->AppendStyleSheet(SheetType::Agent, aSheet); + mStyleSet->AppendStyleSheet(SheetType::Agent, aSheet->AsServo()); RestyleForCSSRuleChanges(); } @@ -1576,9 +1575,10 @@ PresShell::AddAuthorSheet(StyleSheet* aSheet) StyleSheet* firstAuthorSheet = mDocument->GetFirstAdditionalAuthorSheet(); if (firstAuthorSheet) { - mStyleSet->InsertStyleSheetBefore(SheetType::Doc, aSheet, firstAuthorSheet); + mStyleSet->InsertStyleSheetBefore(SheetType::Doc, aSheet->AsServo(), + firstAuthorSheet->AsServo()); } else { - mStyleSet->AppendStyleSheet(SheetType::Doc, aSheet); + mStyleSet->AppendStyleSheet(SheetType::Doc, aSheet->AsServo()); } RestyleForCSSRuleChanges(); @@ -1587,7 +1587,7 @@ PresShell::AddAuthorSheet(StyleSheet* aSheet) void PresShell::RemoveSheet(SheetType aType, StyleSheet* aSheet) { - mStyleSet->RemoveStyleSheet(aType, aSheet); + mStyleSet->RemoveStyleSheet(aType, aSheet->AsServo()); RestyleForCSSRuleChanges(); } @@ -4366,7 +4366,7 @@ PresShell::DocumentStatesChanged(nsIDocument* aDocument, EventStates aStateMask) MOZ_ASSERT(!aStateMask.IsEmpty()); if (mDidInitialize) { - mStyleSet->AsServo()->InvalidateStyleForDocumentStateChanges(aStateMask); + mStyleSet->InvalidateStyleForDocumentStateChanges(aStateMask); } if (aStateMask.HasState(NS_DOCUMENT_STATE_WINDOW_INACTIVE)) { @@ -8395,7 +8395,7 @@ PresShell::IsVisible() } nsresult -PresShell::GetAgentStyleSheets(nsTArray>& aSheets) +PresShell::GetAgentStyleSheets(nsTArray>& aSheets) { aSheets.Clear(); int32_t sheetCount = mStyleSet->SheetCount(SheetType::Agent); @@ -8405,7 +8405,7 @@ PresShell::GetAgentStyleSheets(nsTArray>& aSheets) } for (int32_t i = 0; i < sheetCount; ++i) { - StyleSheet* sheet = mStyleSet->StyleSheetAt(SheetType::Agent, i); + ServoStyleSheet* sheet = mStyleSet->StyleSheetAt(SheetType::Agent, i); aSheets.AppendElement(sheet); } @@ -8413,7 +8413,7 @@ PresShell::GetAgentStyleSheets(nsTArray>& aSheets) } nsresult -PresShell::SetAgentStyleSheets(const nsTArray>& aSheets) +PresShell::SetAgentStyleSheets(const nsTArray>& aSheets) { return mStyleSet->ReplaceSheets(SheetType::Agent, aSheets); } @@ -8421,13 +8421,13 @@ PresShell::SetAgentStyleSheets(const nsTArray>& aSheets) nsresult PresShell::AddOverrideStyleSheet(StyleSheet* aSheet) { - return mStyleSet->PrependStyleSheet(SheetType::Override, aSheet); + return mStyleSet->PrependStyleSheet(SheetType::Override, aSheet->AsServo()); } nsresult PresShell::RemoveOverrideStyleSheet(StyleSheet* aSheet) { - return mStyleSet->RemoveStyleSheet(SheetType::Override, aSheet); + return mStyleSet->RemoveStyleSheet(SheetType::Override, aSheet->AsServo()); } static void @@ -9495,11 +9495,11 @@ FindTopFrame(nsIFrame* aRoot) #ifdef DEBUG static void -CopySheetsIntoClone(StyleSetHandle aSet, StyleSetHandle aClone) +CopySheetsIntoClone(ServoStyleSet* aSet, ServoStyleSet* aClone) { int32_t i, n = aSet->SheetCount(SheetType::Override); for (i = 0; i < n; i++) { - StyleSheet* ss = aSet->StyleSheetAt(SheetType::Override, i); + ServoStyleSheet* ss = aSet->StyleSheetAt(SheetType::Override, i); if (ss) aClone->AppendStyleSheet(SheetType::Override, ss); } @@ -9516,25 +9516,25 @@ CopySheetsIntoClone(StyleSetHandle aSet, StyleSetHandle aClone) n = aSet->SheetCount(SheetType::User); for (i = 0; i < n; i++) { - StyleSheet* ss = aSet->StyleSheetAt(SheetType::User, i); + ServoStyleSheet* ss = aSet->StyleSheetAt(SheetType::User, i); if (ss) aClone->AppendStyleSheet(SheetType::User, ss); } n = aSet->SheetCount(SheetType::Agent); for (i = 0; i < n; i++) { - StyleSheet* ss = aSet->StyleSheetAt(SheetType::Agent, i); + ServoStyleSheet* ss = aSet->StyleSheetAt(SheetType::Agent, i); if (ss) aClone->AppendStyleSheet(SheetType::Agent, ss); } } -ServoStyleSet* +UniquePtr PresShell::CloneStyleSet(ServoStyleSet* aSet) { - ServoStyleSet* clone = new ServoStyleSet(); - CopySheetsIntoClone(aSet, clone); + auto clone = MakeUnique(); + CopySheetsIntoClone(aSet, clone.get()); return clone; } @@ -9588,12 +9588,10 @@ PresShell::VerifyIncrementalReflow() // Create a new presentation shell to view the document. Use the // exact same style information that this document has. - nsAutoPtr newServoSet(CloneStyleSet(mStyleSet->AsServo())); - StyleSetHandle newSet(newServoSet); + UniquePtr newSet = CloneStyleSet(StyleSet()); - nsCOMPtr sh = mDocument->CreateShell(cx, vm, newSet); + nsCOMPtr sh = mDocument->CreateShell(cx, vm, Move(newSet)); NS_ENSURE_TRUE(sh, false); - newServoSet.forget(); // Note that after we create the shell, we must make sure to destroy it sh->SetVerifyReflowEnable(false); // turn off verify reflow while we're reflowing the test frame tree vm->SetPresShell(sh); @@ -10321,7 +10319,7 @@ PresShell::AddSizeOfIncludingThis(nsWindowSizes& aSizes) const mApproximatelyVisibleFrames.ShallowSizeOfExcludingThis(mallocSizeOf) + mFramesToDirty.ShallowSizeOfExcludingThis(mallocSizeOf); - StyleSet()->AsServo()->AddSizeOfIncludingThis(aSizes); + StyleSet()->AddSizeOfIncludingThis(aSizes); aSizes.mLayoutTextRunsSize += SizeOfTextRuns(mallocSizeOf); diff --git a/layout/base/PresShell.h b/layout/base/PresShell.h index 63dc9f9c4d7b..f9a97735730e 100644 --- a/layout/base/PresShell.h +++ b/layout/base/PresShell.h @@ -14,7 +14,7 @@ #include "mozilla/EventForwards.h" #include "mozilla/layers/FocusTarget.h" #include "mozilla/MemoryReporting.h" -#include "mozilla/StyleSetHandle.h" +#include "mozilla/ServoStyleSet.h" #include "mozilla/UniquePtr.h" #include "nsAutoPtr.h" #include "nsContentUtils.h" // For AddScriptBlocker(). @@ -45,6 +45,7 @@ class nsAutoCauseReflowNotifier; class AutoPointerEventTargetUpdater; namespace mozilla { +class ServoStyleSheet; namespace dom { class Element; @@ -81,7 +82,8 @@ class PresShell final : public nsIPresShell, static bool AccessibleCaretEnabled(nsIDocShell* aDocShell); void Init(nsIDocument* aDocument, nsPresContext* aPresContext, - nsViewManager* aViewManager, StyleSetHandle aStyleSet); + nsViewManager* aViewManager, + UniquePtr aStyleSet); void Destroy() override; void UpdatePreferenceStyles() override; @@ -158,9 +160,9 @@ class PresShell final : public nsIPresShell, void UnsuppressPainting() override; nsresult GetAgentStyleSheets( - nsTArray>& aSheets) override; + nsTArray>& aSheets) override; nsresult SetAgentStyleSheets( - const nsTArray>& aSheets) override; + const nsTArray>& aSheets) override; nsresult AddOverrideStyleSheet(StyleSheet* aSheet) override; nsresult RemoveOverrideStyleSheet(StyleSheet* aSheet) override; @@ -505,7 +507,7 @@ class PresShell final : public nsIPresShell, bool mCaretEnabled; #ifdef DEBUG - ServoStyleSet* CloneStyleSet(ServoStyleSet* aSet); + UniquePtr CloneStyleSet(ServoStyleSet* aSet); bool VerifyIncrementalReflow(); bool mInVerifyReflow; void ShowEventTargetDebug(); diff --git a/layout/base/RestyleManager.cpp b/layout/base/RestyleManager.cpp index 963e9c63fc56..e18383b8c10f 100644 --- a/layout/base/RestyleManager.cpp +++ b/layout/base/RestyleManager.cpp @@ -9,8 +9,6 @@ #include "Layers.h" #include "LayerAnimationInfo.h" // For LayerAnimationInfo::sRecords -#include "mozilla/StyleSetHandleInlines.h" -#include "mozilla/ServoStyleSetInlines.h" #include "nsAnimationManager.h" #include "nsCSSFrameConstructor.h" #include "nsCSSRendering.h" diff --git a/layout/base/ServoRestyleManager.cpp b/layout/base/ServoRestyleManager.cpp index 3d33a7686b84..4bd1910da41f 100644 --- a/layout/base/ServoRestyleManager.cpp +++ b/layout/base/ServoRestyleManager.cpp @@ -12,7 +12,7 @@ #include "mozilla/ComputedStyleInlines.h" #include "mozilla/DocumentStyleRootIterator.h" #include "mozilla/ServoBindings.h" -#include "mozilla/ServoStyleSet.h" +#include "mozilla/ServoStyleSetInlines.h" #include "mozilla/Unused.h" #include "mozilla/ViewportFrame.h" #include "mozilla/dom/ChildIterator.h" @@ -1547,7 +1547,7 @@ ServoRestyleManager::ReparentComputedStyle(nsIFrame* aFrame) void ServoRestyleManager::DoReparentComputedStyle(nsIFrame* aFrame, - ServoStyleSet& aStyleSet) + ServoStyleSet& aStyleSet) { if (aFrame->IsBackdropFrame()) { // Style context of backdrop frame has no parent style, and thus we do not diff --git a/layout/base/ServoRestyleManager.h b/layout/base/ServoRestyleManager.h index c93988fd4327..c769da0049df 100644 --- a/layout/base/ServoRestyleManager.h +++ b/layout/base/ServoRestyleManager.h @@ -19,6 +19,7 @@ namespace mozilla { namespace dom { class Element; } // namespace dom +class ServoStyleSet; } // namespace mozilla class nsAttrValue; class nsAtom; @@ -303,10 +304,7 @@ class ServoRestyleManager : public RestyleManager ServoRestyleState& aRestyleState, ServoPostTraversalFlags aFlags); - inline ServoStyleSet* StyleSet() const - { - return PresContext()->StyleSet()->AsServo(); - } + inline ServoStyleSet* StyleSet() const { return PresContext()->StyleSet(); } const SnapshotTable& Snapshots() const { return mSnapshots; } void ClearSnapshots(); diff --git a/layout/base/nsCSSFrameConstructor.cpp b/layout/base/nsCSSFrameConstructor.cpp index 3a4f00dcc473..b7939dba2f9e 100644 --- a/layout/base/nsCSSFrameConstructor.cpp +++ b/layout/base/nsCSSFrameConstructor.cpp @@ -40,8 +40,6 @@ #include "nsHTMLParts.h" #include "nsIPresShell.h" #include "nsUnicharUtils.h" -#include "mozilla/StyleSetHandle.h" -#include "mozilla/StyleSetHandleInlines.h" #include "nsViewManager.h" #include "nsStyleConsts.h" #ifdef MOZ_XUL @@ -1831,7 +1829,7 @@ nsCSSFrameConstructor::CreateGeneratedContentItem(nsFrameConstructorState& aStat aPseudoElement == CSSPseudoElementType::after, "unexpected aPseudoElement"); - StyleSetHandle styleSet = mPresShell->StyleSet(); + ServoStyleSet* styleSet = mPresShell->StyleSet(); // Probe for the existence of the pseudo-element RefPtr pseudoComputedStyle; @@ -1889,9 +1887,8 @@ nsCSSFrameConstructor::CreateGeneratedContentItem(nsFrameConstructorState& aStat // If animations are involved, we avoid the SetExplicitStyle optimization // above. We need to grab style with animations from the pseudo element // and replace old one. - mPresShell->StyleSet()->AsServo()->StyleNewSubtree(container); - pseudoComputedStyle = - styleSet->AsServo()->ResolveServoStyle(container); + mPresShell->StyleSet()->StyleNewSubtree(container); + pseudoComputedStyle = styleSet->ResolveServoStyle(container); } uint32_t contentCount = pseudoComputedStyle->StyleContent()->ContentCount(); @@ -1904,7 +1901,7 @@ nsCSSFrameConstructor::CreateGeneratedContentItem(nsFrameConstructorState& aStat if (content->IsElement()) { // If we created any children elements, Servo needs to traverse them, but // the root is already set up. - mPresShell->StyleSet()->AsServo()->StyleNewSubtree(content->AsElement()); + mPresShell->StyleSet()->StyleNewSubtree(content->AsElement()); } } } @@ -2433,18 +2430,17 @@ nsCSSFrameConstructor::ConstructDocElementFrame(Element* aDocEle state.mPresShell->CaptureHistoryState(getter_AddRefs(mTempFrameTreeState)); // --------- CREATE AREA OR BOX FRAME ------- - if (ServoStyleSet* set = mPresShell->StyleSet()->GetAsServo()) { - // Ensure the document element is styled at this point. - if (!aDocElement->HasServoData()) { - // NOTE(emilio): If the root has a non-null binding, we'll stop at the - // document element and won't process any children, loading the bindings - // (or failing to do so) will take care of the rest. - set->StyleNewSubtree(aDocElement); - } + ServoStyleSet* set = mPresShell->StyleSet(); + // Ensure the document element is styled at this point. + if (!aDocElement->HasServoData()) { + // NOTE(emilio): If the root has a non-null binding, we'll stop at the + // document element and won't process any children, loading the bindings + // (or failing to do so) will take care of the rest. + set->StyleNewSubtree(aDocElement); } RefPtr computedStyle = - mPresShell->StyleSet()->AsServo()->ResolveServoStyle(aDocElement); + mPresShell->StyleSet()->ResolveServoStyle(aDocElement); const nsStyleDisplay* display = computedStyle->StyleDisplay(); @@ -2476,8 +2472,7 @@ nsCSSFrameConstructor::ConstructDocElementFrame(Element* aDocEle } if (resolveStyle) { - computedStyle = - mPresShell->StyleSet()->AsServo()->ResolveServoStyle(aDocElement); + computedStyle = mPresShell->StyleSet()->ResolveServoStyle(aDocElement); display = computedStyle->StyleDisplay(); } } @@ -2685,7 +2680,7 @@ nsCSSFrameConstructor::ConstructRootFrame() { AUTO_LAYOUT_PHASE_ENTRY_POINT(mPresShell->GetPresContext(), FrameC); - StyleSetHandle styleSet = mPresShell->StyleSet(); + ServoStyleSet* styleSet = mPresShell->StyleSet(); // --------- BUILD VIEWPORT ----------- RefPtr viewportPseudoStyle = @@ -2852,7 +2847,7 @@ nsCSSFrameConstructor::SetUpDocElementContainingBlock(nsIContent* aDocElement) // Start off with the viewport as parent; we'll adjust it as needed. nsContainerFrame* parentFrame = viewportFrame; - StyleSetHandle styleSet = mPresShell->StyleSet(); + ServoStyleSet* styleSet = mPresShell->StyleSet(); // If paginated, make sure we don't put scrollbars in if (!isScrollable) { rootPseudoStyle = @@ -2956,7 +2951,7 @@ nsCSSFrameConstructor::ConstructPageFrame(nsIPresShell* aPresShell, nsContainerFrame*& aCanvasFrame) { ComputedStyle* parentComputedStyle = aParentFrame->Style(); - StyleSetHandle styleSet = aPresShell->StyleSet(); + ServoStyleSet* styleSet = aPresShell->StyleSet(); RefPtr pagePseudoStyle; pagePseudoStyle = @@ -4240,12 +4235,11 @@ nsCSSFrameConstructor::GetAnonymousContent(nsIContent* aParent, } } - if (ServoStyleSet* styleSet = mPresShell->StyleSet()->GetAsServo()) { - // Eagerly compute styles for the anonymous content tree. - for (auto& info : aContent) { - if (info.mContent->IsElement()) { - styleSet->StyleNewSubtree(info.mContent->AsElement()); - } + ServoStyleSet* styleSet = mPresShell->StyleSet(); + // Eagerly compute styles for the anonymous content tree. + for (auto& info : aContent) { + if (info.mContent->IsElement()) { + styleSet->StyleNewSubtree(info.mContent->AsElement()); } } @@ -4598,7 +4592,7 @@ nsCSSFrameConstructor::BeginBuildingScrollFrame(nsFrameConstructorState& aState, gfxScrollFrame->AddStateBits(NS_FRAME_OWNS_ANON_BOXES); // we used the style that was passed in. So resolve another one. - StyleSetHandle styleSet = mPresShell->StyleSet(); + ServoStyleSet* styleSet = mPresShell->StyleSet(); RefPtr scrolledChildStyle = styleSet->ResolveInheritingAnonymousBoxStyle(aScrolledPseudo, contentStyle); @@ -5009,7 +5003,7 @@ nsCSSFrameConstructor::InitAndRestoreFrame(const nsFrameConstructorState& aState already_AddRefed nsCSSFrameConstructor::ResolveComputedStyle(nsIContent* aContent) { - ServoStyleSet* styleSet = mPresShell->StyleSet()->AsServo(); + ServoStyleSet* styleSet = mPresShell->StyleSet(); if (aContent->IsElement()) { return styleSet->ResolveServoStyle(aContent->AsElement()); @@ -5055,7 +5049,7 @@ nsCSSFrameConstructor::FlushAccumulatedBlock(nsFrameConstructorState& aState, ComputedStyle* parentContext = nsFrame::CorrectStyleParentFrame(aParentFrame, anonPseudo)->Style(); - StyleSetHandle styleSet = mPresShell->StyleSet(); + ServoStyleSet* styleSet = mPresShell->StyleSet(); RefPtr blockContext; blockContext = styleSet-> ResolveInheritingAnonymousBoxStyle(anonPseudo, parentContext); @@ -5696,7 +5690,7 @@ nsCSSFrameConstructor::AddFrameConstructionItemsInternal(nsFrameConstructorState if (resolveStyle) { computedStyle = - mPresShell->StyleSet()->AsServo()->ResolveServoStyle(aContent->AsElement()); + mPresShell->StyleSet()->ResolveServoStyle(aContent->AsElement()); } display = computedStyle->StyleDisplay(); @@ -7077,7 +7071,7 @@ void nsCSSFrameConstructor::StyleNewChildRange(nsIContent* aStartChild, nsIContent* aEndChild) { - ServoStyleSet* styleSet = mPresShell->StyleSet()->AsServo(); + ServoStyleSet* styleSet = mPresShell->StyleSet(); for (nsIContent* child = aStartChild; child != aEndChild; child = child->GetNextSibling()) { @@ -10753,7 +10747,7 @@ nsCSSFrameConstructor::CreateFloatingLetterFrame( // Make sure we get a proper style for it (the one passed in is for the letter // frame and will have the float property set on it; the text frame shouldn't // have that set). - StyleSetHandle styleSet = mPresShell->StyleSet(); + ServoStyleSet* styleSet = mPresShell->StyleSet(); RefPtr textSC = styleSet-> ResolveStyleForText(aTextContent, aComputedStyle); aTextFrame->SetComputedStyleWithoutNotification(textSC); @@ -10834,7 +10828,7 @@ nsCSSFrameConstructor::CreateLetterFrame(nsContainerFrame* aBlockFrame, nsCSSPseudoElements::firstLetter); sc = - mPresShell->StyleSet()->AsServo()->ReparentComputedStyle( + mPresShell->StyleSet()->ReparentComputedStyle( sc, parentComputedStyle, parentIgnoringFirstLine->Style(), diff --git a/layout/base/nsDocumentViewer.cpp b/layout/base/nsDocumentViewer.cpp index c67888fd664e..ce54c516659f 100644 --- a/layout/base/nsDocumentViewer.cpp +++ b/layout/base/nsDocumentViewer.cpp @@ -22,8 +22,6 @@ #include "nsIDocument.h" #include "nsPresContext.h" #include "nsIPresShell.h" -#include "mozilla/StyleSetHandle.h" -#include "mozilla/StyleSetHandleInlines.h" #include "nsIFrame.h" #include "nsIWritablePropertyBag2.h" #include "nsSubDocumentFrame.h" @@ -685,17 +683,17 @@ nsDocumentViewer::InitPresentationStuff(bool aDoInitialReflow) "Someone should have destroyed the presshell!"); // Create the style set... - StyleSetHandle styleSet = CreateStyleSet(mDocument); + UniquePtr styleSet = CreateStyleSet(mDocument); // Now make the shell for the document - mPresShell = mDocument->CreateShell(mPresContext, mViewManager, styleSet); + mPresShell = mDocument->CreateShell(mPresContext, mViewManager, + mozilla::Move(styleSet)); if (!mPresShell) { - styleSet->Delete(); return NS_ERROR_FAILURE; } // We're done creating the style set - styleSet->EndUpdate(); + mPresShell->StyleSet()->EndUpdate(); if (aDoInitialReflow) { // Since Initialize() will create frames for *all* items @@ -2309,7 +2307,7 @@ nsDocumentViewer::RequestWindowClose(bool* aCanClose) return NS_OK; } -StyleSetHandle +UniquePtr nsDocumentViewer::CreateStyleSet(nsIDocument* aDocument) { // Make sure this does the same thing as PresShell::AddSheet wrt ordering. @@ -2317,7 +2315,7 @@ nsDocumentViewer::CreateStyleSet(nsIDocument* aDocument) // this should eventually get expanded to allow for creating // different sets for different media - StyleSetHandle styleSet = new ServoStyleSet(); + UniquePtr styleSet = MakeUnique(); styleSet->BeginUpdate(); @@ -2347,8 +2345,9 @@ nsDocumentViewer::CreateStyleSet(nsIDocument* aDocument) sheet = cache->UserContentSheet(); } - if (sheet) - styleSet->AppendStyleSheet(SheetType::User, sheet); + if (sheet) { + styleSet->AppendStyleSheet(SheetType::User, sheet->AsServo()); + } // Append chrome sheets (scrollbars + forms). bool shouldOverride = false; @@ -2384,7 +2383,7 @@ nsDocumentViewer::CreateStyleSet(nsIDocument* aDocument) cssLoader->LoadSheetSync(uri, &chromeSheet); if (!chromeSheet) continue; - styleSet->PrependStyleSheet(SheetType::Agent, chromeSheet); + styleSet->PrependStyleSheet(SheetType::Agent, chromeSheet->AsServo()); shouldOverride = true; } free(str); @@ -2395,7 +2394,7 @@ nsDocumentViewer::CreateStyleSet(nsIDocument* aDocument) if (!shouldOverride) { sheet = cache->ScrollbarsSheet(); if (sheet) { - styleSet->PrependStyleSheet(SheetType::Agent, sheet); + styleSet->PrependStyleSheet(SheetType::Agent, sheet->AsServo()); } } @@ -2411,26 +2410,26 @@ nsDocumentViewer::CreateStyleSet(nsIDocument* aDocument) sheet = cache->NumberControlSheet(); if (sheet) { - styleSet->PrependStyleSheet(SheetType::Agent, sheet); + styleSet->PrependStyleSheet(SheetType::Agent, sheet->AsServo()); } sheet = cache->FormsSheet(); if (sheet) { - styleSet->PrependStyleSheet(SheetType::Agent, sheet); + styleSet->PrependStyleSheet(SheetType::Agent, sheet->AsServo()); } if (aDocument->LoadsFullXULStyleSheetUpFront()) { // This is the only place components.css gets loaded, unlike xul.css sheet = cache->XULComponentsSheet(); if (sheet) { - styleSet->PrependStyleSheet(SheetType::Agent, sheet); + styleSet->PrependStyleSheet(SheetType::Agent, sheet->AsServo()); } // nsXULElement::BindToTree loads xul.css on-demand if we don't load it // up-front here. sheet = cache->XULSheet(); if (sheet) { - styleSet->PrependStyleSheet(SheetType::Agent, sheet); + styleSet->PrependStyleSheet(SheetType::Agent, sheet->AsServo()); } } @@ -2438,25 +2437,25 @@ nsDocumentViewer::CreateStyleSet(nsIDocument* aDocument) if (sheet) { // Load the minimal XUL rules for scrollbars and a few other XUL things // that non-XUL (typically HTML) documents commonly use. - styleSet->PrependStyleSheet(SheetType::Agent, sheet); + styleSet->PrependStyleSheet(SheetType::Agent, sheet->AsServo()); } sheet = cache->CounterStylesSheet(); if (sheet) { - styleSet->PrependStyleSheet(SheetType::Agent, sheet); + styleSet->PrependStyleSheet(SheetType::Agent, sheet->AsServo()); } if (nsLayoutUtils::ShouldUseNoScriptSheet(aDocument)) { sheet = cache->NoScriptSheet(); if (sheet) { - styleSet->PrependStyleSheet(SheetType::Agent, sheet); + styleSet->PrependStyleSheet(SheetType::Agent, sheet->AsServo()); } } if (nsLayoutUtils::ShouldUseNoFramesSheet(aDocument)) { sheet = cache->NoFramesSheet(); if (sheet) { - styleSet->PrependStyleSheet(SheetType::Agent, sheet); + styleSet->PrependStyleSheet(SheetType::Agent, sheet->AsServo()); } } @@ -2465,26 +2464,26 @@ nsDocumentViewer::CreateStyleSet(nsIDocument* aDocument) sheet = cache->HTMLSheet(); if (sheet) { - styleSet->PrependStyleSheet(SheetType::Agent, sheet); + styleSet->PrependStyleSheet(SheetType::Agent, sheet->AsServo()); } styleSet->PrependStyleSheet(SheetType::Agent, - cache->UASheet()); + cache->UASheet()->AsServo()); } else { // SVG documents may have scrollbars and need the scrollbar styling. sheet = cache->MinimalXULSheet(); if (sheet) { - styleSet->PrependStyleSheet(SheetType::Agent, sheet); + styleSet->PrependStyleSheet(SheetType::Agent, sheet->AsServo()); } } nsStyleSheetService* sheetService = nsStyleSheetService::GetInstance(); if (sheetService) { for (StyleSheet* sheet : *sheetService->AgentStyleSheets()) { - styleSet->AppendStyleSheet(SheetType::Agent, sheet); + styleSet->AppendStyleSheet(SheetType::Agent, sheet->AsServo()); } for (StyleSheet* sheet : Reversed(*sheetService->UserStyleSheets())) { - styleSet->PrependStyleSheet(SheetType::User, sheet); + styleSet->PrependStyleSheet(SheetType::User, sheet->AsServo()); } } diff --git a/layout/base/nsIDocumentViewerPrint.h b/layout/base/nsIDocumentViewerPrint.h index 45207a1617c2..50ff526a9495 100644 --- a/layout/base/nsIDocumentViewerPrint.h +++ b/layout/base/nsIDocumentViewerPrint.h @@ -7,10 +7,11 @@ #define nsIDocumentViewerPrint_h___ #include "nsISupports.h" +#include "mozilla/UniquePtr.h" class nsIDocument; namespace mozilla { -class StyleSetHandle; +class ServoStyleSet; } // namespace mozilla class nsIPresShell; class nsPresContext; @@ -39,7 +40,8 @@ class nsIDocumentViewerPrint : public nsISupports // The style set returned by CreateStyleSet is in the middle of an // update batch so that the caller can add sheets to it if needed. // Callers should call EndUpdate() on it when ready to use. - virtual mozilla::StyleSetHandle CreateStyleSet(nsIDocument* aDocument) = 0; + virtual mozilla::UniquePtr + CreateStyleSet(nsIDocument* aDocument) = 0; /** * This is used by nsPagePrintTimer to make nsDocumentViewer::Destroy() @@ -78,7 +80,8 @@ NS_DEFINE_STATIC_IID_ACCESSOR(nsIDocumentViewerPrint, bool GetIsPrinting() override; \ void SetIsPrintPreview(bool aIsPrintPreview) override; \ bool GetIsPrintPreview() override; \ - mozilla::StyleSetHandle CreateStyleSet(nsIDocument* aDocument) override; \ + mozilla::UniquePtr \ + CreateStyleSet(nsIDocument* aDocument) override; \ void IncrementDestroyBlockedCount() override; \ void DecrementDestroyBlockedCount() override; \ void OnDonePrinting() override; \ diff --git a/layout/base/nsIPresShell.h b/layout/base/nsIPresShell.h index e28fe78271ea..d3b2a11d0797 100644 --- a/layout/base/nsIPresShell.h +++ b/layout/base/nsIPresShell.h @@ -13,9 +13,10 @@ #include "mozilla/EventForwards.h" #include "mozilla/FlushType.h" #include "mozilla/MemoryReporting.h" +#include "mozilla/ServoStyleSet.h" #include "mozilla/StaticPtr.h" -#include "mozilla/StyleSetHandle.h" #include "mozilla/StyleSheet.h" +#include "mozilla/UniquePtr.h" #include "mozilla/WeakPtr.h" #include "GeckoProfiler.h" #include "gfxPoint.h" @@ -56,7 +57,7 @@ class nsCanvasFrame; class nsCaret; namespace mozilla { class AccessibleCaretEventHub; -class CSSStyleSheet; +class ServoStyleSheet; } // namespace mozilla class nsFrameSelection; class nsFrameManager; @@ -278,7 +279,7 @@ class nsIPresShell : public nsStubDocumentObserver } #endif - mozilla::StyleSetHandle StyleSet() const { return mStyleSet; } + mozilla::ServoStyleSet* StyleSet() const { return mStyleSet.get(); } nsCSSFrameConstructor* FrameConstructor() const { return mFrameConstructor; } @@ -993,13 +994,13 @@ class nsIPresShell : public nsStubDocumentObserver * Get the set of agent style sheets for this presentation */ virtual nsresult GetAgentStyleSheets( - nsTArray>& aSheets) = 0; + nsTArray>& aSheets) = 0; /** * Replace the set of agent style sheets */ virtual nsresult SetAgentStyleSheets( - const nsTArray>& aSheets) = 0; + const nsTArray>& aSheets) = 0; /** * Add an override style sheet for this presentation @@ -1694,7 +1695,7 @@ class nsIPresShell : public nsStubDocumentObserver // we must share ownership. nsCOMPtr mDocument; RefPtr mPresContext; - mozilla::StyleSetHandle mStyleSet; // [OWNS] + mozilla::UniquePtr mStyleSet; nsCSSFrameConstructor* mFrameConstructor; // [OWNS] nsViewManager* mViewManager; // [WEAK] docViewer owns it so I don't have to nsPresArena mFrameArena; diff --git a/layout/base/nsLayoutUtils.cpp b/layout/base/nsLayoutUtils.cpp index 314d716e6ecf..7cb920c3f5ca 100644 --- a/layout/base/nsLayoutUtils.cpp +++ b/layout/base/nsLayoutUtils.cpp @@ -116,8 +116,7 @@ #include "mozilla/Telemetry.h" #include "mozilla/EventDispatcher.h" #include "mozilla/StyleAnimationValue.h" -#include "mozilla/StyleSetHandle.h" -#include "mozilla/StyleSetHandleInlines.h" +#include "mozilla/ServoStyleSet.h" #include "mozilla/WheelHandlingHelper.h" // for WheelHandlingUtils #include "RegionBuilder.h" #include "SVGViewportElement.h" diff --git a/layout/base/nsPresContext.cpp b/layout/base/nsPresContext.cpp index dc46555c1674..31743a9e8278 100644 --- a/layout/base/nsPresContext.cpp +++ b/layout/base/nsPresContext.cpp @@ -23,8 +23,7 @@ #include "nsDocShell.h" #include "nsIContentViewer.h" #include "nsPIDOMWindow.h" -#include "mozilla/StyleSetHandle.h" -#include "mozilla/StyleSetHandleInlines.h" +#include "mozilla/ServoStyleSet.h" #include "nsIContent.h" #include "nsIFrame.h" #include "nsIDocument.h" @@ -121,22 +120,11 @@ class ContainerLayerPresContext : public LayerUserData { nscolor nsPresContext::MakeColorPref(const nsString& aColor) { - bool ok; - nscolor result; - - ServoStyleSet* servoStyleSet = mShell && mShell->StyleSet() - ? mShell->StyleSet()->GetAsServo() - : nullptr; - - bool useServoParser = - true; + ServoStyleSet* styleSet = mShell ? mShell->StyleSet() : nullptr; - if (useServoParser) { - ok = ServoCSSParser::ComputeColor(servoStyleSet, NS_RGB(0, 0, 0), aColor, - &result); - } else { - MOZ_CRASH("old style system disabled"); - } + nscolor result; + bool ok = ServoCSSParser:: + ComputeColor(styleSet, NS_RGB(0, 0, 0), aColor, &result); if (!ok) { // Any better choices? @@ -1202,8 +1190,8 @@ nsPresContext::CompatibilityModeChanged() return; } - StyleSetHandle styleSet = mShell->StyleSet(); - styleSet->AsServo()->CompatibilityModeChanged(); + ServoStyleSet* styleSet = mShell->StyleSet(); + styleSet->CompatibilityModeChanged(); if (doc->IsSVGDocument()) { // SVG documents never load quirk.css. @@ -1221,11 +1209,11 @@ nsPresContext::CompatibilityModeChanged() if (needsQuirkSheet) { // quirk.css needs to come after html.css; we just keep it at the end. DebugOnly rv = - styleSet->AppendStyleSheet(SheetType::Agent, sheet); + styleSet->AppendStyleSheet(SheetType::Agent, sheet->AsServo()); NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "failed to insert quirk.css"); } else { DebugOnly rv = - styleSet->RemoveStyleSheet(SheetType::Agent, sheet); + styleSet->RemoveStyleSheet(SheetType::Agent, sheet->AsServo()); NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "failed to remove quirk.css"); } @@ -1470,7 +1458,7 @@ GetPropagatedScrollbarStylesForViewport(nsPresContext* aPresContext, } // Check the style on the document root element - StyleSetHandle styleSet = aPresContext->StyleSet(); + ServoStyleSet* styleSet = aPresContext->StyleSet(); RefPtr rootStyle = styleSet->ResolveStyleFor(docElement, nullptr, LazyComputeBehavior::Allow); if (CheckOverflow(rootStyle->StyleDisplay(), aStyles)) { @@ -3022,7 +3010,7 @@ nsPresContext::FlushFontFeatureValues() } if (mFontFeatureValuesDirty) { - StyleSetHandle styleSet = mShell->StyleSet(); + ServoStyleSet* styleSet = mShell->StyleSet(); mFontFeatureValuesLookup = styleSet->BuildFontFeatureValueSet(); mFontFeatureValuesDirty = false; } diff --git a/layout/base/nsPresContext.h b/layout/base/nsPresContext.h index 6ea3bb8e5cb4..2a51de0cba02 100644 --- a/layout/base/nsPresContext.h +++ b/layout/base/nsPresContext.h @@ -223,7 +223,8 @@ class nsPresContext : public nsISupports, return mDocument; } - mozilla::StyleSetHandle StyleSet() const { return GetPresShell()->StyleSet(); } + mozilla::ServoStyleSet* StyleSet() const + { return GetPresShell()->StyleSet(); } bool HasPendingMediaQueryUpdates() const { diff --git a/layout/forms/nsButtonFrameRenderer.cpp b/layout/forms/nsButtonFrameRenderer.cpp index 38f0bd3ed7ec..07e0c93d7c96 100644 --- a/layout/forms/nsButtonFrameRenderer.cpp +++ b/layout/forms/nsButtonFrameRenderer.cpp @@ -9,8 +9,7 @@ #include "nsGkAtoms.h" #include "nsCSSPseudoElements.h" #include "nsNameSpaceManager.h" -#include "mozilla/StyleSetHandle.h" -#include "mozilla/StyleSetHandleInlines.h" +#include "mozilla/ServoStyleSet.h" #include "mozilla/Unused.h" #include "nsDisplayList.h" #include "nsITheme.h" @@ -559,7 +558,7 @@ nsButtonFrameRenderer::ReResolveStyles(nsPresContext* aPresContext) { // get all the styles ComputedStyle* context = mFrame->Style(); - StyleSetHandle styleSet = aPresContext->StyleSet(); + ServoStyleSet* styleSet = aPresContext->StyleSet(); // get styles assigned to -moz-inner-focus (ie dotted border on Windows) mInnerFocusStyle = diff --git a/layout/forms/nsColorControlFrame.cpp b/layout/forms/nsColorControlFrame.cpp index fbd254e17535..0d553d872f40 100644 --- a/layout/forms/nsColorControlFrame.cpp +++ b/layout/forms/nsColorControlFrame.cpp @@ -13,8 +13,6 @@ #include "nsGkAtoms.h" #include "nsIDOMNode.h" #include "nsIFormControl.h" -#include "mozilla/StyleSetHandle.h" -#include "mozilla/StyleSetHandleInlines.h" #include "mozilla/dom/HTMLInputElement.h" #include "nsIDocument.h" diff --git a/layout/forms/nsComboboxControlFrame.cpp b/layout/forms/nsComboboxControlFrame.cpp index 43d7c919afa0..d72b781e8d68 100644 --- a/layout/forms/nsComboboxControlFrame.cpp +++ b/layout/forms/nsComboboxControlFrame.cpp @@ -33,8 +33,7 @@ #include "nsIDocument.h" #include "nsIScrollableFrame.h" #include "nsListControlFrame.h" -#include "mozilla/StyleSetHandle.h" -#include "mozilla/StyleSetHandleInlines.h" +#include "mozilla/ServoStyleSet.h" #include "nsNodeInfoManager.h" #include "nsContentCreatorFunctions.h" #include "nsLayoutUtils.h" @@ -1390,7 +1389,7 @@ nsComboboxControlFrame::CreateFrameForDisplayNode() // Get PresShell nsIPresShell *shell = PresShell(); - StyleSetHandle styleSet = shell->StyleSet(); + ServoStyleSet* styleSet = shell->StyleSet(); // create the ComputedStyle for the anonymous block frame and text frame RefPtr computedStyle; diff --git a/layout/forms/nsGfxButtonControlFrame.cpp b/layout/forms/nsGfxButtonControlFrame.cpp index cf6a26996293..4d524b5a03ae 100644 --- a/layout/forms/nsGfxButtonControlFrame.cpp +++ b/layout/forms/nsGfxButtonControlFrame.cpp @@ -7,8 +7,6 @@ #include "nsGfxButtonControlFrame.h" #include "nsIFormControl.h" #include "nsGkAtoms.h" -#include "mozilla/StyleSetHandle.h" -#include "mozilla/StyleSetHandleInlines.h" #include "mozilla/dom/HTMLInputElement.h" #include "nsContentUtils.h" #include "nsTextNode.h" diff --git a/layout/forms/nsMeterFrame.cpp b/layout/forms/nsMeterFrame.cpp index b11c671c09eb..9565cc3cf722 100644 --- a/layout/forms/nsMeterFrame.cpp +++ b/layout/forms/nsMeterFrame.cpp @@ -20,8 +20,6 @@ #include "mozilla/dom/Element.h" #include "mozilla/dom/HTMLMeterElement.h" #include "nsCSSPseudoElements.h" -#include "mozilla/StyleSetHandle.h" -#include "mozilla/StyleSetHandleInlines.h" #include "nsThemeConstants.h" #include diff --git a/layout/forms/nsNumberControlFrame.cpp b/layout/forms/nsNumberControlFrame.cpp index 69669659fecb..675672f76baf 100644 --- a/layout/forms/nsNumberControlFrame.cpp +++ b/layout/forms/nsNumberControlFrame.cpp @@ -21,8 +21,6 @@ #include "nsContentUtils.h" #include "nsContentCreatorFunctions.h" #include "nsCSSPseudoElements.h" -#include "mozilla/StyleSetHandle.h" -#include "mozilla/StyleSetHandleInlines.h" #include "nsThreadUtils.h" #include "mozilla/FloatingPoint.h" #include "mozilla/dom/MutationEventBinding.h" diff --git a/layout/forms/nsProgressFrame.cpp b/layout/forms/nsProgressFrame.cpp index 0d60d479a1a2..b35606e71aaa 100644 --- a/layout/forms/nsProgressFrame.cpp +++ b/layout/forms/nsProgressFrame.cpp @@ -20,8 +20,6 @@ #include "mozilla/dom/Element.h" #include "mozilla/dom/HTMLProgressElement.h" #include "nsCSSPseudoElements.h" -#include "mozilla/StyleSetHandle.h" -#include "mozilla/StyleSetHandleInlines.h" #include "nsThemeConstants.h" #include diff --git a/layout/forms/nsRangeFrame.cpp b/layout/forms/nsRangeFrame.cpp index dadc021b78d9..e5c759ee6d8b 100644 --- a/layout/forms/nsRangeFrame.cpp +++ b/layout/forms/nsRangeFrame.cpp @@ -24,8 +24,7 @@ #include "nsPresContext.h" #include "nsNodeInfoManager.h" #include "mozilla/dom/Element.h" -#include "mozilla/StyleSetHandle.h" -#include "mozilla/StyleSetHandleInlines.h" +#include "mozilla/ServoStyleSet.h" #include "nsThemeConstants.h" #ifdef ACCESSIBILITY @@ -79,7 +78,7 @@ nsRangeFrame::Init(nsIContent* aContent, } aContent->AddEventListener(NS_LITERAL_STRING("touchstart"), mDummyTouchListener, false); - StyleSetHandle styleSet = PresContext()->StyleSet(); + ServoStyleSet* styleSet = PresContext()->StyleSet(); mOuterFocusStyle = styleSet->ProbePseudoElementStyle(aContent->AsElement(), diff --git a/layout/forms/nsTextControlFrame.cpp b/layout/forms/nsTextControlFrame.cpp index 14d4f0897735..c130a21f8410 100644 --- a/layout/forms/nsTextControlFrame.cpp +++ b/layout/forms/nsTextControlFrame.cpp @@ -40,8 +40,6 @@ #include "mozilla/TextEditRules.h" #include "nsContentUtils.h" #include "nsTextNode.h" -#include "mozilla/StyleSetHandle.h" -#include "mozilla/StyleSetHandleInlines.h" #include "mozilla/dom/HTMLInputElement.h" #include "mozilla/dom/HTMLTextAreaElement.h" #include "mozilla/dom/ScriptSettings.h" diff --git a/layout/generic/nsBlockFrame.cpp b/layout/generic/nsBlockFrame.cpp index 65df14a8a553..299463123840 100644 --- a/layout/generic/nsBlockFrame.cpp +++ b/layout/generic/nsBlockFrame.cpp @@ -56,8 +56,6 @@ #include "mozilla/RestyleManagerInlines.h" #include "mozilla/ServoRestyleManager.h" #include "mozilla/ServoStyleSet.h" -#include "mozilla/StyleSetHandle.h" -#include "mozilla/StyleSetHandleInlines.h" #include "mozilla/Telemetry.h" #include "nsBidiPresUtils.h" @@ -7553,7 +7551,7 @@ nsBlockFrame::UpdatePseudoElementStyles(ServoRestyleState& aRestyleState) already_AddRefed nsBlockFrame::ResolveBulletStyle(CSSPseudoElementType aType, - StyleSetHandle aStyleSet) + ServoStyleSet* aStyleSet) { ComputedStyle* parentStyle = CorrectStyleParentFrame(this, diff --git a/layout/generic/nsBlockFrame.h b/layout/generic/nsBlockFrame.h index 512f599ad587..2b498f01815e 100644 --- a/layout/generic/nsBlockFrame.h +++ b/layout/generic/nsBlockFrame.h @@ -45,7 +45,7 @@ class nsBulletFrame; namespace mozilla { class BlockReflowInput; class ServoRestyleState; -class StyleSetHandle; +class ServoStyleSet; } // namespace mozilla /** @@ -943,7 +943,7 @@ class nsBlockFrame : public nsContainerFrame // optimization, because all callsites have it. already_AddRefed ResolveBulletStyle( mozilla::CSSPseudoElementType aType, - mozilla::StyleSetHandle aStyleSet); + mozilla::ServoStyleSet* aStyleSet); #ifdef DEBUG void VerifyLines(bool aFinalCheckOK); diff --git a/layout/generic/nsFirstLetterFrame.cpp b/layout/generic/nsFirstLetterFrame.cpp index ac0f18fdabcf..238d10aa0447 100644 --- a/layout/generic/nsFirstLetterFrame.cpp +++ b/layout/generic/nsFirstLetterFrame.cpp @@ -12,8 +12,7 @@ #include "nsIContent.h" #include "nsLineLayout.h" #include "nsGkAtoms.h" -#include "mozilla/StyleSetHandle.h" -#include "mozilla/StyleSetHandleInlines.h" +#include "mozilla/ServoStyleSet.h" #include "nsFrameManager.h" #include "mozilla/RestyleManager.h" #include "mozilla/RestyleManagerInlines.h" diff --git a/layout/generic/nsFrameSetFrame.cpp b/layout/generic/nsFrameSetFrame.cpp index b0d110008298..cb05690325c8 100644 --- a/layout/generic/nsFrameSetFrame.cpp +++ b/layout/generic/nsFrameSetFrame.cpp @@ -29,8 +29,7 @@ #include "nsHTMLParts.h" #include "nsNameSpaceManager.h" #include "nsCSSAnonBoxes.h" -#include "mozilla/StyleSetHandle.h" -#include "mozilla/StyleSetHandleInlines.h" +#include "mozilla/ServoStyleSet.h" #include "mozilla/dom/Element.h" #include "nsDisplayList.h" #include "nsNodeUtils.h" @@ -803,7 +802,7 @@ nsHTMLFramesetFrame::Reflow(nsPresContext* aPresContext, MOZ_ASSERT(aStatus.IsEmpty(), "Caller should pass a fresh reflow status!"); nsIPresShell *shell = aPresContext->PresShell(); - StyleSetHandle styleSet = shell->StyleSet(); + ServoStyleSet* styleSet = shell->StyleSet(); GetParent()->AddStateBits(NS_FRAME_CONTAINS_RELATIVE_BSIZE); diff --git a/layout/generic/nsImageFrame.cpp b/layout/generic/nsImageFrame.cpp index 3059478c96f3..c29a3ad0f150 100644 --- a/layout/generic/nsImageFrame.cpp +++ b/layout/generic/nsImageFrame.cpp @@ -71,8 +71,7 @@ #include "gfxRect.h" #include "ImageLayers.h" #include "ImageContainer.h" -#include "mozilla/StyleSetHandle.h" -#include "mozilla/StyleSetHandleInlines.h" +#include "mozilla/ServoStyleSet.h" #include "nsBlockFrame.h" #include "nsStyleStructInlines.h" diff --git a/layout/generic/nsInlineFrame.cpp b/layout/generic/nsInlineFrame.cpp index 075e3e54776f..5eafc7d83ad4 100644 --- a/layout/generic/nsInlineFrame.cpp +++ b/layout/generic/nsInlineFrame.cpp @@ -22,8 +22,6 @@ #include "SVGTextFrame.h" #include "nsStyleChangeList.h" #include "mozilla/ComputedStyle.h" -#include "mozilla/StyleSetHandle.h" -#include "mozilla/StyleSetHandleInlines.h" #include "mozilla/ServoStyleSet.h" #ifdef DEBUG diff --git a/layout/generic/nsTextFrame.cpp b/layout/generic/nsTextFrame.cpp index a38849090758..7ad4f56de707 100644 --- a/layout/generic/nsTextFrame.cpp +++ b/layout/generic/nsTextFrame.cpp @@ -66,8 +66,7 @@ #include "nsLineBreaker.h" #include "nsIFrameInlines.h" #include "mozilla/intl/WordBreaker.h" -#include "mozilla/StyleSetHandle.h" -#include "mozilla/StyleSetHandleInlines.h" +#include "mozilla/ServoStyleSet.h" #include "mozilla/layers/LayersMessages.h" #include "mozilla/layers/WebRenderLayerManager.h" #include "mozilla/layers/WebRenderBridgeChild.h" diff --git a/layout/inspector/InspectorUtils.cpp b/layout/inspector/InspectorUtils.cpp index c8d74d9b2f0e..fad9628326cc 100644 --- a/layout/inspector/InspectorUtils.cpp +++ b/layout/inspector/InspectorUtils.cpp @@ -39,7 +39,7 @@ #include "nsCSSProps.h" #include "nsCSSValue.h" #include "nsColor.h" -#include "mozilla/StyleSetHandleInlines.h" +#include "mozilla/ServoStyleSet.h" #include "nsStyleUtil.h" #include "nsQueryObject.h" #include "mozilla/ServoBindings.h" @@ -67,7 +67,7 @@ InspectorUtils::GetAllStyleSheets(GlobalObject& aGlobalObject, nsIPresShell* presShell = aDocument.GetShell(); if (presShell) { - StyleSetHandle styleSet = presShell->StyleSet(); + ServoStyleSet* styleSet = presShell->StyleSet(); SheetType sheetType = SheetType::Agent; for (int32_t i = 0; i < styleSet->SheetCount(sheetType); i++) { aResult.AppendElement(styleSet->StyleSheetAt(sheetType, i)); @@ -187,7 +187,7 @@ InspectorUtils::GetCSSStyleRules(GlobalObject& aGlobalObject, AutoTArray maps; { - ServoStyleSet* styleSet = shell->StyleSet()->AsServo(); + ServoStyleSet* styleSet = shell->StyleSet(); ServoStyleRuleMap* map = styleSet->StyleRuleMap(); maps.AppendElement(map); } diff --git a/layout/mathml/nsMathMLFrame.cpp b/layout/mathml/nsMathMLFrame.cpp index dca08ac74cb7..6a6abf8e5da1 100644 --- a/layout/mathml/nsMathMLFrame.cpp +++ b/layout/mathml/nsMathMLFrame.cpp @@ -17,8 +17,7 @@ #include "gfxMathTable.h" // used to map attributes into CSS rules -#include "mozilla/StyleSetHandle.h" -#include "mozilla/StyleSetHandleInlines.h" +#include "mozilla/ServoStyleSet.h" #include "nsDisplayList.h" using namespace mozilla; diff --git a/layout/printing/nsPrintJob.cpp b/layout/printing/nsPrintJob.cpp index 6102329db6f3..2149335ff643 100644 --- a/layout/printing/nsPrintJob.cpp +++ b/layout/printing/nsPrintJob.cpp @@ -119,8 +119,7 @@ static const char kPrintingPromptService[] = "@mozilla.org/embedcomp/printingpro #include "nsIChannel.h" #include "xpcpublic.h" #include "nsVariant.h" -#include "mozilla/StyleSetHandle.h" -#include "mozilla/StyleSetHandleInlines.h" +#include "mozilla/ServoStyleSet.h" using namespace mozilla; using namespace mozilla::dom; @@ -2345,19 +2344,20 @@ nsPrintJob::ReflowPrintObject(const UniquePtr& aPO) rv = aPO->mViewManager->Init(printData->mPrintDC); NS_ENSURE_SUCCESS(rv,rv); - StyleSetHandle styleSet = mDocViewerPrint->CreateStyleSet(aPO->mDocument); + UniquePtr styleSet = + mDocViewerPrint->CreateStyleSet(aPO->mDocument); if (aPO->mDocument->IsSVGDocument()) { // The SVG document only loads minimal-xul.css, so it doesn't apply other // styles. We should add ua.css for applying style which related to print. auto cache = nsLayoutStylesheetCache::Singleton(); - styleSet->PrependStyleSheet(SheetType::Agent, cache->UASheet()); + styleSet->PrependStyleSheet(SheetType::Agent, cache->UASheet()->AsServo()); } aPO->mPresShell = aPO->mDocument->CreateShell(aPO->mPresContext, - aPO->mViewManager, styleSet); + aPO->mViewManager, + Move(styleSet)); if (!aPO->mPresShell) { - styleSet->Delete(); return NS_ERROR_FAILURE; } @@ -2369,7 +2369,7 @@ nsPrintJob::ReflowPrintObject(const UniquePtr& aPO) DeleteUnselectedNodes(aPO->mDocument->GetOriginalDocument(), aPO->mDocument); } - styleSet->EndUpdate(); + aPO->mPresShell->StyleSet()->EndUpdate(); // The pres shell now owns the style set object. diff --git a/layout/style/ComputedStyle.cpp b/layout/style/ComputedStyle.cpp index 83057105a109..b2a2be5783f4 100644 --- a/layout/style/ComputedStyle.cpp +++ b/layout/style/ComputedStyle.cpp @@ -30,8 +30,6 @@ #include "mozilla/ArenaObjectID.h" #include "mozilla/ComputedStyleInlines.h" #include "mozilla/Preferences.h" -#include "mozilla/StyleSetHandle.h" -#include "mozilla/StyleSetHandleInlines.h" #include "mozilla/ReflowInput.h" #include "nsLayoutUtils.h" diff --git a/layout/style/ComputedStyle.h b/layout/style/ComputedStyle.h index 40842040e205..ab253e32a641 100644 --- a/layout/style/ComputedStyle.h +++ b/layout/style/ComputedStyle.h @@ -14,7 +14,6 @@ #include "mozilla/ArenaObjectID.h" #include "mozilla/Assertions.h" #include "mozilla/RestyleLogging.h" -#include "mozilla/ServoStyleSet.h" #include "mozilla/ServoTypes.h" #include "mozilla/ServoUtils.h" #include "mozilla/StyleComplexColor.h" diff --git a/layout/style/CounterStyleManager.cpp b/layout/style/CounterStyleManager.cpp index 28ca7d56bf39..c8dba3cccbde 100644 --- a/layout/style/CounterStyleManager.cpp +++ b/layout/style/CounterStyleManager.cpp @@ -17,8 +17,7 @@ #include "nsTArray.h" #include "nsTHashtable.h" #include "nsUnicodeProperties.h" -#include "mozilla/StyleSetHandle.h" -#include "mozilla/StyleSetHandleInlines.h" +#include "mozilla/ServoStyleSet.h" namespace mozilla { @@ -2035,7 +2034,7 @@ CounterStyleManager::BuildCounterStyle(nsAtom* aName) // Names are compared case-sensitively here. Predefined names should // have been lowercased by the parser. - StyleSetHandle styleSet = mPresContext->StyleSet(); + ServoStyleSet* styleSet = mPresContext->StyleSet(); nsCSSCounterStyleRule* rule = styleSet->CounterStyleRuleForName(aName); if (rule) { MOZ_ASSERT(rule->Name() == aName); @@ -2086,7 +2085,7 @@ CounterStyleManager::NotifyRuleChanged() CounterStyle* style = iter.Data(); bool toBeUpdated = false; bool toBeRemoved = false; - StyleSetHandle styleSet = mPresContext->StyleSet(); + ServoStyleSet* styleSet = mPresContext->StyleSet(); nsCSSCounterStyleRule* newRule = styleSet->CounterStyleRuleForName(iter.Key()); if (!newRule) { if (style->IsCustomStyle()) { diff --git a/layout/style/ServoMediaList.cpp b/layout/style/ServoMediaList.cpp index b49a63c710c1..f433da8781d6 100644 --- a/layout/style/ServoMediaList.cpp +++ b/layout/style/ServoMediaList.cpp @@ -94,7 +94,7 @@ bool ServoMediaList::Matches(nsPresContext* aPresContext) const { const RawServoStyleSet* rawSet = - aPresContext->StyleSet()->AsServo()->RawSet(); + aPresContext->StyleSet()->RawSet(); MOZ_ASSERT(rawSet, "The RawServoStyleSet should be valid!"); return Servo_MediaList_Matches(mRawList, rawSet); } diff --git a/layout/style/ServoStyleSheet.cpp b/layout/style/ServoStyleSheet.cpp index 9845ef85108e..278203f78507 100644 --- a/layout/style/ServoStyleSheet.cpp +++ b/layout/style/ServoStyleSheet.cpp @@ -11,7 +11,6 @@ #include "mozilla/ServoCSSRuleList.h" #include "mozilla/ServoImportRule.h" #include "mozilla/ServoMediaList.h" -#include "mozilla/ServoStyleSet.h" #include "mozilla/css/GroupRule.h" #include "mozilla/dom/CSSRuleList.h" #include "mozilla/dom/MediaList.h" diff --git a/layout/style/StyleAnimationValue.cpp b/layout/style/StyleAnimationValue.cpp index e1a39061a0b7..b26d363e2aac 100644 --- a/layout/style/StyleAnimationValue.cpp +++ b/layout/style/StyleAnimationValue.cpp @@ -11,8 +11,7 @@ #include "mozilla/ArrayUtils.h" #include "mozilla/MathAlgorithms.h" #include "mozilla/ServoBindings.h" -#include "mozilla/StyleSetHandle.h" -#include "mozilla/StyleSetHandleInlines.h" +#include "mozilla/ServoStyleSet.h" #include "mozilla/Tuple.h" #include "mozilla/UniquePtr.h" #include "nsAutoPtr.h" @@ -241,10 +240,8 @@ AnimationValue::FromString(nsCSSPropertyID aProperty, return result; } - result.mServo = - shell->StyleSet()->AsServo()->ComputeAnimationValue(aElement, - declarations, - computedStyle); + result.mServo = shell->StyleSet()-> + ComputeAnimationValue(aElement, declarations, computedStyle); return result; } diff --git a/layout/style/StyleSetHandle.h b/layout/style/StyleSetHandle.h deleted file mode 100644 index 2d7eb196c9e5..000000000000 --- a/layout/style/StyleSetHandle.h +++ /dev/null @@ -1,209 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=8 sts=2 et sw=2 tw=80: */ -/* 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_StyleSetHandle_h -#define mozilla_StyleSetHandle_h - -#include "mozilla/AtomArray.h" -#include "mozilla/EventStates.h" -#include "mozilla/MediaFeatureChange.h" -#include "mozilla/RefPtr.h" -#include "mozilla/ServoTypes.h" -#include "mozilla/SheetType.h" -#include "mozilla/StyleSheet.h" -#include "nsChangeHint.h" -#include "nsCSSPseudoElements.h" -#include "nsTArray.h" - -class nsBindingManager; -class nsCSSCounterStyleRule; -struct nsFontFaceRuleContainer; -class nsAtom; -class nsICSSAnonBoxPseudo; -class nsIContent; -class nsIDocument; -class nsStyleSet; -class nsPresContext; -class gfxFontFeatureValueSet; - -namespace mozilla { - -class ComputedStyle; -class CSSStyleSheet; -class ServoStyleSet; -namespace dom { -class Element; -class ShadowRoot; -} // namespace dom -namespace css { -class Rule; -} // namespace css - -/** - * Smart pointer class that can hold a pointer to either an nsStyleSet - * or a ServoStyleSet. - */ -class StyleSetHandle -{ -public: - // We define this Ptr class with a StyleSet API that forwards on to the - // wrapped pointer, rather than putting these methods on StyleSetHandle - // itself, so that we can have StyleSetHandle behave like a smart pointer and - // be dereferenced with operator->. - class Ptr - { - public: - friend class ::mozilla::StyleSetHandle; - - ServoStyleSet* AsServo() - { - return reinterpret_cast(mValue); - } - - ServoStyleSet* GetAsServo() { return AsServo(); } - - - const ServoStyleSet* AsServo() const - { - return const_cast(this)->AsServo(); - } - - const ServoStyleSet* GetAsServo() const { return AsServo(); } - - // These inline methods are defined in StyleSetHandleInlines.h. - inline void Delete(); - - // Style set interface. These inline methods are defined in - // StyleSetHandleInlines.h and just forward to the underlying - // nsStyleSet or ServoStyleSet. See corresponding comments in - // nsStyleSet.h for descriptions of these methods. - - inline void Init(nsPresContext* aPresContext); - inline void BeginShutdown(); - inline void Shutdown(); - inline bool GetAuthorStyleDisabled() const; - inline void SetAuthorStyleDisabled(bool aStyleDisabled); - inline void BeginUpdate(); - inline nsresult EndUpdate(); - inline already_AddRefed - ResolveStyleFor(dom::Element* aElement, - ComputedStyle* aParentContext, - LazyComputeBehavior aMayCompute); - inline already_AddRefed - ResolveStyleFor(dom::Element* aElement, LazyComputeBehavior aMayCompute); - - // TODO(emilio): This might be nicer (albeit a bit slower) if we just grab - // the style from the parent in ServoStyleSet. - // - // It may be faster if we account not having to pass it around in - // nsCSSFrameConstructor though. - inline already_AddRefed - ResolveStyleForText(nsIContent* aTextNode, ComputedStyle* aParentContext); - - inline already_AddRefed - ResolveStyleForFirstLetterContinuation(ComputedStyle* aParentContext); - inline already_AddRefed - ResolveStyleForPlaceholder(); - inline already_AddRefed - ResolvePseudoElementStyle(dom::Element* aParentElement, - mozilla::CSSPseudoElementType aType, - ComputedStyle* aParentContext, - dom::Element* aPseudoElement); - inline already_AddRefed - ResolveInheritingAnonymousBoxStyle(nsAtom* aPseudoTag, - ComputedStyle* aParentContext); - inline already_AddRefed - ResolveNonInheritingAnonymousBoxStyle(nsAtom* aPseudoTag); -#ifdef MOZ_XUL - inline already_AddRefed - ResolveXULTreePseudoStyle(dom::Element* aParentElement, - nsICSSAnonBoxPseudo* aPseudoTag, - ComputedStyle* aParentContext, - const AtomArray& aInputWord); -#endif - inline nsresult AppendStyleSheet(SheetType aType, StyleSheet* aSheet); - inline nsresult PrependStyleSheet(SheetType aType, StyleSheet* aSheet); - inline nsresult RemoveStyleSheet(SheetType aType, StyleSheet* aSheet); - inline nsresult ReplaceSheets(SheetType aType, - const nsTArray>& aNewSheets); - inline nsresult InsertStyleSheetBefore(SheetType aType, - StyleSheet* aNewSheet, - StyleSheet* aReferenceSheet); - inline int32_t SheetCount(SheetType aType) const; - inline StyleSheet* StyleSheetAt(SheetType aType, int32_t aIndex) const; - inline void AppendAllXBLStyleSheets(nsTArray& aArray) const; - inline nsresult RemoveDocStyleSheet(StyleSheet* aSheet); - inline nsresult AddDocStyleSheet(StyleSheet* aSheet, nsIDocument* aDocument); - - inline void RuleRemoved(StyleSheet&, css::Rule&); - inline void RuleAdded(StyleSheet&, css::Rule&); - inline void RuleChanged(StyleSheet&, css::Rule*); - - inline void RecordShadowStyleChange(mozilla::dom::ShadowRoot& aShadowRoot); - inline bool StyleSheetsHaveChanged() const; - inline void InvalidateStyleForCSSRuleChanges(); - inline nsRestyleHint MediumFeaturesChanged(mozilla::MediaFeatureChangeReason); - inline already_AddRefed - ProbePseudoElementStyle(dom::Element* aParentElement, - mozilla::CSSPseudoElementType aType, - ComputedStyle* aParentContext); - inline already_AddRefed - ProbePseudoElementStyle(dom::Element* aParentElement, - mozilla::CSSPseudoElementType aType); - - inline bool AppendFontFaceRules(nsTArray& aArray); - inline nsCSSCounterStyleRule* CounterStyleRuleForName(nsAtom* aName); - inline already_AddRefed BuildFontFeatureValueSet(); - - inline bool EnsureUniqueInnerOnCSSSheets(); - inline void SetNeedsRestyleAfterEnsureUniqueInner(); - - private: - // Stores a pointer to an nsStyleSet or a ServoStyleSet. The least - // significant bit is 0 for the former, 1 for the latter. This is - // valid as the least significant bit will never be used for a pointer - // value on platforms we care about. - uintptr_t mValue; - }; - - StyleSetHandle() { mPtr.mValue = 0; } - StyleSetHandle(const StyleSetHandle& aOth) { mPtr.mValue = aOth.mPtr.mValue; } - MOZ_IMPLICIT StyleSetHandle(nsStyleSet* aSet) { *this = aSet; } - MOZ_IMPLICIT StyleSetHandle(ServoStyleSet* aSet) { *this = aSet; } - - StyleSetHandle& operator=(nsStyleSet* aStyleSet) - { - mPtr.mValue = reinterpret_cast(aStyleSet); - return *this; - } - - StyleSetHandle& operator=(ServoStyleSet* aStyleSet) - { - mPtr.mValue = - aStyleSet ? reinterpret_cast(aStyleSet) : 0; - return *this; - } - - // Make StyleSetHandle usable in boolean contexts. - explicit operator bool() const { return !!mPtr.mValue; } - bool operator!() const { return !mPtr.mValue; } - bool operator==(const StyleSetHandle& aOth) const - { - return mPtr.mValue == aOth.mPtr.mValue; - } - bool operator!=(const StyleSetHandle& aOth) const { return !(*this == aOth); } - - // Make StyleSetHandle behave like a smart pointer. - Ptr* operator->() { return &mPtr; } - const Ptr* operator->() const { return &mPtr; } - -private: - Ptr mPtr; -}; - -} // namespace mozilla - -#endif // mozilla_StyleSetHandle_h diff --git a/layout/style/StyleSetHandleInlines.h b/layout/style/StyleSetHandleInlines.h deleted file mode 100644 index b521de3aa995..000000000000 --- a/layout/style/StyleSetHandleInlines.h +++ /dev/null @@ -1,299 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=8 sts=2 et sw=2 tw=80: */ -/* 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_StyleSetHandleInlines_h -#define mozilla_StyleSetHandleInlines_h - -#include "mozilla/StyleSheetInlines.h" -#include "mozilla/ComputedStyle.h" -#include "mozilla/ServoStyleSet.h" -#include "mozilla/ComputedStyle.h" - - -#define FORWARD_CONCRETE(method_, geckoargs_, servoargs_) \ - return AsServo()->method_ servoargs_; - - -#define FORWARD(method_, args_) FORWARD_CONCRETE(method_, args_, args_) - -namespace mozilla { - -void -StyleSetHandle::Ptr::Delete() -{ - if (mValue) { - delete AsServo(); - } -} - -void -StyleSetHandle::Ptr::Init(nsPresContext* aPresContext) -{ - FORWARD(Init, (aPresContext)); -} - -void -StyleSetHandle::Ptr::BeginShutdown() -{ - FORWARD(BeginShutdown, ()); -} - -void -StyleSetHandle::Ptr::Shutdown() -{ - FORWARD(Shutdown, ()); -} - -bool -StyleSetHandle::Ptr::GetAuthorStyleDisabled() const -{ - FORWARD(GetAuthorStyleDisabled, ()); -} - -void -StyleSetHandle::Ptr::SetAuthorStyleDisabled(bool aStyleDisabled) -{ - FORWARD(SetAuthorStyleDisabled, (aStyleDisabled)); -} - -void -StyleSetHandle::Ptr::BeginUpdate() -{ - FORWARD(BeginUpdate, ()); -} - -nsresult -StyleSetHandle::Ptr::EndUpdate() -{ - FORWARD(EndUpdate, ()); -} - -// resolve a ComputedStyle -already_AddRefed -StyleSetHandle::Ptr::ResolveStyleFor(dom::Element* aElement, - ComputedStyle* aParentStyle, - LazyComputeBehavior aMayCompute) -{ - FORWARD(ResolveStyleFor, (aElement, aParentStyle, aMayCompute)); -} - -already_AddRefed -StyleSetHandle::Ptr::ResolveStyleForText(nsIContent* aTextNode, - ComputedStyle* aParentStyle) -{ - FORWARD(ResolveStyleForText, (aTextNode, aParentStyle)); -} - -already_AddRefed -StyleSetHandle::Ptr::ResolveStyleForPlaceholder() -{ - FORWARD(ResolveStyleForPlaceholder, ()); -} - -already_AddRefed -StyleSetHandle::Ptr::ResolveStyleForFirstLetterContinuation(ComputedStyle* aParentStyle) -{ - FORWARD(ResolveStyleForFirstLetterContinuation, (aParentStyle)); -} - -already_AddRefed -StyleSetHandle::Ptr::ResolvePseudoElementStyle(dom::Element* aParentElement, - CSSPseudoElementType aType, - ComputedStyle* aParentStyle, - dom::Element* aPseudoElement) -{ - FORWARD(ResolvePseudoElementStyle, (aParentElement, aType, aParentStyle, aPseudoElement)); -} - -already_AddRefed -StyleSetHandle::Ptr::ResolveInheritingAnonymousBoxStyle(nsAtom* aPseudoTag, - ComputedStyle* aParentStyle) -{ - FORWARD(ResolveInheritingAnonymousBoxStyle, (aPseudoTag, aParentStyle)); -} - -already_AddRefed -StyleSetHandle::Ptr::ResolveNonInheritingAnonymousBoxStyle(nsAtom* aPseudoTag) -{ - FORWARD(ResolveNonInheritingAnonymousBoxStyle, (aPseudoTag)); -} - -#ifdef MOZ_XUL -already_AddRefed -StyleSetHandle::Ptr::ResolveXULTreePseudoStyle(dom::Element* aParentElement, - nsICSSAnonBoxPseudo* aPseudoTag, - ComputedStyle* aParentStyle, - const AtomArray& aInputWord) -{ - FORWARD(ResolveXULTreePseudoStyle, (aParentElement, aPseudoTag, aParentStyle, aInputWord)); -} -#endif - -// manage the set of style sheets in the style set -nsresult -StyleSetHandle::Ptr::AppendStyleSheet(SheetType aType, StyleSheet* aSheet) -{ - FORWARD_CONCRETE(AppendStyleSheet, (aType, aSheet->AsGecko()), - (aType, aSheet->AsServo())); -} - -nsresult -StyleSetHandle::Ptr::PrependStyleSheet(SheetType aType, StyleSheet* aSheet) -{ - FORWARD_CONCRETE(PrependStyleSheet, (aType, aSheet->AsGecko()), - (aType, aSheet->AsServo())); -} - -nsresult -StyleSetHandle::Ptr::RemoveStyleSheet(SheetType aType, StyleSheet* aSheet) -{ - FORWARD_CONCRETE(RemoveStyleSheet, (aType, aSheet->AsGecko()), - (aType, aSheet->AsServo())); -} - -nsresult -StyleSetHandle::Ptr::ReplaceSheets(SheetType aType, - const nsTArray>& aNewSheets) -{ - nsTArray> newSheets(aNewSheets.Length()); - for (auto& sheet : aNewSheets) { - newSheets.AppendElement(sheet->AsServo()); - } - return AsServo()->ReplaceSheets(aType, newSheets); -} - -nsresult -StyleSetHandle::Ptr::InsertStyleSheetBefore(SheetType aType, - StyleSheet* aNewSheet, - StyleSheet* aReferenceSheet) -{ - FORWARD_CONCRETE( - InsertStyleSheetBefore, - (aType, aNewSheet->AsGecko(), aReferenceSheet->AsGecko()), - (aType, aNewSheet->AsServo(), aReferenceSheet->AsServo())); -} - -int32_t -StyleSetHandle::Ptr::SheetCount(SheetType aType) const -{ - FORWARD(SheetCount, (aType)); -} - -StyleSheet* -StyleSetHandle::Ptr::StyleSheetAt(SheetType aType, int32_t aIndex) const -{ - FORWARD(StyleSheetAt, (aType, aIndex)); -} - -void -StyleSetHandle::Ptr::AppendAllXBLStyleSheets(nsTArray& aArray) const -{ - FORWARD(AppendAllXBLStyleSheets, (aArray)); -} - -nsresult -StyleSetHandle::Ptr::RemoveDocStyleSheet(StyleSheet* aSheet) -{ - FORWARD_CONCRETE(RemoveDocStyleSheet, (aSheet->AsGecko()), - (aSheet->AsServo())); -} - -nsresult -StyleSetHandle::Ptr::AddDocStyleSheet(StyleSheet* aSheet, - nsIDocument* aDocument) -{ - FORWARD_CONCRETE(AddDocStyleSheet, (aSheet->AsGecko(), aDocument), - (aSheet->AsServo(), aDocument)); -} - -void -StyleSetHandle::Ptr::RuleRemoved(StyleSheet& aSheet, css::Rule& aRule) -{ - FORWARD_CONCRETE(RuleRemoved, (*aSheet.AsGecko(), aRule), - (*aSheet.AsServo(), aRule)); -} - -void -StyleSetHandle::Ptr::RuleAdded(StyleSheet& aSheet, css::Rule& aRule) -{ - FORWARD_CONCRETE(RuleAdded, (*aSheet.AsGecko(), aRule), - (*aSheet.AsServo(), aRule)); -} - -void -StyleSetHandle::Ptr::RuleChanged(StyleSheet& aSheet, css::Rule* aRule) -{ - FORWARD_CONCRETE(RuleChanged, (*aSheet.AsGecko(), aRule), - (*aSheet.AsServo(), aRule)); -} - -void -StyleSetHandle::Ptr::RecordShadowStyleChange(mozilla::dom::ShadowRoot& aShadowRoot) -{ - FORWARD(RecordShadowStyleChange, (aShadowRoot)); -} - -bool -StyleSetHandle::Ptr::StyleSheetsHaveChanged() const -{ - FORWARD(StyleSheetsHaveChanged, ()); -} -nsRestyleHint -StyleSetHandle::Ptr::MediumFeaturesChanged(mozilla::MediaFeatureChangeReason aReason) -{ - FORWARD(MediumFeaturesChanged, (aReason)); -} -void -StyleSetHandle::Ptr::InvalidateStyleForCSSRuleChanges() -{ - FORWARD(InvalidateStyleForCSSRuleChanges, ()); -} - -// check whether there is ::before/::after style for an element -already_AddRefed -StyleSetHandle::Ptr::ProbePseudoElementStyle(dom::Element* aParentElement, - CSSPseudoElementType aType, - ComputedStyle* aParentStyle) -{ - FORWARD(ProbePseudoElementStyle, (aParentElement, aType, aParentStyle)); -} - -bool -StyleSetHandle::Ptr:: -AppendFontFaceRules(nsTArray& aArray) -{ - FORWARD(AppendFontFaceRules, (aArray)); -} - -nsCSSCounterStyleRule* -StyleSetHandle::Ptr::CounterStyleRuleForName(nsAtom* aName) -{ - FORWARD(CounterStyleRuleForName, (aName)); -} - -already_AddRefed -StyleSetHandle::Ptr::BuildFontFeatureValueSet() -{ - FORWARD(BuildFontFeatureValueSet, ()); -} - -bool -StyleSetHandle::Ptr::EnsureUniqueInnerOnCSSSheets() -{ - FORWARD(EnsureUniqueInnerOnCSSSheets, ()); -} - -void -StyleSetHandle::Ptr::SetNeedsRestyleAfterEnsureUniqueInner() -{ - FORWARD(SetNeedsRestyleAfterEnsureUniqueInner, ()); -} - -} // namespace mozilla - -#undef FORWARD - -#endif // mozilla_StyleSetHandleInlines_h diff --git a/layout/style/StyleSheet.cpp b/layout/style/StyleSheet.cpp index 8526b7f07fce..39578362ddc1 100644 --- a/layout/style/StyleSheet.cpp +++ b/layout/style/StyleSheet.cpp @@ -17,7 +17,6 @@ #include "mozilla/ServoCSSRuleList.h" #include "mozilla/ServoStyleSet.h" #include "mozilla/ServoStyleSheet.h" -#include "mozilla/StyleSetHandleInlines.h" #include "mozilla/StyleSheetInlines.h" #include "mozAutoDocUpdate.h" @@ -360,7 +359,7 @@ StyleSheet::WillDirty() } void -StyleSheet::AddStyleSet(const StyleSetHandle& aStyleSet) +StyleSheet::AddStyleSet(ServoStyleSet* aStyleSet) { NS_ASSERTION(!mStyleSets.Contains(aStyleSet), "style set already registered"); @@ -368,7 +367,7 @@ StyleSheet::AddStyleSet(const StyleSetHandle& aStyleSet) } void -StyleSheet::DropStyleSet(const StyleSetHandle& aStyleSet) +StyleSheet::DropStyleSet(ServoStyleSet* aStyleSet) { DebugOnly found = mStyleSets.RemoveElement(aStyleSet); NS_ASSERTION(found, "didn't find style set"); @@ -399,7 +398,7 @@ StyleSheet::EnsureUniqueInner() // let our containing style sets know that if we call // nsPresContext::EnsureSafeToHandOutCSSRules we will need to restyle the // document - for (StyleSetHandle& setHandle : mStyleSets) { + for (ServoStyleSet* setHandle : mStyleSets) { setHandle->SetNeedsRestyleAfterEnsureUniqueInner(); } } @@ -527,7 +526,7 @@ StyleSheet::GetContainingShadow() const #define NOTIFY(function_, args_) do { \ StyleSheet* current = this; \ do { \ - for (StyleSetHandle handle : current->mStyleSets) { \ + for (ServoStyleSet* handle : current->mStyleSets) { \ handle->function_ args_; \ } \ if (auto* shadow = current->GetContainingShadow()) { \ @@ -542,7 +541,7 @@ StyleSheet::RuleAdded(css::Rule& aRule) { DidDirty(); mDirtyFlags |= MODIFIED_RULES; - NOTIFY(RuleAdded, (*this, aRule)); + NOTIFY(RuleAdded, (*AsServo(), aRule)); if (mDocument) { mDocument->StyleRuleAdded(this, &aRule); @@ -554,7 +553,7 @@ StyleSheet::RuleRemoved(css::Rule& aRule) { DidDirty(); mDirtyFlags |= MODIFIED_RULES; - NOTIFY(RuleRemoved, (*this, aRule)); + NOTIFY(RuleRemoved, (*AsServo(), aRule)); if (mDocument) { mDocument->StyleRuleRemoved(this, &aRule); @@ -566,7 +565,7 @@ StyleSheet::RuleChanged(css::Rule* aRule) { DidDirty(); mDirtyFlags |= MODIFIED_RULES; - NOTIFY(RuleChanged, (*this, aRule)); + NOTIFY(RuleChanged, (*AsServo(), aRule)); if (mDocument) { mDocument->StyleRuleChanged(this, aRule); diff --git a/layout/style/StyleSheet.h b/layout/style/StyleSheet.h index a15f9d697e20..bce562bf5980 100644 --- a/layout/style/StyleSheet.h +++ b/layout/style/StyleSheet.h @@ -23,8 +23,8 @@ class nsCSSRuleProcessor; namespace mozilla { class CSSStyleSheet; +class ServoStyleSet; class ServoStyleSheet; -class StyleSetHandle; struct StyleSheetInfo; struct CSSStyleSheetInner; @@ -260,8 +260,8 @@ class StyleSheet : public nsICSSLoaderObserver // it's owning media rule, plus it's used for the stylesheet media itself. void RuleChanged(css::Rule*); - void AddStyleSet(const StyleSetHandle& aStyleSet); - void DropStyleSet(const StyleSetHandle& aStyleSet); + void AddStyleSet(ServoStyleSet* aStyleSet); + void DropStyleSet(ServoStyleSet* aStyleSet); nsresult DeleteRuleFromGroup(css::GroupRule* aGroup, uint32_t aIndex); nsresult InsertRuleIntoGroup(const nsAString& aRule, @@ -369,7 +369,7 @@ class StyleSheet : public nsICSSLoaderObserver // StyleSheet clones. StyleSheetInfo* mInner; - nsTArray mStyleSets; + nsTArray mStyleSets; friend class ::nsCSSRuleProcessor; diff --git a/layout/style/moz.build b/layout/style/moz.build index b57fe3a05458..6b0f482cbc59 100644 --- a/layout/style/moz.build +++ b/layout/style/moz.build @@ -112,8 +112,6 @@ EXPORTS.mozilla += [ 'StyleAnimationValue.h', 'StyleComplexColor.h', 'StylePrefs.h', - 'StyleSetHandle.h', - 'StyleSetHandleInlines.h', 'StyleSheet.h', 'StyleSheetInfo.h', 'StyleSheetInlines.h', diff --git a/layout/style/nsAnimationManager.cpp b/layout/style/nsAnimationManager.cpp index 573a0160bd26..45dbe393bab8 100755 --- a/layout/style/nsAnimationManager.cpp +++ b/layout/style/nsAnimationManager.cpp @@ -362,7 +362,7 @@ class MOZ_STACK_CLASS ServoCSSAnimationBuilder final { const nsTimingFunction& aTimingFunction, nsTArray& aKeyframes) { - ServoStyleSet* styleSet = aPresContext->StyleSet()->AsServo(); + ServoStyleSet* styleSet = aPresContext->StyleSet(); MOZ_ASSERT(styleSet); return styleSet->GetKeyframesForName(aName, aTimingFunction, diff --git a/layout/style/nsComputedDOMStyle.cpp b/layout/style/nsComputedDOMStyle.cpp index 3662a03a9e74..15175c1e0528 100644 --- a/layout/style/nsComputedDOMStyle.cpp +++ b/layout/style/nsComputedDOMStyle.cpp @@ -37,8 +37,7 @@ #include "nsCSSPseudoElements.h" #include "mozilla/EffectSet.h" #include "mozilla/IntegerRange.h" -#include "mozilla/StyleSetHandle.h" -#include "mozilla/StyleSetHandleInlines.h" +#include "mozilla/ServoStyleSet.h" #include "mozilla/ServoRestyleManager.h" #include "mozilla/RestyleManagerInlines.h" #include "imgIRequest.h" @@ -120,7 +119,7 @@ DocumentNeedsRestyle( // Unfortunately we don't know if the sheet change affects mContent or not, so // just assume it will and that we need to flush normally. - StyleSetHandle styleSet = shell->StyleSet(); + ServoStyleSet* styleSet = shell->StyleSet(); if (styleSet->StyleSheetsHaveChanged()) { return true; } @@ -550,7 +549,7 @@ nsComputedDOMStyle::DoGetComputedStyleNoFlush(Element* aElement, // No frame has been created, or we have a pseudo, or we're looking // for the default style, so resolve the style ourselves. - ServoStyleSet* styleSet = presShell->StyleSet()->AsServo(); + ServoStyleSet* styleSet = presShell->StyleSet(); StyleRuleInclusion rules = aStyleType == eDefaultOnly ? StyleRuleInclusion::DefaultOnly @@ -579,8 +578,8 @@ nsComputedDOMStyle::GetUnanimatedComputedStyleNoFlush(Element* aElement, return nullptr; } - return shell->StyleSet()->AsServo()->GetBaseContextForElement( - elementOrPseudoElement, style); + return shell->StyleSet()-> + GetBaseContextForElement(elementOrPseudoElement, style); } nsMargin diff --git a/layout/style/nsStyleStructInlines.h b/layout/style/nsStyleStructInlines.h index 3ad1151e1f10..5e0fd1accf04 100644 --- a/layout/style/nsStyleStructInlines.h +++ b/layout/style/nsStyleStructInlines.h @@ -17,7 +17,6 @@ #include "nsIContent.h" // for GetParent() #include "nsTextFrame.h" // for nsTextFrame::ShouldSuppressLineBreak #include "nsSVGUtils.h" // for nsSVGUtils::IsInSVGTextSubtree -#include "mozilla/ServoStyleSet.h" inline void nsStyleImage::EnsureCachedBIData() const diff --git a/layout/tables/nsTableFrame.cpp b/layout/tables/nsTableFrame.cpp index 3d2b8ffee95d..95234407594e 100644 --- a/layout/tables/nsTableFrame.cpp +++ b/layout/tables/nsTableFrame.cpp @@ -41,8 +41,6 @@ #include "mozilla/Range.h" #include "mozilla/ServoRestyleManager.h" #include "mozilla/ServoStyleSet.h" -#include "mozilla/StyleSetHandle.h" -#include "mozilla/StyleSetHandleInlines.h" #include "nsDisplayList.h" #include "nsIScrollableFrame.h" #include "nsCSSProps.h" diff --git a/layout/xul/nsListBoxBodyFrame.cpp b/layout/xul/nsListBoxBodyFrame.cpp index 2dca3a208820..c320d9505add 100644 --- a/layout/xul/nsListBoxBodyFrame.cpp +++ b/layout/xul/nsListBoxBodyFrame.cpp @@ -26,8 +26,7 @@ #include "mozilla/ComputedStyle.h" #include "nsFontMetrics.h" #include "nsITimer.h" -#include "mozilla/StyleSetHandle.h" -#include "mozilla/StyleSetHandleInlines.h" +#include "mozilla/ServoStyleSet.h" #include "mozilla/dom/Text.h" #include "nsPIBoxObject.h" #include "nsLayoutUtils.h" diff --git a/layout/xul/nsSplitterFrame.cpp b/layout/xul/nsSplitterFrame.cpp index 4eb826befeaa..4cd3819b8a83 100644 --- a/layout/xul/nsSplitterFrame.cpp +++ b/layout/xul/nsSplitterFrame.cpp @@ -29,8 +29,6 @@ #include "nsIServiceManager.h" #include "nsContainerFrame.h" #include "nsContentCID.h" -#include "mozilla/StyleSetHandle.h" -#include "mozilla/StyleSetHandleInlines.h" #include "nsLayoutUtils.h" #include "nsDisplayList.h" #include "nsContentUtils.h" diff --git a/layout/xul/tree/nsTreeStyleCache.cpp b/layout/xul/tree/nsTreeStyleCache.cpp index e63368d23b48..5149e7d0e8f4 100644 --- a/layout/xul/tree/nsTreeStyleCache.cpp +++ b/layout/xul/tree/nsTreeStyleCache.cpp @@ -6,8 +6,7 @@ #include "nsTreeStyleCache.h" #include "mozilla/dom/Element.h" -#include "mozilla/StyleSetHandle.h" -#include "mozilla/StyleSetHandleInlines.h" +#include "mozilla/ServoStyleSet.h" using namespace mozilla;