Bug 1296173 part 2 - Rename the servo binding functions. r=bholley

MozReview-Commit-ID: Gxqx52v3sDQ

--HG--
extra : rebase_source : 98fdf4a1463680b629c4986df2b2b9c3b306c64e
This commit is contained in:
Xidorn Quan 2016-08-23 13:14:27 +10:00
parent 22456d1070
commit 611f544c5d
8 changed files with 53 additions and 68 deletions

View File

@ -85,7 +85,7 @@ MiscContainer::Cache()
sheet = mValue.mGeckoCSSDeclaration->GetHTMLCSSStyleSheet();
break;
case nsAttrValue::eServoCSSDeclaration:
sheet = Servo_GetDeclarationBlockCache(mValue.mServoCSSDeclaration);
sheet = Servo_DeclarationBlock_GetCache(mValue.mServoCSSDeclaration);
break;
default:
MOZ_ASSERT_UNREACHABLE("unexpected cached nsAttrValue type");
@ -112,7 +112,7 @@ MiscContainer::Cache()
mValue.mGeckoCSSDeclaration->SetImmutable();
break;
case nsAttrValue::eServoCSSDeclaration:
Servo_SetDeclarationBlockImmutable(mValue.mServoCSSDeclaration);
Servo_DeclarationBlock_SetImmutable(mValue.mServoCSSDeclaration);
break;
default:
MOZ_ASSERT_UNREACHABLE("unexpected cached nsAttrValue type");
@ -139,7 +139,7 @@ MiscContainer::Evict()
sheet = mValue.mGeckoCSSDeclaration->GetHTMLCSSStyleSheet();
break;
case nsAttrValue::eServoCSSDeclaration:
sheet = Servo_GetDeclarationBlockCache(mValue.mServoCSSDeclaration);
sheet = Servo_DeclarationBlock_GetCache(mValue.mServoCSSDeclaration);
break;
default:
MOZ_ASSERT_UNREACHABLE("unexpected cached nsAttrValue type");

View File

@ -56,7 +56,7 @@ class nsDOMMutationObserver;
// We declare the bare minimum infrastructure here to allow us to have a
// UniquePtr<ServoNodeData> on nsINode.
struct ServoNodeData;
extern "C" void Servo_DropNodeData(ServoNodeData*);
extern "C" void Servo_NodeData_Drop(ServoNodeData*);
namespace mozilla {
template<>
class DefaultDelete<ServoNodeData>
@ -64,7 +64,7 @@ class DefaultDelete<ServoNodeData>
public:
void operator()(ServoNodeData* aPtr) const
{
Servo_DropNodeData(aPtr);
Servo_NodeData_Drop(aPtr);
}
};
} // namespace mozilla

View File

