mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
Stylo: Bug 1361994 - Implement access to CSSMozDocumentRule
This commit is contained in:
parent
0040160b38
commit
79e9168c00
3 changed files with 55 additions and 3 deletions
|
@ -9,7 +9,7 @@
|
|||
#![allow(non_snake_case, missing_docs)]
|
||||
|
||||
use gecko_bindings::bindings::{RawServoMediaList, RawServoMediaRule, RawServoNamespaceRule, RawServoPageRule};
|
||||
use gecko_bindings::bindings::{RawServoRuleNode, RawServoRuleNodeStrong};
|
||||
use gecko_bindings::bindings::{RawServoRuleNode, RawServoRuleNodeStrong, RawServoDocumentRule};
|
||||
use gecko_bindings::bindings::{RawServoStyleSheet, RawServoImportRule, RawServoSupportsRule};
|
||||
use gecko_bindings::bindings::{ServoComputedValues, ServoCssRules};
|
||||
use gecko_bindings::structs::{RawServoDeclarationBlock, RawServoStyleRule};
|
||||
|
@ -22,7 +22,7 @@ use rule_tree::StrongRuleNode;
|
|||
use shared_lock::Locked;
|
||||
use std::{mem, ptr};
|
||||
use stylesheets::{CssRules, Stylesheet, StyleRule, ImportRule, MediaRule};
|
||||
use stylesheets::{NamespaceRule, PageRule, SupportsRule};
|
||||
use stylesheets::{NamespaceRule, PageRule, SupportsRule, DocumentRule};
|
||||
|
||||
macro_rules! impl_arc_ffi {
|
||||
($servo_type:ty => $gecko_type:ty [$addref:ident, $release:ident]) => {
|
||||
|
@ -79,6 +79,9 @@ impl_arc_ffi!(Locked<PageRule> => RawServoPageRule
|
|||
impl_arc_ffi!(Locked<SupportsRule> => RawServoSupportsRule
|
||||
[Servo_SupportsRule_AddRef, Servo_SupportsRule_Release]);
|
||||
|
||||
impl_arc_ffi!(Locked<DocumentRule> => RawServoDocumentRule
|
||||
[Servo_DocumentRule_AddRef, Servo_DocumentRule_Release]);
|
||||
|
||||
// RuleNode is a Arc-like type but it does not use Arc.
|
||||
|
||||
impl StrongRuleNode {
|
||||
|
|
|
@ -255,6 +255,11 @@ pub type RawServoRuleNodeBorrowed<'a> = &'a RawServoRuleNode;
|
|||
pub type RawServoRuleNodeBorrowedOrNull<'a> = Option<&'a RawServoRuleNode>;
|
||||
enum RawServoRuleNodeVoid { }
|
||||
pub struct RawServoRuleNode(RawServoRuleNodeVoid);
|
||||
pub type RawServoDocumentRuleStrong = ::gecko_bindings::sugar::ownership::Strong<RawServoDocumentRule>;
|
||||
pub type RawServoDocumentRuleBorrowed<'a> = &'a RawServoDocumentRule;
|
||||
pub type RawServoDocumentRuleBorrowedOrNull<'a> = Option<&'a RawServoDocumentRule>;
|
||||
enum RawServoDocumentRuleVoid { }
|
||||
pub struct RawServoDocumentRule(RawServoDocumentRuleVoid);
|
||||
pub type RawServoStyleSetOwned = ::gecko_bindings::sugar::ownership::Owned<RawServoStyleSet>;
|
||||
pub type RawServoStyleSetOwnedOrNull = ::gecko_bindings::sugar::ownership::OwnedOrNull<RawServoStyleSet>;
|
||||
pub type RawServoStyleSetBorrowed<'a> = &'a RawServoStyleSet;
|
||||
|
@ -422,6 +427,12 @@ extern "C" {
|
|||
extern "C" {
|
||||
pub fn Servo_RuleNode_Release(ptr: RawServoRuleNodeBorrowed);
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Servo_DocumentRule_AddRef(ptr: RawServoDocumentRuleBorrowed);
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Servo_DocumentRule_Release(ptr: RawServoDocumentRuleBorrowed);
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Servo_StyleSet_Drop(ptr: RawServoStyleSetOwned);
|
||||
}
|
||||
|
@ -1767,6 +1778,23 @@ extern "C" {
|
|||
pub fn Servo_SupportsRule_GetRules(rule: RawServoSupportsRuleBorrowed)
|
||||
-> ServoCssRulesStrong;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Servo_CssRules_GetDocumentRuleAt(rules: ServoCssRulesBorrowed,
|
||||
index: u32)
|
||||
-> RawServoDocumentRuleStrong;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Servo_DocumentRule_Debug(rule: RawServoDocumentRuleBorrowed,
|
||||
result: *mut nsACString);
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Servo_DocumentRule_GetCssText(rule: RawServoDocumentRuleBorrowed,
|
||||
result: *mut nsAString);
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Servo_DocumentRule_GetRules(rule: RawServoDocumentRuleBorrowed)
|
||||
-> ServoCssRulesStrong;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Servo_CssRules_GetFontFaceRuleAt(rules: ServoCssRulesBorrowed,
|
||||
index: u32)
|
||||
|
@ -1811,6 +1839,11 @@ extern "C" {
|
|||
RawServoSupportsRuleBorrowed,
|
||||
result: *mut nsAString);
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Servo_DocumentRule_GetConditionText(rule:
|
||||
RawServoDocumentRuleBorrowed,
|
||||
result: *mut nsAString);
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Servo_ParseProperty(property: nsCSSPropertyID,
|
||||
value: *const nsACString,
|
||||
|
|
|
@ -28,6 +28,7 @@ use style::gecko::wrapper::GeckoElement;
|
|||
use style::gecko_bindings::bindings;
|
||||
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::{RawServoMediaList, RawServoMediaListBorrowed, RawServoMediaListStrong};
|
||||
use style::gecko_bindings::bindings::{RawServoMediaRule, RawServoMediaRuleBorrowed};
|
||||
use style::gecko_bindings::bindings::{RawServoNamespaceRule, RawServoNamespaceRuleBorrowed};
|
||||
|
@ -87,7 +88,7 @@ use style::style_adjuster::StyleAdjuster;
|
|||
use style::stylearc::Arc;
|
||||
use style::stylesheets::{CssRule, CssRules, CssRuleType, CssRulesHelpers};
|
||||
use style::stylesheets::{ImportRule, MediaRule, NamespaceRule, Origin};
|
||||
use style::stylesheets::{PageRule, Stylesheet, StyleRule, SupportsRule};
|
||||
use style::stylesheets::{PageRule, Stylesheet, StyleRule, SupportsRule, DocumentRule};
|
||||
use style::stylesheets::StylesheetLoader as StyleStylesheetLoader;
|
||||
use style::supports::parse_condition_or_declaration;
|
||||
use style::thread_state;
|
||||
|
@ -834,6 +835,13 @@ impl_group_rule_funcs! { (Supports, SupportsRule, RawServoSupportsRule),
|
|||
to_css: Servo_SupportsRule_GetCssText,
|
||||
}
|
||||
|
||||
impl_group_rule_funcs! { (Document, DocumentRule, RawServoDocumentRule),
|
||||
get_rules: Servo_DocumentRule_GetRules,
|
||||
getter: Servo_CssRules_GetDocumentRuleAt,
|
||||
debug: Servo_DocumentRule_Debug,
|
||||
to_css: Servo_DocumentRule_GetCssText,
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn Servo_CssRules_GetFontFaceRuleAt(rules: ServoCssRulesBorrowed, index: u32)
|
||||
-> *mut nsCSSFontFaceRule
|
||||
|
@ -913,6 +921,14 @@ pub extern "C" fn Servo_SupportsRule_GetConditionText(rule: RawServoSupportsRule
|
|||
})
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn Servo_DocumentRule_GetConditionText(rule: RawServoDocumentRuleBorrowed,
|
||||
result: *mut nsAString) {
|
||||
read_locked_arc(rule, |rule: &DocumentRule| {
|
||||
rule.condition.to_css(unsafe { result.as_mut().unwrap() }).unwrap();
|
||||
})
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn Servo_ComputedValues_GetForAnonymousBox(parent_style_or_null: ServoComputedValuesBorrowedOrNull,
|
||||
pseudo_tag: *mut nsIAtom,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue