Bug 1216049 part 1 - Remove the use of Element::IsFullScreenAncestor() in Element::UnbindFromTree(). r?smaug draft
authorXidorn Quan <me@upsuper.org>
Wed, 29 Jun 2016 15:52:23 +1000
changeset 382248 283dc22bbd06507620bf50743ad25077156066f0
parent 382160 260b04d1226f35bcb3c61bc3d17115507b573486
child 382249 f15138055e80688ea8a1bd528374e1c8055b7633
push id21673
push userxquan@mozilla.com
push dateWed, 29 Jun 2016 12:14:27 +0000
reviewerssmaug
bugs1216049
milestone50.0a1
Bug 1216049 part 1 - Remove the use of Element::IsFullScreenAncestor() in Element::UnbindFromTree(). r?smaug Since UnbindFromTree() would eventually be called synchronously for every element unbound, we don't have to check whether the root of unbound elements is a fullscreen ancestor. MozReview-Commit-ID: F6mxNsVZ2yl
dom/base/Element.cpp
--- a/dom/base/Element.cpp
+++ b/dom/base/Element.cpp
@@ -1728,28 +1728,27 @@ Element::UnbindFromTree(bool aDeep, bool
 
   // Make sure to unbind this node before doing the kids
   nsIDocument* document =
     HasFlag(NODE_FORCE_XBL_BINDINGS) ? OwnerDoc() : GetComposedDoc();
 
   if (HasPointerLock()) {
     nsIDocument::UnlockPointer();
   }
+  if (OwnerDoc()->GetFullscreenElement() == this) {
+    // The element being removed is an ancestor of the full-screen element,
+    // exit full-screen state.
+    nsContentUtils::ReportToConsole(nsIScriptError::warningFlag,
+                                    NS_LITERAL_CSTRING("DOM"), OwnerDoc(),
+                                    nsContentUtils::eDOM_PROPERTIES,
+                                    "RemovedFullscreenElement");
+    // Fully exit full-screen.
+    nsIDocument::ExitFullscreenInDocTree(OwnerDoc());
+  }
   if (aNullParent) {
-    if (IsFullScreenAncestor()) {
-      // The element being removed is an ancestor of the full-screen element,
-      // exit full-screen state.
-      nsContentUtils::ReportToConsole(nsIScriptError::warningFlag,
-                                      NS_LITERAL_CSTRING("DOM"), OwnerDoc(),
-                                      nsContentUtils::eDOM_PROPERTIES,
-                                      "RemovedFullscreenElement");
-      // Fully exit full-screen.
-      nsIDocument::ExitFullscreenInDocTree(OwnerDoc());
-    }
-
     if (GetParent() && GetParent()->IsInUncomposedDoc()) {
       // Update the editable descendant count in the ancestors before we
       // lose the reference to the parent.
       int32_t editableDescendantChange = -1 * EditableInclusiveDescendantCount(this);
       if (editableDescendantChange != 0) {
         nsIContent* parent = GetParent();
         while (parent) {
           parent->ChangeEditableDescendantCount(editableDescendantChange);