Skip to content
Permalink
Browse files

Auto merge of #23073 - sbansal3096:master, r=emilio

Expose public getter to stylesheet's owner

<!-- Please describe your changes on the following line: -->

- [x] expose a public getter on CSSStyleSheet to return the stylesheet's owner
- [x] in CSSRuleList::insert_rule, use the new getter to pass a non-None value as an argument to arc.insert_rule
- [x] add a test for this that verifies that the new stylesheet is actually loaded
---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: -->
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [x] These changes fix #23028

<!-- Either: -->
- [x] There are tests for these changes

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/23073)
<!-- Reviewable:end -->
  • Loading branch information...
bors-servo committed Mar 22, 2019
2 parents 0ff87c8 + 13eebbf commit 7e5758b128b38dae3b64954cc12196d17e06729d
@@ -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,14 +104,20 @@ 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,
rule,
&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": [
[
{}
]
],
"css/cssom/stylesheet-owner.html": [],
"css/selectors/focus-visible-001-manual.html": [
[
"css/selectors/focus-visible-001-manual.html",
{}
]
],
"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",
]
},
"stub": {
"css/cssom/stylesheet-owner.html": [],
"service-workers/stub-3.1-service-worker-obj.html": [
[
"service-workers/stub-3.1-service-worker-obj.html",
{}
]
],
"css/cssom/insertRule-from-script-ref.html": [
[
{}
]
],
"css/cssom/medialist-dynamic-001-ref.html": [
[
{}
{}
]
],
"css/cssom/stylesheet-owner.html": [],
"css/cssom/stylesheet-replacedata-dynamic-ref.html": [
[
{}
{}
]
],
"css/cssom/support/black.css": [
[
{}
]
],
"css/cssom/support/c-red.css": [
[
{}
{}
]
],
"css/cssom/stylesheet-owner.html": [],
"css/cssom/stylesheet-same-origin.sub.html": [
[
"css/cssom/stylesheet-same-origin.sub.html",
{}
]
],
"css/cssom/stylesheet-owner.html": [],
"css/mediaqueries/media-queries-001.xht": [
[
"css/mediaqueries/media-queries-001.xht",
]
},
"wdspec": {
"css/cssom/stylesheet-owner.html": [],
"infrastructure/webdriver/tests/test_load_file.py": [
[
"infrastructure/webdriver/tests/test_load_file.py",
"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"
"a0473f5ca26652c1229290bbf1f81eabc1e37280",
"support"
],
"css/cssom/support/black.css": [
"833a0e00926ba4eb4615d177df63747cdb23f321",
"support"
],
"css/cssom/support/c-red.css": [
"d4ba5c64e95406f541e2f8cc19e192e9f521ed6b",
"support"

This file was deleted.

@@ -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>
@@ -0,0 +1,4 @@
html {
background-color: black;
color: white;
}

1 comment on commit 7e5758b

@taskcluster

This comment has been minimized.

Copy link

commented on 7e5758b Mar 22, 2019

Submitting the task to Taskcluster failed. Details

InterpreterError at template.tasks[0]: object keys must be strings

Please sign in to comment.
You can’t perform that action at this time.