From 25896c384ffcd8083318817a33f91b64902c1f69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Naz=C4=B1m=20Can=20Alt=C4=B1nova?= Date: Thu, 27 Jul 2017 11:20:19 -0700 Subject: [PATCH] stylo: Create ServoFontFeatureValuesRule and bind servo data Add ServoFontFeatureValuesRule for CSSOM representation of @font-feature-values rule and wire up with bindings. --- components/style/gecko/arc_types.rs | 7 +++- components/style/gecko/generated/bindings.rs | 41 ++++++++++++++++++++ ports/geckolib/glue.rs | 25 +++++++++++- 3 files changed, 70 insertions(+), 3 deletions(-) diff --git a/components/style/gecko/arc_types.rs b/components/style/gecko/arc_types.rs index f25d5ef6f5f..21afd37217c 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::{RawServoImportRule, RawServoSupportsRule}; +use gecko_bindings::bindings::{RawServoFontFeatureValuesRule, RawServoImportRule, RawServoSupportsRule}; use gecko_bindings::bindings::{RawServoKeyframe, RawServoKeyframesRule}; use gecko_bindings::bindings::{RawServoMediaRule, RawServoNamespaceRule, RawServoPageRule}; use gecko_bindings::bindings::{RawServoRuleNode, RawServoRuleNodeStrong, RawServoDocumentRule}; @@ -24,7 +24,7 @@ use servo_arc::{Arc, ArcBorrow}; use shared_lock::Locked; use std::{mem, ptr}; use stylesheets::{CssRules, StylesheetContents, StyleRule, ImportRule, KeyframesRule, MediaRule}; -use stylesheets::{NamespaceRule, PageRule, SupportsRule, DocumentRule}; +use stylesheets::{FontFeatureValuesRule, NamespaceRule, PageRule, SupportsRule, DocumentRule}; use stylesheets::keyframes_rule::Keyframe; macro_rules! impl_arc_ffi { @@ -88,6 +88,9 @@ impl_arc_ffi!(Locked => RawServoSupportsRule impl_arc_ffi!(Locked => RawServoDocumentRule [Servo_DocumentRule_AddRef, Servo_DocumentRule_Release]); +impl_arc_ffi!(Locked => RawServoFontFeatureValuesRule + [Servo_FontFeatureValuesRule_AddRef, Servo_FontFeatureValuesRule_Release]); + // RuleNode is a Arc-like type but it does not use Arc. impl StrongRuleNode { diff --git a/components/style/gecko/generated/bindings.rs b/components/style/gecko/generated/bindings.rs index 223aec0692b..a966f356f35 100644 --- a/components/style/gecko/generated/bindings.rs +++ b/components/style/gecko/generated/bindings.rs @@ -378,6 +378,11 @@ pub type RawServoDocumentRuleBorrowed<'a> = &'a RawServoDocumentRule; pub type RawServoDocumentRuleBorrowedOrNull<'a> = Option<&'a RawServoDocumentRule>; enum RawServoDocumentRuleVoid { } pub struct RawServoDocumentRule(RawServoDocumentRuleVoid); +pub type RawServoFontFeatureValuesRuleStrong = ::gecko_bindings::sugar::ownership::Strong; +pub type RawServoFontFeatureValuesRuleBorrowed<'a> = &'a RawServoFontFeatureValuesRule; +pub type RawServoFontFeatureValuesRuleBorrowedOrNull<'a> = Option<&'a RawServoFontFeatureValuesRule>; +enum RawServoFontFeatureValuesRuleVoid { } +pub struct RawServoFontFeatureValuesRule(RawServoFontFeatureValuesRuleVoid); pub type RawServoRuleNodeStrong = ::gecko_bindings::sugar::ownership::Strong; pub type RawServoRuleNodeBorrowed<'a> = &'a RawServoRuleNode; pub type RawServoRuleNodeBorrowedOrNull<'a> = Option<&'a RawServoRuleNode>; @@ -480,6 +485,14 @@ extern "C" { extern "C" { pub fn Servo_DocumentRule_Release(ptr: RawServoDocumentRuleBorrowed); } +extern "C" { + pub fn Servo_FontFeatureValuesRule_AddRef(ptr: + RawServoFontFeatureValuesRuleBorrowed); +} +extern "C" { + pub fn Servo_FontFeatureValuesRule_Release(ptr: + RawServoFontFeatureValuesRuleBorrowed); +} extern "C" { pub fn Servo_RuleNode_AddRef(ptr: RawServoRuleNodeBorrowed); } @@ -2159,6 +2172,24 @@ extern "C" { pub fn Servo_DocumentRule_GetRules(rule: RawServoDocumentRuleBorrowed) -> ServoCssRulesStrong; } +extern "C" { + pub fn Servo_CssRules_GetFontFeatureValuesRuleAt(rules: + ServoCssRulesBorrowed, + index: u32, + line: *mut u32, + column: *mut u32) + -> RawServoFontFeatureValuesRuleStrong; +} +extern "C" { + pub fn Servo_FontFeatureValuesRule_Debug(rule: + RawServoFontFeatureValuesRuleBorrowed, + result: *mut nsACString); +} +extern "C" { + pub fn Servo_FontFeatureValuesRule_GetCssText(rule: + RawServoFontFeatureValuesRuleBorrowed, + result: *mut nsAString); +} extern "C" { pub fn Servo_CssRules_GetFontFaceRuleAt(rules: ServoCssRulesBorrowed, index: u32) @@ -2296,6 +2327,16 @@ extern "C" { RawServoDocumentRuleBorrowed, result: *mut nsAString); } +extern "C" { + pub fn Servo_FontFeatureValuesRule_GetFontFamily(rule: + RawServoFontFeatureValuesRuleBorrowed, + result: *mut nsAString); +} +extern "C" { + pub fn Servo_FontFeatureValuesRule_GetValueText(rule: + RawServoFontFeatureValuesRuleBorrowed, + result: *mut nsAString); +} extern "C" { pub fn Servo_ParseProperty(property: nsCSSPropertyID, value: *const nsACString, diff --git a/ports/geckolib/glue.rs b/ports/geckolib/glue.rs index 580d2503113..715843e67a4 100644 --- a/ports/geckolib/glue.rs +++ b/ports/geckolib/glue.rs @@ -31,6 +31,7 @@ use style::gecko_bindings::bindings::{RawGeckoElementBorrowed, RawGeckoElementBo use style::gecko_bindings::bindings::{RawGeckoKeyframeListBorrowed, RawGeckoKeyframeListBorrowedMut}; use style::gecko_bindings::bindings::{RawServoDeclarationBlockBorrowed, RawServoDeclarationBlockStrong}; use style::gecko_bindings::bindings::{RawServoDocumentRule, RawServoDocumentRuleBorrowed}; +use style::gecko_bindings::bindings::{RawServoFontFeatureValuesRule, RawServoFontFeatureValuesRuleBorrowed}; use style::gecko_bindings::bindings::{RawServoImportRule, RawServoImportRuleBorrowed}; use style::gecko_bindings::bindings::{RawServoKeyframe, RawServoKeyframeBorrowed, RawServoKeyframeStrong}; use style::gecko_bindings::bindings::{RawServoKeyframesRule, RawServoKeyframesRuleBorrowed}; @@ -107,7 +108,7 @@ use style::shared_lock::{SharedRwLockReadGuard, StylesheetGuards, ToCssWithGuard use style::string_cache::Atom; use style::style_adjuster::StyleAdjuster; use style::stylesheets::{CssRule, CssRules, CssRuleType, CssRulesHelpers, DocumentRule}; -use style::stylesheets::{ImportRule, KeyframesRule, MallocSizeOfWithGuard, MediaRule}; +use style::stylesheets::{FontFeatureValuesRule, ImportRule, KeyframesRule, MallocSizeOfWithGuard, MediaRule}; use style::stylesheets::{NamespaceRule, Origin, PageRule, StyleRule, SupportsRule}; use style::stylesheets::StylesheetContents; use style::stylesheets::StylesheetLoader as StyleStylesheetLoader; @@ -1233,6 +1234,12 @@ impl_group_rule_funcs! { (Document, DocumentRule, RawServoDocumentRule), to_css: Servo_DocumentRule_GetCssText, } +impl_basic_rule_funcs! { (FontFeatureValues, FontFeatureValuesRule, RawServoFontFeatureValuesRule), + getter: Servo_CssRules_GetFontFeatureValuesRuleAt, + debug: Servo_FontFeatureValuesRule_Debug, + to_css: Servo_FontFeatureValuesRule_GetCssText, +} + macro_rules! impl_getter_for_embedded_rule { ($getter:ident: $name:ident -> $ty:ty) => { #[no_mangle] @@ -1523,6 +1530,22 @@ pub extern "C" fn Servo_DocumentRule_GetConditionText(rule: RawServoDocumentRule }) } +#[no_mangle] +pub extern "C" fn Servo_FontFeatureValuesRule_GetFontFamily(rule: RawServoFontFeatureValuesRuleBorrowed, + result: *mut nsAString) { + read_locked_arc(rule, |rule: &FontFeatureValuesRule| { + rule.font_family_to_css(unsafe { result.as_mut().unwrap() }).unwrap(); + }) +} + +#[no_mangle] +pub extern "C" fn Servo_FontFeatureValuesRule_GetValueText(rule: RawServoFontFeatureValuesRuleBorrowed, + result: *mut nsAString) { + read_locked_arc(rule, |rule: &FontFeatureValuesRule| { + rule.value_to_css(unsafe { result.as_mut().unwrap() }).unwrap(); + }) +} + #[no_mangle] pub extern "C" fn Servo_ComputedValues_GetForAnonymousBox(parent_style_or_null: ServoStyleContextBorrowedOrNull, pseudo_tag: *mut nsIAtom,