Bug 1437502: Introduce AuthorStyles. r?xidorn draft
authorEmilio Cobos Álvarez <emilio@crisal.io>
Mon, 12 Feb 2018 13:57:26 +0100
changeset 753785 ff088dfa2b0af11fd705221996077d7ce60ce6e4
parent 753713 c78915dcc887dbb38fa11adf288bbdccce10b906
child 754344 410006fa99e508e96bb2d3a389ad42b6f51af550
push id98681
push userbmo:emilio@crisal.io
push dateMon, 12 Feb 2018 13:04:46 +0000
reviewersxidorn
bugs1437502
milestone60.0a1
Bug 1437502: Introduce AuthorStyles. r?xidorn It's just a struct aggregating stylesheets + CascadeData, with a quirks_mode parameter because XBL sucks so bad. MozReview-Commit-ID: 7q99tSNXo0K
layout/style/ServoBindingTypes.h
layout/style/ServoBindings.toml
servo/components/style/author_styles.rs
servo/components/style/lib.rs
--- a/layout/style/ServoBindingTypes.h
+++ b/layout/style/ServoBindingTypes.h
@@ -10,16 +10,17 @@
 #include "mozilla/RefPtr.h"
 #include "mozilla/ServoTypes.h"
 #include "mozilla/UniquePtr.h"
 #include "mozilla/gfx/Types.h"
 #include "nsCSSPropertyID.h"
 #include "nsStyleAutoArray.h"
 #include "nsTArray.h"
 
+struct RawServoAuthorStyles;
 struct RawServoStyleSet;
 struct RawServoSelectorList;
 struct RawServoSourceSizeList;
 struct RawServoAnimationValueMap;
 struct RustString;
 
 #define SERVO_ARC_TYPE(name_, type_) struct type_;
 #include "mozilla/ServoArcTypeList.h"
@@ -131,16 +132,17 @@ struct MOZ_MUST_USE_TYPE ServoStyleConte
   typedef type_* type_##OwnedOrNull;               \
   DECL_NULLABLE_BORROWED_REF_TYPE_FOR(type_)       \
   DECL_NULLABLE_BORROWED_MUT_REF_TYPE_FOR(type_)
 
 // This is a reference to a reference of RawServoDeclarationBlock, which
 // corresponds to Option<&Arc<RawServoDeclarationBlock>> in Servo side.
 DECL_NULLABLE_BORROWED_REF_TYPE_FOR(RawServoDeclarationBlockStrong)
 
+DECL_OWNED_REF_TYPE_FOR(RawServoAuthorStyles)
 DECL_OWNED_REF_TYPE_FOR(RawServoStyleSet)
 DECL_NULLABLE_BORROWED_REF_TYPE_FOR(RawServoStyleSet)
 DECL_NULLABLE_OWNED_REF_TYPE_FOR(StyleChildrenIterator)
 DECL_OWNED_REF_TYPE_FOR(StyleChildrenIterator)
 DECL_OWNED_REF_TYPE_FOR(ServoElementSnapshot)
 DECL_OWNED_REF_TYPE_FOR(RawServoAnimationValueMap)
 
 // We don't use BorrowedMut because the nodes may alias
@@ -223,14 +225,15 @@ DECL_NULLABLE_BORROWED_REF_TYPE_FOR(RawS
     void operator()(type_* aPtr) const                      \
     {                                                       \
       Servo_##name_##_Drop(aPtr);                           \
     }                                                       \
   };                                                        \
   }
 
 DEFINE_BOXED_TYPE(StyleSet, RawServoStyleSet);
+DEFINE_BOXED_TYPE(AuthorStyles, RawServoAuthorStyles);
 DEFINE_BOXED_TYPE(SelectorList, RawServoSelectorList);
 DEFINE_BOXED_TYPE(SourceSizeList, RawServoSourceSizeList);
 
 #undef DEFINE_BOXED_TYPE
 
 #endif // mozilla_ServoBindingTypes_h
--- a/layout/style/ServoBindings.toml
+++ b/layout/style/ServoBindings.toml
@@ -613,16 +613,17 @@ structs-types = [
     "FontFamilyName",
     "mozilla::SharedFontList",
 ]
 array-types = [
     { cpp-type = "uintptr_t", rust-type = "usize" },
 ]
 servo-owned-types = [
     { name = "RawServoStyleSet", opaque = true },
+    { name = "RawServoAuthorStyles", opaque = true },
     { name = "RawServoSelectorList", opaque = false },
     { name = "RawServoSourceSizeList", opaque = false },
     { name = "ServoElementSnapshot", opaque = false },
     { name = "RawServoAnimationValueMap", opaque = true },
 ]
 servo-immutable-borrow-types = [
     "RawGeckoNode",
     "RawGeckoElement",
new file mode 100644
--- /dev/null
+++ b/servo/components/style/author_styles.rs
@@ -0,0 +1,31 @@
+/* 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 set of author stylesheets and their computed representation, such as the
+//! ones used for ShadowRoot and XBL.
+
+use context::QuirksMode;
+use stylesheet_set::AuthorStylesheetSet;
+
+/// A set of author stylesheets and their computed representation, such as the
+/// ones used for ShadowRoot and XBL.
+pub struct AuthorStyles {
+    /// The sheet collection, which holds the sheet pointers, the invalidations,
+    /// and all that stuff.
+    pub stylesheets: AuthorStylesheetSet,
+    /// The actual cascade data computed from the stylesheets.
+    pub data: CascadeData,
+    /// The quirks mode of the last stylesheet flush, used because XBL sucks and
+    /// we should really fix it, see bug 1406875.
+    pub quirks_mode: QuirksMode,
+}
+
+#[cfg(feature = "gecko")]
+unsafe impl HasFFI for AuthorStyles {
+    type FFIType = ::gecko_bindings::structs::RawServoAuthorStyles;
+}
+#[cfg(feature = "gecko")]
+unsafe impl HasSimpleFFI for PerDocumentStyleData {}
+#[cfg(feature = "gecko")]
+unsafe impl HasBoxFFI for PerDocumentStyleData {}
--- a/servo/components/style/lib.rs
+++ b/servo/components/style/lib.rs
@@ -82,16 +82,17 @@ extern crate void;
 
 #[macro_use]
 mod macros;
 
 #[cfg(feature = "servo")] pub mod animation;
 pub mod applicable_declarations;
 #[allow(missing_docs)] // TODO.
 #[cfg(feature = "servo")] pub mod attr;
+#[cfg(feature = "servo")] pub mod author_styles;
 pub mod bezier;
 pub mod bloom;
 pub mod context;
 pub mod counter_style;
 pub mod custom_properties;
 pub mod data;
 pub mod dom;
 pub mod dom_apis;