Bug 1417829 - Remove unresolved pseudoclass; r=heycam,smaug
authorEdgar Chen <echen@mozilla.com>
Mon, 04 Dec 2017 17:49:41 +0800
changeset 453022 770bbacbc16bdcb1c62d402e68d57767e626be0c
parent 453021 172079108ce9650fd6dd88f010b887602f5f2789
child 453023 78533a254124a2686d70f6fd39323f954a1f06bf
push id1648
push usermtabara@mozilla.com
push dateThu, 01 Mar 2018 12:45:47 +0000
treeherdermozilla-release@cbb9688c2eeb [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersheycam, smaug
bugs1417829
milestone59.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1417829 - Remove unresolved pseudoclass; r=heycam,smaug MozReview-Commit-ID: JHfYVnh1SET
dom/base/CustomElementRegistry.cpp
dom/events/EventStates.h
dom/tests/mochitest/webcomponents/mochitest.ini
dom/tests/mochitest/webcomponents/test_unresolved_pseudo_class.html
layout/style/nsCSSPseudoClassList.h
--- a/dom/base/CustomElementRegistry.cpp
+++ b/dom/base/CustomElementRegistry.cpp
@@ -328,17 +328,16 @@ CustomElementRegistry::RegisterUnresolve
 
   if (mCustomDefinitions.GetWeak(typeName)) {
     return;
   }
 
   nsTArray<nsWeakPtr>* unresolved = mCandidatesMap.LookupOrAdd(typeName);
   nsWeakPtr* elem = unresolved->AppendElement();
   *elem = do_GetWeakReference(aElement);
-  aElement->AddStates(NS_EVENT_STATE_UNRESOLVED);
 }
 
 void
 CustomElementRegistry::UnregisterUnresolvedElement(Element* aElement,
                                                    nsAtom* aTypeName)
 {
   nsTArray<nsWeakPtr>* candidates;
   if (mCandidatesMap.Get(aTypeName, &candidates)) {
@@ -902,18 +901,16 @@ DoUpgrade(Element* aElement,
 } // anonymous namespace
 
 // https://html.spec.whatwg.org/multipage/scripting.html#upgrades
 /* static */ void
 CustomElementRegistry::Upgrade(Element* aElement,
                                CustomElementDefinition* aDefinition,
                                ErrorResult& aRv)
 {
-  aElement->RemoveStates(NS_EVENT_STATE_UNRESOLVED);
-
   RefPtr<CustomElementData> data = aElement->GetCustomElementData();
   MOZ_ASSERT(data, "CustomElementData should exist");
 
   // Step 1 and step 2.
   if (data->mState == CustomElementData::State::eCustom ||
       data->mState == CustomElementData::State::eFailed) {
     return;
   }
--- a/dom/events/EventStates.h
+++ b/dom/events/EventStates.h
@@ -237,18 +237,17 @@ private:
 // Handler for the content has been disabled.
 #define NS_EVENT_STATE_HANDLER_DISABLED NS_DEFINE_EVENT_STATE_MACRO(19)
 // Handler for the content has crashed
 #define NS_EVENT_STATE_HANDLER_CRASHED NS_DEFINE_EVENT_STATE_MACRO(20)
 // Content is required.
 #define NS_EVENT_STATE_REQUIRED      NS_DEFINE_EVENT_STATE_MACRO(21)
 // Content is optional (and can be required).
 #define NS_EVENT_STATE_OPTIONAL      NS_DEFINE_EVENT_STATE_MACRO(22)
-// Element is an unresolved custom element candidate
-#define NS_EVENT_STATE_UNRESOLVED NS_DEFINE_EVENT_STATE_MACRO(23)
+// Free bit                          NS_DEFINE_EVENT_STATE_MACRO(23)
 // Link has been visited.
 #define NS_EVENT_STATE_VISITED       NS_DEFINE_EVENT_STATE_MACRO(24)
 // Link hasn't been visited.
 #define NS_EVENT_STATE_UNVISITED     NS_DEFINE_EVENT_STATE_MACRO(25)
 // Drag is hovering over content.
 #define NS_EVENT_STATE_DRAGOVER      NS_DEFINE_EVENT_STATE_MACRO(26)
 // Content value is in-range (and can be out-of-range).
 #define NS_EVENT_STATE_INRANGE       NS_DEFINE_EVENT_STATE_MACRO(27)
@@ -355,15 +354,14 @@ private:
   REQUIRED_STATES |                           \
   NS_EVENT_STATE_ACTIVE |                     \
   NS_EVENT_STATE_DRAGOVER |                   \
   NS_EVENT_STATE_FOCUS |                      \
   NS_EVENT_STATE_FOCUSRING |                  \
   NS_EVENT_STATE_FOCUS_WITHIN |               \
   NS_EVENT_STATE_FULL_SCREEN |                \
   NS_EVENT_STATE_HOVER |                      \
-  NS_EVENT_STATE_UNRESOLVED |                 \
   NS_EVENT_STATE_URLTARGET                    \
 )
 
 #define INTRINSIC_STATES (~EXTERNALLY_MANAGED_STATES)
 
 #endif // mozilla_EventStates_h_
--- a/dom/tests/mochitest/webcomponents/mochitest.ini
+++ b/dom/tests/mochitest/webcomponents/mochitest.ini
@@ -37,11 +37,10 @@ support-files =
 [test_template.html]
 [test_template_xhtml.html]
 [test_shadowroot.html]
 [test_shadowroot_inert_element.html]
 [test_shadowroot_style.html]
 [test_shadowroot_style_order.html]
 [test_style_fallback_content.html]
 skip-if = stylo # Bug 1410170
-[test_unresolved_pseudo_class.html]
 [test_link_prefetch.html]
 [test_bug1269155.html]
deleted file mode 100644
--- a/dom/tests/mochitest/webcomponents/test_unresolved_pseudo_class.html
+++ /dev/null
@@ -1,101 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<!--
-https://bugzilla.mozilla.org/show_bug.cgi?id=1111633
--->
-<head>
-  <title>Test template element in stale document.</title>
-  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
-  <style>
-  :unresolved {
-    color: rgb(0, 0, 255);
-    background-color: rgb(0, 0, 255);
-  }
-
-  x-foo { color: rgb(255, 0, 0); }
-
-  [is="x-del"]:not(:unresolved) { color: rgb(255, 0, 0); }
-
-  [is="x-bar"]:not(:unresolved) { color: rgb(255, 0, 0); }
-
-  [is="x-bar"]:unresolved { background-color: rgb(255, 0, 0); }
-
-  x-baz:not(:unresolved) {
-    color: rgb(255, 0, 0);
-    background-color: rgb(255, 0, 0);
-  }
-
-  span { color: rgb(0,255,0); }
-
-  x-foo:unresolved + span { color: rgb(255,0,0); }
-
-  </style>
-</head>
-<body>
-<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1111633">Bug 1111633</a>
-<div id="container"></div>
-<x-foo id="foo"></x-foo>
-<span id="span1">This text should be green</span>
-<span id="bar" is="x-bar"></span>
-<x-baz id="baz"></x-baz>
-<span id="del" is="x-del"></span>
-<script>
-
-// Before define
-var foo = document.querySelector('#foo');
-is(getComputedStyle(foo).color, "rgb(0, 0, 255)", "foo - color");
-is(getComputedStyle(foo).backgroundColor, "rgb(0, 0, 255)", "foo - backgroundColor");
-
-var bar = document.querySelector('#bar');
-is(getComputedStyle(bar).color, "rgb(0, 0, 255)", "bar - color");
-is(getComputedStyle(bar).backgroundColor, "rgb(255, 0, 0)", "bar - backgroundColor");
-
-var baz = document.querySelector('#baz');
-is(getComputedStyle(baz).color, "rgb(0, 0, 255)", "baz - color");
-is(getComputedStyle(baz).backgroundColor, "rgb(0, 0, 255)", "baz - backgroundColor");
-
-var span1 = document.querySelector('#span1');
-is(getComputedStyle(span1).color, "rgb(255, 0, 0)", "span1 - color");
-
-customElements.define('x-foo', class extends HTMLElement {});
-
-customElements.define('x-bar', class extends HTMLSpanElement {}, { extends: 'span' });
-
-customElements.define('x-baz', class extends HTMLElement {});
-
-// After define
-is(getComputedStyle(foo).color, "rgb(255, 0, 0)",
-   "foo - color (after define)");
-
-is(getComputedStyle(bar).color,
-   "rgb(255, 0, 0)", "bar - color (after define)");
-
-is(getComputedStyle(baz).color,
-   "rgb(255, 0, 0)", "baz - color (after define)");
-is(getComputedStyle(baz).backgroundColor,
-   "rgb(255, 0, 0)", "baz - backgroundColor (after define)");
-
-is(getComputedStyle(span1).color, "rgb(0, 255, 0)", "span1 - color (after define)");
-
-// After tree removal
-var del = document.querySelector('#del');
-is(getComputedStyle(del).color, "rgb(0, 0, 255)", "del - color");
-var par = del.parentNode;
-par.removeChild(del);
-// Changing is attribute after creation should not change the type
-// of a custom element, even if the element was removed and re-append to the tree.
-del.setAttribute("is", "foobar");
-par.appendChild(del);
-is(getComputedStyle(del).color, "rgb(0, 0, 255)", "del - color (after reappend)");
-
-class Del extends HTMLSpanElement {};
-customElements.define('x-del', Del, { extends: 'span' });
-// [is="x-del"] will not match any longer so the rule of span will apply
-is(getComputedStyle(del).color, "rgb(0, 255, 0)", "del - color (after define)");
-// but the element should have been upgraded:
-ok(del instanceof Del, "element was upgraded correctly after changing |is|");
-
-</script>
-</body>
-</html>
--- a/layout/style/nsCSSPseudoClassList.h
+++ b/layout/style/nsCSSPseudoClassList.h
@@ -84,19 +84,16 @@ CSS_PSEUDO_CLASS(onlyOfType, ":only-of-t
 CSS_PSEUDO_CLASS(nthChild, ":nth-child", 0, "")
 CSS_PSEUDO_CLASS(nthLastChild, ":nth-last-child", 0, "")
 CSS_PSEUDO_CLASS(nthOfType, ":nth-of-type", 0, "")
 CSS_PSEUDO_CLASS(nthLastOfType, ":nth-last-of-type", 0, "")
 
 // Match nodes that are HTML but not XHTML
 CSS_PSEUDO_CLASS(mozIsHTML, ":-moz-is-html", 0, "")
 
-// Match all custom elements whose created callback has not yet been invoked
- CSS_STATE_PSEUDO_CLASS(unresolved, ":unresolved", 0, "", NS_EVENT_STATE_UNRESOLVED)
-
 // Matches nodes that are in a native-anonymous subtree (i.e., nodes in
 // a subtree of C++ anonymous content constructed by Gecko for its own
 // purposes).
 CSS_PSEUDO_CLASS(mozNativeAnonymous, ":-moz-native-anonymous",
                  CSS_PSEUDO_CLASS_ENABLED_IN_UA_SHEETS, "")
 
 CSS_PSEUDO_CLASS(mozUseShadowTreeRoot, ":-moz-use-shadow-tree-root",
                  CSS_PSEUDO_CLASS_ENABLED_IN_UA_SHEETS, "")