Bug 404798, assertions when root element is removed from xul document during inline script, r+sr=smaug
authorNeil Deakin <neil@mozilla.com>
Wed, 22 Apr 2009 08:55:54 -0400
changeset 27619 0b355aff0abdb772438f68cc8d7481755eec8cc9
parent 27618 d02c0b3b889475b09862ab168b0d2458afe5f7c0
child 27620 221b58f349ccb0dd7996aff3a4ba4776df629279
push id6654
push userneil@mozilla.com
push dateWed, 22 Apr 2009 12:57:00 +0000
treeherdermozilla-central@0b355aff0abd [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs404798
milestone1.9.2a1pre
Bug 404798, assertions when root element is removed from xul document during inline script, r+sr=smaug
content/xul/document/src/nsXULDocument.cpp
layout/base/nsPresShell.cpp
--- a/content/xul/document/src/nsXULDocument.cpp
+++ b/content/xul/document/src/nsXULDocument.cpp
@@ -1993,29 +1993,16 @@ nsXULDocument::Init()
 
     return NS_OK;
 }
 
 
 nsresult
 nsXULDocument::StartLayout(void)
 {
-    if (!GetRootContent()) {
-#ifdef PR_LOGGING
-        if (PR_LOG_TEST(gXULLog, PR_LOG_WARNING)) {
-            nsCAutoString urlspec;
-            mDocumentURI->GetSpec(urlspec);
-
-            PR_LOG(gXULLog, PR_LOG_WARNING,
-                   ("xul: unable to layout '%s'; no root content", urlspec.get()));
-        }
-#endif
-        return NS_OK;
-    }
-
     nsPresShellIterator iter(this);
     nsCOMPtr<nsIPresShell> shell;
     while ((shell = iter.GetNextShell())) {
 
         // Resize-reflow this time
         nsPresContext *cx = shell->GetPresContext();
         NS_ASSERTION(cx != nsnull, "no pres context");
         if (! cx)
@@ -3817,19 +3804,20 @@ nsXULDocument::CheckTemplateBuilderHooku
 }
 
 /* static */ nsresult
 nsXULDocument::CreateTemplateBuilder(nsIContent* aElement)
 {
     // Check if need to construct a tree builder or content builder.
     PRBool isTreeBuilder = PR_FALSE;
 
-    nsIDocument *document = aElement->GetOwnerDoc();
-    NS_ASSERTION(document, "no document");
-    NS_ENSURE_TRUE(document, NS_ERROR_UNEXPECTED);
+    // return successful if the element is not is a document, as an inline
+    // script could have removed it
+    nsIDocument *document = aElement->GetCurrentDoc();
+    NS_ENSURE_TRUE(document, NS_OK);
 
     PRInt32 nameSpaceID;
     nsIAtom* baseTag = document->BindingManager()->
       ResolveTag(aElement, &nameSpaceID);
 
     if ((nameSpaceID == kNameSpaceID_XUL) && (baseTag == nsGkAtoms::tree)) {
         // By default, we build content for a tree and then we attach
         // the tree content view. However, if the `dont-build-content'
--- a/layout/base/nsPresShell.cpp
+++ b/layout/base/nsPresShell.cpp
@@ -5806,17 +5806,17 @@ PresShell::HandleEvent(nsIView         *
     
     if (targetView) {
       aView = targetView;
       frame = static_cast<nsIFrame*>(aView->GetClientData());
     }
   }
 
   if (dispatchUsingCoordinates) {
-    NS_ASSERTION(frame, "Nothing to handle this event!");
+    NS_WARN_IF_FALSE(frame, "Nothing to handle this event!");
     if (!frame)
       return NS_OK;
 
     nsPresContext* framePresContext = frame->PresContext();
     nsPresContext* rootPresContext = framePresContext->RootPresContext();
     NS_ASSERTION(rootPresContext == mPresContext->RootPresContext(),
                  "How did we end up outside the connected prescontext/viewmanager hierarchy?"); 
     // If we aren't starting our event dispatch from the root frame of the root prescontext,