From 89087437192070b6c2408c32ab8e90a276adaa23 Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Wed, 4 Jan 2017 13:33:00 -0500 Subject: [PATCH] Bug 1298588 part 2, servo piece. Pass through an nsPresContext to the PerDocumentStyleData constructor. r=bholley --- components/style/build_gecko.rs | 3 +++ components/style/gecko/data.rs | 4 +++- components/style/gecko_bindings/bindings.rs | 6 +++++- components/style/gecko_bindings/structs_debug.rs | 2 ++ components/style/gecko_bindings/structs_release.rs | 2 ++ ports/geckolib/glue.rs | 6 ++++-- 6 files changed, 19 insertions(+), 4 deletions(-) diff --git a/components/style/build_gecko.rs b/components/style/build_gecko.rs index 21f8b05dbf6..2eec1be1ce3 100644 --- a/components/style/build_gecko.rs +++ b/components/style/build_gecko.rs @@ -392,6 +392,7 @@ mod bindings { // for clang. "nsPIDOMWindow", // <- Takes the vtable from a template parameter, and we can't // generate it conditionally. + "RawGeckoPresContext", // Just passing it through. "JS::Rooted", "mozilla::Maybe", "gfxSize", // <- union { struct { T width; T height; }; T components[2] }; @@ -467,6 +468,7 @@ mod bindings { "RawGeckoDocument", "RawGeckoElement", "RawGeckoNode", + "RawGeckoPresContext", "ThreadSafeURIHolder", "ThreadSafePrincipalHolder", "ConsumeStyleBehavior", @@ -560,6 +562,7 @@ mod bindings { "RawGeckoElement", "RawGeckoDocument", "RawServoDeclarationBlockStrong", + "RawGeckoPresContext", ]; let servo_borrow_types = [ "nsCSSValue", diff --git a/components/style/gecko/data.rs b/components/style/gecko/data.rs index f67e3871bbc..c0b9dbff4ce 100644 --- a/components/style/gecko/data.rs +++ b/components/style/gecko/data.rs @@ -8,6 +8,7 @@ use animation::Animation; use atomic_refcell::{AtomicRef, AtomicRefCell, AtomicRefMut}; use dom::OpaqueNode; use euclid::size::TypedSize2D; +use gecko_bindings::bindings::RawGeckoPresContextBorrowed; use gecko_bindings::bindings::RawServoStyleSet; use gecko_bindings::sugar::ownership::{HasBoxFFI, HasFFI, HasSimpleFFI}; use media_queries::{Device, MediaType}; @@ -73,7 +74,8 @@ lazy_static! { impl PerDocumentStyleData { /// Create a dummy `PerDocumentStyleData`. - pub fn new() -> Self { + #[allow(unused_variables)] // temporary until we make use of the ctor arg. + pub fn new(pres_context: RawGeckoPresContextBorrowed) -> Self { // FIXME(bholley): Real window size. let window_size: TypedSize2D = TypedSize2D::new(800.0, 600.0); let device = Device::new(MediaType::Screen, window_size); diff --git a/components/style/gecko_bindings/bindings.rs b/components/style/gecko_bindings/bindings.rs index 77a2fb2712d..60880449382 100644 --- a/components/style/gecko_bindings/bindings.rs +++ b/components/style/gecko_bindings/bindings.rs @@ -6,6 +6,7 @@ type nsAString_internal = nsAString; use gecko_bindings::structs::RawGeckoDocument; use gecko_bindings::structs::RawGeckoElement; use gecko_bindings::structs::RawGeckoNode; +use gecko_bindings::structs::RawGeckoPresContext; use gecko_bindings::structs::ThreadSafeURIHolder; use gecko_bindings::structs::ThreadSafePrincipalHolder; use gecko_bindings::structs::ConsumeStyleBehavior; @@ -206,6 +207,8 @@ pub type RawGeckoDocumentBorrowed<'a> = &'a RawGeckoDocument; pub type RawGeckoDocumentBorrowedOrNull<'a> = Option<&'a RawGeckoDocument>; pub type RawServoDeclarationBlockStrongBorrowed<'a> = &'a RawServoDeclarationBlockStrong; pub type RawServoDeclarationBlockStrongBorrowedOrNull<'a> = Option<&'a RawServoDeclarationBlockStrong>; +pub type RawGeckoPresContextBorrowed<'a> = &'a RawGeckoPresContext; +pub type RawGeckoPresContextBorrowedOrNull<'a> = Option<&'a RawGeckoPresContext>; pub type nsCSSValueBorrowed<'a> = &'a nsCSSValue; pub type nsCSSValueBorrowedOrNull<'a> = Option<&'a nsCSSValue>; pub type nsCSSValueBorrowedMut<'a> = &'a mut nsCSSValue; @@ -1028,7 +1031,8 @@ extern "C" { -> ServoCssRulesStrong; } extern "C" { - pub fn Servo_StyleSet_Init() -> RawServoStyleSetOwned; + pub fn Servo_StyleSet_Init(pres_context: RawGeckoPresContextBorrowed) + -> RawServoStyleSetOwned; } extern "C" { pub fn Servo_StyleSet_AppendStyleSheet(set: RawServoStyleSetBorrowed, diff --git a/components/style/gecko_bindings/structs_debug.rs b/components/style/gecko_bindings/structs_debug.rs index 4f51b9b523a..25ed0cb366f 100644 --- a/components/style/gecko_bindings/structs_debug.rs +++ b/components/style/gecko_bindings/structs_debug.rs @@ -11613,12 +11613,14 @@ pub mod root { pub type RawGeckoNode = root::nsINode; pub type RawGeckoElement = root::mozilla::dom::Element; pub type RawGeckoDocument = root::nsIDocument; + pub type RawGeckoPresContext = [u64; 156usize]; pub type RawGeckoNodeBorrowed = *const root::RawGeckoNode; pub type RawGeckoNodeBorrowedOrNull = *const root::RawGeckoNode; pub type RawGeckoElementBorrowed = *const root::RawGeckoElement; pub type RawGeckoElementBorrowedOrNull = *const root::RawGeckoElement; pub type RawGeckoDocumentBorrowed = *const root::RawGeckoDocument; pub type RawGeckoDocumentBorrowedOrNull = *const root::RawGeckoDocument; + pub type RawGeckoPresContextBorrowed = *const [u64; 156usize]; #[repr(u32)] #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub enum nsCSSTokenSerializationType { diff --git a/components/style/gecko_bindings/structs_release.rs b/components/style/gecko_bindings/structs_release.rs index 27501f88a86..99e02860158 100644 --- a/components/style/gecko_bindings/structs_release.rs +++ b/components/style/gecko_bindings/structs_release.rs @@ -11540,12 +11540,14 @@ pub mod root { pub type RawGeckoNode = root::nsINode; pub type RawGeckoElement = root::mozilla::dom::Element; pub type RawGeckoDocument = root::nsIDocument; + pub type RawGeckoPresContext = [u64; 152usize]; pub type RawGeckoNodeBorrowed = *const root::RawGeckoNode; pub type RawGeckoNodeBorrowedOrNull = *const root::RawGeckoNode; pub type RawGeckoElementBorrowed = *const root::RawGeckoElement; pub type RawGeckoElementBorrowedOrNull = *const root::RawGeckoElement; pub type RawGeckoDocumentBorrowed = *const root::RawGeckoDocument; pub type RawGeckoDocumentBorrowedOrNull = *const root::RawGeckoDocument; + pub type RawGeckoPresContextBorrowed = *const [u64; 152usize]; #[repr(u32)] #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub enum nsCSSTokenSerializationType { diff --git a/ports/geckolib/glue.rs b/ports/geckolib/glue.rs index 87ef1c87738..c5c0733a5c5 100644 --- a/ports/geckolib/glue.rs +++ b/ports/geckolib/glue.rs @@ -36,6 +36,7 @@ use style::gecko_bindings::bindings::{RawServoStyleSheetStrong, ServoComputedVal use style::gecko_bindings::bindings::{ServoCssRulesBorrowed, ServoCssRulesStrong}; use style::gecko_bindings::bindings::{nsACString, nsAString}; use style::gecko_bindings::bindings::RawGeckoElementBorrowed; +use style::gecko_bindings::bindings::RawGeckoPresContextBorrowed; use style::gecko_bindings::bindings::RawServoImportRuleBorrowed; use style::gecko_bindings::bindings::ServoComputedValuesBorrowedOrNull; use style::gecko_bindings::bindings::nsTArrayBorrowed_uintptr_t; @@ -601,8 +602,9 @@ pub extern "C" fn Servo_ComputedValues_Release(ptr: ServoComputedValuesBorrowed) } #[no_mangle] -pub extern "C" fn Servo_StyleSet_Init() -> RawServoStyleSetOwned { - let data = Box::new(PerDocumentStyleData::new()); +pub extern "C" fn Servo_StyleSet_Init(pres_context: RawGeckoPresContextBorrowed) + -> RawServoStyleSetOwned { + let data = Box::new(PerDocumentStyleData::new(pres_context)); data.into_ffi() }