mirror of
https://github.com/servo/servo.git
synced 2025-08-07 14:35:33 +01:00
Add basic CSSOM support for @import rule.
This commit is contained in:
parent
939716a7bc
commit
33deafba12
2 changed files with 22 additions and 5 deletions
|
@ -633,6 +633,9 @@ pub struct ImportRule {
|
||||||
/// It contains an empty list of rules and namespace set that is updated
|
/// It contains an empty list of rules and namespace set that is updated
|
||||||
/// when it loads.
|
/// when it loads.
|
||||||
pub stylesheet: Arc<Stylesheet>,
|
pub stylesheet: Arc<Stylesheet>,
|
||||||
|
|
||||||
|
/// The line and column of the rule's source code.
|
||||||
|
pub source_location: SourceLocation,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Clone for ImportRule {
|
impl Clone for ImportRule {
|
||||||
|
@ -641,6 +644,7 @@ impl Clone for ImportRule {
|
||||||
ImportRule {
|
ImportRule {
|
||||||
url: self.url.clone(),
|
url: self.url.clone(),
|
||||||
stylesheet: Arc::new(stylesheet.clone()),
|
stylesheet: Arc::new(stylesheet.clone()),
|
||||||
|
source_location: self.source_location.clone(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1530,6 +1534,8 @@ impl<'a> AtRuleParser for TopLevelRuleParser<'a> {
|
||||||
|
|
||||||
fn parse_prelude(&mut self, name: &str, input: &mut Parser)
|
fn parse_prelude(&mut self, name: &str, input: &mut Parser)
|
||||||
-> Result<AtRuleType<AtRulePrelude, CssRule>, ()> {
|
-> Result<AtRuleType<AtRulePrelude, CssRule>, ()> {
|
||||||
|
let location = get_location_with_offset(input.current_source_location(),
|
||||||
|
self.context.line_number_offset);
|
||||||
match_ignore_ascii_case! { name,
|
match_ignore_ascii_case! { name,
|
||||||
"import" => {
|
"import" => {
|
||||||
if self.state.get() <= State::Imports {
|
if self.state.get() <= State::Imports {
|
||||||
|
@ -1561,7 +1567,8 @@ impl<'a> AtRuleParser for TopLevelRuleParser<'a> {
|
||||||
dirty_on_viewport_size_change: AtomicBool::new(false),
|
dirty_on_viewport_size_change: AtomicBool::new(false),
|
||||||
disabled: AtomicBool::new(false),
|
disabled: AtomicBool::new(false),
|
||||||
quirks_mode: self.context.quirks_mode,
|
quirks_mode: self.context.quirks_mode,
|
||||||
})
|
}),
|
||||||
|
source_location: location,
|
||||||
}
|
}
|
||||||
}, &mut |import_rule| {
|
}, &mut |import_rule| {
|
||||||
Arc::new(self.shared_lock.wrap(import_rule))
|
Arc::new(self.shared_lock.wrap(import_rule))
|
||||||
|
@ -1576,9 +1583,6 @@ impl<'a> AtRuleParser for TopLevelRuleParser<'a> {
|
||||||
if self.state.get() <= State::Namespaces {
|
if self.state.get() <= State::Namespaces {
|
||||||
self.state.set(State::Namespaces);
|
self.state.set(State::Namespaces);
|
||||||
|
|
||||||
let location = get_location_with_offset(input.current_source_location(),
|
|
||||||
self.context.line_number_offset);
|
|
||||||
|
|
||||||
let prefix_result = input.try(|input| input.expect_ident());
|
let prefix_result = input.try(|input| input.expect_ident());
|
||||||
let url = Namespace::from(try!(input.expect_url_or_string()));
|
let url = Namespace::from(try!(input.expect_url_or_string()));
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,7 @@ use style::gecko_bindings::bindings::{RawGeckoElementBorrowed, RawGeckoElementBo
|
||||||
use style::gecko_bindings::bindings::{RawGeckoKeyframeListBorrowed, RawGeckoKeyframeListBorrowedMut};
|
use style::gecko_bindings::bindings::{RawGeckoKeyframeListBorrowed, RawGeckoKeyframeListBorrowedMut};
|
||||||
use style::gecko_bindings::bindings::{RawServoDeclarationBlockBorrowed, RawServoDeclarationBlockStrong};
|
use style::gecko_bindings::bindings::{RawServoDeclarationBlockBorrowed, RawServoDeclarationBlockStrong};
|
||||||
use style::gecko_bindings::bindings::{RawServoDocumentRule, RawServoDocumentRuleBorrowed};
|
use style::gecko_bindings::bindings::{RawServoDocumentRule, RawServoDocumentRuleBorrowed};
|
||||||
|
use style::gecko_bindings::bindings::{RawServoImportRule, RawServoImportRuleBorrowed};
|
||||||
use style::gecko_bindings::bindings::{RawServoKeyframe, RawServoKeyframeBorrowed, RawServoKeyframeStrong};
|
use style::gecko_bindings::bindings::{RawServoKeyframe, RawServoKeyframeBorrowed, RawServoKeyframeStrong};
|
||||||
use style::gecko_bindings::bindings::{RawServoKeyframesRule, RawServoKeyframesRuleBorrowed};
|
use style::gecko_bindings::bindings::{RawServoKeyframesRule, RawServoKeyframesRuleBorrowed};
|
||||||
use style::gecko_bindings::bindings::{RawServoMediaList, RawServoMediaListBorrowed, RawServoMediaListStrong};
|
use style::gecko_bindings::bindings::{RawServoMediaList, RawServoMediaListBorrowed, RawServoMediaListStrong};
|
||||||
|
@ -56,7 +57,6 @@ use style::gecko_bindings::bindings::RawGeckoServoStyleRuleListBorrowedMut;
|
||||||
use style::gecko_bindings::bindings::RawServoAnimationValueBorrowed;
|
use style::gecko_bindings::bindings::RawServoAnimationValueBorrowed;
|
||||||
use style::gecko_bindings::bindings::RawServoAnimationValueMapBorrowedMut;
|
use style::gecko_bindings::bindings::RawServoAnimationValueMapBorrowedMut;
|
||||||
use style::gecko_bindings::bindings::RawServoAnimationValueStrong;
|
use style::gecko_bindings::bindings::RawServoAnimationValueStrong;
|
||||||
use style::gecko_bindings::bindings::RawServoImportRuleBorrowed;
|
|
||||||
use style::gecko_bindings::bindings::RawServoStyleRuleBorrowed;
|
use style::gecko_bindings::bindings::RawServoStyleRuleBorrowed;
|
||||||
use style::gecko_bindings::bindings::ServoComputedValuesBorrowedOrNull;
|
use style::gecko_bindings::bindings::ServoComputedValuesBorrowedOrNull;
|
||||||
use style::gecko_bindings::bindings::nsTArrayBorrowed_uintptr_t;
|
use style::gecko_bindings::bindings::nsTArrayBorrowed_uintptr_t;
|
||||||
|
@ -988,6 +988,12 @@ impl_basic_rule_funcs! { (Style, StyleRule, RawServoStyleRule),
|
||||||
to_css: Servo_StyleRule_GetCssText,
|
to_css: Servo_StyleRule_GetCssText,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl_basic_rule_funcs! { (Import, ImportRule, RawServoImportRule),
|
||||||
|
getter: Servo_CssRules_GetImportRuleAt,
|
||||||
|
debug: Servo_ImportRule_Debug,
|
||||||
|
to_css: Servo_ImportRule_GetCssText,
|
||||||
|
}
|
||||||
|
|
||||||
impl_basic_rule_funcs_without_getter! { (Keyframe, RawServoKeyframe),
|
impl_basic_rule_funcs_without_getter! { (Keyframe, RawServoKeyframe),
|
||||||
debug: Servo_Keyframe_Debug,
|
debug: Servo_Keyframe_Debug,
|
||||||
to_css: Servo_Keyframe_GetCssText,
|
to_css: Servo_Keyframe_GetCssText,
|
||||||
|
@ -1077,6 +1083,13 @@ pub extern "C" fn Servo_StyleRule_GetSelectorText(rule: RawServoStyleRuleBorrowe
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[no_mangle]
|
||||||
|
pub extern "C" fn Servo_ImportRule_GetHref(rule: RawServoImportRuleBorrowed, result: *mut nsAString) {
|
||||||
|
read_locked_arc(rule, |rule: &ImportRule| {
|
||||||
|
write!(unsafe { &mut *result }, "{}", rule.url.as_str()).unwrap();
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn Servo_Keyframe_GetKeyText(keyframe: RawServoKeyframeBorrowed, result: *mut nsAString) {
|
pub extern "C" fn Servo_Keyframe_GetKeyText(keyframe: RawServoKeyframeBorrowed, result: *mut nsAString) {
|
||||||
read_locked_arc(keyframe, |keyframe: &Keyframe| {
|
read_locked_arc(keyframe, |keyframe: &Keyframe| {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue