diff --git a/dom/base/Element.cpp b/dom/base/Element.cpp index a377b06e47..7522128d46 100644 --- a/dom/base/Element.cpp +++ b/dom/base/Element.cpp @@ -56,7 +56,6 @@ #include "mozilla/AnimationComparator.h" #include "mozilla/AsyncEventDispatcher.h" #include "mozilla/ContentEvents.h" -#include "mozilla/DeclarationBlockInlines.h" #include "mozilla/EffectSet.h" #include "mozilla/EventDispatcher.h" #include "mozilla/EventListenerManager.h" @@ -108,6 +107,7 @@ #include "nsViewManager.h" #include "nsIScrollableFrame.h" #include "mozilla/css/StyleRule.h" /* For nsCSSSelectorList */ +#include "mozilla/css/Declaration.h" #include "nsCSSRuleProcessor.h" #include "nsRuleProcessorData.h" #include "nsTextNode.h" @@ -2024,7 +2024,7 @@ Element::GetSMILOverrideStyle() return slots->mSMILOverrideStyle; } -DeclarationBlock* +css::Declaration* Element::GetSMILOverrideStyleDeclaration() { Element::nsExtendedDOMSlots* slots = GetExistingExtendedDOMSlots(); @@ -2032,7 +2032,7 @@ Element::GetSMILOverrideStyleDeclaration() } nsresult -Element::SetSMILOverrideStyleDeclaration(DeclarationBlock* aDeclaration, +Element::SetSMILOverrideStyleDeclaration(css::Declaration* aDeclaration, bool aNotify) { Element::nsExtendedDOMSlots* slots = ExtendedDOMSlots(); @@ -2072,14 +2072,14 @@ Element::IsInteractiveHTMLContent(bool aIgnoreTabindex) const return false; } -DeclarationBlock* +css::Declaration* Element::GetInlineStyleDeclaration() { return nullptr; } nsresult -Element::SetInlineStyleDeclaration(DeclarationBlock* aDeclaration, +Element::SetInlineStyleDeclaration(css::Declaration* aDeclaration, const nsAString* aSerialized, bool aNotify) { diff --git a/dom/base/Element.h b/dom/base/Element.h index cf342e94d1..4d4c9284d3 100644 --- a/dom/base/Element.h +++ b/dom/base/Element.h @@ -57,7 +57,9 @@ class nsDocument; class nsDOMStringMap; namespace mozilla { -class DeclarationBlock; +namespace css { + class Declaration; +} // namespace css namespace dom { struct AnimationFilter; struct ScrollIntoViewOptions; @@ -274,13 +276,13 @@ public: /** * Get the inline style declaration, if any, for this element. */ - virtual DeclarationBlock* GetInlineStyleDeclaration(); + virtual css::Declaration* GetInlineStyleDeclaration(); /** * Set the inline style declaration for this element. This will send * an appropriate AttributeChanged notification if aNotify is true. */ - virtual nsresult SetInlineStyleDeclaration(DeclarationBlock* aDeclaration, + virtual nsresult SetInlineStyleDeclaration(css::Declaration* aDeclaration, const nsAString* aSerialized, bool aNotify); @@ -288,7 +290,7 @@ public: * Get the SMIL override style declaration for this element. If the * rule hasn't been created, this method simply returns null. */ - virtual DeclarationBlock* GetSMILOverrideStyleDeclaration(); + virtual css::Declaration* GetSMILOverrideStyleDeclaration(); /** * Set the SMIL override style declaration for this element. If @@ -296,7 +298,7 @@ public: * context, so that the style changes will be noticed. */ virtual nsresult SetSMILOverrideStyleDeclaration( - DeclarationBlock* aDeclaration, bool aNotify); + css::Declaration* aDeclaration, bool aNotify); /** * Returns a new nsISMILAttr that allows the caller to animate the given diff --git a/dom/base/FragmentOrElement.cpp b/dom/base/FragmentOrElement.cpp index 126267fe93..1c2fc05b09 100644 --- a/dom/base/FragmentOrElement.cpp +++ b/dom/base/FragmentOrElement.cpp @@ -17,7 +17,6 @@ #include "mozilla/dom/FragmentOrElement.h" #include "mozilla/AsyncEventDispatcher.h" -#include "mozilla/DeclarationBlockInlines.h" #include "mozilla/EffectSet.h" #include "mozilla/EventDispatcher.h" #include "mozilla/EventListenerManager.h" @@ -99,6 +98,7 @@ #include "nsIScrollableFrame.h" #include "ChildIterator.h" #include "mozilla/css/StyleRule.h" /* For nsCSSSelectorList */ +#include "mozilla/css/Declaration.h" #include "nsRuleProcessorData.h" #include "nsTextNode.h" #include "mozilla/dom/NodeListBinding.h" diff --git a/dom/base/FragmentOrElement.h b/dom/base/FragmentOrElement.h index 2f65fe5174..50c10536a9 100644 --- a/dom/base/FragmentOrElement.h +++ b/dom/base/FragmentOrElement.h @@ -35,7 +35,9 @@ class nsDOMStringMap; class nsIURI; namespace mozilla { -class DeclarationBlock; +namespace css { +class Declaration; +} namespace dom { struct CustomElementData; class DOMIntersectionObserver; @@ -265,7 +267,7 @@ public: /** * Holds any SMIL override style declaration for this element. */ - RefPtr mSMILOverrideStyleDeclaration; + RefPtr mSMILOverrideStyleDeclaration; /** * The nearest enclosing content node with a binding that created us. diff --git a/dom/base/nsAttrValue.cpp b/dom/base/nsAttrValue.cpp index cdc95a570e..9c4dcc9236 100644 --- a/dom/base/nsAttrValue.cpp +++ b/dom/base/nsAttrValue.cpp @@ -16,7 +16,7 @@ #include "nsIAtom.h" #include "nsUnicharUtils.h" #include "mozilla/MemoryReporting.h" -#include "mozilla/DeclarationBlockInlines.h" +#include "mozilla/css/Declaration.h" #include "nsContentUtils.h" #include "nsReadableUtils.h" #include "prprf.h" @@ -149,7 +149,7 @@ nsAttrValue::nsAttrValue(nsIAtom* aValue) SetTo(aValue); } -nsAttrValue::nsAttrValue(already_AddRefed aValue, +nsAttrValue::nsAttrValue(already_AddRefed aValue, const nsAString* aSerialized) : mBits(0) { @@ -419,7 +419,7 @@ nsAttrValue::SetTo(double aValue, const nsAString* aSerialized) } void -nsAttrValue::SetTo(already_AddRefed aValue, +nsAttrValue::SetTo(already_AddRefed aValue, const nsAString* aSerialized) { MiscContainer* cont = EnsureEmptyMiscContainer(); @@ -642,7 +642,7 @@ nsAttrValue::ToString(nsAString& aResult) const { aResult.Truncate(); MiscContainer *container = GetMiscContainer(); - if (DeclarationBlock* decl = container->mValue.mCSSDeclaration) { + if (css::Declaration* decl = container->mValue.mCSSDeclaration) { decl->ToString(aResult); } const_cast(this)->SetMiscAtomOrString(&aResult); @@ -1747,7 +1747,7 @@ nsAttrValue::ParseStyleAttribute(const nsAString& aString, } } - RefPtr decl; + RefPtr decl; css::Loader* cssLoader = ownerDoc->CSSLoader(); nsCSSParser cssParser(cssLoader); decl = cssParser.ParseStyleAttribute(aString, docURI, baseURI, diff --git a/dom/base/nsAttrValue.h b/dom/base/nsAttrValue.h index f2cb17aebf..831633afa2 100644 --- a/dom/base/nsAttrValue.h +++ b/dom/base/nsAttrValue.h @@ -36,8 +36,8 @@ class nsStyledElement; struct MiscContainer; namespace mozilla { -class DeclarationBlock; namespace css { +class Declaration; struct URLValue; struct ImageValue; } // namespace css @@ -122,7 +122,7 @@ public: nsAttrValue(const nsAttrValue& aOther); explicit nsAttrValue(const nsAString& aValue); explicit nsAttrValue(nsIAtom* aValue); - nsAttrValue(already_AddRefed aValue, + nsAttrValue(already_AddRefed aValue, const nsAString* aSerialized); explicit nsAttrValue(const nsIntMargin& aValue); ~nsAttrValue(); @@ -148,7 +148,7 @@ public: void SetTo(int16_t aInt); void SetTo(int32_t aInt, const nsAString* aSerialized); void SetTo(double aValue, const nsAString* aSerialized); - void SetTo(already_AddRefed aValue, + void SetTo(already_AddRefed aValue, const nsAString* aSerialized); void SetTo(mozilla::css::URLValue* aValue, const nsAString* aSerialized); void SetTo(const nsIntMargin& aValue); @@ -200,7 +200,7 @@ public: inline int16_t GetEnumValue() const; inline float GetPercentValue() const; inline AtomArray* GetAtomArrayValue() const; - inline mozilla::DeclarationBlock* GetCSSDeclarationValue() const; + inline mozilla::css::Declaration* GetCSSDeclarationValue() const; inline mozilla::css::URLValue* GetURLValue() const; inline mozilla::css::ImageValue* GetImageValue() const; inline double GetDoubleValue() const; diff --git a/dom/base/nsAttrValueInlines.h b/dom/base/nsAttrValueInlines.h index 382270f157..8909111137 100644 --- a/dom/base/nsAttrValueInlines.h +++ b/dom/base/nsAttrValueInlines.h @@ -30,7 +30,7 @@ struct MiscContainer final nscolor mColor; uint32_t mEnumValue; int32_t mPercent; - mozilla::DeclarationBlock* mCSSDeclaration; + mozilla::css::Declaration* mCSSDeclaration; mozilla::css::URLValue* mURL; mozilla::css::ImageValue* mImage; nsAttrValue::AtomArray* mAtomArray; @@ -145,7 +145,7 @@ nsAttrValue::GetAtomArrayValue() const return GetMiscContainer()->mValue.mAtomArray; } -inline mozilla::DeclarationBlock* +inline mozilla::css::Declaration* nsAttrValue::GetCSSDeclarationValue() const { NS_PRECONDITION(Type() == eCSSDeclaration, "wrong type"); diff --git a/dom/base/nsStyledElement.cpp b/dom/base/nsStyledElement.cpp index b9331c076d..607926a484 100644 --- a/dom/base/nsStyledElement.cpp +++ b/dom/base/nsStyledElement.cpp @@ -14,9 +14,9 @@ #include "nsDOMCSSAttrDeclaration.h" #include "nsServiceManagerUtils.h" #include "nsIDocument.h" -#include "mozilla/DeclarationBlockInlines.h" #include "nsCSSParser.h" #include "mozilla/css/Loader.h" +#include "mozilla/css/Declaration.h" #include "nsIDOMMutationEvent.h" #include "nsXULElement.h" #include "nsContentUtils.h" @@ -64,7 +64,7 @@ nsStyledElement::BeforeSetAttr(int32_t aNamespaceID, nsIAtom* aName, } nsresult -nsStyledElement::SetInlineStyleDeclaration(DeclarationBlock* aDeclaration, +nsStyledElement::SetInlineStyleDeclaration(css::Declaration* aDeclaration, const nsAString* aSerialized, bool aNotify) { @@ -113,7 +113,7 @@ nsStyledElement::SetInlineStyleDeclaration(DeclarationBlock* aDeclaration, document, updateBatch); } -DeclarationBlock* +css::Declaration* nsStyledElement::GetInlineStyleDeclaration() { if (!MayHaveStyle()) { diff --git a/dom/base/nsStyledElement.h b/dom/base/nsStyledElement.h index 4c32a049b2..38e76f44ae 100644 --- a/dom/base/nsStyledElement.h +++ b/dom/base/nsStyledElement.h @@ -17,7 +17,9 @@ #include "mozilla/dom/Element.h" namespace mozilla { -class DeclarationBlock; +namespace css { +class Declaration; +} // namespace css } // namespace mozilla // IID for nsStyledElement interface @@ -43,8 +45,8 @@ public: NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr) override; // Element interface methods - virtual mozilla::DeclarationBlock* GetInlineStyleDeclaration() override; - virtual nsresult SetInlineStyleDeclaration(mozilla::DeclarationBlock* aDeclaration, + virtual mozilla::css::Declaration* GetInlineStyleDeclaration() override; + virtual nsresult SetInlineStyleDeclaration(mozilla::css::Declaration* aDeclaration, const nsAString* aSerialized, bool aNotify) override; diff --git a/dom/html/nsGenericHTMLElement.cpp b/dom/html/nsGenericHTMLElement.cpp index da7121a714..b34f10df6e 100644 --- a/dom/html/nsGenericHTMLElement.cpp +++ b/dom/html/nsGenericHTMLElement.cpp @@ -4,7 +4,6 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "mozilla/ArrayUtils.h" -#include "mozilla/DeclarationBlockInlines.h" #include "mozilla/EventDispatcher.h" #include "mozilla/EventListenerManager.h" #include "mozilla/EventStateManager.h" @@ -189,11 +188,11 @@ nsGenericHTMLElement::CopyInnerTo(Element* aDst) if (name->Equals(nsGkAtoms::style, kNameSpaceID_None) && value->Type() == nsAttrValue::eCSSDeclaration) { - DeclarationBlock* decl = value->GetCSSDeclarationValue(); + css::Declaration* decl = value->GetCSSDeclarationValue(); // We can't just set this as a string, because that will fail // to reparse the string into style data until the node is // inserted into the document. Clone the Rule instead. - RefPtr declClone = decl->Clone(); + RefPtr declClone = decl->Clone(); rv = aDst->SetInlineStyleDeclaration(declClone, &valStr, false); NS_ENSURE_SUCCESS(rv, rv); diff --git a/dom/xul/nsXULElement.cpp b/dom/xul/nsXULElement.cpp index 332e7bb8b4..ee3a50cb88 100644 --- a/dom/xul/nsXULElement.cpp +++ b/dom/xul/nsXULElement.cpp @@ -38,7 +38,6 @@ #include "mozilla/EventListenerManager.h" #include "mozilla/EventStateManager.h" #include "mozilla/EventStates.h" -#include "mozilla/DeclarationBlockInlines.h" #include "nsFocusManager.h" #include "nsHTMLStyleSheet.h" #include "nsNameSpaceManager.h" @@ -54,6 +53,7 @@ #include "nsIScriptSecurityManager.h" #include "nsIServiceManager.h" #include "mozilla/css/StyleRule.h" +#include "mozilla/css/Declaration.h" #include "nsIURL.h" #include "nsViewManager.h" #include "nsIWidget.h" @@ -348,9 +348,9 @@ nsXULElement::Clone(mozilla::dom::NodeInfo *aNodeInfo, nsINode **aResult) const // Style rules need to be cloned. if (originalValue->Type() == nsAttrValue::eCSSDeclaration) { - DeclarationBlock* decl = originalValue->GetCSSDeclarationValue(); + css::Declaration* decl = originalValue->GetCSSDeclarationValue(); RefPtr - declClone = new css::Declaration(*decl->AsGecko()); + declClone = new css::Declaration(*decl); nsString stringValue; originalValue->ToString(stringValue); @@ -1900,9 +1900,9 @@ nsXULElement::MakeHeavyweight(nsXULPrototypeElement* aPrototype) // Style rules need to be cloned. if (protoattr->mValue.Type() == nsAttrValue::eCSSDeclaration) { - DeclarationBlock* decl = protoattr->mValue.GetCSSDeclarationValue(); + css::Declaration* decl = protoattr->mValue.GetCSSDeclarationValue(); RefPtr - declClone = new css::Declaration(*decl->AsGecko()); + declClone = new css::Declaration(*decl); nsString stringValue; protoattr->mValue.ToString(stringValue); diff --git a/editor/libeditor/CSSEditUtils.cpp b/editor/libeditor/CSSEditUtils.cpp index 976918b7c8..f2aaec3e23 100644 --- a/editor/libeditor/CSSEditUtils.cpp +++ b/editor/libeditor/CSSEditUtils.cpp @@ -9,8 +9,8 @@ #include "mozilla/ChangeStyleTransaction.h" #include "mozilla/HTMLEditor.h" #include "mozilla/Preferences.h" -#include "mozilla/DeclarationBlockInlines.h" #include "mozilla/css/StyleRule.h" +#include "mozilla/css/Declaration.h" #include "mozilla/dom/Element.h" #include "mozilla/mozalloc.h" #include "nsAString.h" @@ -548,7 +548,7 @@ CSSEditUtils::GetCSSInlinePropertyBase(nsINode* aNode, } MOZ_ASSERT(aStyleType == eSpecified); - RefPtr decl = element->GetInlineStyleDeclaration(); + RefPtr decl = element->GetInlineStyleDeclaration(); if (!decl) { return NS_OK; } @@ -556,7 +556,7 @@ CSSEditUtils::GetCSSInlinePropertyBase(nsINode* aNode, nsCSSProps::LookupProperty(nsDependentAtomString(aProperty), CSSEnabledState::eForAllContent); MOZ_ASSERT(prop != eCSSProperty_UNKNOWN); - decl->AsGecko()->GetPropertyValueByID(prop, aValue); + decl->GetPropertyValueByID(prop, aValue); return NS_OK; } diff --git a/layout/style/Declaration.cpp b/layout/style/Declaration.cpp index 6ef53f5db1..ab2def15fa 100644 --- a/layout/style/Declaration.cpp +++ b/layout/style/Declaration.cpp @@ -59,9 +59,14 @@ ImportantStyleData::List(FILE* out, int32_t aIndent) const } #endif +Declaration::Declaration() + : mImmutable(false) +{ + mContainer.mRaw = 0; +} + Declaration::Declaration(const Declaration& aCopy) - : DeclarationBlock(aCopy), - mOrder(aCopy.mOrder), + : mOrder(aCopy.mOrder), mVariableOrder(aCopy.mVariableOrder), mData(aCopy.mData ? aCopy.mData->Clone() : nullptr), mImportantData(aCopy.mImportantData ? @@ -71,7 +76,8 @@ Declaration::Declaration(const Declaration& aCopy) nullptr), mImportantVariables(aCopy.mImportantVariables ? new CSSVariableDeclarations(*aCopy.mImportantVariables) : - nullptr) + nullptr), + mImmutable(false) { } @@ -1827,6 +1833,24 @@ Declaration::InitializeEmpty() mData = nsCSSCompressedDataBlock::CreateEmptyBlock(); } +already_AddRefed +Declaration::Clone() const +{ + RefPtr result; + result = new Declaration(*this); + return result.forget(); +} + +already_AddRefed +Declaration::EnsureMutable() +{ + AssertNotExpanded(); + if (!IsMutable()) { + return Clone(); + } + return do_AddRef(this); +} + size_t Declaration::SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const { diff --git a/layout/style/Declaration.h b/layout/style/Declaration.h index e3ab95560c..e7701e7380 100644 --- a/layout/style/Declaration.h +++ b/layout/style/Declaration.h @@ -18,7 +18,6 @@ #endif #include "mozilla/Attributes.h" -#include "mozilla/DeclarationBlock.h" #include "mozilla/MemoryReporting.h" #include "CSSVariableDeclarations.h" #include "nsCSSDataBlock.h" @@ -83,8 +82,7 @@ private: // be copied before it can be modified, which is taken care of by // |EnsureMutable|. -class Declaration final : public DeclarationBlock - , public nsIStyleRule +class Declaration final : public nsIStyleRule { public: /** @@ -92,7 +90,7 @@ public: * |mData|) and cannot be used until its |CompressFrom| method or * |InitializeEmpty| method is called. */ - Declaration() : DeclarationBlock() {} + Declaration(); Declaration(const Declaration& aCopy); @@ -104,6 +102,63 @@ private: ~Declaration(); public: + /** + * Return whether |this| may be modified. + */ + bool IsMutable() const { + return !mImmutable; + } + + /** + * Crash if |this| cannot be modified. + */ + void AssertMutable() const { + MOZ_ASSERT(IsMutable(), "someone forgot to call EnsureMutable"); + } + + /** + * Mark this declaration as unmodifiable. It's 'const' so it can + * be called from ToString. + */ + void SetImmutable() const { mImmutable = true; } + + /** + * Copy |this|, if necessary to ensure that it can be modified. + */ + already_AddRefed EnsureMutable(); + + void SetOwningRule(css::Rule* aRule) { + MOZ_ASSERT(!mContainer.mOwningRule || !aRule, + "should never overwrite one rule with another"); + mContainer.mOwningRule = aRule; + } + + css::Rule* GetOwningRule() const { + if (mContainer.mRaw & 0x1) { + return nullptr; + } + return mContainer.mOwningRule; + } + + void SetHTMLCSSStyleSheet(nsHTMLCSSStyleSheet* aHTMLCSSStyleSheet) { + MOZ_ASSERT(!mContainer.mHTMLCSSStyleSheet || !aHTMLCSSStyleSheet, + "should never overwrite one sheet with another"); + mContainer.mHTMLCSSStyleSheet = aHTMLCSSStyleSheet; + if (aHTMLCSSStyleSheet) { + mContainer.mRaw |= uintptr_t(1); + } + } + + nsHTMLCSSStyleSheet* GetHTMLCSSStyleSheet() const { + if (!(mContainer.mRaw & 0x1)) { + return nullptr; + } + auto c = mContainer; + c.mRaw &= ~uintptr_t(1); + return c.mHTMLCSSStyleSheet; + } + + already_AddRefed Clone() const; // nsIStyleRule implementation virtual void MapRuleInfoInto(nsRuleData *aRuleData) override; @@ -367,6 +422,27 @@ public: size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const; private: + union { + // We only ever have one of these since we have an + // nsHTMLCSSStyleSheet only for style attributes, and style + // attributes never have an owning rule. + + // It's an nsHTMLCSSStyleSheet if the low bit is set. + + uintptr_t mRaw; + + // The style rule that owns this declaration. May be null. + css::Rule* mOwningRule; + + // The nsHTMLCSSStyleSheet that is responsible for this declaration. + // Only non-null for style attributes. + nsHTMLCSSStyleSheet* mHTMLCSSStyleSheet; + } mContainer; + + // set when declaration put in the rule tree; + // also by ToString (hence the 'mutable'). + mutable bool mImmutable; + // The order of properties in this declaration. Longhand properties are // represented by their nsCSSPropertyID value, and each custom property (--*) // is represented by a value that begins at eCSSProperty_COUNT. diff --git a/layout/style/DeclarationBlock.h b/layout/style/DeclarationBlock.h deleted file mode 100644 index 272cdccee3..0000000000 --- a/layout/style/DeclarationBlock.h +++ /dev/null @@ -1,140 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -/* - * representation of a declaration block in a CSS stylesheet, or of - * a style attribute - */ - -#ifndef mozilla_DeclarationBlock_h -#define mozilla_DeclarationBlock_h - -#include "mozilla/DeprecatedUtils.h" - -#include "nsCSSPropertyID.h" - -class nsHTMLCSSStyleSheet; - -namespace mozilla { - -namespace css { -class Declaration; -class Rule; -} // namespace css - -class DeclarationBlock -{ -protected: - explicit DeclarationBlock() - : mImmutable(false) { mContainer.mRaw = 0; } - - DeclarationBlock(const DeclarationBlock& aCopy) - : DeclarationBlock() {} - -public: - MOZ_DECL_DEPRECATED_METHODS(css::Declaration) - - inline MozExternalRefCountType AddRef(); - inline MozExternalRefCountType Release(); - - inline already_AddRefed Clone() const; - - /** - * Return whether |this| may be modified. - */ - bool IsMutable() const { - return !mImmutable; - } - - /** - * Crash if |this| cannot be modified. - */ - void AssertMutable() const { - MOZ_ASSERT(IsMutable(), "someone forgot to call EnsureMutable"); - } - - /** - * Mark this declaration as unmodifiable. It's 'const' so it can - * be called from ToString. - */ - void SetImmutable() const { mImmutable = true; } - - /** - * Copy |this|, if necessary to ensure that it can be modified. - */ - inline already_AddRefed EnsureMutable(); - - void SetOwningRule(css::Rule* aRule) { - MOZ_ASSERT(!mContainer.mOwningRule || !aRule, - "should never overwrite one rule with another"); - mContainer.mOwningRule = aRule; - } - - css::Rule* GetOwningRule() const { - if (mContainer.mRaw & 0x1) { - return nullptr; - } - return mContainer.mOwningRule; - } - - void SetHTMLCSSStyleSheet(nsHTMLCSSStyleSheet* aHTMLCSSStyleSheet) { - MOZ_ASSERT(!mContainer.mHTMLCSSStyleSheet || !aHTMLCSSStyleSheet, - "should never overwrite one sheet with another"); - mContainer.mHTMLCSSStyleSheet = aHTMLCSSStyleSheet; - if (aHTMLCSSStyleSheet) { - mContainer.mRaw |= uintptr_t(1); - } - } - - nsHTMLCSSStyleSheet* GetHTMLCSSStyleSheet() const { - if (!(mContainer.mRaw & 0x1)) { - return nullptr; - } - auto c = mContainer; - c.mRaw &= ~uintptr_t(1); - return c.mHTMLCSSStyleSheet; - } - - inline void ToString(nsAString& aString) const; - - inline uint32_t Count() const; - inline bool GetNthProperty(uint32_t aIndex, nsAString& aReturn) const; - - inline void GetPropertyValue(const nsAString& aProperty, - nsAString& aValue) const; - inline void GetPropertyValueByID(nsCSSPropertyID aPropID, - nsAString& aValue) const; - inline void GetAuthoredPropertyValue(const nsAString& aProperty, - nsAString& aValue) const; - inline bool GetPropertyIsImportant(const nsAString& aProperty) const; - inline void RemoveProperty(const nsAString& aProperty); - inline void RemovePropertyByID(nsCSSPropertyID aProperty); - -private: - union { - // We only ever have one of these since we have an - // nsHTMLCSSStyleSheet only for style attributes, and style - // attributes never have an owning rule. - - // It's an nsHTMLCSSStyleSheet if the low bit is set. - - uintptr_t mRaw; - - // The style rule that owns this declaration. May be null. - css::Rule* mOwningRule; - - // The nsHTMLCSSStyleSheet that is responsible for this declaration. - // Only non-null for style attributes. - nsHTMLCSSStyleSheet* mHTMLCSSStyleSheet; - } mContainer; - - // set when declaration put in the rule tree; - // also by ToString (hence the 'mutable'). - mutable bool mImmutable; -}; - -} // namespace mozilla - -#endif // mozilla_DeclarationBlock_h diff --git a/layout/style/DeclarationBlockInlines.h b/layout/style/DeclarationBlockInlines.h deleted file mode 100644 index 17f7ddb5e0..0000000000 --- a/layout/style/DeclarationBlockInlines.h +++ /dev/null @@ -1,106 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef mozilla_DeclarationBlockInlines_h -#define mozilla_DeclarationBlockInlines_h - -#include "mozilla/css/Declaration.h" - -namespace mozilla { - -MOZ_DEFINE_DEPRECATED_METHODS(DeclarationBlock, css::Declaration) - -MozExternalRefCountType -DeclarationBlock::AddRef() -{ - return AsGecko()->AddRef(); -} - -MozExternalRefCountType -DeclarationBlock::Release() -{ - return AsGecko()->Release(); -} - -already_AddRefed -DeclarationBlock::Clone() const -{ - RefPtr result; - result = new css::Declaration(*AsGecko()); - return result.forget(); -} - -already_AddRefed -DeclarationBlock::EnsureMutable() -{ -#ifdef DEBUG - AsGecko()->AssertNotExpanded(); -#endif - if (!IsMutable()) { - return Clone(); - } - return do_AddRef(this); -} - -void -DeclarationBlock::ToString(nsAString& aString) const -{ - AsGecko()->ToString(aString); -} - -uint32_t -DeclarationBlock::Count() const -{ - return AsGecko()->Count(); -} - -bool -DeclarationBlock::GetNthProperty(uint32_t aIndex, nsAString& aReturn) const -{ - return AsGecko()->GetNthProperty(aIndex, aReturn); -} - -void -DeclarationBlock::GetPropertyValue(const nsAString& aProperty, - nsAString& aValue) const -{ - AsGecko()->GetPropertyValue(aProperty, aValue); -} - -void -DeclarationBlock::GetPropertyValueByID(nsCSSPropertyID aPropID, - nsAString& aValue) const -{ - AsGecko()->GetPropertyValueByID(aPropID, aValue); -} - -void -DeclarationBlock::GetAuthoredPropertyValue(const nsAString& aProperty, - nsAString& aValue) const -{ - AsGecko()->GetAuthoredPropertyValue(aProperty, aValue); -} - -bool -DeclarationBlock::GetPropertyIsImportant(const nsAString& aProperty) const -{ - return AsGecko()->GetPropertyIsImportant(aProperty); -} - -void -DeclarationBlock::RemoveProperty(const nsAString& aProperty) -{ - AsGecko()->RemoveProperty(aProperty); -} - -void -DeclarationBlock::RemovePropertyByID(nsCSSPropertyID aProperty) -{ - AsGecko()->RemovePropertyByID(aProperty); -} - -} // namespace mozilla - -#endif // mozilla_DeclarationBlockInlines_h diff --git a/layout/style/StyleRule.cpp b/layout/style/StyleRule.cpp index f7a267776d..5c3ec354d5 100644 --- a/layout/style/StyleRule.cpp +++ b/layout/style/StyleRule.cpp @@ -11,7 +11,6 @@ #include "mozilla/css/StyleRule.h" -#include "mozilla/DeclarationBlockInlines.h" #include "mozilla/StyleSheetInlines.h" #include "mozilla/MemoryReporting.h" #include "mozilla/css/GroupRule.h" @@ -1113,8 +1112,8 @@ public: NS_IMETHOD GetParentRule(nsIDOMCSSRule **aParent) override; void DropReference(void); - virtual DeclarationBlock* GetCSSDeclaration(Operation aOperation) override; - virtual nsresult SetCSSDeclaration(DeclarationBlock* aDecl) override; + virtual css::Declaration* GetCSSDeclaration(Operation aOperation) override; + virtual nsresult SetCSSDeclaration(css::Declaration* aDecl) override; virtual void GetCSSParsingEnvironment(CSSParsingEnvironment& aCSSParseEnv) override; virtual nsIDocument* DocToUpdate() override; @@ -1227,7 +1226,7 @@ DOMCSSDeclarationImpl::DropReference(void) mRule = nullptr; } -DeclarationBlock* +css::Declaration* DOMCSSDeclarationImpl::GetCSSDeclaration(Operation aOperation) { if (mRule) { @@ -1264,7 +1263,7 @@ DOMCSSDeclarationImpl::GetParentRule(nsIDOMCSSRule **aParent) } nsresult -DOMCSSDeclarationImpl::SetCSSDeclaration(DeclarationBlock* aDecl) +DOMCSSDeclarationImpl::SetCSSDeclaration(css::Declaration* aDecl) { NS_PRECONDITION(mRule, "can only be called when |GetCSSDeclaration| returned a declaration"); @@ -1277,7 +1276,7 @@ DOMCSSDeclarationImpl::SetCSSDeclaration(DeclarationBlock* aDecl) mozAutoDocUpdate updateBatch(doc, UPDATE_STYLE, true); - mRule->SetDeclaration(aDecl->AsGecko()); + mRule->SetDeclaration(aDecl); if (sheet) { sheet->DidDirty(); diff --git a/layout/style/moz.build b/layout/style/moz.build index 7595212966..9452ff15ce 100644 --- a/layout/style/moz.build +++ b/layout/style/moz.build @@ -79,8 +79,6 @@ EXPORTS.mozilla += [ 'CSSVariableDeclarations.h', 'CSSVariableResolver.h', 'CSSVariableValues.h', - 'DeclarationBlock.h', - 'DeclarationBlockInlines.h', 'DeprecatedUtils.h', 'HandleRefPtr.h', 'IncrementalClearCOMRuleArray.h', diff --git a/layout/style/nsCSSRules.cpp b/layout/style/nsCSSRules.cpp index dc79e471d8..1642516979 100644 --- a/layout/style/nsCSSRules.cpp +++ b/layout/style/nsCSSRules.cpp @@ -29,7 +29,7 @@ #include "nsContentUtils.h" #include "nsError.h" #include "nsStyleUtil.h" -#include "mozilla/DeclarationBlockInlines.h" +#include "mozilla/css/Declaration.h" #include "nsCSSParser.h" #include "nsDOMClassInfoID.h" #include "mozilla/dom/CSSStyleDeclarationBinding.h" @@ -1953,7 +1953,7 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsCSSKeyframeStyleDeclaration) NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY NS_INTERFACE_MAP_END_INHERITING(nsDOMCSSDeclaration) -DeclarationBlock* +css::Declaration* nsCSSKeyframeStyleDeclaration::GetCSSDeclaration(Operation aOperation) { if (mRule) { @@ -1979,10 +1979,10 @@ nsCSSKeyframeStyleDeclaration::GetParentRule(nsIDOMCSSRule **aParent) } nsresult -nsCSSKeyframeStyleDeclaration::SetCSSDeclaration(DeclarationBlock* aDecl) +nsCSSKeyframeStyleDeclaration::SetCSSDeclaration(css::Declaration* aDecl) { MOZ_ASSERT(aDecl, "must be non-null"); - mRule->ChangeDeclaration(aDecl->AsGecko()); + mRule->ChangeDeclaration(aDecl); return NS_OK; } @@ -2511,7 +2511,7 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsCSSPageStyleDeclaration) NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY NS_INTERFACE_MAP_END_INHERITING(nsDOMCSSDeclaration) -DeclarationBlock* +css::Declaration* nsCSSPageStyleDeclaration::GetCSSDeclaration(Operation aOperation) { if (mRule) { @@ -2537,10 +2537,10 @@ nsCSSPageStyleDeclaration::GetParentRule(nsIDOMCSSRule** aParent) } nsresult -nsCSSPageStyleDeclaration::SetCSSDeclaration(DeclarationBlock* aDecl) +nsCSSPageStyleDeclaration::SetCSSDeclaration(css::Declaration* aDecl) { MOZ_ASSERT(aDecl, "must be non-null"); - mRule->ChangeDeclaration(aDecl->AsGecko()); + mRule->ChangeDeclaration(aDecl); return NS_OK; } diff --git a/layout/style/nsCSSRules.h b/layout/style/nsCSSRules.h index 3e4eef039c..9c3196575c 100644 --- a/layout/style/nsCSSRules.h +++ b/layout/style/nsCSSRules.h @@ -360,8 +360,8 @@ public: NS_IMETHOD GetParentRule(nsIDOMCSSRule **aParent) override; void DropReference() { mRule = nullptr; } - virtual mozilla::DeclarationBlock* GetCSSDeclaration(Operation aOperation) override; - virtual nsresult SetCSSDeclaration(mozilla::DeclarationBlock* aDecl) override; + virtual mozilla::css::Declaration* GetCSSDeclaration(Operation aOperation) override; + virtual nsresult SetCSSDeclaration(mozilla::css::Declaration* aDecl) override; virtual void GetCSSParsingEnvironment(CSSParsingEnvironment& aCSSParseEnv) override; virtual nsIDocument* DocToUpdate() override; @@ -491,8 +491,8 @@ public: NS_IMETHOD GetParentRule(nsIDOMCSSRule **aParent) override; void DropReference() { mRule = nullptr; } - virtual mozilla::DeclarationBlock* GetCSSDeclaration(Operation aOperation) override; - virtual nsresult SetCSSDeclaration(mozilla::DeclarationBlock* aDecl) override; + virtual mozilla::css::Declaration* GetCSSDeclaration(Operation aOperation) override; + virtual nsresult SetCSSDeclaration(mozilla::css::Declaration* aDecl) override; virtual void GetCSSParsingEnvironment(CSSParsingEnvironment& aCSSParseEnv) override; virtual nsIDocument* DocToUpdate() override; diff --git a/layout/style/nsComputedDOMStyle.cpp b/layout/style/nsComputedDOMStyle.cpp index 191bffcfb5..006d8ffbba 100644 --- a/layout/style/nsComputedDOMStyle.cpp +++ b/layout/style/nsComputedDOMStyle.cpp @@ -578,7 +578,7 @@ nsComputedDOMStyle::GetPresShellForContent(nsIContent* aContent) // nsDOMCSSDeclaration abstract methods which should never be called // on a nsComputedDOMStyle object, but must be defined to avoid // compile errors. -DeclarationBlock* +mozilla::css::Declaration* nsComputedDOMStyle::GetCSSDeclaration(Operation) { NS_RUNTIMEABORT("called nsComputedDOMStyle::GetCSSDeclaration"); @@ -586,7 +586,7 @@ nsComputedDOMStyle::GetCSSDeclaration(Operation) } nsresult -nsComputedDOMStyle::SetCSSDeclaration(DeclarationBlock*) +nsComputedDOMStyle::SetCSSDeclaration(mozilla::css::Declaration*) { NS_RUNTIMEABORT("called nsComputedDOMStyle::SetCSSDeclaration"); return NS_ERROR_FAILURE; diff --git a/layout/style/nsComputedDOMStyle.h b/layout/style/nsComputedDOMStyle.h index 363de2a8fe..996f8ffc42 100644 --- a/layout/style/nsComputedDOMStyle.h +++ b/layout/style/nsComputedDOMStyle.h @@ -113,8 +113,8 @@ public: // nsDOMCSSDeclaration abstract methods which should never be called // on a nsComputedDOMStyle object, but must be defined to avoid // compile errors. - virtual mozilla::DeclarationBlock* GetCSSDeclaration(Operation) override; - virtual nsresult SetCSSDeclaration(mozilla::DeclarationBlock*) override; + virtual mozilla::css::Declaration* GetCSSDeclaration(Operation) override; + virtual nsresult SetCSSDeclaration(mozilla::css::Declaration*) override; virtual nsIDocument* DocToUpdate() override; virtual void GetCSSParsingEnvironment(CSSParsingEnvironment& aCSSParseEnv) override; diff --git a/layout/style/nsDOMCSSAttrDeclaration.cpp b/layout/style/nsDOMCSSAttrDeclaration.cpp index f2117dc0df..7b68990333 100644 --- a/layout/style/nsDOMCSSAttrDeclaration.cpp +++ b/layout/style/nsDOMCSSAttrDeclaration.cpp @@ -19,7 +19,6 @@ #include "nsIFrame.h" #include "ActiveLayerTracker.h" #include "StyleSetHandle.h" -#include "DeclarationBlockInlines.h" using namespace mozilla; using namespace mozilla::dom; @@ -73,7 +72,7 @@ NS_IMPL_CYCLE_COLLECTING_ADDREF(nsDOMCSSAttributeDeclaration) NS_IMPL_CYCLE_COLLECTING_RELEASE(nsDOMCSSAttributeDeclaration) nsresult -nsDOMCSSAttributeDeclaration::SetCSSDeclaration(DeclarationBlock* aDecl) +nsDOMCSSAttributeDeclaration::SetCSSDeclaration(css::Declaration* aDecl) { NS_ASSERTION(mElement, "Must have Element to set the declaration!"); return mIsSMILOverride @@ -89,13 +88,13 @@ nsDOMCSSAttributeDeclaration::DocToUpdate() return mElement->OwnerDoc(); } -DeclarationBlock* +css::Declaration* nsDOMCSSAttributeDeclaration::GetCSSDeclaration(Operation aOperation) { if (!mElement) return nullptr; - DeclarationBlock* declaration; + css::Declaration* declaration; if (mIsSMILOverride) { declaration = mElement->GetSMILOverrideStyleDeclaration(); } else { @@ -132,9 +131,9 @@ nsDOMCSSAttributeDeclaration::GetCSSDeclaration(Operation aOperation) } // cannot fail - RefPtr decl; + RefPtr decl; decl = new css::Declaration(); - decl->AsGecko()->InitializeEmpty(); + decl->InitializeEmpty(); // this *can* fail (inside SetAttrAndNotify, at least). nsresult rv; diff --git a/layout/style/nsDOMCSSAttrDeclaration.h b/layout/style/nsDOMCSSAttrDeclaration.h index 482d665ea7..e10f99fc4c 100644 --- a/layout/style/nsDOMCSSAttrDeclaration.h +++ b/layout/style/nsDOMCSSAttrDeclaration.h @@ -30,7 +30,7 @@ public: // If GetCSSDeclaration returns non-null, then the decl it returns // is owned by our current style rule. - virtual mozilla::DeclarationBlock* GetCSSDeclaration(Operation aOperation) override; + virtual mozilla::css::Declaration* GetCSSDeclaration(Operation aOperation) override; virtual void GetCSSParsingEnvironment(CSSParsingEnvironment& aCSSParseEnv) override; NS_IMETHOD GetParentRule(nsIDOMCSSRule **aParent) override; @@ -44,7 +44,7 @@ public: protected: ~nsDOMCSSAttributeDeclaration(); - virtual nsresult SetCSSDeclaration(mozilla::DeclarationBlock* aDecl) override; + virtual nsresult SetCSSDeclaration(mozilla::css::Declaration* aDecl) override; virtual nsIDocument* DocToUpdate() override; RefPtr mElement; diff --git a/layout/style/nsDOMCSSDeclaration.cpp b/layout/style/nsDOMCSSDeclaration.cpp index 26faa16d4c..25af0275b7 100644 --- a/layout/style/nsDOMCSSDeclaration.cpp +++ b/layout/style/nsDOMCSSDeclaration.cpp @@ -8,10 +8,9 @@ #include "nsDOMCSSDeclaration.h" #include "nsCSSParser.h" -#include "mozilla/DeclarationBlockInlines.h" #include "mozilla/StyleSheetInlines.h" #include "mozilla/css/Rule.h" -#include "mozilla/DeclarationBlockInlines.h" +#include "mozilla/css/Declaration.h" #include "mozilla/dom/CSS2PropertiesBinding.h" #include "nsCSSProps.h" #include "nsCOMPtr.h" @@ -49,7 +48,7 @@ nsDOMCSSDeclaration::GetPropertyValue(const nsCSSPropertyID aPropID, "Should never pass eCSSProperty_UNKNOWN around"); aValue.Truncate(); - if (DeclarationBlock* decl = GetCSSDeclaration(eOperation_Read)) { + if (css::Declaration* decl = GetCSSDeclaration(eOperation_Read)) { decl->GetPropertyValueByID(aPropID, aValue); } return NS_OK; @@ -97,7 +96,7 @@ nsDOMCSSDeclaration::SetPropertyValue(const nsCSSPropertyID aPropID, NS_IMETHODIMP nsDOMCSSDeclaration::GetCssText(nsAString& aCssText) { - DeclarationBlock* decl = GetCSSDeclaration(eOperation_Read); + css::Declaration* decl = GetCSSDeclaration(eOperation_Read); aCssText.Truncate(); if (decl) { @@ -112,7 +111,7 @@ nsDOMCSSDeclaration::SetCssText(const nsAString& aCssText) { // We don't need to *do* anything with the old declaration, but we need // to ensure that it exists, or else SetCSSDeclaration may crash. - DeclarationBlock* olddecl = GetCSSDeclaration(eOperation_Modify); + css::Declaration* olddecl = GetCSSDeclaration(eOperation_Modify); if (!olddecl) { return NS_ERROR_NOT_AVAILABLE; } @@ -130,7 +129,7 @@ nsDOMCSSDeclaration::SetCssText(const nsAString& aCssText) // rule (see stack in bug 209575). mozAutoDocConditionalContentUpdateBatch autoUpdate(DocToUpdate(), true); - RefPtr newdecl; + RefPtr newdecl; RefPtr decl(new css::Declaration()); decl->InitializeEmpty(); nsCSSParser cssParser(env.mCSSLoader); @@ -149,7 +148,7 @@ nsDOMCSSDeclaration::SetCssText(const nsAString& aCssText) NS_IMETHODIMP nsDOMCSSDeclaration::GetLength(uint32_t* aLength) { - DeclarationBlock* decl = GetCSSDeclaration(eOperation_Read); + css::Declaration* decl = GetCSSDeclaration(eOperation_Read); if (decl) { *aLength = decl->Count(); @@ -171,7 +170,7 @@ nsDOMCSSDeclaration::GetPropertyCSSValue(const nsAString& aPropertyName, ErrorRe void nsDOMCSSDeclaration::IndexedGetter(uint32_t aIndex, bool& aFound, nsAString& aPropName) { - DeclarationBlock* decl = GetCSSDeclaration(eOperation_Read); + css::Declaration* decl = GetCSSDeclaration(eOperation_Read); aFound = decl && decl->GetNthProperty(aIndex, aPropName); } @@ -180,7 +179,7 @@ nsDOMCSSDeclaration::GetPropertyValue(const nsAString& aPropertyName, nsAString& aReturn) { aReturn.Truncate(); - if (DeclarationBlock* decl = GetCSSDeclaration(eOperation_Read)) { + if (css::Declaration* decl = GetCSSDeclaration(eOperation_Read)) { decl->GetPropertyValue(aPropertyName, aReturn); } return NS_OK; @@ -190,7 +189,7 @@ NS_IMETHODIMP nsDOMCSSDeclaration::GetAuthoredPropertyValue(const nsAString& aPropertyName, nsAString& aReturn) { - if (DeclarationBlock* decl = GetCSSDeclaration(eOperation_Read)) { + if (css::Declaration* decl = GetCSSDeclaration(eOperation_Read)) { decl->GetAuthoredPropertyValue(aPropertyName, aReturn); } return NS_OK; @@ -200,7 +199,7 @@ NS_IMETHODIMP nsDOMCSSDeclaration::GetPropertyPriority(const nsAString& aPropertyName, nsAString& aReturn) { - DeclarationBlock* decl = GetCSSDeclaration(eOperation_Read); + css::Declaration* decl = GetCSSDeclaration(eOperation_Read); aReturn.Truncate(); if (decl && decl->GetPropertyIsImportant(aPropertyName)) { @@ -276,7 +275,7 @@ nsDOMCSSDeclaration::ParsePropertyValue(const nsCSSPropertyID aPropID, const nsAString& aPropValue, bool aIsImportant) { - DeclarationBlock* olddecl = GetCSSDeclaration(eOperation_Modify); + css::Declaration* olddecl = GetCSSDeclaration(eOperation_Modify); if (!olddecl) { return NS_ERROR_NOT_AVAILABLE; } @@ -293,13 +292,13 @@ nsDOMCSSDeclaration::ParsePropertyValue(const nsCSSPropertyID aPropID, // between when we mutate the declaration and when we set the new // rule (see stack in bug 209575). mozAutoDocConditionalContentUpdateBatch autoUpdate(DocToUpdate(), true); - RefPtr decl = olddecl->EnsureMutable(); + RefPtr decl = olddecl->EnsureMutable(); bool changed; nsCSSParser cssParser(env.mCSSLoader); cssParser.ParseProperty(aPropID, aPropValue, env.mSheetURI, env.mBaseURI, env.mPrincipal, - decl->AsGecko(), &changed, aIsImportant); + decl, &changed, aIsImportant); if (!changed) { // Parsing failed -- but we don't throw an exception for that. return NS_OK; @@ -315,7 +314,7 @@ nsDOMCSSDeclaration::ParseCustomPropertyValue(const nsAString& aPropertyName, { MOZ_ASSERT(nsCSSProps::IsCustomPropertyName(aPropertyName)); - DeclarationBlock* olddecl = GetCSSDeclaration(eOperation_Modify); + css::Declaration* olddecl = GetCSSDeclaration(eOperation_Modify); if (!olddecl) { return NS_ERROR_NOT_AVAILABLE; } @@ -332,13 +331,13 @@ nsDOMCSSDeclaration::ParseCustomPropertyValue(const nsAString& aPropertyName, // between when we mutate the declaration and when we set the new // rule (see stack in bug 209575). mozAutoDocConditionalContentUpdateBatch autoUpdate(DocToUpdate(), true); - RefPtr decl = olddecl->EnsureMutable(); + RefPtr decl = olddecl->EnsureMutable(); bool changed; auto propName = Substring(aPropertyName, CSS_CUSTOM_NAME_PREFIX_LENGTH); nsCSSParser cssParser(env.mCSSLoader); cssParser.ParseVariable(propName, aPropValue, env.mSheetURI, - env.mBaseURI, env.mPrincipal, decl->AsGecko(), + env.mBaseURI, env.mPrincipal, decl, &changed, aIsImportant); if (!changed) { // Parsing failed -- but we don't throw an exception for that. @@ -351,7 +350,7 @@ nsDOMCSSDeclaration::ParseCustomPropertyValue(const nsAString& aPropertyName, nsresult nsDOMCSSDeclaration::RemovePropertyInternal(nsCSSPropertyID aPropID) { - DeclarationBlock* olddecl = GetCSSDeclaration(eOperation_RemoveProperty); + css::Declaration* olddecl = GetCSSDeclaration(eOperation_RemoveProperty); if (!olddecl) { return NS_OK; // no decl, so nothing to remove } @@ -363,7 +362,7 @@ nsDOMCSSDeclaration::RemovePropertyInternal(nsCSSPropertyID aPropID) // rule (see stack in bug 209575). mozAutoDocConditionalContentUpdateBatch autoUpdate(DocToUpdate(), true); - RefPtr decl = olddecl->EnsureMutable(); + RefPtr decl = olddecl->EnsureMutable(); decl->RemovePropertyByID(aPropID); return SetCSSDeclaration(decl); } @@ -371,7 +370,7 @@ nsDOMCSSDeclaration::RemovePropertyInternal(nsCSSPropertyID aPropID) nsresult nsDOMCSSDeclaration::RemovePropertyInternal(const nsAString& aPropertyName) { - DeclarationBlock* olddecl = GetCSSDeclaration(eOperation_RemoveProperty); + css::Declaration* olddecl = GetCSSDeclaration(eOperation_RemoveProperty); if (!olddecl) { return NS_OK; // no decl, so nothing to remove } @@ -383,7 +382,7 @@ nsDOMCSSDeclaration::RemovePropertyInternal(const nsAString& aPropertyName) // rule (see stack in bug 209575). mozAutoDocConditionalContentUpdateBatch autoUpdate(DocToUpdate(), true); - RefPtr decl = olddecl->EnsureMutable(); + RefPtr decl = olddecl->EnsureMutable(); decl->RemoveProperty(aPropertyName); return SetCSSDeclaration(decl); } diff --git a/layout/style/nsDOMCSSDeclaration.h b/layout/style/nsDOMCSSDeclaration.h index 5b2308e4af..c0b296709d 100644 --- a/layout/style/nsDOMCSSDeclaration.h +++ b/layout/style/nsDOMCSSDeclaration.h @@ -20,10 +20,10 @@ struct JSContext; class JSObject; namespace mozilla { -class DeclarationBlock; namespace css { class Loader; class Rule; +class Declaration; } // namespace css } // namespace mozilla @@ -119,8 +119,8 @@ protected: // AttributeWillChange. eOperation_RemoveProperty }; - virtual mozilla::DeclarationBlock* GetCSSDeclaration(Operation aOperation) = 0; - virtual nsresult SetCSSDeclaration(mozilla::DeclarationBlock* aDecl) = 0; + virtual mozilla::css::Declaration* GetCSSDeclaration(Operation aOperation) = 0; + virtual nsresult SetCSSDeclaration(mozilla::css::Declaration* aDecl) = 0; // Document that we must call BeginUpdate/EndUpdate on around the // calls to SetCSSDeclaration and the style rule mutation that leads // to it. diff --git a/layout/style/nsHTMLCSSStyleSheet.cpp b/layout/style/nsHTMLCSSStyleSheet.cpp index efe14c120e..4f68e6741b 100644 --- a/layout/style/nsHTMLCSSStyleSheet.cpp +++ b/layout/style/nsHTMLCSSStyleSheet.cpp @@ -10,7 +10,7 @@ #include "nsHTMLCSSStyleSheet.h" #include "mozilla/MemoryReporting.h" #include "mozilla/css/StyleRule.h" -#include "mozilla/DeclarationBlockInlines.h" +#include "mozilla/css/Declaration.h" #include "nsIStyleRuleProcessor.h" #include "nsPresContext.h" #include "nsRuleWalker.h" @@ -39,7 +39,7 @@ nsHTMLCSSStyleSheet::~nsHTMLCSSStyleSheet() // Ideally we'd just call MiscContainer::Evict, but we can't do that since // we're iterating the hashtable. if (value->mType == nsAttrValue::eCSSDeclaration) { - DeclarationBlock* declaration = value->mValue.mCSSDeclaration; + css::Declaration* declaration = value->mValue.mCSSDeclaration; declaration->SetHTMLCSSStyleSheet(nullptr); } else { MOZ_ASSERT_UNREACHABLE("unexpected cached nsAttrValue type"); @@ -65,10 +65,10 @@ nsHTMLCSSStyleSheet::ElementRulesMatching(nsPresContext* aPresContext, nsRuleWalker* aRuleWalker) { // just get the one and only style rule from the content's STYLE attribute - DeclarationBlock* declaration = aElement->GetInlineStyleDeclaration(); + css::Declaration* declaration = aElement->GetInlineStyleDeclaration(); if (declaration) { declaration->SetImmutable(); - aRuleWalker->Forward(declaration->AsGecko()); + aRuleWalker->Forward(declaration); } declaration = aElement->GetSMILOverrideStyleDeclaration(); @@ -78,7 +78,7 @@ nsHTMLCSSStyleSheet::ElementRulesMatching(nsPresContext* aPresContext, // Animation restyle (or non-restyle traversal of rules) // Now we can walk SMIL overrride style, without triggering transitions. declaration->SetImmutable(); - aRuleWalker->Forward(declaration->AsGecko()); + aRuleWalker->Forward(declaration); } } } @@ -94,10 +94,10 @@ nsHTMLCSSStyleSheet::PseudoElementRulesMatching(Element* aPseudoElement, MOZ_ASSERT(aPseudoElement); // just get the one and only style rule from the content's STYLE attribute - DeclarationBlock* declaration = aPseudoElement->GetInlineStyleDeclaration(); + css::Declaration* declaration = aPseudoElement->GetInlineStyleDeclaration(); if (declaration) { declaration->SetImmutable(); - aRuleWalker->Forward(declaration->AsGecko()); + aRuleWalker->Forward(declaration); } }