Bug 1425834: style: Parse ::slotted() if the webcomponents pref is on. r?heycam draft
authorEmilio Cobos Álvarez <emilio@crisal.io>
Mon, 18 Dec 2017 09:20:59 +0100
changeset 713206 90b3d43ee6a874308c094cff7f540e6c84ac5525
parent 712691 35b148e8b27cd7ffb2aa03c3ea3b1b72853fe128
child 744268 f6e4157129083ef97cd5eb5f6801d39a6ae9b3df
push id93571
push userbmo:emilio@crisal.io
push dateTue, 19 Dec 2017 20:05:54 +0000
reviewersheycam
bugs1425834
milestone59.0a1
Bug 1425834: style: Parse ::slotted() if the webcomponents pref is on. r?heycam MozReview-Commit-ID: IOFneIgu7Rm
servo/components/style/gecko/selector_parser.rs
testing/web-platform/meta/css/css-scoping/css-scoping-shadow-slotted-nested.html.ini
testing/web-platform/meta/css/css-scoping/css-scoping-shadow-slotted-rule.html.ini
testing/web-platform/meta/css/css-scoping/shadow-cascade-order-001.html.ini
testing/web-platform/meta/css/css-scoping/slotted-parsing.html.ini
--- a/servo/components/style/gecko/selector_parser.rs
+++ b/servo/components/style/gecko/selector_parser.rs
@@ -1,17 +1,17 @@
 /* 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 http://mozilla.org/MPL/2.0/. */
 
 //! Gecko-specific bits for selector-parsing.
 
 use cssparser::{BasicParseError, BasicParseErrorKind, Parser, ToCss, Token, CowRcStr, SourceLocation};
 use element_state::{DocumentState, ElementState};
-use gecko_bindings::structs::CSSPseudoClassType;
+use gecko_bindings::structs::{self, CSSPseudoClassType};
 use gecko_bindings::structs::RawServoSelectorList;
 use gecko_bindings::sugar::ownership::{HasBoxFFI, HasFFI, HasSimpleFFI};
 use selector_parser::{Direction, SelectorParser};
 use selectors::SelectorList;
 use selectors::parser::{self as selector_parser, Selector, SelectorMethods, SelectorParseErrorKind};
 use selectors::visitor::SelectorVisitor;
 use std::fmt;
 use string_cache::{Atom, Namespace, WeakAtom, WeakNamespace};
