diff options
-rw-r--r-- | components/style/build_gecko.rs | 3 | ||||
-rw-r--r-- | components/style/gecko/arc_types.rs | 5 | ||||
-rw-r--r-- | components/style/gecko_bindings/bindings.rs | 13 | ||||
-rw-r--r-- | components/style/gecko_bindings/structs_debug.rs | 7 | ||||
-rw-r--r-- | components/style/gecko_bindings/structs_release.rs | 7 | ||||
-rw-r--r-- | ports/geckolib/glue.rs | 30 |
6 files changed, 59 insertions, 6 deletions
diff --git a/components/style/build_gecko.rs b/components/style/build_gecko.rs index 85997cdb3c2..26f9c51bb4b 100644 --- a/components/style/build_gecko.rs +++ b/components/style/build_gecko.rs @@ -614,9 +614,11 @@ mod bindings { "RawServoAnimationValue", "RawServoAnimationValueMap", "RawServoDeclarationBlock", + "RawServoStyleRule", "RawGeckoPresContext", "RawGeckoPresContextOwned", "RawGeckoStyleAnimationList", + "RawGeckoServoStyleRuleList", "RawGeckoURLExtraData", "RefPtr", "CSSPseudoClassType", @@ -731,6 +733,7 @@ mod bindings { "RawGeckoKeyframeList", "RawGeckoComputedKeyframeValuesList", "RawGeckoFontFaceRuleList", + "RawGeckoServoStyleRuleList", ]; for &ty in structs_types.iter() { builder = builder.hide_type(ty) diff --git a/components/style/gecko/arc_types.rs b/components/style/gecko/arc_types.rs index 0f8d336b2e2..f733349e203 100644 --- a/components/style/gecko/arc_types.rs +++ b/components/style/gecko/arc_types.rs @@ -9,9 +9,10 @@ #![allow(non_snake_case, missing_docs)] use gecko_bindings::bindings::{RawServoMediaList, RawServoMediaRule, RawServoNamespaceRule, RawServoPageRule}; -use gecko_bindings::bindings::{RawServoStyleSheet, RawServoStyleRule, RawServoImportRule}; +use gecko_bindings::bindings::{RawServoStyleSheet, RawServoImportRule}; use gecko_bindings::bindings::{ServoComputedValues, ServoCssRules}; -use gecko_bindings::structs::{RawServoAnimationValue, RawServoAnimationValueMap, RawServoDeclarationBlock}; +use gecko_bindings::structs::{RawServoAnimationValue, RawServoAnimationValueMap}; +use gecko_bindings::structs::{RawServoDeclarationBlock, RawServoStyleRule}; use gecko_bindings::sugar::ownership::{HasArcFFI, HasFFI}; use media_queries::MediaList; use parking_lot::RwLock; diff --git a/components/style/gecko_bindings/bindings.rs b/components/style/gecko_bindings/bindings.rs index 9f9ed20ff44..205402392cf 100644 --- a/components/style/gecko_bindings/bindings.rs +++ b/components/style/gecko_bindings/bindings.rs @@ -16,9 +16,11 @@ use gecko_bindings::structs::RawGeckoAnimationValueList; use gecko_bindings::structs::RawServoAnimationValue; use gecko_bindings::structs::RawServoAnimationValueMap; use gecko_bindings::structs::RawServoDeclarationBlock; +use gecko_bindings::structs::RawServoStyleRule; use gecko_bindings::structs::RawGeckoPresContext; use gecko_bindings::structs::RawGeckoPresContextOwned; use gecko_bindings::structs::RawGeckoStyleAnimationList; +use gecko_bindings::structs::RawGeckoServoStyleRuleList; use gecko_bindings::structs::RawGeckoURLExtraData; use gecko_bindings::structs::RefPtr; use gecko_bindings::structs::CSSPseudoClassType; @@ -207,8 +209,6 @@ pub type RawServoDeclarationBlockBorrowedOrNull<'a> = Option<&'a RawServoDeclara pub type RawServoStyleRuleStrong = ::gecko_bindings::sugar::ownership::Strong<RawServoStyleRule>; pub type RawServoStyleRuleBorrowed<'a> = &'a RawServoStyleRule; pub type RawServoStyleRuleBorrowedOrNull<'a> = Option<&'a RawServoStyleRule>; -enum RawServoStyleRuleVoid { } -pub struct RawServoStyleRule(RawServoStyleRuleVoid); pub type RawServoImportRuleStrong = ::gecko_bindings::sugar::ownership::Strong<RawServoImportRule>; pub type RawServoImportRuleBorrowed<'a> = &'a RawServoImportRule; pub type RawServoImportRuleBorrowedOrNull<'a> = Option<&'a RawServoImportRule>; @@ -306,6 +306,10 @@ pub type RawGeckoFontFaceRuleListBorrowed<'a> = &'a RawGeckoFontFaceRuleList; pub type RawGeckoFontFaceRuleListBorrowedOrNull<'a> = Option<&'a RawGeckoFontFaceRuleList>; pub type RawGeckoFontFaceRuleListBorrowedMut<'a> = &'a mut RawGeckoFontFaceRuleList; pub type RawGeckoFontFaceRuleListBorrowedMutOrNull<'a> = Option<&'a mut RawGeckoFontFaceRuleList>; +pub type RawGeckoServoStyleRuleListBorrowed<'a> = &'a RawGeckoServoStyleRuleList; +pub type RawGeckoServoStyleRuleListBorrowedOrNull<'a> = Option<&'a RawGeckoServoStyleRuleList>; +pub type RawGeckoServoStyleRuleListBorrowedMut<'a> = &'a mut RawGeckoServoStyleRuleList; +pub type RawGeckoServoStyleRuleListBorrowedMutOrNull<'a> = Option<&'a mut RawGeckoServoStyleRuleList>; extern "C" { pub fn Gecko_EnsureTArrayCapacity(aArray: *mut ::std::os::raw::c_void, @@ -1912,6 +1916,11 @@ extern "C" { -> *mut ServoElementSnapshot; } extern "C" { + pub fn Servo_Element_GetStyleRuleList(element: RawGeckoElementBorrowed, + rules: + RawGeckoServoStyleRuleListBorrowedMut); +} +extern "C" { pub fn Servo_NoteExplicitHints(element: RawGeckoElementBorrowed, restyle_hint: nsRestyleHint, change_hint: nsChangeHint); diff --git a/components/style/gecko_bindings/structs_debug.rs b/components/style/gecko_bindings/structs_debug.rs index 1c65c51d414..5a1a00a57ad 100644 --- a/components/style/gecko_bindings/structs_debug.rs +++ b/components/style/gecko_bindings/structs_debug.rs @@ -26659,6 +26659,9 @@ pub mod root { pub struct RawServoDeclarationBlock([u8; 0]); #[repr(C)] #[derive(Debug, Copy, Clone)] + pub struct RawServoStyleRule([u8; 0]); + #[repr(C)] + #[derive(Debug, Copy, Clone)] pub struct RawServoAnimationValue([u8; 0]); #[repr(C)] #[derive(Debug, Copy, Clone)] @@ -26680,6 +26683,8 @@ pub mod root { pub type RawGeckoAnimationPropertySegment = root::mozilla::AnimationPropertySegment; pub type RawGeckoComputedTiming = root::mozilla::ComputedTiming; + pub type RawGeckoServoStyleRuleList = + root::nsTArray<*const root::RawServoStyleRule>; pub type RawServoAnimationValueMapBorrowed = *const root::RawServoAnimationValueMap; pub type RawGeckoNodeBorrowed = *const root::RawGeckoNode; @@ -26706,6 +26711,8 @@ pub mod root { *const root::RawGeckoAnimationPropertySegment; pub type RawGeckoComputedTimingBorrowed = *const root::RawGeckoComputedTiming; + pub type RawGeckoServoStyleRuleListBorrowedMut = + *mut root::RawGeckoServoStyleRuleList; #[repr(C)] #[derive(Debug, Copy, Clone)] pub struct nsSVGAngle([u8; 0]); diff --git a/components/style/gecko_bindings/structs_release.rs b/components/style/gecko_bindings/structs_release.rs index e75474a2b43..ea795902144 100644 --- a/components/style/gecko_bindings/structs_release.rs +++ b/components/style/gecko_bindings/structs_release.rs @@ -26000,6 +26000,9 @@ pub mod root { pub struct RawServoDeclarationBlock([u8; 0]); #[repr(C)] #[derive(Debug, Copy, Clone)] + pub struct RawServoStyleRule([u8; 0]); + #[repr(C)] + #[derive(Debug, Copy, Clone)] pub struct RawServoAnimationValue([u8; 0]); #[repr(C)] #[derive(Debug, Copy, Clone)] @@ -26021,6 +26024,8 @@ pub mod root { pub type RawGeckoAnimationPropertySegment = root::mozilla::AnimationPropertySegment; pub type RawGeckoComputedTiming = root::mozilla::ComputedTiming; + pub type RawGeckoServoStyleRuleList = + root::nsTArray<*const root::RawServoStyleRule>; pub type RawServoAnimationValueMapBorrowed = *const root::RawServoAnimationValueMap; pub type RawGeckoNodeBorrowed = *const root::RawGeckoNode; @@ -26047,6 +26052,8 @@ pub mod root { *const root::RawGeckoAnimationPropertySegment; pub type RawGeckoComputedTimingBorrowed = *const root::RawGeckoComputedTiming; + pub type RawGeckoServoStyleRuleListBorrowedMut = + *mut root::RawGeckoServoStyleRuleList; #[repr(C)] #[derive(Debug, Copy, Clone)] pub struct nsSVGAngle([u8; 0]); diff --git a/ports/geckolib/glue.rs b/ports/geckolib/glue.rs index 69393e98ce3..04f1ee6c9ed 100644 --- a/ports/geckolib/glue.rs +++ b/ports/geckolib/glue.rs @@ -34,7 +34,6 @@ use style::gecko_bindings::bindings::{RawServoMediaListBorrowed, RawServoMediaLi use style::gecko_bindings::bindings::{RawServoMediaRule, RawServoMediaRuleBorrowed}; use style::gecko_bindings::bindings::{RawServoNamespaceRule, RawServoNamespaceRuleBorrowed}; use style::gecko_bindings::bindings::{RawServoPageRule, RawServoPageRuleBorrowed}; -use style::gecko_bindings::bindings::{RawServoStyleRule, RawServoStyleRuleBorrowed}; use style::gecko_bindings::bindings::{RawServoStyleSetBorrowed, RawServoStyleSetOwned}; use style::gecko_bindings::bindings::{RawServoStyleSheetBorrowed, ServoComputedValuesBorrowed}; use style::gecko_bindings::bindings::{RawServoStyleSheetStrong, ServoComputedValuesStrong}; @@ -46,20 +45,22 @@ use style::gecko_bindings::bindings::RawGeckoComputedKeyframeValuesListBorrowedM use style::gecko_bindings::bindings::RawGeckoComputedTimingBorrowed; use style::gecko_bindings::bindings::RawGeckoElementBorrowed; use style::gecko_bindings::bindings::RawGeckoFontFaceRuleListBorrowedMut; +use style::gecko_bindings::bindings::RawGeckoServoStyleRuleListBorrowedMut; use style::gecko_bindings::bindings::RawServoAnimationValueBorrowed; use style::gecko_bindings::bindings::RawServoAnimationValueMapBorrowed; use style::gecko_bindings::bindings::RawServoAnimationValueStrong; use style::gecko_bindings::bindings::RawServoImportRuleBorrowed; +use style::gecko_bindings::bindings::RawServoStyleRuleBorrowed; use style::gecko_bindings::bindings::ServoComputedValuesBorrowedOrNull; use style::gecko_bindings::bindings::nsTArrayBorrowed_uintptr_t; use style::gecko_bindings::bindings::nsTimingFunctionBorrowed; use style::gecko_bindings::bindings::nsTimingFunctionBorrowedMut; use style::gecko_bindings::structs; +use style::gecko_bindings::structs::{RawServoStyleRule, ServoStyleSheet}; use style::gecko_bindings::structs::{SheetParsingMode, nsIAtom, nsCSSPropertyID}; use style::gecko_bindings::structs::{nsRestyleHint, nsChangeHint, nsCSSFontFaceRule}; use style::gecko_bindings::structs::Loader; use style::gecko_bindings::structs::RawGeckoPresContextOwned; -use style::gecko_bindings::structs::ServoStyleSheet; use style::gecko_bindings::structs::URLExtraData; use style::gecko_bindings::structs::nsCSSValueSharedList; use style::gecko_bindings::structs::nsresult; @@ -77,6 +78,7 @@ use style::properties::SKIP_ROOT_AND_ITEM_BASED_DISPLAY_FIXUP; use style::properties::animated_properties::{AnimationValue, Interpolate, TransitionProperty}; use style::properties::parse_one_declaration; use style::restyle_hints::{self, RestyleHint}; +use style::rule_tree::StyleSource; use style::selector_parser::PseudoElementCascadeType; use style::sequential; use style::shared_lock::{SharedRwLock, SharedRwLockReadGuard, StylesheetGuards, ToCssWithGuard, Locked}; @@ -1561,6 +1563,30 @@ pub extern "C" fn Servo_Element_GetSnapshot(element: RawGeckoElementBorrowed) -> } #[no_mangle] +pub extern "C" fn Servo_Element_GetStyleRuleList(element: RawGeckoElementBorrowed, + rules: RawGeckoServoStyleRuleListBorrowedMut) { + let element = GeckoElement(element); + let data = match element.borrow_data() { + Some(element_data) => element_data, + None => return, + }; + let computed = match data.get_styles() { + Some(styles) => &styles.primary, + None => return, + }; + let mut result = vec![]; + for rule_node in computed.rules.self_and_ancestors() { + if let Some(&StyleSource::Style(ref rule)) = rule_node.style_source() { + result.push(Locked::<StyleRule>::arc_as_borrowed(&rule)); + } + } + unsafe { rules.set_len(result.len() as u32) }; + for (&src, dest) in result.into_iter().zip(rules.iter_mut()) { + *dest = src; + } +} + +#[no_mangle] pub extern "C" fn Servo_NoteExplicitHints(element: RawGeckoElementBorrowed, restyle_hint: nsRestyleHint, change_hint: nsChangeHint) { |