Bug 1498755 - Part 6: Move some C++ types from ServoBindingTypes.h to ServoTypes.h r=emilio
authorCameron McCormack <cam@mcc.id.au>
Sun, 14 Oct 2018 00:05:56 +0000
changeset 489538 77e7f45a9c3d23544adec8ac3f986401d4c288fc
parent 489537 7c22eed0a6de3dfaf527eda236dda01e064c1010
child 489539 0c14eb604558caf0108f55078b95bcdb036453e3
push id247
push userfmarier@mozilla.com
push dateSat, 27 Oct 2018 01:06:44 +0000
reviewersemilio
bugs1498755
milestone64.0a1
Bug 1498755 - Part 6: Move some C++ types from ServoBindingTypes.h to ServoTypes.h r=emilio Depends on D8647 Differential Revision: https://phabricator.services.mozilla.com/D8648
layout/style/GeckoBindings.h
layout/style/ServoBindingTypes.h
layout/style/ServoBindings.h
layout/style/ServoBindings.toml
layout/style/ServoComputedData.h
layout/style/ServoTypes.h
layout/style/nsCSSValue.h
layout/style/nsDOMCSSAttrDeclaration.h
layout/style/nsDOMCSSDeclaration.h
--- a/layout/style/GeckoBindings.h
+++ b/layout/style/GeckoBindings.h
@@ -32,17 +32,16 @@ namespace mozilla {
   class ServoElementSnapshotTable;
   class SharedFontList;
   class StyleSheet;
   enum class CSSPseudoElementType : uint8_t;
   enum class PointerCapabilities : uint8_t;
   enum class UpdateAnimationsTasks : uint8_t;
   struct FontFamilyName;
   struct Keyframe;
-  struct LangGroupFontPrefs;
 
   namespace css {
     class LoaderReusableStyleSheets;
   }
 }
 
 #ifdef NIGHTLY_BUILD
 const bool GECKO_IS_NIGHTLY = true;
@@ -78,28 +77,16 @@ class ServoBundledURI
 public:
   // NOTE(emilio): Not calling IntoCssUrl will cause to leak the
   // string, so don't do that :)
   already_AddRefed<mozilla::css::URLValue> IntoCssUrl(mozilla::CORSMode);
   mozilla::ServoRawOffsetArc<RustString> mURLString;
   mozilla::URLExtraData* mExtraData;
 };
 
-struct FontSizePrefs
-{
-  void CopyFrom(const mozilla::LangGroupFontPrefs&);
-  nscoord mDefaultVariableSize;
-  nscoord mDefaultFixedSize;
-  nscoord mDefaultSerifSize;
-  nscoord mDefaultSansSerifSize;
-  nscoord mDefaultMonospaceSize;
-  nscoord mDefaultCursiveSize;
-  nscoord mDefaultFantasySize;
-};
-
 // Debugging stuff.
 void Gecko_Element_DebugListAttributes(RawGeckoElementBorrowed, nsCString*);
 void Gecko_Snapshot_DebugListAttributes(const mozilla::ServoElementSnapshot*, nsCString*);
 
 bool Gecko_IsSignificantChild(RawGeckoNodeBorrowed node, bool whitespace_is_significant);
 RawGeckoNodeBorrowedOrNull Gecko_GetLastChild(RawGeckoNodeBorrowed node);
 RawGeckoNodeBorrowedOrNull Gecko_GetPreviousSibling(RawGeckoNodeBorrowed node);
 RawGeckoNodeBorrowedOrNull Gecko_GetFlattenedTreeParentNode(RawGeckoNodeBorrowed node);