@@ -328,16 +328,23 @@ impl<'a> SelectorParser<'a> {
         return false;
     }
 }
 
 impl<'a, 'i> ::selectors::Parser<'i> for SelectorParser<'a> {
     type Impl = SelectorImpl;
     type Error = StyleParseErrorKind<'i>;
 
+    fn parse_slotted(&self) -> bool {
+        // NOTE(emilio): Slot assignment and such works per-document, but
+        // getting a document around here is not trivial, and it's not worth
+        // anyway to handle this in a per-doc basis.
+        unsafe { structs::nsContentUtils_sIsWebComponentsEnabled }
+    }
+
     fn pseudo_element_allows_single_colon(name: &str) -> bool {
         // FIXME: -moz-tree check should probably be ascii-case-insensitive.
         ::selectors::parser::is_css2_pseudo_element(name) ||
             name.starts_with("-moz-tree-")
     }
 
     fn parse_non_ts_pseudo_class(
         &self,
deleted file mode 100644
--- a/testing/web-platform/meta/css/css-scoping/css-scoping-shadow-slotted-nested.html.ini
+++ /dev/null
@@ -1,3 +0,0 @@
-[css-scoping-shadow-slotted-nested.html]
-  type: reftest
-  expected: FAIL
deleted file mode 100644
--- a/testing/web-platform/meta/css/css-scoping/css-scoping-shadow-slotted-rule.html.ini
+++ /dev/null
@@ -1,4 +0,0 @@
-[css-scoping-shadow-slotted-rule.html]
-  type: reftest
-  expected: FAIL
-
--- a/testing/web-platform/meta/css/css-scoping/shadow-cascade-order-001.html.ini
+++ b/testing/web-platform/meta/css/css-scoping/shadow-cascade-order-001.html.ini
@@ -1,31 +1,14 @@
 [shadow-cascade-order-001.html]
   type: testharness
-  [A4. ::slotted vs :host, earlier in tree-of-trees rule should win for open mode.]
-    expected: FAIL
-
-  [B4. ::slotted  with !important vs :host, earlier in tree-of-trees rule should win for open mode.]
-    expected: FAIL
-
-  [B5. ::slotted vs inline with !important, inline rule should win for open mode.]
-    expected: FAIL
-
-  [C1. document vs ::slotted with !important, ::slotted rule should win for open mode.]
-    expected: FAIL
 
   [C2. document vs :host with !important, :host rule should win for open mode.]
     expected: FAIL
 
-  [C4. ::slotted vs :host with !important, later in tree-of-trees rule should win for open mode.]
-    expected: FAIL
-
-  [C5. ::slotted with !important vs inline, ::slotted rule should win for open mode.]
-    expected: FAIL
-
   [C6. :host with !important vs inline, :host rule should win for open mode.]
     expected: FAIL
 
   [D1. document vs ::slotted both with !important, ::slotted rule should win for open mode.]
     expected: FAIL
 
   [D2. document vs :host both with !important, :host rule should win for open mode.]
     expected: FAIL
@@ -37,49 +20,25 @@
     expected: FAIL
 
   [D6. :host vs inline both with !important, :host rule should win for open mode.]
     expected: FAIL
 
   [E2. all styles with !important applied, rule in the last tree-of-trees should win for open mode.]
     expected: FAIL
 
-  [F3. document vs ::slotted with !important, important rule should win for open mode.]
-    expected: FAIL
-
-  [F4. document vs ::slotted with !important, important rule should win for open mode.]
-    expected: FAIL
-
   [F5. document vs :host with !important, important rule should win for open mode.]
     expected: FAIL
 
   [F6. all rules with !important, the last rule in tree-of-trees should win for open mode.]
     expected: FAIL
 
-  [A4. ::slotted vs :host, earlier in tree-of-trees rule should win for closed mode.]
-    expected: FAIL
-
-  [B4. ::slotted  with !important vs :host, earlier in tree-of-trees rule should win for closed mode.]
-    expected: FAIL
-
-  [B5. ::slotted vs inline with !important, inline rule should win for closed mode.]
-    expected: FAIL
-
-  [C1. document vs ::slotted with !important, ::slotted rule should win for closed mode.]
-    expected: FAIL
-
   [C2. document vs :host with !important, :host rule should win for closed mode.]
     expected: FAIL
 
-  [C4. ::slotted vs :host with !important, later in tree-of-trees rule should win for closed mode.]
-    expected: FAIL
-
-  [C5. ::slotted with !important vs inline, ::slotted rule should win for closed mode.]
-    expected: FAIL
-
   [C6. :host with !important vs inline, :host rule should win for closed mode.]
     expected: FAIL
 
   [D1. document vs ::slotted both with !important, ::slotted rule should win for closed mode.]
     expected: FAIL
 
   [D2. document vs :host both with !important, :host rule should win for closed mode.]
     expected: FAIL
@@ -91,20 +50,14 @@
     expected: FAIL
 
   [D6. :host vs inline both with !important, :host rule should win for closed mode.]
     expected: FAIL
 
   [E2. all styles with !important applied, rule in the last tree-of-trees should win for closed mode.]
     expected: FAIL
 
-  [F3. document vs ::slotted with !important, important rule should win for closed mode.]
-    expected: FAIL
-
-  [F4. document vs ::slotted with !important, important rule should win for closed mode.]
-    expected: FAIL
-
   [F5. document vs :host with !important, important rule should win for closed mode.]
     expected: FAIL
 
   [F6. all rules with !important, the last rule in tree-of-trees should win for closed mode.]
     expected: FAIL
 
--- a/testing/web-platform/meta/css/css-scoping/slotted-parsing.html.ini
+++ b/testing/web-platform/meta/css/css-scoping/slotted-parsing.html.ini
@@ -1,20 +1,8 @@
 [slotted-parsing.html]
   type: testharness
-  [Should be a valid selector: '::slotted(*)']
-    expected: FAIL
-
-  [Should be a valid selector: '::slotted(div)']
-    expected: FAIL
-
-  [Should be a valid selector: '::slotted([attr\]:hover)']
-    expected: FAIL
-
-  [Should be a valid selector: '::slotted(:not(.a))']
-    expected: FAIL
-
   [Should be a valid selector: '::slotted(*)::before']
     expected: FAIL
 
   [Should be a valid selector: '::slotted(*)::after']
     expected: FAIL