Bug 1022741 - Use CrossShadowCurrentDoc() in Element::UpdateState. r=smaug, a=2.0+
authorWilliam Chen <wchen@mozilla.com>
Tue, 10 Jun 2014 14:41:31 -0700
changeset 206953 2fa749e072e2afe9044b0deb672f76462740de1c
parent 206952 1313a8d95e9591f4cdc4f4b211b2ae5b2177c858
child 206954 f78313ff6cbfe8ca00353cfe36adf89de305c8f0
push id3741
push userasasaki@mozilla.com
push dateMon, 21 Jul 2014 20:25:18 +0000
treeherdermozilla-beta@4d6f46f5af68 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug, 2
bugs1022741
milestone32.0a2
Bug 1022741 - Use CrossShadowCurrentDoc() in Element::UpdateState. r=smaug, a=2.0+
content/base/src/Element.cpp
layout/reftests/webcomponents/input-transition-1-ref.html
layout/reftests/webcomponents/input-transition-1.html
layout/reftests/webcomponents/reftest.list
layout/style/nsTransitionManager.cpp
--- a/content/base/src/Element.cpp
+++ b/content/base/src/Element.cpp
@@ -211,17 +211,17 @@ Element::UpdateLinkState(EventStates aSt
 void
 Element::UpdateState(bool aNotify)
 {
   EventStates oldState = mState;
   mState = IntrinsicState() | (oldState & ESM_MANAGED_STATES);
   if (aNotify) {
     EventStates changedStates = oldState ^ mState;
     if (!changedStates.IsEmpty()) {
-      nsIDocument* doc = GetCurrentDoc();
+      nsIDocument* doc = GetCrossShadowCurrentDoc();
       if (doc) {
         nsAutoScriptBlocker scriptBlocker;
         doc->ContentStateChanged(this, changedStates);
       }
     }
   }
 }
 
new file mode 100644
--- /dev/null
+++ b/layout/reftests/webcomponents/input-transition-1-ref.html
@@ -0,0 +1,6 @@
+<!DOCTYPE html>
+<html>
+  <body>
+    <input type="checkbox" checked><div style="height: 50px; width: 50px; background: green;"></div>
+  </body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/webcomponents/input-transition-1.html
@@ -0,0 +1,23 @@
+<!DOCTYPE html>
+<html class="reftest-wait">
+  <head>
+  </head>
+  <body>
+    <div id="host"></div>
+    <script>
+      var host = document.getElementById("host");
+      var root = host.createShadowRoot();
+      root.innerHTML = '<style>input ~ div { background: red; transition: background 100ms; } input:checked ~ div { background: green; }</style><input id="one" type="checkbox"><div style="height: 50px; width: 50px;"></div>';
+
+      function tweak() {
+          var el = root.getElementById("one");
+          el.checked = true;
+          el.nextSibling.addEventListener("transitionend", function() {
+            document.documentElement.removeAttribute("class");
+          }, false);
+      }
+
+      window.addEventListener("MozReftestInvalidate", tweak, false);
+    </script>
+  </body>
+</html>
--- a/layout/reftests/webcomponents/reftest.list
+++ b/layout/reftests/webcomponents/reftest.list
@@ -8,8 +8,9 @@ pref(dom.webcomponents.enabled,true) == 
 pref(dom.webcomponents.enabled,true) == adjacent-insertion-points-1.html adjacent-insertion-points-1-ref.html
 pref(dom.webcomponents.enabled,true) == adjacent-insertion-points-2.html adjacent-insertion-points-2-ref.html
 pref(dom.webcomponents.enabled,true) == fallback-content-1.html fallback-content-1-ref.html
 pref(dom.webcomponents.enabled,true) == remove-insertion-point-1.html remove-insertion-point-1-ref.html
 pref(dom.webcomponents.enabled,true) == nested-insertion-point-1.html nested-insertion-point-1-ref.html
 pref(dom.webcomponents.enabled,true) == basic-shadow-element-1.html basic-shadow-element-1-ref.html
 pref(dom.webcomponents.enabled,true) == nested-shadow-element-1.html nested-shadow-element-1-ref.html
 pref(dom.webcomponents.enabled,true) == update-dist-node-descendants-1.html update-dist-node-descendants-1-ref.html
+pref(dom.webcomponents.enabled,true) random-if(B2G&&browserIsRemote) == input-transition-1.html input-transition-1-ref.html # Failure on B2G emulator due to Bug 1018381
--- a/layout/style/nsTransitionManager.cpp
+++ b/layout/style/nsTransitionManager.cpp
@@ -938,17 +938,17 @@ nsTransitionManager::FlushTransitions(Fl
       ElementTransitions *et = static_cast<ElementTransitions*>(next);
       next = PR_NEXT_LINK(next);
 
       bool canThrottleTick = aFlags == Can_Throttle &&
         et->CanPerformOnCompositorThread(
           CommonElementAnimationData::CanAnimateFlags(0)) &&
         et->CanThrottleAnimation(now);
 
-      NS_ABORT_IF_FALSE(et->mElement->GetCurrentDoc() ==
+      NS_ABORT_IF_FALSE(et->mElement->GetCrossShadowCurrentDoc() ==
                           mPresContext->Document(),
                         "Element::UnbindFromTree should have "
                         "destroyed the element transitions object");
 
       uint32_t i = et->mAnimations.Length();
       NS_ABORT_IF_FALSE(i != 0, "empty transitions list?");
       bool transitionStartedOrEnded = false;
       do {