-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add CSSOM support for CSS layers (#31481)
Instead of just crashing.
- Loading branch information
1 parent
845f503
commit 06aeeeb
Showing
25 changed files
with
298 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* 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 dom_struct::dom_struct; | ||
use servo_arc::Arc; | ||
use style::shared_lock::ToCssWithGuard; | ||
use style::stylesheets::LayerBlockRule; | ||
use style_traits::ToCss; | ||
|
||
use crate::dom::bindings::codegen::Bindings::CSSLayerBlockRuleBinding::CSSLayerBlockRuleMethods; | ||
use crate::dom::bindings::reflector::reflect_dom_object; | ||
use crate::dom::bindings::root::DomRoot; | ||
use crate::dom::bindings::str::DOMString; | ||
use crate::dom::cssgroupingrule::CSSGroupingRule; | ||
use crate::dom::cssrule::SpecificCSSRule; | ||
use crate::dom::cssstylesheet::CSSStyleSheet; | ||
use crate::dom::window::Window; | ||
|
||
#[dom_struct] | ||
pub struct CSSLayerBlockRule { | ||
cssgroupingrule: CSSGroupingRule, | ||
#[ignore_malloc_size_of = "Arc"] | ||
#[no_trace] | ||
layerblockrule: Arc<LayerBlockRule>, | ||
} | ||
|
||
impl CSSLayerBlockRule { | ||
pub fn new_inherited( | ||
parent_stylesheet: &CSSStyleSheet, | ||
layerblockrule: Arc<LayerBlockRule>, | ||
) -> CSSLayerBlockRule { | ||
CSSLayerBlockRule { | ||
cssgroupingrule: CSSGroupingRule::new_inherited( | ||
parent_stylesheet, | ||
layerblockrule.rules.clone(), | ||
), | ||
layerblockrule, | ||
} | ||
} | ||
|
||
#[allow(crown::unrooted_must_root)] | ||
pub fn new( | ||
window: &Window, | ||
parent_stylesheet: &CSSStyleSheet, | ||
layerblockrule: Arc<LayerBlockRule>, | ||
) -> DomRoot<CSSLayerBlockRule> { | ||
reflect_dom_object( | ||
Box::new(CSSLayerBlockRule::new_inherited( | ||
parent_stylesheet, | ||
layerblockrule, | ||
)), | ||
window, | ||
) | ||
} | ||
} | ||
|
||
impl SpecificCSSRule for CSSLayerBlockRule { | ||
fn ty(&self) -> u16 { | ||
0 | ||
} | ||
|
||
fn get_css(&self) -> DOMString { | ||
let guard = self.cssgroupingrule.shared_lock().read(); | ||
self.layerblockrule.to_css_string(&guard).into() | ||
} | ||
} | ||
|
||
impl CSSLayerBlockRuleMethods for CSSLayerBlockRule { | ||
/// <https://drafts.csswg.org/css-cascade-5/#dom-csslayerblockrule-name> | ||
fn Name(&self) -> DOMString { | ||
if let Some(name) = &self.layerblockrule.name { | ||
DOMString::from_string(name.to_css_string()) | ||
} else { | ||
DOMString::new() | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* 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 dom_struct::dom_struct; | ||
use js::jsval::JSVal; | ||
use servo_arc::Arc; | ||
use style::shared_lock::ToCssWithGuard; | ||
use style::stylesheets::LayerStatementRule; | ||
use style_traits::ToCss; | ||
|
||
use crate::dom::bindings::codegen::Bindings::CSSLayerStatementRuleBinding::CSSLayerStatementRuleMethods; | ||
use crate::dom::bindings::reflector::reflect_dom_object; | ||
use crate::dom::bindings::root::DomRoot; | ||
use crate::dom::bindings::str::DOMString; | ||
use crate::dom::bindings::utils::to_frozen_array; | ||
use crate::dom::cssrule::{CSSRule, SpecificCSSRule}; | ||
use crate::dom::cssstylesheet::CSSStyleSheet; | ||
use crate::dom::window::Window; | ||
use crate::script_runtime::JSContext as SafeJSContext; | ||
|
||
#[dom_struct] | ||
pub struct CSSLayerStatementRule { | ||
cssrule: CSSRule, | ||
#[ignore_malloc_size_of = "Arc"] | ||
#[no_trace] | ||
layerstatementrule: Arc<LayerStatementRule>, | ||
} | ||
|
||
impl CSSLayerStatementRule { | ||
pub fn new_inherited( | ||
parent_stylesheet: &CSSStyleSheet, | ||
layerstatementrule: Arc<LayerStatementRule>, | ||
) -> CSSLayerStatementRule { | ||
CSSLayerStatementRule { | ||
cssrule: CSSRule::new_inherited(parent_stylesheet), | ||
layerstatementrule, | ||
} | ||
} | ||
|
||
#[allow(crown::unrooted_must_root)] | ||
pub fn new( | ||
window: &Window, | ||
parent_stylesheet: &CSSStyleSheet, | ||
layerstatementrule: Arc<LayerStatementRule>, | ||
) -> DomRoot<CSSLayerStatementRule> { | ||
reflect_dom_object( | ||
Box::new(CSSLayerStatementRule::new_inherited( | ||
parent_stylesheet, | ||
layerstatementrule, | ||
)), | ||
window, | ||
) | ||
} | ||
} | ||
|
||
impl SpecificCSSRule for CSSLayerStatementRule { | ||
fn ty(&self) -> u16 { | ||
0 | ||
} | ||
|
||
fn get_css(&self) -> DOMString { | ||
let guard = self.cssrule.shared_lock().read(); | ||
self.layerstatementrule.to_css_string(&guard).into() | ||
} | ||
} | ||
|
||
impl CSSLayerStatementRuleMethods for CSSLayerStatementRule { | ||
/// <https://drafts.csswg.org/css-cascade-5/#dom-csslayerstatementrule-namelist> | ||
fn NameList(&self, cx: SafeJSContext) -> JSVal { | ||
let names: Vec<DOMString> = self | ||
.layerstatementrule | ||
.names | ||
.iter() | ||
.map(|name| DOMString::from_string(name.to_css_string())) | ||
.collect(); | ||
to_frozen_array(names.as_slice(), cx) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* 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/. */ | ||
|
||
// https://drafts.csswg.org/css-cascade-5/#the-csslayerblockrule-interface | ||
[Exposed=Window] | ||
interface CSSLayerBlockRule : CSSGroupingRule { | ||
readonly attribute DOMString name; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* 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/. */ | ||
|
||
// https://drafts.csswg.org/css-cascade-5/#the-csslayerstatementrule-interface | ||
[Exposed=Window] | ||
interface CSSLayerStatementRule : CSSRule { | ||
readonly attribute /*FrozenArray<ResizeObserverSize>*/any nameList; | ||
}; |
2 changes: 1 addition & 1 deletion
2
tests/wpt/meta-legacy-layout/css/css-cascade/all-prop-revert-layer.html.ini
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
[all-prop-revert-layer.html] | ||
expected: CRASH | ||
expected: TIMEOUT |
33 changes: 32 additions & 1 deletion
33
tests/wpt/meta-legacy-layout/css/css-cascade/idlharness.html.ini
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,33 @@ | ||
[idlharness.html] | ||
expected: CRASH | ||
[CSSScopeRule interface: existence and properties of interface object] | ||
expected: FAIL | ||
|
||
[CSSScopeRule interface object length] | ||
expected: FAIL | ||
|
||
[CSSScopeRule interface object name] | ||
expected: FAIL | ||
|
||
[CSSScopeRule interface: existence and properties of interface prototype object] | ||
expected: FAIL | ||
|
||
[CSSScopeRule interface: existence and properties of interface prototype object's "constructor" property] | ||
expected: FAIL | ||
[CSSScopeRule interface: existence and properties of interface prototype object's @@unscopables property] | ||
expected: FAIL | ||
|
||
[CSSScopeRule interface: attribute start] | ||
expected: FAIL | ||
|
||
[CSSScopeRule interface: attribute end] | ||
expected: FAIL | ||
|
||
[Stringification of scope] | ||
expected: FAIL | ||
|
||
[CSSScopeRule interface: scope must inherit property "start" with the proper type] | ||
expected: FAIL | ||
|
||
[CSSScopeRule interface: scope must inherit property "end" with the proper type] | ||
expected: FAIL |
6 changes: 5 additions & 1 deletion
6
tests/wpt/meta-legacy-layout/css/css-cascade/layer-cssom-order-reverse-at-property.html.ini
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,6 @@ | ||
[layer-cssom-order-reverse-at-property.html] | ||
expected: CRASH | ||
[Insert layer invalidates @property] | ||
expected: FAIL | ||
|
||
[Delete layer invalidates @property] | ||
expected: FAIL |
6 changes: 5 additions & 1 deletion
6
tests/wpt/meta-legacy-layout/css/css-cascade/layer-cssom-order-reverse.html.ini
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,6 @@ | ||
[layer-cssom-order-reverse.html] | ||
expected: CRASH | ||
[Insert layer invalidates @font-face] | ||
expected: FAIL | ||
|
||
[Delete layer invalidates @font-face] | ||
expected: FAIL |
27 changes: 0 additions & 27 deletions
27
tests/wpt/meta-legacy-layout/css/css-cascade/layer-rules-cssom.html.ini
This file was deleted.
Oops, something went wrong.
3 changes: 2 additions & 1 deletion
3
tests/wpt/meta-legacy-layout/css/css-cascade/layer-statement-before-import.html.ini
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
[layer-statement-before-import.html] | ||
expected: CRASH | ||
[insert other rules before the first layer statement without imports] | ||
expected: FAIL |
2 changes: 0 additions & 2 deletions
2
tests/wpt/meta-legacy-layout/css/css-cascade/parsing/layer.html.ini
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
[all-prop-revert-layer.html] | ||
expected: CRASH | ||
expected: TIMEOUT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,33 @@ | ||
[idlharness.html] | ||
expected: CRASH | ||
[CSSScopeRule interface: existence and properties of interface object] | ||
expected: FAIL | ||
|
||
[CSSScopeRule interface object length] | ||
expected: FAIL | ||
|
||
[CSSScopeRule interface object name] | ||
expected: FAIL | ||
|
||
[CSSScopeRule interface: existence and properties of interface prototype object] | ||
expected: FAIL | ||
|
||
[CSSScopeRule interface: existence and properties of interface prototype object's "constructor" property] | ||
expected: FAIL | ||
[CSSScopeRule interface: existence and properties of interface prototype object's @@unscopables property] | ||
expected: FAIL | ||
|
||
[CSSScopeRule interface: attribute start] | ||
expected: FAIL | ||
|
||
[CSSScopeRule interface: attribute end] | ||
expected: FAIL | ||
|
||
[Stringification of scope] | ||
expected: FAIL | ||
|
||
[CSSScopeRule interface: scope must inherit property "start" with the proper type] | ||
expected: FAIL | ||
|
||
[CSSScopeRule interface: scope must inherit property "end" with the proper type] | ||
expected: FAIL |
Oops, something went wrong.