@ -79,7 +79,7 @@ ServoRestyleManager::RecreateStyleContexts(nsIContent* aContent,
if (aContent->IsDirtyForServo()) {
RefPtr<ServoComputedValues> computedValues =
Servo_GetComputedValues(aContent).Consume();
Servo_ComputedValues_Get(aContent).Consume();
MOZ_ASSERT(computedValues);
nsChangeHint changeHint = nsChangeHint(0);

View File

@ -13,27 +13,25 @@
namespace mozilla {
template<>
struct RefPtrTraits<RawServoStyleSheet>
{
static void AddRef(RawServoStyleSheet* aPtr) {
Servo_AddRefStyleSheet(aPtr);
#define DEFINE_REFPTR_TRAITS(name_, type_) \
template<> \
struct RefPtrTraits<type_> \
{ \
static void AddRef(type_* aPtr) \
{ \
Servo_##name_##_AddRef(aPtr); \
} \
static void Release(type_* aPtr) \
{ \
Servo_##name_##_Release(aPtr); \
} \
}
static void Release(RawServoStyleSheet* aPtr) {
Servo_ReleaseStyleSheet(aPtr);
}
};
template<>
struct RefPtrTraits<ServoComputedValues>
{
static void AddRef(ServoComputedValues* aPtr) {
Servo_AddRefComputedValues(aPtr);
}
static void Release(ServoComputedValues* aPtr) {
Servo_ReleaseComputedValues(aPtr);
}
};
DEFINE_REFPTR_TRAITS(StyleSheet, RawServoStyleSheet);
DEFINE_REFPTR_TRAITS(ComputedValues, ServoComputedValues);
DEFINE_REFPTR_TRAITS(DeclarationBlock, ServoDeclarationBlock);
#undef DEFINE_REFPTR_TRAITS
template<>
class DefaultDelete<RawServoStyleSet>
@ -41,20 +39,7 @@ class DefaultDelete<RawServoStyleSet>
public:
void operator()(RawServoStyleSet* aPtr) const
{
Servo_DropStyleSet(aPtr);
}
};
template<>
struct RefPtrTraits<ServoDeclarationBlock>
{
static void AddRef(ServoDeclarationBlock* aPtr)
{
Servo_DeclarationBlock_AddRef(aPtr);
}
static void Release(ServoDeclarationBlock* aPtr)
{
Servo_DeclarationBlock_Release(aPtr);
Servo_StyleSet_Drop(aPtr);
}
};

View File

@ -19,24 +19,24 @@
*/
// Node data
SERVO_BINDING_FUNC(Servo_DropNodeData, void, ServoNodeData* data)
SERVO_BINDING_FUNC(Servo_NodeData_Drop, void, ServoNodeData* data)
// Styleset and Stylesheet management
SERVO_BINDING_FUNC(Servo_StylesheetFromUTF8Bytes, RawServoStyleSheetStrong,
SERVO_BINDING_FUNC(Servo_StyleSheet_FromUTF8Bytes, RawServoStyleSheetStrong,
const uint8_t* bytes, uint32_t length,
mozilla::css::SheetParsingMode parsing_mode,
const uint8_t* base_bytes, uint32_t base_length,
ThreadSafeURIHolder* base,
ThreadSafeURIHolder* referrer,
ThreadSafePrincipalHolder* principal)
SERVO_BINDING_FUNC(Servo_AddRefStyleSheet, void,
SERVO_BINDING_FUNC(Servo_StyleSheet_AddRef, void,
RawServoStyleSheetBorrowed sheet)
SERVO_BINDING_FUNC(Servo_ReleaseStyleSheet, void,
SERVO_BINDING_FUNC(Servo_StyleSheet_Release, void,
RawServoStyleSheetBorrowed sheet)
SERVO_BINDING_FUNC(Servo_StyleSheetHasRules, bool,
SERVO_BINDING_FUNC(Servo_StyleSheet_HasRules, bool,
RawServoStyleSheetBorrowed sheet)
SERVO_BINDING_FUNC(Servo_InitStyleSet, RawServoStyleSet*)
SERVO_BINDING_FUNC(Servo_DropStyleSet, void, RawServoStyleSet* set)
SERVO_BINDING_FUNC(Servo_StyleSet_Init, RawServoStyleSet*)
SERVO_BINDING_FUNC(Servo_StyleSet_Drop, void, RawServoStyleSet* set)
SERVO_BINDING_FUNC(Servo_StyleSet_AppendStyleSheet, void,
RawServoStyleSet* set, RawServoStyleSheetBorrowed sheet)
SERVO_BINDING_FUNC(Servo_StyleSet_PrependStyleSheet, void,
@ -55,11 +55,11 @@ SERVO_BINDING_FUNC(Servo_DeclarationBlock_AddRef, void,
ServoDeclarationBlockBorrowed declarations)
SERVO_BINDING_FUNC(Servo_DeclarationBlock_Release, void,
ServoDeclarationBlockBorrowed declarations)
SERVO_BINDING_FUNC(Servo_GetDeclarationBlockCache, nsHTMLCSSStyleSheet*,
SERVO_BINDING_FUNC(Servo_DeclarationBlock_GetCache, nsHTMLCSSStyleSheet*,
ServoDeclarationBlockBorrowed declarations)
SERVO_BINDING_FUNC(Servo_SetDeclarationBlockImmutable, void,
SERVO_BINDING_FUNC(Servo_DeclarationBlock_SetImmutable, void,
ServoDeclarationBlockBorrowed declarations)
SERVO_BINDING_FUNC(Servo_ClearDeclarationBlockCachePointer, void,
SERVO_BINDING_FUNC(Servo_DeclarationBlock_ClearCachePointer, void,
ServoDeclarationBlockBorrowed declarations)
// CSS supports()
@ -68,22 +68,22 @@ SERVO_BINDING_FUNC(Servo_CSSSupports, bool,
const uint8_t* value, uint32_t value_length)
// Computed style data
SERVO_BINDING_FUNC(Servo_GetComputedValues, ServoComputedValuesStrong,
SERVO_BINDING_FUNC(Servo_ComputedValues_Get, ServoComputedValuesStrong,
RawGeckoNode* node)
SERVO_BINDING_FUNC(Servo_GetComputedValuesForAnonymousBox,
SERVO_BINDING_FUNC(Servo_ComputedValues_GetForAnonymousBox,
ServoComputedValuesStrong,
ServoComputedValuesBorrowed parent_style_or_null,
nsIAtom* pseudoTag, RawServoStyleSet* set)
SERVO_BINDING_FUNC(Servo_GetComputedValuesForPseudoElement,
SERVO_BINDING_FUNC(Servo_ComputedValues_GetForPseudoElement,
ServoComputedValuesStrong,
ServoComputedValuesBorrowed parent_style,
RawGeckoElement* match_element, nsIAtom* pseudo_tag,
RawServoStyleSet* set, bool is_probe)
SERVO_BINDING_FUNC(Servo_InheritComputedValues, ServoComputedValuesStrong,
SERVO_BINDING_FUNC(Servo_ComputedValues_Inherit, ServoComputedValuesStrong,
ServoComputedValuesBorrowed parent_style)
SERVO_BINDING_FUNC(Servo_AddRefComputedValues, void,
SERVO_BINDING_FUNC(Servo_ComputedValues_AddRef, void,
ServoComputedValuesBorrowed computed_values)
SERVO_BINDING_FUNC(Servo_ReleaseComputedValues, void,
SERVO_BINDING_FUNC(Servo_ComputedValues_Release, void,
ServoComputedValuesBorrowed computed_values)
// Initialize Servo components. Should be called exactly once at startup.
@ -96,7 +96,7 @@ SERVO_BINDING_FUNC(Servo_ComputeRestyleHint, nsRestyleHint,
RawGeckoElement* element, ServoElementSnapshot* snapshot,
RawServoStyleSet* set)
// Restyle the given document or subtree
// Restyle the given document or subtree
SERVO_BINDING_FUNC(Servo_RestyleDocument, void,
RawGeckoDocument* doc, RawServoStyleSet* set)
SERVO_BINDING_FUNC(Servo_RestyleSubtree, void,

View File

@ -19,7 +19,7 @@ using namespace mozilla::dom;
ServoStyleSet::ServoStyleSet()
: mPresContext(nullptr)
, mRawSet(Servo_InitStyleSet())
, mRawSet(Servo_StyleSet_Init())
, mBatching(0)
, mStylingStarted(false)
{
@ -97,7 +97,7 @@ ServoStyleSet::GetContext(nsIContent* aContent,
CSSPseudoElementType aPseudoType)
{
RefPtr<ServoComputedValues> computedValues =
Servo_GetComputedValues(aContent).Consume();
Servo_ComputedValues_Get(aContent).Consume();
MOZ_ASSERT(computedValues);
return GetContext(computedValues.forget(), aParentContext, aPseudoTag, aPseudoType);
}
@ -159,9 +159,9 @@ ServoStyleSet::ResolveStyleForText(nsIContent* aTextNode,
ServoComputedValues* parentComputedValues =
aParentContext->StyleSource().AsServoComputedValues();
computedValues =
Servo_InheritComputedValues(parentComputedValues).Consume();
Servo_ComputedValues_Inherit(parentComputedValues).Consume();
} else {
computedValues = Servo_GetComputedValues(aTextNode).Consume();
computedValues = Servo_ComputedValues_Get(aTextNode).Consume();
}
return GetContext(computedValues.forget(), aParentContext,
@ -176,7 +176,7 @@ ServoStyleSet::ResolveStyleForOtherNonElement(nsStyleContext* aParentContext)
ServoComputedValues* parent =
aParentContext ? aParentContext->StyleSource().AsServoComputedValues() : nullptr;
RefPtr<ServoComputedValues> computedValues =
Servo_InheritComputedValues(parent).Consume();
Servo_ComputedValues_Inherit(parent).Consume();
MOZ_ASSERT(computedValues);
return GetContext(computedValues.forget(), aParentContext,
@ -198,7 +198,7 @@ ServoStyleSet::ResolvePseudoElementStyle(Element* aParentElement,
nsIAtom* pseudoTag = nsCSSPseudoElements::GetPseudoAtom(aType);
RefPtr<ServoComputedValues> computedValues =
Servo_GetComputedValuesForPseudoElement(
Servo_ComputedValues_GetForPseudoElement(
aParentContext->StyleSource().AsServoComputedValues(),
aParentElement, pseudoTag, mRawSet.get(), /* is_probe = */ false).Consume();
MOZ_ASSERT(computedValues);
@ -222,8 +222,8 @@ ServoStyleSet::ResolveAnonymousBoxStyle(nsIAtom* aPseudoTag,
aParentContext ? aParentContext->StyleSource().AsServoComputedValues()
: nullptr;
RefPtr<ServoComputedValues> computedValues =
Servo_GetComputedValuesForAnonymousBox(parentStyle, aPseudoTag,
mRawSet.get()).Consume();
Servo_ComputedValues_GetForAnonymousBox(parentStyle, aPseudoTag,
mRawSet.get()).Consume();
#ifdef DEBUG
if (!computedValues) {
nsString pseudo;
@ -393,7 +393,7 @@ ServoStyleSet::ProbePseudoElementStyle(Element* aParentElement,
nsIAtom* pseudoTag = nsCSSPseudoElements::GetPseudoAtom(aType);
RefPtr<ServoComputedValues> computedValues =
Servo_GetComputedValuesForPseudoElement(
Servo_ComputedValues_GetForPseudoElement(
aParentContext->StyleSource().AsServoComputedValues(),
aParentElement, pseudoTag, mRawSet.get(), /* is_probe = */ true).Consume();

View File

@ -32,7 +32,7 @@ ServoStyleSheet::IsApplicable() const
bool
ServoStyleSheet::HasRules() const
{
return Servo_StyleSheetHasRules(RawSheet());
return Servo_StyleSheet_HasRules(RawSheet());
}
nsIDocument*
@ -86,7 +86,7 @@ ServoStyleSheet::ParseSheet(const nsAString& aInput,
aBaseURI->GetSpec(baseString);
NS_ConvertUTF16toUTF8 input(aInput);
mSheet = Servo_StylesheetFromUTF8Bytes(
mSheet = Servo_StyleSheet_FromUTF8Bytes(
reinterpret_cast<const uint8_t*>(input.get()), input.Length(),
mParsingMode,
reinterpret_cast<const uint8_t*>(baseString.get()), baseString.Length(),

View File

@ -47,7 +47,7 @@ nsHTMLCSSStyleSheet::~nsHTMLCSSStyleSheet()
case nsAttrValue::eServoCSSDeclaration: {
ServoDeclarationBlock* declarations =
value->mValue.mServoCSSDeclaration;
Servo_ClearDeclarationBlockCachePointer(declarations);
Servo_DeclarationBlock_ClearCachePointer(declarations);
break;
}
default: