From a9ecebbe328a867ab2975af5fc8de50966023a67 Mon Sep 17 00:00:00 2001 From: "J. Ryan Stinnett" Date: Fri, 31 Mar 2017 16:13:47 -0500 Subject: [PATCH] Servo glue for @page rule Expose new glue functions and types on the Servo side for working with @page rules from Gecko. MozReview-Commit-ID: 5g13YldTr9 --- components/style/gecko/arc_types.rs | 7 +++++-- ports/geckolib/glue.rs | 25 ++++++++++++++++++++++++- 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/components/style/gecko/arc_types.rs b/components/style/gecko/arc_types.rs index 349fca1bbcbb..0f8d336b2e29 100644 --- a/components/style/gecko/arc_types.rs +++ b/components/style/gecko/arc_types.rs @@ -8,7 +8,7 @@ #![allow(non_snake_case, missing_docs)] -use gecko_bindings::bindings::{RawServoMediaList, RawServoMediaRule, RawServoNamespaceRule}; +use gecko_bindings::bindings::{RawServoMediaList, RawServoMediaRule, RawServoNamespaceRule, RawServoPageRule}; use gecko_bindings::bindings::{RawServoStyleSheet, RawServoStyleRule, RawServoImportRule}; use gecko_bindings::bindings::{ServoComputedValues, ServoCssRules}; use gecko_bindings::structs::{RawServoAnimationValue, RawServoAnimationValueMap, RawServoDeclarationBlock}; @@ -18,7 +18,7 @@ use parking_lot::RwLock; use properties::{ComputedValues, PropertyDeclarationBlock}; use properties::animated_properties::{AnimationValue, AnimationValueMap}; use shared_lock::Locked; -use stylesheets::{CssRules, Stylesheet, StyleRule, ImportRule, MediaRule, NamespaceRule}; +use stylesheets::{CssRules, Stylesheet, StyleRule, ImportRule, MediaRule, NamespaceRule, PageRule}; macro_rules! impl_arc_ffi { ($servo_type:ty => $gecko_type:ty [$addref:ident, $release:ident]) => { @@ -71,3 +71,6 @@ impl_arc_ffi!(Locked => RawServoMediaRule impl_arc_ffi!(Locked => RawServoNamespaceRule [Servo_NamespaceRule_AddRef, Servo_NamespaceRule_Release]); + +impl_arc_ffi!(Locked => RawServoPageRule + [Servo_PageRule_AddRef, Servo_PageRule_Release]); diff --git a/ports/geckolib/glue.rs b/ports/geckolib/glue.rs index a0e9a6fc68d3..902667439ec6 100644 --- a/ports/geckolib/glue.rs +++ b/ports/geckolib/glue.rs @@ -32,6 +32,7 @@ use style::gecko_bindings::bindings::{RawServoDeclarationBlockBorrowed, RawServo use style::gecko_bindings::bindings::{RawServoMediaListBorrowed, RawServoMediaListStrong}; 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}; @@ -79,7 +80,7 @@ use style::selector_parser::PseudoElementCascadeType; use style::sequential; use style::shared_lock::{SharedRwLock, SharedRwLockReadGuard, StylesheetGuards, ToCssWithGuard, Locked}; use style::string_cache::Atom; -use style::stylesheets::{CssRule, CssRules, CssRuleType, ImportRule, MediaRule, NamespaceRule}; +use style::stylesheets::{CssRule, CssRules, CssRuleType, ImportRule, MediaRule, NamespaceRule, PageRule}; use style::stylesheets::{Origin, Stylesheet, StyleRule}; use style::stylesheets::StylesheetLoader as StyleStylesheetLoader; use style::supports::parse_condition_or_declaration; @@ -731,6 +732,12 @@ impl_basic_rule_funcs! { (Namespace, NamespaceRule, RawServoNamespaceRule), to_css: Servo_NamespaceRule_GetCssText, } +impl_basic_rule_funcs! { (Page, PageRule, RawServoPageRule), + getter: Servo_CssRules_GetPageRuleAt, + debug: Servo_PageRule_Debug, + to_css: Servo_PageRule_GetCssText, +} + #[no_mangle] pub extern "C" fn Servo_CssRules_GetFontFaceRuleAt(rules: ServoCssRulesBorrowed, index: u32) -> *mut nsCSSFontFaceRule @@ -793,6 +800,22 @@ pub extern "C" fn Servo_NamespaceRule_GetURI(rule: RawServoNamespaceRuleBorrowed read_locked_arc(rule, |rule: &NamespaceRule| rule.url.0.as_ptr()) } +#[no_mangle] +pub extern "C" fn Servo_PageRule_GetStyle(rule: RawServoPageRuleBorrowed) -> RawServoDeclarationBlockStrong { + read_locked_arc(rule, |rule: &PageRule| { + rule.0.clone().into_strong() + }) +} + +#[no_mangle] +pub extern "C" fn Servo_PageRule_SetStyle(rule: RawServoPageRuleBorrowed, + declarations: RawServoDeclarationBlockBorrowed) { + let declarations = Locked::::as_arc(&declarations); + write_locked_arc(rule, |rule: &mut PageRule| { + rule.0 = declarations.clone(); + }) +} + #[no_mangle] pub extern "C" fn Servo_ComputedValues_GetForAnonymousBox(parent_style_or_null: ServoComputedValuesBorrowedOrNull, pseudo_tag: *mut nsIAtom,