Backed out changeset a8ac411e1653 (bug 552938) for causing some randomorange.
authorDaniel Holbert <dholbert@cs.stanford.edu>
Wed, 09 Jun 2010 17:16:25 -0700
changeset 43434 42a58530d41962e11cd20a2abfcf02e6c13b21c3
parent 43388 a8ac411e1653c2a2359aa5a76e3f0bc45d99aca5
child 43435 9f3e085fa0f44acf348b9a4fefb2dcfe536c58f9
push id1
push usershaver@mozilla.com
push dateTue, 04 Jan 2011 17:58:04 +0000
bugs552938
milestone1.9.3a5pre
backs outa8ac411e1653c2a2359aa5a76e3f0bc45d99aca5
Backed out changeset a8ac411e1653 (bug 552938) for causing some randomorange.
content/xml/document/src/nsXMLContentSink.cpp
layout/svg/crashtests/crashtests.list
parser/html/Makefile.in
parser/html/nsHtml5SVGLoadDispatcher.cpp
parser/html/nsHtml5SVGLoadDispatcher.h
parser/html/nsHtml5TreeBuilderCppSupplement.h
parser/html/nsHtml5TreeOperation.cpp
parser/html/nsHtml5TreeOperation.h
parser/htmlparser/tests/mochitest/Makefile.in
parser/htmlparser/tests/mochitest/test_bug552938-2.html
parser/htmlparser/tests/mochitest/test_bug552938.html
--- a/content/xml/document/src/nsXMLContentSink.cpp
+++ b/content/xml/document/src/nsXMLContentSink.cpp
@@ -47,16 +47,18 @@
 #include "nsIDOMDOMImplementation.h"
 #include "nsIDOMNSDocument.h"
 #include "nsIContent.h"
 #include "nsIURI.h"
 #include "nsNetUtil.h"
 #include "nsIDocShell.h"
 #include "nsIDocShellTreeItem.h"
 #include "nsIStyleSheetLinkingElement.h"
+#include "nsPresContext.h"
+#include "nsIPresShell.h"
 #include "nsIDOMComment.h"
 #include "nsIDOMCDATASection.h"
 #include "nsDOMDocumentType.h"
 #include "nsHTMLParts.h"
 #include "nsCRT.h"
 #include "nsCSSStyleSheet.h"
 #include "nsCSSLoader.h"
 #include "nsGkAtoms.h"
@@ -89,21 +91,22 @@
 #include "nsContentCreatorFunctions.h"
 #include "nsIContentPolicy.h"
 #include "nsContentPolicyUtils.h"
 #include "nsContentErrors.h"
 #include "nsIDOMProcessingInstruction.h"
 #include "nsNodeUtils.h"
 #include "nsIScriptGlobalObject.h"
 #include "nsIHTMLDocument.h"
+#include "nsEventDispatcher.h"
 #include "mozAutoDocUpdate.h"
 #include "nsMimeTypes.h"
 
 #ifdef MOZ_SVG
-#include "nsHtml5SVGLoadDispatcher.h"
+#include "nsGUIEvent.h"
 #endif
 
 // XXX Open Issues:
 // 1) what's not allowed - We need to figure out which HTML tags
 //    (prefixed with a HTML namespace qualifier) are explicitly not
 //    allowed (if any).
 // 2) factoring code with nsHTMLContentSink - There's some amount of
 //    common code between this and the HTML content sink. This will
@@ -1150,23 +1153,39 @@ nsXMLContentSink::HandleEndElement(const
     if (numFlushed < content->GetChildCount()) {
     	  NotifyAppend(content, numFlushed);
     }
     mNotifyLevel = stackLen - 1;
   }
   DidAddContent();
 
 #ifdef MOZ_SVG
