Bug 1771564 - Constify ComputedStyle usage in nsComputedDOMStyle. r=dholbert

None of the consumer need to mutate styles, and this saves some ugly
const_casting on the next patch.

Doesn't change behavior.

Differential Revision: https://phabricator.services.mozilla.com/D147555
This commit is contained in:
Emilio Cobos Álvarez
2022-05-28 01:04:24 +00:00
parent ae643b70f3
commit e48bb99524
30 changed files with 102 additions and 97 deletions

View File

@@ -40,7 +40,7 @@ class StyleInfo {
CSSCoord Margin(Side aSide); CSSCoord Margin(Side aSide);
dom::Element* mElement; dom::Element* mElement;
RefPtr<ComputedStyle> mComputedStyle; RefPtr<const ComputedStyle> mComputedStyle;
}; };
} // namespace a11y } // namespace a11y

View File

@@ -145,7 +145,8 @@ void KeyframeEffect::SetComposite(const CompositeOperation& aComposite) {
} }
if (mTarget) { if (mTarget) {
RefPtr<ComputedStyle> computedStyle = GetTargetComputedStyle(Flush::None); RefPtr<const ComputedStyle> computedStyle =
GetTargetComputedStyle(Flush::None);
if (computedStyle) { if (computedStyle) {
UpdateProperties(computedStyle); UpdateProperties(computedStyle);
} }
@@ -241,7 +242,7 @@ void KeyframeEffect::SetKeyframes(JSContext* aContext,
return; return;
} }
RefPtr<ComputedStyle> style = GetTargetComputedStyle(Flush::None); RefPtr<const ComputedStyle> style = GetTargetComputedStyle(Flush::None);
SetKeyframes(std::move(keyframes), style); SetKeyframes(std::move(keyframes), style);
} }
@@ -525,7 +526,7 @@ void KeyframeEffect::EnsureBaseStyles(
" we should have also failed to calculate the computed values" " we should have also failed to calculate the computed values"
" passed-in as aProperties"); " passed-in as aProperties");
RefPtr<ComputedStyle> baseComputedStyle; RefPtr<const ComputedStyle> baseComputedStyle;
for (const AnimationProperty& property : aProperties) { for (const AnimationProperty& property : aProperties) {
EnsureBaseStyle(property, presContext, aComputedValues, baseComputedStyle); EnsureBaseStyle(property, presContext, aComputedValues, baseComputedStyle);
} }
@@ -543,7 +544,7 @@ void KeyframeEffect::EnsureBaseStyles(
void KeyframeEffect::EnsureBaseStyle( void KeyframeEffect::EnsureBaseStyle(
const AnimationProperty& aProperty, nsPresContext* aPresContext, const AnimationProperty& aProperty, nsPresContext* aPresContext,
const ComputedStyle* aComputedStyle, const ComputedStyle* aComputedStyle,
RefPtr<ComputedStyle>& aBaseComputedStyle) { RefPtr<const ComputedStyle>& aBaseComputedStyle) {
bool hasAdditiveValues = false; bool hasAdditiveValues = false;
for (const AnimationPropertySegment& segment : aProperty.mSegments) { for (const AnimationPropertySegment& segment : aProperty.mSegments) {
@@ -919,7 +920,8 @@ void KeyframeEffect::UpdateTarget(Element* aElement,
if (mTarget) { if (mTarget) {
UpdateTargetRegistration(); UpdateTargetRegistration();
RefPtr<ComputedStyle> computedStyle = GetTargetComputedStyle(Flush::None); RefPtr<const ComputedStyle> computedStyle =
GetTargetComputedStyle(Flush::None);
if (computedStyle) { if (computedStyle) {
UpdateProperties(computedStyle); UpdateProperties(computedStyle);
} }
@@ -1005,7 +1007,7 @@ void KeyframeEffect::RequestRestyle(
} }
} }
already_AddRefed<ComputedStyle> KeyframeEffect::GetTargetComputedStyle( already_AddRefed<const ComputedStyle> KeyframeEffect::GetTargetComputedStyle(
Flush aFlushType) const { Flush aFlushType) const {
if (!GetRenderedDocument()) { if (!GetRenderedDocument()) {
return nullptr; return nullptr;
@@ -1230,7 +1232,7 @@ void KeyframeEffect::GetKeyframes(JSContext* aCx, nsTArray<JSObject*>& aResult,
// be consistent with Gecko, we just expand the variables (assuming we have // be consistent with Gecko, we just expand the variables (assuming we have
// enough context to do so). For that we need to grab the ComputedStyle so we // enough context to do so). For that we need to grab the ComputedStyle so we
// know what custom property values to provide. // know what custom property values to provide.
RefPtr<ComputedStyle> computedStyle; RefPtr<const ComputedStyle> computedStyle;
if (isCSSAnimation) { if (isCSSAnimation) {
// The following will flush style but that's ok since if you update // The following will flush style but that's ok since if you update
// a variable's computed value, you expect to see that updated value in the // a variable's computed value, you expect to see that updated value in the
@@ -1756,7 +1758,7 @@ void KeyframeEffect::SetPerformanceWarning(
} }
} }
already_AddRefed<ComputedStyle> already_AddRefed<const ComputedStyle>
KeyframeEffect::CreateComputedStyleForAnimationValue( KeyframeEffect::CreateComputedStyleForAnimationValue(
nsCSSPropertyID aProperty, const AnimationValue& aValue, nsCSSPropertyID aProperty, const AnimationValue& aValue,
nsPresContext* aPresContext, const ComputedStyle* aBaseComputedStyle) { nsPresContext* aPresContext, const ComputedStyle* aBaseComputedStyle) {
@@ -1827,16 +1829,20 @@ void KeyframeEffect::CalculateCumulativeChangeHint(
continue; continue;
} }
RefPtr<ComputedStyle> fromContext = CreateComputedStyleForAnimationValue( RefPtr<const ComputedStyle> fromContext =
property.mProperty, segment.mFromValue, presContext, aComputedStyle); CreateComputedStyleForAnimationValue(property.mProperty,
segment.mFromValue, presContext,
aComputedStyle);
if (!fromContext) { if (!fromContext) {
mCumulativeChangeHint = ~nsChangeHint_Hints_CanIgnoreIfNotVisible; mCumulativeChangeHint = ~nsChangeHint_Hints_CanIgnoreIfNotVisible;
mNeedsStyleData = true; mNeedsStyleData = true;
return; return;
} }
RefPtr<ComputedStyle> toContext = CreateComputedStyleForAnimationValue( RefPtr<const ComputedStyle> toContext =
property.mProperty, segment.mToValue, presContext, aComputedStyle); CreateComputedStyleForAnimationValue(property.mProperty,
segment.mToValue, presContext,
aComputedStyle);
if (!toContext) { if (!toContext) {
mCumulativeChangeHint = ~nsChangeHint_Hints_CanIgnoreIfNotVisible; mCumulativeChangeHint = ~nsChangeHint_Hints_CanIgnoreIfNotVisible;
mNeedsStyleData = true; mNeedsStyleData = true;

View File

@@ -400,8 +400,7 @@ class KeyframeEffect : public AnimationEffect {
Style, Style,
None, None,
}; };
already_AddRefed<ComputedStyle> GetTargetComputedStyle( already_AddRefed<const ComputedStyle> GetTargetComputedStyle(Flush) const;
Flush aFlushType) const;
// A wrapper for marking cascade update according to the current // A wrapper for marking cascade update according to the current
// target and its effectSet. // target and its effectSet.
@@ -413,7 +412,7 @@ class KeyframeEffect : public AnimationEffect {
void EnsureBaseStyle(const AnimationProperty& aProperty, void EnsureBaseStyle(const AnimationProperty& aProperty,
nsPresContext* aPresContext, nsPresContext* aPresContext,
const ComputedStyle* aComputedValues, const ComputedStyle* aComputedValues,
RefPtr<ComputedStyle>& aBaseComputedValues); RefPtr<const ComputedStyle>& aBaseComputedValues);
OwningAnimationTarget mTarget; OwningAnimationTarget mTarget;
@@ -468,7 +467,7 @@ class KeyframeEffect : public AnimationEffect {
const AnimationPropertySegment& aSegment, const AnimationPropertySegment& aSegment,
const ComputedTiming& aComputedTiming); const ComputedTiming& aComputedTiming);
already_AddRefed<ComputedStyle> CreateComputedStyleForAnimationValue( already_AddRefed<const ComputedStyle> CreateComputedStyleForAnimationValue(
nsCSSPropertyID aProperty, const AnimationValue& aValue, nsCSSPropertyID aProperty, const AnimationValue& aValue,
nsPresContext* aPresContext, const ComputedStyle* aBaseComputedStyle); nsPresContext* aPresContext, const ComputedStyle* aBaseComputedStyle);

View File

@@ -3194,7 +3194,7 @@ nsDOMWindowUtils::GetUnanimatedComputedStyle(Element* aElement,
if (!pseudo) { if (!pseudo) {
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
} }
RefPtr<ComputedStyle> computedStyle = RefPtr<const ComputedStyle> computedStyle =
nsComputedDOMStyle::GetUnanimatedComputedStyleNoFlush(aElement, *pseudo); nsComputedDOMStyle::GetUnanimatedComputedStyleNoFlush(aElement, *pseudo);
if (!computedStyle) { if (!computedStyle) {
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;

View File

@@ -1116,7 +1116,7 @@ bool CanvasRenderingContext2D::ParseColor(const nsACString& aString,
if (wasCurrentColor && mCanvasElement) { if (wasCurrentColor && mCanvasElement) {
// Otherwise, get the value of the color property, flushing style // Otherwise, get the value of the color property, flushing style
// if necessary. // if necessary.
RefPtr<ComputedStyle> canvasStyle = RefPtr<const ComputedStyle> canvasStyle =
nsComputedDOMStyle::GetComputedStyle(mCanvasElement); nsComputedDOMStyle::GetComputedStyle(mCanvasElement);
if (canvasStyle) { if (canvasStyle) {
*aColor = canvasStyle->StyleText()->mColor.ToColor(); *aColor = canvasStyle->StyleText()->mColor.ToColor();
@@ -1696,7 +1696,7 @@ void CanvasRenderingContext2D::ClearTarget(int32_t aWidth, int32_t aHeight) {
// For vertical writing-mode, unless text-orientation is sideways, // For vertical writing-mode, unless text-orientation is sideways,
// we'll modify the initial value of textBaseline to 'middle'. // we'll modify the initial value of textBaseline to 'middle'.
RefPtr<ComputedStyle> canvasStyle = RefPtr<const ComputedStyle> canvasStyle =
nsComputedDOMStyle::GetComputedStyle(mCanvasElement); nsComputedDOMStyle::GetComputedStyle(mCanvasElement);
if (canvasStyle) { if (canvasStyle) {
WritingMode wm(canvasStyle); WritingMode wm(canvasStyle);
@@ -2453,7 +2453,7 @@ static already_AddRefed<RawServoDeclarationBlock> CreateFontDeclarationForServo(
return CreateDeclarationForServo(eCSSProperty_font, aFont, aDocument); return CreateDeclarationForServo(eCSSProperty_font, aFont, aDocument);
} }
static already_AddRefed<ComputedStyle> GetFontStyleForServo( static already_AddRefed<const ComputedStyle> GetFontStyleForServo(
Element* aElement, const nsACString& aFont, PresShell* aPresShell, Element* aElement, const nsACString& aFont, PresShell* aPresShell,
nsACString& aOutUsedFont, ErrorResult& aError) { nsACString& aOutUsedFont, ErrorResult& aError) {
RefPtr<RawServoDeclarationBlock> declarations = RefPtr<RawServoDeclarationBlock> declarations =
@@ -2473,7 +2473,7 @@ static already_AddRefed<ComputedStyle> GetFontStyleForServo(
ServoStyleSet* styleSet = aPresShell->StyleSet(); ServoStyleSet* styleSet = aPresShell->StyleSet();
RefPtr<ComputedStyle> parentStyle; RefPtr<const ComputedStyle> parentStyle;
// have to get a parent ComputedStyle for inherit-like relative // have to get a parent ComputedStyle for inherit-like relative
// values (2em, bolder, etc.) // values (2em, bolder, etc.)
if (aElement && aElement->IsInComposedDoc()) { if (aElement && aElement->IsInComposedDoc()) {
@@ -2500,7 +2500,7 @@ static already_AddRefed<ComputedStyle> GetFontStyleForServo(
"We should have returned an error above if the presshell is " "We should have returned an error above if the presshell is "
"being destroyed."); "being destroyed.");
RefPtr<ComputedStyle> sc = RefPtr<const ComputedStyle> sc =
styleSet->ResolveForDeclarations(parentStyle, declarations); styleSet->ResolveForDeclarations(parentStyle, declarations);
// https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-font // https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-font
@@ -2527,7 +2527,7 @@ CreateFilterDeclarationForServo(const nsACString& aFilter,
return CreateDeclarationForServo(eCSSProperty_filter, aFilter, aDocument); return CreateDeclarationForServo(eCSSProperty_filter, aFilter, aDocument);
} }
static already_AddRefed<ComputedStyle> ResolveFilterStyleForServo( static already_AddRefed<const ComputedStyle> ResolveFilterStyleForServo(
const nsACString& aFilterString, const ComputedStyle* aParentStyle, const nsACString& aFilterString, const ComputedStyle* aParentStyle,
PresShell* aPresShell, ErrorResult& aError) { PresShell* aPresShell, ErrorResult& aError) {
RefPtr<RawServoDeclarationBlock> declarations = RefPtr<RawServoDeclarationBlock> declarations =
@@ -2545,7 +2545,7 @@ static already_AddRefed<ComputedStyle> ResolveFilterStyleForServo(
} }
ServoStyleSet* styleSet = aPresShell->StyleSet(); ServoStyleSet* styleSet = aPresShell->StyleSet();
RefPtr<ComputedStyle> computedValues = RefPtr<const ComputedStyle> computedValues =
styleSet->ResolveForDeclarations(aParentStyle, declarations); styleSet->ResolveForDeclarations(aParentStyle, declarations);
return computedValues.forget(); return computedValues.forget();
@@ -2562,13 +2562,13 @@ bool CanvasRenderingContext2D::ParseFilter(
nsAutoCString usedFont; // unused nsAutoCString usedFont; // unused
RefPtr<ComputedStyle> parentStyle = GetFontStyleForServo( RefPtr<const ComputedStyle> parentStyle = GetFontStyleForServo(
mCanvasElement, GetFont(), presShell, usedFont, aError); mCanvasElement, GetFont(), presShell, usedFont, aError);
if (!parentStyle) { if (!parentStyle) {
return false; return false;
} }
RefPtr<ComputedStyle> style = RefPtr<const ComputedStyle> style =
ResolveFilterStyleForServo(aString, parentStyle, presShell, aError); ResolveFilterStyleForServo(aString, parentStyle, presShell, aError);
if (!style) { if (!style) {
return false; return false;
@@ -3409,7 +3409,7 @@ bool CanvasRenderingContext2D::SetFontInternal(const nsACString& aFont,
} }
nsCString usedFont; nsCString usedFont;
RefPtr<ComputedStyle> sc = RefPtr<const ComputedStyle> sc =
GetFontStyleForServo(mCanvasElement, aFont, presShell, usedFont, aError); GetFontStyleForServo(mCanvasElement, aFont, presShell, usedFont, aError);
if (!sc) { if (!sc) {
return false; return false;
@@ -3990,7 +3990,7 @@ TextMetrics* CanvasRenderingContext2D::DrawOrMeasureText(
textToDraw.Truncate(); textToDraw.Truncate();
} }
RefPtr<ComputedStyle> canvasStyle; RefPtr<const ComputedStyle> canvasStyle;
if (mCanvasElement && mCanvasElement->IsInComposedDoc()) { if (mCanvasElement && mCanvasElement->IsInComposedDoc()) {
// try to find the closest context // try to find the closest context
canvasStyle = nsComputedDOMStyle::GetComputedStyle(mCanvasElement); canvasStyle = nsComputedDOMStyle::GetComputedStyle(mCanvasElement);

View File

@@ -377,7 +377,7 @@ bool nsPlainTextSerializer::IsIgnorableRubyAnnotation(
// Return true if aElement has 'display:none' or if we just don't know. // Return true if aElement has 'display:none' or if we just don't know.
static bool IsDisplayNone(Element* aElement) { static bool IsDisplayNone(Element* aElement) {
RefPtr<ComputedStyle> computedStyle = RefPtr<const ComputedStyle> computedStyle =
nsComputedDOMStyle::GetComputedStyleNoFlush(aElement); nsComputedDOMStyle::GetComputedStyleNoFlush(aElement);
return !computedStyle || return !computedStyle ||
computedStyle->StyleDisplay()->mDisplay == StyleDisplay::None; computedStyle->StyleDisplay()->mDisplay == StyleDisplay::None;
@@ -1689,7 +1689,7 @@ bool nsPlainTextSerializer::IsElementPreformatted() const {
} }
bool nsPlainTextSerializer::IsElementPreformatted(Element* aElement) { bool nsPlainTextSerializer::IsElementPreformatted(Element* aElement) {
RefPtr<ComputedStyle> computedStyle = RefPtr<const ComputedStyle> computedStyle =
nsComputedDOMStyle::GetComputedStyleNoFlush(aElement); nsComputedDOMStyle::GetComputedStyleNoFlush(aElement);
if (computedStyle) { if (computedStyle) {
const nsStyleText* textStyle = computedStyle->StyleText(); const nsStyleText* textStyle = computedStyle->StyleText();
@@ -1700,7 +1700,7 @@ bool nsPlainTextSerializer::IsElementPreformatted(Element* aElement) {
} }
bool nsPlainTextSerializer::IsCssBlockLevelElement(Element* aElement) { bool nsPlainTextSerializer::IsCssBlockLevelElement(Element* aElement) {
RefPtr<ComputedStyle> computedStyle = RefPtr<const ComputedStyle> computedStyle =
nsComputedDOMStyle::GetComputedStyleNoFlush(aElement); nsComputedDOMStyle::GetComputedStyleNoFlush(aElement);
if (computedStyle) { if (computedStyle) {
const nsStyleDisplay* displayStyle = computedStyle->StyleDisplay(); const nsStyleDisplay* displayStyle = computedStyle->StyleDisplay();

View File

@@ -633,7 +633,7 @@ bool nsXHTMLContentSerializer::IsElementPreformatted(nsIContent* aNode) {
if (!aNode->IsElement()) { if (!aNode->IsElement()) {
return false; return false;
} }
RefPtr<ComputedStyle> computedStyle = RefPtr<const ComputedStyle> computedStyle =
nsComputedDOMStyle::GetComputedStyleNoFlush(aNode->AsElement()); nsComputedDOMStyle::GetComputedStyleNoFlush(aNode->AsElement());
if (computedStyle) { if (computedStyle) {
const nsStyleText* textStyle = computedStyle->StyleText(); const nsStyleText* textStyle = computedStyle->StyleText();

View File

@@ -23,7 +23,7 @@ namespace mozilla {
// Class Methods // Class Methods
SMILCSSProperty::SMILCSSProperty(nsCSSPropertyID aPropID, SMILCSSProperty::SMILCSSProperty(nsCSSPropertyID aPropID,
dom::Element* aElement, dom::Element* aElement,
ComputedStyle* aBaseComputedStyle) const ComputedStyle* aBaseComputedStyle)
: mPropID(aPropID), : mPropID(aPropID),
mElement(aElement), mElement(aElement),
mBaseComputedStyle(aBaseComputedStyle) { mBaseComputedStyle(aBaseComputedStyle) {

View File

@@ -38,7 +38,7 @@ class SMILCSSProperty : public SMILAttr {
* the SMILCSSValueType will be returned. * the SMILCSSValueType will be returned.
*/ */
SMILCSSProperty(nsCSSPropertyID aPropID, dom::Element* aElement, SMILCSSProperty(nsCSSPropertyID aPropID, dom::Element* aElement,
ComputedStyle* aBaseComputedStyle); const ComputedStyle* aBaseComputedStyle);
// SMILAttr methods // SMILAttr methods
virtual nsresult ValueFromString( virtual nsresult ValueFromString(
@@ -71,7 +71,7 @@ class SMILCSSProperty : public SMILAttr {
// As with mElement, since a SMILAttr only lives as long as the // As with mElement, since a SMILAttr only lives as long as the
// compositing step and since ComposeAttribute holds an owning reference to // compositing step and since ComposeAttribute holds an owning reference to
// the base ComputedStyle, we can use a non-owning reference here. // the base ComputedStyle, we can use a non-owning reference here.
ComputedStyle* mBaseComputedStyle; const ComputedStyle* mBaseComputedStyle;
}; };
} // namespace mozilla } // namespace mozilla

View File

@@ -410,11 +410,10 @@ nsresult SMILCSSValueType::Interpolate(const SMILValue& aStartVal,
return InterpolateForServo(startWrapper, *endWrapper, aUnitDistance, aResult); return InterpolateForServo(startWrapper, *endWrapper, aUnitDistance, aResult);
} }
static ServoAnimationValues ValueFromStringHelper(nsCSSPropertyID aPropID, static ServoAnimationValues ValueFromStringHelper(
Element* aTargetElement, nsCSSPropertyID aPropID, Element* aTargetElement,
nsPresContext* aPresContext, nsPresContext* aPresContext, const ComputedStyle* aComputedStyle,
ComputedStyle* aComputedStyle, const nsAString& aString) {
const nsAString& aString) {
ServoAnimationValues result; ServoAnimationValues result;
Document* doc = aTargetElement->GetComposedDoc(); Document* doc = aTargetElement->GetComposedDoc();
@@ -461,7 +460,7 @@ void SMILCSSValueType::ValueFromString(nsCSSPropertyID aPropID,
return; return;
} }
RefPtr<ComputedStyle> computedStyle = RefPtr<const ComputedStyle> computedStyle =
nsComputedDOMStyle::GetComputedStyle(aTargetElement); nsComputedDOMStyle::GetComputedStyle(aTargetElement);
if (!computedStyle) { if (!computedStyle) {
return; return;

View File

@@ -49,7 +49,7 @@ void SMILCompositor::ComposeAttribute(bool& aMightHavePendingStyleUpdates) {
// If we might need to resolve base styles, grab a suitable ComputedStyle // If we might need to resolve base styles, grab a suitable ComputedStyle
// for initializing our SMILAttr with. // for initializing our SMILAttr with.
RefPtr<ComputedStyle> baseComputedStyle; RefPtr<const ComputedStyle> baseComputedStyle;
if (MightNeedBaseStyle()) { if (MightNeedBaseStyle()) {
baseComputedStyle = nsComputedDOMStyle::GetUnanimatedComputedStyleNoFlush( baseComputedStyle = nsComputedDOMStyle::GetUnanimatedComputedStyleNoFlush(
mKey.mElement, PseudoStyleType::NotPseudo); mKey.mElement, PseudoStyleType::NotPseudo);
@@ -122,7 +122,7 @@ void SMILCompositor::ClearAnimationEffects() {
// Protected Helper Functions // Protected Helper Functions
// -------------------------- // --------------------------
UniquePtr<SMILAttr> SMILCompositor::CreateSMILAttr( UniquePtr<SMILAttr> SMILCompositor::CreateSMILAttr(
ComputedStyle* aBaseComputedStyle) { const ComputedStyle* aBaseComputedStyle) {
nsCSSPropertyID propID = GetCSSPropertyToAnimate(); nsCSSPropertyID propID = GetCSSPropertyToAnimate();
if (propID != eCSSProperty_UNKNOWN) { if (propID != eCSSProperty_UNKNOWN) {

View File

@@ -79,7 +79,7 @@ class SMILCompositor : public PLDHashEntryHdr {
// //
// @param aBaseComputedStyle An optional ComputedStyle which, if set, will be // @param aBaseComputedStyle An optional ComputedStyle which, if set, will be
// used when fetching the base style. // used when fetching the base style.
UniquePtr<SMILAttr> CreateSMILAttr(ComputedStyle* aBaseComputedStyle); UniquePtr<SMILAttr> CreateSMILAttr(const ComputedStyle* aBaseComputedStyle);
// Returns the CSS property this compositor should animate, or // Returns the CSS property this compositor should animate, or
// eCSSProperty_UNKNOWN if this compositor does not animate a CSS property. // eCSSProperty_UNKNOWN if this compositor does not animate a CSS property.

View File

@@ -325,7 +325,7 @@ Float SVGContentUtils::GetStrokeWidth(SVGElement* aElement,
SVGContextPaint* aContextPaint) { SVGContextPaint* aContextPaint) {
Float res = 0.0; Float res = 0.0;
auto doCompute = [&](ComputedStyle const* computedStyle) { auto doCompute = [&](const ComputedStyle* computedStyle) {
const nsStyleSVG* styleSVG = computedStyle->StyleSVG(); const nsStyleSVG* styleSVG = computedStyle->StyleSVG();
if (styleSVG->mStrokeWidth.IsContextValue()) { if (styleSVG->mStrokeWidth.IsContextValue()) {
@@ -366,7 +366,7 @@ float SVGContentUtils::GetFontSize(Element* aElement) {
return GetFontSize(f->Style(), pc); return GetFontSize(f->Style(), pc);
} }
if (RefPtr<ComputedStyle> style = if (RefPtr<const ComputedStyle> style =
nsComputedDOMStyle::GetComputedStyleNoFlush(aElement)) { nsComputedDOMStyle::GetComputedStyleNoFlush(aElement)) {
return GetFontSize(style, pc); return GetFontSize(style, pc);
} }
@@ -381,7 +381,7 @@ float SVGContentUtils::GetFontSize(nsIFrame* aFrame) {
return GetFontSize(aFrame->Style(), aFrame->PresContext()); return GetFontSize(aFrame->Style(), aFrame->PresContext());
} }
float SVGContentUtils::GetFontSize(ComputedStyle* aComputedStyle, float SVGContentUtils::GetFontSize(const ComputedStyle* aComputedStyle,
nsPresContext* aPresContext) { nsPresContext* aPresContext) {
MOZ_ASSERT(aComputedStyle); MOZ_ASSERT(aComputedStyle);
MOZ_ASSERT(aPresContext); MOZ_ASSERT(aPresContext);
@@ -404,7 +404,7 @@ float SVGContentUtils::GetFontXHeight(Element* aElement) {
return GetFontXHeight(f->Style(), pc); return GetFontXHeight(f->Style(), pc);
} }
if (RefPtr<ComputedStyle> style = if (RefPtr<const ComputedStyle> style =
nsComputedDOMStyle::GetComputedStyleNoFlush(aElement)) { nsComputedDOMStyle::GetComputedStyleNoFlush(aElement)) {
return GetFontXHeight(style, pc); return GetFontXHeight(style, pc);
} }
@@ -419,7 +419,7 @@ float SVGContentUtils::GetFontXHeight(nsIFrame* aFrame) {
return GetFontXHeight(aFrame->Style(), aFrame->PresContext()); return GetFontXHeight(aFrame->Style(), aFrame->PresContext());
} }
float SVGContentUtils::GetFontXHeight(ComputedStyle* aComputedStyle, float SVGContentUtils::GetFontXHeight(const ComputedStyle* aComputedStyle,
nsPresContext* aPresContext) { nsPresContext* aPresContext) {
MOZ_ASSERT(aComputedStyle && aPresContext); MOZ_ASSERT(aComputedStyle && aPresContext);

View File

@@ -167,7 +167,7 @@ class SVGContentUtils {
*/ */
static float GetFontSize(mozilla::dom::Element* aElement); static float GetFontSize(mozilla::dom::Element* aElement);
static float GetFontSize(nsIFrame* aFrame); static float GetFontSize(nsIFrame* aFrame);
static float GetFontSize(ComputedStyle*, nsPresContext*); static float GetFontSize(const ComputedStyle*, nsPresContext*);
/* /*
* Get the number of CSS px (user units) per ex (i.e. the x-height in user * Get the number of CSS px (user units) per ex (i.e. the x-height in user
* units) for an nsIContent * units) for an nsIContent
@@ -177,7 +177,7 @@ class SVGContentUtils {
*/ */
static float GetFontXHeight(mozilla::dom::Element* aElement); static float GetFontXHeight(mozilla::dom::Element* aElement);
static float GetFontXHeight(nsIFrame* aFrame); static float GetFontXHeight(nsIFrame* aFrame);
static float GetFontXHeight(ComputedStyle*, nsPresContext*); static float GetFontXHeight(const ComputedStyle*, nsPresContext*);
/* /*
* Report a localized error message to the error console. * Report a localized error message to the error console.

View File

@@ -235,7 +235,7 @@ bool DoForComputedStyle(const SVGElement* aElement, Func aFunc) {
return true; return true;
} }
if (RefPtr<ComputedStyle> computedStyle = if (RefPtr<const ComputedStyle> computedStyle =
nsComputedDOMStyle::GetComputedStyleNoFlush(aElement)) { nsComputedDOMStyle::GetComputedStyleNoFlush(aElement)) {
aFunc(computedStyle.get()); aFunc(computedStyle.get());
return true; return true;

View File

@@ -542,7 +542,7 @@ bool EditorUtils::IsWhiteSpacePreformatted(const nsIContent& aContent) {
return false; return false;
} }
RefPtr<ComputedStyle> elementStyle = RefPtr<const ComputedStyle> elementStyle =
nsComputedDOMStyle::GetComputedStyleNoFlush(element); nsComputedDOMStyle::GetComputedStyleNoFlush(element);
if (!elementStyle) { if (!elementStyle) {
// Consider nodes without a ComputedStyle to be NOT preformatted: // Consider nodes without a ComputedStyle to be NOT preformatted:
@@ -563,7 +563,7 @@ bool EditorUtils::IsNewLinePreformatted(const nsIContent& aContent) {
return false; return false;
} }
RefPtr<ComputedStyle> elementStyle = RefPtr<const ComputedStyle> elementStyle =
nsComputedDOMStyle::GetComputedStyleNoFlush(element); nsComputedDOMStyle::GetComputedStyleNoFlush(element);
if (!elementStyle) { if (!elementStyle) {
// Consider nodes without a ComputedStyle to be NOT preformatted: // Consider nodes without a ComputedStyle to be NOT preformatted:
@@ -584,7 +584,7 @@ bool EditorUtils::IsOnlyNewLinePreformatted(const nsIContent& aContent) {
return false; return false;
} }
RefPtr<ComputedStyle> elementStyle = RefPtr<const ComputedStyle> elementStyle =
nsComputedDOMStyle::GetComputedStyleNoFlush(element); nsComputedDOMStyle::GetComputedStyleNoFlush(element);
if (!elementStyle) { if (!elementStyle) {
// Consider nodes without a ComputedStyle to be NOT preformatted: // Consider nodes without a ComputedStyle to be NOT preformatted:

View File

@@ -937,7 +937,8 @@ nsresult HTMLEditor::GetTemporaryStyleForFocusedPositionedElement(
return NS_OK; return NS_OK;
} }
RefPtr<ComputedStyle> style = nsComputedDOMStyle::GetComputedStyle(&aElement); RefPtr<const ComputedStyle> style =
nsComputedDOMStyle::GetComputedStyle(&aElement);
if (NS_WARN_IF(Destroyed())) { if (NS_WARN_IF(Destroyed())) {
return NS_ERROR_EDITOR_DESTROYED; return NS_ERROR_EDITOR_DESTROYED;
} }

View File

@@ -160,7 +160,7 @@ bool HTMLEditUtils::IsInlineStyle(nsINode* aNode) {
} }
bool HTMLEditUtils::IsDisplayOutsideInline(const Element& aElement) { bool HTMLEditUtils::IsDisplayOutsideInline(const Element& aElement) {
RefPtr<ComputedStyle> elementStyle = RefPtr<const ComputedStyle> elementStyle =
nsComputedDOMStyle::GetComputedStyleNoFlush(&aElement); nsComputedDOMStyle::GetComputedStyleNoFlush(&aElement);
if (!elementStyle) { if (!elementStyle) {
return false; return false;

View File

@@ -4063,7 +4063,7 @@ already_AddRefed<nsFontMetrics> nsLayoutUtils::GetFontMetricsForFrame(
} }
already_AddRefed<nsFontMetrics> nsLayoutUtils::GetFontMetricsForComputedStyle( already_AddRefed<nsFontMetrics> nsLayoutUtils::GetFontMetricsForComputedStyle(
ComputedStyle* aComputedStyle, nsPresContext* aPresContext, const ComputedStyle* aComputedStyle, nsPresContext* aPresContext,
float aInflation, uint8_t aVariantWidth) { float aInflation, uint8_t aVariantWidth) {
WritingMode wm(aComputedStyle); WritingMode wm(aComputedStyle);
const nsStyleFont* styleFont = aComputedStyle->StyleFont(); const nsStyleFont* styleFont = aComputedStyle->StyleFont();
@@ -6903,7 +6903,7 @@ nsIFrame* nsLayoutUtils::GetReferenceFrame(nsIFrame* aFrame) {
} }
/* static */ gfx::ShapedTextFlags nsLayoutUtils::GetTextRunFlagsForStyle( /* static */ gfx::ShapedTextFlags nsLayoutUtils::GetTextRunFlagsForStyle(
ComputedStyle* aComputedStyle, nsPresContext* aPresContext, const ComputedStyle* aComputedStyle, nsPresContext* aPresContext,
const nsStyleFont* aStyleFont, const nsStyleText* aStyleText, const nsStyleFont* aStyleFont, const nsStyleText* aStyleText,
nscoord aLetterSpacing) { nscoord aLetterSpacing) {
gfx::ShapedTextFlags result = gfx::ShapedTextFlags(); gfx::ShapedTextFlags result = gfx::ShapedTextFlags();
@@ -6932,7 +6932,7 @@ nsIFrame* nsLayoutUtils::GetReferenceFrame(nsIFrame* aFrame) {
} }
/* static */ gfx::ShapedTextFlags nsLayoutUtils::GetTextRunOrientFlagsForStyle( /* static */ gfx::ShapedTextFlags nsLayoutUtils::GetTextRunOrientFlagsForStyle(
ComputedStyle* aComputedStyle) { const ComputedStyle* aComputedStyle) {
auto writingMode = aComputedStyle->StyleVisibility()->mWritingMode; auto writingMode = aComputedStyle->StyleVisibility()->mWritingMode;
switch (writingMode) { switch (writingMode) {
case StyleWritingModeProperty::HorizontalTb: case StyleWritingModeProperty::HorizontalTb:

View File

@@ -1401,7 +1401,7 @@ class nsLayoutUtils {
* @param aSizeInflation number to multiply font size by * @param aSizeInflation number to multiply font size by
*/ */
static already_AddRefed<nsFontMetrics> GetFontMetricsForComputedStyle( static already_AddRefed<nsFontMetrics> GetFontMetricsForComputedStyle(
ComputedStyle* aComputedStyle, nsPresContext* aPresContext, const ComputedStyle* aComputedStyle, nsPresContext* aPresContext,
float aSizeInflation = 1.0f, float aSizeInflation = 1.0f,
uint8_t aVariantWidth = NS_FONT_VARIANT_WIDTH_NORMAL); uint8_t aVariantWidth = NS_FONT_VARIANT_WIDTH_NORMAL);
@@ -2114,15 +2114,14 @@ class nsLayoutUtils {
* and prefs indicate we should be optimizing for speed over quality * and prefs indicate we should be optimizing for speed over quality
*/ */
static mozilla::gfx::ShapedTextFlags GetTextRunFlagsForStyle( static mozilla::gfx::ShapedTextFlags GetTextRunFlagsForStyle(
ComputedStyle* aComputedStyle, nsPresContext* aPresContext, const ComputedStyle*, nsPresContext*, const nsStyleFont*,
const nsStyleFont* aStyleFont, const nsStyleText* aStyleText, const nsStyleText*, nscoord aLetterSpacing);
nscoord aLetterSpacing);
/** /**
* Get orientation flags for textrun construction. * Get orientation flags for textrun construction.
*/ */
static mozilla::gfx::ShapedTextFlags GetTextRunOrientFlagsForStyle( static mozilla::gfx::ShapedTextFlags GetTextRunOrientFlagsForStyle(
ComputedStyle* aComputedStyle); const ComputedStyle*);
/** /**
* Takes two rectangles whose origins must be the same, and computes * Takes two rectangles whose origins must be the same, and computes

View File

@@ -2740,7 +2740,7 @@ static nscoord GetNormalLineHeight(nsFontMetrics* aFontMetrics) {
return normalLineHeight; return normalLineHeight;
} }
static inline nscoord ComputeLineHeight(ComputedStyle* aComputedStyle, static inline nscoord ComputeLineHeight(const ComputedStyle* aComputedStyle,
nsPresContext* aPresContext, nsPresContext* aPresContext,
nscoord aBlockBSize, nscoord aBlockBSize,
float aFontSizeInflation) { float aFontSizeInflation) {
@@ -2800,7 +2800,7 @@ void ReflowInput::SetLineHeight(nscoord aLineHeight) {
/* static */ /* static */
nscoord ReflowInput::CalcLineHeight(nsIContent* aContent, nscoord ReflowInput::CalcLineHeight(nsIContent* aContent,
ComputedStyle* aComputedStyle, const ComputedStyle* aComputedStyle,
nsPresContext* aPresContext, nsPresContext* aPresContext,
nscoord aBlockBSize, nscoord aBlockBSize,
float aFontSizeInflation) { float aFontSizeInflation) {

View File

@@ -724,7 +724,7 @@ struct ReflowInput : public SizeComputationInput {
* calculation. * calculation.
*/ */
static nscoord CalcLineHeight(nsIContent* aContent, static nscoord CalcLineHeight(nsIContent* aContent,
ComputedStyle* aComputedStyle, const ComputedStyle* aComputedStyle,
nsPresContext* aPresContext, nsPresContext* aPresContext,
nscoord aBlockBSize, float aFontSizeInflation); nscoord aBlockBSize, float aFontSizeInflation);

View File

@@ -53,7 +53,7 @@ using namespace mozilla::dom;
namespace mozilla { namespace mozilla {
namespace dom { namespace dom {
static already_AddRefed<ComputedStyle> GetCleanComputedStyleForElement( static already_AddRefed<const ComputedStyle> GetCleanComputedStyleForElement(
dom::Element* aElement, PseudoStyleType aPseudo) { dom::Element* aElement, PseudoStyleType aPseudo) {
MOZ_ASSERT(aElement); MOZ_ASSERT(aElement);
@@ -189,7 +189,7 @@ void InspectorUtils::GetCSSStyleRules(
return; return;
} }
RefPtr<ComputedStyle> computedStyle = RefPtr<const ComputedStyle> computedStyle =
GetCleanComputedStyleForElement(&aElement, *type); GetCleanComputedStyleForElement(&aElement, *type);
if (!computedStyle) { if (!computedStyle) {
// This can fail for elements that are not in the document or // This can fail for elements that are not in the document or

View File

@@ -16,7 +16,6 @@ class nsAtom;
class nsINode; class nsINode;
class nsINodeList; class nsINodeList;
class nsRange; class nsRange;
class ComputedStyle;
namespace mozilla { namespace mozilla {
class BindingStyleRule; class BindingStyleRule;

View File

@@ -195,7 +195,7 @@ AnimationValue AnimationValue::FromString(nsCSSPropertyID aProperty,
// GetComputedStyle() flushes style, so we shouldn't assume that any // GetComputedStyle() flushes style, so we shouldn't assume that any
// non-owning references we have are still valid. // non-owning references we have are still valid.
RefPtr<ComputedStyle> computedStyle = RefPtr<const ComputedStyle> computedStyle =
nsComputedDOMStyle::GetComputedStyle(aElement); nsComputedDOMStyle::GetComputedStyle(aElement);
MOZ_ASSERT(computedStyle); MOZ_ASSERT(computedStyle);

View File

@@ -508,7 +508,7 @@ nsresult nsComputedDOMStyle::GetPropertyValue(
} }
/* static */ /* static */
already_AddRefed<ComputedStyle> nsComputedDOMStyle::GetComputedStyle( already_AddRefed<const ComputedStyle> nsComputedDOMStyle::GetComputedStyle(
Element* aElement, PseudoStyleType aPseudo, StyleType aStyleType) { Element* aElement, PseudoStyleType aPseudo, StyleType aStyleType) {
if (Document* doc = aElement->GetComposedDoc()) { if (Document* doc = aElement->GetComposedDoc()) {
doc->FlushPendingNotifications(FlushType::Style); doc->FlushPendingNotifications(FlushType::Style);
@@ -524,7 +524,7 @@ already_AddRefed<ComputedStyle> nsComputedDOMStyle::GetComputedStyle(
* ::first-letter frame, in which case we can't return the frame style, and we * ::first-letter frame, in which case we can't return the frame style, and we
* need to resolve it. See bug 505515. * need to resolve it. See bug 505515.
*/ */
static bool MustReresolveStyle(const mozilla::ComputedStyle* aStyle) { static bool MustReresolveStyle(const ComputedStyle* aStyle) {
MOZ_ASSERT(aStyle); MOZ_ASSERT(aStyle);
// TODO(emilio): We may want to avoid re-resolving pseudo-element styles // TODO(emilio): We may want to avoid re-resolving pseudo-element styles
@@ -549,9 +549,11 @@ static bool IsInFlatTree(const Element& aElement) {
return root && root->IsDocument(); return root && root->IsDocument();
} }
already_AddRefed<ComputedStyle> nsComputedDOMStyle::DoGetComputedStyleNoFlush( already_AddRefed<const ComputedStyle>
const Element* aElement, PseudoStyleType aPseudo, PresShell* aPresShell, nsComputedDOMStyle::DoGetComputedStyleNoFlush(const Element* aElement,
StyleType aStyleType) { PseudoStyleType aPseudo,
PresShell* aPresShell,
StyleType aStyleType) {
MOZ_ASSERT(aElement, "NULL element"); MOZ_ASSERT(aElement, "NULL element");
// If the content has a pres shell, we must use it. Otherwise we'd // If the content has a pres shell, we must use it. Otherwise we'd
@@ -612,10 +614,11 @@ already_AddRefed<ComputedStyle> nsComputedDOMStyle::DoGetComputedStyleNoFlush(
return result.forget(); return result.forget();
} }
already_AddRefed<ComputedStyle> already_AddRefed<const ComputedStyle>
nsComputedDOMStyle::GetUnanimatedComputedStyleNoFlush(Element* aElement, nsComputedDOMStyle::GetUnanimatedComputedStyleNoFlush(Element* aElement,
PseudoStyleType aPseudo) { PseudoStyleType aPseudo) {
RefPtr<ComputedStyle> style = GetComputedStyleNoFlush(aElement, aPseudo); RefPtr<const ComputedStyle> style =
GetComputedStyleNoFlush(aElement, aPseudo);
if (!style) { if (!style) {
return nullptr; return nullptr;
} }
@@ -792,7 +795,7 @@ void nsComputedDOMStyle::ClearComputedStyle() {
} }
void nsComputedDOMStyle::SetResolvedComputedStyle( void nsComputedDOMStyle::SetResolvedComputedStyle(
RefPtr<ComputedStyle>&& aContext, uint64_t aGeneration) { RefPtr<const ComputedStyle>&& aContext, uint64_t aGeneration) {
if (!mResolvedComputedStyle) { if (!mResolvedComputedStyle) {
mResolvedComputedStyle = true; mResolvedComputedStyle = true;
mElement->AddMutationObserver(this); mElement->AddMutationObserver(this);
@@ -1087,9 +1090,6 @@ void nsComputedDOMStyle::UpdateCurrentStyleSources(nsCSSPropertyID aPropID) {
// For undisplayed elements we need to take into account any DOM changes that // For undisplayed elements we need to take into account any DOM changes that
// might cause a restyle, because Servo will not increase the generation for // might cause a restyle, because Servo will not increase the generation for
// undisplayed elements. // undisplayed elements.
// As for Gecko, GetUndisplayedRestyleGeneration is effectively equal to
// GetRestyleGeneration, since the generation is incremented whenever we
// process restyles.
uint64_t currentGeneration = uint64_t currentGeneration =
mPresShell->GetPresContext()->GetUndisplayedRestyleGeneration(); mPresShell->GetPresContext()->GetUndisplayedRestyleGeneration();
@@ -1118,9 +1118,10 @@ void nsComputedDOMStyle::UpdateCurrentStyleSources(nsCSSPropertyID aPropID) {
if (!mComputedStyle || MustReresolveStyle(mComputedStyle)) { if (!mComputedStyle || MustReresolveStyle(mComputedStyle)) {
PresShell* presShellForContent = mElement->OwnerDoc()->GetPresShell(); PresShell* presShellForContent = mElement->OwnerDoc()->GetPresShell();
// Need to resolve a style. // Need to resolve a style.
RefPtr<ComputedStyle> resolvedComputedStyle = DoGetComputedStyleNoFlush( RefPtr<const ComputedStyle> resolvedComputedStyle =
mElement, mPseudo, DoGetComputedStyleNoFlush(
presShellForContent ? presShellForContent : mPresShell, mStyleType); mElement, mPseudo,
presShellForContent ? presShellForContent : mPresShell, mStyleType);
if (!resolvedComputedStyle) { if (!resolvedComputedStyle) {
ClearComputedStyle(); ClearComputedStyle();
return; return;

View File

@@ -93,11 +93,11 @@ class nsComputedDOMStyle final : public nsDOMCSSDeclaration,
nsINode* GetAssociatedNode() const override { return mElement; } nsINode* GetAssociatedNode() const override { return mElement; }
nsINode* GetParentObject() const override { return mElement; } nsINode* GetParentObject() const override { return mElement; }
static already_AddRefed<ComputedStyle> GetComputedStyle( static already_AddRefed<const ComputedStyle> GetComputedStyle(
Element* aElement, PseudoStyleType = PseudoStyleType::NotPseudo, Element* aElement, PseudoStyleType = PseudoStyleType::NotPseudo,
StyleType = StyleType::All); StyleType = StyleType::All);
static already_AddRefed<ComputedStyle> GetComputedStyleNoFlush( static already_AddRefed<const ComputedStyle> GetComputedStyleNoFlush(
const Element* aElement, const Element* aElement,
PseudoStyleType aPseudo = PseudoStyleType::NotPseudo, PseudoStyleType aPseudo = PseudoStyleType::NotPseudo,
StyleType aStyleType = StyleType::All) { StyleType aStyleType = StyleType::All) {
@@ -106,7 +106,8 @@ class nsComputedDOMStyle final : public nsDOMCSSDeclaration,
aStyleType); aStyleType);
} }
static already_AddRefed<ComputedStyle> GetUnanimatedComputedStyleNoFlush( static already_AddRefed<const ComputedStyle>
GetUnanimatedComputedStyleNoFlush(
Element*, PseudoStyleType = PseudoStyleType::NotPseudo); Element*, PseudoStyleType = PseudoStyleType::NotPseudo);
// Helper for nsDOMWindowUtils::GetVisitedDependentComputedStyle // Helper for nsDOMWindowUtils::GetVisitedDependentComputedStyle
@@ -160,11 +161,11 @@ class nsComputedDOMStyle final : public nsDOMCSSDeclaration,
// Helper functions called by UpdateCurrentStyleSources. // Helper functions called by UpdateCurrentStyleSources.
void ClearComputedStyle(); void ClearComputedStyle();
void SetResolvedComputedStyle(RefPtr<ComputedStyle>&& aContext, void SetResolvedComputedStyle(RefPtr<const ComputedStyle>&& aContext,
uint64_t aGeneration); uint64_t aGeneration);
void SetFrameComputedStyle(ComputedStyle* aStyle, uint64_t aGeneration); void SetFrameComputedStyle(ComputedStyle* aStyle, uint64_t aGeneration);
static already_AddRefed<ComputedStyle> DoGetComputedStyleNoFlush( static already_AddRefed<const ComputedStyle> DoGetComputedStyleNoFlush(
const Element*, PseudoStyleType, mozilla::PresShell*, StyleType); const Element*, PseudoStyleType, mozilla::PresShell*, StyleType);
#define STYLE_STRUCT(name_) \ #define STYLE_STRUCT(name_) \
@@ -339,7 +340,7 @@ class nsComputedDOMStyle final : public nsDOMCSSDeclaration,
* by checking whether flush styles results in any restyles having been * by checking whether flush styles results in any restyles having been
* processed. * processed.
*/ */
RefPtr<ComputedStyle> mComputedStyle; RefPtr<const ComputedStyle> mComputedStyle;
/* /*
* While computing style data, the primary frame for mContent --- named * While computing style data, the primary frame for mContent --- named

View File

@@ -123,7 +123,7 @@ already_AddRefed<nsIURI> nsMenuItemIconX::GetIconURI(nsIContent* aContent) {
return nullptr; return nullptr;
} }
RefPtr<ComputedStyle> sc = nsComputedDOMStyle::GetComputedStyle(aContent->AsElement()); RefPtr<const ComputedStyle> sc = nsComputedDOMStyle::GetComputedStyle(aContent->AsElement());
if (!sc) { if (!sc) {
return nullptr; return nullptr;
} }

View File

@@ -711,7 +711,7 @@ void nsMenuX::OnWillActivateItem(NSMenuItem* aItem) {
static NSUserInterfaceLayoutDirection DirectionForElement(dom::Element* aElement) { static NSUserInterfaceLayoutDirection DirectionForElement(dom::Element* aElement) {
// Get the direction from the computed style so that inheritance into submenus is respected. // Get the direction from the computed style so that inheritance into submenus is respected.
// aElement may not have a frame. // aElement may not have a frame.
RefPtr<ComputedStyle> sc = nsComputedDOMStyle::GetComputedStyle(aElement); RefPtr<const ComputedStyle> sc = nsComputedDOMStyle::GetComputedStyle(aElement);
if (!sc) { if (!sc) {
return NSApp.userInterfaceLayoutDirection; return NSApp.userInterfaceLayoutDirection;
} }

View File

@@ -113,7 +113,6 @@ nsresult StatusBarEntry::Init() {
mMenu->GetAttr(kNameSpaceID_None, nsGkAtoms::image, imageURIString); mMenu->GetAttr(kNameSpaceID_None, nsGkAtoms::image, imageURIString);
nsresult rv; nsresult rv;
RefPtr<ComputedStyle> sc;
nsCOMPtr<nsIURI> iconURI; nsCOMPtr<nsIURI> iconURI;
if (!hasImageAttr) { if (!hasImageAttr) {
// If the content node has no "image" attribute, get the // If the content node has no "image" attribute, get the
@@ -123,7 +122,8 @@ nsresult StatusBarEntry::Init() {
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
} }
sc = nsComputedDOMStyle::GetComputedStyle(mMenu); RefPtr<const ComputedStyle> sc =
nsComputedDOMStyle::GetComputedStyle(mMenu);
if (!sc) { if (!sc) {
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
} }