From 82f45610bf3f27d2235a56051d3bb4421efc1926 Mon Sep 17 00:00:00 2001 From: "rjesup%wgate.com" Date: Fri, 6 Sep 2002 18:46:19 +0000 Subject: [PATCH] Bug 126346: make iframes inherit text zoom values. Re-commiting after mods to deal with 1.5% Tp regression in last commit. r=dbaron, sr=jst, a=roc+moz --- content/base/src/nsDocumentViewer.cpp | 7 ++ docshell/base/nsDocShell.cpp | 126 +++++++++++--------------- layout/base/nsDocumentViewer.cpp | 7 ++ 3 files changed, 67 insertions(+), 73 deletions(-) diff --git a/content/base/src/nsDocumentViewer.cpp b/content/base/src/nsDocumentViewer.cpp index f68b351c4b3..1ab2f0efc63 100644 --- a/content/base/src/nsDocumentViewer.cpp +++ b/content/base/src/nsDocumentViewer.cpp @@ -2290,7 +2290,14 @@ SetChildTextZoom(nsIMarkupDocumentViewer* aChild, void* aClosure) NS_IMETHODIMP DocumentViewerImpl::SetTextZoom(float aTextZoom) { if (mDeviceContext) { + float oldTextZoom + // Don't reflow or bubble down if there's no change in the textZoom. + // Not having this check caused the Tp regression from bug 126346 + mDeviceContext->GetTextZoom(&oldTextZoom); mDeviceContext->SetTextZoom(aTextZoom); + if (oldTextZoom == aTextZoom) + return NS_OK; + if (mPresContext) { mPresContext->ClearStyleDataAndReflow(); } diff --git a/docshell/base/nsDocShell.cpp b/docshell/base/nsDocShell.cpp index f93c5a94cb9..d2fb0366f8c 100644 --- a/docshell/base/nsDocShell.cpp +++ b/docshell/base/nsDocShell.cpp @@ -207,6 +207,7 @@ nsDocShell::nsDocShell(): mAllowImages(PR_TRUE), mFocusDocFirst(PR_FALSE), mCreatingDocument(PR_FALSE), + mUseErrorPages(PR_FALSE), mAppType(nsIDocShell::APP_TYPE_UNKNOWN), mBusyFlags(BUSY_FLAGS_NONE), mFiredUnloadEvent(PR_FALSE), @@ -215,7 +216,6 @@ nsDocShell::nsDocShell(): mUseExternalProtocolHandler(PR_FALSE), mDisallowPopupWindows(PR_FALSE), mIsBeingDestroyed(PR_FALSE), - mUseErrorPages(PR_FALSE), mParent(nsnull), mTreeOwner(nsnull), mChromeEventHandler(nsnull) @@ -1984,41 +1984,7 @@ nsDocShell::AddChild(nsIDocShellTreeItem * aChild) if (!childAsDocShell) return NS_OK; - // Do some docShell Specific stuff. - nsXPIDLString defaultCharset; - nsXPIDLString forceCharset; - float textZoom = 1.0; - NS_ENSURE_TRUE(mContentViewer, NS_ERROR_FAILURE); - - nsCOMPtr muDV = - do_QueryInterface(mContentViewer); - if (muDV) { - NS_ENSURE_SUCCESS(muDV-> - GetDefaultCharacterSet(getter_Copies(defaultCharset)), - NS_ERROR_FAILURE); - NS_ENSURE_SUCCESS(muDV-> - GetForceCharacterSet(getter_Copies(forceCharset)), - NS_ERROR_FAILURE); - NS_ENSURE_SUCCESS(muDV-> - GetTextZoom(&textZoom), - NS_ERROR_FAILURE); - } - nsCOMPtr childCV; - NS_ENSURE_SUCCESS(childAsDocShell-> - GetContentViewer(getter_AddRefs(childCV)), - NS_ERROR_FAILURE); - if (childCV) { - nsCOMPtr childmuDV = - do_QueryInterface(childCV); - if (childmuDV) { - NS_ENSURE_SUCCESS(childmuDV->SetDefaultCharacterSet(defaultCharset), - NS_ERROR_FAILURE); - NS_ENSURE_SUCCESS(childmuDV->SetForceCharacterSet(forceCharset), - NS_ERROR_FAILURE); - NS_ENSURE_SUCCESS(childmuDV->SetTextZoom(textZoom), - NS_ERROR_FAILURE); - } - } + // charset and zoom will be inherited in SetupNewViewer() // Now take this document's charset and set the parentCharset field of the // child's DocumentCharsetInfo to it. We'll later use that field, in the @@ -4422,6 +4388,15 @@ nsDocShell::SetupNewViewer(nsIContentViewer * aNewViewer) NS_ERROR_FAILURE); nsCOMPtr parent(do_QueryInterface(parentAsItem)); + nsXPIDLString defaultCharset; + nsXPIDLString forceCharset; + nsXPIDLString hintCharset; + PRInt32 hintCharsetSource; + nsXPIDLString prevDocCharset; + float textZoom; + // |newMUDV| also serves as a flag to set the data from the above vars + nsCOMPtr newMUDV; + if (mContentViewer || parent) { nsCOMPtr oldMUDV; if (mContentViewer) { @@ -4437,44 +4412,31 @@ nsDocShell::SetupNewViewer(nsIContentViewer * aNewViewer) oldMUDV = do_QueryInterface(parentContentViewer); } - nsXPIDLString defaultCharset; - nsXPIDLString forceCharset; - nsXPIDLString hintCharset; - PRInt32 hintCharsetSource; - nsXPIDLString prevDocCharset; + if (oldMUDV) { + nsresult rv; - nsCOMPtr - newMUDV(do_QueryInterface(aNewViewer)); - if (oldMUDV && newMUDV) { - NS_ENSURE_SUCCESS(oldMUDV-> - GetDefaultCharacterSet(getter_Copies - (defaultCharset)), - NS_ERROR_FAILURE); - NS_ENSURE_SUCCESS(oldMUDV-> - GetForceCharacterSet(getter_Copies(forceCharset)), - NS_ERROR_FAILURE); - NS_ENSURE_SUCCESS(oldMUDV-> - GetHintCharacterSet(getter_Copies(hintCharset)), - NS_ERROR_FAILURE); - NS_ENSURE_SUCCESS(oldMUDV-> - GetHintCharacterSetSource(&hintCharsetSource), - NS_ERROR_FAILURE); - NS_ENSURE_SUCCESS(oldMUDV-> - GetPrevDocCharacterSet(getter_Copies(prevDocCharset)), - NS_ERROR_FAILURE); - - // set the old state onto the new content viewer - NS_ENSURE_SUCCESS(newMUDV->SetDefaultCharacterSet(defaultCharset), - NS_ERROR_FAILURE); - NS_ENSURE_SUCCESS(newMUDV->SetForceCharacterSet(forceCharset), - NS_ERROR_FAILURE); - NS_ENSURE_SUCCESS(newMUDV->SetHintCharacterSet(hintCharset), - NS_ERROR_FAILURE); - NS_ENSURE_SUCCESS(newMUDV-> - SetHintCharacterSetSource(hintCharsetSource), - NS_ERROR_FAILURE); - NS_ENSURE_SUCCESS(newMUDV->SetPrevDocCharacterSet(prevDocCharset), - NS_ERROR_FAILURE); + newMUDV = do_QueryInterface(aNewViewer,&rv); + if (newMUDV) { + NS_ENSURE_SUCCESS(oldMUDV-> + GetDefaultCharacterSet(getter_Copies + (defaultCharset)), + NS_ERROR_FAILURE); + NS_ENSURE_SUCCESS(oldMUDV-> + GetForceCharacterSet(getter_Copies(forceCharset)), + NS_ERROR_FAILURE); + NS_ENSURE_SUCCESS(oldMUDV-> + GetHintCharacterSet(getter_Copies(hintCharset)), + NS_ERROR_FAILURE); + NS_ENSURE_SUCCESS(oldMUDV-> + GetHintCharacterSetSource(&hintCharsetSource), + NS_ERROR_FAILURE); + NS_ENSURE_SUCCESS(oldMUDV-> + GetTextZoom(&textZoom), + NS_ERROR_FAILURE); + NS_ENSURE_SUCCESS(oldMUDV-> + GetPrevDocCharacterSet(getter_Copies(prevDocCharset)), + NS_ERROR_FAILURE); + } } } @@ -4587,6 +4549,24 @@ nsDocShell::SetupNewViewer(nsIContentViewer * aNewViewer) return NS_ERROR_FAILURE; } + // If we have old state to copy, set the old state onto the new content + // viewer + if (newMUDV) { + NS_ENSURE_SUCCESS(newMUDV->SetDefaultCharacterSet(defaultCharset), + NS_ERROR_FAILURE); + NS_ENSURE_SUCCESS(newMUDV->SetForceCharacterSet(forceCharset), + NS_ERROR_FAILURE); + NS_ENSURE_SUCCESS(newMUDV->SetHintCharacterSet(hintCharset), + NS_ERROR_FAILURE); + NS_ENSURE_SUCCESS(newMUDV-> + SetHintCharacterSetSource(hintCharsetSource), + NS_ERROR_FAILURE); + NS_ENSURE_SUCCESS(newMUDV->SetPrevDocCharacterSet(prevDocCharset), + NS_ERROR_FAILURE); + NS_ENSURE_SUCCESS(newMUDV->SetTextZoom(textZoom), + NS_ERROR_FAILURE); + } + // End copying block (Don't mess with the old content/document viewer // beyond here!!) diff --git a/layout/base/nsDocumentViewer.cpp b/layout/base/nsDocumentViewer.cpp index f68b351c4b3..1ab2f0efc63 100644 --- a/layout/base/nsDocumentViewer.cpp +++ b/layout/base/nsDocumentViewer.cpp @@ -2290,7 +2290,14 @@ SetChildTextZoom(nsIMarkupDocumentViewer* aChild, void* aClosure) NS_IMETHODIMP DocumentViewerImpl::SetTextZoom(float aTextZoom) { if (mDeviceContext) { + float oldTextZoom + // Don't reflow or bubble down if there's no change in the textZoom. + // Not having this check caused the Tp regression from bug 126346 + mDeviceContext->GetTextZoom(&oldTextZoom); mDeviceContext->SetTextZoom(aTextZoom); + if (oldTextZoom == aTextZoom) + return NS_OK; + if (mPresContext) { mPresContext->ClearStyleDataAndReflow(); }