Bug 467775, ensure GetMayProcessChildren is called for all recursive template checks, r=smaug,sr=jonas
authorNeil Deakin <neil@mozilla.com>
Tue, 30 Dec 2008 08:31:00 -0500
changeset 23191 beda28c8452898c6608445841d0e2b9e0f03c9a3
parent 23190 1b729bea6d14533d6518efc2939b2a2cd7d4f9d6
child 23192 101fb71a7066705bd9c3217695680742d6949d6a
push id4381
push userneil@mozilla.com
push dateTue, 30 Dec 2008 13:31:40 +0000
treeherdermozilla-central@beda28c84528 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug, jonas
bugs467775
milestone1.9.2a1pre
Bug 467775, ensure GetMayProcessChildren is called for all recursive template checks, r=smaug,sr=jonas
content/xul/templates/src/nsXULContentBuilder.cpp
--- a/content/xul/templates/src/nsXULContentBuilder.cpp
+++ b/content/xul/templates/src/nsXULContentBuilder.cpp
@@ -744,19 +744,18 @@ nsXULContentBuilder::BuildContentFromTem
                 //    <label value="?title"/>
                 //  </vbox>
                 rv = BuildContentFromTemplate(tmplKid, aResourceNode, realKid, PR_FALSE,
                                               PR_FALSE, aChild, PR_FALSE, aMatch,
                                               nsnull /* don't care */,
                                               nsnull /* don't care */);
                 if (NS_FAILED(rv)) return rv;
 
-                if (isGenerationElement && !(mFlags & eDontRecurse)) {
-                    // if recursion is allowed, continue by building the next
-                    // level of children
+                if (isGenerationElement) {
+                    // build the next level of children
                     rv = CreateContainerContents(realKid, aChild, PR_FALSE,
                                                  PR_FALSE, PR_FALSE);
                     if (NS_FAILED(rv)) return rv;
                 }
             }
 
             // We'll _already_ have added the unique elements; but if
             // it's -not- unique, then use the XUL sort service now to
@@ -1017,26 +1016,19 @@ nsXULContentBuilder::CreateTemplateAndCo
                                     PR_FALSE, PR_TRUE);
         }
     }
     else if (!(mFlags & eDontRecurse)) {
         // The content map will contain the generation elements (the ones that
         // are given ids) and only those elements, so get the reference point
         // from the corresponding match.
         nsTemplateMatch *match = nsnull;
-        if (mContentSupportMap.Get(aElement, &match)) {
-            // don't generate children if child processing isn't allowed
-            PRBool mayProcessChildren;
-            nsresult rv = match->mResult->GetMayProcessChildren(&mayProcessChildren);
-            if (NS_FAILED(rv) || !mayProcessChildren)
-                return rv;
-
+        if (mContentSupportMap.Get(aElement, &match))
             CreateContainerContents(aElement, match->mResult, aForceCreation,
                                     PR_FALSE, PR_TRUE);
-        }
     }
 
     PR_LOG(gXULTemplateLog, PR_LOG_ALWAYS,
            ("nsXULContentBuilder::CreateTemplateAndContainerContents end"));
 
     return NS_OK;
 }
 
@@ -1045,16 +1037,27 @@ nsXULContentBuilder::CreateContainerCont
                                              nsIXULTemplateResult* aResult,
                                              PRBool aForceCreation,
                                              PRBool aNotify,
                                              PRBool aNotifyAtEnd)
 {
     if (!aForceCreation && !IsOpen(aElement))
         return NS_OK;
 
+    // don't generate children if recursion or child processing isn't allowed
+    if (aResult != mRootResult) {
+        if (mFlags & eDontRecurse)
+            return NS_OK;
+
+        PRBool mayProcessChildren;
+        nsresult rv = aResult->GetMayProcessChildren(&mayProcessChildren);
+        if (NS_FAILED(rv) || !mayProcessChildren)
+            return rv;
+    }
+
     nsCOMPtr<nsIRDFResource> refResource;
     GetResultResource(aResult, getter_AddRefs(refResource));
     if (! refResource)
         return NS_ERROR_FAILURE;
 
     // Avoid re-entrant builds for the same resource.
     if (IsActivated(refResource))
         return NS_OK;