Bug 1181920. Persist XUL attributes off a scriptrunner. r=peterv
authorBoris Zbarsky <bzbarsky@mit.edu>
Tue, 14 Jul 2015 15:28:57 -0400
changeset 252889 091a6a24c8d1f83ca3f1e87433d0df681e835ae6
parent 252888 19640c24a48b02b552f2f3e15c7a45d7d79b3672
child 252890 29d3d5041e09382fb585a43cffa575513859d8d9
push id29048
push userryanvm@gmail.com
push dateWed, 15 Jul 2015 03:36:39 +0000
treeherdermozilla-central@892594bdad30 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspeterv
bugs1181920
milestone42.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 1181920. Persist XUL attributes off a scriptrunner. r=peterv
dom/xul/XULDocument.cpp
dom/xul/XULDocument.h
--- a/dom/xul/XULDocument.cpp
+++ b/dom/xul/XULDocument.cpp
@@ -939,18 +939,16 @@ XULDocument::AttributeChanged(nsIDocumen
     nsCOMPtr<nsIMutationObserver> kungFuDeathGrip(this);
 
     // XXXbz check aNameSpaceID, dammit!
     // See if we need to update our ref map.
     if (aAttribute == nsGkAtoms::ref) {
         AddElementToRefMap(aElement);
     }
 
-    nsresult rv;
-
     // Synchronize broadcast listeners
     if (mBroadcasterMap &&
         CanBroadcast(aNameSpaceID, aAttribute)) {
         BroadcasterMapEntry* entry =
             static_cast<BroadcasterMapEntry*>
                        (PL_DHashTableSearch(mBroadcasterMap, aElement));
 
         if (entry) {
@@ -1007,18 +1005,20 @@ XULDocument::AttributeChanged(nsIDocumen
     // 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) {
-            rv = Persist(aElement, kNameSpaceID_None, aAttribute);
-            if (NS_FAILED(rv)) return;
+            nsContentUtils::AddScriptRunner(NS_NewRunnableMethodWithArgs
+              <nsIContent*, int32_t, nsIAtom*>
+              (this, &XULDocument::DoPersist, aElement, kNameSpaceID_None,
+               aAttribute));
         }
     }
 }
 
 void
 XULDocument::ContentAppended(nsIDocument* aDocument,
                              nsIContent* aContainer,
                              nsIContent* aFirstNewContent,
--- a/dom/xul/XULDocument.h
+++ b/dom/xul/XULDocument.h
@@ -293,16 +293,22 @@ protected:
     static nsIRDFResource* kNC_persist;
     static nsIRDFResource* kNC_attribute;
     static nsIRDFResource* kNC_value;
 
     static PRLogModuleInfo* gXULLog;
 
     nsresult
     Persist(nsIContent* aElement, int32_t aNameSpaceID, nsIAtom* aAttribute);
+    // Just like Persist but ignores the return value so we can use it
+    // as a runnable method.
+    void DoPersist(nsIContent* aElement, int32_t aNameSpaceID, nsIAtom* aAttribute)
+    {
+        Persist(aElement, aNameSpaceID, aAttribute);
+    }
 
     virtual JSObject* WrapNode(JSContext *aCx, JS::Handle<JSObject*> aGivenProto) override;
 
     // IMPORTANT: The ownership implicit in the following member
     // variables has been explicitly checked and set using nsCOMPtr
     // for owning pointers and raw COM interface pointers for weak
     // (ie, non owning) references. If you add any members to this
     // class, please make the ownership explicit (pinkerton, scc).