Bug 545593. Remove nsViewManager::Enable/DisableRefresh. r=roc
☠☠ backed out by 4e883e25a86c ☠ ☠
authorTimothy Nikkel <tnikkel@gmail.com>
Thu, 11 Feb 2010 18:14:59 -0600
changeset 38141 93c7b23284b828d28423bfcf0f9f8f59b6f625c6
parent 38140 2d0716b92bdbd4606db568d4f8ed71d7bd46304c
child 38142 20d2d6abd4a2e78f12d27ff3dfd2e18502d81530
child 38144 4e883e25a86ca9a2cf9d18294c04e25c2f1830e4
push idunknown
push userunknown
push dateunknown
reviewersroc
bugs545593
milestone1.9.3a2pre
Bug 545593. Remove nsViewManager::Enable/DisableRefresh. r=roc
content/base/src/nsContentSink.cpp
content/base/src/nsContentSink.h
content/html/document/src/nsMediaDocument.cpp
content/xul/document/src/nsXULDocument.cpp
docshell/base/nsDocShell.cpp
docshell/base/nsIContentViewer.idl
intl/chardet/src/nsDetectionAdaptor.cpp
intl/chardet/src/nsObserverBase.cpp
layout/base/nsDocumentViewer.cpp
parser/html/nsHtml5TreeOpExecutor.cpp
view/public/nsIViewManager.h
view/src/nsViewManager.cpp
view/src/nsViewManager.h
webshell/public/nsIWebShellServices.h
--- a/content/base/src/nsContentSink.cpp
+++ b/content/base/src/nsContentSink.cpp
@@ -1261,39 +1261,16 @@ nsContentSink::ScrollToRef()
         rv = shell->GoToAnchor(ref, mChangeScrollPosWhenScrollingToRef);
     }
     if (NS_SUCCEEDED(rv)) {
       mScrolledToRefAlready = PR_TRUE;
     }
   }
 }
 
-nsresult
-nsContentSink::RefreshIfEnabled(nsIViewManager* vm)
-{
-  if (!vm) {
-    // vm might be null if the shell got Destroy() called already
-    return NS_OK;
-  }
-
-  NS_ENSURE_TRUE(mDocShell, NS_ERROR_FAILURE);
-
-  nsCOMPtr<nsIContentViewer> contentViewer;
-  mDocShell->GetContentViewer(getter_AddRefs(contentViewer));
-  if (contentViewer) {
-    PRBool enabled;
-    contentViewer->GetEnableRendering(&enabled);
-    if (enabled) {
-      vm->EnableRefresh(NS_VMREFRESH_IMMEDIATE);
-    }
-  }
-
-  return NS_OK;
-}
-
 void
 nsContentSink::StartLayout(PRBool aIgnorePendingSheets)
 {
   if (mLayoutStarted) {
     // Nothing to do here
     return;
   }
   
@@ -1326,19 +1303,16 @@ nsContentSink::StartLayout(PRBool aIgnor
   // (Bug 153815)
   if (shell && !shell->DidInitialReflow()) {
     nsRect r = shell->GetPresContext()->GetVisibleArea();
     nsCOMPtr<nsIPresShell> shellGrip = shell;
     nsresult rv = shell->InitialReflow(r.width, r.height);
     if (NS_FAILED(rv)) {
       return;
     }
-
-    // Now trigger a refresh
-    RefreshIfEnabled(shell->GetViewManager());
   }
 
   // If the document we are loading has a reference or it is a
   // frameset document, disable the scroll bars on the views.
 
   if (mDocumentURI) {
     nsCAutoString ref;
 
--- a/content/base/src/nsContentSink.h
+++ b/content/base/src/nsContentSink.h
@@ -252,17 +252,16 @@ public:
   // Extracts the manifest attribute from the element if it is the root 
   // element and calls the above method.
   void ProcessOfflineManifest(nsIContent *aElement);
 
 protected:
   // Tries to scroll to the URI's named anchor. Once we've successfully
   // done that, further calls to this method will be ignored.
   void ScrollToRef();
-  nsresult RefreshIfEnabled(nsIViewManager* vm);
 
   // Start layout.  If aIgnorePendingSheets is true, this will happen even if
   // we still have stylesheet loads pending.  Otherwise, we'll wait until the
   // stylesheets are all done loading.
 public:
   void StartLayout(PRBool aIgnorePendingSheets);
 protected:
   void
--- a/content/html/document/src/nsMediaDocument.cpp
+++ b/content/html/document/src/nsMediaDocument.cpp
@@ -278,23 +278,16 @@ nsMediaDocument::StartLayout()
   mMayStartLayout = PR_TRUE;
   nsCOMPtr<nsIPresShell> shell = GetPrimaryShell();
   // Don't mess with the presshell if someone has already handled
   // its initial reflow.
   if (shell && !shell->DidInitialReflow()) {
     nsRect visibleArea = shell->GetPresContext()->GetVisibleArea();
     nsresult rv = shell->InitialReflow(visibleArea.width, visibleArea.height);
     NS_ENSURE_SUCCESS(rv, rv);
-
-    // Now trigger a refresh.  vm might be null if the presshell got
-    // Destroy() called already.
-    nsIViewManager* vm = shell->GetViewManager();
-    if (vm) {
-      vm->EnableRefresh(NS_VMREFRESH_IMMEDIATE);
-    }
   }
 
   return NS_OK;
 }
 
 void
 nsMediaDocument::GetFileName(nsAString& aResult)
 {
--- a/content/xul/document/src/nsXULDocument.cpp
+++ b/content/xul/document/src/nsXULDocument.cpp
@@ -2029,39 +2029,17 @@ nsXULDocument::StartLayout(void)
         if (! container)
             return NS_ERROR_UNEXPECTED;
 
         nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(container));
         NS_ASSERTION(docShell != nsnull, "container is not a docshell");
         if (! docShell)
             return NS_ERROR_UNEXPECTED;
 
-        // Trigger a refresh before the call to InitialReflow(),
-        // because the view manager's UpdateView() function is
-        // dropping dirty rects if refresh is disabled rather than
-        // accumulating them until refresh is enabled and then
-        // triggering a repaint...
-        // XXXbz Is that still the case?
         nsresult rv = NS_OK;
-        nsIViewManager* vm = shell->GetViewManager();
-        if (vm) {
-            nsCOMPtr<nsIContentViewer> contentViewer;
-            rv = docShell->GetContentViewer(getter_AddRefs(contentViewer));
-            if (NS_SUCCEEDED(rv) && (contentViewer != nsnull)) {
-                PRBool enabled;
-                contentViewer->GetEnableRendering(&enabled);
-                if (enabled) {
-                    vm->EnableRefresh(NS_VMREFRESH_IMMEDIATE);
-                }
-            }
-        }
-
-        // Don't try to call GetVisibleArea earlier than this --- the EnableRefresh call
-        // above can flush reflows, which can cause a parent document to be flushed,
-        // calling ResizeReflow on our document which does SetVisibleArea.
         nsRect r = cx->GetVisibleArea();
         rv = shell->InitialReflow(r.width, r.height);
         NS_ENSURE_SUCCESS(rv, rv);
     }
 
     return NS_OK;
 }
 
--- a/docshell/base/nsDocShell.cpp
+++ b/docshell/base/nsDocShell.cpp
@@ -11416,30 +11416,16 @@ nsDocShell::StopDocumentLoad(void)
     Stop(nsIWebNavigation::STOP_ALL);
     return NS_OK;
   }
   //return failer if this request is not accepted due to mCharsetReloadState
   return NS_ERROR_DOCSHELL_REQUEST_REJECTED;
 }
 
 NS_IMETHODIMP
-nsDocShell::SetRendering(PRBool aRender)
-{
-  if(eCharsetReloadRequested != mCharsetReloadState) 
-  {
-    if (mContentViewer) {
-       mContentViewer->SetEnableRendering(aRender);
-       return NS_OK;
-    }
-  }
-  //return failer if this request is not accepted due to mCharsetReloadState
-  return NS_ERROR_DOCSHELL_REQUEST_REJECTED;
-}
-
-NS_IMETHODIMP
 nsDocShell::GetPrintPreview(nsIWebBrowserPrint** aPrintPreview)
 {
   *aPrintPreview = nsnull;
 #if NS_PRINT_PREVIEW
   nsCOMPtr<nsIDocumentViewerPrint> print = do_QueryInterface(mContentViewer);
   if (!print || !print->IsInitializedForPrintPreview()) {
     Stop(nsIWebNavigation::STOP_ALL);
     nsCOMPtr<nsIPrincipal> principal =
--- a/docshell/base/nsIContentViewer.idl
+++ b/docshell/base/nsIContentViewer.idl
@@ -10,17 +10,17 @@ class nsIWidget;
 class nsIDocument;
 struct nsIntRect;
 %}
 
 [ptr] native nsIWidgetPtr(nsIWidget);
 [ptr] native nsIDocumentPtr(nsIDocument);
 [ref] native nsIntRectRef(nsIntRect);
 
-[scriptable, uuid(c824ac5e-3d86-4ae5-9ccc-9433bdc43004)]
+[scriptable, uuid(e2e5dd7d-8140-4fc5-b2c3-3a3b4f946fc7)]
 interface nsIContentViewer : nsISupports
 {
 
   [noscript] void init(in nsIWidgetPtr aParentWidget,
                        [const] in nsIntRectRef aBounds);
 
   attribute nsISupports container;
 
@@ -91,18 +91,16 @@ interface nsIContentViewer : nsISupports
    */
   [noscript] attribute nsIContentViewer previousViewer;
 
   void move(in long aX, in long aY);
 
   void show();
   void hide();
 
-  attribute boolean enableRendering;
-
   attribute boolean sticky;
 
   /*
    * This is called when the DOM window wants to be closed.  Returns true
    * if the window can close immediately.  Otherwise, returns false and will
    * close the DOM window as soon as practical.
    */
 
--- a/intl/chardet/src/nsDetectionAdaptor.cpp
+++ b/intl/chardet/src/nsDetectionAdaptor.cpp
@@ -57,17 +57,16 @@ NS_IMETHODIMP nsMyObserver::Notify(
       PRInt32 existingSource;
       mWeakRefParser->GetDocumentCharset(existingCharset, existingSource);  
       if (existingSource >= kCharsetFromAutoDetection) 
         return NS_OK;
     }
      
     if(!mCharset.Equals(aCharset)) {
       if(mNotifyByReload) {
-        rv = mWebShellSvc->SetRendering( PR_FALSE);
         rv = mWebShellSvc->StopDocumentLoad();
         rv = mWebShellSvc->ReloadDocument(aCharset, kCharsetFromAutoDetection);
       } else {
         nsDependentCString newcharset(aCharset);
         if (mWeakRefParser) {
           mWeakRefParser->SetDocumentCharset(newcharset, kCharsetFromAutoDetection);
           nsCOMPtr<nsIContentSink> contentSink = mWeakRefParser->GetContentSink();
           if (contentSink)
--- a/intl/chardet/src/nsObserverBase.cpp
+++ b/intl/chardet/src/nsObserverBase.cpp
@@ -30,18 +30,16 @@
  * 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 ***** */
 
-//#define DONT_INFORM_DOCSHELL
-
 #include "nsIServiceManager.h"
 #include "nsIWebShellServices.h"
 #include "nsObserverBase.h"
 #include "nsString.h"
 #include "nsIHttpChannel.h"
 
 
 
@@ -62,34 +60,26 @@ NS_IMETHODIMP nsObserverBase::NotifyDocS
      if (method.EqualsLiteral("POST")) { // XXX What about PUT, etc?
        return NS_OK;
      }
    }
 
    nsCOMPtr<nsIWebShellServices> wss;
    wss = do_QueryInterface(aDocShell,&res);
    if (NS_SUCCEEDED(res)) {
-
-#ifndef DONT_INFORM_DOCSHELL
      // ask the webshellservice to load the URL
-     if (NS_FAILED( res = wss->SetRendering(PR_FALSE) ))
-       rv = res;
-
-     // XXX nisheeth, uncomment the following two line to see the reent problem
-
-     else if (NS_FAILED(res = wss->StopDocumentLoad())){
-             rv = wss->SetRendering(PR_TRUE); // turn on the rendering so at least we will see something.
+     if (NS_FAILED(wss->StopDocumentLoad())){
+       // do nothing and fall through
      }
-     else if (NS_FAILED(res = wss->ReloadDocument(charset, source))) {
-             rv = wss->SetRendering(PR_TRUE); // turn on the rendering so at least we will see something.
+     else if (NS_FAILED(wss->ReloadDocument(charset, source))) {
+       // do nothing and fall through
      }
      else {
        rv = NS_ERROR_HTMLPARSER_STOPPARSING; // We're reloading a new document...stop loading the current.
      }
-#endif
    }
 
    //if our reload request is not accepted, we should tell parser to go on
   if (rv != NS_ERROR_HTMLPARSER_STOPPARSING) 
     rv = NS_ERROR_HTMLPARSER_CONTINUE;
 
   return rv;
 }
--- a/layout/base/nsDocumentViewer.cpp
+++ b/layout/base/nsDocumentViewer.cpp
@@ -380,21 +380,18 @@ private:
                         nsISupports *aState,
                         const nsIntRect& aBounds,
                         PRBool aDoCreation,
                         PRBool aInPrintPreview,
                         PRBool aNeedMakeCX = PR_TRUE);
   /**
    * @param aDoInitialReflow set to true if you want to kick off the initial
    * reflow
-   * @param aReenableRefresh set to true if you want this to reenable refresh
-   * before returning; otherwise this will return with refresh disabled
-   * in the view manager
    */
-  nsresult InitPresentationStuff(PRBool aDoInitialReflow, PRBool aReenableRefresh);
+  nsresult InitPresentationStuff(PRBool aDoInitialReflow);
 
   nsresult GetPopupNode(nsIDOMNode** aNode);
   nsresult GetPopupLinkNode(nsIDOMNode** aNode);
   nsresult GetPopupImageNode(nsIImageLoadingContent** aNode);
 
   void PrepareToStartLoad(void);
 
   nsresult SyncParentSubDocMap();
@@ -450,17 +447,16 @@ protected:
   // mTextZoom/mPageZoom record the textzoom/pagezoom of the first (galley)
   // presshell only.
   float mTextZoom;      // Text zoom, defaults to 1.0
   float mPageZoom;
 
   PRInt16 mNumURLStarts;
   PRInt16 mDestroyRefCount;    // a second "refcount" for the document viewer's "destroy"
 
-  unsigned      mEnableRendering : 1;
   unsigned      mStopped : 1;
   unsigned      mLoaded : 1;
   unsigned      mDeferredWindowClose : 1;
   // document management data
   //   these items are specific to markup documents (html and xml)
   //   may consider splitting these out into a subclass
   unsigned      mIsSticky : 1;
   unsigned      mInPermitUnload : 1;
@@ -492,16 +488,17 @@ protected:
   nsCString mHintCharset;
   nsCString mDefaultCharacterSet;
   nsCString mForceCharacterSet;
   nsCString mPrevDocCharacterSet;
   
   PRPackedBool mIsPageMode;
   PRPackedBool mCallerIsClosingWindow;
   PRPackedBool mInitializedForPrintPreview;
+  PRPackedBool mHidden;
 };
 
 //------------------------------------------------------------------
 // DocumentViewerImpl
 //------------------------------------------------------------------
 // Class IDs
 static NS_DEFINE_CID(kViewManagerCID,       NS_VIEW_MANAGER_CID);
 static NS_DEFINE_CID(kWidgetCID,            NS_CHILD_CID);
@@ -518,17 +515,16 @@ NS_NewDocumentViewer(nsIDocumentViewer**
 
   NS_ADDREF(*aResult);
 
   return NS_OK;
 }
 
 void DocumentViewerImpl::PrepareToStartLoad()
 {
-  mEnableRendering  = PR_TRUE;
   mStopped          = PR_FALSE;
   mLoaded           = PR_FALSE;
   mDeferredWindowClose = PR_FALSE;
   mCallerIsClosingWindow = PR_FALSE;
 
 #ifdef NS_PRINTING
   mPrintIsPending        = PR_FALSE;
   mPrintDocIsFullyLoaded = PR_FALSE;
@@ -553,17 +549,18 @@ void DocumentViewerImpl::PrepareToStartL
 // Note: operator new zeros our memory, so no need to init things to null.
 DocumentViewerImpl::DocumentViewerImpl()
   : mTextZoom(1.0), mPageZoom(1.0),
     mIsSticky(PR_TRUE),
 #ifdef NS_PRINT_PREVIEW
     mPrintPreviewZoom(1.0),
 #endif
     mHintCharsetSource(kCharsetUninitialized),
-    mInitializedForPrintPreview(PR_FALSE)
+    mInitializedForPrintPreview(PR_FALSE),
+    mHidden(PR_FALSE)
 {
   PrepareToStartLoad();
 }
 
 NS_IMPL_ADDREF(DocumentViewerImpl)
 NS_IMPL_RELEASE(DocumentViewerImpl)
 
 NS_INTERFACE_MAP_BEGIN(DocumentViewerImpl)
@@ -691,17 +688,17 @@ DocumentViewerImpl::GetContainer(nsISupp
 NS_IMETHODIMP
 DocumentViewerImpl::Init(nsIWidget* aParentWidget,
                          const nsIntRect& aBounds)
 {
   return InitInternal(aParentWidget, nsnull, aBounds, PR_TRUE, PR_FALSE);
 }
 
 nsresult
-DocumentViewerImpl::InitPresentationStuff(PRBool aDoInitialReflow, PRBool aReenableRefresh)
+DocumentViewerImpl::InitPresentationStuff(PRBool aDoInitialReflow)
 {
   if (GetIsPrintPreview())
     return NS_OK;
 
   NS_ASSERTION(!mPresShell,
                "Someone should have destroyed the presshell!");
 
   // Create the style set...
@@ -734,17 +731,16 @@ DocumentViewerImpl::InitPresentationStuf
   }
 
   mPresShell->BeginObservingDocument();
 
   // Initialize our view manager
   nscoord width = mPresContext->DeviceContext()->UnscaledAppUnitsPerDevPixel() * mBounds.width;
   nscoord height = mPresContext->DeviceContext()->UnscaledAppUnitsPerDevPixel() * mBounds.height;
 
-  mViewManager->DisableRefresh();
   mViewManager->SetWindowDimensions(width, height);
   mPresContext->SetTextZoom(mTextZoom);
   mPresContext->SetFullZoom(mPageZoom);
 
   if (aDoInitialReflow) {
     nsCOMPtr<nsIHTMLDocument> htmlDoc = do_QueryInterface(mDocument);
     if (htmlDoc) {
       nsCOMPtr<nsIDOMHTMLFrameSetElement> frameset =
@@ -756,21 +752,16 @@ DocumentViewerImpl::InitPresentationStuf
     // Initial reflow
     mPresShell->InitialReflow(width, height);
   } else {
     // Store the visible area so it's available for other callers of
     // InitialReflow, like nsContentSink::StartLayout.
     mPresContext->SetVisibleArea(nsRect(0, 0, width, height));
   }
 
-  // Now trigger a refresh
-  if (aReenableRefresh && mEnableRendering && mViewManager) {
-    mViewManager->EnableRefresh(NS_VMREFRESH_IMMEDIATE);
-  }
-
   // now register ourselves as a selection listener, so that we get
   // called when the selection changes in the window
   if (!mSelectionListener) {
     nsDocViewerSelectionListener *selectionListener =
       new nsDocViewerSelectionListener();
     NS_ENSURE_TRUE(selectionListener, NS_ERROR_OUT_OF_MEMORY);
 
     selectionListener->Init(this);
@@ -961,17 +952,17 @@ DocumentViewerImpl::InitInternal(nsIWidg
       }
     }
   }
 
   if (aDoCreation && mPresContext) {
     // The ViewManager and Root View was created above (in
     // MakeWindow())...
 
-    rv = InitPresentationStuff(!makeCX, !makeCX);
+    rv = InitPresentationStuff(!makeCX);
   }
 
   return rv;
 }
 
 //
 // LoadComplete(aStatus)
 //
@@ -1255,17 +1246,17 @@ DocumentViewerImpl::ResetCloseWindow()
     }
   }
   return NS_OK;
 }
 
 NS_IMETHODIMP
 DocumentViewerImpl::PageHide(PRBool aIsUnload)
 {
-  mEnableRendering = PR_FALSE;
+  mHidden = PR_TRUE;
 
   if (!mDocument) {
     return NS_ERROR_NULL_POINTER;
   }
 
   mDocument->OnPageHide(!aIsUnload, nsnull);
 
   // inform the window so that the focus state is reset.
@@ -1635,17 +1626,17 @@ DocumentViewerImpl::Destroy()
 NS_IMETHODIMP
 DocumentViewerImpl::Stop(void)
 {
   NS_ASSERTION(mDocument, "Stop called too early or too late");
   if (mDocument) {
     mDocument->StopDocumentLoad();
   }
 
-  if (mEnableRendering && (mLoaded || mStopped) && mPresContext && !mSHEntry)
+  if (!mHidden && (mLoaded || mStopped) && mPresContext && !mSHEntry)
     mPresContext->SetImageAnimationMode(imgIContainer::kDontAnimMode);
 
   mStopped = PR_TRUE;
 
   if (!mLoaded && mPresShell) {
     // Well, we might as well paint what we have so far.
     nsCOMPtr<nsIPresShell> shellDeathGrip(mPresShell); // bug 378682
     mPresShell->UnsuppressPainting();
@@ -1750,20 +1741,17 @@ DocumentViewerImpl::SetDOMDocument(nsIDO
 
   // And if we're already given a prescontext...
   if (mPresContext) {
     // If we had a linkHandler and it got removed, put it back.
     if (linkHandler) {
       mPresContext->SetLinkHandler(linkHandler);
     }
 
-    rv = InitPresentationStuff(PR_FALSE, PR_FALSE);
-    if (NS_SUCCEEDED(rv) && mEnableRendering && mViewManager) {
-      mViewManager->EnableRefresh(NS_VMREFRESH_IMMEDIATE);
-    }
+    rv = InitPresentationStuff(PR_FALSE);
   }
 
   return rv;
 }
 
 nsIPresShell*
 DocumentViewerImpl::GetPresShell()
 {
@@ -1980,18 +1968,17 @@ DocumentViewerImpl::Show(void)
       }
 
       mPresContext->SetContainer(base_win);
     }
 
     if (mPresContext) {
       Hide();
 
-      rv = InitPresentationStuff(mDocument->MayStartLayout(),
-                                 mDocument->MayStartLayout());
+      rv = InitPresentationStuff(mDocument->MayStartLayout());
     }
 
     // If we get here the document load has already started and the
     // window is shown because some JS on the page caused it to be
     // shown...
 
     if (mPresShell) {
       nsCOMPtr<nsIPresShell> shellDeathGrip(mPresShell); // bug 378682
@@ -2049,36 +2036,16 @@ DocumentViewerImpl::Hide(void)
   nsCOMPtr<nsIBaseWindow> base_win(do_QueryReferent(mContainer));
 
   if (base_win) {
     base_win->SetParentWidget(nsnull);
   }
 
   return NS_OK;
 }
-NS_IMETHODIMP
-DocumentViewerImpl::SetEnableRendering(PRBool aOn)
-{
-  NS_ENSURE_TRUE(mDocument, NS_ERROR_NOT_AVAILABLE);
-  mEnableRendering = aOn;
-  if (mViewManager) {
-    if (aOn) {
-      mViewManager->EnableRefresh(NS_VMREFRESH_IMMEDIATE);
-      nsIView* view;
-      mViewManager->GetRootView(view);   // views are not refCounted
-      if (view) {
-        mViewManager->UpdateView(view, NS_VMREFRESH_IMMEDIATE);
-      }
-    }
-    else {
-      mViewManager->DisableRefresh();
-    }
-  }
-  return NS_OK;
-}
 
 NS_IMETHODIMP
 DocumentViewerImpl::GetSticky(PRBool *aSticky)
 {
   *aSticky = mIsSticky;
 
   return NS_OK;
 }
@@ -2087,27 +2054,16 @@ NS_IMETHODIMP
 DocumentViewerImpl::SetSticky(PRBool aSticky)
 {
   mIsSticky = aSticky;
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
-DocumentViewerImpl::GetEnableRendering(PRBool* aResult)
-{
-  NS_ENSURE_TRUE(mDocument, NS_ERROR_NOT_AVAILABLE);
-  NS_PRECONDITION(nsnull != aResult, "null OUT ptr");
-  if (aResult) {
-    *aResult = mEnableRendering;
-  }
-  return NS_OK;
-}
-
-NS_IMETHODIMP
 DocumentViewerImpl::RequestWindowClose(PRBool* aCanClose)
 {
 #ifdef NS_PRINTING
   if (mPrintIsPending || (mPrintEngine && mPrintEngine->GetIsPrinting())) {
     *aCanClose = PR_FALSE;
     mDeferredWindowClose = PR_TRUE;
   } else
 #endif
@@ -4241,20 +4197,16 @@ DocumentViewerImpl::ReturnToGalleyPresen
   }
 
   SetIsPrintPreview(PR_FALSE);
 
   mPrintEngine->TurnScriptingOn(PR_TRUE);
   mPrintEngine->Destroy();
   mPrintEngine = nsnull;
 
-  if (mViewManager) {
-    mViewManager->EnableRefresh(NS_VMREFRESH_DEFERRED);
-  }
-
   nsCOMPtr<nsIDocShell> docShell(do_QueryReferent(mContainer));
   ResetFocusState(docShell);
 
   SetTextZoom(mTextZoom);
   SetFullZoom(mPageZoom);
   Show();
 
 #endif // NS_PRINTING && NS_PRINT_PREVIEW
@@ -4355,17 +4307,16 @@ NS_IMETHODIMP DocumentViewerImpl::SetPag
         nsPresContext::eContext_PageLayout, FindContainerView());
     NS_ENSURE_TRUE(mPresContext, NS_ERROR_OUT_OF_MEMORY);
     mPresContext->SetPaginatedScrolling(PR_TRUE);
     mPresContext->SetPrintSettings(aPrintSettings);
     nsresult rv = mPresContext->Init(mDeviceContext);
     NS_ENSURE_SUCCESS(rv, rv);
   }
   InitInternal(mParentWidget, nsnull, mBounds, PR_TRUE, PR_FALSE, PR_FALSE);
-  mViewManager->EnableRefresh(NS_VMREFRESH_NO_SYNC);
 
   Show();
   return NS_OK;
 }
 
 NS_IMETHODIMP
 DocumentViewerImpl::GetHistoryEntry(nsISHEntry **aHistoryEntry)
 {
--- a/parser/html/nsHtml5TreeOpExecutor.cpp
+++ b/parser/html/nsHtml5TreeOpExecutor.cpp
@@ -595,33 +595,27 @@ nsHtml5TreeOpExecutor::NeedsCharsetSwitc
 {
   EndDocUpdate();
 
   if(NS_UNLIKELY(!mParser)) {
     // got terminate
     return;
   }
   
-  nsresult rv = NS_OK;
   nsCOMPtr<nsIWebShellServices> wss = do_QueryInterface(mDocShell);
   if (!wss) {
     return;
   }
-#ifndef DONT_INFORM_WEBSHELL
+
   // ask the webshellservice to load the URL
-  if (NS_FAILED(rv = wss->SetRendering(PR_FALSE))) {
-    // do nothing and fall thru
-  } else if (NS_FAILED(rv = wss->StopDocumentLoad())) {
-    rv = wss->SetRendering(PR_TRUE); // turn on the rendering so at least we will see something.
-  } else if (NS_FAILED(rv = wss->ReloadDocument(aEncoding, kCharsetFromMetaTag))) {
-    rv = wss->SetRendering(PR_TRUE); // turn on the rendering so at least we will see something.
+  if (NS_SUCCEEDED(wss->StopDocumentLoad())) {
+    wss->ReloadDocument(aEncoding, kCharsetFromMetaTag);
   }
   // if the charset switch was accepted, wss has called Terminate() on the
   // parser by now
-#endif
 
   if (!mParser) {
     // success
     return;
   }
 
   (static_cast<nsHtml5Parser*> (mParser.get()))->ContinueAfterFailedCharsetSwitch();
 
--- a/view/public/nsIViewManager.h
+++ b/view/public/nsIViewManager.h
@@ -45,18 +45,18 @@
 
 class nsIWidget;
 struct nsRect;
 class nsRegion;
 class nsIDeviceContext;
 class nsIViewObserver;
 
 #define NS_IVIEWMANAGER_IID   \
-  { 0x6ca2fd1c, 0xa57e, 0x4802, \
-    { 0xad, 0x55, 0x85, 0xf6, 0x6f, 0x4a, 0x2c, 0x04 } }
+  { 0xbbdd429c, 0x6542, 0x477a, \
+    { 0xab, 0x48, 0x6c, 0xd6, 0xcb, 0xb8, 0xdf, 0x98 } }
 
 class nsIViewManager : public nsISupports
 {
 public:
 
   NS_DECLARE_STATIC_IID_ACCESSOR(NS_IVIEWMANAGER_IID)
   /**
    * Initialize the ViewManager
@@ -272,33 +272,16 @@ public:
   NS_IMETHOD GetViewObserver(nsIViewObserver *&aObserver) = 0;
 
   /**
    * Get the device context associated with this manager
    * @result device context
    */
   NS_IMETHOD  GetDeviceContext(nsIDeviceContext *&aContext) = 0;
 
-  /**
-   * prevent the view manager from refreshing.
-   * @return error status
-   */
-  // XXXbz callers of this function don't seem to realize that it disables
-  // refresh for the entire view manager hierarchy.... Maybe it shouldn't do
-  // that?
-  NS_IMETHOD DisableRefresh(void) = 0;
-
-  /**
-   * allow the view manager to refresh. this may cause a synchronous
-   * paint to occur inside the call.
-   * @param aUpdateFlags see bottom of nsIViewManager.h for description
-   * @return error status
-   */
-  NS_IMETHOD EnableRefresh(PRUint32 aUpdateFlags) = 0;
-
   class NS_STACK_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
--- a/view/src/nsViewManager.cpp
+++ b/view/src/nsViewManager.cpp
@@ -251,18 +251,16 @@ NS_IMETHODIMP nsViewManager::Init(nsIDev
   if (nsnull == aContext) {
     return NS_ERROR_NULL_POINTER;
   }
   if (nsnull != mContext) {
     return NS_ERROR_ALREADY_INITIALIZED;
   }
   mContext = aContext;
 
-  mRefreshEnabled = PR_TRUE;
-
   return NS_OK;
 }
 
 NS_IMETHODIMP_(nsIView *)
 nsViewManager::CreateView(const nsRect& aBounds,
                           const nsIView* aParent,
                           nsViewVisibility aVisibilityFlag)
 {
@@ -516,17 +514,17 @@ void nsViewManager::ProcessPendingUpdate
   for (nsView* childView = aView->GetFirstChild(); childView;
        childView = childView->GetNextSibling()) {
     ProcessPendingUpdates(childView, aDoInvalidate);
   }
 
   if (aDoInvalidate && aView->HasNonEmptyDirtyRegion()) {
     // Push out updates after we've processed the children; ensures that
     // damage is applied based on the final widget geometry
-    NS_ASSERTION(mRefreshEnabled, "Cannot process pending updates with refresh disabled");
+    NS_ASSERTION(IsRefreshEnabled(), "Cannot process pending updates with refresh disabled");
     nsRegion* dirtyRegion = aView->GetDirtyRegion();
     if (dirtyRegion) {
       nsView* nearestViewWithWidget = aView;
       while (!nearestViewWithWidget->HasWidget() &&
              nearestViewWithWidget->GetParent()) {
         nearestViewWithWidget =
           static_cast<nsView*>(nearestViewWithWidget->GetParent());
       }
@@ -1594,100 +1592,78 @@ nsViewManager::CreateRenderingContext(ns
                    "ViewToWidgetOffset not handled!");
       if (nsnull != cx)
         cx->Translate(ax, ay);
     }
 
   return cx;
 }
 
-NS_IMETHODIMP nsViewManager::DisableRefresh(void)
+void nsViewManager::TriggerRefresh(PRUint32 aUpdateFlags)
 {
   if (!IsRootVM()) {
-    return RootViewManager()->DisableRefresh();
+    RootViewManager()->TriggerRefresh(aUpdateFlags);
+    return;
   }
   
   if (mUpdateBatchCnt > 0)
-    return NS_OK;
-
-  mRefreshEnabled = PR_FALSE;
-  return NS_OK;
-}
-
-NS_IMETHODIMP nsViewManager::EnableRefresh(PRUint32 aUpdateFlags)
-{
-  if (!IsRootVM()) {
-    return RootViewManager()->EnableRefresh(aUpdateFlags);
-  }
-  
-  if (mUpdateBatchCnt > 0)
-    return NS_OK;
-
-  mRefreshEnabled = PR_TRUE;
+    return;
 
   // nested batching can combine IMMEDIATE with DEFERRED. Favour
   // IMMEDIATE over DEFERRED and DEFERRED over NO_SYNC.  We need to
   // check for IMMEDIATE before checking mHasPendingUpdates, because
   // the latter might be false as far as gecko is concerned but the OS
   // might still have queued up expose events that it hasn't sent yet.
   if (aUpdateFlags & NS_VMREFRESH_IMMEDIATE) {
     FlushPendingInvalidates();
     Composite();
   } else if (!mHasPendingUpdates) {
     // Nothing to do
   } else if (aUpdateFlags & NS_VMREFRESH_DEFERRED) {
     PostInvalidateEvent();
   } else { // NO_SYNC
     FlushPendingInvalidates();
   }
-
-  return NS_OK;
 }
 
 nsIViewManager* nsViewManager::BeginUpdateViewBatch(void)
 {
   if (!IsRootVM()) {
     return RootViewManager()->BeginUpdateViewBatch();
   }
   
-  nsresult result = NS_OK;
-  
   if (mUpdateBatchCnt == 0) {
     mUpdateBatchFlags = 0;
-    result = DisableRefresh();
   }
 
-  if (NS_SUCCEEDED(result))
-    ++mUpdateBatchCnt;
+  ++mUpdateBatchCnt;
 
   return this;
 }
 
 NS_IMETHODIMP nsViewManager::EndUpdateViewBatch(PRUint32 aUpdateFlags)
 {
   NS_ASSERTION(IsRootVM(), "Should only be called on root");
   
-  nsresult result = NS_OK;
-
   --mUpdateBatchCnt;
 
   NS_ASSERTION(mUpdateBatchCnt >= 0, "Invalid batch count!");
 
   if (mUpdateBatchCnt < 0)
     {
       mUpdateBatchCnt = 0;
       return NS_ERROR_FAILURE;
     }
 
   mUpdateBatchFlags |= aUpdateFlags;
   if (mUpdateBatchCnt == 0) {
-    result = EnableRefresh(mUpdateBatchFlags);
+    TriggerRefresh(mUpdateBatchFlags);
   }
 
-  return result;
+  return NS_OK;
 }
 
 NS_IMETHODIMP nsViewManager::GetRootWidget(nsIWidget **aWidget)
 {
   if (!mRootView) {
     *aWidget = nsnull;
     return NS_OK;
   }
@@ -1761,27 +1737,19 @@ nsViewManager::FlushPendingInvalidates()
 
   // Make sure to not send WillPaint notifications while scrolling
   if (mScrollCnt == 0) {
     // Disable refresh while we notify our view observers, so that if they do
     // view update batches we don't reenter this code and so that we batch
     // all of them together.  We don't use
     // BeginUpdateViewBatch/EndUpdateViewBatch, since that would reenter this
     // exact code, but we want the effect of a single big update batch.
-    PRBool refreshEnabled = mRefreshEnabled;
-    mRefreshEnabled = PR_FALSE;
     ++mUpdateBatchCnt;
     CallWillPaintOnObservers();
     --mUpdateBatchCnt;
-
-    // Someone could have called EnableRefresh on us from inside WillPaint().
-    // Only reset the old mRefreshEnabled value if the current value is false.
-    if (!mRefreshEnabled) {
-      mRefreshEnabled = refreshEnabled;
-    }
   }
   
   if (mHasPendingUpdates) {
     ProcessPendingUpdates(mRootView, PR_TRUE);
     mHasPendingUpdates = PR_FALSE;
   }
 }
 
--- a/view/src/nsViewManager.h
+++ b/view/src/nsViewManager.h
@@ -144,19 +144,16 @@ public:
 
   NS_IMETHOD  SetViewZIndex(nsIView *aView, PRBool aAuto, PRInt32 aZIndex, PRBool aTopMost=PR_FALSE);
 
   NS_IMETHOD  SetViewObserver(nsIViewObserver *aObserver);
   NS_IMETHOD  GetViewObserver(nsIViewObserver *&aObserver);
 
   NS_IMETHOD  GetDeviceContext(nsIDeviceContext *&aContext);
 
-  NS_IMETHOD  DisableRefresh(void);
-  NS_IMETHOD  EnableRefresh(PRUint32 aUpdateFlags);
-
   virtual nsIViewManager* BeginUpdateViewBatch(void);
   NS_IMETHOD  EndUpdateViewBatch(PRUint32 aUpdateFlags);
 
   NS_IMETHOD GetRootWidget(nsIWidget **aWidget);
   NS_IMETHOD ForceUpdate();
  
   NS_IMETHOD IsPainting(PRBool& aIsPainting);
   NS_IMETHOD GetLastUserEventTime(PRUint32& aTime);
@@ -184,16 +181,18 @@ private:
   void ReparentWidgets(nsIView* aView, nsIView *aParent);
   already_AddRefed<nsIRenderingContext> CreateRenderingContext(nsView &aView);
   void UpdateWidgetArea(nsView *aWidgetView, nsIWidget* aWidget,
                         const nsRegion &aDamagedRegion,
                         nsView* aIgnoreWidgetView);
 
   void UpdateViews(nsView *aView, PRUint32 aUpdateFlags);
 
+  void TriggerRefresh(PRUint32 aUpdateFlags);
+
   void Refresh(nsView *aView, nsIRenderingContext *aContext,
                nsIRegion *region, PRUint32 aUpdateFlags);
   void RenderViews(nsView *aRootView, nsIRenderingContext& aRC,
                    const nsRegion& aRegion);
 
   void InvalidateRectDifference(nsView *aView, const nsRect& aRect, const nsRect& aCutOut, PRUint32 aUpdateFlags);
   void InvalidateHorizontalBandDifference(nsView *aView, const nsRect& aRect, const nsRect& aCutOut,
                                           PRUint32 aUpdateFlags, nscoord aY1, nscoord aY2, PRBool aInCutOut);
@@ -271,17 +270,17 @@ public: // NOT in nsIViewManager, so pri
 
   virtual nsresult WillBitBlit(nsIView* aView, const nsRect& aRect,
                                nsPoint aScrollAmount);
   virtual void UpdateViewAfterScroll(nsIView *aView,
                                      const nsRegion& aUpdateRegion);
 
   nsresult CreateRegion(nsIRegion* *result);
 
-  PRBool IsRefreshEnabled() { return RootViewManager()->mRefreshEnabled; }
+  PRBool IsRefreshEnabled() { return RootViewManager()->mUpdateBatchCnt == 0; }
 
   nsIViewObserver* GetViewObserver() { return mObserver; }
 
   // Call this when you need to let the viewmanager know that it now has
   // pending updates.
   void PostPendingUpdate() { RootViewManager()->mHasPendingUpdates = PR_TRUE; }
 private:
   nsCOMPtr<nsIDeviceContext> mContext;
@@ -306,18 +305,16 @@ private:
   // this, as noted.
   
   // Use IncrementUpdateCount(), DecrementUpdateCount(), UpdateCount(),
   // ClearUpdateCount() on the root viewmanager to access mUpdateCnt.
   PRInt32           mUpdateCnt;
   PRInt32           mUpdateBatchCnt;
   PRUint32          mUpdateBatchFlags;
   PRInt32           mScrollCnt;
-  // Use IsRefreshEnabled() to check the value of mRefreshEnabled.
-  PRPackedBool      mRefreshEnabled;
   // Use IsPainting() and SetPainting() to access mPainting.
   PRPackedBool      mPainting;
   PRPackedBool      mRecursiveRefreshPending;
   PRPackedBool      mHasPendingUpdates;
   PRPackedBool      mInScroll;
 
   //from here to public should be static and locked... MMP
   static PRInt32           mVMCount;        //number of viewmanagers
--- a/webshell/public/nsIWebShellServices.h
+++ b/webshell/public/nsIWebShellServices.h
@@ -37,34 +37,31 @@
 #ifndef nsIWebShellServices_h___
 #define nsIWebShellServices_h___
 
 #include "nsISupports.h"
 #include "nsIParser.h"
 
 // Interface ID for nsIWebShellServices
 
-/* 8b26a346-031e-11d3-aeea-00108300ff91 */
+/* 0c628af0-5638-4703-8f99-ed6134c9de18 */
 #define NS_IWEB_SHELL_SERVICES_IID \
-{ 0x8b26a346, 0x031e, 0x11d3, {0xae, 0xea, 0x00, 0x10, 0x83, 0x00, 0xff, 0x91} }
-
+{ 0x0c628af0, 0x5638, 0x4703, {0x8f, 0x99, 0xed, 0x61, 0x34, 0xc9, 0xde, 0x18} }
 
 //----------------------------------------------------------------------
 
 class nsIWebShellServices : public nsISupports {
 public:
   NS_DECLARE_STATIC_IID_ACCESSOR(NS_IWEB_SHELL_SERVICES_IID)
 
   NS_IMETHOD ReloadDocument(const char* aCharset = nsnull , 
                             PRInt32 aSource = kCharsetUninitialized) = 0;
   NS_IMETHOD StopDocumentLoad(void) = 0;
-  NS_IMETHOD SetRendering(PRBool aRender) = 0;
 };
 
 NS_DEFINE_STATIC_IID_ACCESSOR(nsIWebShellServices, NS_IWEB_SHELL_SERVICES_IID)
 
 /* Use this macro when declaring classes that implement this interface. */
 #define NS_DECL_NSIWEBSHELLSERVICES \
   NS_IMETHOD ReloadDocument(const char *aCharset=nsnull, PRInt32 aSource=kCharsetUninitialized); \
   NS_IMETHOD StopDocumentLoad(void); \
-  NS_IMETHOD SetRendering(PRBool aRender); 
 
 #endif /* nsIWebShellServices_h___ */