@@ -571,17 +558,17 @@ void Gecko_nsStyleFont_SetLang(nsStyleFo
 void Gecko_nsStyleFont_CopyLangFrom(nsStyleFont* aFont, const nsStyleFont* aSource);
 void Gecko_nsStyleFont_FixupNoneGeneric(nsStyleFont* font,
                                         RawGeckoPresContextBorrowed pres_context);
 void Gecko_nsStyleFont_PrefillDefaultForGeneric(nsStyleFont* font,
                                                 RawGeckoPresContextBorrowed pres_context,
                                                 uint8_t generic_id);
 void Gecko_nsStyleFont_FixupMinFontSize(nsStyleFont* font,
                                         RawGeckoPresContextBorrowed pres_context);
-FontSizePrefs Gecko_GetBaseSize(nsAtom* lang);
+mozilla::FontSizePrefs Gecko_GetBaseSize(nsAtom* lang);
 
 // XBL related functions.
 RawGeckoElementBorrowedOrNull Gecko_GetBindingParent(RawGeckoElementBorrowed aElement);
 RawServoAuthorStylesBorrowedOrNull Gecko_XBLBinding_GetRawServoStyles(RawGeckoXBLBindingBorrowed aXBLBinding);
 bool Gecko_XBLBinding_InheritsStyle(RawGeckoXBLBindingBorrowed aXBLBinding);
 
 struct GeckoFontMetrics
 {
--- a/layout/style/ServoBindingTypes.h
+++ b/layout/style/ServoBindingTypes.h
@@ -5,17 +5,16 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef mozilla_ServoBindingTypes_h
 #define mozilla_ServoBindingTypes_h
 
 #include "mozilla/RefPtr.h"
 #include "mozilla/ServoComputedData.h"
 #include "mozilla/ServoTypes.h"
-#include "mozilla/SheetType.h"
 #include "mozilla/UniquePtr.h"
 #include "mozilla/gfx/Types.h"
 #include "nsCSSPropertyID.h"
 #include "nsStyleAutoArray.h"
 #include "nsTArray.h"
 
 struct RawServoAuthorStyles;
 struct RawServoStyleSet;
@@ -79,25 +78,16 @@ typedef nsStyleAutoArray<mozilla::StyleA
 typedef nsTArray<nsFontFaceRuleContainer> RawGeckoFontFaceRuleList;
 typedef mozilla::AnimationPropertySegment RawGeckoAnimationPropertySegment;
 typedef mozilla::ComputedTiming RawGeckoComputedTiming;
 typedef nsTArray<const RawServoStyleRule*> RawGeckoServoStyleRuleList;
 typedef nsTArray<nsCSSPropertyID> RawGeckoCSSPropertyIDList;
 typedef mozilla::gfx::Float RawGeckoGfxMatrix4x4[16];
 typedef mozilla::dom::StyleChildrenIterator RawGeckoStyleChildrenIterator;
 
-// A callback that can be sent via FFI which will be invoked _right before_
-// being mutated, and at most once.
-struct DeclarationBlockMutationClosure
-{
-  // The callback function. The argument is `data`.
-  void (*function)(void*) = nullptr;
-  void* data = nullptr;
-};
-
 // We have these helper types so that we can directly generate
 // things like &T or Borrowed<T> on the Rust side in the function, providing
 // additional safety benefits.
 //
 // FFI has a problem with templated types, so we just use raw pointers here.
 //
 // The "Borrowed" types generate &T or Borrowed<T> in the nullable case.
 //
@@ -248,31 +238,18 @@ DECL_NULLABLE_BORROWED_REF_TYPE_FOR(Styl
 DEFINE_BOXED_TYPE(StyleSet, RawServoStyleSet);
 DEFINE_BOXED_TYPE(AuthorStyles, RawServoAuthorStyles);
 DEFINE_BOXED_TYPE(SelectorList, RawServoSelectorList);
 DEFINE_BOXED_TYPE(SourceSizeList, RawServoSourceSizeList);
 DEFINE_BOXED_TYPE(UseCounters, StyleUseCounters);
 
 #undef DEFINE_BOXED_TYPE
 
-// used for associating sheet type with specific @font-face rules
-struct nsFontFaceRuleContainer
-{
-  RefPtr<RawServoFontFaceRule> mRule;
-  mozilla::SheetType mSheetType;
-};
-
 #define DEFINE_ARRAY_TYPE_FOR(type_)                                \
   struct nsTArrayBorrowed_##type_ {                                 \
     nsTArray<type_>* mArray;                                        \
     MOZ_IMPLICIT nsTArrayBorrowed_##type_(nsTArray<type_>* aArray)  \
       : mArray(aArray) {}                                           \
   }
 DEFINE_ARRAY_TYPE_FOR(uintptr_t);
 #undef DEFINE_ARRAY_TYPE_FOR
 
-struct MediumFeaturesChangedResult {
-  bool mAffectsDocumentRules;
-  bool mAffectsNonDocumentRules;
-  bool mUsesViewportUnits;
-};
-
 #endif // mozilla_ServoBindingTypes_h
--- a/layout/style/ServoBindings.h
+++ b/layout/style/ServoBindings.h
@@ -135,17 +135,17 @@ void Servo_StyleSheet_GetSourceURL(
 uint8_t Servo_StyleSheet_GetOrigin(RawServoStyleSheetContentsBorrowed sheet);
 
 RawServoStyleSet* Servo_StyleSet_Init(RawGeckoPresContextOwned pres_context);
 void Servo_StyleSet_RebuildCachedData(RawServoStyleSetBorrowed set);
 
 // We'd like to return `OriginFlags` here, but bindgen bitfield enums don't
 // work as return values with the Linux 32-bit ABI at the moment because
 // they wrap the value in a struct.
-MediumFeaturesChangedResult Servo_StyleSet_MediumFeaturesChanged(
+mozilla::MediumFeaturesChangedResult Servo_StyleSet_MediumFeaturesChanged(
   RawServoStyleSetBorrowed document_set,
   nsTArray<RawServoAuthorStylesBorrowedMut>* non_document_sets,
   bool may_affect_default_style);
 
 void Servo_StyleSet_Drop(RawServoStyleSetOwned set);
 void Servo_StyleSet_CompatModeChanged(RawServoStyleSetBorrowed raw_data);
 
 void Servo_StyleSet_AppendStyleSheet(
@@ -744,42 +744,42 @@ bool Servo_DeclarationBlock_SetProperty(
   RawServoDeclarationBlockBorrowed declarations,
   const nsACString* property,
   const nsACString* value,
   bool is_important,
   RawGeckoURLExtraData* data,
   mozilla::ParsingMode parsing_mode,
   nsCompatibility quirks_mode,
   mozilla::css::Loader* loader,
-  DeclarationBlockMutationClosure);
+  mozilla::DeclarationBlockMutationClosure);
 
 bool Servo_DeclarationBlock_SetPropertyToAnimationValue(
   RawServoDeclarationBlockBorrowed declarations,
   RawServoAnimationValueBorrowed animation_value);
 
 bool Servo_DeclarationBlock_SetPropertyById(
   RawServoDeclarationBlockBorrowed declarations,
   nsCSSPropertyID property,
   const nsACString* value,
   bool is_important,
   RawGeckoURLExtraData* data,
   mozilla::ParsingMode parsing_mode,
   nsCompatibility quirks_mode,
   mozilla::css::Loader* loader,
-  DeclarationBlockMutationClosure);
+  mozilla::DeclarationBlockMutationClosure);
 
 bool Servo_DeclarationBlock_RemoveProperty(
   RawServoDeclarationBlockBorrowed declarations,
   const nsACString* property,
-  DeclarationBlockMutationClosure);
+  mozilla::DeclarationBlockMutationClosure);
 
 bool Servo_DeclarationBlock_RemovePropertyById(
   RawServoDeclarationBlockBorrowed declarations,
   nsCSSPropertyID property,
-  DeclarationBlockMutationClosure);
+  mozilla::DeclarationBlockMutationClosure);
 
 bool Servo_DeclarationBlock_HasCSSWideKeyword(
   RawServoDeclarationBlockBorrowed declarations,
   nsCSSPropertyID property);
 
 // Compose animation value for a given property.
 // |base_values| is nsRefPtrHashtable<nsUint32HashKey, RawServoAnimationValue>.
 // We use RawServoAnimationValueTableBorrowed to avoid exposing
--- a/layout/style/ServoBindings.toml
+++ b/layout/style/ServoBindings.toml
@@ -222,17 +222,17 @@ whitelist-vars = [
     "kNameSpaceID_.*",
     "kGenericFont_.*",
     "kPresContext_.*",
     "nsContentUtils_.*",
     "GECKO_IS_NIGHTLY",
 ]
 whitelist-types = [
     "RawGecko.*",
-    "DeclarationBlockMutationClosure",
+    "mozilla::DeclarationBlockMutationClosure",
     "mozilla::AnimationPropertySegment",
     "mozilla::AnonymousCounterStyle",
     "mozilla::AtomArray",
     "mozilla::ComputedTiming",
     "mozilla::ComputedTimingFunction",
     "mozilla::ComputedTimingFunction::BeforeFlag",
     "mozilla::SeenPtrs",
     "mozilla::ServoElementSnapshot.*",
@@ -276,29 +276,29 @@ whitelist-types = [
     "AnonymousContent",
     "AudioContext",
     "CapturingContentInfo",
     "DefaultDelete",
     "DOMIntersectionObserverEntry",
     "Element",
     "FontFamilyList",
     "FontFamilyName",
-    "FontSizePrefs",
+    "mozilla::FontSizePrefs",
     "FragmentOrURL",
     "FrameRequestCallback",
     "GeckoParserExtraData",
     "GeckoFontMetrics",
     "gfxAlternateValue",
     "gfxFontFeatureValueSet",
     "GridNamedArea",
     "mozilla::HalfCorner",
     "Image",
     "ImageURL",
     "Keyframe",
-    "MediumFeaturesChangedResult",
+    "mozilla::MediumFeaturesChangedResult",
     "nsAttrName",
     "nsAttrValue",
     "nscolor",
     "nsChangeHint",
     "nsCSSCounterDesc",
     "nsCSSFontDesc",
     "nsCSSKTableEntry",
     "nsCSSKeyword",
@@ -503,24 +503,24 @@ structs-types = [
     "mozilla::StyleComputedFontWeightRange",
     "mozilla::StyleFontDisplay",
     "mozilla::StyleUnicodeRange",
     "mozilla::StyleFontLanguageOverride",
     "mozilla::StyleFontFaceSourceListComponent",
     "gfxFontFeature",
     "mozilla::gfx::FontVariation",
     "ServoRawOffsetArc",
-    "DeclarationBlockMutationClosure",
+    "mozilla::DeclarationBlockMutationClosure",
     "nsAttrValue",
     "nsIContent",
     "nsINode",
     "nsIDocument",
     "nsIDocument_DocumentTheme",
     "nsSimpleContentList",
-    "MediumFeaturesChangedResult",
+    "mozilla::MediumFeaturesChangedResult",
     "RawGeckoAnimationPropertySegment",
     "RawGeckoComputedTiming",
     "RawGeckoCSSPropertyIDList",
     "RawGeckoDocument",
     "RawGeckoElement",
     "Element",
     "RawGeckoKeyframeList",
     "RawGeckoPropertyValuePairList",
@@ -546,17 +546,17 @@ structs-types = [
     "RefPtr",
     "RustString",
     "StyleUseCounters",
     "CSSPseudoElementType",
     "ServoTraversalFlags",
     "ComputedTimingFunction_BeforeFlag",
     "CounterStylePtr",
     "FontFamilyType",
-    "FontSizePrefs",
+    "mozilla::FontSizePrefs",
     "GeckoFontMetrics",
     "IterationCompositeOperation",
     "Keyframe",
     "PropertyValuePair",
     "SeenPtrs",
     "ServoBundledURI",
     "ServoElementSnapshot",
     "ServoElementSnapshotTable",
--- a/layout/style/ServoComputedData.h
+++ b/layout/style/ServoComputedData.h
@@ -2,53 +2,63 @@
 /* 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_ServoComputedData_h
 #define mozilla_ServoComputedData_h
 
-#include "mozilla/ServoTypes.h"
-
 class nsWindowSizes;
 
 /*
  * ServoComputedData and its related types.
  */
 
 #define STYLE_STRUCT(name_) struct nsStyle##name_;
 #include "nsStyleStructList.h"
 #undef STYLE_STRUCT
 
 namespace mozilla {
 
-struct ServoWritingMode {
+template<typename T>
+struct ServoRawOffsetArc
+{
+  // This is a pointer to a T that lives inside a servo_arc::Arc<T>, and
+  // which already has had its reference count incremented.
+  T* mPtr;
+};
+
+struct ServoWritingMode
+{
   uint8_t mBits;
 };
 
-struct ServoCustomPropertiesMap {
+struct ServoCustomPropertiesMap
+{
   uintptr_t mPtr;
 };
 
-struct ServoRuleNode {
+struct ServoRuleNode
+{
   uintptr_t mPtr;
 };
 
 class ComputedStyle;
 
-struct ServoVisitedStyle {
-  // This is actually a strong reference
-  // but ServoComputedData's destructor is
-  // managed by the Rust code so we just use a
-  // regular pointer
+struct ServoVisitedStyle
+{
+  // This is actually a strong reference but ServoComputedData's
+  // destructor is managed by the Rust code so we just use a regular
+  // pointer
   ComputedStyle* mPtr;
 };
 
-struct ServoComputedValueFlags {
+struct ServoComputedValueFlags
+{
   uint16_t mFlags;
 };
 
 #define STYLE_STRUCT(name_) struct Gecko##name_;
 #include "nsStyleStructList.h"
 #undef STYLE_STRUCT
 
 } // namespace mozilla
--- a/layout/style/ServoTypes.h
+++ b/layout/style/ServoTypes.h
@@ -1,23 +1,36 @@
 /* -*- 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/. */
 
+/* types defined to pass values through Gecko_* and Servo_* FFI functions */
+
 #ifndef mozilla_ServoTypes_h
 #define mozilla_ServoTypes_h
 
+#include "mozilla/RefPtr.h"
+#include "mozilla/SheetType.h"
 #include "mozilla/TypedEnumBits.h"
+#include "nsCoord.h"
+
+struct RawServoFontFaceRule;
 
-/*
- * Type definitions used to interact with Servo. This gets included by nsINode,
- * so don't add significant include dependencies to this file.
- */
+namespace mozilla {
+  struct LangGroupFontPrefs;
+}
+
+// used for associating sheet type with specific @font-face rules
+struct nsFontFaceRuleContainer
+{
+  RefPtr<RawServoFontFaceRule> mRule;
+  mozilla::SheetType mSheetType;
+};
 
 namespace mozilla {
 
 // Indicates whether the Servo style system should expect the style on an element
 // to have already been resolved (i.e. via a parallel traversal), or whether it
 // may be lazily computed.
 enum class LazyComputeBehavior {
   Allow,
@@ -129,18 +142,39 @@ public:
     , mPrecomputedPseudos(0)
     , mElementAndPseudosMaps(0)
     , mInvalidationMap(0)
     , mRevalidationSelectors(0)
     , mOther(0)
   {}
 };
 
-template <typename T>
-struct ServoRawOffsetArc {
-  // Again, a strong reference, but
-  // managed by the Rust code
-  T* mPtr;
+// A callback that can be sent via FFI which will be invoked _right before_
+// being mutated, and at most once.
+struct DeclarationBlockMutationClosure
+{
+  // The callback function. The argument is `data`.
+  void (*function)(void*) = nullptr;
+  void* data = nullptr;
+};
+
+struct MediumFeaturesChangedResult
+{
+  bool mAffectsDocumentRules;
+  bool mAffectsNonDocumentRules;
+  bool mUsesViewportUnits;
+};
+
+struct FontSizePrefs
+{
+  void CopyFrom(const mozilla::LangGroupFontPrefs&);
+  nscoord mDefaultVariableSize;
+  nscoord mDefaultFixedSize;
+  nscoord mDefaultSerifSize;
+  nscoord mDefaultSansSerifSize;
+  nscoord mDefaultMonospaceSize;
+  nscoord mDefaultCursiveSize;
+  nscoord mDefaultFantasySize;
 };
 
 } // namespace mozilla
 
 #endif // mozilla_ServoTypes_h
--- a/layout/style/nsCSSValue.h
+++ b/layout/style/nsCSSValue.h
@@ -8,17 +8,17 @@
 
 #ifndef nsCSSValue_h___
 #define nsCSSValue_h___
 
 #include "mozilla/Attributes.h"
 #include "mozilla/CORSMode.h"
 #include "mozilla/FontPropertyTypes.h"
 #include "mozilla/MemoryReporting.h"
-#include "mozilla/ServoTypes.h"
+#include "mozilla/ServoBindingTypes.h"
 #include "mozilla/SheetType.h"
 #include "mozilla/URLExtraData.h"
 #include "mozilla/UniquePtr.h"
 
 #include "nsCSSKeywords.h"
 #include "nsCSSPropertyID.h"
 #include "nsCoord.h"
 #include "nsProxyRelease.h"
--- a/layout/style/nsDOMCSSAttrDeclaration.h
+++ b/layout/style/nsDOMCSSAttrDeclaration.h
@@ -53,17 +53,17 @@ public:
 
   nsresult SetPropertyValue(const nsCSSPropertyID aPropID,
                             const nsAString& aValue,
                             nsIPrincipal* aSubjectPrincipal) override;
 
   static void MutationClosureFunction(void* aData);
 
   void
-  GetPropertyChangeClosure(DeclarationBlockMutationClosure* aClosure,
+  GetPropertyChangeClosure(mozilla::DeclarationBlockMutationClosure* aClosure,
                            mozilla::MutationClosureData* aClosureData) final
   {
     if (!mIsSMILOverride) {
       aClosure->function = MutationClosureFunction;
       aClosure->data = aClosureData;
       aClosureData->mClosure = MutationClosureFunction;
       aClosureData->mElement = mElement;
     }
--- a/layout/style/nsDOMCSSDeclaration.h
+++ b/layout/style/nsDOMCSSDeclaration.h
@@ -18,20 +18,20 @@
 #include "nsIURI.h"
 #include "nsCOMPtr.h"
 #include "nsCompatibility.h"
 
 class nsIPrincipal;
 class nsIDocument;
 struct JSContext;
 class JSObject;
-struct DeclarationBlockMutationClosure;
 
 namespace mozilla {
 class DeclarationBlock;
+struct DeclarationBlockMutationClosure;
 namespace css {
 class Loader;
 class Rule;
 } // namespace css
 namespace dom {
 class Element;
 }
 
@@ -214,17 +214,17 @@ protected:
                                     const nsAString& aPropValue,
                                     bool aIsImportant,
                                     nsIPrincipal* aSubjectPrincipal);
 
   nsresult RemovePropertyInternal(nsCSSPropertyID aPropID);
   nsresult RemovePropertyInternal(const nsAString& aProperty);
 
   virtual void
-  GetPropertyChangeClosure(DeclarationBlockMutationClosure* aClosure,
+  GetPropertyChangeClosure(mozilla::DeclarationBlockMutationClosure* aClosure,
                            mozilla::MutationClosureData* aClosureData)
   {
   }
 
 protected:
   virtual ~nsDOMCSSDeclaration();
 
 private: