Bug 611798 - Do not pretent that we need the presshell to exist in order to turn off update view batching when the editor operations finish, because we don't; r=bzbarsky a=blocking-final+
authorEhsan Akhgari <ehsan@mozilla.com>
Fri, 10 Dec 2010 17:14:26 -0500
changeset 59113 e42d81b3e0ccc79066cd3514446ae4f881b4bff2
parent 59112 7aedd1d023d0ba4eb9b3483f6742bd11691a1e2d
child 59114 61361e67bfc41a2ca5b0b5f9667f1736fa28fb36
push idunknown
push userunknown
push dateunknown
reviewersbzbarsky, blocking-final
bugs611798
milestone2.0b8pre
first release with
nightly linux32
e42d81b3e0cc / 4.0b8pre / 20101211030333 / files
nightly linux64
e42d81b3e0cc / 4.0b8pre / 20101211030333 / files
nightly mac
e42d81b3e0cc / 4.0b8pre / 20101211030333 / files
nightly win32
e42d81b3e0cc / 4.0b8pre / 20101211030333 / files
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
releases
nightly linux32
nightly linux64
nightly mac
nightly win32
Bug 611798 - Do not pretent that we need the presshell to exist in order to turn off update view batching when the editor operations finish, because we don't; r=bzbarsky a=blocking-final+ This patch should fix all of the possible cases where a browser window stops painting when the presshell dies in the middle of an editor operation.
docshell/base/crashtests/432114-2.html
docshell/base/crashtests/crashtests.list
editor/libeditor/base/nsEditor.cpp
view/public/nsIViewManager.h
--- a/docshell/base/crashtests/432114-2.html
+++ b/docshell/base/crashtests/432114-2.html
@@ -1,9 +1,16 @@
-<html>
+<html class="reftest-wait">
 <head>
 <title>testcase2 Bug 432114  Crash [@ PL_DHashTableOperate] with DOMNodeInserted event listener removing window and frameset contenteditable</title>
 </head>
 <body>
+<script>
+  window.addEventListener("DOMNodeRemoved", function() {
+    setTimeout(function() {
+      document.documentElement.removeAttribute("class");
+    }, 0);
+  }, false);
+</script>
 <iframe id="content" src="data:application/xhtml+xml;charset=utf-8,%3Chtml%20xmlns%3D%22http%3A//www.w3.org/1999/xhtml%22%3E%0A%3Cframeset%20contenteditable%3D%22true%22/%3E%0A%3Cscript%3E%0Afunction%20doExecCommand%28%29%7B%0Adocument.execCommand%28%27insertParagraph%27%2C%20false%2C%20%27%27%29%3B%0A%7D%0AsetTimeout%28doExecCommand%2C100%29%3B%0Awindow.addEventListener%28%27DOMNodeRemoved%27%2C%20function%28%29%20%7Bwindow.frameElement.parentNode.removeChild%28window.frameElement%29%3B%7D%2C%20true%29%3B%0A%3C/script%3E%0A%3C/html%3E" style="width:1000px;height: 200px;"></iframe>
 
 </body>
 </html>
--- a/docshell/base/crashtests/crashtests.list
+++ b/docshell/base/crashtests/crashtests.list
@@ -1,11 +1,11 @@
 load 40929-1.html
 load 369126-1.html
 load 403574-1.xhtml
 load 430124-1.html
 load 430628-1.html
 asserts(1-4) load 432114-1.html # bug 570215
-asserts(0-2) load 432114-2.html # bug 570215, bug 571020
+asserts(1) load 432114-2.html # bug 570210
 load 436900-1.html
 asserts(0-2) load 436900-2.html # bug 566159
 load 500328-1.html
 load 514779-1.xhtml
--- a/editor/libeditor/base/nsEditor.cpp
+++ b/editor/libeditor/base/nsEditor.cpp
@@ -4207,30 +4207,24 @@ nsresult nsEditor::EndUpdateViewBatch()
 
     StCaretHider caretHider(caret);
 
     PRUint32 flags = 0;
 
     GetFlags(&flags);
 
     // Turn view updating back on.
-    nsCOMPtr<nsIViewManager> viewManager;
-    if (presShell)
-      viewManager = presShell->GetViewManager();
-    if (viewManager)
-    {
-      PRUint32 updateFlag = NS_VMREFRESH_IMMEDIATE;
-
-      // If we're doing async updates, use NS_VMREFRESH_DEFERRED here, so that
-      // the reflows we caused will get processed before the invalidates.
-      if (flags & nsIPlaintextEditor::eEditorUseAsyncUpdatesMask) {
-        updateFlag = NS_VMREFRESH_DEFERRED;
-      }
-      mBatch.EndUpdateViewBatch(updateFlag);
+    PRUint32 updateFlag = NS_VMREFRESH_IMMEDIATE;
+
+    // If we're doing async updates, use NS_VMREFRESH_DEFERRED here, so that
+    // the reflows we caused will get processed before the invalidates.
+    if (flags & nsIPlaintextEditor::eEditorUseAsyncUpdatesMask) {
+      updateFlag = NS_VMREFRESH_DEFERRED;
     }
+    mBatch.EndUpdateViewBatch(updateFlag);
 
     // Turn selection updating and notifications back on.
 
     nsCOMPtr<nsISelection>selection;
     GetSelection(getter_AddRefs(selection));
 
     if (selection) {
       nsCOMPtr<nsISelectionPrivate>selPrivate(do_QueryInterface(selection));
--- a/view/public/nsIViewManager.h
+++ b/view/public/nsIViewManager.h
@@ -273,17 +273,17 @@ public:
   NS_IMETHOD GetViewObserver(nsIViewObserver *&aObserver) = 0;
 
   /**
    * Get the device context associated with this manager
    * @result device context
    */
   NS_IMETHOD  GetDeviceContext(nsIDeviceContext *&aContext) = 0;
 
-  class NS_STACK_CLASS UpdateViewBatch {
+  class UpdateViewBatch {
   public:
     UpdateViewBatch() {}
   /**
    * prevents the view manager from refreshing. allows UpdateView()
    * to notify widgets of damaged regions that should be repainted
    * when the batch is ended. Call EndUpdateViewBatch on this object
    * before it is destroyed
    * @return error status