Bug 1464496 - Part 1: Merge ServoDeclarationBlock and DeclarationBlock r=emilio

MozReview-Commit-ID: By9fV70Oq0K
This commit is contained in:
Nazım Can Altınova
2018-05-30 18:15:25 +02:00
parent 49a95db590
commit 4e99e486f8
31 changed files with 148 additions and 292 deletions

View File

@@ -59,7 +59,7 @@
#include "mozilla/AnimationComparator.h"
#include "mozilla/AsyncEventDispatcher.h"
#include "mozilla/ContentEvents.h"
#include "mozilla/DeclarationBlockInlines.h"
#include "mozilla/DeclarationBlock.h"
#include "mozilla/EffectSet.h"
#include "mozilla/EventDispatcher.h"
#include "mozilla/EventListenerManager.h"

View File

@@ -16,7 +16,7 @@
#include "mozilla/dom/FragmentOrElement.h"
#include "mozilla/AsyncEventDispatcher.h"
#include "mozilla/DeclarationBlockInlines.h"
#include "mozilla/DeclarationBlock.h"
#include "mozilla/EffectSet.h"
#include "mozilla/EventDispatcher.h"
#include "mozilla/EventListenerManager.h"

View File

@@ -20,7 +20,7 @@
#include "mozilla/MemoryReporting.h"
#include "mozilla/ServoBindingTypes.h"
#include "mozilla/ServoUtils.h"
#include "mozilla/DeclarationBlockInlines.h"
#include "mozilla/DeclarationBlock.h"
#include "nsContentUtils.h"
#include "nsReadableUtils.h"
#include "nsHTMLCSSStyleSheet.h"
@@ -1701,7 +1701,7 @@ nsAttrValue::ParseStyleAttribute(const nsAString& aString,
RefPtr<URLExtraData> data = new URLExtraData(baseURI, docURI,
principal);
RefPtr<DeclarationBlock> decl = ServoDeclarationBlock::
RefPtr<DeclarationBlock> decl = DeclarationBlock::
FromCssText(aString, data,
ownerDoc->GetCompatibilityMode(),
ownerDoc->CSSLoader());
@@ -1949,7 +1949,7 @@ nsAttrValue::SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const
if (Type() == eCSSDeclaration && container->mValue.mCSSDeclaration) {
// TODO: mCSSDeclaration might be owned by another object which
// would make us count them twice, bug 677493.
// Bug 1281964: For ServoDeclarationBlock if we do measure we'll
// Bug 1281964: For DeclarationBlock if we do measure we'll
// need a way to call the Servo heap_size_of function.
//n += container->mCSSDeclaration->SizeOfIncludingThis(aMallocSizeOf);
} else if (Type() == eAtomArray && container->mValue.mAtomArray) {

View File

@@ -11,10 +11,10 @@
#include "nsMappedAttributes.h"
#include "nsHTMLStyleSheet.h"
#include "mozilla/DeclarationBlock.h"
#include "mozilla/GenericSpecifiedValues.h"
#include "mozilla/HashFunctions.h"
#include "mozilla/MemoryReporting.h"
#include "mozilla/ServoDeclarationBlock.h"
#include "mozilla/ServoSpecifiedValues.h"
using namespace mozilla;
@@ -54,7 +54,7 @@ nsMappedAttributes::nsMappedAttributes(const nsMappedAttributes& aCopy)
mSheet(aCopy.mSheet),
mRuleMapper(aCopy.mRuleMapper),
// This is only called by ::Clone, which is used to create independent
// nsMappedAttributes objects which should not share a ServoDeclarationBlock
// nsMappedAttributes objects which should not share a DeclarationBlock
mServoStyle(nullptr)
{
NS_ASSERTION(mBufferSize >= aCopy.mAttrCount, "can't fit attributes");

View File

@@ -17,7 +17,7 @@
#include "nsDOMCSSAttrDeclaration.h"
#include "nsServiceManagerUtils.h"
#include "nsIDocument.h"
#include "mozilla/DeclarationBlockInlines.h"
#include "mozilla/DeclarationBlock.h"
#include "mozilla/css/Loader.h"
#include "nsXULElement.h"
#include "nsContentUtils.h"

View File

@@ -9,8 +9,6 @@
#include "mozilla/ArrayUtils.h"
#include "mozilla/BindingStyleRule.h"
#include "mozilla/DeclarationBlock.h"
#include "mozilla/DeclarationBlockInlines.h"
#include "mozilla/ServoDeclarationBlock.h"
#include "mozilla/StyleSheetInlines.h"
#include "mozilla/css/Rule.h"
#include "mozilla/dom/CSSRuleList.h"
@@ -1176,7 +1174,7 @@ nsTreeSanitizer::SanitizeAttributes(mozilla::dom::Element* aElement,
nsIDocument* document = aElement->OwnerDoc();
RefPtr<URLExtraData> urlExtra(aElement->GetURLDataForStyleAttr());
RefPtr<DeclarationBlock> decl =
ServoDeclarationBlock::FromCssText(
DeclarationBlock::FromCssText(
value,
urlExtra,
document->GetCompatibilityMode(),

View File

@@ -5,7 +5,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "mozilla/ArrayUtils.h"
#include "mozilla/DeclarationBlockInlines.h"
#include "mozilla/DeclarationBlock.h"
#include "mozilla/EventDispatcher.h"
#include "mozilla/EventListenerManager.h"
#include "mozilla/EventStateManager.h"

View File

@@ -16,9 +16,8 @@
#include "nsCSSValue.h"
#include "nsColor.h"
#include "nsPresContext.h"
#include "mozilla/DeclarationBlockInlines.h"
#include "mozilla/DeclarationBlock.h"
#include "mozilla/ServoBindings.h"
#include "mozilla/ServoDeclarationBlock.h"
#include "mozilla/StyleAnimationValue.h" // For AnimationValue
#include "mozilla/ServoCSSParser.h"
#include "mozilla/ServoStyleSet.h"
@@ -594,7 +593,7 @@ nsSMILCSSValueType::SetPropertyValues(const nsSMILValue& aValue,
for (const auto& value : wrapper->mServoValues) {
changed |=
Servo_DeclarationBlock_SetPropertyToAnimationValue(
aDecl.AsServo()->Raw(), value);
aDecl.Raw(), value);
}
return changed;

View File

@@ -53,7 +53,6 @@
#include "mozilla/dom/MutationEventBinding.h"
#include "mozilla/dom/SVGElementBinding.h"
#include "mozilla/DeclarationBlock.h"
#include "mozilla/DeclarationBlockInlines.h"
#include "mozilla/Unused.h"
#include "mozilla/RestyleManager.h"
@@ -1188,7 +1187,7 @@ MappedAttrParser::ParseMappedAttrValue(nsAtom* aMappedAttrName,
const nsAString& aMappedAttrValue)
{
if (!mDecl) {
mDecl = new ServoDeclarationBlock();
mDecl = new DeclarationBlock();
}
// Get the nsCSSPropertyID ID for our mapped attribute.
@@ -1202,7 +1201,7 @@ MappedAttrParser::ParseMappedAttrValue(nsAtom* aMappedAttrName,
RefPtr<URLExtraData> data = new URLExtraData(mBaseURI, mDocURI,
mElement->NodePrincipal());
changed = Servo_DeclarationBlock_SetPropertyById(
mDecl->AsServo()->Raw(), propertyID, &value, false, data,
mDecl->Raw(), propertyID, &value, false, data,
ParsingMode::AllowUnitlessLength, mElement->OwnerDoc()->GetCompatibilityMode(), mLoader);
if (changed) {
@@ -1231,7 +1230,7 @@ MappedAttrParser::ParseMappedAttrValue(nsAtom* aMappedAttrName,
if (aMappedAttrName == nsGkAtoms::lang) {
propertyID = eCSSProperty__x_lang;
RefPtr<nsAtom> atom = NS_Atomize(aMappedAttrValue);
Servo_DeclarationBlock_SetIdentStringValue(mDecl->AsServo()->Raw(), propertyID, atom);
Servo_DeclarationBlock_SetIdentStringValue(mDecl->Raw(), propertyID, atom);
}
}

View File

@@ -18,7 +18,7 @@
#include "mozilla/EventListenerManager.h"
#include "mozilla/EventStateManager.h"
#include "mozilla/EventStates.h"
#include "mozilla/DeclarationBlockInlines.h"
#include "mozilla/DeclarationBlock.h"
#include "nsFocusManager.h"
#include "nsHTMLStyleSheet.h"
#include "nsNameSpaceManager.h"
@@ -2323,7 +2323,7 @@ nsXULPrototypeElement::SetAttrAt(uint32_t aPos, const nsAString& aValue,
RefPtr<URLExtraData> data =
new URLExtraData(aDocumentURI, aDocumentURI, principal);
RefPtr<DeclarationBlock> declaration =
ServoDeclarationBlock::FromCssText(
DeclarationBlock::FromCssText(
aValue, data, eCompatibility_FullStandards, nullptr);
if (declaration) {
mAttributes[aPos].mValue.SetTo(declaration.forget(), &aValue);

View File

@@ -9,7 +9,7 @@
#include "mozilla/ChangeStyleTransaction.h"
#include "mozilla/HTMLEditor.h"
#include "mozilla/Preferences.h"
#include "mozilla/DeclarationBlockInlines.h"
#include "mozilla/DeclarationBlock.h"
#include "mozilla/dom/Element.h"
#include "mozilla/mozalloc.h"
#include "nsAString.h"

View File

@@ -4,7 +4,7 @@
* 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/. */
#include "mozilla/ServoDeclarationBlock.h"
#include "mozilla/DeclarationBlock.h"
#include "mozilla/ServoBindings.h"
@@ -12,44 +12,44 @@
namespace mozilla {
/* static */ already_AddRefed<ServoDeclarationBlock>
ServoDeclarationBlock::FromCssText(const nsAString& aCssText,
URLExtraData* aExtraData,
nsCompatibility aMode,
css::Loader* aLoader)
/* static */ already_AddRefed<DeclarationBlock>
DeclarationBlock::FromCssText(const nsAString& aCssText,
URLExtraData* aExtraData,
nsCompatibility aMode,
css::Loader* aLoader)
{
NS_ConvertUTF16toUTF8 value(aCssText);
// FIXME (bug 1343964): Figure out a better solution for sending the base uri to servo
RefPtr<RawServoDeclarationBlock>
raw = Servo_ParseStyleAttribute(&value, aExtraData, aMode, aLoader).Consume();
RefPtr<ServoDeclarationBlock> decl = new ServoDeclarationBlock(raw.forget());
RefPtr<DeclarationBlock> decl = new DeclarationBlock(raw.forget());
return decl.forget();
}
// TODO: We can make them inline.
void
ServoDeclarationBlock::GetPropertyValue(const nsAString& aProperty,
nsAString& aValue) const
DeclarationBlock::GetPropertyValue(const nsAString& aProperty,
nsAString& aValue) const
{
NS_ConvertUTF16toUTF8 property(aProperty);
Servo_DeclarationBlock_GetPropertyValue(mRaw, &property, &aValue);
}
void
ServoDeclarationBlock::GetPropertyValueByID(nsCSSPropertyID aPropID,
nsAString& aValue) const
DeclarationBlock::GetPropertyValueByID(nsCSSPropertyID aPropID,
nsAString& aValue) const
{
Servo_DeclarationBlock_GetPropertyValueById(mRaw, aPropID, &aValue);
}
bool
ServoDeclarationBlock::GetPropertyIsImportant(const nsAString& aProperty) const
DeclarationBlock::GetPropertyIsImportant(const nsAString& aProperty) const
{
NS_ConvertUTF16toUTF8 property(aProperty);
return Servo_DeclarationBlock_GetPropertyIsImportant(mRaw, &property);
}
bool
ServoDeclarationBlock::RemoveProperty(const nsAString& aProperty)
DeclarationBlock::RemoveProperty(const nsAString& aProperty)
{
AssertMutable();
NS_ConvertUTF16toUTF8 property(aProperty);
@@ -57,7 +57,7 @@ ServoDeclarationBlock::RemoveProperty(const nsAString& aProperty)
}
bool
ServoDeclarationBlock::RemovePropertyByID(nsCSSPropertyID aPropID)
DeclarationBlock::RemovePropertyByID(nsCSSPropertyID aPropID)
{
AssertMutable();
return Servo_DeclarationBlock_RemovePropertyById(mRaw, aPropID);

View File

@@ -13,7 +13,7 @@
#define mozilla_DeclarationBlock_h
#include "mozilla/Atomics.h"
#include "mozilla/ServoUtils.h"
#include "mozilla/ServoBindings.h"
#include "nsCSSPropertyID.h"
@@ -21,33 +21,40 @@ class nsHTMLCSSStyleSheet;
namespace mozilla {
class ServoDeclarationBlock;
namespace css {
class Declaration;
class Rule;
} // namespace css
class DeclarationBlock
class DeclarationBlock final
{
protected:
DeclarationBlock()
public:
explicit DeclarationBlock(
already_AddRefed<RawServoDeclarationBlock> aRaw)
: mImmutable(false)
, mIsDirty(false)
, mRaw(aRaw)
{
mContainer.mRaw = 0;
}
DeclarationBlock()
: DeclarationBlock(Servo_DeclarationBlock_CreateEmpty().Consume()) {}
DeclarationBlock(const DeclarationBlock& aCopy)
: DeclarationBlock() {}
: mImmutable(false)
, mIsDirty(false)
, mRaw(Servo_DeclarationBlock_Clone(aCopy.mRaw).Consume())
{
mContainer.mRaw = 0;
}
public:
MOZ_DECL_STYLO_METHODS(css::Declaration, ServoDeclarationBlock)
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(DeclarationBlock)
inline MozExternalRefCountType AddRef();
inline MozExternalRefCountType Release();
inline already_AddRefed<DeclarationBlock> Clone() const;
inline already_AddRefed<DeclarationBlock> Clone() const
{
return do_AddRef(new DeclarationBlock(*this));
}
/**
* Return whether |this| may be modified.
@@ -87,7 +94,23 @@ public:
/**
* Copy |this|, if necessary to ensure that it can be modified.
*/
inline already_AddRefed<DeclarationBlock> EnsureMutable();
inline already_AddRefed<DeclarationBlock>
EnsureMutable()
{
if (!IsDirty()) {
// In stylo, the old DeclarationBlock is stored in element's rule node tree
// directly, to avoid new values replacing the DeclarationBlock in the tree
// directly, we need to copy the old one here if we haven't yet copied.
// As a result the new value does not replace rule node tree until traversal
// happens.
return Clone();
}
if (!IsMutable()) {
return Clone();
}
return do_AddRef(this);
}
void SetOwningRule(css::Rule* aRule) {
MOZ_ASSERT(!mContainer.mOwningRule || !aRule,
@@ -120,22 +143,55 @@ public:
return c.mHTMLCSSStyleSheet;
}
inline void ToString(nsAString& aString) const;
static already_AddRefed<DeclarationBlock>
FromCssText(const nsAString& aCssText, URLExtraData* aExtraData,
nsCompatibility aMode, css::Loader* aLoader);
inline uint32_t Count() const;
inline bool GetNthProperty(uint32_t aIndex, nsAString& aReturn) const;
RawServoDeclarationBlock* Raw() const { return mRaw; }
RawServoDeclarationBlock* const* RefRaw() const
{
static_assert(sizeof(RefPtr<RawServoDeclarationBlock>) ==
sizeof(RawServoDeclarationBlock*),
"RefPtr should just be a pointer");
return reinterpret_cast<RawServoDeclarationBlock* const*>(&mRaw);
}
inline void GetPropertyValue(const nsAString& aProperty,
nsAString& aValue) const;
inline void GetPropertyValueByID(nsCSSPropertyID aPropID,
nsAString& aValue) const;
inline bool GetPropertyIsImportant(const nsAString& aProperty) const;
const RawServoDeclarationBlockStrong* RefRawStrong() const
{
static_assert(sizeof(RefPtr<RawServoDeclarationBlock>) ==
sizeof(RawServoDeclarationBlock*),
"RefPtr should just be a pointer");
static_assert(sizeof(RefPtr<RawServoDeclarationBlock>) ==
sizeof(RawServoDeclarationBlockStrong),
"RawServoDeclarationBlockStrong should be the same as RefPtr");
return reinterpret_cast<const RawServoDeclarationBlockStrong*>(&mRaw);
}
void ToString(nsAString& aResult) const {
Servo_DeclarationBlock_GetCssText(mRaw, &aResult);
}
uint32_t Count() const {
return Servo_DeclarationBlock_Count(mRaw);
}
bool GetNthProperty(uint32_t aIndex, nsAString& aReturn) const {
aReturn.Truncate();
return Servo_DeclarationBlock_GetNthProperty(mRaw, aIndex, &aReturn);
}
void GetPropertyValue(const nsAString& aProperty,
nsAString& aValue) const;
void GetPropertyValueByID(nsCSSPropertyID aPropID,
nsAString& aValue) const;
bool GetPropertyIsImportant(const nsAString& aProperty) const;
// Returns whether the property was removed.
inline bool RemoveProperty(const nsAString& aProperty);
bool RemoveProperty(const nsAString& aProperty);
// Returns whether the property was removed.
inline bool RemovePropertyByID(nsCSSPropertyID aProperty);
bool RemovePropertyByID(nsCSSPropertyID aProperty);
private:
~DeclarationBlock() = default;
union {
// We only ever have one of these since we have an
// nsHTMLCSSStyleSheet only for style attributes, and style
@@ -168,6 +224,8 @@ private:
// reference, and there is no problem with another user of the same
// DeclarationBlock thinking that it is not dirty.
Atomic<bool, MemoryOrdering::Relaxed> mIsDirty;
RefPtr<RawServoDeclarationBlock> mRaw;
};
} // namespace mozilla

View File

@@ -1,104 +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_DeclarationBlockInlines_h
#define mozilla_DeclarationBlockInlines_h
#include "mozilla/ServoDeclarationBlock.h"
namespace mozilla {
MOZ_DEFINE_STYLO_METHODS(DeclarationBlock, css::Declaration, ServoDeclarationBlock)
MozExternalRefCountType
DeclarationBlock::AddRef()
{
MOZ_STYLO_FORWARD(AddRef, ())
}
MozExternalRefCountType
DeclarationBlock::Release()
{
MOZ_STYLO_FORWARD(Release, ())
}
already_AddRefed<DeclarationBlock>
DeclarationBlock::Clone() const
{
return do_AddRef(new ServoDeclarationBlock(*AsServo()));
}
already_AddRefed<DeclarationBlock>
DeclarationBlock::EnsureMutable()
{
if (!IsDirty()) {
// In stylo, the old DeclarationBlock is stored in element's rule node tree
// directly, to avoid new values replacing the DeclarationBlock in the tree
// directly, we need to copy the old one here if we haven't yet copied.
// As a result the new value does not replace rule node tree until traversal
// happens.
return Clone();
}
if (!IsMutable()) {
return Clone();
}
return do_AddRef(this);
}
void
DeclarationBlock::ToString(nsAString& aString) const
{
MOZ_STYLO_FORWARD(ToString, (aString))
}
uint32_t
DeclarationBlock::Count() const
{
MOZ_STYLO_FORWARD(Count, ())
}
bool
DeclarationBlock::GetNthProperty(uint32_t aIndex, nsAString& aReturn) const
{
MOZ_STYLO_FORWARD(GetNthProperty, (aIndex, aReturn))
}
void
DeclarationBlock::GetPropertyValue(const nsAString& aProperty,
nsAString& aValue) const
{
MOZ_STYLO_FORWARD(GetPropertyValue, (aProperty, aValue))
}
void
DeclarationBlock::GetPropertyValueByID(nsCSSPropertyID aPropID,
nsAString& aValue) const
{
MOZ_STYLO_FORWARD(GetPropertyValueByID, (aPropID, aValue))
}
bool
DeclarationBlock::GetPropertyIsImportant(const nsAString& aProperty) const
{
MOZ_STYLO_FORWARD(GetPropertyIsImportant, (aProperty))
}
bool
DeclarationBlock::RemoveProperty(const nsAString& aProperty)
{
MOZ_STYLO_FORWARD(RemoveProperty, (aProperty))
}
bool
DeclarationBlock::RemovePropertyByID(nsCSSPropertyID aProperty)
{
MOZ_STYLO_FORWARD(RemovePropertyByID, (aProperty))
}
} // namespace mozilla
#endif // mozilla_DeclarationBlockInlines_h

View File

@@ -47,7 +47,7 @@
#include "nsWindowSizes.h"
#include "mozilla/CORSMode.h"
#include "mozilla/DeclarationBlockInlines.h"
#include "mozilla/DeclarationBlock.h"
#include "mozilla/EffectCompositor.h"
#include "mozilla/EffectSet.h"
#include "mozilla/EventStates.h"
@@ -391,7 +391,7 @@ Gecko_GetStyleAttrDeclarationBlock(RawGeckoElementBorrowed aElement)
if (!decl) {
return nullptr;
}
return decl->AsServo()->RefRawStrong();
return decl->RefRawStrong();
}
void
@@ -421,7 +421,7 @@ Gecko_GetHTMLPresentationAttrDeclarationBlock(RawGeckoElementBorrowed aElement)
auto* svg = nsSVGElement::FromNodeOrNull(aElement);
if (svg) {
if (auto decl = svg->GetContentDeclarationBlock()) {
return decl->AsServo()->RefRawStrong();
return decl->RefRawStrong();
}
}
return nullptr;

View File

@@ -55,6 +55,7 @@ headers = [
"nsThemeConstants.h",
"mozilla/css/Loader.h",
"mozilla/css/SheetLoadData.h",
"mozilla/DeclarationBlock.h",
"mozilla/dom/AnimationEffectBinding.h",
"mozilla/dom/HTMLSlotElement.h",
"mozilla/dom/KeyframeEffectBinding.h",
@@ -74,7 +75,6 @@ headers = [
"mozilla/StaticPrefs.h",
"mozilla/ServoBindings.h",
"mozilla/ComputedStyle.h",
"mozilla/ServoDeclarationBlock.h",
"mozilla/ServoTraversalStatistics.h",
"mozilla/SizeOfState.h",
"nsCSSProps.h",
@@ -359,12 +359,12 @@ whitelist-types = [
"StyleTransition",
"ThemeWidgetType",
"mozilla::UniquePtr",
"mozilla::DeclarationBlock",
"mozilla::DefaultDelete",
"mozilla::Side",
"mozilla::binding_danger::AssertAndSuppressCleanupPolicy",
"mozilla::ParsingMode",
"mozilla::InheritTarget",
"mozilla::ServoDeclarationBlock",
"mozilla::dom::MediaList",
"mozilla::StyleRuleInclusion",
"nsStyleTransformMatrix::MatrixTransformOperator",

View File

@@ -1,81 +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_ServoDeclarationBlock_h
#define mozilla_ServoDeclarationBlock_h
#include "mozilla/ServoBindings.h"
#include "mozilla/DeclarationBlock.h"
namespace mozilla {
class ServoDeclarationBlock final : public DeclarationBlock
{
public:
explicit ServoDeclarationBlock(
already_AddRefed<RawServoDeclarationBlock> aRaw)
: DeclarationBlock(), mRaw(aRaw) {}
ServoDeclarationBlock()
: ServoDeclarationBlock(Servo_DeclarationBlock_CreateEmpty().Consume()) {}
ServoDeclarationBlock(const ServoDeclarationBlock& aCopy)
: DeclarationBlock(aCopy)
, mRaw(Servo_DeclarationBlock_Clone(aCopy.mRaw).Consume()) {}
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(ServoDeclarationBlock)
static already_AddRefed<ServoDeclarationBlock>
FromCssText(const nsAString& aCssText, URLExtraData* aExtraData,
nsCompatibility aMode, css::Loader* aLoader);
RawServoDeclarationBlock* Raw() const { return mRaw; }
RawServoDeclarationBlock* const* RefRaw() const {
static_assert(sizeof(RefPtr<RawServoDeclarationBlock>) ==
sizeof(RawServoDeclarationBlock*),
"RefPtr should just be a pointer");
return reinterpret_cast<RawServoDeclarationBlock* const*>(&mRaw);
}
const RawServoDeclarationBlockStrong* RefRawStrong() const
{
static_assert(sizeof(RefPtr<RawServoDeclarationBlock>) ==
sizeof(RawServoDeclarationBlock*),
"RefPtr should just be a pointer");
static_assert(sizeof(RefPtr<RawServoDeclarationBlock>) ==
sizeof(RawServoDeclarationBlockStrong),
"RawServoDeclarationBlockStrong should be the same as RefPtr");
return reinterpret_cast<const RawServoDeclarationBlockStrong*>(&mRaw);
}
void ToString(nsAString& aResult) const {
Servo_DeclarationBlock_GetCssText(mRaw, &aResult);
}
uint32_t Count() const {
return Servo_DeclarationBlock_Count(mRaw);
}
bool GetNthProperty(uint32_t aIndex, nsAString& aReturn) const {
aReturn.Truncate();
return Servo_DeclarationBlock_GetNthProperty(mRaw, aIndex, &aReturn);
}
void GetPropertyValue(const nsAString& aProperty, nsAString& aValue) const;
void GetPropertyValueByID(nsCSSPropertyID aPropID, nsAString& aValue) const;
bool GetPropertyIsImportant(const nsAString& aProperty) const;
// The two functions blow return whether any property was removed.
bool RemoveProperty(const nsAString& aProperty);
bool RemovePropertyByID(nsCSSPropertyID aPropID);
private:
~ServoDeclarationBlock() {}
RefPtr<RawServoDeclarationBlock> mRaw;
};
} // namespace mozilla
#endif // mozilla_ServoDeclarationBlock_h

View File

@@ -8,6 +8,7 @@
#include "mozilla/dom/CSSFontFaceRuleBinding.h"
#include "mozilla/dom/CSSStyleDeclarationBinding.h"
#include "nsCSSProps.h"
using namespace mozilla;
using namespace mozilla::dom;

View File

@@ -6,8 +6,7 @@
#include "mozilla/ServoKeyframeRule.h"
#include "mozilla/DeclarationBlockInlines.h"
#include "mozilla/ServoDeclarationBlock.h"
#include "mozilla/DeclarationBlock.h"
#include "nsDOMCSSDeclaration.h"
#include "mozAutoDocUpdate.h"
@@ -23,7 +22,7 @@ public:
explicit ServoKeyframeDeclaration(ServoKeyframeRule* aRule)
: mRule(aRule)
{
mDecls = new ServoDeclarationBlock(
mDecls = new DeclarationBlock(
Servo_Keyframe_GetStyle(aRule->Raw()).Consume());
}
@@ -50,7 +49,7 @@ public:
mRule->UpdateRule([this, aDecls]() {
if (mDecls != aDecls) {
mDecls->SetOwningRule(nullptr);
mDecls = aDecls->AsServo();
mDecls = aDecls;
mDecls->SetOwningRule(mRule);
Servo_Keyframe_SetStyle(mRule->Raw(), mDecls->Raw());
}
@@ -82,7 +81,7 @@ private:
}
ServoKeyframeRule* mRule;
RefPtr<ServoDeclarationBlock> mDecls;
RefPtr<DeclarationBlock> mDecls;
};
NS_IMPL_CYCLE_COLLECTING_ADDREF(ServoKeyframeDeclaration)

View File

@@ -14,7 +14,7 @@ class nsICSSDeclaration;
namespace mozilla {
class ServoDeclarationBlock;
class DeclarationBlock;
class ServoKeyframeDeclaration;
class ServoKeyframeRule final : public dom::CSSKeyframeRule

View File

@@ -8,9 +8,8 @@
#include "mozilla/ServoPageRule.h"
#include "mozilla/DeclarationBlockInlines.h"
#include "mozilla/DeclarationBlock.h"
#include "mozilla/ServoBindings.h"
#include "mozilla/ServoDeclarationBlock.h"
using namespace mozilla::dom;
@@ -20,7 +19,7 @@ namespace mozilla {
ServoPageRuleDeclaration::ServoPageRuleDeclaration(
already_AddRefed<RawServoDeclarationBlock> aDecls)
: mDecls(new ServoDeclarationBlock(Move(aDecls)))
: mDecls(new DeclarationBlock(Move(aDecls)))
{
}
@@ -72,7 +71,7 @@ ServoPageRuleDeclaration::SetCSSDeclaration(DeclarationBlock* aDecl)
if (aDecl != mDecls) {
mDecls->SetOwningRule(nullptr);
RefPtr<ServoDeclarationBlock> decls = aDecl->AsServo();
RefPtr<DeclarationBlock> decls = aDecl;
Servo_PageRule_SetStyle(rule->Raw(), decls->Raw());
mDecls = decls.forget();
mDecls->SetOwningRule(rule);

View File

@@ -20,7 +20,7 @@ namespace dom {
class DocGroup;
} // namespace dom
class ServoDeclarationBlock;
class DeclarationBlock;
class ServoPageRule;
class ServoPageRuleDeclaration final : public nsDOMCSSDeclaration
@@ -49,7 +49,7 @@ private:
inline ServoPageRule* Rule();
inline const ServoPageRule* Rule() const;
RefPtr<ServoDeclarationBlock> mDecls;
RefPtr<DeclarationBlock> mDecls;
};
class ServoPageRule final : public dom::CSSPageRule

View File

@@ -8,9 +8,8 @@
#include "mozilla/ServoStyleRule.h"
#include "mozilla/DeclarationBlockInlines.h"
#include "mozilla/DeclarationBlock.h"
#include "mozilla/ServoBindings.h"
#include "mozilla/ServoDeclarationBlock.h"
#include "mozilla/dom/CSSStyleRuleBinding.h"
#include "mozAutoDocUpdate.h"
@@ -23,7 +22,7 @@ namespace mozilla {
ServoStyleRuleDeclaration::ServoStyleRuleDeclaration(
already_AddRefed<RawServoDeclarationBlock> aDecls)
: mDecls(new ServoDeclarationBlock(Move(aDecls)))
: mDecls(new DeclarationBlock(Move(aDecls)))
{
}
@@ -74,7 +73,7 @@ ServoStyleRuleDeclaration::SetCSSDeclaration(DeclarationBlock* aDecl)
if (RefPtr<StyleSheet> sheet = rule->GetStyleSheet()) {
if (aDecl != mDecls) {
mDecls->SetOwningRule(nullptr);
RefPtr<ServoDeclarationBlock> decls = aDecl->AsServo();
RefPtr<DeclarationBlock> decls = aDecl;
Servo_StyleRule_SetStyle(rule->Raw(), decls->Raw());
mDecls = decls.forget();
mDecls->SetOwningRule(rule);

View File

@@ -21,7 +21,7 @@ namespace dom {
class DocGroup;
} // namespace dom
class ServoDeclarationBlock;
class DeclarationBlock;
class ServoStyleRule;
class ServoStyleRuleDeclaration final : public nsDOMCSSDeclaration
@@ -50,7 +50,7 @@ private:
inline ServoStyleRule* Rule();
inline const ServoStyleRule* Rule() const;
RefPtr<ServoDeclarationBlock> mDecls;
RefPtr<DeclarationBlock> mDecls;
};
class ServoStyleRule final : public BindingStyleRule

View File

@@ -474,7 +474,7 @@ private:
const SnapshotTable& Snapshots();
/**
* Resolve all ServoDeclarationBlocks attached to mapped
* Resolve all DeclarationBlocks attached to mapped
* presentation attributes cached on the document.
*
* Call this before jumping into Servo's style system.

View File

@@ -69,7 +69,6 @@ EXPORTS.mozilla += [
'CSSEnabledState.h',
'CSSPropFlags.h',
'DeclarationBlock.h',
'DeclarationBlockInlines.h',
'DocumentStyleRootIterator.h',
'GenericSpecifiedValues.h',
'GenericSpecifiedValuesInlines.h',
@@ -86,7 +85,6 @@ EXPORTS.mozilla += [
'ServoCounterStyleRule.h',
'ServoCSSParser.h',
'ServoCSSRuleList.h',
'ServoDeclarationBlock.h',
'ServoDocumentRule.h',
'ServoElementSnapshot.h',
'ServoElementSnapshotTable.h',
@@ -165,6 +163,7 @@ UNIFIED_SOURCES += [
'CSSPageRule.cpp',
'CSSRuleList.cpp',
'CSSSupportsRule.cpp',
'DeclarationBlock.cpp',
'DocumentStyleRootIterator.cpp',
'ErrorReporter.cpp',
'FontFace.cpp',
@@ -206,7 +205,6 @@ UNIFIED_SOURCES += [
'ServoCounterStyleRule.cpp',
'ServoCSSParser.cpp',
'ServoCSSRuleList.cpp',
'ServoDeclarationBlock.cpp',
'ServoDocumentRule.cpp',
'ServoElementSnapshot.cpp',
'ServoFontFaceRule.cpp',

View File

@@ -9,11 +9,9 @@
#include "nsDOMCSSAttrDeclaration.h"
#include "mozilla/DeclarationBlock.h"
#include "mozilla/DeclarationBlockInlines.h"
#include "mozilla/dom/Element.h"
#include "mozilla/dom/MutationEventBinding.h"
#include "mozilla/InternalMutationEvent.h"
#include "mozilla/ServoDeclarationBlock.h"
#include "mozAutoDocUpdate.h"
#include "nsContentUtils.h"
#include "nsIDocument.h"
@@ -140,7 +138,7 @@ nsDOMCSSAttributeDeclaration::GetCSSDeclaration(Operation aOperation)
}
// cannot fail
RefPtr<DeclarationBlock> decl = new ServoDeclarationBlock();
RefPtr<DeclarationBlock> decl = new DeclarationBlock();
// this *can* fail (inside SetAttrAndNotify, at least).
nsresult rv;

View File

@@ -8,7 +8,7 @@
#include "nsDOMCSSDeclaration.h"
#include "mozilla/DeclarationBlockInlines.h"
#include "mozilla/DeclarationBlock.h"
#include "mozilla/StyleSheetInlines.h"
#include "mozilla/css/Rule.h"
#include "mozilla/dom/CSS2PropertiesBinding.h"
@@ -126,8 +126,8 @@ nsDOMCSSDeclaration::SetCssText(const nsAString& aCssText,
}
RefPtr<DeclarationBlock> newdecl =
ServoDeclarationBlock::FromCssText(aCssText, servoEnv.mUrlExtraData,
servoEnv.mCompatMode, servoEnv.mLoader);
DeclarationBlock::FromCssText(aCssText, servoEnv.mUrlExtraData,
servoEnv.mCompatMode, servoEnv.mLoader);
aRv = SetCSSDeclaration(newdecl);
}
@@ -268,7 +268,7 @@ nsDOMCSSDeclaration::ModifyDeclaration(nsIPrincipal* aSubjectPrincipal,
return NS_ERROR_NOT_AVAILABLE;
}
changed = aFunc(decl->AsServo(), servoEnv);
changed = aFunc(decl, servoEnv);
if (!changed) {
// Parsing failed -- but we don't throw an exception for that.
@@ -286,7 +286,7 @@ nsDOMCSSDeclaration::ParsePropertyValue(const nsCSSPropertyID aPropID,
{
return ModifyDeclaration(
aSubjectPrincipal,
[&](ServoDeclarationBlock* decl, ParsingEnvironment& env) {
[&](DeclarationBlock* decl, ParsingEnvironment& env) {
NS_ConvertUTF16toUTF8 value(aPropValue);
return Servo_DeclarationBlock_SetPropertyById(
decl->Raw(), aPropID, &value, aIsImportant, env.mUrlExtraData,
@@ -303,7 +303,7 @@ nsDOMCSSDeclaration::ParseCustomPropertyValue(const nsAString& aPropertyName,
MOZ_ASSERT(nsCSSProps::IsCustomPropertyName(aPropertyName));
return ModifyDeclaration(
aSubjectPrincipal,
[&](ServoDeclarationBlock* decl, ParsingEnvironment& env) {
[&](DeclarationBlock* decl, ParsingEnvironment& env) {
NS_ConvertUTF16toUTF8 property(aPropertyName);
NS_ConvertUTF16toUTF8 value(aPropValue);
return Servo_DeclarationBlock_SetProperty(

View File

@@ -10,7 +10,7 @@
#include "nsHTMLCSSStyleSheet.h"
#include "mozilla/MemoryReporting.h"
#include "mozilla/DeclarationBlockInlines.h"
#include "mozilla/DeclarationBlock.h"
#include "nsPresContext.h"
#include "mozilla/dom/Element.h"
#include "nsAttrValue.h"

View File

@@ -55,7 +55,7 @@ public:
UniqueMappedAttributes(nsMappedAttributes* aMapped);
void DropMappedAttributes(nsMappedAttributes* aMapped);
// For each mapped presentation attribute in the cache, resolve
// the attached ServoDeclarationBlock by running the mapping
// the attached DeclarationBlock by running the mapping
// and converting the ruledata to Servo specified values.
void CalculateMappedServoDeclarations();

View File

@@ -1215,16 +1215,9 @@ impl<'le> TElement for GeckoElement<'le> {
unsafe {
let slots = self.extended_slots()?;
let base_declaration: &structs::DeclarationBlock =
let declaration: &structs::DeclarationBlock =
slots.mSMILOverrideStyleDeclaration.mRawPtr.as_ref()?;
let declaration: &structs::ServoDeclarationBlock = mem::transmute(base_declaration);
debug_assert_eq!(
&declaration._base as *const structs::DeclarationBlock,
base_declaration as *const structs::DeclarationBlock
);
let raw: &structs::RawServoDeclarationBlock = declaration.mRaw.mRawPtr.as_ref()?;
Some(