зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1296186 part 2 - Make ServoDeclarationBlock refcounted. r=heycam
MozReview-Commit-ID: 2X0JX8HA4ej --HG-- extra : rebase_source : e5e888be0fb98f995a7ac17bd0985177206914a2 extra : source : 53ce9619813b91b26a5bc51b7417c55e8b9cb505
This commit is contained in:
Родитель
0fab79f248
Коммит
b1014aeb0c
|
@ -17,7 +17,7 @@
|
|||
#include "nsIAtom.h"
|
||||
#include "nsUnicharUtils.h"
|
||||
#include "mozilla/MemoryReporting.h"
|
||||
#include "mozilla/ServoBindings.h"
|
||||
#include "mozilla/ServoBindingHelpers.h"
|
||||
#include "mozilla/css/Declaration.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsReadableUtils.h"
|
||||
|
@ -463,12 +463,12 @@ nsAttrValue::SetTo(css::Declaration* aValue, const nsAString* aSerialized)
|
|||
}
|
||||
|
||||
void
|
||||
nsAttrValue::SetTo(ServoDeclarationBlock* aValue,
|
||||
nsAttrValue::SetTo(already_AddRefed<ServoDeclarationBlock> aValue,
|
||||
const nsAString* aSerialized)
|
||||
{
|
||||
MiscContainer* cont = EnsureEmptyMiscContainer();
|
||||
MOZ_ASSERT(cont->mValue.mRefCount == 0);
|
||||
cont->mValue.mServoCSSDeclaration = aValue;
|
||||
cont->mValue.mServoCSSDeclaration = aValue.take();
|
||||
cont->mType = eServoCSSDeclaration;
|
||||
NS_ADDREF(cont);
|
||||
SetMiscAtomOrString(aSerialized);
|
||||
|
@ -1745,12 +1745,11 @@ nsAttrValue::ParseStyleAttribute(const nsAString& aString,
|
|||
|
||||
if (ownerDoc->GetStyleBackendType() == StyleBackendType::Servo) {
|
||||
NS_ConvertUTF16toUTF8 value(aString);
|
||||
ServoDeclarationBlock* decl = Servo_ParseStyleAttribute(
|
||||
RefPtr<ServoDeclarationBlock> decl = Servo_ParseStyleAttribute(
|
||||
reinterpret_cast<const uint8_t*>(value.get()),
|
||||
value.Length(),
|
||||
sheet);
|
||||
value.Length(), sheet).Consume();
|
||||
MOZ_ASSERT(decl);
|
||||
SetTo(decl, &aString);
|
||||
SetTo(decl.forget(), &aString);
|
||||
} else {
|
||||
css::Loader* cssLoader = ownerDoc->CSSLoader();
|
||||
nsCSSParser cssParser(cssLoader);
|
||||
|
@ -1862,7 +1861,7 @@ nsAttrValue::ClearMiscContainer()
|
|||
if (cont->mType == eGeckoCSSDeclaration) {
|
||||
NS_RELEASE(cont->mValue.mGeckoCSSDeclaration);
|
||||
} else {
|
||||
Servo_DropDeclarationBlock(cont->mValue.mServoCSSDeclaration);
|
||||
Servo_DeclarationBlock_Release(cont->mValue.mServoCSSDeclaration);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -148,7 +148,7 @@ public:
|
|||
void SetTo(int32_t aInt, const nsAString* aSerialized);
|
||||
void SetTo(double aValue, const nsAString* aSerialized);
|
||||
void SetTo(mozilla::css::Declaration* aValue, const nsAString* aSerialized);
|
||||
void SetTo(ServoDeclarationBlock* aDeclarationBlock,
|
||||
void SetTo(already_AddRefed<ServoDeclarationBlock> aDeclarationBlock,
|
||||
const nsAString* aSerialized);
|
||||
void SetTo(mozilla::css::URLValue* aValue, const nsAString* aSerialized);
|
||||
void SetTo(const nsIntMargin& aValue);
|
||||
|
|
|
@ -45,6 +45,19 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct RefPtrTraits<ServoDeclarationBlock>
|
||||
{
|
||||
static void AddRef(ServoDeclarationBlock* aPtr)
|
||||
{
|
||||
Servo_DeclarationBlock_AddRef(aPtr);
|
||||
}
|
||||
static void Release(ServoDeclarationBlock* aPtr)
|
||||
{
|
||||
Servo_DeclarationBlock_Release(aPtr);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // mozilla_ServoBindingHelpers_h
|
||||
|
|
|
@ -49,17 +49,19 @@ SERVO_BINDING_FUNC(Servo_InitStyleSet, RawServoStyleSet*)
|
|||
SERVO_BINDING_FUNC(Servo_DropStyleSet, void, RawServoStyleSet* set)
|
||||
|
||||
// Style attribute
|
||||
SERVO_BINDING_FUNC(Servo_ParseStyleAttribute, ServoDeclarationBlock*,
|
||||
SERVO_BINDING_FUNC(Servo_ParseStyleAttribute, ServoDeclarationBlockStrong,
|
||||
const uint8_t* bytes, uint32_t length,
|
||||
nsHTMLCSSStyleSheet* cache)
|
||||
SERVO_BINDING_FUNC(Servo_DropDeclarationBlock, void,
|
||||
ServoDeclarationBlock* declarations)
|
||||
SERVO_BINDING_FUNC(Servo_DeclarationBlock_AddRef, void,
|
||||
ServoDeclarationBlockBorrowed declarations)
|
||||
SERVO_BINDING_FUNC(Servo_DeclarationBlock_Release, void,
|
||||
ServoDeclarationBlockBorrowed declarations)
|
||||
SERVO_BINDING_FUNC(Servo_GetDeclarationBlockCache, nsHTMLCSSStyleSheet*,
|
||||
ServoDeclarationBlock* declarations)
|
||||
ServoDeclarationBlockBorrowed declarations)
|
||||
SERVO_BINDING_FUNC(Servo_SetDeclarationBlockImmutable, void,
|
||||
ServoDeclarationBlock* declarations)
|
||||
ServoDeclarationBlockBorrowed declarations)
|
||||
SERVO_BINDING_FUNC(Servo_ClearDeclarationBlockCachePointer, void,
|
||||
ServoDeclarationBlock* declarations)
|
||||
ServoDeclarationBlockBorrowed declarations)
|
||||
|
||||
// CSS supports()
|
||||
SERVO_BINDING_FUNC(Servo_CSSSupports, bool,
|
||||
|
|
|
@ -40,6 +40,7 @@ using namespace mozilla;
|
|||
|
||||
IMPL_STRONG_REF_TYPE_FOR(ServoComputedValues)
|
||||
IMPL_STRONG_REF_TYPE_FOR(RawServoStyleSheet)
|
||||
IMPL_STRONG_REF_TYPE_FOR(ServoDeclarationBlock)
|
||||
|
||||
#undef IMPL_STRONG_REF_TYPE_FOR
|
||||
|
||||
|
|
|
@ -65,6 +65,7 @@ struct ServoDeclarationBlock;
|
|||
|
||||
DECL_REF_TYPE_FOR(ServoComputedValues)
|
||||
DECL_REF_TYPE_FOR(RawServoStyleSheet)
|
||||
DECL_REF_TYPE_FOR(ServoDeclarationBlock)
|
||||
|
||||
#undef DECL_REF_TYPE_FOR
|
||||
|
||||
|
@ -145,7 +146,7 @@ SERVO_DECLARE_ELEMENT_ATTR_MATCHING_FUNCTIONS(Gecko_Snapshot,
|
|||
#undef SERVO_DECLARE_ELEMENT_ATTR_MATCHING_FUNCTIONS
|
||||
|
||||
// Style attributes.
|
||||
ServoDeclarationBlock* Gecko_GetServoDeclarationBlock(RawGeckoElement* element);
|
||||
ServoDeclarationBlockBorrowed Gecko_GetServoDeclarationBlock(RawGeckoElement* element);
|
||||
|
||||
// Node data.
|
||||
ServoNodeData* Gecko_GetNodeData(RawGeckoNode* node);
|
||||
|
|
Загрузка…
Ссылка в новой задаче