From 9776d070ea6def6162c7d7b5428078343c336daa Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Tue, 18 Jul 2017 11:51:56 -0700 Subject: [PATCH 1/4] stylo: Replace stylearc with servo_arc --- components/style/gecko/generated/structs_debug.rs | 6 +++--- components/style/gecko/generated/structs_release.rs | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/components/style/gecko/generated/structs_debug.rs b/components/style/gecko/generated/structs_debug.rs index 2cc35817f6a..c54e2904f01 100644 --- a/components/style/gecko/generated/structs_debug.rs +++ b/components/style/gecko/generated/structs_debug.rs @@ -11,11 +11,11 @@ pub type ServoCell = ::std::cell::Cell; pub type ServoNodeData = AtomicRefCell; pub type ServoWritingMode = ::logical_geometry::WritingMode; pub type ServoFontComputationData = ::properties::FontComputationData; -pub type ServoCustomPropertiesMap = Option<::stylearc::Arc<::custom_properties::CustomPropertiesMap>>; +pub type ServoCustomPropertiesMap = Option<::servo_arc::Arc<::custom_properties::CustomPropertiesMap>>; pub type ServoRuleNode = Option<::rule_tree::StrongRuleNode>; -pub type ServoVisitedStyle = Option<::stylearc::RawOffsetArc<::properties::ComputedValues>>; +pub type ServoVisitedStyle = Option<::servo_arc::RawOffsetArc<::properties::ComputedValues>>; pub type ServoComputedValueFlags = ::properties::computed_value_flags::ComputedValueFlags; -pub type ServoRawOffsetArc = ::stylearc::RawOffsetArc; +pub type ServoRawOffsetArc = ::servo_arc::RawOffsetArc; pub type ServoStyleContextStrong = ::gecko_bindings::sugar::ownership::Strong; #[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] diff --git a/components/style/gecko/generated/structs_release.rs b/components/style/gecko/generated/structs_release.rs index 206aba53c2c..cdcaf83b24c 100644 --- a/components/style/gecko/generated/structs_release.rs +++ b/components/style/gecko/generated/structs_release.rs @@ -11,11 +11,11 @@ pub type ServoCell = ::std::cell::Cell; pub type ServoNodeData = AtomicRefCell; pub type ServoWritingMode = ::logical_geometry::WritingMode; pub type ServoFontComputationData = ::properties::FontComputationData; -pub type ServoCustomPropertiesMap = Option<::stylearc::Arc<::custom_properties::CustomPropertiesMap>>; +pub type ServoCustomPropertiesMap = Option<::servo_arc::Arc<::custom_properties::CustomPropertiesMap>>; pub type ServoRuleNode = Option<::rule_tree::StrongRuleNode>; -pub type ServoVisitedStyle = Option<::stylearc::RawOffsetArc<::properties::ComputedValues>>; +pub type ServoVisitedStyle = Option<::servo_arc::RawOffsetArc<::properties::ComputedValues>>; pub type ServoComputedValueFlags = ::properties::computed_value_flags::ComputedValueFlags; -pub type ServoRawOffsetArc = ::stylearc::RawOffsetArc; +pub type ServoRawOffsetArc = ::servo_arc::RawOffsetArc; pub type ServoStyleContextStrong = ::gecko_bindings::sugar::ownership::Strong; #[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] From 3c3e4399da4fcddcb75255a1178ed71be7a5f46b Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Tue, 18 Jul 2017 23:17:34 -0700 Subject: [PATCH 2/4] stylo: Remove usage of ServoComputedValues from binding functions --- components/servo_arc/lib.rs | 6 ++ components/style/gecko/arc_types.rs | 35 ++++++++++-- components/style/gecko/generated/bindings.rs | 14 ++--- .../style/gecko/generated/structs_debug.rs | 2 +- .../style/gecko/generated/structs_release.rs | 2 +- components/style/properties/gecko.mako.rs | 3 +- ports/geckolib/glue.rs | 55 +++++++++---------- 7 files changed, 71 insertions(+), 46 deletions(-) diff --git a/components/servo_arc/lib.rs b/components/servo_arc/lib.rs index b1f4f277a49..d8a74758247 100644 --- a/components/servo_arc/lib.rs +++ b/components/servo_arc/lib.rs @@ -889,6 +889,12 @@ impl<'a, T> ArcBorrow<'a, T> { arc } + /// For constructing from a reference known to be Arc-backed, + /// e.g. if we obtain such a reference over FFI + pub unsafe fn from_ref(r: &'a T) -> Self { + ArcBorrow(r) + } + pub fn with_arc(&self, f: F) -> U where F: FnOnce(&Arc) -> U, T: 'static { // Synthesize transient Arc, which never touches the refcount. let transient = unsafe { NoDrop::new(Arc::from_raw(self.0)) }; diff --git a/components/style/gecko/arc_types.rs b/components/style/gecko/arc_types.rs index 704369e225c..f25d5ef6f5f 100644 --- a/components/style/gecko/arc_types.rs +++ b/components/style/gecko/arc_types.rs @@ -13,13 +13,14 @@ use gecko_bindings::bindings::{RawServoKeyframe, RawServoKeyframesRule}; use gecko_bindings::bindings::{RawServoMediaRule, RawServoNamespaceRule, RawServoPageRule}; use gecko_bindings::bindings::{RawServoRuleNode, RawServoRuleNodeStrong, RawServoDocumentRule}; use gecko_bindings::bindings::ServoCssRules; -use gecko_bindings::structs::{RawServoAnimationValue, RawServoDeclarationBlock, RawServoStyleRule, RawServoMediaList}; -use gecko_bindings::structs::{RawServoStyleSheetContents, ServoStyleContext}; -use gecko_bindings::sugar::ownership::{HasArcFFI, HasFFI}; +use gecko_bindings::structs::{RawServoAnimationValue, RawServoDeclarationBlock, RawServoStyleRule}; +use gecko_bindings::structs::{RawServoMediaList, RawServoStyleSheetContents}; +use gecko_bindings::sugar::ownership::{HasArcFFI, HasFFI, Strong}; use media_queries::MediaList; use properties::{ComputedValues, PropertyDeclarationBlock}; use properties::animated_properties::AnimationValue; use rule_tree::StrongRuleNode; +use servo_arc::{Arc, ArcBorrow}; use shared_lock::Locked; use std::{mem, ptr}; use stylesheets::{CssRules, StylesheetContents, StyleRule, ImportRule, KeyframesRule, MediaRule}; @@ -51,9 +52,6 @@ impl_arc_ffi!(Locked => ServoCssRules impl_arc_ffi!(StylesheetContents => RawServoStyleSheetContents [Servo_StyleSheetContents_AddRef, Servo_StyleSheetContents_Release]); -impl_arc_ffi!(ComputedValues => ServoStyleContext - [Servo_StyleContext_AddRef, Servo_StyleContext_Release]); - impl_arc_ffi!(Locked => RawServoDeclarationBlock [Servo_DeclarationBlock_AddRef, Servo_DeclarationBlock_Release]); @@ -114,3 +112,28 @@ pub unsafe extern "C" fn Servo_RuleNode_Release(obj: &RawServoRuleNode) { let ptr = StrongRuleNode::from_ffi(&obj); ptr::read(ptr as *const StrongRuleNode); } + +// ServoStyleContext is not an opaque type on any side of FFI. +// This means that doing the HasArcFFI type trick is actually unsound, +// since it gives us a way to construct an Arc from +// an &ServoStyleContext, which in general is not allowed. So we +// implement the restricted set of arc type functionality we need. + +#[no_mangle] +pub unsafe extern "C" fn Servo_StyleContext_AddRef(obj: &ComputedValues) { + mem::forget(ArcBorrow::from_ref(obj).clone_arc()); +} + +#[no_mangle] +pub unsafe extern "C" fn Servo_StyleContext_Release(obj: &ComputedValues) { + ArcBorrow::from_ref(obj).with_arc(|a: &Arc| { + let _: Arc = ptr::read(a); + }); +} + + +impl From> for Strong { + fn from(arc: Arc) -> Self { + unsafe { mem::transmute(Arc::into_raw_offset(arc)) } + } +} diff --git a/components/style/gecko/generated/bindings.rs b/components/style/gecko/generated/bindings.rs index 1f237d61566..a31af059128 100644 --- a/components/style/gecko/generated/bindings.rs +++ b/components/style/gecko/generated/bindings.rs @@ -5,7 +5,7 @@ use gecko_bindings::structs::nsStyleTransformMatrix; use gecko_bindings::structs::nsTArray; type nsACString_internal = nsACString; type nsAString_internal = nsAString; -pub type ServoStyleContextBorrowed<'a> = &'a ServoStyleContext; +pub type ServoStyleContextBorrowed<'a> = &'a ::properties::ComputedValues; pub type ServoStyleContextBorrowedOrNull<'a> = Option<&'a ::properties::ComputedValues>; pub type ServoComputedValuesBorrowed<'a> = &'a ServoComputedValues; pub type ServoComputedValuesBorrowedOrNull<'a> = Option<&'a ServoComputedValues>; @@ -2322,7 +2322,7 @@ extern "C" { } extern "C" { pub fn Servo_ComputedValues_SpecifiesAnimationsOrTransitions(computed_values: - ServoComputedValuesBorrowed) + ServoStyleContextBorrowed) -> bool; } extern "C" { @@ -2705,7 +2705,7 @@ extern "C" { } extern "C" { pub fn Servo_ComputedValues_GetStyleBits(values: - ServoComputedValuesBorrowed) + ServoStyleContextBorrowed) -> u64; } extern "C" { @@ -2717,7 +2717,7 @@ extern "C" { } extern "C" { pub fn Servo_ComputedValues_GetStyleRuleList(values: - ServoComputedValuesBorrowed, + ServoStyleContextBorrowed, rules: RawGeckoServoStyleRuleListBorrowedMut); } @@ -2804,17 +2804,17 @@ extern "C" { } extern "C" { pub fn Servo_GetCustomPropertyValue(computed_values: - ServoComputedValuesBorrowed, + ServoStyleContextBorrowed, name: *const nsAString, value: *mut nsAString) -> bool; } extern "C" { pub fn Servo_GetCustomPropertiesCount(computed_values: - ServoComputedValuesBorrowed) + ServoStyleContextBorrowed) -> u32; } extern "C" { - pub fn Servo_GetCustomPropertyNameAt(arg1: ServoComputedValuesBorrowed, + pub fn Servo_GetCustomPropertyNameAt(arg1: ServoStyleContextBorrowed, index: u32, name: *mut nsAString) -> bool; } diff --git a/components/style/gecko/generated/structs_debug.rs b/components/style/gecko/generated/structs_debug.rs index c54e2904f01..22405e6d570 100644 --- a/components/style/gecko/generated/structs_debug.rs +++ b/components/style/gecko/generated/structs_debug.rs @@ -16,7 +16,7 @@ pub type ServoRuleNode = Option<::rule_tree::StrongRuleNode>; pub type ServoVisitedStyle = Option<::servo_arc::RawOffsetArc<::properties::ComputedValues>>; pub type ServoComputedValueFlags = ::properties::computed_value_flags::ComputedValueFlags; pub type ServoRawOffsetArc = ::servo_arc::RawOffsetArc; -pub type ServoStyleContextStrong = ::gecko_bindings::sugar::ownership::Strong; +pub type ServoStyleContextStrong = ::gecko_bindings::sugar::ownership::Strong<::properties::ComputedValues>; #[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] pub mod root { diff --git a/components/style/gecko/generated/structs_release.rs b/components/style/gecko/generated/structs_release.rs index cdcaf83b24c..86ad173caf3 100644 --- a/components/style/gecko/generated/structs_release.rs +++ b/components/style/gecko/generated/structs_release.rs @@ -16,7 +16,7 @@ pub type ServoRuleNode = Option<::rule_tree::StrongRuleNode>; pub type ServoVisitedStyle = Option<::servo_arc::RawOffsetArc<::properties::ComputedValues>>; pub type ServoComputedValueFlags = ::properties::computed_value_flags::ComputedValueFlags; pub type ServoRawOffsetArc = ::servo_arc::RawOffsetArc; -pub type ServoStyleContextStrong = ::gecko_bindings::sugar::ownership::Strong; +pub type ServoStyleContextStrong = ::gecko_bindings::sugar::ownership::Strong<::properties::ComputedValues>; #[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] pub mod root { diff --git a/components/style/properties/gecko.mako.rs b/components/style/properties/gecko.mako.rs index a6859238d83..9523126f60e 100644 --- a/components/style/properties/gecko.mako.rs +++ b/components/style/properties/gecko.mako.rs @@ -227,7 +227,8 @@ impl ComputedValuesInner { ) -> Arc { let arc = unsafe { let arc: Arc = Arc::new(uninitialized()); - bindings::Gecko_ServoStyleContext_Init(&arc.0 as *const _ as *mut _, parent, pres_context, + bindings::Gecko_ServoStyleContext_Init(&arc.0 as *const _ as *mut _, + parent, pres_context, &self, pseudo_ty, pseudo_tag); // We're simulating a move by having C++ do a memcpy and then forgetting // it on this end. diff --git a/ports/geckolib/glue.rs b/ports/geckolib/glue.rs index 6d71fdf7a72..52ac9419aa2 100644 --- a/ports/geckolib/glue.rs +++ b/ports/geckolib/glue.rs @@ -8,7 +8,7 @@ use cssparser::ToCss as ParserToCss; use env_logger::LogBuilder; use selectors::Element; use selectors::matching::{MatchingContext, MatchingMode, matches_selector}; -use servo_arc::{Arc, RawOffsetArc}; +use servo_arc::{Arc, ArcBorrow, RawOffsetArc}; use std::env; use std::fmt::Write; use std::ptr; @@ -666,10 +666,10 @@ pub extern "C" fn Servo_StyleSet_GetBaseComputedValuesForElement(raw_data: RawSe use style::style_resolver::StyleResolverForElement; debug_assert!(!snapshots.is_null()); - let computed_values = ComputedValues::as_arc(&computed_values); + let computed_values = unsafe { ArcBorrow::from_ref(computed_values) }; let rules = match computed_values.rules { - None => return computed_values.clone().into_strong(), + None => return computed_values.clone_arc().into(), Some(ref rules) => rules, }; @@ -678,14 +678,14 @@ pub extern "C" fn Servo_StyleSet_GetBaseComputedValuesForElement(raw_data: RawSe doc_data.stylist.rule_tree().remove_animation_rules(rules); if without_animations == *rules { - return computed_values.clone().into_strong(); + return computed_values.clone_arc().into(); } let element = GeckoElement(element); let element_data = match element.borrow_data() { Some(data) => data, - None => return computed_values.clone().into_strong(), + None => return computed_values.clone_arc().into(), }; let styles = &element_data.styles; @@ -695,7 +695,7 @@ pub extern "C" fn Servo_StyleSet_GetBaseComputedValuesForElement(raw_data: RawSe .pseudos .get(&pseudo) .expect("GetBaseComputedValuesForElement for an unexisting pseudo?") - .clone().into_strong(); + .clone().into(); } let global_style_data = &*GLOBAL_STYLE_DATA; @@ -721,7 +721,7 @@ pub extern "C" fn Servo_StyleSet_GetBaseComputedValuesForElement(raw_data: RawSe StyleResolverForElement::new(element, &mut context, RuleInclusion::All) .cascade_style_and_visited_with_default_parents(inputs) - .into_strong() + .into() } #[no_mangle] @@ -734,8 +734,7 @@ pub extern "C" fn Servo_ComputedValues_ExtractAnimationValue(computed_values: Se None => return Strong::null(), }; - let computed_values = ComputedValues::as_arc(&computed_values); - Arc::new(AnimationValue::from_computed_values(&property, computed_values)).into_strong() + Arc::new(AnimationValue::from_computed_values(&property, &computed_values)).into_strong() } #[no_mangle] @@ -1526,7 +1525,7 @@ pub extern "C" fn Servo_ComputedValues_GetForAnonymousBox(parent_style_or_null: &pseudo, parent_style_or_null.map(|x| &*x), cascade_flags, &metrics - ).into_strong() + ).into() } #[no_mangle] @@ -1550,7 +1549,7 @@ pub extern "C" fn Servo_ResolvePseudoStyle(element: RawGeckoElementBorrowed, return if is_probe { Strong::null() } else { - doc_data.default_computed_values().clone().into_strong() + doc_data.default_computed_values().clone().into() }; } @@ -1571,7 +1570,7 @@ pub extern "C" fn Servo_ResolvePseudoStyle(element: RawGeckoElementBorrowed, ); match style { - Some(s) => s.into_strong(), + Some(s) => s.into(), None => { debug_assert!(is_probe); Strong::null() @@ -1584,13 +1583,12 @@ pub extern "C" fn Servo_SetExplicitStyle(element: RawGeckoElementBorrowed, style: ServoStyleContextBorrowed) { let element = GeckoElement(element); - let style = ComputedValues::as_arc(&style); debug!("Servo_SetExplicitStyle: {:?}", element); // We only support this API for initial styling. There's no reason it couldn't // work for other things, we just haven't had a reason to do so. debug_assert!(element.get_data().is_none()); let mut data = unsafe { element.ensure_data() }; - data.styles.primary = Some(style.clone_arc()); + data.styles.primary = Some(unsafe { ArcBorrow::from_ref(style) }.clone_arc()); } #[no_mangle] @@ -1730,11 +1728,11 @@ pub extern "C" fn Servo_ComputedValues_Inherit( ).build() }; - style.into_strong() + style.into() } #[no_mangle] -pub extern "C" fn Servo_ComputedValues_GetStyleBits(values: ServoComputedValuesBorrowed) -> u64 { +pub extern "C" fn Servo_ComputedValues_GetStyleBits(values: ServoStyleContextBorrowed) -> u64 { use style::properties::computed_value_flags::*; let flags = values.flags; let mut result = 0; @@ -1748,7 +1746,7 @@ pub extern "C" fn Servo_ComputedValues_GetStyleBits(values: ServoComputedValuesB } #[no_mangle] -pub extern "C" fn Servo_ComputedValues_SpecifiesAnimationsOrTransitions(values: ServoComputedValuesBorrowed) +pub extern "C" fn Servo_ComputedValues_SpecifiesAnimationsOrTransitions(values: ServoStyleContextBorrowed) -> bool { let b = values.get_box(); b.specifies_animations() || b.specifies_transitions() @@ -1763,7 +1761,7 @@ pub extern "C" fn Servo_ComputedValues_EqualCustomProperties( } #[no_mangle] -pub extern "C" fn Servo_ComputedValues_GetStyleRuleList(values: ServoComputedValuesBorrowed, +pub extern "C" fn Servo_ComputedValues_GetStyleRuleList(values: ServoStyleContextBorrowed, rules: RawGeckoServoStyleRuleListBorrowedMut) { if let Some(ref rule_node) = values.rules { let mut result = vec![]; @@ -2804,7 +2802,7 @@ pub extern "C" fn Servo_ResolveStyle(element: RawGeckoElementBorrowed, }; debug_assert!(element.has_current_styles_for_traversal(&*data, flags), "Resolving style on element without current styles"); - data.styles.primary().clone().into_strong() + data.styles.primary().clone().into() } #[no_mangle] @@ -2853,7 +2851,7 @@ pub extern "C" fn Servo_ResolveStyleLazily(element: RawGeckoElementBorrowed, } }); if let Some(result) = styles { - return result.into_strong(); + return result.into(); } } @@ -2870,7 +2868,7 @@ pub extern "C" fn Servo_ResolveStyleLazily(element: RawGeckoElementBorrowed, }; let styles = resolve_style(&mut context, element, rule_inclusion); - finish(&styles).into_strong() + finish(&styles).into() } #[cfg(feature = "gecko_debug")] @@ -2919,7 +2917,6 @@ pub extern "C" fn Servo_GetComputedKeyframeValues(keyframes: RawGeckoKeyframeLis let data = PerDocumentStyleData::from_ffi(raw_data).borrow(); let metrics = get_metrics_provider_for_product(); - let style = ComputedValues::as_arc(&style); let element = GeckoElement(element); let parent_element = element.inheritance_parent(); @@ -2927,7 +2924,7 @@ pub extern "C" fn Servo_GetComputedKeyframeValues(keyframes: RawGeckoKeyframeLis let parent_style = parent_data.as_ref().map(|d| d.styles.primary()).map(|x| &**x); let pseudo = style.pseudo(); - let mut context = create_context(&data, &metrics, style, parent_style, pseudo.as_ref()); + let mut context = create_context(&data, &metrics, &style, parent_style, pseudo.as_ref()); let global_style_data = &*GLOBAL_STYLE_DATA; let guard = global_style_data.shared_lock.read(); @@ -3001,7 +2998,6 @@ pub extern "C" fn Servo_GetAnimationValues(declarations: RawServoDeclarationBloc animation_values: RawGeckoServoAnimationValueListBorrowedMut) { let data = PerDocumentStyleData::from_ffi(raw_data).borrow(); let metrics = get_metrics_provider_for_product(); - let style = ComputedValues::as_arc(&style); let element = GeckoElement(element); let parent_element = element.inheritance_parent(); @@ -3009,7 +3005,7 @@ pub extern "C" fn Servo_GetAnimationValues(declarations: RawServoDeclarationBloc let parent_style = parent_data.as_ref().map(|d| d.styles.primary()).map(|x| &**x); let pseudo = style.pseudo(); - let mut context = create_context(&data, &metrics, style, parent_style, pseudo.as_ref()); + let mut context = create_context(&data, &metrics, &style, parent_style, pseudo.as_ref()); let default_values = data.default_computed_values(); let global_style_data = &*GLOBAL_STYLE_DATA; @@ -3031,7 +3027,6 @@ pub extern "C" fn Servo_AnimationValue_Compute(element: RawGeckoElementBorrowed, -> RawServoAnimationValueStrong { let data = PerDocumentStyleData::from_ffi(raw_data).borrow(); let metrics = get_metrics_provider_for_product(); - let style = ComputedValues::as_arc(&style); let element = GeckoElement(element); let parent_element = element.inheritance_parent(); @@ -3293,7 +3288,7 @@ pub extern "C" fn Servo_StyleSet_ResolveForDeclarations( &guards, parent_style, declarations.clone_arc(), - ).into_strong() + ).into() } #[no_mangle] @@ -3350,7 +3345,7 @@ pub extern "C" fn Servo_StyleSet_HasStateDependency( } #[no_mangle] -pub extern "C" fn Servo_GetCustomPropertyValue(computed_values: ServoComputedValuesBorrowed, +pub extern "C" fn Servo_GetCustomPropertyValue(computed_values: ServoStyleContextBorrowed, name: *const nsAString, value: *mut nsAString) -> bool { let custom_properties = match computed_values.custom_properties() { @@ -3369,7 +3364,7 @@ pub extern "C" fn Servo_GetCustomPropertyValue(computed_values: ServoComputedVal } #[no_mangle] -pub extern "C" fn Servo_GetCustomPropertiesCount(computed_values: ServoComputedValuesBorrowed) -> u32 { +pub extern "C" fn Servo_GetCustomPropertiesCount(computed_values: ServoStyleContextBorrowed) -> u32 { match computed_values.custom_properties() { Some(p) => p.len() as u32, None => 0, @@ -3377,7 +3372,7 @@ pub extern "C" fn Servo_GetCustomPropertiesCount(computed_values: ServoComputedV } #[no_mangle] -pub extern "C" fn Servo_GetCustomPropertyNameAt(computed_values: ServoComputedValuesBorrowed, +pub extern "C" fn Servo_GetCustomPropertyNameAt(computed_values: ServoStyleContextBorrowed, index: u32, name: *mut nsAString) -> bool { let custom_properties = match computed_values.custom_properties() { From cca0eacf808cf769d4090b71d01ce6497bcf7a34 Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Thu, 20 Jul 2017 17:27:05 -0700 Subject: [PATCH 3/4] stylo: Remove usage of ServoComputedValues from most Gecko code --- components/style/gecko/generated/bindings.rs | 1 - .../style/gecko/generated/structs_debug.rs | 2 -- .../style/gecko/generated/structs_release.rs | 2 -- components/style/gecko/restyle_damage.rs | 4 ++-- components/style/properties/gecko.mako.rs | 16 ---------------- 5 files changed, 2 insertions(+), 23 deletions(-) diff --git a/components/style/gecko/generated/bindings.rs b/components/style/gecko/generated/bindings.rs index a31af059128..256f3985a36 100644 --- a/components/style/gecko/generated/bindings.rs +++ b/components/style/gecko/generated/bindings.rs @@ -8,7 +8,6 @@ type nsAString_internal = nsAString; pub type ServoStyleContextBorrowed<'a> = &'a ::properties::ComputedValues; pub type ServoStyleContextBorrowedOrNull<'a> = Option<&'a ::properties::ComputedValues>; pub type ServoComputedValuesBorrowed<'a> = &'a ServoComputedValues; -pub type ServoComputedValuesBorrowedOrNull<'a> = Option<&'a ServoComputedValues>; use gecko_bindings::structs::mozilla::css::GridTemplateAreasValue; use gecko_bindings::structs::mozilla::css::ErrorReporter; use gecko_bindings::structs::mozilla::css::ImageValue; diff --git a/components/style/gecko/generated/structs_debug.rs b/components/style/gecko/generated/structs_debug.rs index 22405e6d570..8861fcbcd29 100644 --- a/components/style/gecko/generated/structs_debug.rs +++ b/components/style/gecko/generated/structs_debug.rs @@ -38456,8 +38456,6 @@ pub mod root { pub type ServoStyleContextBorrowedOrNull = *const root::mozilla::ServoStyleContext; pub type ServoComputedValuesBorrowed = *const root::ServoComputedValues; - pub type ServoComputedValuesBorrowedOrNull = - *const root::ServoComputedValues; pub type RawServoAnimationValueMapBorrowedMut = *mut root::RawServoAnimationValueMap; pub type RawGeckoNodeBorrowed = *const root::RawGeckoNode; diff --git a/components/style/gecko/generated/structs_release.rs b/components/style/gecko/generated/structs_release.rs index 86ad173caf3..e87d5e7b588 100644 --- a/components/style/gecko/generated/structs_release.rs +++ b/components/style/gecko/generated/structs_release.rs @@ -37765,8 +37765,6 @@ pub mod root { pub type ServoStyleContextBorrowedOrNull = *const root::mozilla::ServoStyleContext; pub type ServoComputedValuesBorrowed = *const root::ServoComputedValues; - pub type ServoComputedValuesBorrowedOrNull = - *const root::ServoComputedValues; pub type RawServoAnimationValueMapBorrowedMut = *mut root::RawServoAnimationValueMap; pub type RawGeckoNodeBorrowed = *const root::RawGeckoNode; diff --git a/components/style/gecko/restyle_damage.rs b/components/style/gecko/restyle_damage.rs index 62865e06b79..7d0c29c232f 100644 --- a/components/style/gecko/restyle_damage.rs +++ b/components/style/gecko/restyle_damage.rs @@ -53,8 +53,8 @@ impl GeckoRestyleDamage { ) -> StyleDifference { let mut any_style_changed: bool = false; let hint = unsafe { - bindings::Gecko_CalcStyleDifference(old_style.as_style_context(), - new_style.as_style_context(), + bindings::Gecko_CalcStyleDifference(old_style, + new_style, source.mBits, &mut any_style_changed) }; diff --git a/components/style/properties/gecko.mako.rs b/components/style/properties/gecko.mako.rs index 9523126f60e..e238f25069f 100644 --- a/components/style/properties/gecko.mako.rs +++ b/components/style/properties/gecko.mako.rs @@ -39,7 +39,6 @@ use gecko_bindings::bindings::Gecko_nsStyleFont_CopyLangFrom; use gecko_bindings::bindings::Gecko_SetListStyleImageNone; use gecko_bindings::bindings::Gecko_SetListStyleImageImageValue; use gecko_bindings::bindings::Gecko_SetNullImageValue; -use gecko_bindings::bindings::ServoComputedValuesBorrowedOrNull; use gecko_bindings::bindings::{Gecko_ResetFilters, Gecko_CopyFiltersFrom}; use gecko_bindings::bindings::RawGeckoPresContextBorrowed; use gecko_bindings::structs; @@ -137,10 +136,6 @@ impl ComputedValues { let atom = Atom::from(atom); PseudoElement::from_atom(&atom) } - - pub fn as_style_context(&self) -> &::gecko_bindings::structs::mozilla::ServoStyleContext { - &self.0 - } } impl Drop for ComputedValues { @@ -4974,23 +4969,12 @@ clip-path } -<%def name="define_ffi_struct_accessor(style_struct)"> -#[no_mangle] -#[allow(non_snake_case, unused_variables)] -pub unsafe extern "C" fn Servo_GetStyle${style_struct.gecko_name}(computed_values: - ServoComputedValuesBorrowedOrNull) -> *const ${style_struct.gecko_ffi_name} { - computed_values.unwrap().get_${style_struct.name_lower}().get_gecko() - as *const ${style_struct.gecko_ffi_name} -} - - % for style_struct in data.style_structs: ${declare_style_struct(style_struct)} ${impl_style_struct(style_struct)} % if not style_struct.name in data.manual_style_structs: <%self:raw_impl_trait style_struct="${style_struct}"> % endif -${define_ffi_struct_accessor(style_struct)} % endfor // This is only accessed from the Gecko main thread. From b332a061b4cf9d83ff99cb253b3bc6cccb5fa436 Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Thu, 20 Jul 2017 21:44:02 -0700 Subject: [PATCH 4/4] stylo: Rename ServoComputedValues -> ServoComputedData ServoComputedValues is confusing because ComputedValues is actually ServoStyleContext on the C++ side. --- components/style/gecko/generated/bindings.rs | 18 +-- .../style/gecko/generated/structs_debug.rs | 152 +++++++++--------- .../style/gecko/generated/structs_release.rs | 152 +++++++++--------- components/style/properties/gecko.mako.rs | 2 +- ports/geckolib/glue.rs | 6 +- 5 files changed, 165 insertions(+), 165 deletions(-) diff --git a/components/style/gecko/generated/bindings.rs b/components/style/gecko/generated/bindings.rs index 256f3985a36..3226c67b1d0 100644 --- a/components/style/gecko/generated/bindings.rs +++ b/components/style/gecko/generated/bindings.rs @@ -7,7 +7,7 @@ type nsACString_internal = nsACString; type nsAString_internal = nsAString; pub type ServoStyleContextBorrowed<'a> = &'a ::properties::ComputedValues; pub type ServoStyleContextBorrowedOrNull<'a> = Option<&'a ::properties::ComputedValues>; -pub type ServoComputedValuesBorrowed<'a> = &'a ServoComputedValues; +pub type ServoComputedDataBorrowed<'a> = &'a ServoComputedData; use gecko_bindings::structs::mozilla::css::GridTemplateAreasValue; use gecko_bindings::structs::mozilla::css::ErrorReporter; use gecko_bindings::structs::mozilla::css::ImageValue; @@ -220,7 +220,7 @@ use gecko_bindings::structs::nsresult; use gecko_bindings::structs::Loader; use gecko_bindings::structs::LoaderReusableStyleSheets; use gecko_bindings::structs::ServoStyleSheet; -use gecko_bindings::structs::ServoComputedValues; +use gecko_bindings::structs::ServoComputedData; use gecko_bindings::structs::ServoStyleContext; use gecko_bindings::structs::ServoStyleContextStrong; use gecko_bindings::structs::EffectCompositor_CascadeLevel; @@ -535,7 +535,7 @@ extern "C" { ServoStyleContextBorrowedOrNull, pres_context: RawGeckoPresContextBorrowed, - values: ServoComputedValuesBorrowed, + values: ServoComputedDataBorrowed, pseudo_type: CSSPseudoElementType, pseudo_tag: *mut nsIAtom); } @@ -1046,8 +1046,8 @@ extern "C" { -> CSSPseudoElementType; } extern "C" { - pub fn Gecko_CalcStyleDifference(old_style: *const ServoStyleContext, - new_style: *const ServoStyleContext, + pub fn Gecko_CalcStyleDifference(old_style: ServoStyleContextBorrowed, + new_style: ServoStyleContextBorrowed, old_style_bits: u64, any_style_changed: *mut bool) -> nsChangeHint; @@ -1984,10 +1984,10 @@ extern "C" { -> ServoStyleContextStrong; } extern "C" { - pub fn Servo_StyleContext_AddRef(ctx: &ServoStyleContext); + pub fn Servo_StyleContext_AddRef(ctx: ServoStyleContextBorrowed); } extern "C" { - pub fn Servo_StyleContext_Release(ctx: &ServoStyleContext); + pub fn Servo_StyleContext_Release(ctx: ServoStyleContextBorrowed); } extern "C" { pub fn Servo_StyleSet_MightHaveAttributeDependency(set: @@ -2709,9 +2709,9 @@ extern "C" { } extern "C" { pub fn Servo_ComputedValues_EqualCustomProperties(first: - ServoComputedValuesBorrowed, + ServoComputedDataBorrowed, second: - ServoComputedValuesBorrowed) + ServoComputedDataBorrowed) -> bool; } extern "C" { diff --git a/components/style/gecko/generated/structs_debug.rs b/components/style/gecko/generated/structs_debug.rs index 8861fcbcd29..5a6c073d0a1 100644 --- a/components/style/gecko/generated/structs_debug.rs +++ b/components/style/gecko/generated/structs_debug.rs @@ -7590,7 +7590,7 @@ pub mod root { pub struct ServoStyleContext { pub _base: root::nsStyleContext, pub mPresContext: *mut root::nsPresContext, - pub mSource: root::ServoComputedValues, + pub mSource: root::ServoComputedData, } #[test] fn bindgen_test_layout_ServoStyleContext() { @@ -20993,7 +20993,7 @@ pub mod root { */ #[repr(C)] #[derive(Debug)] - pub struct ServoComputedValues { + pub struct ServoComputedData { pub Font: ::gecko_bindings::structs::ServoRawOffsetArc, pub Color: ::gecko_bindings::structs::ServoRawOffsetArc, pub List: ::gecko_bindings::structs::ServoRawOffsetArc, @@ -21031,187 +21031,187 @@ pub mod root { pub font_computation_data: ::gecko_bindings::structs::ServoFontComputationData, } #[test] - fn bindgen_test_layout_ServoComputedValues() { - assert_eq!(::std::mem::size_of::() , 224usize , + fn bindgen_test_layout_ServoComputedData() { + assert_eq!(::std::mem::size_of::() , 224usize , concat ! ( - "Size of: " , stringify ! ( ServoComputedValues ) )); - assert_eq! (::std::mem::align_of::() , 8usize , + "Size of: " , stringify ! ( ServoComputedData ) )); + assert_eq! (::std::mem::align_of::() , 8usize , concat ! ( - "Alignment of " , stringify ! ( ServoComputedValues ) )); + "Alignment of " , stringify ! ( ServoComputedData ) )); assert_eq! (unsafe { - & ( * ( 0 as * const ServoComputedValues ) ) . Font as * + & ( * ( 0 as * const ServoComputedData ) ) . Font as * const _ as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( ServoComputedValues + "Alignment of field: " , stringify ! ( ServoComputedData ) , "::" , stringify ! ( Font ) )); assert_eq! (unsafe { - & ( * ( 0 as * const ServoComputedValues ) ) . Color as * + & ( * ( 0 as * const ServoComputedData ) ) . Color as * const _ as usize } , 8usize , concat ! ( - "Alignment of field: " , stringify ! ( ServoComputedValues + "Alignment of field: " , stringify ! ( ServoComputedData ) , "::" , stringify ! ( Color ) )); assert_eq! (unsafe { - & ( * ( 0 as * const ServoComputedValues ) ) . List as * + & ( * ( 0 as * const ServoComputedData ) ) . List as * const _ as usize } , 16usize , concat ! ( - "Alignment of field: " , stringify ! ( ServoComputedValues + "Alignment of field: " , stringify ! ( ServoComputedData ) , "::" , stringify ! ( List ) )); assert_eq! (unsafe { - & ( * ( 0 as * const ServoComputedValues ) ) . Text as * + & ( * ( 0 as * const ServoComputedData ) ) . Text as * const _ as usize } , 24usize , concat ! ( - "Alignment of field: " , stringify ! ( ServoComputedValues + "Alignment of field: " , stringify ! ( ServoComputedData ) , "::" , stringify ! ( Text ) )); assert_eq! (unsafe { - & ( * ( 0 as * const ServoComputedValues ) ) . Visibility + & ( * ( 0 as * const ServoComputedData ) ) . Visibility as * const _ as usize } , 32usize , concat ! ( - "Alignment of field: " , stringify ! ( ServoComputedValues + "Alignment of field: " , stringify ! ( ServoComputedData ) , "::" , stringify ! ( Visibility ) )); assert_eq! (unsafe { - & ( * ( 0 as * const ServoComputedValues ) ) . + & ( * ( 0 as * const ServoComputedData ) ) . UserInterface as * const _ as usize } , 40usize , concat ! ( - "Alignment of field: " , stringify ! ( ServoComputedValues + "Alignment of field: " , stringify ! ( ServoComputedData ) , "::" , stringify ! ( UserInterface ) )); assert_eq! (unsafe { - & ( * ( 0 as * const ServoComputedValues ) ) . TableBorder + & ( * ( 0 as * const ServoComputedData ) ) . TableBorder as * const _ as usize } , 48usize , concat ! ( - "Alignment of field: " , stringify ! ( ServoComputedValues + "Alignment of field: " , stringify ! ( ServoComputedData ) , "::" , stringify ! ( TableBorder ) )); assert_eq! (unsafe { - & ( * ( 0 as * const ServoComputedValues ) ) . SVG as * + & ( * ( 0 as * const ServoComputedData ) ) . SVG as * const _ as usize } , 56usize , concat ! ( - "Alignment of field: " , stringify ! ( ServoComputedValues + "Alignment of field: " , stringify ! ( ServoComputedData ) , "::" , stringify ! ( SVG ) )); assert_eq! (unsafe { - & ( * ( 0 as * const ServoComputedValues ) ) . Background + & ( * ( 0 as * const ServoComputedData ) ) . Background as * const _ as usize } , 64usize , concat ! ( - "Alignment of field: " , stringify ! ( ServoComputedValues + "Alignment of field: " , stringify ! ( ServoComputedData ) , "::" , stringify ! ( Background ) )); assert_eq! (unsafe { - & ( * ( 0 as * const ServoComputedValues ) ) . Position as + & ( * ( 0 as * const ServoComputedData ) ) . Position as * const _ as usize } , 72usize , concat ! ( - "Alignment of field: " , stringify ! ( ServoComputedValues + "Alignment of field: " , stringify ! ( ServoComputedData ) , "::" , stringify ! ( Position ) )); assert_eq! (unsafe { - & ( * ( 0 as * const ServoComputedValues ) ) . TextReset + & ( * ( 0 as * const ServoComputedData ) ) . TextReset as * const _ as usize } , 80usize , concat ! ( - "Alignment of field: " , stringify ! ( ServoComputedValues + "Alignment of field: " , stringify ! ( ServoComputedData ) , "::" , stringify ! ( TextReset ) )); assert_eq! (unsafe { - & ( * ( 0 as * const ServoComputedValues ) ) . Display as + & ( * ( 0 as * const ServoComputedData ) ) . Display as * const _ as usize } , 88usize , concat ! ( - "Alignment of field: " , stringify ! ( ServoComputedValues + "Alignment of field: " , stringify ! ( ServoComputedData ) , "::" , stringify ! ( Display ) )); assert_eq! (unsafe { - & ( * ( 0 as * const ServoComputedValues ) ) . Content as + & ( * ( 0 as * const ServoComputedData ) ) . Content as * const _ as usize } , 96usize , concat ! ( - "Alignment of field: " , stringify ! ( ServoComputedValues + "Alignment of field: " , stringify ! ( ServoComputedData ) , "::" , stringify ! ( Content ) )); assert_eq! (unsafe { - & ( * ( 0 as * const ServoComputedValues ) ) . UIReset as + & ( * ( 0 as * const ServoComputedData ) ) . UIReset as * const _ as usize } , 104usize , concat ! ( - "Alignment of field: " , stringify ! ( ServoComputedValues + "Alignment of field: " , stringify ! ( ServoComputedData ) , "::" , stringify ! ( UIReset ) )); assert_eq! (unsafe { - & ( * ( 0 as * const ServoComputedValues ) ) . Table as * + & ( * ( 0 as * const ServoComputedData ) ) . Table as * const _ as usize } , 112usize , concat ! ( - "Alignment of field: " , stringify ! ( ServoComputedValues + "Alignment of field: " , stringify ! ( ServoComputedData ) , "::" , stringify ! ( Table ) )); assert_eq! (unsafe { - & ( * ( 0 as * const ServoComputedValues ) ) . Margin as * + & ( * ( 0 as * const ServoComputedData ) ) . Margin as * const _ as usize } , 120usize , concat ! ( - "Alignment of field: " , stringify ! ( ServoComputedValues + "Alignment of field: " , stringify ! ( ServoComputedData ) , "::" , stringify ! ( Margin ) )); assert_eq! (unsafe { - & ( * ( 0 as * const ServoComputedValues ) ) . Padding as + & ( * ( 0 as * const ServoComputedData ) ) . Padding as * const _ as usize } , 128usize , concat ! ( - "Alignment of field: " , stringify ! ( ServoComputedValues + "Alignment of field: " , stringify ! ( ServoComputedData ) , "::" , stringify ! ( Padding ) )); assert_eq! (unsafe { - & ( * ( 0 as * const ServoComputedValues ) ) . Border as * + & ( * ( 0 as * const ServoComputedData ) ) . Border as * const _ as usize } , 136usize , concat ! ( - "Alignment of field: " , stringify ! ( ServoComputedValues + "Alignment of field: " , stringify ! ( ServoComputedData ) , "::" , stringify ! ( Border ) )); assert_eq! (unsafe { - & ( * ( 0 as * const ServoComputedValues ) ) . Outline as + & ( * ( 0 as * const ServoComputedData ) ) . Outline as * const _ as usize } , 144usize , concat ! ( - "Alignment of field: " , stringify ! ( ServoComputedValues + "Alignment of field: " , stringify ! ( ServoComputedData ) , "::" , stringify ! ( Outline ) )); assert_eq! (unsafe { - & ( * ( 0 as * const ServoComputedValues ) ) . XUL as * + & ( * ( 0 as * const ServoComputedData ) ) . XUL as * const _ as usize } , 152usize , concat ! ( - "Alignment of field: " , stringify ! ( ServoComputedValues + "Alignment of field: " , stringify ! ( ServoComputedData ) , "::" , stringify ! ( XUL ) )); assert_eq! (unsafe { - & ( * ( 0 as * const ServoComputedValues ) ) . SVGReset as + & ( * ( 0 as * const ServoComputedData ) ) . SVGReset as * const _ as usize } , 160usize , concat ! ( - "Alignment of field: " , stringify ! ( ServoComputedValues + "Alignment of field: " , stringify ! ( ServoComputedData ) , "::" , stringify ! ( SVGReset ) )); assert_eq! (unsafe { - & ( * ( 0 as * const ServoComputedValues ) ) . Column as * + & ( * ( 0 as * const ServoComputedData ) ) . Column as * const _ as usize } , 168usize , concat ! ( - "Alignment of field: " , stringify ! ( ServoComputedValues + "Alignment of field: " , stringify ! ( ServoComputedData ) , "::" , stringify ! ( Column ) )); assert_eq! (unsafe { - & ( * ( 0 as * const ServoComputedValues ) ) . Effects as + & ( * ( 0 as * const ServoComputedData ) ) . Effects as * const _ as usize } , 176usize , concat ! ( - "Alignment of field: " , stringify ! ( ServoComputedValues + "Alignment of field: " , stringify ! ( ServoComputedData ) , "::" , stringify ! ( Effects ) )); assert_eq! (unsafe { - & ( * ( 0 as * const ServoComputedValues ) ) . + & ( * ( 0 as * const ServoComputedData ) ) . custom_properties as * const _ as usize } , 184usize , concat ! ( - "Alignment of field: " , stringify ! ( ServoComputedValues + "Alignment of field: " , stringify ! ( ServoComputedData ) , "::" , stringify ! ( custom_properties ) )); assert_eq! (unsafe { - & ( * ( 0 as * const ServoComputedValues ) ) . + & ( * ( 0 as * const ServoComputedData ) ) . writing_mode as * const _ as usize } , 192usize , concat ! ( - "Alignment of field: " , stringify ! ( ServoComputedValues + "Alignment of field: " , stringify ! ( ServoComputedData ) , "::" , stringify ! ( writing_mode ) )); assert_eq! (unsafe { - & ( * ( 0 as * const ServoComputedValues ) ) . flags as * + & ( * ( 0 as * const ServoComputedData ) ) . flags as * const _ as usize } , 193usize , concat ! ( - "Alignment of field: " , stringify ! ( ServoComputedValues + "Alignment of field: " , stringify ! ( ServoComputedData ) , "::" , stringify ! ( flags ) )); assert_eq! (unsafe { - & ( * ( 0 as * const ServoComputedValues ) ) . rules as * + & ( * ( 0 as * const ServoComputedData ) ) . rules as * const _ as usize } , 200usize , concat ! ( - "Alignment of field: " , stringify ! ( ServoComputedValues + "Alignment of field: " , stringify ! ( ServoComputedData ) , "::" , stringify ! ( rules ) )); assert_eq! (unsafe { - & ( * ( 0 as * const ServoComputedValues ) ) . + & ( * ( 0 as * const ServoComputedData ) ) . visited_style as * const _ as usize } , 208usize , concat ! ( - "Alignment of field: " , stringify ! ( ServoComputedValues + "Alignment of field: " , stringify ! ( ServoComputedData ) , "::" , stringify ! ( visited_style ) )); assert_eq! (unsafe { - & ( * ( 0 as * const ServoComputedValues ) ) . + & ( * ( 0 as * const ServoComputedData ) ) . font_computation_data as * const _ as usize } , 216usize , concat ! ( - "Alignment of field: " , stringify ! ( ServoComputedValues + "Alignment of field: " , stringify ! ( ServoComputedData ) , "::" , stringify ! ( font_computation_data ) )); } #[repr(C)] #[derive(Debug, Copy)] - pub struct ServoComputedValuesForgotten { - pub mPtr: *const root::ServoComputedValues, + pub struct ServoComputedDataForgotten { + pub mPtr: *const root::ServoComputedData, } #[test] - fn bindgen_test_layout_ServoComputedValuesForgotten() { - assert_eq!(::std::mem::size_of::() , + fn bindgen_test_layout_ServoComputedDataForgotten() { + assert_eq!(::std::mem::size_of::() , 8usize , concat ! ( - "Size of: " , stringify ! ( ServoComputedValuesForgotten ) + "Size of: " , stringify ! ( ServoComputedDataForgotten ) )); - assert_eq! (::std::mem::align_of::() , + assert_eq! (::std::mem::align_of::() , 8usize , concat ! ( "Alignment of " , stringify ! ( - ServoComputedValuesForgotten ) )); + ServoComputedDataForgotten ) )); assert_eq! (unsafe { - & ( * ( 0 as * const ServoComputedValuesForgotten ) ) . + & ( * ( 0 as * const ServoComputedDataForgotten ) ) . mPtr as * const _ as usize } , 0usize , concat ! ( "Alignment of field: " , stringify ! ( - ServoComputedValuesForgotten ) , "::" , stringify ! ( mPtr + ServoComputedDataForgotten ) , "::" , stringify ! ( mPtr ) )); } - impl Clone for ServoComputedValuesForgotten { + impl Clone for ServoComputedDataForgotten { fn clone(&self) -> Self { *self } } #[repr(u32)] @@ -38455,7 +38455,7 @@ pub mod root { *const root::mozilla::ServoStyleContext; pub type ServoStyleContextBorrowedOrNull = *const root::mozilla::ServoStyleContext; - pub type ServoComputedValuesBorrowed = *const root::ServoComputedValues; + pub type ServoComputedDataBorrowed = *const root::ServoComputedData; pub type RawServoAnimationValueMapBorrowedMut = *mut root::RawServoAnimationValueMap; pub type RawGeckoNodeBorrowed = *const root::RawGeckoNode; diff --git a/components/style/gecko/generated/structs_release.rs b/components/style/gecko/generated/structs_release.rs index e87d5e7b588..1bd450faae8 100644 --- a/components/style/gecko/generated/structs_release.rs +++ b/components/style/gecko/generated/structs_release.rs @@ -7438,7 +7438,7 @@ pub mod root { pub struct ServoStyleContext { pub _base: root::nsStyleContext, pub mPresContext: *mut root::nsPresContext, - pub mSource: root::ServoComputedValues, + pub mSource: root::ServoComputedData, } #[test] fn bindgen_test_layout_ServoStyleContext() { @@ -20609,7 +20609,7 @@ pub mod root { */ #[repr(C)] #[derive(Debug)] - pub struct ServoComputedValues { + pub struct ServoComputedData { pub Font: ::gecko_bindings::structs::ServoRawOffsetArc, pub Color: ::gecko_bindings::structs::ServoRawOffsetArc, pub List: ::gecko_bindings::structs::ServoRawOffsetArc, @@ -20647,187 +20647,187 @@ pub mod root { pub font_computation_data: ::gecko_bindings::structs::ServoFontComputationData, } #[test] - fn bindgen_test_layout_ServoComputedValues() { - assert_eq!(::std::mem::size_of::() , 224usize , + fn bindgen_test_layout_ServoComputedData() { + assert_eq!(::std::mem::size_of::() , 224usize , concat ! ( - "Size of: " , stringify ! ( ServoComputedValues ) )); - assert_eq! (::std::mem::align_of::() , 8usize , + "Size of: " , stringify ! ( ServoComputedData ) )); + assert_eq! (::std::mem::align_of::() , 8usize , concat ! ( - "Alignment of " , stringify ! ( ServoComputedValues ) )); + "Alignment of " , stringify ! ( ServoComputedData ) )); assert_eq! (unsafe { - & ( * ( 0 as * const ServoComputedValues ) ) . Font as * + & ( * ( 0 as * const ServoComputedData ) ) . Font as * const _ as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( ServoComputedValues + "Alignment of field: " , stringify ! ( ServoComputedData ) , "::" , stringify ! ( Font ) )); assert_eq! (unsafe { - & ( * ( 0 as * const ServoComputedValues ) ) . Color as * + & ( * ( 0 as * const ServoComputedData ) ) . Color as * const _ as usize } , 8usize , concat ! ( - "Alignment of field: " , stringify ! ( ServoComputedValues + "Alignment of field: " , stringify ! ( ServoComputedData ) , "::" , stringify ! ( Color ) )); assert_eq! (unsafe { - & ( * ( 0 as * const ServoComputedValues ) ) . List as * + & ( * ( 0 as * const ServoComputedData ) ) . List as * const _ as usize } , 16usize , concat ! ( - "Alignment of field: " , stringify ! ( ServoComputedValues + "Alignment of field: " , stringify ! ( ServoComputedData ) , "::" , stringify ! ( List ) )); assert_eq! (unsafe { - & ( * ( 0 as * const ServoComputedValues ) ) . Text as * + & ( * ( 0 as * const ServoComputedData ) ) . Text as * const _ as usize } , 24usize , concat ! ( - "Alignment of field: " , stringify ! ( ServoComputedValues + "Alignment of field: " , stringify ! ( ServoComputedData ) , "::" , stringify ! ( Text ) )); assert_eq! (unsafe { - & ( * ( 0 as * const ServoComputedValues ) ) . Visibility + & ( * ( 0 as * const ServoComputedData ) ) . Visibility as * const _ as usize } , 32usize , concat ! ( - "Alignment of field: " , stringify ! ( ServoComputedValues + "Alignment of field: " , stringify ! ( ServoComputedData ) , "::" , stringify ! ( Visibility ) )); assert_eq! (unsafe { - & ( * ( 0 as * const ServoComputedValues ) ) . + & ( * ( 0 as * const ServoComputedData ) ) . UserInterface as * const _ as usize } , 40usize , concat ! ( - "Alignment of field: " , stringify ! ( ServoComputedValues + "Alignment of field: " , stringify ! ( ServoComputedData ) , "::" , stringify ! ( UserInterface ) )); assert_eq! (unsafe { - & ( * ( 0 as * const ServoComputedValues ) ) . TableBorder + & ( * ( 0 as * const ServoComputedData ) ) . TableBorder as * const _ as usize } , 48usize , concat ! ( - "Alignment of field: " , stringify ! ( ServoComputedValues + "Alignment of field: " , stringify ! ( ServoComputedData ) , "::" , stringify ! ( TableBorder ) )); assert_eq! (unsafe { - & ( * ( 0 as * const ServoComputedValues ) ) . SVG as * + & ( * ( 0 as * const ServoComputedData ) ) . SVG as * const _ as usize } , 56usize , concat ! ( - "Alignment of field: " , stringify ! ( ServoComputedValues + "Alignment of field: " , stringify ! ( ServoComputedData ) , "::" , stringify ! ( SVG ) )); assert_eq! (unsafe { - & ( * ( 0 as * const ServoComputedValues ) ) . Background + & ( * ( 0 as * const ServoComputedData ) ) . Background as * const _ as usize } , 64usize , concat ! ( - "Alignment of field: " , stringify ! ( ServoComputedValues + "Alignment of field: " , stringify ! ( ServoComputedData ) , "::" , stringify ! ( Background ) )); assert_eq! (unsafe { - & ( * ( 0 as * const ServoComputedValues ) ) . Position as + & ( * ( 0 as * const ServoComputedData ) ) . Position as * const _ as usize } , 72usize , concat ! ( - "Alignment of field: " , stringify ! ( ServoComputedValues + "Alignment of field: " , stringify ! ( ServoComputedData ) , "::" , stringify ! ( Position ) )); assert_eq! (unsafe { - & ( * ( 0 as * const ServoComputedValues ) ) . TextReset + & ( * ( 0 as * const ServoComputedData ) ) . TextReset as * const _ as usize } , 80usize , concat ! ( - "Alignment of field: " , stringify ! ( ServoComputedValues + "Alignment of field: " , stringify ! ( ServoComputedData ) , "::" , stringify ! ( TextReset ) )); assert_eq! (unsafe { - & ( * ( 0 as * const ServoComputedValues ) ) . Display as + & ( * ( 0 as * const ServoComputedData ) ) . Display as * const _ as usize } , 88usize , concat ! ( - "Alignment of field: " , stringify ! ( ServoComputedValues + "Alignment of field: " , stringify ! ( ServoComputedData ) , "::" , stringify ! ( Display ) )); assert_eq! (unsafe { - & ( * ( 0 as * const ServoComputedValues ) ) . Content as + & ( * ( 0 as * const ServoComputedData ) ) . Content as * const _ as usize } , 96usize , concat ! ( - "Alignment of field: " , stringify ! ( ServoComputedValues + "Alignment of field: " , stringify ! ( ServoComputedData ) , "::" , stringify ! ( Content ) )); assert_eq! (unsafe { - & ( * ( 0 as * const ServoComputedValues ) ) . UIReset as + & ( * ( 0 as * const ServoComputedData ) ) . UIReset as * const _ as usize } , 104usize , concat ! ( - "Alignment of field: " , stringify ! ( ServoComputedValues + "Alignment of field: " , stringify ! ( ServoComputedData ) , "::" , stringify ! ( UIReset ) )); assert_eq! (unsafe { - & ( * ( 0 as * const ServoComputedValues ) ) . Table as * + & ( * ( 0 as * const ServoComputedData ) ) . Table as * const _ as usize } , 112usize , concat ! ( - "Alignment of field: " , stringify ! ( ServoComputedValues + "Alignment of field: " , stringify ! ( ServoComputedData ) , "::" , stringify ! ( Table ) )); assert_eq! (unsafe { - & ( * ( 0 as * const ServoComputedValues ) ) . Margin as * + & ( * ( 0 as * const ServoComputedData ) ) . Margin as * const _ as usize } , 120usize , concat ! ( - "Alignment of field: " , stringify ! ( ServoComputedValues + "Alignment of field: " , stringify ! ( ServoComputedData ) , "::" , stringify ! ( Margin ) )); assert_eq! (unsafe { - & ( * ( 0 as * const ServoComputedValues ) ) . Padding as + & ( * ( 0 as * const ServoComputedData ) ) . Padding as * const _ as usize } , 128usize , concat ! ( - "Alignment of field: " , stringify ! ( ServoComputedValues + "Alignment of field: " , stringify ! ( ServoComputedData ) , "::" , stringify ! ( Padding ) )); assert_eq! (unsafe { - & ( * ( 0 as * const ServoComputedValues ) ) . Border as * + & ( * ( 0 as * const ServoComputedData ) ) . Border as * const _ as usize } , 136usize , concat ! ( - "Alignment of field: " , stringify ! ( ServoComputedValues + "Alignment of field: " , stringify ! ( ServoComputedData ) , "::" , stringify ! ( Border ) )); assert_eq! (unsafe { - & ( * ( 0 as * const ServoComputedValues ) ) . Outline as + & ( * ( 0 as * const ServoComputedData ) ) . Outline as * const _ as usize } , 144usize , concat ! ( - "Alignment of field: " , stringify ! ( ServoComputedValues + "Alignment of field: " , stringify ! ( ServoComputedData ) , "::" , stringify ! ( Outline ) )); assert_eq! (unsafe { - & ( * ( 0 as * const ServoComputedValues ) ) . XUL as * + & ( * ( 0 as * const ServoComputedData ) ) . XUL as * const _ as usize } , 152usize , concat ! ( - "Alignment of field: " , stringify ! ( ServoComputedValues + "Alignment of field: " , stringify ! ( ServoComputedData ) , "::" , stringify ! ( XUL ) )); assert_eq! (unsafe { - & ( * ( 0 as * const ServoComputedValues ) ) . SVGReset as + & ( * ( 0 as * const ServoComputedData ) ) . SVGReset as * const _ as usize } , 160usize , concat ! ( - "Alignment of field: " , stringify ! ( ServoComputedValues + "Alignment of field: " , stringify ! ( ServoComputedData ) , "::" , stringify ! ( SVGReset ) )); assert_eq! (unsafe { - & ( * ( 0 as * const ServoComputedValues ) ) . Column as * + & ( * ( 0 as * const ServoComputedData ) ) . Column as * const _ as usize } , 168usize , concat ! ( - "Alignment of field: " , stringify ! ( ServoComputedValues + "Alignment of field: " , stringify ! ( ServoComputedData ) , "::" , stringify ! ( Column ) )); assert_eq! (unsafe { - & ( * ( 0 as * const ServoComputedValues ) ) . Effects as + & ( * ( 0 as * const ServoComputedData ) ) . Effects as * const _ as usize } , 176usize , concat ! ( - "Alignment of field: " , stringify ! ( ServoComputedValues + "Alignment of field: " , stringify ! ( ServoComputedData ) , "::" , stringify ! ( Effects ) )); assert_eq! (unsafe { - & ( * ( 0 as * const ServoComputedValues ) ) . + & ( * ( 0 as * const ServoComputedData ) ) . custom_properties as * const _ as usize } , 184usize , concat ! ( - "Alignment of field: " , stringify ! ( ServoComputedValues + "Alignment of field: " , stringify ! ( ServoComputedData ) , "::" , stringify ! ( custom_properties ) )); assert_eq! (unsafe { - & ( * ( 0 as * const ServoComputedValues ) ) . + & ( * ( 0 as * const ServoComputedData ) ) . writing_mode as * const _ as usize } , 192usize , concat ! ( - "Alignment of field: " , stringify ! ( ServoComputedValues + "Alignment of field: " , stringify ! ( ServoComputedData ) , "::" , stringify ! ( writing_mode ) )); assert_eq! (unsafe { - & ( * ( 0 as * const ServoComputedValues ) ) . flags as * + & ( * ( 0 as * const ServoComputedData ) ) . flags as * const _ as usize } , 193usize , concat ! ( - "Alignment of field: " , stringify ! ( ServoComputedValues + "Alignment of field: " , stringify ! ( ServoComputedData ) , "::" , stringify ! ( flags ) )); assert_eq! (unsafe { - & ( * ( 0 as * const ServoComputedValues ) ) . rules as * + & ( * ( 0 as * const ServoComputedData ) ) . rules as * const _ as usize } , 200usize , concat ! ( - "Alignment of field: " , stringify ! ( ServoComputedValues + "Alignment of field: " , stringify ! ( ServoComputedData ) , "::" , stringify ! ( rules ) )); assert_eq! (unsafe { - & ( * ( 0 as * const ServoComputedValues ) ) . + & ( * ( 0 as * const ServoComputedData ) ) . visited_style as * const _ as usize } , 208usize , concat ! ( - "Alignment of field: " , stringify ! ( ServoComputedValues + "Alignment of field: " , stringify ! ( ServoComputedData ) , "::" , stringify ! ( visited_style ) )); assert_eq! (unsafe { - & ( * ( 0 as * const ServoComputedValues ) ) . + & ( * ( 0 as * const ServoComputedData ) ) . font_computation_data as * const _ as usize } , 216usize , concat ! ( - "Alignment of field: " , stringify ! ( ServoComputedValues + "Alignment of field: " , stringify ! ( ServoComputedData ) , "::" , stringify ! ( font_computation_data ) )); } #[repr(C)] #[derive(Debug, Copy)] - pub struct ServoComputedValuesForgotten { - pub mPtr: *const root::ServoComputedValues, + pub struct ServoComputedDataForgotten { + pub mPtr: *const root::ServoComputedData, } #[test] - fn bindgen_test_layout_ServoComputedValuesForgotten() { - assert_eq!(::std::mem::size_of::() , + fn bindgen_test_layout_ServoComputedDataForgotten() { + assert_eq!(::std::mem::size_of::() , 8usize , concat ! ( - "Size of: " , stringify ! ( ServoComputedValuesForgotten ) + "Size of: " , stringify ! ( ServoComputedDataForgotten ) )); - assert_eq! (::std::mem::align_of::() , + assert_eq! (::std::mem::align_of::() , 8usize , concat ! ( "Alignment of " , stringify ! ( - ServoComputedValuesForgotten ) )); + ServoComputedDataForgotten ) )); assert_eq! (unsafe { - & ( * ( 0 as * const ServoComputedValuesForgotten ) ) . + & ( * ( 0 as * const ServoComputedDataForgotten ) ) . mPtr as * const _ as usize } , 0usize , concat ! ( "Alignment of field: " , stringify ! ( - ServoComputedValuesForgotten ) , "::" , stringify ! ( mPtr + ServoComputedDataForgotten ) , "::" , stringify ! ( mPtr ) )); } - impl Clone for ServoComputedValuesForgotten { + impl Clone for ServoComputedDataForgotten { fn clone(&self) -> Self { *self } } #[repr(u32)] @@ -37764,7 +37764,7 @@ pub mod root { *const root::mozilla::ServoStyleContext; pub type ServoStyleContextBorrowedOrNull = *const root::mozilla::ServoStyleContext; - pub type ServoComputedValuesBorrowed = *const root::ServoComputedValues; + pub type ServoComputedDataBorrowed = *const root::ServoComputedData; pub type RawServoAnimationValueMapBorrowedMut = *mut root::RawServoAnimationValueMap; pub type RawGeckoNodeBorrowed = *const root::RawGeckoNode; diff --git a/components/style/properties/gecko.mako.rs b/components/style/properties/gecko.mako.rs index e238f25069f..ede7eac91a7 100644 --- a/components/style/properties/gecko.mako.rs +++ b/components/style/properties/gecko.mako.rs @@ -73,7 +73,7 @@ pub mod style_structs { } /// FIXME(emilio): This is completely duplicated with the other properties code. -pub type ComputedValuesInner = ::gecko_bindings::structs::ServoComputedValues; +pub type ComputedValuesInner = ::gecko_bindings::structs::ServoComputedData; #[derive(Debug)] #[repr(C)] diff --git a/ports/geckolib/glue.rs b/ports/geckolib/glue.rs index 52ac9419aa2..7abddf977da 100644 --- a/ports/geckolib/glue.rs +++ b/ports/geckolib/glue.rs @@ -39,7 +39,7 @@ use style::gecko_bindings::bindings::{RawServoMediaRule, RawServoMediaRuleBorrow use style::gecko_bindings::bindings::{RawServoNamespaceRule, RawServoNamespaceRuleBorrowed}; use style::gecko_bindings::bindings::{RawServoPageRule, RawServoPageRuleBorrowed}; use style::gecko_bindings::bindings::{RawServoStyleSetBorrowed, RawServoStyleSetOwned}; -use style::gecko_bindings::bindings::{RawServoStyleSheetContentsBorrowed, ServoComputedValuesBorrowed}; +use style::gecko_bindings::bindings::{RawServoStyleSheetContentsBorrowed, ServoComputedDataBorrowed}; use style::gecko_bindings::bindings::{RawServoStyleSheetContentsStrong, ServoStyleContextBorrowed}; use style::gecko_bindings::bindings::{RawServoSupportsRule, RawServoSupportsRuleBorrowed}; use style::gecko_bindings::bindings::{ServoCssRulesBorrowed, ServoCssRulesStrong}; @@ -1754,8 +1754,8 @@ pub extern "C" fn Servo_ComputedValues_SpecifiesAnimationsOrTransitions(values: #[no_mangle] pub extern "C" fn Servo_ComputedValues_EqualCustomProperties( - first: ServoComputedValuesBorrowed, - second: ServoComputedValuesBorrowed + first: ServoComputedDataBorrowed, + second: ServoComputedDataBorrowed ) -> bool { first.get_custom_properties() == second.get_custom_properties() }