-  if (content->GetNameSpaceID() == kNameSpaceID_SVG &&
-      content->Tag() == nsGkAtoms::svg) {
+  if (mDocument &&
+      content->GetNameSpaceID() == kNameSpaceID_SVG &&
+      (
+#ifdef MOZ_SMIL
+       content->Tag() == nsGkAtoms::svg ||
+#endif
+       content->HasAttr(kNameSpaceID_None, nsGkAtoms::onload))) {
     FlushTags();
-    nsCOMPtr<nsIRunnable> event = new nsHtml5SVGLoadDispatcher(content);
-    if (NS_FAILED(NS_DispatchToMainThread(event))) {
-      NS_WARNING("failed to dispatch svg load dispatcher");
+
+    nsEvent event(PR_TRUE, NS_SVG_LOAD);
+    event.eventStructType = NS_SVG_EVENT;
+    event.flags |= NS_EVENT_FLAG_CANT_BUBBLE;
+
+    // Do we care about forcing presshell creation if it hasn't happened yet?
+    // That is, should this code flush or something?  Does it really matter?
+    // For that matter, do we really want to try getting the prescontext?  Does
+    // this event ever want one?
+    nsRefPtr<nsPresContext> ctx;
+    nsCOMPtr<nsIPresShell> shell = mDocument->GetPrimaryShell();
+    if (shell) {
+      ctx = shell->GetPresContext();
     }
+    nsEventDispatcher::Dispatch(content, ctx, &event);
   }
 #endif
 
   return aInterruptable && NS_SUCCEEDED(result) ? DidProcessATokenImpl() :
                                                   result;
 }
 
 NS_IMETHODIMP 
--- a/layout/svg/crashtests/crashtests.list
+++ b/layout/svg/crashtests/crashtests.list
@@ -44,17 +44,17 @@ load 371563-1.xhtml
 load 375775-1.svg
 load 380691-1.svg
 load 384391-1.xhtml
 load 384499-1.svg
 load 384637-1.svg
 load 384728-1.svg
 load 385246-1.svg
 load 385246-2.svg
-load 385840-1.svg
+asserts(1) load 385840-1.svg # bug 385845
 load 385852-1.svg
 load 386475-1.xhtml
 load 386566-1.svg
 load 387290-1.svg
 load 402408-1.svg
 load 404677-1.xhtml
 load 409565-1.xhtml
 load 409573-1.svg
--- a/parser/html/Makefile.in
+++ b/parser/html/Makefile.in
@@ -45,22 +45,16 @@ MODULE		= html5
 LIBRARY_NAME	= html5p_s
 LIBXUL_LIBRARY	= 1
 
 
 EXPORTS		= \
 		nsHtml5Module.h \
 		$(NULL)
 
-ifdef MOZ_SVG
-EXPORTS += \
-		nsHtml5SVGLoadDispatcher.h \
-		$(NULL)
-endif
-
 CPPSRCS		= \
 		nsHtml5Atoms.cpp \
 		nsHtml5Atom.cpp \
 		nsHtml5AtomTable.cpp \
 		nsHtml5Parser.cpp \
 		nsHtml5AttributeName.cpp \
 		nsHtml5ElementName.cpp \
 		nsHtml5HtmlAttributes.cpp \
@@ -78,21 +72,15 @@ CPPSRCS		= \
 		nsHtml5TreeOpStage.cpp \
 		nsHtml5StateSnapshot.cpp \
 		nsHtml5TreeOpExecutor.cpp \
 		nsHtml5StreamParser.cpp \
 		nsHtml5Speculation.cpp \
 		nsHtml5SpeculativeLoad.cpp \
 		$(NULL)
 
-ifdef MOZ_SVG
-CPPSRCS += \
-		nsHtml5SVGLoadDispatcher.cpp \
-		$(NULL)
-endif
-
 FORCE_STATIC_LIB = 1
 
 include $(topsrcdir)/config/rules.mk
 
 INCLUDES	+= \
 		-I$(srcdir)/../../content/base/src \
 		$(NULL)
deleted file mode 100644
--- a/parser/html/nsHtml5SVGLoadDispatcher.cpp
+++ /dev/null
@@ -1,66 +0,0 @@
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is Mozilla Communicator client code.
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 1998
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *   Pierre Phaneuf <pp@ludusdesign.com>
- *   Henri Sivonen <hsivonen@iki.fi>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either of the GNU General Public License Version 2 or later (the "GPL"),
- * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-#include "nsHtml5SVGLoadDispatcher.h"
-#include "nsPresContext.h"
-#include "nsEventDispatcher.h"
-#include "nsIPresShell.h"
-
-nsHtml5SVGLoadDispatcher::nsHtml5SVGLoadDispatcher(nsIContent* aElement)
-  : mElement(aElement)
-{
-}
-
-NS_IMETHODIMP
-nsHtml5SVGLoadDispatcher::Run()
-{
-  nsEvent event(PR_TRUE, NS_SVG_LOAD);
-  event.eventStructType = NS_SVG_EVENT;
-  event.flags |= NS_EVENT_FLAG_CANT_BUBBLE;
-  // Do we care about forcing presshell creation if it hasn't happened yet?
-  // That is, should this code flush or something?  Does it really matter?
-  // For that matter, do we really want to try getting the prescontext?
-  // Does this event ever want one?
-  nsRefPtr<nsPresContext> ctx;
-  nsCOMPtr<nsIPresShell> shell = mElement->GetOwnerDoc()->GetPrimaryShell();
-  if (shell) {
-    ctx = shell->GetPresContext();
-  }
-  nsEventDispatcher::Dispatch(mElement, ctx, &event);
-  return NS_OK;
-}
deleted file mode 100644
--- a/parser/html/nsHtml5SVGLoadDispatcher.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is Asynchronous SVG load event dispatching code.
- *
- * The Initial Developer of the Original Code is
- * Mozilla Foundation.
- * Portions created by the Initial Developer are Copyright (C) 2010
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *   Henri Sivonen <hsivonen@iki.fi>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-#ifndef nsHtml5SVGLoadDispatcher_h_
-#define nsHtml5SVGLoadDispatcher_h_
-
-#include "nsThreadUtils.h"
-#include "nsIContent.h"
-
-class nsHtml5SVGLoadDispatcher : public nsRunnable
-{
-  private:
-    nsCOMPtr<nsIContent> mElement;
-  public:
-    nsHtml5SVGLoadDispatcher(nsIContent* aElement);
-    NS_IMETHOD Run();
-};
-
-#endif // nsHtml5SVGLoadDispatcher_h_
--- a/parser/html/nsHtml5TreeBuilderCppSupplement.h
+++ b/parser/html/nsHtml5TreeBuilderCppSupplement.h
@@ -481,23 +481,34 @@ nsHtml5TreeBuilder::elementPopped(PRInt3
   }
   if (aName == nsHtml5Atoms::style || (aNamespace == kNameSpaceID_XHTML && aName == nsHtml5Atoms::link)) {
     nsHtml5TreeOperation* treeOp = mOpQueue.AppendElement();
     NS_ASSERTION(treeOp, "Tree op allocation failed.");
     treeOp->Init(eTreeOpUpdateStyleSheet, aElement);
     return;
   }
   if (aNamespace == kNameSpaceID_SVG) {
-#ifdef MOZ_SVG
-    if (aName == nsHtml5Atoms::svg) {
-      nsHtml5TreeOperation* treeOp = mOpQueue.AppendElement();
-      NS_ASSERTION(treeOp, "Tree op allocation failed.");
-      treeOp->Init(eTreeOpSvgLoad, aElement);
+#if 0
+    if (aElement->HasAttr(kNameSpaceID_None, nsHtml5Atoms::onload)) {
+      nsEvent event(PR_TRUE, NS_SVG_LOAD);
+      event.eventStructType = NS_SVG_EVENT;
+      event.flags |= NS_EVENT_FLAG_CANT_BUBBLE;
+      // Do we care about forcing presshell creation if it hasn't happened yet?
+      // That is, should this code flush or something?  Does it really matter?
+      // For that matter, do we really want to try getting the prescontext?  Does
+      // this event ever want one?
+      nsRefPtr<nsPresContext> ctx;
+      nsCOMPtr<nsIPresShell> shell = parser->GetDocument()->GetPrimaryShell();
+      if (shell) {
+        ctx = shell->GetPresContext();
+      }
+      nsEventDispatcher::Dispatch(aElement, ctx, &event);
     }
 #endif
+    // TODO soft flush the op queue every now and then
     return;
   }
   // we now have only HTML
   // Some HTML nodes need DoneAddingChildren() called to initialize
   // properly (e.g. form state restoration).
   // XXX expose ElementName group here and do switch
   if (aName == nsHtml5Atoms::video ||
       aName == nsHtml5Atoms::audio ||
--- a/parser/html/nsHtml5TreeOperation.cpp
+++ b/parser/html/nsHtml5TreeOperation.cpp
@@ -56,20 +56,16 @@
 #include "nsIDOMHTMLFormElement.h"
 #include "nsIFormControl.h"
 #include "nsIStyleSheetLinkingElement.h"
 #include "nsIDOMDocumentType.h"
 #include "nsIMutationObserver.h"
 #include "nsIFormProcessor.h"
 #include "nsIServiceManager.h"
 
-#ifdef MOZ_SVG
-#include "nsHtml5SVGLoadDispatcher.h"
-#endif
-
 static NS_DEFINE_CID(kFormProcessorCID, NS_FORMPROCESSOR_CID);
 
 /**
  * Helper class that opens a notification batch if the current doc
  * is different from the executor doc.
  */
 class NS_STACK_CLASS nsHtml5OtherDocUpdate {
   public:
@@ -659,24 +655,14 @@ nsHtml5TreeOperation::Perform(nsHtml5Tre
     case eTreeOpSetScriptLineNumberAndFreeze: {
       nsIContent* node = *(mOne.node);
       nsCOMPtr<nsIScriptElement> sele = do_QueryInterface(node);
       NS_ASSERTION(sele, "Node didn't QI to script.");
       sele->SetScriptLineNumber(mInt);
       sele->FreezeUriAsyncDefer();
       return rv;
     }
-#ifdef MOZ_SVG
-    case eTreeOpSvgLoad: {
-      nsIContent* node = *(mOne.node);
-      nsCOMPtr<nsIRunnable> event = new nsHtml5SVGLoadDispatcher(node);
-      if (NS_FAILED(NS_DispatchToMainThread(event))) {
-        NS_WARNING("failed to dispatch svg load dispatcher");
-      }
-      return rv;
-    }
-#endif
     default: {
       NS_NOTREACHED("Bogus tree op");
     }
   }
   return rv; // keep compiler happy
 }
--- a/parser/html/nsHtml5TreeOperation.h
+++ b/parser/html/nsHtml5TreeOperation.h
@@ -76,19 +76,16 @@ enum eHtml5TreeOperation {
   eTreeOpNeedsCharsetSwitchTo,
   eTreeOpUpdateStyleSheet,
   eTreeOpProcessMeta,
   eTreeOpProcessOfflineManifest,
   eTreeOpMarkMalformedIfScript,
   eTreeOpStreamEnded,
   eTreeOpSetStyleLineNumber,
   eTreeOpSetScriptLineNumberAndFreeze,
-#ifdef MOZ_SVG
-  eTreeOpSvgLoad,
-#endif
   eTreeOpStartLayout
 };
 
 class nsHtml5TreeOperationStringPair {
   private:
     nsString mPublicId;
     nsString mSystemId;
   public:
--- a/parser/htmlparser/tests/mochitest/Makefile.in
+++ b/parser/htmlparser/tests/mochitest/Makefile.in
@@ -56,14 +56,12 @@ include $(topsrcdir)/config/rules.mk
 		test_bug358797.html \
 		test_bug396568.html \
 		test_bug418464.html \
 		test_bug460437.xhtml \
 		test_bug502091.html \
 		bug_502091_iframe.html \
 		test_compatmode.html \
 		invalidchar.xml \
-		test_bug552938.html \
-		test_bug552938-2.html \
 		$(NULL)
 
 libs:: $(_TEST_FILES)
 	$(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/tests/$(relativesrcdir)
deleted file mode 100644
--- a/parser/htmlparser/tests/mochitest/test_bug552938-2.html
+++ /dev/null
@@ -1,38 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<!--
-https://bugzilla.mozilla.org/show_bug.cgi?id=552938
--->
-<head>
-  <title>Test for Bug 552938</title>
-  <script type="text/javascript" src="/MochiKit/MochiKit.js"></script>
-  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
-</head>
-<body onload='runTest();'>
-<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=552938">Mozilla Bug 552938</a>
-<script>
-var svgLoadFired = false;
-</script>
-<p id="display"></p>
-<div id="content" style="display: none">
-  <svg>
-    <script>
-       document.getElementsByTagName("svg")[0].addEventListener("SVGLoad", 
-         function() { svgLoadFired = true; }, false);
-    </script>
-  </svg>
-</div>
-<pre id="test">
-<script class="testbody" type="text/javascript">
-
-/** Test for Bug 552938 **/
-function runTest() {
-  ok(svgLoadFired, "The SVG load event should have fired.");
-  SimpleTest.finish();
-}
-SimpleTest.waitForExplicitFinish();
-</script>
-</pre>
-</body>
-</html>
deleted file mode 100644
--- a/parser/htmlparser/tests/mochitest/test_bug552938.html
+++ /dev/null
@@ -1,33 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<!--
-https://bugzilla.mozilla.org/show_bug.cgi?id=552938
--->
-<head>
-  <title>Test for Bug 552938</title>
-  <script type="text/javascript" src="/MochiKit/MochiKit.js"></script>
-  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
-</head>
-<body onload='runTest();'>
-<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=552938">Mozilla Bug 552938</a>
-<script>
-var svgLoadFired = false;
-</script>
-<p id="display"></p>
-<div id="content" style="display: none">
-  <svg onload="svgLoadFired = true;"></svg>
-</div>
-<pre id="test">
-<script class="testbody" type="text/javascript">
-
-/** Test for Bug 552938 **/
-function runTest() {
-  ok(svgLoadFired, "The SVG load event should have fired.");
-  SimpleTest.finish();
-}
-SimpleTest.waitForExplicitFinish();
-</script>
-</pre>
-</body>
-</html>