From b8499fbfc0216da671febd35fe33b3e65e95484a Mon Sep 17 00:00:00 2001 From: "dbaron%dbaron.org" Date: Sat, 4 Sep 2004 06:53:36 +0000 Subject: [PATCH] Land bug 72747 in pieces: Simplify the mechanisms used to prevent framesets from having scrollbars and used to implement the scrolling attribute on frames and iframes. Implement scrolling='yes'. b=72747 r+sr=roc git-svn-id: svn://10.0.0.236/trunk@161744 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/content/base/src/nsDocumentViewer.cpp | 24 ++---- .../html/document/src/nsHTMLContentSink.cpp | 20 +---- .../html/document/src/nsHTMLDocument.h | 5 ++ .../html/document/src/nsIHTMLDocument.h | 3 + .../html/document/src/nsMediaDocument.cpp | 7 -- .../xml/document/src/nsXMLContentSink.cpp | 7 -- mozilla/docshell/base/nsDocShell.cpp | 72 ++--------------- mozilla/docshell/base/nsDocShell.h | 1 - mozilla/docshell/base/nsIScrollable.idl | 5 +- .../browser/webBrowser/nsWebBrowser.cpp | 26 ------ mozilla/layout/base/nsCSSFrameConstructor.cpp | 32 ++------ mozilla/layout/base/nsDocumentViewer.cpp | 24 ++---- mozilla/layout/generic/nsGfxScrollFrame.cpp | 79 +++++++++++++------ .../layout/html/base/src/nsGfxScrollFrame.cpp | 79 +++++++++++++------ .../html/style/src/nsCSSFrameConstructor.cpp | 32 ++------ 15 files changed, 154 insertions(+), 262 deletions(-) diff --git a/mozilla/content/base/src/nsDocumentViewer.cpp b/mozilla/content/base/src/nsDocumentViewer.cpp index 088a22c32b2..37d82603967 100644 --- a/mozilla/content/base/src/nsDocumentViewer.cpp +++ b/mozilla/content/base/src/nsDocumentViewer.cpp @@ -120,7 +120,7 @@ #include "nsIFocusController.h" #include "nsIScrollableView.h" -#include "nsIScrollable.h" +#include "nsIHTMLDocument.h" #include "nsITimelineService.h" #include "nsGfxCIID.h" @@ -678,23 +678,11 @@ DocumentViewerImpl::InitPresentationStuff(PRBool aDoInitialReflow) mViewManager->SetDefaultBackgroundColor(mPresContext->DefaultBackgroundColor()); if (aDoInitialReflow) { - nsCOMPtr sc = do_QueryInterface(mContainer); - - if (sc) { - nsCOMPtr frameset(do_QueryInterface(mDocument->GetRootContent())); - - if (frameset) { - // If this is a frameset (i.e. not a frame) then we never want - // scrollbars on it, the scrollbars go inside the frames - // inside the frameset... - - sc->SetCurrentScrollbarPreferences(nsIScrollable::ScrollOrientation_Y, - nsIScrollable::Scrollbar_Never); - sc->SetCurrentScrollbarPreferences(nsIScrollable::ScrollOrientation_X, - nsIScrollable::Scrollbar_Never); - } else { - sc->ResetScrollbarPreferences(); - } + nsCOMPtr htmlDoc = do_QueryInterface(mDocument); + if (htmlDoc) { + nsCOMPtr frameset = + do_QueryInterface(mDocument->GetRootContent()); + htmlDoc->SetIsFrameset(frameset != nsnull); } // Initial reflow diff --git a/mozilla/content/html/document/src/nsHTMLContentSink.cpp b/mozilla/content/html/document/src/nsHTMLContentSink.cpp index 650b90da514..f2f2fefb770 100644 --- a/mozilla/content/html/document/src/nsHTMLContentSink.cpp +++ b/mozilla/content/html/document/src/nsHTMLContentSink.cpp @@ -108,7 +108,6 @@ #include "nsTimer.h" #include "nsITimer.h" #include "nsDOMError.h" -#include "nsIScrollable.h" #include "nsContentPolicyUtils.h" #include "nsIScriptContext.h" #include "nsStyleLinkElement.h" @@ -3646,24 +3645,9 @@ HTMLContentSink::StartLayout() mLastNotificationTime = PR_Now(); - // If it's a frameset document then disable scrolling. - // Else, reset scrolling to default settings for this shell. - // This must happen before the initial reflow, when we create the root frame - nsCOMPtr scrollableContainer = do_QueryInterface(mDocShell); - if (scrollableContainer) { - if (mFrameset) { - scrollableContainer-> - SetCurrentScrollbarPreferences(nsIScrollable::ScrollOrientation_Y, - nsIScrollable::Scrollbar_Never); - scrollableContainer-> - SetCurrentScrollbarPreferences(nsIScrollable::ScrollOrientation_X, - nsIScrollable::Scrollbar_Never); - } else { - scrollableContainer->ResetScrollbarPreferences(); - } - } + mHTMLDocument->SetIsFrameset(mFrameset != nsnull); - nsContentSink::StartLayout(!!mFrameset); + nsContentSink::StartLayout(mFrameset != nsnull); } void diff --git a/mozilla/content/html/document/src/nsHTMLDocument.h b/mozilla/content/html/document/src/nsHTMLDocument.h index 3ff0e760270..3b0037b6e86 100644 --- a/mozilla/content/html/document/src/nsHTMLDocument.h +++ b/mozilla/content/html/document/src/nsHTMLDocument.h @@ -119,6 +119,9 @@ public: return mWriteLevel != PRUint32(0); } + virtual PRBool GetIsFrameset() { return mIsFrameset; } + virtual void SetIsFrameset(PRBool aFrameset) { mIsFrameset = aFrameset; } + virtual void ContentAppended(nsIContent* aContainer, PRInt32 aNewIndexInContainer); virtual void ContentInserted(nsIContent* aContainer, @@ -319,6 +322,8 @@ protected: */ PRPackedBool mDomainWasSet; + PRPackedBool mIsFrameset; + PLDHashTable mIdAndNameHashTable; nsCOMPtr mWyciwygChannel; diff --git a/mozilla/content/html/document/src/nsIHTMLDocument.h b/mozilla/content/html/document/src/nsIHTMLDocument.h index ab9848cfbc8..12eae9914b5 100644 --- a/mozilla/content/html/document/src/nsIHTMLDocument.h +++ b/mozilla/content/html/document/src/nsIHTMLDocument.h @@ -111,6 +111,9 @@ public: virtual PRInt32 GetNumFormsSynchronous() = 0; virtual PRBool IsWriting() = 0; + + virtual PRBool GetIsFrameset() = 0; + virtual void SetIsFrameset(PRBool aFrameset) = 0; }; #endif /* nsIHTMLDocument_h___ */ diff --git a/mozilla/content/html/document/src/nsMediaDocument.cpp b/mozilla/content/html/document/src/nsMediaDocument.cpp index c23378527df..2fe13f86d56 100644 --- a/mozilla/content/html/document/src/nsMediaDocument.cpp +++ b/mozilla/content/html/document/src/nsMediaDocument.cpp @@ -267,13 +267,6 @@ nsMediaDocument::CreateSyntheticDocument() nsresult nsMediaDocument::StartLayout() { - // Reset scrolling to default settings for this shell. - // This must happen before the initial reflow, when we create the root frame - nsCOMPtr scrollableContainer(do_QueryReferent(mDocumentContainer)); - if (scrollableContainer) { - scrollableContainer->ResetScrollbarPreferences(); - } - PRUint32 numberOfShells = GetNumberOfShells(); for (PRUint32 i = 0; i < numberOfShells; i++) { nsIPresShell *shell = GetShellAt(i); diff --git a/mozilla/content/xml/document/src/nsXMLContentSink.cpp b/mozilla/content/xml/document/src/nsXMLContentSink.cpp index 4c8ba67f5aa..5a87993f2ba 100644 --- a/mozilla/content/xml/document/src/nsXMLContentSink.cpp +++ b/mozilla/content/xml/document/src/nsXMLContentSink.cpp @@ -78,7 +78,6 @@ #include "prlog.h" #include "prmem.h" #include "nsParserUtils.h" -#include "nsIScrollable.h" #include "nsRect.h" #include "nsGenericElement.h" #include "nsIWebNavigation.h" @@ -832,12 +831,6 @@ nsXMLContentSink::PopContent() void nsXMLContentSink::StartLayout() { - // Reset scrolling to default settings for this shell. - // This must happen before the initial reflow, when we create the root frame - nsCOMPtr scrollableContainer(do_QueryInterface(mDocShell)); - if (scrollableContainer) { - scrollableContainer->ResetScrollbarPreferences(); - } PRBool topLevelFrameset = PR_FALSE; nsCOMPtr docShellAsItem(do_QueryInterface(mDocShell)); if (docShellAsItem) { diff --git a/mozilla/docshell/base/nsDocShell.cpp b/mozilla/docshell/base/nsDocShell.cpp index e412428bd2a..486c4fe72b6 100644 --- a/mozilla/docshell/base/nsDocShell.cpp +++ b/mozilla/docshell/base/nsDocShell.cpp @@ -268,7 +268,6 @@ nsDocShell::nsDocShell(): mMarginHeight(0), mItemType(typeContent), mContentListener(nsnull), - mCurrentScrollbarPref(Scrollbar_Auto, Scrollbar_Auto), mDefaultScrollbarPref(Scrollbar_Auto, Scrollbar_Auto), mEditorData(nsnull), mParent(nsnull), @@ -3653,29 +3652,6 @@ nsDocShell::SetScrollRangeEx(PRInt32 minHorizontalPos, return NS_ERROR_FAILURE; } -// Get scroll setting for this document only -// -// One important client is nsCSSFrameConstructor::ConstructRootFrame() -NS_IMETHODIMP -nsDocShell::GetCurrentScrollbarPreferences(PRInt32 scrollOrientation, - PRInt32 * scrollbarPref) -{ - NS_ENSURE_ARG_POINTER(scrollbarPref); - switch (scrollOrientation) { - case ScrollOrientation_X: - *scrollbarPref = mCurrentScrollbarPref.x; - return NS_OK; - - case ScrollOrientation_Y: - *scrollbarPref = mCurrentScrollbarPref.y; - return NS_OK; - - default: - NS_ENSURE_TRUE(PR_FALSE, NS_ERROR_INVALID_ARG); - } - return NS_ERROR_FAILURE; -} - // This returns setting for all documents in this webshell NS_IMETHODIMP nsDocShell::GetDefaultScrollbarPreferences(PRInt32 scrollOrientation, @@ -3697,39 +3673,14 @@ nsDocShell::GetDefaultScrollbarPreferences(PRInt32 scrollOrientation, return NS_ERROR_FAILURE; } -// Set scrolling preference for this document only. +// Set scrolling preference for all documents in this shell // // There are three possible values stored in the shell: -// 1) NS_STYLE_OVERFLOW_HIDDEN = no scrollbars -// 2) NS_STYLE_OVERFLOW_AUTO = scrollbars appear if needed -// 3) NS_STYLE_OVERFLOW_SCROLL = scrollbars always +// 1) nsIScrollable::Scrollbar_Never = no scrollbar +// 2) nsIScrollable::Scrollbar_Auto = scrollbar appears if the document +// being displayed would normally have scrollbar +// 3) nsIScrollable::Scrollbar_Always = scrollbar always appears // -// XXX Currently OVERFLOW_SCROLL isn't honored, -// as it is not implemented by Gfx scrollbars -// XXX setting has no effect after the root frame is created -// as it is not implemented by Gfx scrollbars -// -// One important client is HTMLContentSink::StartLayout() -NS_IMETHODIMP -nsDocShell::SetCurrentScrollbarPreferences(PRInt32 scrollOrientation, - PRInt32 scrollbarPref) -{ - switch (scrollOrientation) { - case ScrollOrientation_X: - mCurrentScrollbarPref.x = scrollbarPref; - return NS_OK; - - case ScrollOrientation_Y: - mCurrentScrollbarPref.y = scrollbarPref; - return NS_OK; - - default: - NS_ENSURE_TRUE(PR_FALSE, NS_ERROR_INVALID_ARG); - } - return NS_ERROR_FAILURE; -} - -// Set scrolling preference for all documents in this shell // One important client is nsHTMLFrameInnerFrame::CreateWebShell() NS_IMETHODIMP nsDocShell::SetDefaultScrollbarPreferences(PRInt32 scrollOrientation, @@ -3750,19 +3701,6 @@ nsDocShell::SetDefaultScrollbarPreferences(PRInt32 scrollOrientation, return NS_ERROR_FAILURE; } -// Reset 'current' scrollbar settings to 'default'. -// This must be called before every document load or else -// frameset scrollbar settings (e.g.