mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-12 02:31:41 +00:00
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
This commit is contained in:
parent
a8633dbceb
commit
31bf95ea38
@ -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<nsIScrollable> sc = do_QueryInterface(mContainer);
|
||||
|
||||
if (sc) {
|
||||
nsCOMPtr<nsIDOMHTMLFrameSetElement> 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<nsIHTMLDocument> htmlDoc = do_QueryInterface(mDocument);
|
||||
if (htmlDoc) {
|
||||
nsCOMPtr<nsIDOMHTMLFrameSetElement> frameset =
|
||||
do_QueryInterface(mDocument->GetRootContent());
|
||||
htmlDoc->SetIsFrameset(frameset != nsnull);
|
||||
}
|
||||
|
||||
// Initial reflow
|
||||
|
@ -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<nsIScrollable> 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
|
||||
|
@ -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<nsIWyciwygChannel> mWyciwygChannel;
|
||||
|
@ -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___ */
|
||||
|
@ -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<nsIScrollable> scrollableContainer(do_QueryReferent(mDocumentContainer));
|
||||
if (scrollableContainer) {
|
||||
scrollableContainer->ResetScrollbarPreferences();
|
||||
}
|
||||
|
||||
PRUint32 numberOfShells = GetNumberOfShells();
|
||||
for (PRUint32 i = 0; i < numberOfShells; i++) {
|
||||
nsIPresShell *shell = GetShellAt(i);
|
||||
|
@ -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<nsIScrollable> scrollableContainer(do_QueryInterface(mDocShell));
|
||||
if (scrollableContainer) {
|
||||
scrollableContainer->ResetScrollbarPreferences();
|
||||
}
|
||||
PRBool topLevelFrameset = PR_FALSE;
|
||||
nsCOMPtr<nsIDocShellTreeItem> docShellAsItem(do_QueryInterface(mDocShell));
|
||||
if (docShellAsItem) {
|
||||
|
@ -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. <IFRAME SCROLLING="no">
|
||||
// will not be preserved.
|
||||
//
|
||||
// One important client is HTMLContentSink::StartLayout()
|
||||
NS_IMETHODIMP
|
||||
nsDocShell::ResetScrollbarPreferences()
|
||||
{
|
||||
mCurrentScrollbarPref = mDefaultScrollbarPref;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocShell::GetScrollbarVisibility(PRBool * verticalVisible,
|
||||
PRBool * horizontalVisible)
|
||||
|
@ -411,7 +411,6 @@ protected:
|
||||
nsCOMPtr<nsIGlobalHistory2> mGlobalHistory;
|
||||
nsCOMPtr<nsISupports> mLoadCookie; // the load cookie associated with the window context.
|
||||
nsCOMPtr<nsIWebBrowserFind> mFind;
|
||||
nsPoint mCurrentScrollbarPref; // this document only
|
||||
nsPoint mDefaultScrollbarPref; // persistent across doc loads
|
||||
// Reference to the SHEntry for this docshell until the page is destroyed.
|
||||
// Somebody give me better name
|
||||
|
@ -48,7 +48,7 @@
|
||||
* min and the max.
|
||||
*/
|
||||
|
||||
[scriptable, uuid(70bd2967-288b-4d0b-880a-de0b7c15a77c)]
|
||||
[scriptable, uuid(919e792a-6490-40b8-bba5-f9e9ad5640c8)]
|
||||
interface nsIScrollable : nsISupports
|
||||
{
|
||||
/*
|
||||
@ -114,11 +114,8 @@ interface nsIScrollable : nsISupports
|
||||
default is 'scrolling preference for all documents in this shell'
|
||||
resetScrollbarPreferences resets current to default
|
||||
*/
|
||||
long getCurrentScrollbarPreferences(in long scrollOrientation);
|
||||
void setCurrentScrollbarPreferences(in long scrollOrientation, in long scrollbarPref);
|
||||
long getDefaultScrollbarPreferences(in long scrollOrientation);
|
||||
void setDefaultScrollbarPreferences(in long scrollOrientation, in long scrollbarPref);
|
||||
void resetScrollbarPreferences();
|
||||
|
||||
/*
|
||||
Get information about whether the vertical and horizontal scrollbars are
|
||||
|
@ -1524,15 +1524,6 @@ NS_IMETHODIMP nsWebBrowser::SetScrollRangeEx(PRInt32 aMinHorizontalPos,
|
||||
aMaxHorizontalPos, aMinVerticalPos, aMaxVerticalPos);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsWebBrowser::GetCurrentScrollbarPreferences(PRInt32 aScrollOrientation,
|
||||
PRInt32* aScrollbarPref)
|
||||
{
|
||||
NS_ENSURE_STATE(mDocShell);
|
||||
|
||||
return mDocShellAsScrollable->GetCurrentScrollbarPreferences(aScrollOrientation,
|
||||
aScrollbarPref);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsWebBrowser::GetDefaultScrollbarPreferences(PRInt32 aScrollOrientation,
|
||||
PRInt32* aScrollbarPref)
|
||||
{
|
||||
@ -1542,16 +1533,6 @@ NS_IMETHODIMP nsWebBrowser::GetDefaultScrollbarPreferences(PRInt32 aScrollOrient
|
||||
aScrollbarPref);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsWebBrowser::SetCurrentScrollbarPreferences(PRInt32 aScrollOrientation,
|
||||
PRInt32 aScrollbarPref)
|
||||
{
|
||||
NS_ENSURE_STATE(mDocShell);
|
||||
|
||||
return mDocShellAsScrollable->SetCurrentScrollbarPreferences(aScrollOrientation,
|
||||
aScrollbarPref);
|
||||
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsWebBrowser::SetDefaultScrollbarPreferences(PRInt32 aScrollOrientation,
|
||||
PRInt32 aScrollbarPref)
|
||||
{
|
||||
@ -1561,13 +1542,6 @@ NS_IMETHODIMP nsWebBrowser::SetDefaultScrollbarPreferences(PRInt32 aScrollOrient
|
||||
aScrollbarPref);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsWebBrowser::ResetScrollbarPreferences()
|
||||
{
|
||||
NS_ENSURE_STATE(mDocShell);
|
||||
|
||||
return mDocShellAsScrollable->ResetScrollbarPreferences();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsWebBrowser::GetScrollbarVisibility(PRBool* aVerticalVisible,
|
||||
PRBool* aHorizontalVisible)
|
||||
{
|
||||
|
@ -3824,7 +3824,6 @@ nsCSSFrameConstructor::ConstructRootFrame(nsIPresShell* aPresShell,
|
||||
// for print-preview, but not when printing), then create a scroll frame that
|
||||
// will act as the scrolling mechanism for the viewport.
|
||||
// XXX Do we even need a viewport when printing to a printer?
|
||||
PRBool isScrollable = PR_TRUE;
|
||||
|
||||
//isScrollable = PR_FALSE;
|
||||
|
||||
@ -3837,8 +3836,6 @@ nsCSSFrameConstructor::ConstructRootFrame(nsIPresShell* aPresShell,
|
||||
// 2) NS_STYLE_OVERFLOW_AUTO = scrollbars appear if needed
|
||||
// 3) NS_STYLE_OVERFLOW_SCROLL = scrollbars always
|
||||
// Only need to create a scroll frame/view for cases 2 and 3.
|
||||
// Currently OVERFLOW_SCROLL isn't honored, as
|
||||
// scrollportview::SetScrollPref is not implemented.
|
||||
|
||||
PRBool isHTML = aDocElement->IsContentOfType(nsIContent::eHTML);
|
||||
PRBool isXUL = PR_FALSE;
|
||||
@ -3848,28 +3845,13 @@ nsCSSFrameConstructor::ConstructRootFrame(nsIPresShell* aPresShell,
|
||||
}
|
||||
|
||||
// Never create scrollbars for XUL documents
|
||||
#ifdef MOZ_XUL
|
||||
if (isXUL) {
|
||||
isScrollable = PR_FALSE;
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
nsresult rv;
|
||||
if (aPresContext) {
|
||||
nsCOMPtr<nsISupports> container = aPresContext->GetContainer();
|
||||
if (container) {
|
||||
nsCOMPtr<nsIScrollable> scrollableContainer = do_QueryInterface(container, &rv);
|
||||
if (NS_SUCCEEDED(rv) && scrollableContainer) {
|
||||
PRInt32 scrolling = -1;
|
||||
// XXX We should get prefs for X and Y and deal with these independently!
|
||||
scrollableContainer->GetCurrentScrollbarPreferences(nsIScrollable::ScrollOrientation_Y,&scrolling);
|
||||
if (nsIScrollable::Scrollbar_Never == scrolling) {
|
||||
isScrollable = PR_FALSE;
|
||||
}
|
||||
// XXX NS_STYLE_OVERFLOW_SCROLL should create 'always on' scrollbars
|
||||
}
|
||||
}
|
||||
}
|
||||
PRBool isScrollable = !isXUL;
|
||||
|
||||
// Never create scrollbars for frameset documents.
|
||||
if (isHTML) {
|
||||
nsCOMPtr<nsIHTMLDocument> htmlDoc = do_QueryInterface(mDocument);
|
||||
if (htmlDoc && htmlDoc->GetIsFrameset())
|
||||
isScrollable = PR_FALSE;
|
||||
}
|
||||
|
||||
if (isPaginated) {
|
||||
|
@ -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<nsIScrollable> sc = do_QueryInterface(mContainer);
|
||||
|
||||
if (sc) {
|
||||
nsCOMPtr<nsIDOMHTMLFrameSetElement> 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<nsIHTMLDocument> htmlDoc = do_QueryInterface(mDocument);
|
||||
if (htmlDoc) {
|
||||
nsCOMPtr<nsIDOMHTMLFrameSetElement> frameset =
|
||||
do_QueryInterface(mDocument->GetRootContent());
|
||||
htmlDoc->SetIsFrameset(frameset != nsnull);
|
||||
}
|
||||
|
||||
// Initial reflow
|
||||
|
@ -45,6 +45,7 @@
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIView.h"
|
||||
#include "nsIScrollableView.h"
|
||||
#include "nsIScrollable.h"
|
||||
#include "nsIViewManager.h"
|
||||
#include "nsHTMLContainerFrame.h"
|
||||
#include "nsWidgetsCID.h"
|
||||
@ -1181,40 +1182,72 @@ NS_IMETHODIMP_(nsrefcnt) nsGfxScrollFrameInner::Release(void)
|
||||
|
||||
NS_IMPL_QUERY_INTERFACE1(nsGfxScrollFrameInner, nsIScrollPositionListener)
|
||||
|
||||
static void HandleScrollPref(nsIScrollable *aScrollable, PRInt32 aOrientation,
|
||||
PRUint8& aValue)
|
||||
{
|
||||
PRInt32 pref;
|
||||
aScrollable->GetDefaultScrollbarPreferences(aOrientation, &pref);
|
||||
switch (pref) {
|
||||
case nsIScrollable::Scrollbar_Auto:
|
||||
// leave |aValue| untouched
|
||||
break;
|
||||
case nsIScrollable::Scrollbar_Never:
|
||||
aValue = NS_STYLE_OVERFLOW_HIDDEN;
|
||||
break;
|
||||
case nsIScrollable::Scrollbar_Always:
|
||||
aValue = NS_STYLE_OVERFLOW_SCROLL;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static nsGfxScrollFrameInner::ScrollbarStyles
|
||||
ConvertOverflow(PRUint8 aOverflow)
|
||||
{
|
||||
nsGfxScrollFrameInner::ScrollbarStyles result;
|
||||
switch (aOverflow) {
|
||||
case NS_STYLE_OVERFLOW_SCROLLBARS_VERTICAL:
|
||||
result.mHorizontal = NS_STYLE_OVERFLOW_HIDDEN;
|
||||
result.mVertical = NS_STYLE_OVERFLOW_SCROLL;
|
||||
break;
|
||||
case NS_STYLE_OVERFLOW_SCROLLBARS_HORIZONTAL:
|
||||
result.mHorizontal = NS_STYLE_OVERFLOW_SCROLL;
|
||||
result.mVertical = NS_STYLE_OVERFLOW_HIDDEN;
|
||||
break;
|
||||
default:
|
||||
result.mHorizontal = aOverflow;
|
||||
result.mVertical = aOverflow;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
nsGfxScrollFrameInner::ScrollbarStyles
|
||||
nsGfxScrollFrameInner::GetScrollbarStylesFromFrame() const
|
||||
{
|
||||
PRUint8 overflow;
|
||||
ScrollbarStyles result;
|
||||
nsIFrame* parent = mOuter->GetParent();
|
||||
if (parent && parent->GetType() == nsLayoutAtoms::viewportFrame &&
|
||||
// Make sure we're actually the root scrollframe
|
||||
parent->GetFirstChild(nsnull) ==
|
||||
NS_STATIC_CAST(const nsIFrame*, mOuter)) {
|
||||
overflow = mOuter->GetPresContext()->GetViewportOverflowOverride();
|
||||
nsPresContext *presContext = mOuter->GetPresContext();
|
||||
result = ConvertOverflow(presContext->GetViewportOverflowOverride());
|
||||
|
||||
nsCOMPtr<nsISupports> container = presContext->GetContainer();
|
||||
nsCOMPtr<nsIScrollable> scrollable = do_QueryInterface(container);
|
||||
HandleScrollPref(scrollable, nsIScrollable::ScrollOrientation_X,
|
||||
result.mHorizontal);
|
||||
HandleScrollPref(scrollable, nsIScrollable::ScrollOrientation_Y,
|
||||
result.mVertical);
|
||||
} else {
|
||||
overflow = mOuter->GetStyleDisplay()->mOverflow;
|
||||
result = ConvertOverflow(mOuter->GetStyleDisplay()->mOverflow);
|
||||
}
|
||||
|
||||
switch (overflow) {
|
||||
case NS_STYLE_OVERFLOW_SCROLL:
|
||||
case NS_STYLE_OVERFLOW_HIDDEN:
|
||||
case NS_STYLE_OVERFLOW_VISIBLE: // should never happen
|
||||
case NS_STYLE_OVERFLOW_AUTO:
|
||||
return ScrollbarStyles(overflow, overflow);
|
||||
case NS_STYLE_OVERFLOW_CLIP:
|
||||
// This isn't quite right (although the value is deprecated and not
|
||||
// very important). The scrollframe will still be scrollable using
|
||||
// keys. This can happen when HTML or BODY has propagated the style
|
||||
// to the viewport. (In other cases, there will be no scrollframe.)
|
||||
return ScrollbarStyles(NS_STYLE_OVERFLOW_HIDDEN, NS_STYLE_OVERFLOW_HIDDEN);
|
||||
case NS_STYLE_OVERFLOW_SCROLLBARS_VERTICAL:
|
||||
return ScrollbarStyles(NS_STYLE_OVERFLOW_HIDDEN, NS_STYLE_OVERFLOW_SCROLL);
|
||||
case NS_STYLE_OVERFLOW_SCROLLBARS_HORIZONTAL:
|
||||
return ScrollbarStyles(NS_STYLE_OVERFLOW_SCROLL, NS_STYLE_OVERFLOW_HIDDEN);
|
||||
default:
|
||||
NS_NOTREACHED("invalid overflow value");
|
||||
return ScrollbarStyles(NS_STYLE_OVERFLOW_HIDDEN, NS_STYLE_OVERFLOW_HIDDEN);
|
||||
}
|
||||
NS_ASSERTION(result.mHorizontal != NS_STYLE_OVERFLOW_VISIBLE &&
|
||||
result.mHorizontal != NS_STYLE_OVERFLOW_CLIP &&
|
||||
result.mVertical != NS_STYLE_OVERFLOW_VISIBLE &&
|
||||
result.mVertical != NS_STYLE_OVERFLOW_CLIP,
|
||||
"scrollbars should not have been created");
|
||||
return result;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -45,6 +45,7 @@
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIView.h"
|
||||
#include "nsIScrollableView.h"
|
||||
#include "nsIScrollable.h"
|
||||
#include "nsIViewManager.h"
|
||||
#include "nsHTMLContainerFrame.h"
|
||||
#include "nsWidgetsCID.h"
|
||||
@ -1181,40 +1182,72 @@ NS_IMETHODIMP_(nsrefcnt) nsGfxScrollFrameInner::Release(void)
|
||||
|
||||
NS_IMPL_QUERY_INTERFACE1(nsGfxScrollFrameInner, nsIScrollPositionListener)
|
||||
|
||||
static void HandleScrollPref(nsIScrollable *aScrollable, PRInt32 aOrientation,
|
||||
PRUint8& aValue)
|
||||
{
|
||||
PRInt32 pref;
|
||||
aScrollable->GetDefaultScrollbarPreferences(aOrientation, &pref);
|
||||
switch (pref) {
|
||||
case nsIScrollable::Scrollbar_Auto:
|
||||
// leave |aValue| untouched
|
||||
break;
|
||||
case nsIScrollable::Scrollbar_Never:
|
||||
aValue = NS_STYLE_OVERFLOW_HIDDEN;
|
||||
break;
|
||||
case nsIScrollable::Scrollbar_Always:
|
||||
aValue = NS_STYLE_OVERFLOW_SCROLL;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static nsGfxScrollFrameInner::ScrollbarStyles
|
||||
ConvertOverflow(PRUint8 aOverflow)
|
||||
{
|
||||
nsGfxScrollFrameInner::ScrollbarStyles result;
|
||||
switch (aOverflow) {
|
||||
case NS_STYLE_OVERFLOW_SCROLLBARS_VERTICAL:
|
||||
result.mHorizontal = NS_STYLE_OVERFLOW_HIDDEN;
|
||||
result.mVertical = NS_STYLE_OVERFLOW_SCROLL;
|
||||
break;
|
||||
case NS_STYLE_OVERFLOW_SCROLLBARS_HORIZONTAL:
|
||||
result.mHorizontal = NS_STYLE_OVERFLOW_SCROLL;
|
||||
result.mVertical = NS_STYLE_OVERFLOW_HIDDEN;
|
||||
break;
|
||||
default:
|
||||
result.mHorizontal = aOverflow;
|
||||
result.mVertical = aOverflow;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
nsGfxScrollFrameInner::ScrollbarStyles
|
||||
nsGfxScrollFrameInner::GetScrollbarStylesFromFrame() const
|
||||
{
|
||||
PRUint8 overflow;
|
||||
ScrollbarStyles result;
|
||||
nsIFrame* parent = mOuter->GetParent();
|
||||
if (parent && parent->GetType() == nsLayoutAtoms::viewportFrame &&
|
||||
// Make sure we're actually the root scrollframe
|
||||
parent->GetFirstChild(nsnull) ==
|
||||
NS_STATIC_CAST(const nsIFrame*, mOuter)) {
|
||||
overflow = mOuter->GetPresContext()->GetViewportOverflowOverride();
|
||||
nsPresContext *presContext = mOuter->GetPresContext();
|
||||
result = ConvertOverflow(presContext->GetViewportOverflowOverride());
|
||||
|
||||
nsCOMPtr<nsISupports> container = presContext->GetContainer();
|
||||
nsCOMPtr<nsIScrollable> scrollable = do_QueryInterface(container);
|
||||
HandleScrollPref(scrollable, nsIScrollable::ScrollOrientation_X,
|
||||
result.mHorizontal);
|
||||
HandleScrollPref(scrollable, nsIScrollable::ScrollOrientation_Y,
|
||||
result.mVertical);
|
||||
} else {
|
||||
overflow = mOuter->GetStyleDisplay()->mOverflow;
|
||||
result = ConvertOverflow(mOuter->GetStyleDisplay()->mOverflow);
|
||||
}
|
||||
|
||||
switch (overflow) {
|
||||
case NS_STYLE_OVERFLOW_SCROLL:
|
||||
case NS_STYLE_OVERFLOW_HIDDEN:
|
||||
case NS_STYLE_OVERFLOW_VISIBLE: // should never happen
|
||||
case NS_STYLE_OVERFLOW_AUTO:
|
||||
return ScrollbarStyles(overflow, overflow);
|
||||
case NS_STYLE_OVERFLOW_CLIP:
|
||||
// This isn't quite right (although the value is deprecated and not
|
||||
// very important). The scrollframe will still be scrollable using
|
||||
// keys. This can happen when HTML or BODY has propagated the style
|
||||
// to the viewport. (In other cases, there will be no scrollframe.)
|
||||
return ScrollbarStyles(NS_STYLE_OVERFLOW_HIDDEN, NS_STYLE_OVERFLOW_HIDDEN);
|
||||
case NS_STYLE_OVERFLOW_SCROLLBARS_VERTICAL:
|
||||
return ScrollbarStyles(NS_STYLE_OVERFLOW_HIDDEN, NS_STYLE_OVERFLOW_SCROLL);
|
||||
case NS_STYLE_OVERFLOW_SCROLLBARS_HORIZONTAL:
|
||||
return ScrollbarStyles(NS_STYLE_OVERFLOW_SCROLL, NS_STYLE_OVERFLOW_HIDDEN);
|
||||
default:
|
||||
NS_NOTREACHED("invalid overflow value");
|
||||
return ScrollbarStyles(NS_STYLE_OVERFLOW_HIDDEN, NS_STYLE_OVERFLOW_HIDDEN);
|
||||
}
|
||||
NS_ASSERTION(result.mHorizontal != NS_STYLE_OVERFLOW_VISIBLE &&
|
||||
result.mHorizontal != NS_STYLE_OVERFLOW_CLIP &&
|
||||
result.mVertical != NS_STYLE_OVERFLOW_VISIBLE &&
|
||||
result.mVertical != NS_STYLE_OVERFLOW_CLIP,
|
||||
"scrollbars should not have been created");
|
||||
return result;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -3824,7 +3824,6 @@ nsCSSFrameConstructor::ConstructRootFrame(nsIPresShell* aPresShell,
|
||||
// for print-preview, but not when printing), then create a scroll frame that
|
||||
// will act as the scrolling mechanism for the viewport.
|
||||
// XXX Do we even need a viewport when printing to a printer?
|
||||
PRBool isScrollable = PR_TRUE;
|
||||
|
||||
//isScrollable = PR_FALSE;
|
||||
|
||||
@ -3837,8 +3836,6 @@ nsCSSFrameConstructor::ConstructRootFrame(nsIPresShell* aPresShell,
|
||||
// 2) NS_STYLE_OVERFLOW_AUTO = scrollbars appear if needed
|
||||
// 3) NS_STYLE_OVERFLOW_SCROLL = scrollbars always
|
||||
// Only need to create a scroll frame/view for cases 2 and 3.
|
||||
// Currently OVERFLOW_SCROLL isn't honored, as
|
||||
// scrollportview::SetScrollPref is not implemented.
|
||||
|
||||
PRBool isHTML = aDocElement->IsContentOfType(nsIContent::eHTML);
|
||||
PRBool isXUL = PR_FALSE;
|
||||
@ -3848,28 +3845,13 @@ nsCSSFrameConstructor::ConstructRootFrame(nsIPresShell* aPresShell,
|
||||
}
|
||||
|
||||
// Never create scrollbars for XUL documents
|
||||
#ifdef MOZ_XUL
|
||||
if (isXUL) {
|
||||
isScrollable = PR_FALSE;
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
nsresult rv;
|
||||
if (aPresContext) {
|
||||
nsCOMPtr<nsISupports> container = aPresContext->GetContainer();
|
||||
if (container) {
|
||||
nsCOMPtr<nsIScrollable> scrollableContainer = do_QueryInterface(container, &rv);
|
||||
if (NS_SUCCEEDED(rv) && scrollableContainer) {
|
||||
PRInt32 scrolling = -1;
|
||||
// XXX We should get prefs for X and Y and deal with these independently!
|
||||
scrollableContainer->GetCurrentScrollbarPreferences(nsIScrollable::ScrollOrientation_Y,&scrolling);
|
||||
if (nsIScrollable::Scrollbar_Never == scrolling) {
|
||||
isScrollable = PR_FALSE;
|
||||
}
|
||||
// XXX NS_STYLE_OVERFLOW_SCROLL should create 'always on' scrollbars
|
||||
}
|
||||
}
|
||||
}
|
||||
PRBool isScrollable = !isXUL;
|
||||
|
||||
// Never create scrollbars for frameset documents.
|
||||
if (isHTML) {
|
||||
nsCOMPtr<nsIHTMLDocument> htmlDoc = do_QueryInterface(mDocument);
|
||||
if (htmlDoc && htmlDoc->GetIsFrameset())
|
||||
isScrollable = PR_FALSE;
|
||||
}
|
||||
|
||||
if (isPaginated) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user