From c3d6f78b1892e58bff31b4dbd46724994c7c1ede Mon Sep 17 00:00:00 2001 From: "bryner%netscape.com" Date: Wed, 31 Oct 2001 05:06:31 +0000 Subject: [PATCH] When creating the root view's widget, don't show it. This prevents full-page Invalidates during page load caused by showing and then hiding the widget. Bug 97895, r=blizzard, sr=hyatt. --- content/base/src/nsDocumentViewer.cpp | 14 +++----------- docshell/base/nsIContentViewer.idl | 1 - layout/base/nsDocumentViewer.cpp | 14 +++----------- modules/plugin/base/src/nsPluginViewer.cpp | 8 -------- view/public/nsIView.h | 3 ++- view/src/nsView.cpp | 13 ++++++++----- view/src/nsView.h | 3 ++- view/src/nsViewManager.cpp | 3 ++- widget/src/gtk/nsWidget.cpp | 6 ++++++ widget/src/gtk/nsWidget.h | 1 + widget/src/gtk/nsWindow.cpp | 11 +++++++++-- widget/src/gtk/nsWindow.h | 3 +-- 12 files changed, 37 insertions(+), 43 deletions(-) diff --git a/content/base/src/nsDocumentViewer.cpp b/content/base/src/nsDocumentViewer.cpp index a397c6541e2..9479aded0a1 100644 --- a/content/base/src/nsDocumentViewer.cpp +++ b/content/base/src/nsDocumentViewer.cpp @@ -1391,7 +1391,6 @@ DocumentViewerImpl::SetPreviousViewer(nsIContentViewer* aViewer) // link from the chain. This ensures that at most only 2 documents are alive // and undestroyed at any given time (the one that is showing and the one that // is loading with painting suppressed). - aViewer->Validate(); nsCOMPtr prevViewer; aViewer->GetPreviousViewer(getter_AddRefs(prevViewer)); if (prevViewer) { @@ -1463,15 +1462,6 @@ DocumentViewerImpl::Hide(void) return NS_OK; } -NS_IMETHODIMP -DocumentViewerImpl::Validate(void) -{ - NS_PRECONDITION(mWindow, "null window"); - if (mWindow) - mWindow->Validate(); - return NS_OK; -} - nsresult DocumentViewerImpl::FindFrameSetWithIID(nsIContent * aParentContent, const nsIID& aIID) { @@ -3827,7 +3817,9 @@ DocumentViewerImpl::MakeWindow(nsIWidget* aParentWidget, if (NS_FAILED(rv)) return rv; - rv = mView->CreateWidget(kWidgetCID, nsnull, aParentWidget->GetNativeData(NS_NATIVE_WIDGET)); + rv = mView->CreateWidget(kWidgetCID, nsnull, + aParentWidget->GetNativeData(NS_NATIVE_WIDGET), + PR_TRUE, PR_FALSE); if (rv != NS_OK) return rv; diff --git a/docshell/base/nsIContentViewer.idl b/docshell/base/nsIContentViewer.idl index f6d85a30568..98dbf307562 100644 --- a/docshell/base/nsIContentViewer.idl +++ b/docshell/base/nsIContentViewer.idl @@ -55,7 +55,6 @@ interface nsIContentViewer : nsISupports void show(); void hide(); - void validate(); attribute boolean enableRendering; }; diff --git a/layout/base/nsDocumentViewer.cpp b/layout/base/nsDocumentViewer.cpp index a397c6541e2..9479aded0a1 100644 --- a/layout/base/nsDocumentViewer.cpp +++ b/layout/base/nsDocumentViewer.cpp @@ -1391,7 +1391,6 @@ DocumentViewerImpl::SetPreviousViewer(nsIContentViewer* aViewer) // link from the chain. This ensures that at most only 2 documents are alive // and undestroyed at any given time (the one that is showing and the one that // is loading with painting suppressed). - aViewer->Validate(); nsCOMPtr prevViewer; aViewer->GetPreviousViewer(getter_AddRefs(prevViewer)); if (prevViewer) { @@ -1463,15 +1462,6 @@ DocumentViewerImpl::Hide(void) return NS_OK; } -NS_IMETHODIMP -DocumentViewerImpl::Validate(void) -{ - NS_PRECONDITION(mWindow, "null window"); - if (mWindow) - mWindow->Validate(); - return NS_OK; -} - nsresult DocumentViewerImpl::FindFrameSetWithIID(nsIContent * aParentContent, const nsIID& aIID) { @@ -3827,7 +3817,9 @@ DocumentViewerImpl::MakeWindow(nsIWidget* aParentWidget, if (NS_FAILED(rv)) return rv; - rv = mView->CreateWidget(kWidgetCID, nsnull, aParentWidget->GetNativeData(NS_NATIVE_WIDGET)); + rv = mView->CreateWidget(kWidgetCID, nsnull, + aParentWidget->GetNativeData(NS_NATIVE_WIDGET), + PR_TRUE, PR_FALSE); if (rv != NS_OK) return rv; diff --git a/modules/plugin/base/src/nsPluginViewer.cpp b/modules/plugin/base/src/nsPluginViewer.cpp index 48720dc4219..c9669fee866 100644 --- a/modules/plugin/base/src/nsPluginViewer.cpp +++ b/modules/plugin/base/src/nsPluginViewer.cpp @@ -577,14 +577,6 @@ PluginViewerImpl::SetPreviousViewer(nsIContentViewer* aViewer) return NS_OK; } -NS_IMETHODIMP -PluginViewerImpl::Validate() -{ - if (mWindow) - mWindow->Validate(); - return NS_OK; -} - NS_IMETHODIMP PluginViewerImpl::SetBounds(const nsRect& aBounds) { diff --git a/view/public/nsIView.h b/view/public/nsIView.h index 2385dc5731d..4e04263678e 100644 --- a/view/public/nsIView.h +++ b/view/public/nsIView.h @@ -434,7 +434,8 @@ public: NS_IMETHOD CreateWidget(const nsIID &aWindowIID, nsWidgetInitData *aWidgetInitData = nsnull, nsNativeWidget aNative = nsnull, - PRBool aEnableDragDrop = PR_TRUE) = 0; + PRBool aEnableDragDrop = PR_TRUE, + PRBool aResetVisibility = PR_TRUE) = 0; /** * Set the widget associated with this view. diff --git a/view/src/nsView.cpp b/view/src/nsView.cpp index 5b3b2852954..8c21fd1f6c5 100644 --- a/view/src/nsView.cpp +++ b/view/src/nsView.cpp @@ -942,7 +942,8 @@ NS_IMETHODIMP nsView :: GetClientData(void *&aData) const NS_IMETHODIMP nsView :: CreateWidget(const nsIID &aWindowIID, nsWidgetInitData *aWidgetInitData, nsNativeWidget aNative, - PRBool aEnableDragDrop) + PRBool aEnableDragDrop, + PRBool aResetVisibility) { nsIDeviceContext *dx; nsRect trect = mBounds; @@ -983,10 +984,12 @@ NS_IMETHODIMP nsView :: CreateWidget(const nsIID &aWindowIID, //make sure visibility state is accurate - nsViewVisibility vis; - - GetVisibility(vis); - SetVisibility(vis); + if (aResetVisibility) { + nsViewVisibility vis; + + GetVisibility(vis); + SetVisibility(vis); + } NS_RELEASE(dx); diff --git a/view/src/nsView.h b/view/src/nsView.h index 608fa34e9f2..85918f9e9e0 100644 --- a/view/src/nsView.h +++ b/view/src/nsView.h @@ -115,7 +115,8 @@ public: NS_IMETHOD CreateWidget(const nsIID &aWindowIID, nsWidgetInitData *aWidgetInitData = nsnull, nsNativeWidget aNative = nsnull, - PRBool aEnableDragDrop = PR_TRUE); + PRBool aEnableDragDrop = PR_TRUE, + PRBool aResetVisibility = PR_TRUE); NS_IMETHOD SetWidget(nsIWidget *aWidget); NS_IMETHOD GetWidget(nsIWidget *&aWidget) const; NS_IMETHOD HasWidget(PRBool *aHasWidget) const; diff --git a/view/src/nsViewManager.cpp b/view/src/nsViewManager.cpp index 17e7023aeb9..c467eee86ab 100644 --- a/view/src/nsViewManager.cpp +++ b/view/src/nsViewManager.cpp @@ -405,7 +405,8 @@ public: NS_IMETHOD CreateWidget(const nsIID &aWindowIID, nsWidgetInitData *aWidgetInitData = nsnull, nsNativeWidget aNative = nsnull, - PRBool aEnableDragDrop = PR_TRUE) + PRBool aEnableDragDrop = PR_TRUE, + PRBool aResetVisibility = PR_TRUE) { NS_ASSERTION(PR_FALSE, "Unimplemented"); return NS_ERROR_NOT_IMPLEMENTED; } NS_IMETHOD SetWidget(nsIWidget *aWidget) { return NS_OK; } diff --git a/widget/src/gtk/nsWidget.cpp b/widget/src/gtk/nsWidget.cpp index f8c01544038..8df7887efca 100644 --- a/widget/src/gtk/nsWidget.cpp +++ b/widget/src/gtk/nsWidget.cpp @@ -870,6 +870,12 @@ NS_IMETHODIMP nsWidget::SetCursor(nsCursor aCursor) #define CAPS_LOCK_IS_ON \ (nsWidget::sDebugFeedback && (nsGtkUtils::gdk_keyboard_get_modifiers() & GDK_LOCK_MASK)) +NS_IMETHODIMP nsWidget::Validate() +{ + mUpdateArea->SetTo(0, 0, 0, 0); + return NS_OK; +} + NS_IMETHODIMP nsWidget::Invalidate(PRBool aIsSynchronous) { if (!mWidget) diff --git a/widget/src/gtk/nsWidget.h b/widget/src/gtk/nsWidget.h index afa26587c4a..e5d4f83ea36 100644 --- a/widget/src/gtk/nsWidget.h +++ b/widget/src/gtk/nsWidget.h @@ -162,6 +162,7 @@ public: NS_IMETHOD CaptureMouse(PRBool aCapture) { return NS_ERROR_FAILURE; } + NS_IMETHOD Validate(); NS_IMETHOD Invalidate(PRBool aIsSynchronous); NS_IMETHOD Invalidate(const nsRect &aRect, PRBool aIsSynchronous); NS_IMETHOD InvalidateRegion(const nsIRegion *aRegion, PRBool aIsSynchronous); diff --git a/widget/src/gtk/nsWindow.cpp b/widget/src/gtk/nsWindow.cpp index c6a53a5da7a..74cf7425aa6 100644 --- a/widget/src/gtk/nsWindow.cpp +++ b/widget/src/gtk/nsWindow.cpp @@ -182,8 +182,6 @@ nsWindow::nsWindow() { mShell = nsnull; mResized = PR_FALSE; - mVisible = PR_FALSE; - mDisplayed = PR_FALSE; mLowerLeft = PR_FALSE; mWindowType = eWindowType_child; mBorderStyle = eBorderStyle_default; @@ -965,6 +963,15 @@ void nsWindow::NativeGrab(PRBool aGrab) } } +NS_IMETHODIMP nsWindow::Validate() +{ + if (mIsUpdating) { + mUpdateArea->SetTo(0, 0, 0, 0); + UnqueueDraw(); + } + return NS_OK; +} + NS_IMETHODIMP nsWindow::Invalidate(PRBool aIsSynchronous) { diff --git a/widget/src/gtk/nsWindow.h b/widget/src/gtk/nsWindow.h index 43d43b4151c..831078edaf6 100644 --- a/widget/src/gtk/nsWindow.h +++ b/widget/src/gtk/nsWindow.h @@ -101,6 +101,7 @@ public: NS_IMETHOD CaptureRollupEvents(nsIRollupListener * aListener, PRBool aDoCapture, PRBool aConsumeRollupEvent); + NS_IMETHOD Validate(); NS_IMETHOD Invalidate(PRBool aIsSynchronous); NS_IMETHOD Invalidate(const nsRect &aRect, PRBool aIsSynchronous); NS_IMETHOD InvalidateRegion(const nsIRegion* aRegion, PRBool aIsSynchronous); @@ -209,8 +210,6 @@ protected: virtual void InitCallbacks(char * aName = nsnull); NS_IMETHOD CreateNative(GtkObject *parentWidget); - PRBool mVisible; - PRBool mDisplayed; PRBool mIsTooSmall; // Resize event management