mirror of
https://github.com/servo/servo.git
synced 2025-07-22 23:03:42 +01:00
Make CSSConditionRule's conditionText readonly (#30768)
As per https://github.com/w3c/csswg-drafts/issues/6819 This will be needed for https://phabricator.services.mozilla.com/D179060 The test was created by Mozilla, but was not correctly synced into WPT.
This commit is contained in:
parent
604d785bad
commit
b5bd416f7c
8 changed files with 36 additions and 98 deletions
|
@ -2,17 +2,13 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use cssparser::{Parser, ParserInput};
|
||||
use dom_struct::dom_struct;
|
||||
use servo_arc::Arc;
|
||||
use style::parser::ParserContext;
|
||||
use style::shared_lock::{Locked, ToCssWithGuard};
|
||||
use style::stylesheets::supports_rule::SupportsCondition;
|
||||
use style::stylesheets::{CssRuleType, Origin, SupportsRule};
|
||||
use style_traits::{ParsingMode, ToCss};
|
||||
use style::stylesheets::SupportsRule;
|
||||
use style_traits::ToCss;
|
||||
|
||||
use crate::dom::bindings::codegen::Bindings::WindowBinding::Window_Binding::WindowMethods;
|
||||
use crate::dom::bindings::reflector::{reflect_dom_object, DomObject};
|
||||
use crate::dom::bindings::reflector::reflect_dom_object;
|
||||
use crate::dom::bindings::root::DomRoot;
|
||||
use crate::dom::bindings::str::DOMString;
|
||||
use crate::dom::cssconditionrule::CSSConditionRule;
|
||||
|
@ -62,42 +58,6 @@ impl CSSSupportsRule {
|
|||
let rule = self.supportsrule.read_with(&guard);
|
||||
rule.condition.to_css_string().into()
|
||||
}
|
||||
|
||||
/// <https://drafts.csswg.org/css-conditional-3/#the-csssupportsrule-interface>
|
||||
pub fn set_condition_text(&self, text: DOMString) {
|
||||
let mut input = ParserInput::new(&text);
|
||||
let mut input = Parser::new(&mut input);
|
||||
let cond = SupportsCondition::parse(&mut input);
|
||||
if let Ok(cond) = cond {
|
||||
let global = self.global();
|
||||
let win = global.as_window();
|
||||
let url = win.Document().url();
|
||||
let quirks_mode = win.Document().quirks_mode();
|
||||
let context = ParserContext::new(
|
||||
Origin::Author,
|
||||
&url,
|
||||
Some(CssRuleType::Supports),
|
||||
ParsingMode::DEFAULT,
|
||||
quirks_mode,
|
||||
None,
|
||||
None,
|
||||
);
|
||||
let enabled = {
|
||||
let namespaces = self
|
||||
.cssconditionrule
|
||||
.parent_stylesheet()
|
||||
.style_stylesheet()
|
||||
.contents
|
||||
.namespaces
|
||||
.read();
|
||||
cond.eval(&context, &namespaces)
|
||||
};
|
||||
let mut guard = self.cssconditionrule.shared_lock().write();
|
||||
let rule = self.supportsrule.write_with(&mut guard);
|
||||
rule.condition = cond;
|
||||
rule.enabled = enabled;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl SpecificCSSRule for CSSSupportsRule {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue