Auto merge of #14190 - Manishearth:cssom, r=SimonSapin

Immutable CSSOM

This PR is intended to add basic support for all CSSOM interfaces, with the ability to index `document.styleSheets` and css rule lists, and serializing individual css rules. Handling individual interface methods for CSSRule subclasses can probably be done with easy/medium bugs.

Mutation safety isn't dealt with here; if the css rule list is mutated the CSSOM will be in an inconsistent state. I intend to deal with this via zero sized tokens, see https://groups.google.com/forum/#!topic/mozilla.dev.servo/AnxJoVmtMXQ .  I'll handle that when I start making the CSSOM mutable. (Getting the immutable bit landed first opens this up for easy bugs)

This doesn't really change style aside from adding an extra arc in the CSS rule list as discussed in the linked thread. So far this same design can be used by stylo as well when the time comes.

f? @SimonSapin @emilio

cc @upsuper

part of #11420
Todo:

 - [x] Stubs for rest of the CSSRule subclasses
 - [x] <s>ToCSS impls for CSSRules.</s> May make into easy bugs and stub out in this PR https://github.com/servo/servo/issues/14195
 - [x] Cache CSSStyleSheet on the relevant node

<!-- 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/14190)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2016-11-16 15:05:59 -06:00 committed by GitHub
commit afc60bee28
57 changed files with 915 additions and 209 deletions

View file

@ -1,2 +1,3 @@
[test_pref_reset.html]
type: testharness
prefs: [@Reset]

View file

@ -1,3 +1,4 @@
[test_pref_set.html]
type: testharness
prefs: ["browser.display.foreground_color:#00FF00",
"browser.display.background_color:#000000"]

View file

@ -1,2 +1,3 @@
[testharness_1.html]
type: testharness
disabled: @False

View file

@ -1,4 +1,5 @@
tags: [file-tag]
[testharness_0.html]
type: testharness
tags: [test-tag]

View file

@ -1,2 +1,3 @@
[testharness_0.html]
type: testharness
tags: [test-1-tag]

View file

@ -1,4 +1,5 @@
tags: [file-tag]
[testharness_2.html]
type: testharness
tags: [test-2-tag, @Reset]

View file

@ -2,6 +2,7 @@
type: testharness
[changing transition-property / values]
expected: FAIL
[changing transition-duration / values]
expected: FAIL

View file

@ -1,2 +1,3 @@
[color-applies-to-014.htm]
disabled: https://github.com/servo/servo/pull/13870#issuecomment-255507790
type: reftest
disabled: https://github.com/servo/servo/pull/13870

View file

@ -1,3 +1,8 @@
[index-003.htm]
type: testharness
expected: ERROR
[@import rule is expected to be @import url("main.css")]
expected: FAIL
[page rule is expected to be @page :first]
expected: FAIL

View file

@ -117,24 +117,9 @@
[StyleSheet interface: attribute disabled]
expected: FAIL
[CSSStyleSheet interface: existence and properties of interface object]
expected: FAIL
[CSSStyleSheet interface object length]
expected: FAIL
[CSSStyleSheet interface: existence and properties of interface prototype object]
expected: FAIL
[CSSStyleSheet interface: existence and properties of interface prototype object's "constructor" property]
expected: FAIL
[CSSStyleSheet interface: attribute ownerRule]
expected: FAIL
[CSSStyleSheet interface: attribute cssRules]
expected: FAIL
[CSSStyleSheet interface: operation insertRule(DOMString,unsigned long)]
expected: FAIL
@ -189,24 +174,9 @@
[StyleSheetList interface: existence and properties of interface prototype object]
expected: FAIL
[CSSRuleList interface: existence and properties of interface object]
expected: FAIL
[CSSRuleList interface object length]
expected: FAIL
[CSSRuleList interface: existence and properties of interface prototype object]
expected: FAIL
[CSSRuleList interface: existence and properties of interface prototype object's "constructor" property]
expected: FAIL
[CSSRuleList interface: operation item(unsigned long)]
expected: FAIL
[CSSRuleList interface: attribute length]
expected: FAIL
[CSSRuleList must be primary interface of style_element.sheet.cssRules]
expected: FAIL
@ -222,90 +192,9 @@
[CSSRuleList interface: style_element.sheet.cssRules must inherit property "length" with the proper type (1)]
expected: FAIL
[CSSRule interface: existence and properties of interface object]
expected: FAIL
[CSSRule interface object length]
expected: FAIL
[CSSRule interface: existence and properties of interface prototype object]
expected: FAIL
[CSSRule interface: existence and properties of interface prototype object's "constructor" property]
expected: FAIL
[CSSRule interface: constant STYLE_RULE on interface object]
expected: FAIL
[CSSRule interface: constant STYLE_RULE on interface prototype object]
expected: FAIL
[CSSRule interface: constant CHARSET_RULE on interface object]
expected: FAIL
[CSSRule interface: constant CHARSET_RULE on interface prototype object]
expected: FAIL
[CSSRule interface: constant IMPORT_RULE on interface object]
expected: FAIL
[CSSRule interface: constant IMPORT_RULE on interface prototype object]
expected: FAIL
[CSSRule interface: constant MEDIA_RULE on interface object]
expected: FAIL
[CSSRule interface: constant MEDIA_RULE on interface prototype object]
expected: FAIL
[CSSRule interface: constant FONT_FACE_RULE on interface object]
expected: FAIL
[CSSRule interface: constant FONT_FACE_RULE on interface prototype object]
expected: FAIL
[CSSRule interface: constant PAGE_RULE on interface object]
expected: FAIL
[CSSRule interface: constant PAGE_RULE on interface prototype object]
expected: FAIL
[CSSRule interface: constant MARGIN_RULE on interface object]
expected: FAIL
[CSSRule interface: constant MARGIN_RULE on interface prototype object]
expected: FAIL
[CSSRule interface: constant NAMESPACE_RULE on interface object]
expected: FAIL
[CSSRule interface: constant NAMESPACE_RULE on interface prototype object]
expected: FAIL
[CSSRule interface: attribute type]
expected: FAIL
[CSSRule interface: attribute cssText]
expected: FAIL
[CSSRule interface: attribute parentRule]
expected: FAIL
[CSSRule interface: attribute parentStyleSheet]
expected: FAIL
[CSSStyleRule interface: existence and properties of interface object]
expected: FAIL
[CSSStyleRule interface object length]
expected: FAIL
[CSSStyleRule interface: existence and properties of interface prototype object]
expected: FAIL
[CSSStyleRule interface: existence and properties of interface prototype object's "constructor" property]
expected: FAIL
[CSSStyleRule interface: attribute selectorText]
expected: FAIL
@ -381,18 +270,6 @@
[CSSImportRule interface: attribute styleSheet]
expected: FAIL
[CSSGroupingRule interface: existence and properties of interface object]
expected: FAIL
[CSSGroupingRule interface object length]
expected: FAIL
[CSSGroupingRule interface: existence and properties of interface prototype object]
expected: FAIL
[CSSGroupingRule interface: existence and properties of interface prototype object's "constructor" property]
expected: FAIL
[CSSGroupingRule interface: attribute cssRules]
expected: FAIL
@ -402,18 +279,6 @@
[CSSGroupingRule interface: operation deleteRule(unsigned long)]
expected: FAIL
[CSSMediaRule interface: existence and properties of interface object]
expected: FAIL
[CSSMediaRule interface object length]
expected: FAIL
[CSSMediaRule interface: existence and properties of interface prototype object]
expected: FAIL
[CSSMediaRule interface: existence and properties of interface prototype object's "constructor" property]
expected: FAIL
[CSSMediaRule interface: attribute media]
expected: FAIL
@ -453,18 +318,6 @@
[CSSMarginRule interface: attribute style]
expected: FAIL
[CSSNamespaceRule interface: existence and properties of interface object]
expected: FAIL
[CSSNamespaceRule interface object length]
expected: FAIL
[CSSNamespaceRule interface: existence and properties of interface prototype object]
expected: FAIL
[CSSNamespaceRule interface: existence and properties of interface prototype object's "constructor" property]
expected: FAIL
[CSSNamespaceRule interface: attribute namespaceURI]
expected: FAIL

View file

@ -17,3 +17,4 @@
[test skewY()]
expected: FAIL

View file

@ -1,6 +1,5 @@
[DOMMatrix-001.xht]
type: testharness
[testConstructor1]
expected: FAIL

View file

@ -17,3 +17,4 @@
[test skewY()]
expected: FAIL

View file

@ -1,6 +1,5 @@
[DOMMatrix-001.xht]
type: testharness
[testConstructor1]
expected: FAIL

View file

@ -17,3 +17,4 @@
[test skewY()]
expected: FAIL

View file

@ -1,2 +1,3 @@
[basic-transition.html]
type: reftest
disabled: https://github.com/servo/servo/issues/13865

View file

@ -0,0 +1,4 @@
[inline_block_opacity_change.html]
type: reftest
expected: PASS
disabled: https://github.com/servo/servo/issues/13360

View file

@ -20,7 +20,17 @@ test_interfaces([
"CharacterData",
"CloseEvent",
"CSS",
"CSSFontFaceRule",
"CSSGroupingRule",
"CSSKeyframesRule",
"CSSMediaRule",
"CSSNamespaceRule",
"CSSRule",
"CSSRuleList",
"CSSStyleDeclaration",
"CSSStyleRule",
"CSSStyleSheet",
"CSSViewportRule",
"DOMMatrix",
"DOMMatrixReadOnly",
"DOMPoint",

View file

@ -10,7 +10,6 @@ test_interfaces([
"BeforeUnloadEvent",
"Blob",
"CloseEvent",
"CSS",
"CSSStyleDeclaration",
"DOMPoint",
"DOMPointReadOnly",
@ -50,8 +49,6 @@ test_interfaces([
"Screen",
"Storage",
"StorageEvent",
"StyleSheet",
"StyleSheetList",
"TextDecoder",
"TextEncoder",
"URL",