mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
Fix insertRule crash by exposing getter on stylesheet's owner
This commit is contained in:
parent
e58226814f
commit
13eebbfe56
7 changed files with 79 additions and 4 deletions
|
@ -6,12 +6,15 @@ use crate::dom::bindings::cell::DomRefCell;
|
|||
use crate::dom::bindings::codegen::Bindings::CSSRuleListBinding;
|
||||
use crate::dom::bindings::codegen::Bindings::CSSRuleListBinding::CSSRuleListMethods;
|
||||
use crate::dom::bindings::error::{Error, ErrorResult, Fallible};
|
||||
use crate::dom::bindings::inheritance::Castable;
|
||||
use crate::dom::bindings::reflector::{reflect_dom_object, DomObject, Reflector};
|
||||
use crate::dom::bindings::root::{Dom, DomRoot, MutNullableDom};
|
||||
use crate::dom::csskeyframerule::CSSKeyframeRule;
|
||||
use crate::dom::cssrule::CSSRule;
|
||||
use crate::dom::cssstylesheet::CSSStyleSheet;
|
||||
use crate::dom::htmlelement::HTMLElement;
|
||||
use crate::dom::window::Window;
|
||||
use crate::stylesheet_loader::StylesheetLoader;
|
||||
use dom_struct::dom_struct;
|
||||
use servo_arc::Arc;
|
||||
use style::shared_lock::Locked;
|
||||
|
@ -101,6 +104,12 @@ impl CSSRuleList {
|
|||
let index = idx as usize;
|
||||
|
||||
let parent_stylesheet = self.parent_stylesheet.style_stylesheet();
|
||||
let owner = self
|
||||
.parent_stylesheet
|
||||
.get_owner()
|
||||
.downcast::<HTMLElement>()
|
||||
.unwrap();
|
||||
let loader = StylesheetLoader::for_element(owner);
|
||||
let new_rule = css_rules.with_raw_offset_arc(|arc| {
|
||||
arc.insert_rule(
|
||||
&parent_stylesheet.shared_lock,
|
||||
|
@ -108,7 +117,7 @@ impl CSSRuleList {
|
|||
&parent_stylesheet.contents,
|
||||
index,
|
||||
nested,
|
||||
None,
|
||||
Some(&loader),
|
||||
)
|
||||
})?;
|
||||
|
||||
|
|
|
@ -75,6 +75,10 @@ impl CSSStyleSheet {
|
|||
self.style_stylesheet.disabled()
|
||||
}
|
||||
|
||||
pub fn get_owner(&self) -> &Element {
|
||||
&*self.owner
|
||||
}
|
||||
|
||||
pub fn set_disabled(&self, disabled: bool) {
|
||||
if self.style_stylesheet.set_disabled(disabled) {
|
||||
self.global()
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
{
|
||||
"items": {
|
||||
"conformancechecker": {
|
||||
"css/cssom/stylesheet-owner.html": []
|
||||
},
|
||||
"manual": {
|
||||
"2dcontext/conformance-requirements/2d.coordinatespace-manual.html": [
|
||||
[
|
||||
|
@ -10573,6 +10576,7 @@
|
|||
{}
|
||||
]
|
||||
],
|
||||
"css/cssom/stylesheet-owner.html": [],
|
||||
"css/selectors/focus-visible-001-manual.html": [
|
||||
[
|
||||
"css/selectors/focus-visible-001-manual.html",
|
||||
|
@ -172253,6 +172257,18 @@
|
|||
{}
|
||||
]
|
||||
],
|
||||
"css/cssom/insertRule-from-script.html": [
|
||||
[
|
||||
"css/cssom/insertRule-from-script.html",
|
||||
[
|
||||
[
|
||||
"/css/cssom/insertRule-from-script-ref.html",
|
||||
"=="
|
||||
]
|
||||
],
|
||||
{}
|
||||
]
|
||||
],
|
||||
"css/cssom/medialist-dynamic-001.html": [
|
||||
[
|
||||
"css/cssom/medialist-dynamic-001.html",
|
||||
|
@ -201725,6 +201741,7 @@
|
|||
]
|
||||
},
|
||||
"stub": {
|
||||
"css/cssom/stylesheet-owner.html": [],
|
||||
"service-workers/stub-3.1-service-worker-obj.html": [
|
||||
[
|
||||
"service-workers/stub-3.1-service-worker-obj.html",
|
||||
|
@ -282062,6 +282079,11 @@
|
|||
{}
|
||||
]
|
||||
],
|
||||
"css/cssom/insertRule-from-script-ref.html": [
|
||||
[
|
||||
{}
|
||||
]
|
||||
],
|
||||
"css/cssom/medialist-dynamic-001-ref.html": [
|
||||
[
|
||||
{}
|
||||
|
@ -282072,6 +282094,7 @@
|
|||
{}
|
||||
]
|
||||
],
|
||||
"css/cssom/stylesheet-owner.html": [],
|
||||
"css/cssom/stylesheet-replacedata-dynamic-ref.html": [
|
||||
[
|
||||
{}
|
||||
|
@ -282142,6 +282165,11 @@
|
|||
{}
|
||||
]
|
||||
],
|
||||
"css/cssom/support/black.css": [
|
||||
[
|
||||
{}
|
||||
]
|
||||
],
|
||||
"css/cssom/support/c-red.css": [
|
||||
[
|
||||
{}
|
||||
|
@ -364795,6 +364823,7 @@
|
|||
{}
|
||||
]
|
||||
],
|
||||
"css/cssom/stylesheet-owner.html": [],
|
||||
"css/cssom/stylesheet-same-origin.sub.html": [
|
||||
[
|
||||
"css/cssom/stylesheet-same-origin.sub.html",
|
||||
|
@ -471825,6 +471854,7 @@
|
|||
{}
|
||||
]
|
||||
],
|
||||
"css/cssom/stylesheet-owner.html": [],
|
||||
"css/mediaqueries/media-queries-001.xht": [
|
||||
[
|
||||
"css/mediaqueries/media-queries-001.xht",
|
||||
|
@ -472925,6 +472955,7 @@
|
|||
]
|
||||
},
|
||||
"wdspec": {
|
||||
"css/cssom/stylesheet-owner.html": [],
|
||||
"infrastructure/webdriver/tests/test_load_file.py": [
|
||||
[
|
||||
"infrastructure/webdriver/tests/test_load_file.py",
|
||||
|
@ -625992,6 +626023,14 @@
|
|||
"16f2358dc2d806de878bf2a1403aec9e6c41d9bd",
|
||||
"testharness"
|
||||
],
|
||||
"css/cssom/insertRule-from-script-ref.html": [
|
||||
"2fa45526a66565f86832f843ec477fe76e496775",
|
||||
"support"
|
||||
],
|
||||
"css/cssom/insertRule-from-script.html": [
|
||||
"c364afc282b061ef6520b9f8c9b5271f0b11d000",
|
||||
"reftest"
|
||||
],
|
||||
"css/cssom/insertRule-import-no-index.html": [
|
||||
"ad3622f86aaa4dfd58ee18015d1ef8dd1ebd6a70",
|
||||
"testharness"
|
||||
|
@ -626172,6 +626211,10 @@
|
|||
"a0473f5ca26652c1229290bbf1f81eabc1e37280",
|
||||
"support"
|
||||
],
|
||||
"css/cssom/support/black.css": [
|
||||
"833a0e00926ba4eb4615d177df63747cdb23f321",
|
||||
"support"
|
||||
],
|
||||
"css/cssom/support/c-red.css": [
|
||||
"d4ba5c64e95406f541e2f8cc19e192e9f521ed6b",
|
||||
"support"
|
||||
|
|
|
@ -1,3 +0,0 @@
|
|||
[insertRule-namespace-no-index.html]
|
||||
expected: CRASH
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
<!doctype html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>insertrule @import test reference</title>
|
||||
<link rel="stylesheet" href="support/black.css">
|
||||
</head>
|
|
@ -0,0 +1,12 @@
|
|||
<!doctype html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>insertrule @import test</title>
|
||||
<link rel="help" href="https://drafts.csswg.org/cssom/">
|
||||
<link rel="help" href="http://www.w3.org/TR/cssom-1/#the-cssrule-interface">
|
||||
<link rel="match" href="insertRule-from-script-ref.html">
|
||||
<style></style>
|
||||
</head>
|
||||
<body>
|
||||
<script>document.styleSheets[0].insertRule("@import url(\"support/black.css\");");</script>
|
||||
</body>
|
4
tests/wpt/web-platform-tests/css/cssom/support/black.css
Normal file
4
tests/wpt/web-platform-tests/css/cssom/support/black.css
Normal file
|
@ -0,0 +1,4 @@
|
|||
html {
|
||||
background-color: black;
|
||||
color: white;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue