Auto merge of #17538 - jyc:selectorText, r=Manishearth

Implement CSSStyleRule.selectorText.

We parse when assigning using the namespaces of the stylesheet. It isn't
clear if the spec says to do that (Firefox doesn't support the setter at
all, Chrome does, Safari doesn't); the spec issue is here:
https://github.com/w3c/csswg-drafts/issues/1511

Also fix ToCss implementation of AttrSelectorOperator to not pad with
spaces, to conform with CSSOM. This means we have to update some unit
tests that expect operators with spaces around them in attribute
selectors to roundtrip.

See the "attribute selector" section of "Serializing Selectors" here:
https://drafts.csswg.org/cssom/#serializing-selectors

CSSStyleRule.selectorText is specified here:
https://drafts.csswg.org/cssom/#dom-cssstylerule-selectortext

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

---
<!-- 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 is part of a series to fix #17182

<!-- Either: -->
I am running this to identify what tests will fail; as the other PRs in the series are merged, I believe the tests that pass will change as well.

- [ ] There are tests for these changes OR
- [ ] These changes do not require tests because _____

<!-- 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/17538)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2017-07-12 11:08:35 -07:00 committed by GitHub
commit 4b6e79337e
14 changed files with 109 additions and 100 deletions

View file

@ -15,6 +15,3 @@
[StyleRule_properties]
expected: FAIL
[StyleRule_properties_values]
expected: FAIL

View file

@ -117,12 +117,6 @@
[CSSRule interface: attribute parentRule]
expected: FAIL
[CSSStyleRule interface: attribute selectorText]
expected: FAIL
[CSSStyleRule interface: style_element.sheet.cssRules[0\] must inherit property "selectorText" with the proper type (0)]
expected: FAIL
[CSSRule interface: style_element.sheet.cssRules[0\] must inherit property "parentRule" with the proper type (10)]
expected: FAIL

View file

@ -160103,6 +160103,18 @@
{}
]
],
"cssom/selectorText-modification-restyle-001.html": [
[
"/cssom/selectorText-modification-restyle-001.html",
[
[
"/cssom/selectorText-modification-restyle-001-ref.html",
"=="
]
],
{}
]
],
"html/dom/elements/global-attributes/dir_auto-EN-L.html": [
[
"/html/dom/elements/global-attributes/dir_auto-EN-L.html",
@ -274610,6 +274622,11 @@
{}
]
],
"cssom/selectorText-modification-restyle-001-ref.html": [
[
{}
]
],
"cssom/stylesheet-same-origin.css": [
[
{}
@ -553977,6 +553994,14 @@
"002777c7c598eb1131ab625365ee3fe08650e830",
"testharness"
],
"cssom/selectorText-modification-restyle-001-ref.html": [
"4fbe124f09131f30e5c68154774246e5cd15b14a",
"support"
],
"cssom/selectorText-modification-restyle-001.html": [
"ac5a5414dd849151c3ca6348c90c0f4e80a09b75",
"reftest"
],
"cssom/serialization-CSSDeclaration-with-important.html": [
"ecc8b95fb2d71cacee271f4fea2fc16f35cdba57",
"testharness"

View file

@ -9,9 +9,3 @@
[Values of CSSRule attributes]
expected: FAIL
[Values of CSSStyleRule attributes]
expected: FAIL
[Existence and type of CSSStyleRule attributes]
expected: FAIL

View file

@ -54,12 +54,6 @@
[CSSRule interface: attribute parentRule]
expected: FAIL
[CSSStyleRule interface: attribute selectorText]
expected: FAIL
[CSSStyleRule interface: style_element.sheet.cssRules[0\] must inherit property "selectorText" with the proper type (0)]
expected: FAIL
[CSSRule interface: style_element.sheet.cssRules[0\] must inherit property "parentRule" with the proper type (10)]
expected: FAIL

View file

@ -1,68 +0,0 @@
[cssom.html]
type: testharness
[[foo="bar"\] /* sanity check */ getting CSSRule#cssText]
expected: FAIL
[[foo="bar"\] /* sanity check */ getting CSSStyleRule#selectorText]
expected: FAIL
[[foo="bar"\] /* sanity check */ setting CSSStyleRule#selectorText]
expected: FAIL
[[foo="bar"\] /* sanity check */ getting CSSRule#cssText in @media]
expected: FAIL
[[foo="bar"\] /* sanity check */ getting CSSStyleRule#selectorText in @media]
expected: FAIL
[[foo="bar"\] /* sanity check */ setting CSSStyleRule#selectorText in @media]
expected: FAIL
[[foo="bar" i\] getting CSSRule#cssText]
expected: FAIL
[[foo="bar" i\] getting CSSStyleRule#selectorText]
expected: FAIL
[[foo="bar" i\] getting CSSRule#cssText in @media]
expected: FAIL
[[foo="bar" i\] getting CSSStyleRule#selectorText in @media]
expected: FAIL
[[foo="bar" /**/ i\] getting CSSRule#cssText]
expected: FAIL
[[foo="bar" /**/ i\] getting CSSStyleRule#selectorText]
expected: FAIL
[[foo="bar" /**/ i\] setting CSSStyleRule#selectorText]
expected: FAIL
[[foo="bar" /**/ i\] getting CSSRule#cssText in @media]
expected: FAIL
[[foo="bar" /**/ i\] getting CSSStyleRule#selectorText in @media]
expected: FAIL
[[foo="bar" /**/ i\] setting CSSStyleRule#selectorText in @media]
expected: FAIL
[[foo="bar"/**/i\] getting CSSRule#cssText]
expected: FAIL
[[foo="bar"/**/i\] getting CSSStyleRule#selectorText]
expected: FAIL
[[foo="bar"/**/i\] setting CSSStyleRule#selectorText]
expected: FAIL
[[foo="bar"/**/i\] getting CSSRule#cssText in @media]
expected: FAIL
[[foo="bar"/**/i\] getting CSSStyleRule#selectorText in @media]
expected: FAIL
[[foo="bar"/**/i\] setting CSSStyleRule#selectorText in @media]
expected: FAIL

View file

@ -0,0 +1,13 @@
<!doctype html>
<meta charset="utf-8">
<title>(Ref #1) CSSOM - CSSStyleRule.selectorText Modification Restyle - Reference #1</title>
<style>
div {
color: green;
}
</style>
<body>
<div>I should be green.</div>
</body>

View file

@ -0,0 +1,21 @@
<!doctype html>
<meta charset="utf-8">
<title>(Test #1) CSSOM - CSSStyleRule.selectorText Modification Restyle - Test #1</title>
<link rel="match" href="selectorText-modification-restyle-001-ref.html">
<style>
@namespace bogus url(http://example.com/bogus);
bogus|div {
color: green;
}
</style>
<body>
<div>I should be green.</div>
<script>
// Remove the "bogus" namespace--now it should apply to the div above.
// We also expect to see a restyle.
document.querySelector("style").sheet.cssRules[1].selectorText = "div";
</script>
</body>