diff --git a/components/script/dom/cssconditionrule.rs b/components/script/dom/cssconditionrule.rs index 1a587c3f290..bdda803c012 100644 --- a/components/script/dom/cssconditionrule.rs +++ b/components/script/dom/cssconditionrule.rs @@ -50,15 +50,4 @@ impl CSSConditionRuleMethods for CSSConditionRule { unreachable!() } } - - /// - fn SetConditionText(&self, text: DOMString) { - if let Some(rule) = self.downcast::() { - rule.set_condition_text(text) - } else if let Some(rule) = self.downcast::() { - rule.set_condition_text(text) - } else { - unreachable!() - } - } } diff --git a/components/script/dom/cssmediarule.rs b/components/script/dom/cssmediarule.rs index a17452f92b4..50456680193 100644 --- a/components/script/dom/cssmediarule.rs +++ b/components/script/dom/cssmediarule.rs @@ -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::media_queries::MediaList as StyleMediaList; -use style::parser::ParserContext; use style::shared_lock::{Locked, ToCssWithGuard}; -use style::stylesheets::{CssRuleType, MediaRule, Origin}; -use style_traits::{ParsingMode, ToCss}; +use style::stylesheets::MediaRule; +use style_traits::ToCss; use crate::dom::bindings::codegen::Bindings::CSSMediaRuleBinding::CSSMediaRuleMethods; -use crate::dom::bindings::codegen::Bindings::WindowBinding::Window_Binding::WindowMethods; use crate::dom::bindings::reflector::{reflect_dom_object, DomObject}; use crate::dom::bindings::root::{DomRoot, MutNullableDom}; use crate::dom::bindings::str::DOMString; @@ -75,37 +71,6 @@ impl CSSMediaRule { let list = rule.media_queries.read_with(&guard); list.to_css_string().into() } - - /// - pub fn set_condition_text(&self, text: DOMString) { - let mut input = ParserInput::new(&text); - let mut input = Parser::new(&mut input); - let global = self.global(); - let window = global.as_window(); - let url = window.get_url(); - let quirks_mode = window.Document().quirks_mode(); - let context = ParserContext::new( - Origin::Author, - &url, - Some(CssRuleType::Media), - ParsingMode::DEFAULT, - quirks_mode, - window.css_error_reporter(), - None, - ); - - let new_medialist = StyleMediaList::parse(&context, &mut input); - let mut guard = self.cssconditionrule.shared_lock().write(); - - // Clone an Arc because we can’t borrow `guard` twice at the same time. - - // FIXME(SimonSapin): allow access to multiple objects with one write guard? - // Would need a set of usize pointer addresses or something, - // the same object is not accessed more than once. - let mqs = Arc::clone(&self.mediarule.write_with(&mut guard).media_queries); - - *mqs.write_with(&mut guard) = new_medialist; - } } impl SpecificCSSRule for CSSMediaRule { diff --git a/components/script/dom/csssupportsrule.rs b/components/script/dom/csssupportsrule.rs index 5bdc78b8832..3c9b4e48647 100644 --- a/components/script/dom/csssupportsrule.rs +++ b/components/script/dom/csssupportsrule.rs @@ -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() } - - /// - 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 { diff --git a/components/script/dom/webidls/CSSConditionRule.webidl b/components/script/dom/webidls/CSSConditionRule.webidl index daf4258bc88..2f0aa270c1e 100644 --- a/components/script/dom/webidls/CSSConditionRule.webidl +++ b/components/script/dom/webidls/CSSConditionRule.webidl @@ -5,5 +5,5 @@ // https://drafts.csswg.org/css-conditional/#cssconditionrule [Abstract, Exposed=Window] interface CSSConditionRule : CSSGroupingRule { - attribute DOMString conditionText; + readonly attribute DOMString conditionText; }; diff --git a/tests/wpt/meta-legacy-layout/css/css-conditional/idlharness.html.ini b/tests/wpt/meta-legacy-layout/css/css-conditional/idlharness.html.ini index 32c49ea87e2..8c7dd1bebc2 100644 --- a/tests/wpt/meta-legacy-layout/css/css-conditional/idlharness.html.ini +++ b/tests/wpt/meta-legacy-layout/css/css-conditional/idlharness.html.ini @@ -1,6 +1,3 @@ [idlharness.html] [css-conditional IDL tests] expected: FAIL - - [CSSConditionRule interface: attribute conditionText] - expected: FAIL diff --git a/tests/wpt/meta/MANIFEST.json b/tests/wpt/meta/MANIFEST.json index f44dd6fbedc..13db357f72e 100644 --- a/tests/wpt/meta/MANIFEST.json +++ b/tests/wpt/meta/MANIFEST.json @@ -555189,6 +555189,13 @@ {} ] ], + "CSSConditionRule-conditionText.html": [ + "bccfc3135a4c80695b90638c42268f8a35d7f2fd", + [ + null, + {} + ] + ], "CSSContainerRule.tentative.html": [ "4e01c0b47003a413c0853ba96011d10962ad00a5", [ diff --git a/tests/wpt/meta/css/css-conditional/idlharness.html.ini b/tests/wpt/meta/css/css-conditional/idlharness.html.ini deleted file mode 100644 index 7215ba915d4..00000000000 --- a/tests/wpt/meta/css/css-conditional/idlharness.html.ini +++ /dev/null @@ -1,3 +0,0 @@ -[idlharness.html] - [CSSConditionRule interface: attribute conditionText] - expected: FAIL diff --git a/tests/wpt/tests/css/cssom/CSSConditionRule-conditionText.html b/tests/wpt/tests/css/cssom/CSSConditionRule-conditionText.html new file mode 100644 index 00000000000..bccfc3135a4 --- /dev/null +++ b/tests/wpt/tests/css/cssom/CSSConditionRule-conditionText.html @@ -0,0 +1,23 @@ + +CSSConditionRule.conditionText + + + + + +