Skip to content

Commit

Permalink
stylo: Create ServoFontFeatureValuesRule and bind servo data
Browse files Browse the repository at this point in the history
Add ServoFontFeatureValuesRule for CSSOM representation of
@font-feature-values rule and wire up with bindings.
  • Loading branch information
canova committed Jul 27, 2017
1 parent 43cf493 commit 25896c3
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 3 deletions.
7 changes: 5 additions & 2 deletions components/style/gecko/arc_types.rs
Expand Up @@ -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};
Expand All @@ -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 {
Expand Down Expand Up @@ -88,6 +88,9 @@ impl_arc_ffi!(Locked<SupportsRule> => RawServoSupportsRule
impl_arc_ffi!(Locked<DocumentRule> => RawServoDocumentRule
[Servo_DocumentRule_AddRef, Servo_DocumentRule_Release]);

impl_arc_ffi!(Locked<FontFeatureValuesRule> => RawServoFontFeatureValuesRule
[Servo_FontFeatureValuesRule_AddRef, Servo_FontFeatureValuesRule_Release]);

// RuleNode is a Arc-like type but it does not use Arc.

impl StrongRuleNode {
Expand Down
41 changes: 41 additions & 0 deletions components/style/gecko/generated/bindings.rs
Expand Up @@ -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<RawServoFontFeatureValuesRule>;
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<RawServoRuleNode>;
pub type RawServoRuleNodeBorrowed<'a> = &'a RawServoRuleNode;
pub type RawServoRuleNodeBorrowedOrNull<'a> = Option<&'a RawServoRuleNode>;
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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,
Expand Down
25 changes: 24 additions & 1 deletion ports/geckolib/glue.rs
Expand Up @@ -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};
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 25896c3

Please sign in to comment.