Bug 1137009 - part 2 - Do not persist attributes of xul window if the window is in fullscreen. r=enndeakin, a=lizzard
authorXidorn Quan <quanxunzhen@gmail.com>
Thu, 24 Sep 2015 11:39:22 +1000
changeset 296210 735ebc504963a025a007611bad8c9bf7f05c9ed7
parent 296209 7e06450a934c166a81645b56b1818f6e024e6397
child 296211 ecdf6e8d473d2315e9b44c0e0fcef86760fd0511
push id5245
push userraliiev@mozilla.com
push dateThu, 29 Oct 2015 11:30:51 +0000
treeherdermozilla-beta@dac831dc1bd0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersenndeakin, lizzard
bugs1137009
milestone43.0a2
Bug 1137009 - part 2 - Do not persist attributes of xul window if the window is in fullscreen. r=enndeakin, a=lizzard
dom/xul/XULDocument.cpp
--- a/dom/xul/XULDocument.cpp
+++ b/dom/xul/XULDocument.cpp
@@ -915,16 +915,33 @@ XULDocument::AttributeWillChange(nsIDocu
     // See if we need to update our ref map.
     if (aAttribute == nsGkAtoms::ref) {
         // Might not need this, but be safe for now.
         nsCOMPtr<nsIMutationObserver> kungFuDeathGrip(this);
         RemoveElementFromRefMap(aElement);
     }
 }
 
+static bool
+ShouldPersistAttribute(nsIDocument* aDocument, Element* aElement)
+{
+    if (aElement->IsXULElement(nsGkAtoms::window)) {
+        if (nsCOMPtr<nsPIDOMWindow> window = aDocument->GetWindow()) {
+            bool isFullscreen;
+            window->GetFullScreen(&isFullscreen);
+            if (isFullscreen) {
+                // Don't persist attributes if it is window element and
+                // we are in fullscreen state.
+                return false;
+            }
+        }
+    }
+    return true;
+}
+
 void
 XULDocument::AttributeChanged(nsIDocument* aDocument,
                               Element* aElement, int32_t aNameSpaceID,
                               nsIAtom* aAttribute, int32_t aModType,
                               const nsAttrValue* aOldValue)
 {
     NS_ASSERTION(aDocument == this, "unexpected doc");
 
@@ -989,28 +1006,29 @@ XULDocument::AttributeChanged(nsIDocumen
             }
         }
     }
 
     // checks for modifications in broadcasters
     bool listener, resolved;
     CheckBroadcasterHookup(aElement, &listener, &resolved);
 
-    // See if there is anything we need to persist in the localstore.
-    //
-    // XXX Namespace handling broken :-(
-    nsAutoString persist;
-    aElement->GetAttr(kNameSpaceID_None, nsGkAtoms::persist, persist);
-    if (!persist.IsEmpty()) {
-        // XXXldb This should check that it's a token, not just a substring.
-        if (persist.Find(nsDependentAtomString(aAttribute)) >= 0) {
+    if (ShouldPersistAttribute(aDocument, aElement)) {
+        // See if there is anything we need to persist in the localstore.
+        //
+        // XXX Namespace handling broken :-(
+        nsString persist;
+        aElement->GetAttr(kNameSpaceID_None, nsGkAtoms::persist, persist);
+        if (!persist.IsEmpty() &&
+            // XXXldb This should check that it's a token, not just a substring.
+            persist.Find(nsDependentAtomString(aAttribute)) >= 0) {
             nsContentUtils::AddScriptRunner(NS_NewRunnableMethodWithArgs
-              <nsIContent*, int32_t, nsIAtom*>
-              (this, &XULDocument::DoPersist, aElement, kNameSpaceID_None,
-               aAttribute));
+                <nsIContent*, int32_t, nsIAtom*>
+                (this, &XULDocument::DoPersist, aElement,
+                 kNameSpaceID_None, aAttribute));
         }
     }
 }
 
 void
 XULDocument::ContentAppended(nsIDocument* aDocument,
                              nsIContent* aContainer,
                              nsIContent* aFirstNewContent,