Bug 1296594 - Move Servo binding functions to a list file. r?bholley
MozReview-Commit-ID: GvF8E7LXM1g
new file mode 100644
--- /dev/null
+++ b/layout/style/ServoBindingList.h
@@ -0,0 +1,110 @@
+/* -*- 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/. */
+
+/* a list of all Servo binding functions */
+
+/* This file contains the list of all Servo binding functions. Each
+ * entry is defined as a SERVO_BINDING_FUNC macro with the following
+ * parameters:
+ * - 'name_' the name of the binding function
+ * - 'return_' the return type of the binding function
+ * and the parameter list of the function.
+ *
+ * Users of this list should define a macro
+ * SERVO_BINDING_FUNC(name_, return_, ...)
+ * before including this file.
+ */
+
+// Node data
+SERVO_BINDING_FUNC(Servo_DropNodeData, void, ServoNodeData* data)
+
+// Styleset and Stylesheet management
+SERVO_BINDING_FUNC(Servo_StylesheetFromUTF8Bytes, 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,
+ RawServoStyleSheetBorrowed sheet)
+SERVO_BINDING_FUNC(Servo_ReleaseStyleSheet, void,
+ RawServoStyleSheetBorrowed sheet)
+SERVO_BINDING_FUNC(Servo_AppendStyleSheet, void,
+ RawServoStyleSheetBorrowed sheet, RawServoStyleSet* set)
+SERVO_BINDING_FUNC(Servo_PrependStyleSheet, void,
+ RawServoStyleSheetBorrowed sheet, RawServoStyleSet* set)
+SERVO_BINDING_FUNC(Servo_RemoveStyleSheet, void,
+ RawServoStyleSheetBorrowed sheet, RawServoStyleSet* set)
+SERVO_BINDING_FUNC(Servo_InsertStyleSheetBefore, void,
+ RawServoStyleSheetBorrowed sheet,
+ RawServoStyleSheetBorrowed reference,
+ RawServoStyleSet* set)
+SERVO_BINDING_FUNC(Servo_StyleSheetHasRules, bool,
+ RawServoStyleSheetBorrowed sheet)
+SERVO_BINDING_FUNC(Servo_InitStyleSet, RawServoStyleSet*)
+SERVO_BINDING_FUNC(Servo_DropStyleSet, void, RawServoStyleSet* set)
+
+// Style attribute
+SERVO_BINDING_FUNC(Servo_ParseStyleAttribute, ServoDeclarationBlock*,
+ const uint8_t* bytes, uint32_t length,
+ nsHTMLCSSStyleSheet* cache)
+SERVO_BINDING_FUNC(Servo_DropDeclarationBlock, void,
+ ServoDeclarationBlock* declarations)
+SERVO_BINDING_FUNC(Servo_GetDeclarationBlockCache, nsHTMLCSSStyleSheet*,
+ ServoDeclarationBlock* declarations)
+SERVO_BINDING_FUNC(Servo_SetDeclarationBlockImmutable, void,
+ ServoDeclarationBlock* declarations)
+SERVO_BINDING_FUNC(Servo_ClearDeclarationBlockCachePointer, void,
+ ServoDeclarationBlock* declarations)
+
+// CSS supports()
+SERVO_BINDING_FUNC(Servo_CSSSupports, bool,
+ const uint8_t* name, uint32_t name_length,
+ const uint8_t* value, uint32_t value_length)
+
+// Computed style data
+SERVO_BINDING_FUNC(Servo_GetComputedValues, ServoComputedValuesStrong,
+ RawGeckoNode* node)
+SERVO_BINDING_FUNC(Servo_GetComputedValuesForAnonymousBox,
+ ServoComputedValuesStrong,
+ ServoComputedValuesBorrowed parent_style_or_null,
+ nsIAtom* pseudoTag, RawServoStyleSet* set)
+SERVO_BINDING_FUNC(Servo_GetComputedValuesForPseudoElement,
+ ServoComputedValuesStrong,
+ ServoComputedValuesBorrowed parent_style,
+ RawGeckoElement* match_element, nsIAtom* pseudo_tag,
+ RawServoStyleSet* set, bool is_probe)
+SERVO_BINDING_FUNC(Servo_InheritComputedValues, ServoComputedValuesStrong,
+ ServoComputedValuesBorrowed parent_style)
+SERVO_BINDING_FUNC(Servo_AddRefComputedValues, void,
+ ServoComputedValuesBorrowed computed_values)
+SERVO_BINDING_FUNC(Servo_ReleaseComputedValues, void,
+ ServoComputedValuesBorrowed computed_values)
+
+// Initialize Servo components. Should be called exactly once at startup.
+SERVO_BINDING_FUNC(Servo_Initialize, void)
+// Shut down Servo components. Should be called exactly once at shutdown.
+SERVO_BINDING_FUNC(Servo_Shutdown, void)
+
+// Restyle hints
+SERVO_BINDING_FUNC(Servo_ComputeRestyleHint, nsRestyleHint,
+ RawGeckoElement* element, ServoElementSnapshot* snapshot,
+ RawServoStyleSet* set)
+
+ // Restyle the given document or subtree
+SERVO_BINDING_FUNC(Servo_RestyleDocument, void,
+ RawGeckoDocument* doc, RawServoStyleSet* set)
+SERVO_BINDING_FUNC(Servo_RestyleSubtree, void,
+ RawGeckoNode* node, RawServoStyleSet* set)
+
+// Style-struct management.
+#define STYLE_STRUCT(name, checkdata_cb) \
+ struct nsStyle##name; \
+ SERVO_BINDING_FUNC(Servo_GetStyle##name, const nsStyle##name*, \
+ ServoComputedValuesBorrowed computed_values)
+#include "nsStyleStructList.h"
+#undef STYLE_STRUCT
--- a/layout/style/ServoBindings.cpp
+++ b/layout/style/ServoBindings.cpp
@@ -769,235 +769,22 @@ Gecko_Destroy_nsStyle##name(nsStyle##nam
ptr->~nsStyle##name(); \
}
#include "nsStyleStructList.h"
#undef STYLE_STRUCT
#ifndef MOZ_STYLO
-void
-Servo_DropNodeData(ServoNodeData* data)
-{
- MOZ_CRASH("stylo: shouldn't be calling Servo_DropNodeData in a "
- "non-MOZ_STYLO build");
-}
-
-RawServoStyleSheetStrong
-Servo_StylesheetFromUTF8Bytes(const uint8_t* bytes, uint32_t length,
- mozilla::css::SheetParsingMode mode,
- const uint8_t* base_bytes, uint32_t base_length,
- ThreadSafeURIHolder* base,
- ThreadSafeURIHolder* referrer,
- ThreadSafePrincipalHolder* principal)
-{
- MOZ_CRASH("stylo: shouldn't be calling Servo_StylesheetFromUTF8Bytes in a "
- "non-MOZ_STYLO build");
-}
-
-void
-Servo_AddRefStyleSheet(RawServoStyleSheetBorrowed sheet)
-{
- MOZ_CRASH("stylo: shouldn't be calling Servo_AddRefStylesheet in a "
- "non-MOZ_STYLO build");
-}
-
-void
-Servo_ReleaseStyleSheet(RawServoStyleSheetBorrowed sheet)
-{
- MOZ_CRASH("stylo: shouldn't be calling Servo_ReleaseStylesheet in a "
- "non-MOZ_STYLO build");
-}
-
-void
-Servo_AppendStyleSheet(RawServoStyleSheetBorrowed sheet, RawServoStyleSet* set)
-{
- MOZ_CRASH("stylo: shouldn't be calling Servo_AppendStyleSheet in a "
- "non-MOZ_STYLO build");
-}
-
-void Servo_PrependStyleSheet(RawServoStyleSheetBorrowed sheet, RawServoStyleSet* set)
-{
- MOZ_CRASH("stylo: shouldn't be calling Servo_PrependStyleSheet in a "
- "non-MOZ_STYLO build");
-}
-
-void Servo_RemoveStyleSheet(RawServoStyleSheetBorrowed sheet, RawServoStyleSet* set)
-{
- MOZ_CRASH("stylo: shouldn't be calling Servo_RemoveStyleSheet in a "
- "non-MOZ_STYLO build");
-}
-
-void
-Servo_InsertStyleSheetBefore(RawServoStyleSheetBorrowed sheet,
- RawServoStyleSheetBorrowed reference,
- RawServoStyleSet* set)
-{
- MOZ_CRASH("stylo: shouldn't be calling Servo_InsertStyleSheetBefore in a "
- "non-MOZ_STYLO build");
-}
-
-bool
-Servo_StyleSheetHasRules(RawServoStyleSheetBorrowed sheet)
-{
- MOZ_CRASH("stylo: shouldn't be calling Servo_StyleSheetHasRules in a "
- "non-MOZ_STYLO build");
-}
-
-RawServoStyleSet*
-Servo_InitStyleSet()
-{
- MOZ_CRASH("stylo: shouldn't be calling Servo_InitStyleSet in a "
- "non-MOZ_STYLO build");
-}
-
-void
-Servo_DropStyleSet(RawServoStyleSet* set)
-{
- MOZ_CRASH("stylo: shouldn't be calling Servo_DropStyleSet in a "
- "non-MOZ_STYLO build");
-}
-
-ServoDeclarationBlock*
-Servo_ParseStyleAttribute(const uint8_t* bytes, uint32_t length,
- nsHTMLCSSStyleSheet* cache)
-{
- MOZ_CRASH("stylo: shouldn't be calling Servo_ParseStyleAttribute in a "
- "non-MOZ_STYLO build");
-}
-
-void
-Servo_DropDeclarationBlock(ServoDeclarationBlock* declarations)
-{
- MOZ_CRASH("stylo: shouldn't be calling Servo_DropDeclarationBlock in a "
- "non-MOZ_STYLO build");
-}
-
-nsHTMLCSSStyleSheet*
-Servo_GetDeclarationBlockCache(ServoDeclarationBlock* declarations)
-{
- MOZ_CRASH("stylo: shouldn't be calling Servo_GetDeclarationBlockCache in a "
- "non-MOZ_STYLO build");
-}
-
-void
-Servo_SetDeclarationBlockImmutable(ServoDeclarationBlock* declarations)
-{
- MOZ_CRASH("stylo: shouldn't be calling Servo_SetDeclarationBlockImmutable in a "
- "non-MOZ_STYLO build");
-}
-
-void
-Servo_ClearDeclarationBlockCachePointer(ServoDeclarationBlock* declarations)
-{
- MOZ_CRASH("stylo: shouldn't be calling Servo_ClearDeclarationBlockCachePointer in a "
- "non-MOZ_STYLO build");
-}
-
-bool
-Servo_CSSSupports(const uint8_t* name, uint32_t name_length,
- const uint8_t* value, uint32_t value_length)
-{
- MOZ_CRASH("stylo: shouldn't be calling Servo_CSSSupports in a "
- "non-MOZ_STYLO build");
-}
-
-ServoComputedValuesStrong
-Servo_GetComputedValues(RawGeckoNode* node)
-{
- MOZ_CRASH("stylo: shouldn't be calling Servo_GetComputedValues in a "
- "non-MOZ_STYLO build");
-}
-
-ServoComputedValuesStrong
-Servo_GetComputedValuesForAnonymousBox(ServoComputedValuesBorrowed parentStyleOrNull,
- nsIAtom* pseudoTag,
- RawServoStyleSet* set)
-{
- MOZ_CRASH("stylo: shouldn't be calling Servo_GetComputedValuesForAnonymousBox in a "
- "non-MOZ_STYLO build");
-}
-
-ServoComputedValuesStrong
-Servo_GetComputedValuesForPseudoElement(ServoComputedValuesBorrowed parent_style,
- RawGeckoElement* match_element,
- nsIAtom* pseudo_tag,
- RawServoStyleSet* set,
- bool is_probe)
-{
- MOZ_CRASH("stylo: shouldn't be calling Servo_GetComputedValuesForPseudoElement in a "
- "non-MOZ_STYLO build");
-}
-
-ServoComputedValuesStrong
-Servo_InheritComputedValues(ServoComputedValuesBorrowed parent_style)
-{
- MOZ_CRASH("stylo: shouldn't be calling Servo_InheritComputedValues in a "
- "non-MOZ_STYLO build");
-}
-
-void
-Servo_AddRefComputedValues(ServoComputedValuesBorrowed)
-{
- MOZ_CRASH("stylo: shouldn't be calling Servo_AddRefComputedValues in a "
- "non-MOZ_STYLO build");
-}
-
-void
-Servo_ReleaseComputedValues(ServoComputedValuesBorrowed)
-{
- MOZ_CRASH("stylo: shouldn't be calling Servo_ReleaseComputedValues in a "
- "non-MOZ_STYLO build");
-}
-
-void
-Servo_Initialize()
-{
- MOZ_CRASH("stylo: shouldn't be calling Servo_Initialize in a "
- "non-MOZ_STYLO build");
-}
-
-void
-Servo_Shutdown()
-{
- MOZ_CRASH("stylo: shouldn't be calling Servo_Shutdown in a "
- "non-MOZ_STYLO build");
-}
-
-// Restyle hints.
-nsRestyleHint
-Servo_ComputeRestyleHint(RawGeckoElement* element,
- ServoElementSnapshot* snapshot, RawServoStyleSet* set)
-{
- MOZ_CRASH("stylo: shouldn't be calling Servo_ComputeRestyleHint in a "
- "non-MOZ_STYLO build");
-}
-
-void
-Servo_RestyleDocument(RawGeckoDocument* doc, RawServoStyleSet* set)
-{
- MOZ_CRASH("stylo: shouldn't be calling Servo_RestyleDocument in a "
- "non-MOZ_STYLO build");
-}
-
-void Servo_RestyleSubtree(RawGeckoNode* node, RawServoStyleSet* set)
-{
- MOZ_CRASH("stylo: shouldn't be calling Servo_RestyleSubtree in a "
- "non-MOZ_STYLO build");
-}
-
-#define STYLE_STRUCT(name_, checkdata_cb_) \
-const nsStyle##name_* \
-Servo_GetStyle##name_(ServoComputedValuesBorrowed) \
-{ \
- MOZ_CRASH("stylo: shouldn't be calling Servo_GetStyle" #name_ " in a " \
- "non-MOZ_STYLO build"); \
-}
-#include "nsStyleStructList.h"
-#undef STYLE_STRUCT
+#define SERVO_BINDING_FUNC(name_, return_, ...) \
+ return_ name_(__VA_ARGS__) { \
+ MOZ_CRASH("stylo: shouldn't be calling " #name_ "in a non-stylo build"); \
+ }
+#include "ServoBindingList.h"
+#undef SERVO_BINDING_FUNC
#endif
#ifdef MOZ_STYLO
const nsStyleVariables*
Servo_GetStyleVariables(ServoComputedValuesBorrowed aComputedValues)
{
// Servo can't provide us with Variables structs yet, so instead of linking
// to a Servo_GetStyleVariables defined in Servo we define one here that
--- a/layout/style/ServoBindings.h
+++ b/layout/style/ServoBindings.h
@@ -154,17 +154,16 @@ SERVO_DECLARE_ELEMENT_ATTR_MATCHING_FUNC
#undef SERVO_DECLARE_ELEMENT_ATTR_MATCHING_FUNCTIONS
// Style attributes.
ServoDeclarationBlock* Gecko_GetServoDeclarationBlock(RawGeckoElement* element);
// Node data.
ServoNodeData* Gecko_GetNodeData(RawGeckoNode* node);
void Gecko_SetNodeData(RawGeckoNode* node, ServoNodeData* data);
-void Servo_DropNodeData(ServoNodeData* data);
// Atoms.
nsIAtom* Gecko_Atomize(const char* aString, uint32_t aLength);
void Gecko_AddRefAtom(nsIAtom* aAtom);
void Gecko_ReleaseAtom(nsIAtom* aAtom);
const uint16_t* Gecko_GetAtomAsUTF16(nsIAtom* aAtom, uint32_t* aLength);
bool Gecko_AtomEqualsUTF8(nsIAtom* aAtom, const char* aString, uint32_t aLength);
bool Gecko_AtomEqualsUTF8IgnoreCase(nsIAtom* aAtom, const char* aString, uint32_t aLength);
@@ -234,89 +233,25 @@ void Gecko_InitializeImageLayer(nsStyleI
// Clean up pointer-based coordinates
void Gecko_ResetStyleCoord(nsStyleUnit* unit, nsStyleUnion* value);
// Set an nsStyleCoord to a computed `calc()` value
void Gecko_SetStyleCoordCalcValue(nsStyleUnit* unit, nsStyleUnion* value, nsStyleCoord::CalcValue calc);
NS_DECL_THREADSAFE_FFI_REFCOUNTING(nsStyleCoord::Calc, Calc);
-// Styleset and Stylesheet management.
-//
-// TODO: Make these return already_AddRefed and UniquePtr when the binding
-// generator is smart enough to handle them.
-RawServoStyleSheetStrong Servo_StylesheetFromUTF8Bytes(
- 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);
-void Servo_AddRefStyleSheet(RawServoStyleSheetBorrowed sheet);
-void Servo_ReleaseStyleSheet(RawServoStyleSheetBorrowed sheet);
-void Servo_AppendStyleSheet(RawServoStyleSheetBorrowed sheet, RawServoStyleSet* set);
-void Servo_PrependStyleSheet(RawServoStyleSheetBorrowed sheet, RawServoStyleSet* set);
-void Servo_RemoveStyleSheet(RawServoStyleSheetBorrowed sheet, RawServoStyleSet* set);
-void Servo_InsertStyleSheetBefore(RawServoStyleSheetBorrowed sheet,
- RawServoStyleSheetBorrowed reference,
- RawServoStyleSet* set);
-bool Servo_StyleSheetHasRules(RawServoStyleSheetBorrowed sheet);
-RawServoStyleSet* Servo_InitStyleSet();
-void Servo_DropStyleSet(RawServoStyleSet* set);
-
-// Style attributes.
-ServoDeclarationBlock* Servo_ParseStyleAttribute(const uint8_t* bytes,
- uint32_t length,
- nsHTMLCSSStyleSheet* cache);
-void Servo_DropDeclarationBlock(ServoDeclarationBlock* declarations);
-nsHTMLCSSStyleSheet* Servo_GetDeclarationBlockCache(
- ServoDeclarationBlock* declarations);
-void Servo_SetDeclarationBlockImmutable(ServoDeclarationBlock* declarations);
-void Servo_ClearDeclarationBlockCachePointer(ServoDeclarationBlock* declarations);
-
-// CSS supports().
-bool Servo_CSSSupports(const uint8_t* name, uint32_t name_length,
- const uint8_t* value, uint32_t value_length);
-
-// Computed style data.
-ServoComputedValuesStrong Servo_GetComputedValues(RawGeckoNode* node);
-ServoComputedValuesStrong Servo_GetComputedValuesForAnonymousBox(ServoComputedValuesBorrowed parentStyleOrNull,
- nsIAtom* pseudoTag,
- RawServoStyleSet* set);
-ServoComputedValuesStrong Servo_GetComputedValuesForPseudoElement(ServoComputedValuesBorrowed parent_style,
- RawGeckoElement* match_element,
- nsIAtom* pseudo_tag,
- RawServoStyleSet* set,
- bool is_probe);
-ServoComputedValuesStrong Servo_InheritComputedValues(ServoComputedValuesBorrowed parent_style);
-void Servo_AddRefComputedValues(ServoComputedValuesBorrowed);
-void Servo_ReleaseComputedValues(ServoComputedValuesBorrowed);
-
-// Initialize Servo components. Should be called exactly once at startup.
-void Servo_Initialize();
-
-// Shut down Servo components. Should be called exactly once at shutdown.
-void Servo_Shutdown();
-
-// Restyle the given document or subtree.
-void Servo_RestyleDocument(RawGeckoDocument* doc, RawServoStyleSet* set);
-void Servo_RestyleSubtree(RawGeckoNode* node, RawServoStyleSet* set);
-
-// Restyle hints.
-nsRestyleHint Servo_ComputeRestyleHint(RawGeckoElement* element,
- ServoElementSnapshot* snapshot,
- RawServoStyleSet* set);
-
// Style-struct management.
#define STYLE_STRUCT(name, checkdata_cb) \
struct nsStyle##name; \
void Gecko_Construct_nsStyle##name(nsStyle##name* ptr); \
void Gecko_CopyConstruct_nsStyle##name(nsStyle##name* ptr, \
const nsStyle##name* other); \
- void Gecko_Destroy_nsStyle##name(nsStyle##name* ptr); \
- const nsStyle##name* Servo_GetStyle##name( \
- ServoComputedValuesBorrowed computedValues);
+ void Gecko_Destroy_nsStyle##name(nsStyle##name* ptr);
#include "nsStyleStructList.h"
#undef STYLE_STRUCT
+#define SERVO_BINDING_FUNC(name_, return_, ...) return_ name_(__VA_ARGS__);
+#include "mozilla/ServoBindingList.h"
+#undef SERVO_BINDING_FUNC
+
} // extern "C"
#endif // mozilla_ServoBindings_h
--- a/layout/style/moz.build
+++ b/layout/style/moz.build
@@ -87,16 +87,17 @@ EXPORTS.mozilla += [
'CSSVariableResolver.h',
'CSSVariableValues.h',
'HandleRefPtr.h',
'IncrementalClearCOMRuleArray.h',
'LayerAnimationInfo.h',
'RuleNodeCacheConditions.h',
'RuleProcessorCache.h',
'ServoBindingHelpers.h',
+ 'ServoBindingList.h',
'ServoBindings.h',
'ServoElementSnapshot.h',
'ServoStyleSet.h',
'ServoStyleSheet.h',
'SheetType.h',
'StyleAnimationValue.h',
'StyleBackendType.h',
'StyleContextSource.h',