diff --git a/mozilla/content/base/src/nsDocumentViewer.cpp b/mozilla/content/base/src/nsDocumentViewer.cpp index 37d82603967..088a22c32b2 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 "nsIHTMLDocument.h" +#include "nsIScrollable.h" #include "nsITimelineService.h" #include "nsGfxCIID.h" @@ -678,11 +678,23 @@ DocumentViewerImpl::InitPresentationStuff(PRBool aDoInitialReflow) mViewManager->SetDefaultBackgroundColor(mPresContext->DefaultBackgroundColor()); if (aDoInitialReflow) { - nsCOMPtr htmlDoc = do_QueryInterface(mDocument); - if (htmlDoc) { - nsCOMPtr frameset = - do_QueryInterface(mDocument->GetRootContent()); - htmlDoc->SetIsFrameset(frameset != nsnull); + 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(); + } } // Initial reflow diff --git a/mozilla/content/html/document/src/nsHTMLContentSink.cpp b/mozilla/content/html/document/src/nsHTMLContentSink.cpp index f2f2fefb770..650b90da514 100644 --- a/mozilla/content/html/document/src/nsHTMLContentSink.cpp +++ b/mozilla/content/html/document/src/nsHTMLContentSink.cpp @@ -108,6 +108,7 @@ #include "nsTimer.h" #include "nsITimer.h" #include "nsDOMError.h" +#include "nsIScrollable.h" #include "nsContentPolicyUtils.h" #include "nsIScriptContext.h" #include "nsStyleLinkElement.h" @@ -3645,9 +3646,24 @@ HTMLContentSink::StartLayout() mLastNotificationTime = PR_Now(); - mHTMLDocument->SetIsFrameset(mFrameset != nsnull); + // 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(); + } + } - nsContentSink::StartLayout(mFrameset != nsnull); + nsContentSink::StartLayout(!!mFrameset); } void diff --git a/mozilla/content/html/document/src/nsHTMLDocument.h b/mozilla/content/html/document/src/nsHTMLDocument.h index 3b0037b6e86..3ff0e760270 100644 --- a/mozilla/content/html/document/src/nsHTMLDocument.h +++ b/mozilla/content/html/document/src/nsHTMLDocument.h @@ -119,9 +119,6 @@ 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, @@ -322,8 +319,6 @@ 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 12eae9914b5..ab9848cfbc8 100644 --- a/mozilla/content/html/document/src/nsIHTMLDocument.h +++ b/mozilla/content/html/document/src/nsIHTMLDocument.h @@ -111,9 +111,6 @@ 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 2fe13f86d56..c23378527df 100644 --- a/mozilla/content/html/document/src/nsMediaDocument.cpp +++ b/mozilla/content/html/document/src/nsMediaDocument.cpp @@ -267,6 +267,13 @@ 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 5a87993f2ba..4c8ba67f5aa 100644 --- a/mozilla/content/xml/document/src/nsXMLContentSink.cpp +++ b/mozilla/content/xml/document/src/nsXMLContentSink.cpp @@ -78,6 +78,7 @@ #include "prlog.h" #include "prmem.h" #include "nsParserUtils.h" +#include "nsIScrollable.h" #include "nsRect.h" #include "nsGenericElement.h" #include "nsIWebNavigation.h" @@ -831,6 +832,12 @@ 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 486c4fe72b6..e412428bd2a 100644 --- a/mozilla/docshell/base/nsDocShell.cpp +++ b/mozilla/docshell/base/nsDocShell.cpp @@ -268,6 +268,7 @@ nsDocShell::nsDocShell(): mMarginHeight(0), mItemType(typeContent), mContentListener(nsnull), + mCurrentScrollbarPref(Scrollbar_Auto, Scrollbar_Auto), mDefaultScrollbarPref(Scrollbar_Auto, Scrollbar_Auto), mEditorData(nsnull), mParent(nsnull), @@ -3652,6 +3653,29 @@ 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, @@ -3673,14 +3697,39 @@ nsDocShell::GetDefaultScrollbarPreferences(PRInt32 scrollOrientation, return NS_ERROR_FAILURE; } -// Set scrolling preference for all documents in this shell +// Set scrolling preference for this document only. // // There are three possible values stored in the shell: -// 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 +// 1) NS_STYLE_OVERFLOW_HIDDEN = no scrollbars +// 2) NS_STYLE_OVERFLOW_AUTO = scrollbars appear if needed +// 3) NS_STYLE_OVERFLOW_SCROLL = scrollbars always // +// 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, @@ -3701,6 +3750,19 @@ 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.