Back out the rest of bug 72747 due to Tp regression.

This commit is contained in:
dbaron%dbaron.org 2004-08-27 01:26:55 +00:00
Родитель 58b1c6de36
Коммит 67e0ee1634
47 изменённых файлов: 827 добавлений и 431 удалений

Просмотреть файл

@ -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<nsIHTMLDocument> htmlDoc = do_QueryInterface(mDocument);
if (htmlDoc) {
nsCOMPtr<nsIDOMHTMLFrameSetElement> frameset =
do_QueryInterface(mDocument->GetRootContent());
htmlDoc->SetIsFrameset(frameset != nsnull);
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,
NS_STYLE_OVERFLOW_HIDDEN);
sc->SetCurrentScrollbarPreferences(nsIScrollable::ScrollOrientation_X,
NS_STYLE_OVERFLOW_HIDDEN);
} else {
sc->ResetScrollbarPreferences();
}
}
// Initial reflow

Просмотреть файл

@ -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<nsIScrollable> scrollableContainer = do_QueryInterface(mDocShell);
if (scrollableContainer) {
if (mFrameset) {
scrollableContainer->
SetCurrentScrollbarPreferences(nsIScrollable::ScrollOrientation_Y,
NS_STYLE_OVERFLOW_HIDDEN);
scrollableContainer->
SetCurrentScrollbarPreferences(nsIScrollable::ScrollOrientation_X,
NS_STYLE_OVERFLOW_HIDDEN);
} else {
scrollableContainer->ResetScrollbarPreferences();
}
}
nsContentSink::StartLayout(mFrameset != nsnull);
nsContentSink::StartLayout(!!mFrameset);
}
void

Просмотреть файл

@ -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<nsIWyciwygChannel> mWyciwygChannel;

Просмотреть файл

@ -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___ */

Просмотреть файл

@ -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<nsIScrollable> scrollableContainer(do_QueryReferent(mDocumentContainer));
if (scrollableContainer) {
scrollableContainer->ResetScrollbarPreferences();
}
PRUint32 numberOfShells = GetNumberOfShells();
for (PRUint32 i = 0; i < numberOfShells; i++) {
nsIPresShell *shell = GetShellAt(i);

Просмотреть файл

@ -731,7 +731,7 @@ struct nsStyleDisplay : public nsStyleStruct {
PRUint8 mBreakType; // [reset] see nsStyleConsts.h NS_STYLE_CLEAR_*
PRPackedBool mBreakBefore; // [reset]
PRPackedBool mBreakAfter; // [reset]
PRUint8 mOverflow; // [reset] see nsStyleConsts.h
PRUint8 mOverflow; // [reset] see nsStyleConsts.h
PRUint8 mClipFlags; // [reset] see nsStyleConsts.h
PRBool IsBlockLevel() const {return (NS_STYLE_DISPLAY_BLOCK == mDisplay) ||
@ -747,18 +747,6 @@ struct nsStyleDisplay : public nsStyleStruct {
PRBool IsPositioned() const {return IsAbsolutelyPositioned() ||
(NS_STYLE_POSITION_RELATIVE == mPosition);}
PRBool IsScrollableOverflow() const {
return mOverflow != NS_STYLE_OVERFLOW_VISIBLE &&
mOverflow != NS_STYLE_OVERFLOW_CLIP;
}
// For table elements that don't support scroll frame creation, we
// support 'overflow: hidden' to mean 'overflow: -moz-hidden-unscrollable'.
PRBool IsTableClip() const {
return mOverflow == NS_STYLE_OVERFLOW_CLIP ||
mOverflow == NS_STYLE_OVERFLOW_HIDDEN;
}
};
struct nsStyleTable: public nsStyleStruct {

Просмотреть файл

@ -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<nsIScrollable> scrollableContainer(do_QueryInterface(mDocShell));
if (scrollableContainer) {
scrollableContainer->ResetScrollbarPreferences();
}
PRBool topLevelFrameset = PR_FALSE;
nsCOMPtr<nsIDocShellTreeItem> docShellAsItem(do_QueryInterface(mDocShell));
if (docShellAsItem) {

Просмотреть файл

@ -268,7 +268,8 @@ nsDocShell::nsDocShell():
mMarginHeight(0),
mItemType(typeContent),
mContentListener(nsnull),
mDefaultScrollbarPref(Scrollbar_Auto, Scrollbar_Auto),
mCurrentScrollbarPref(-1, -1),
mDefaultScrollbarPref(-1, -1),
mEditorData(nsnull),
mParent(nsnull),
mTreeOwner(nsnull),
@ -3651,6 +3652,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,
@ -3672,14 +3696,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) NS_STYLE_OVERFLOW_HIDDEN = no scrollbar
// 2) NS_STYLE_OVERFLOW_AUTO = scrollbar appears if the document
// being displayed would normally have scrollbar
// 3) NS_STYLE_OVERFLOW_SCROLL = 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,
@ -3700,6 +3749,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. <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)

Просмотреть файл

@ -408,6 +408,7 @@ 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,20 +48,20 @@
* min and the max.
*/
[scriptable, uuid(919e792a-6490-40b8-bba5-f9e9ad5640c8)]
[scriptable, uuid(61792520-82C2-11d3-AF76-00A024FFC08C)]
interface nsIScrollable : nsISupports
{
/*
Constants declaring the two scroll orientations a scroll bar can be in.
ScrollOrientation_X - Horizontal scrolling. When passing this
in to a scroll position method you are requesting or
setting the positions for the horizontal scroll bar.
ScrollOrientation_Y - Vertical scrolling. When passing this
in to a scroll position you are requesting or setting
the positions for the vertical scroll bar.
ScrollOrientation_X - Vertical scrolling. When passing this in to a scroll position
method you are requesting or setting the positions for the vertical
scroll bar.
ScrollOrientation_Y - Horizontal scrolling. When passing this in to a scroll
position you are requesting or setting the positions for the horizontal
scroll bar.
*/
const long ScrollOrientation_X = 1;
const long ScrollOrientation_Y = 2;
const long ScrollOrientation_Y = 1;
const long ScrollOrientation_X = 2;
/*
Retrieves or Sets the current thumb position to the curPos passed in for the
@ -71,7 +71,7 @@ interface nsIScrollable : nsISupports
NS_ERROR_INVALID_ARG - returned when curPos is not within the
minPos and maxPos.
*/
long getCurScrollPos(in long scrollOrientation);
void getCurScrollPos(in long scrollOrientation, out long curPos);
void setCurScrollPos(in long scrollOrientation, in long curPos);
/*
@ -114,8 +114,11 @@ interface nsIScrollable : nsISupports
default is 'scrolling preference for all documents in this shell'
resetScrollbarPreferences resets current to default
*/
long getDefaultScrollbarPreferences(in long scrollOrientation);
void getCurrentScrollbarPreferences(in long scrollOrientation, out long scrollbarPref);
void setCurrentScrollbarPreferences(in long scrollOrientation, in long scrollbarPref);
void getDefaultScrollbarPreferences(in long scrollOrientation, out long scrollbarPref);
void setDefaultScrollbarPreferences(in long scrollOrientation, in long scrollbarPref);
void resetScrollbarPreferences();
/*
Get information about whether the vertical and horizontal scrollbars are
@ -125,4 +128,4 @@ interface nsIScrollable : nsISupports
*/
void getScrollbarVisibility(out boolean verticalVisible,
out boolean horizontalVisible);
};
};

Просмотреть файл

@ -275,14 +275,15 @@ ScrollbarsPropImpl::GetVisible(PRBool *aVisible)
do_QueryInterface(mDOMWindow->GetDocShell());
if (scroller) {
PRInt32 prefValue;
PRInt32 prefValue = aVisible ? NS_STYLE_OVERFLOW_AUTO :
NS_STYLE_OVERFLOW_HIDDEN;
scroller->GetDefaultScrollbarPreferences(
nsIScrollable::ScrollOrientation_Y, &prefValue);
if (prefValue == nsIScrollable::Scrollbar_Never) // try the other way
if (prefValue == NS_STYLE_OVERFLOW_HIDDEN) // try the other way
scroller->GetDefaultScrollbarPreferences(
nsIScrollable::ScrollOrientation_X, &prefValue);
if (prefValue == nsIScrollable::Scrollbar_Never)
if (prefValue == NS_STYLE_OVERFLOW_HIDDEN)
*aVisible = PR_FALSE;
}
}
@ -306,8 +307,8 @@ ScrollbarsPropImpl::SetVisible(PRBool aVisible)
do_QueryInterface(mDOMWindow->GetDocShell());
if (scroller) {
PRInt32 prefValue = aVisible ? nsIScrollable::Scrollbar_Auto :
nsIScrollable::Scrollbar_Never ;
PRInt32 prefValue = aVisible ? NS_STYLE_OVERFLOW_AUTO :
NS_STYLE_OVERFLOW_HIDDEN;
scroller->SetDefaultScrollbarPreferences(
nsIScrollable::ScrollOrientation_Y, prefValue);
scroller->SetDefaultScrollbarPreferences(

Просмотреть файл

@ -1524,6 +1524,15 @@ 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)
{
@ -1533,6 +1542,16 @@ 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)
{
@ -1542,6 +1561,13 @@ 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)
{

Просмотреть файл

@ -2708,7 +2708,7 @@ nsCSSFrameConstructor::ConstructTableRowGroupFrame(nsIPresShell* aPre
rv = aTableCreator.CreateTableRowGroupFrame(&aNewFrame);
nsIFrame* scrollFrame = nsnull;
if (styleDisplay->IsScrollableOverflow()) {
if (IsScrollable(aPresContext, styleDisplay)) {
// Create an area container for the frame
BuildScrollFrame(aPresShell, aPresContext, aState, aContent, aStyleContext,
aNewFrame, parentFrame, nsnull, scrollFrame, aStyleContext);
@ -3341,19 +3341,6 @@ nsCSSFrameConstructor::ConstructDocElementTableFrame(nsIPresShell* aPresS
return NS_OK;
}
static PRBool CheckOverflow(nsPresContext* aPresContext,
const nsStyleDisplay* aDisplay)
{
if (aDisplay->mOverflow == NS_STYLE_OVERFLOW_VISIBLE)
return PR_FALSE;
if (aDisplay->mOverflow == NS_STYLE_OVERFLOW_CLIP)
aPresContext->SetViewportOverflowOverride(NS_STYLE_OVERFLOW_HIDDEN);
else
aPresContext->SetViewportOverflowOverride(aDisplay->mOverflow);
return PR_TRUE;
}
/**
* This checks the root element and the HTML BODY, if any, for an "overflow" property
* that should be applied to the viewport. If one is found then we return the
@ -3379,12 +3366,14 @@ nsCSSFrameConstructor::PropagateScrollToViewport(nsPresContext* aPresContext)
// Check the style on the document root element
nsStyleSet *styleSet = aPresContext->PresShell()->StyleSet();
nsRefPtr<nsStyleContext> rootStyle;
rootStyle = styleSet->ResolveStyleFor(docElement, nsnull);
if (!rootStyle) {
nsRefPtr<nsStyleContext> styleContext;
styleContext = styleSet->ResolveStyleFor(docElement, nsnull);
if (!styleContext) {
return nsnull;
}
if (CheckOverflow(aPresContext, rootStyle->GetStyleDisplay())) {
const nsStyleDisplay* display = styleContext->GetStyleDisplay();
if (display->mOverflow != NS_STYLE_OVERFLOW_VISIBLE) {
aPresContext->SetViewportOverflowOverride(display->mOverflow);
// tell caller we stole the overflow style from the root element
return docElement;
}
@ -3410,13 +3399,15 @@ nsCSSFrameConstructor::PropagateScrollToViewport(nsPresContext* aPresContext)
return nsnull;
}
nsRefPtr<nsStyleContext> bodyStyle;
bodyStyle = styleSet->ResolveStyleFor(bodyElement, rootStyle);
if (!bodyStyle) {
nsRefPtr<nsStyleContext> bodyContext;
bodyContext = styleSet->ResolveStyleFor(bodyElement, styleContext);
if (!bodyContext) {
return nsnull;
}
if (CheckOverflow(aPresContext, bodyStyle->GetStyleDisplay())) {
display = bodyContext->GetStyleDisplay();
if (display->mOverflow != NS_STYLE_OVERFLOW_VISIBLE) {
aPresContext->SetViewportOverflowOverride(display->mOverflow);
// tell caller we stole the overflow style from the body element
return bodyElement;
}
@ -3530,7 +3521,7 @@ nsCSSFrameConstructor::ConstructDocElementFrame(nsIPresShell* aPresShell,
// The document root should not be scrollable in any paginated context,
// even in print preview.
PRBool isScrollable = display->IsScrollableOverflow()
PRBool isScrollable = IsScrollable(aPresContext, display)
&& !aPresContext->IsPaginated()
&& !propagatedScrollToViewport;
@ -3805,6 +3796,7 @@ 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;
@ -3817,6 +3809,8 @@ 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;
@ -3826,13 +3820,28 @@ nsCSSFrameConstructor::ConstructRootFrame(nsIPresShell* aPresShell,
}
// Never create scrollbars for XUL documents
PRBool isScrollable = !isXUL;
// Never create scrollbars for frameset documents.
if (isHTML) {
nsCOMPtr<nsIHTMLDocument> htmlDoc = do_QueryInterface(mDocument);
if (htmlDoc && htmlDoc->GetIsFrameset())
isScrollable = PR_FALSE;
#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 (NS_STYLE_OVERFLOW_HIDDEN == scrolling) {
isScrollable = PR_FALSE;
}
// XXX NS_STYLE_OVERFLOW_SCROLL should create 'always on' scrollbars
}
}
}
}
if (isPaginated) {
@ -5471,7 +5480,7 @@ nsCSSFrameConstructor::ConstructXULFrame(nsIPresShell* aPresShell,
}
// Boxes can scroll.
if (display->IsScrollableOverflow()) {
if (IsScrollable(aPresContext, display)) {
nsIFrame* scrollPort = nsnull;
if (listboxScrollPort) {
@ -5571,7 +5580,7 @@ nsCSSFrameConstructor::ConstructXULFrame(nsIPresShell* aPresShell,
#endif
}
if (mayBeScrollable && display->IsScrollableOverflow()) {
if (mayBeScrollable && IsScrollable(aPresContext, display)) {
// set the top to be the newly created scrollframe
BuildScrollFrame(aPresShell, aPresContext, aState, aContent,
aStyleContext, newFrame, aParentFrame, nsnull,
@ -6079,7 +6088,7 @@ nsCSSFrameConstructor::ConstructFrameByDisplayType(nsIPresShell* aPre
// XXX Ignore tables for the time being
if (aDisplay->IsBlockLevel() &&
aDisplay->mDisplay != NS_STYLE_DISPLAY_TABLE &&
aDisplay->IsScrollableOverflow() &&
IsScrollable(aPresContext, aDisplay) &&
!propagatedScrollToViewport) {
if (!pseudoParent && !aState.mPseudoFrames.IsEmpty()) { // process pending pseudo frames
@ -6485,6 +6494,25 @@ nsCSSFrameConstructor::ConstructFrameByDisplayType(nsIPresShell* aPre
return rv;
}
PRBool
nsCSSFrameConstructor::IsScrollable(nsPresContext* aPresContext,
const nsStyleDisplay* aDisplay)
{
// For the time being it's scrollable if the overflow property is auto or
// scroll, regardless of whether the width or height is fixed in size
switch (aDisplay->mOverflow) {
case NS_STYLE_OVERFLOW_SCROLL:
case NS_STYLE_OVERFLOW_AUTO:
case NS_STYLE_OVERFLOW_HIDDEN:
case NS_STYLE_OVERFLOW_SCROLLBARS_HORIZONTAL:
case NS_STYLE_OVERFLOW_SCROLLBARS_VERTICAL:
return PR_TRUE;
}
return PR_FALSE;
}
nsresult
nsCSSFrameConstructor::InitAndRestoreFrame(nsPresContext* aPresContext,
nsFrameConstructorState& aState,

Просмотреть файл

@ -685,6 +685,8 @@ private:
nsIContent* aChild,
nsIDOMHTMLSelectElement* aSelectElement);
PRBool IsScrollable(nsPresContext* aPresContext, const nsStyleDisplay* aDisplay);
nsIFrame* GetFrameFor(nsIPresShell* aPresShell,
nsPresContext* aPresContext,
nsIContent* aContent);

Просмотреть файл

@ -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<nsIHTMLDocument> htmlDoc = do_QueryInterface(mDocument);
if (htmlDoc) {
nsCOMPtr<nsIDOMHTMLFrameSetElement> frameset =
do_QueryInterface(mDocument->GetRootContent());
htmlDoc->SetIsFrameset(frameset != nsnull);
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,
NS_STYLE_OVERFLOW_HIDDEN);
sc->SetCurrentScrollbarPreferences(nsIScrollable::ScrollOrientation_X,
NS_STYLE_OVERFLOW_HIDDEN);
} else {
sc->ResetScrollbarPreferences();
}
}
// Initial reflow

Просмотреть файл

@ -140,7 +140,6 @@ static NS_DEFINE_CID(kSelectionImageService, NS_SELECTIONIMAGESERVICE_CID);
nsPresContext::nsPresContext(nsPresContextType aType)
: mType(aType),
mViewportStyleOverflow(NS_STYLE_OVERFLOW_AUTO),
mCompatibilityMode(eCompatibility_FullStandards),
mImageAnimationModePref(imgIContainer::kNormalAnimMode),
mDefaultVariableFont("serif", NS_FONT_STYLE_NORMAL, NS_FONT_VARIANT_NORMAL,
@ -166,6 +165,8 @@ nsPresContext::nsPresContext(nsPresContextType aType)
SetBackgroundImageDraw(PR_TRUE); // always draw the background
SetBackgroundColorDraw(PR_TRUE);
mViewportStyleOverflow = NS_STYLE_OVERFLOW_AUTO;
mBackgroundColor = NS_RGB(0xFF, 0xFF, 0xFF);
mUseDocumentColors = PR_TRUE;

Просмотреть файл

@ -431,21 +431,11 @@ public:
return mLanguageSpecificTransformType;
}
struct ScrollbarStyles {
// Always one of NS_STYLE_OVERFLOW_SCROLL, NS_STYLE_OVERFLOW_HIDDEN,
// or NS_STYLE_OVERFLOW_AUTO.
PRUint8 mHorizontal, mVertical;
ScrollbarStyles(PRUint8 h, PRUint8 v) : mHorizontal(h), mVertical(v) {}
ScrollbarStyles() {}
};
void SetViewportOverflowOverride(PRUint8 aOverflow)
void SetViewportOverflowOverride(PRUint8 aStyle)
{
mViewportStyleOverflow = aOverflow;
}
PRUint8 GetViewportOverflowOverride()
{
return mViewportStyleOverflow;
mViewportStyleOverflow = aStyle;
}
PRUint8 GetViewportOverflowOverride() { return mViewportStyleOverflow; }
/**
* Set and get methods for controling the background drawing
@ -654,8 +644,8 @@ protected:
nscolor mFocusBackgroundColor;
nscolor mFocusTextColor;
PRUint8 mViewportStyleOverflow;
PRUint8 mFocusRingWidth;
PRUint8 mViewportStyleOverflow;
nsCompatibility mCompatibilityMode;
PRUint16 mImageAnimationMode;

Просмотреть файл

@ -42,10 +42,10 @@
#include "nsCoord.h"
#include "nsIViewManager.h"
#include "nsIScrollableViewProvider.h"
#include "nsPresContext.h"
class nsIFrame;
class nsIBox;
class nsPresContext;
class nsBoxLayoutState;
// IID for the nsIScrollableFrame interface
@ -56,6 +56,14 @@ class nsBoxLayoutState;
class nsIScrollableFrame : public nsIScrollableViewProvider {
public:
enum nsScrollPref {
Auto = 0,
NeverScroll,
AlwaysScroll,
AlwaysScrollVertical,
AlwaysScrollHorizontal
};
NS_DEFINE_STATIC_IID_ACCESSOR(NS_ISCROLLABLE_FRAME_IID)
/**
@ -65,7 +73,13 @@ public:
NS_IMETHOD GetScrolledFrame(nsPresContext* aPresContext,
nsIFrame *&aScrolledFrame) const = 0;
typedef nsPresContext::ScrollbarStyles ScrollbarStyles;
struct ScrollbarStyles {
// one of NS_STYLE_OVERFLOW_SCROLL, NS_STYLE_OVERFLOW_HIDDEN,
// NS_STYLE_OVERFLOW_VISIBLE, NS_STYLE_OVERFLOW_AUTO
PRInt32 mHorizontal;
PRInt32 mVertical;
ScrollbarStyles(PRInt32 h, PRInt32 v) : mHorizontal(h), mVertical(v) {}
};
virtual ScrollbarStyles GetScrollbarStyles() const = 0;
@ -81,6 +95,13 @@ public:
*/
virtual nsMargin GetDesiredScrollbarSizes(nsBoxLayoutState* aState) = 0;
/**
* Query whether scroll bars should be displayed all the time, never or
* only when necessary.
* @return current scrollbar selection
*/
NS_IMETHOD GetScrollPreference(nsPresContext* aPresContext, nsScrollPref* aScrollPreference) const = 0;
/**
* Get the position of the scrolled view.
*/
@ -99,6 +120,15 @@ public:
NS_IMETHOD GetScrollableView(nsPresContext* aContext, nsIScrollableView** aResult)=0;
/**
* Set information about whether the vertical and horizontal scrollbars
* are currently visible
*/
NS_IMETHOD SetScrollbarVisibility(nsPresContext* aPresContext,
PRBool aVerticalVisible,
PRBool aHorizontalVisible) = 0;
NS_IMETHOD GetScrollbarBox(PRBool aVertical, nsIBox** aResult) = 0;
NS_IMETHOD CurPosAttributeChanged(nsPresContext* aPresContext,

Просмотреть файл

@ -431,21 +431,11 @@ public:
return mLanguageSpecificTransformType;
}
struct ScrollbarStyles {
// Always one of NS_STYLE_OVERFLOW_SCROLL, NS_STYLE_OVERFLOW_HIDDEN,
// or NS_STYLE_OVERFLOW_AUTO.
PRUint8 mHorizontal, mVertical;
ScrollbarStyles(PRUint8 h, PRUint8 v) : mHorizontal(h), mVertical(v) {}
ScrollbarStyles() {}
};
void SetViewportOverflowOverride(PRUint8 aOverflow)
void SetViewportOverflowOverride(PRUint8 aStyle)
{
mViewportStyleOverflow = aOverflow;
}
PRUint8 GetViewportOverflowOverride()
{
return mViewportStyleOverflow;
mViewportStyleOverflow = aStyle;
}
PRUint8 GetViewportOverflowOverride() { return mViewportStyleOverflow; }
/**
* Set and get methods for controling the background drawing
@ -654,8 +644,8 @@ protected:
nscolor mFocusBackgroundColor;
nscolor mFocusTextColor;
PRUint8 mViewportStyleOverflow;
PRUint8 mFocusRingWidth;
PRUint8 mViewportStyleOverflow;
nsCompatibility mCompatibilityMode;
PRUint16 mImageAnimationMode;

Просмотреть файл

@ -140,7 +140,6 @@ static NS_DEFINE_CID(kSelectionImageService, NS_SELECTIONIMAGESERVICE_CID);
nsPresContext::nsPresContext(nsPresContextType aType)
: mType(aType),
mViewportStyleOverflow(NS_STYLE_OVERFLOW_AUTO),
mCompatibilityMode(eCompatibility_FullStandards),
mImageAnimationModePref(imgIContainer::kNormalAnimMode),
mDefaultVariableFont("serif", NS_FONT_STYLE_NORMAL, NS_FONT_VARIANT_NORMAL,
@ -166,6 +165,8 @@ nsPresContext::nsPresContext(nsPresContextType aType)
SetBackgroundImageDraw(PR_TRUE); // always draw the background
SetBackgroundColorDraw(PR_TRUE);
mViewportStyleOverflow = NS_STYLE_OVERFLOW_AUTO;
mBackgroundColor = NS_RGB(0xFF, 0xFF, 0xFF);
mUseDocumentColors = PR_TRUE;

Просмотреть файл

@ -1637,7 +1637,8 @@ nsTextControlFrame::CreateAnonymousContent(nsPresContext* aPresContext,
// setting -moz-hidden-unscrollable overflow (NS_STYLE_OVERFLOW_CLIP)
// doesn't paint the caret for some reason.
const nsStyleDisplay* disp = GetStyleDisplay();
if (disp->mOverflow != NS_STYLE_OVERFLOW_VISIBLE &&
if (disp->mOverflow != NS_STYLE_OVERFLOW_AUTO && // this is the default
disp->mOverflow != NS_STYLE_OVERFLOW_VISIBLE &&
disp->mOverflow != NS_STYLE_OVERFLOW_CLIP) {
rv = divContent->SetAttr(kNameSpaceID_None, nsHTMLAtoms::style,
NS_LITERAL_STRING("overflow: inherit;"),
@ -2996,6 +2997,16 @@ nsTextControlFrame::SetInitialChildList(nsPresContext* aPresContext,
// than descending from the root frame of the frame hierarchy.
first->AddStateBits(NS_FRAME_REFLOW_ROOT);
//we must turn off scrollbars for singleline text controls
if (IsSingleLineTextControl())
{
nsIScrollableFrame *scrollableFrame = nsnull;
if (first)
first->QueryInterface(NS_GET_IID(nsIScrollableFrame), (void **) &scrollableFrame);
if (scrollableFrame)
scrollableFrame->SetScrollbarVisibility(aPresContext,PR_FALSE,PR_FALSE);
}
//register keylistener
nsCOMPtr<nsIDOMEventReceiver> erP;
if (NS_SUCCEEDED(mContent->QueryInterface(NS_GET_IID(nsIDOMEventReceiver), getter_AddRefs(erP))) && erP)

Просмотреть файл

@ -4269,7 +4269,8 @@ nsFrame::ConsiderChildOverflow(nsPresContext* aPresContext,
const nsStyleDisplay* disp = GetStyleDisplay();
// check here also for hidden as table frames (table, tr and td) currently
// don't wrap their content into a scrollable frame if overflow is specified
if (!disp->IsTableClip()) {
if (NS_STYLE_OVERFLOW_CLIP != disp->mOverflow &&
NS_STYLE_OVERFLOW_HIDDEN != disp->mOverflow) {
nsRect* overflowArea = aChildFrame->GetOverflowAreaProperty();
if (overflowArea) {
nsRect childOverflow(*overflowArea);

Просмотреть файл

@ -617,20 +617,6 @@ nsSubDocumentFrame::GetDocShell(nsIDocShell **aDocShell)
return mFrameLoader->GetDocShell(aDocShell);
}
inline PRInt32 ConvertOverflow(PRUint8 aOverflow)
{
switch (aOverflow) {
case NS_STYLE_OVERFLOW_VISIBLE:
case NS_STYLE_OVERFLOW_AUTO:
return nsIScrollable::Scrollbar_Auto;
case NS_STYLE_OVERFLOW_HIDDEN:
case NS_STYLE_OVERFLOW_CLIP:
return nsIScrollable::Scrollbar_Never;
case NS_STYLE_OVERFLOW_SCROLL:
return nsIScrollable::Scrollbar_Always;
}
}
nsresult
nsSubDocumentFrame::ShowDocShell()
{
@ -659,25 +645,33 @@ nsSubDocumentFrame::ShowDocShell()
nsCOMPtr<nsIScrollable> sc(do_QueryInterface(docShell));
if (sc) {
nsPresContext::ScrollbarStyles pref;
PRUint8 overflow = GetStyleDisplay()->mOverflow;
switch (overflow) {
case NS_STYLE_OVERFLOW_SCROLLBARS_VERTICAL:
pref.mHorizontal = NS_STYLE_OVERFLOW_HIDDEN;
pref.mVertical = NS_STYLE_OVERFLOW_SCROLL;
PRInt32 scrolling = GetStyleDisplay()->mOverflow;
PRInt32 scrollX, scrollY;
switch (scrolling) {
case NS_STYLE_OVERFLOW_CLIP:
scrollX = NS_STYLE_OVERFLOW_HIDDEN;
scrollY = NS_STYLE_OVERFLOW_HIDDEN;
break;
case NS_STYLE_OVERFLOW_SCROLLBARS_HORIZONTAL:
pref.mHorizontal = NS_STYLE_OVERFLOW_SCROLL;
pref.mVertical = NS_STYLE_OVERFLOW_HIDDEN;
scrollX = NS_STYLE_OVERFLOW_SCROLL;
scrollY = NS_STYLE_OVERFLOW_HIDDEN;
break;
case NS_STYLE_OVERFLOW_SCROLLBARS_VERTICAL:
scrollX = NS_STYLE_OVERFLOW_HIDDEN;
scrollY = NS_STYLE_OVERFLOW_SCROLL;
break;
case NS_STYLE_OVERFLOW_VISIBLE:
scrollX = scrollY = NS_STYLE_OVERFLOW_AUTO;
break;
default:
pref.mHorizontal = overflow;
pref.mVertical = overflow;
scrollX = scrollY = scrolling;
break;
}
sc->SetDefaultScrollbarPreferences(nsIScrollable::ScrollOrientation_X,
ConvertOverflow(pref.mHorizontal));
sc->SetDefaultScrollbarPreferences(nsIScrollable::ScrollOrientation_Y,
ConvertOverflow(pref.mVertical));
scrollX);
sc->SetDefaultScrollbarPreferences(nsIScrollable::ScrollOrientation_X,
scrollY);
}
PRInt32 itemType = nsIDocShellTreeItem::typeContent;

Просмотреть файл

@ -45,7 +45,6 @@
#include "nsIServiceManager.h"
#include "nsIView.h"
#include "nsIScrollableView.h"
#include "nsIScrollable.h"
#include "nsIViewManager.h"
#include "nsHTMLContainerFrame.h"
#include "nsWidgetsCID.h"
@ -128,6 +127,20 @@ nsHTMLScrollFrame::ScrollTo(nsPresContext* aContext, nscoord aX, nscoord aY, PRU
return s->ScrollTo(aX, aY, aFlags);
}
/**
* Query whether scroll bars should be displayed all the time, never or
* only when necessary.
* @return current scrollbar selection
* XXX roc only 'Auto' is really tested for. This API should be simplified or
* eliminated.
*/
NS_IMETHODIMP
nsHTMLScrollFrame::GetScrollPreference(nsPresContext* aPresContext, nsScrollPref* aScrollPreference) const
{
*aScrollPreference = mInner.GetScrollPreference();
return NS_OK;
}
nsGfxScrollFrameInner::ScrollbarStyles
nsHTMLScrollFrame::GetScrollbarStyles() const {
return mInner.GetScrollbarStylesFromFrame();
@ -168,6 +181,16 @@ nsMargin nsHTMLScrollFrame::GetDesiredScrollbarSizes(nsBoxLayoutState* aState) {
return result;
}
NS_IMETHODIMP
nsHTMLScrollFrame::SetScrollbarVisibility(nsPresContext* aPresContext,
PRBool aVerticalVisible,
PRBool aHorizontalVisible)
{
mInner.mNeverHasVerticalScrollbar = !aVerticalVisible;
mInner.mNeverHasHorizontalScrollbar = !aHorizontalVisible;
return NS_OK;
}
NS_IMETHODIMP
nsHTMLScrollFrame::GetScrollbarBox(PRBool aVertical, nsIBox** aResult)
{
@ -644,6 +667,20 @@ nsXULScrollFrame::ScrollTo(nsPresContext* aContext, nscoord aX, nscoord aY, PRUi
return s->ScrollTo(aX, aY, aFlags);
}
/**
* Query whether scroll bars should be displayed all the time, never or
* only when necessary.
* @return current scrollbar selection
* XXX roc only 'Auto' is really tested for. This API should be simplified or
* eliminated.
*/
NS_IMETHODIMP
nsXULScrollFrame::GetScrollPreference(nsPresContext* aPresContext, nsScrollPref* aScrollPreference) const
{
*aScrollPreference = mInner.GetScrollPreference();
return NS_OK;
}
nsGfxScrollFrameInner::ScrollbarStyles
nsXULScrollFrame::GetScrollbarStyles() const {
return mInner.GetScrollbarStylesFromFrame();
@ -684,6 +721,16 @@ nsMargin nsXULScrollFrame::GetDesiredScrollbarSizes(nsBoxLayoutState* aState) {
return result;
}
NS_IMETHODIMP
nsXULScrollFrame::SetScrollbarVisibility(nsPresContext* aPresContext,
PRBool aVerticalVisible,
PRBool aHorizontalVisible)
{
mInner.mNeverHasVerticalScrollbar = !aVerticalVisible;
mInner.mNeverHasHorizontalScrollbar = !aHorizontalVisible;
return NS_OK;
}
NS_IMETHODIMP
nsXULScrollFrame::GetScrollbarBox(PRBool aVertical, nsIBox** aResult)
{
@ -1117,6 +1164,8 @@ nsGfxScrollFrameInner::nsGfxScrollFrameInner(nsBoxFrame* aOuter)
mOuter(aOuter),
mMaxElementWidth(0),
mLastDir(-1),
mNeverHasVerticalScrollbar(PR_FALSE),
mNeverHasHorizontalScrollbar(PR_FALSE),
mHasVerticalScrollbar(PR_FALSE),
mHasHorizontalScrollbar(PR_FALSE),
mFirstPass(PR_FALSE),
@ -1139,72 +1188,62 @@ 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
{
ScrollbarStyles result;
PRUint8 overflow;
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)) {
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);
overflow = mOuter->GetPresContext()->GetViewportOverflowOverride();
} else {
result = ConvertOverflow(mOuter->GetStyleDisplay()->mOverflow);
overflow = mOuter->GetStyleDisplay()->mOverflow;
}
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;
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);
}
}
nsIScrollableFrame::nsScrollPref
nsGfxScrollFrameInner::GetScrollPreference() const
{
nsCOMPtr<nsIScrollableFrame> scrollable =
do_QueryInterface(NS_STATIC_CAST(nsIFrame*, mOuter));
ScrollbarStyles styles = scrollable->GetScrollbarStyles();
if (styles.mHorizontal == NS_STYLE_OVERFLOW_SCROLL &&
styles.mVertical == NS_STYLE_OVERFLOW_SCROLL) {
return nsIScrollableFrame::AlwaysScroll;
} else if (styles.mHorizontal == NS_STYLE_OVERFLOW_SCROLL) {
return nsIScrollableFrame::AlwaysScrollHorizontal;
} else if (styles.mVertical == NS_STYLE_OVERFLOW_SCROLL) {
return nsIScrollableFrame::AlwaysScrollVertical;
} else if (styles.mHorizontal == NS_STYLE_OVERFLOW_AUTO ||
styles.mVertical == NS_STYLE_OVERFLOW_AUTO) {
return nsIScrollableFrame::Auto;
} else {
return nsIScrollableFrame::NeverScroll;
}
}
void
@ -1275,31 +1314,45 @@ nsGfxScrollFrameInner::CreateAnonymousContent(nsISupportsArray& aAnonymousChildr
// allow scrollbars if this is the child of the viewport, because
// we must be the scrollbars for the print preview window
if (!parent || parent->GetType() != nsLayoutAtoms::viewportFrame) {
// If we just return early here, we'll never create content or
// frames an |mHScrollbarBox| and |mVScrollbarBox| will always be
// null.
mNeverHasVerticalScrollbar = mNeverHasHorizontalScrollbar = PR_TRUE;
return;
}
}
nsIScrollableFrame *scrollable;
CallQueryInterface(mOuter, &scrollable);
nsIPresShell *shell = presContext->GetPresShell();
nsIDocument *document = nsnull;
if (shell)
document = shell->GetDocument();
ScrollbarStyles styles = scrollable->GetScrollbarStyles();
PRBool canHaveHorizontal = styles.mHorizontal != NS_STYLE_OVERFLOW_HIDDEN;
PRBool canHaveVertical = styles.mVertical != NS_STYLE_OVERFLOW_HIDDEN;
if (!canHaveHorizontal && !canHaveVertical)
// Nothing to do.
// The anonymous <div> used by <inputs> never gets scrollbars.
nsCOMPtr<nsITextControlFrame> textFrame(do_QueryInterface(parent));
if (textFrame) {
// Make sure we are not a text area.
nsCOMPtr<nsIDOMHTMLTextAreaElement> textAreaElement(do_QueryInterface(parent->GetContent()));
if (!textAreaElement) {
mNeverHasVerticalScrollbar = mNeverHasHorizontalScrollbar = PR_TRUE;
return;
}
}
// create horizontal scrollbar
if (!document) {
return;
}
nsNodeInfoManager *nodeInfoManager = document->NodeInfoManager();
nsNodeInfoManager *nodeInfoManager =
presContext->GetDocument()->NodeInfoManager();
nsCOMPtr<nsINodeInfo> nodeInfo;
nodeInfoManager->GetNodeInfo(nsXULAtoms::scrollbar, nsnull,
kNameSpaceID_XUL, getter_AddRefs(nodeInfo));
nsCOMPtr<nsIContent> content;
nsCOMPtr<nsIScrollableFrame> scrollable =
do_QueryInterface(NS_STATIC_CAST(nsIFrame*, mOuter));
ScrollbarStyles styles = scrollable->GetScrollbarStyles();
PRBool canHaveHorizontal = styles.mHorizontal == NS_STYLE_OVERFLOW_AUTO
|| styles.mHorizontal == NS_STYLE_OVERFLOW_SCROLL;
if (canHaveHorizontal) {
NS_NewElement(getter_AddRefs(content), kNameSpaceID_XUL, nodeInfo);
content->SetAttr(kNameSpaceID_None, nsXULAtoms::orient,
@ -1307,6 +1360,8 @@ nsGfxScrollFrameInner::CreateAnonymousContent(nsISupportsArray& aAnonymousChildr
aAnonymousChildren.AppendElement(content);
}
PRBool canHaveVertical = styles.mVertical == NS_STYLE_OVERFLOW_AUTO
|| styles.mVertical == NS_STYLE_OVERFLOW_SCROLL;
if (canHaveVertical) {
NS_NewElement(getter_AddRefs(content), kNameSpaceID_XUL, nodeInfo);
content->SetAttr(kNameSpaceID_None, nsXULAtoms::orient,
@ -1562,7 +1617,7 @@ PRBool
nsGfxScrollFrameInner::AddRemoveScrollbar(nsBoxLayoutState& aState, nsRect& aScrollAreaSize, PRBool aOnTop, PRBool aHorizontal, PRBool aAdd)
{
if (aHorizontal) {
if (!mHScrollbarBox)
if (mNeverHasHorizontalScrollbar || !mHScrollbarBox)
return PR_FALSE;
nsSize hSize;
@ -1579,7 +1634,7 @@ nsGfxScrollFrameInner::AddRemoveScrollbar(nsBoxLayoutState& aState, nsRect& aScr
return fit;
} else {
if (!mVScrollbarBox)
if (mNeverHasVerticalScrollbar || !mVScrollbarBox)
return PR_FALSE;
nsSize vSize;
@ -1752,8 +1807,8 @@ nsGfxScrollFrameInner::Layout(nsBoxLayoutState& aState)
(if we're the viewport and we added or removed a scrollbar).
**************/
nsIScrollableFrame *scrollableFrame;
CallQueryInterface(mOuter, &scrollableFrame);
nsCOMPtr<nsIScrollableFrame> scrollableFrame =
do_QueryInterface(NS_STATIC_CAST(nsIFrame*, mOuter));
ScrollbarStyles styles = scrollableFrame->GetScrollbarStyles();
// Look at our style do we always have vertical or horizontal scrollbars?

Просмотреть файл

@ -63,6 +63,8 @@ public:
typedef nsIScrollableFrame::ScrollbarStyles ScrollbarStyles;
ScrollbarStyles GetScrollbarStylesFromFrame() const;
nsIScrollableFrame::nsScrollPref GetScrollPreference() const;
// If a child frame was added or removed on the scrollframe,
// reload our child frame list.
// We need this if a scrollbar frame is recreated.
@ -244,12 +246,18 @@ public:
NS_IMETHOD GetScrollPosition(nsPresContext* aContext, nscoord &aX, nscoord& aY) const;
NS_IMETHOD ScrollTo(nsPresContext* aContext, nscoord aX, nscoord aY, PRUint32 aFlags);
NS_IMETHOD SetScrollbarVisibility(nsPresContext* aPresContext,
PRBool aVerticalVisible,
PRBool aHorizontalVisible);
NS_IMETHOD GetScrollbarBox(PRBool aVertical, nsIBox** aResult);
NS_IMETHOD CurPosAttributeChanged(nsPresContext* aPresContext,
nsIContent* aChild,
PRInt32 aModType);
NS_IMETHOD GetScrollPreference(nsPresContext* aPresContext, nsScrollPref* aScrollPreference) const;
virtual void ScrollToRestoredPosition() {
mInner.ScrollToRestoredPosition();
}
@ -369,12 +377,18 @@ public:
NS_IMETHOD GetScrollPosition(nsPresContext* aContext, nscoord &aX, nscoord& aY) const;
NS_IMETHOD ScrollTo(nsPresContext* aContext, nscoord aX, nscoord aY, PRUint32 aFlags);
NS_IMETHOD SetScrollbarVisibility(nsPresContext* aPresContext,
PRBool aVerticalVisible,
PRBool aHorizontalVisible);
NS_IMETHOD GetScrollbarBox(PRBool aVertical, nsIBox** aResult);
NS_IMETHOD CurPosAttributeChanged(nsPresContext* aPresContext,
nsIContent* aChild,
PRInt32 aModType);
NS_IMETHOD GetScrollPreference(nsPresContext* aPresContext, nsScrollPref* aScrollPreference) const;
virtual void ScrollToRestoredPosition() {
mInner.ScrollToRestoredPosition();
}

Просмотреть файл

@ -42,10 +42,10 @@
#include "nsCoord.h"
#include "nsIViewManager.h"
#include "nsIScrollableViewProvider.h"
#include "nsPresContext.h"
class nsIFrame;
class nsIBox;
class nsPresContext;
class nsBoxLayoutState;
// IID for the nsIScrollableFrame interface
@ -56,6 +56,14 @@ class nsBoxLayoutState;
class nsIScrollableFrame : public nsIScrollableViewProvider {
public:
enum nsScrollPref {
Auto = 0,
NeverScroll,
AlwaysScroll,
AlwaysScrollVertical,
AlwaysScrollHorizontal
};
NS_DEFINE_STATIC_IID_ACCESSOR(NS_ISCROLLABLE_FRAME_IID)
/**
@ -65,7 +73,13 @@ public:
NS_IMETHOD GetScrolledFrame(nsPresContext* aPresContext,
nsIFrame *&aScrolledFrame) const = 0;
typedef nsPresContext::ScrollbarStyles ScrollbarStyles;
struct ScrollbarStyles {
// one of NS_STYLE_OVERFLOW_SCROLL, NS_STYLE_OVERFLOW_HIDDEN,
// NS_STYLE_OVERFLOW_VISIBLE, NS_STYLE_OVERFLOW_AUTO
PRInt32 mHorizontal;
PRInt32 mVertical;
ScrollbarStyles(PRInt32 h, PRInt32 v) : mHorizontal(h), mVertical(v) {}
};
virtual ScrollbarStyles GetScrollbarStyles() const = 0;
@ -81,6 +95,13 @@ public:
*/
virtual nsMargin GetDesiredScrollbarSizes(nsBoxLayoutState* aState) = 0;
/**
* Query whether scroll bars should be displayed all the time, never or
* only when necessary.
* @return current scrollbar selection
*/
NS_IMETHOD GetScrollPreference(nsPresContext* aPresContext, nsScrollPref* aScrollPreference) const = 0;
/**
* Get the position of the scrolled view.
*/
@ -99,6 +120,15 @@ public:
NS_IMETHOD GetScrollableView(nsPresContext* aContext, nsIScrollableView** aResult)=0;
/**
* Set information about whether the vertical and horizontal scrollbars
* are currently visible
*/
NS_IMETHOD SetScrollbarVisibility(nsPresContext* aPresContext,
PRBool aVerticalVisible,
PRBool aHorizontalVisible) = 0;
NS_IMETHOD GetScrollbarBox(PRBool aVertical, nsIBox** aResult) = 0;
NS_IMETHOD CurPosAttributeChanged(nsPresContext* aPresContext,

Просмотреть файл

@ -4269,7 +4269,8 @@ nsFrame::ConsiderChildOverflow(nsPresContext* aPresContext,
const nsStyleDisplay* disp = GetStyleDisplay();
// check here also for hidden as table frames (table, tr and td) currently
// don't wrap their content into a scrollable frame if overflow is specified
if (!disp->IsTableClip()) {
if (NS_STYLE_OVERFLOW_CLIP != disp->mOverflow &&
NS_STYLE_OVERFLOW_HIDDEN != disp->mOverflow) {
nsRect* overflowArea = aChildFrame->GetOverflowAreaProperty();
if (overflowArea) {
nsRect childOverflow(*overflowArea);

Просмотреть файл

@ -45,7 +45,6 @@
#include "nsIServiceManager.h"
#include "nsIView.h"
#include "nsIScrollableView.h"
#include "nsIScrollable.h"
#include "nsIViewManager.h"
#include "nsHTMLContainerFrame.h"
#include "nsWidgetsCID.h"
@ -128,6 +127,20 @@ nsHTMLScrollFrame::ScrollTo(nsPresContext* aContext, nscoord aX, nscoord aY, PRU
return s->ScrollTo(aX, aY, aFlags);
}
/**
* Query whether scroll bars should be displayed all the time, never or
* only when necessary.
* @return current scrollbar selection
* XXX roc only 'Auto' is really tested for. This API should be simplified or
* eliminated.
*/
NS_IMETHODIMP
nsHTMLScrollFrame::GetScrollPreference(nsPresContext* aPresContext, nsScrollPref* aScrollPreference) const
{
*aScrollPreference = mInner.GetScrollPreference();
return NS_OK;
}
nsGfxScrollFrameInner::ScrollbarStyles
nsHTMLScrollFrame::GetScrollbarStyles() const {
return mInner.GetScrollbarStylesFromFrame();
@ -168,6 +181,16 @@ nsMargin nsHTMLScrollFrame::GetDesiredScrollbarSizes(nsBoxLayoutState* aState) {
return result;
}
NS_IMETHODIMP
nsHTMLScrollFrame::SetScrollbarVisibility(nsPresContext* aPresContext,
PRBool aVerticalVisible,
PRBool aHorizontalVisible)
{
mInner.mNeverHasVerticalScrollbar = !aVerticalVisible;
mInner.mNeverHasHorizontalScrollbar = !aHorizontalVisible;
return NS_OK;
}
NS_IMETHODIMP
nsHTMLScrollFrame::GetScrollbarBox(PRBool aVertical, nsIBox** aResult)
{
@ -644,6 +667,20 @@ nsXULScrollFrame::ScrollTo(nsPresContext* aContext, nscoord aX, nscoord aY, PRUi
return s->ScrollTo(aX, aY, aFlags);
}
/**
* Query whether scroll bars should be displayed all the time, never or
* only when necessary.
* @return current scrollbar selection
* XXX roc only 'Auto' is really tested for. This API should be simplified or
* eliminated.
*/
NS_IMETHODIMP
nsXULScrollFrame::GetScrollPreference(nsPresContext* aPresContext, nsScrollPref* aScrollPreference) const
{
*aScrollPreference = mInner.GetScrollPreference();
return NS_OK;
}
nsGfxScrollFrameInner::ScrollbarStyles
nsXULScrollFrame::GetScrollbarStyles() const {
return mInner.GetScrollbarStylesFromFrame();
@ -684,6 +721,16 @@ nsMargin nsXULScrollFrame::GetDesiredScrollbarSizes(nsBoxLayoutState* aState) {
return result;
}
NS_IMETHODIMP
nsXULScrollFrame::SetScrollbarVisibility(nsPresContext* aPresContext,
PRBool aVerticalVisible,
PRBool aHorizontalVisible)
{
mInner.mNeverHasVerticalScrollbar = !aVerticalVisible;
mInner.mNeverHasHorizontalScrollbar = !aHorizontalVisible;
return NS_OK;
}
NS_IMETHODIMP
nsXULScrollFrame::GetScrollbarBox(PRBool aVertical, nsIBox** aResult)
{
@ -1117,6 +1164,8 @@ nsGfxScrollFrameInner::nsGfxScrollFrameInner(nsBoxFrame* aOuter)
mOuter(aOuter),
mMaxElementWidth(0),
mLastDir(-1),
mNeverHasVerticalScrollbar(PR_FALSE),
mNeverHasHorizontalScrollbar(PR_FALSE),
mHasVerticalScrollbar(PR_FALSE),
mHasHorizontalScrollbar(PR_FALSE),
mFirstPass(PR_FALSE),
@ -1139,72 +1188,62 @@ 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
{
ScrollbarStyles result;
PRUint8 overflow;
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)) {
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);
overflow = mOuter->GetPresContext()->GetViewportOverflowOverride();
} else {
result = ConvertOverflow(mOuter->GetStyleDisplay()->mOverflow);
overflow = mOuter->GetStyleDisplay()->mOverflow;
}
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;
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);
}
}
nsIScrollableFrame::nsScrollPref
nsGfxScrollFrameInner::GetScrollPreference() const
{
nsCOMPtr<nsIScrollableFrame> scrollable =
do_QueryInterface(NS_STATIC_CAST(nsIFrame*, mOuter));
ScrollbarStyles styles = scrollable->GetScrollbarStyles();
if (styles.mHorizontal == NS_STYLE_OVERFLOW_SCROLL &&
styles.mVertical == NS_STYLE_OVERFLOW_SCROLL) {
return nsIScrollableFrame::AlwaysScroll;
} else if (styles.mHorizontal == NS_STYLE_OVERFLOW_SCROLL) {
return nsIScrollableFrame::AlwaysScrollHorizontal;
} else if (styles.mVertical == NS_STYLE_OVERFLOW_SCROLL) {
return nsIScrollableFrame::AlwaysScrollVertical;
} else if (styles.mHorizontal == NS_STYLE_OVERFLOW_AUTO ||
styles.mVertical == NS_STYLE_OVERFLOW_AUTO) {
return nsIScrollableFrame::Auto;
} else {
return nsIScrollableFrame::NeverScroll;
}
}
void
@ -1275,31 +1314,45 @@ nsGfxScrollFrameInner::CreateAnonymousContent(nsISupportsArray& aAnonymousChildr
// allow scrollbars if this is the child of the viewport, because
// we must be the scrollbars for the print preview window
if (!parent || parent->GetType() != nsLayoutAtoms::viewportFrame) {
// If we just return early here, we'll never create content or
// frames an |mHScrollbarBox| and |mVScrollbarBox| will always be
// null.
mNeverHasVerticalScrollbar = mNeverHasHorizontalScrollbar = PR_TRUE;
return;
}
}
nsIScrollableFrame *scrollable;
CallQueryInterface(mOuter, &scrollable);
nsIPresShell *shell = presContext->GetPresShell();
nsIDocument *document = nsnull;
if (shell)
document = shell->GetDocument();
ScrollbarStyles styles = scrollable->GetScrollbarStyles();
PRBool canHaveHorizontal = styles.mHorizontal != NS_STYLE_OVERFLOW_HIDDEN;
PRBool canHaveVertical = styles.mVertical != NS_STYLE_OVERFLOW_HIDDEN;
if (!canHaveHorizontal && !canHaveVertical)
// Nothing to do.
// The anonymous <div> used by <inputs> never gets scrollbars.
nsCOMPtr<nsITextControlFrame> textFrame(do_QueryInterface(parent));
if (textFrame) {
// Make sure we are not a text area.
nsCOMPtr<nsIDOMHTMLTextAreaElement> textAreaElement(do_QueryInterface(parent->GetContent()));
if (!textAreaElement) {
mNeverHasVerticalScrollbar = mNeverHasHorizontalScrollbar = PR_TRUE;
return;
}
}
// create horizontal scrollbar
if (!document) {
return;
}
nsNodeInfoManager *nodeInfoManager = document->NodeInfoManager();
nsNodeInfoManager *nodeInfoManager =
presContext->GetDocument()->NodeInfoManager();
nsCOMPtr<nsINodeInfo> nodeInfo;
nodeInfoManager->GetNodeInfo(nsXULAtoms::scrollbar, nsnull,
kNameSpaceID_XUL, getter_AddRefs(nodeInfo));
nsCOMPtr<nsIContent> content;
nsCOMPtr<nsIScrollableFrame> scrollable =
do_QueryInterface(NS_STATIC_CAST(nsIFrame*, mOuter));
ScrollbarStyles styles = scrollable->GetScrollbarStyles();
PRBool canHaveHorizontal = styles.mHorizontal == NS_STYLE_OVERFLOW_AUTO
|| styles.mHorizontal == NS_STYLE_OVERFLOW_SCROLL;
if (canHaveHorizontal) {
NS_NewElement(getter_AddRefs(content), kNameSpaceID_XUL, nodeInfo);
content->SetAttr(kNameSpaceID_None, nsXULAtoms::orient,
@ -1307,6 +1360,8 @@ nsGfxScrollFrameInner::CreateAnonymousContent(nsISupportsArray& aAnonymousChildr
aAnonymousChildren.AppendElement(content);
}
PRBool canHaveVertical = styles.mVertical == NS_STYLE_OVERFLOW_AUTO
|| styles.mVertical == NS_STYLE_OVERFLOW_SCROLL;
if (canHaveVertical) {
NS_NewElement(getter_AddRefs(content), kNameSpaceID_XUL, nodeInfo);
content->SetAttr(kNameSpaceID_None, nsXULAtoms::orient,
@ -1562,7 +1617,7 @@ PRBool
nsGfxScrollFrameInner::AddRemoveScrollbar(nsBoxLayoutState& aState, nsRect& aScrollAreaSize, PRBool aOnTop, PRBool aHorizontal, PRBool aAdd)
{
if (aHorizontal) {
if (!mHScrollbarBox)
if (mNeverHasHorizontalScrollbar || !mHScrollbarBox)
return PR_FALSE;
nsSize hSize;
@ -1579,7 +1634,7 @@ nsGfxScrollFrameInner::AddRemoveScrollbar(nsBoxLayoutState& aState, nsRect& aScr
return fit;
} else {
if (!mVScrollbarBox)
if (mNeverHasVerticalScrollbar || !mVScrollbarBox)
return PR_FALSE;
nsSize vSize;
@ -1752,8 +1807,8 @@ nsGfxScrollFrameInner::Layout(nsBoxLayoutState& aState)
(if we're the viewport and we added or removed a scrollbar).
**************/
nsIScrollableFrame *scrollableFrame;
CallQueryInterface(mOuter, &scrollableFrame);
nsCOMPtr<nsIScrollableFrame> scrollableFrame =
do_QueryInterface(NS_STATIC_CAST(nsIFrame*, mOuter));
ScrollbarStyles styles = scrollableFrame->GetScrollbarStyles();
// Look at our style do we always have vertical or horizontal scrollbars?

Просмотреть файл

@ -63,6 +63,8 @@ public:
typedef nsIScrollableFrame::ScrollbarStyles ScrollbarStyles;
ScrollbarStyles GetScrollbarStylesFromFrame() const;
nsIScrollableFrame::nsScrollPref GetScrollPreference() const;
// If a child frame was added or removed on the scrollframe,
// reload our child frame list.
// We need this if a scrollbar frame is recreated.
@ -244,12 +246,18 @@ public:
NS_IMETHOD GetScrollPosition(nsPresContext* aContext, nscoord &aX, nscoord& aY) const;
NS_IMETHOD ScrollTo(nsPresContext* aContext, nscoord aX, nscoord aY, PRUint32 aFlags);
NS_IMETHOD SetScrollbarVisibility(nsPresContext* aPresContext,
PRBool aVerticalVisible,
PRBool aHorizontalVisible);
NS_IMETHOD GetScrollbarBox(PRBool aVertical, nsIBox** aResult);
NS_IMETHOD CurPosAttributeChanged(nsPresContext* aPresContext,
nsIContent* aChild,
PRInt32 aModType);
NS_IMETHOD GetScrollPreference(nsPresContext* aPresContext, nsScrollPref* aScrollPreference) const;
virtual void ScrollToRestoredPosition() {
mInner.ScrollToRestoredPosition();
}
@ -369,12 +377,18 @@ public:
NS_IMETHOD GetScrollPosition(nsPresContext* aContext, nscoord &aX, nscoord& aY) const;
NS_IMETHOD ScrollTo(nsPresContext* aContext, nscoord aX, nscoord aY, PRUint32 aFlags);
NS_IMETHOD SetScrollbarVisibility(nsPresContext* aPresContext,
PRBool aVerticalVisible,
PRBool aHorizontalVisible);
NS_IMETHOD GetScrollbarBox(PRBool aVertical, nsIBox** aResult);
NS_IMETHOD CurPosAttributeChanged(nsPresContext* aPresContext,
nsIContent* aChild,
PRInt32 aModType);
NS_IMETHOD GetScrollPreference(nsPresContext* aPresContext, nsScrollPref* aScrollPreference) const;
virtual void ScrollToRestoredPosition() {
mInner.ScrollToRestoredPosition();
}

Просмотреть файл

@ -98,6 +98,10 @@ input {
text-indent: 0;
}
input > .anonymous-div {
white-space : nowrap;
}
textarea {
margin: 1px 0 1px 0;
border: 2px inset ThreeDFace;
@ -114,7 +118,6 @@ textarea {
-moz-binding: url("resource://gre/res/builtin/platformHTMLBindings.xml#textAreas");
-moz-appearance: textfield;
text-indent: 0;
overflow: auto;
}
textarea > scrollbar {
@ -133,11 +136,6 @@ input > .anonymous-div {
text-decoration: inherit;
}
input > .anonymous-div {
white-space : nowrap;
overflow: hidden ! important;
}
select {
margin: 0;
border-color: ThreeDFace;

Просмотреть файл

@ -617,20 +617,6 @@ nsSubDocumentFrame::GetDocShell(nsIDocShell **aDocShell)
return mFrameLoader->GetDocShell(aDocShell);
}
inline PRInt32 ConvertOverflow(PRUint8 aOverflow)
{
switch (aOverflow) {
case NS_STYLE_OVERFLOW_VISIBLE:
case NS_STYLE_OVERFLOW_AUTO:
return nsIScrollable::Scrollbar_Auto;
case NS_STYLE_OVERFLOW_HIDDEN:
case NS_STYLE_OVERFLOW_CLIP:
return nsIScrollable::Scrollbar_Never;
case NS_STYLE_OVERFLOW_SCROLL:
return nsIScrollable::Scrollbar_Always;
}
}
nsresult
nsSubDocumentFrame::ShowDocShell()
{
@ -659,25 +645,33 @@ nsSubDocumentFrame::ShowDocShell()
nsCOMPtr<nsIScrollable> sc(do_QueryInterface(docShell));
if (sc) {
nsPresContext::ScrollbarStyles pref;
PRUint8 overflow = GetStyleDisplay()->mOverflow;
switch (overflow) {
case NS_STYLE_OVERFLOW_SCROLLBARS_VERTICAL:
pref.mHorizontal = NS_STYLE_OVERFLOW_HIDDEN;
pref.mVertical = NS_STYLE_OVERFLOW_SCROLL;
PRInt32 scrolling = GetStyleDisplay()->mOverflow;
PRInt32 scrollX, scrollY;
switch (scrolling) {
case NS_STYLE_OVERFLOW_CLIP:
scrollX = NS_STYLE_OVERFLOW_HIDDEN;
scrollY = NS_STYLE_OVERFLOW_HIDDEN;
break;
case NS_STYLE_OVERFLOW_SCROLLBARS_HORIZONTAL:
pref.mHorizontal = NS_STYLE_OVERFLOW_SCROLL;
pref.mVertical = NS_STYLE_OVERFLOW_HIDDEN;
scrollX = NS_STYLE_OVERFLOW_SCROLL;
scrollY = NS_STYLE_OVERFLOW_HIDDEN;
break;
case NS_STYLE_OVERFLOW_SCROLLBARS_VERTICAL:
scrollX = NS_STYLE_OVERFLOW_HIDDEN;
scrollY = NS_STYLE_OVERFLOW_SCROLL;
break;
case NS_STYLE_OVERFLOW_VISIBLE:
scrollX = scrollY = NS_STYLE_OVERFLOW_AUTO;
break;
default:
pref.mHorizontal = overflow;
pref.mVertical = overflow;
scrollX = scrollY = scrolling;
break;
}
sc->SetDefaultScrollbarPreferences(nsIScrollable::ScrollOrientation_X,
ConvertOverflow(pref.mHorizontal));
sc->SetDefaultScrollbarPreferences(nsIScrollable::ScrollOrientation_Y,
ConvertOverflow(pref.mVertical));
scrollX);
sc->SetDefaultScrollbarPreferences(nsIScrollable::ScrollOrientation_X,
scrollY);
}
PRInt32 itemType = nsIDocShellTreeItem::typeContent;

Просмотреть файл

@ -1637,7 +1637,8 @@ nsTextControlFrame::CreateAnonymousContent(nsPresContext* aPresContext,
// setting -moz-hidden-unscrollable overflow (NS_STYLE_OVERFLOW_CLIP)
// doesn't paint the caret for some reason.
const nsStyleDisplay* disp = GetStyleDisplay();
if (disp->mOverflow != NS_STYLE_OVERFLOW_VISIBLE &&
if (disp->mOverflow != NS_STYLE_OVERFLOW_AUTO && // this is the default
disp->mOverflow != NS_STYLE_OVERFLOW_VISIBLE &&
disp->mOverflow != NS_STYLE_OVERFLOW_CLIP) {
rv = divContent->SetAttr(kNameSpaceID_None, nsHTMLAtoms::style,
NS_LITERAL_STRING("overflow: inherit;"),
@ -2996,6 +2997,16 @@ nsTextControlFrame::SetInitialChildList(nsPresContext* aPresContext,
// than descending from the root frame of the frame hierarchy.
first->AddStateBits(NS_FRAME_REFLOW_ROOT);
//we must turn off scrollbars for singleline text controls
if (IsSingleLineTextControl())
{
nsIScrollableFrame *scrollableFrame = nsnull;
if (first)
first->QueryInterface(NS_GET_IID(nsIScrollableFrame), (void **) &scrollableFrame);
if (scrollableFrame)
scrollableFrame->SetScrollbarVisibility(aPresContext,PR_FALSE,PR_FALSE);
}
//register keylistener
nsCOMPtr<nsIDOMEventReceiver> erP;
if (NS_SUCCEEDED(mContent->QueryInterface(NS_GET_IID(nsIDOMEventReceiver), getter_AddRefs(erP))) && erP)

Просмотреть файл

@ -2708,7 +2708,7 @@ nsCSSFrameConstructor::ConstructTableRowGroupFrame(nsIPresShell* aPre
rv = aTableCreator.CreateTableRowGroupFrame(&aNewFrame);
nsIFrame* scrollFrame = nsnull;
if (styleDisplay->IsScrollableOverflow()) {
if (IsScrollable(aPresContext, styleDisplay)) {
// Create an area container for the frame
BuildScrollFrame(aPresShell, aPresContext, aState, aContent, aStyleContext,
aNewFrame, parentFrame, nsnull, scrollFrame, aStyleContext);
@ -3341,19 +3341,6 @@ nsCSSFrameConstructor::ConstructDocElementTableFrame(nsIPresShell* aPresS
return NS_OK;
}
static PRBool CheckOverflow(nsPresContext* aPresContext,
const nsStyleDisplay* aDisplay)
{
if (aDisplay->mOverflow == NS_STYLE_OVERFLOW_VISIBLE)
return PR_FALSE;
if (aDisplay->mOverflow == NS_STYLE_OVERFLOW_CLIP)
aPresContext->SetViewportOverflowOverride(NS_STYLE_OVERFLOW_HIDDEN);
else
aPresContext->SetViewportOverflowOverride(aDisplay->mOverflow);
return PR_TRUE;
}
/**
* This checks the root element and the HTML BODY, if any, for an "overflow" property
* that should be applied to the viewport. If one is found then we return the
@ -3379,12 +3366,14 @@ nsCSSFrameConstructor::PropagateScrollToViewport(nsPresContext* aPresContext)
// Check the style on the document root element
nsStyleSet *styleSet = aPresContext->PresShell()->StyleSet();
nsRefPtr<nsStyleContext> rootStyle;
rootStyle = styleSet->ResolveStyleFor(docElement, nsnull);
if (!rootStyle) {
nsRefPtr<nsStyleContext> styleContext;
styleContext = styleSet->ResolveStyleFor(docElement, nsnull);
if (!styleContext) {
return nsnull;
}
if (CheckOverflow(aPresContext, rootStyle->GetStyleDisplay())) {
const nsStyleDisplay* display = styleContext->GetStyleDisplay();
if (display->mOverflow != NS_STYLE_OVERFLOW_VISIBLE) {
aPresContext->SetViewportOverflowOverride(display->mOverflow);
// tell caller we stole the overflow style from the root element
return docElement;
}
@ -3410,13 +3399,15 @@ nsCSSFrameConstructor::PropagateScrollToViewport(nsPresContext* aPresContext)
return nsnull;
}
nsRefPtr<nsStyleContext> bodyStyle;
bodyStyle = styleSet->ResolveStyleFor(bodyElement, rootStyle);
if (!bodyStyle) {
nsRefPtr<nsStyleContext> bodyContext;
bodyContext = styleSet->ResolveStyleFor(bodyElement, styleContext);
if (!bodyContext) {
return nsnull;
}
if (CheckOverflow(aPresContext, bodyStyle->GetStyleDisplay())) {
display = bodyContext->GetStyleDisplay();
if (display->mOverflow != NS_STYLE_OVERFLOW_VISIBLE) {
aPresContext->SetViewportOverflowOverride(display->mOverflow);
// tell caller we stole the overflow style from the body element
return bodyElement;
}
@ -3530,7 +3521,7 @@ nsCSSFrameConstructor::ConstructDocElementFrame(nsIPresShell* aPresShell,
// The document root should not be scrollable in any paginated context,
// even in print preview.
PRBool isScrollable = display->IsScrollableOverflow()
PRBool isScrollable = IsScrollable(aPresContext, display)
&& !aPresContext->IsPaginated()
&& !propagatedScrollToViewport;
@ -3805,6 +3796,7 @@ 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;
@ -3817,6 +3809,8 @@ 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;
@ -3826,13 +3820,28 @@ nsCSSFrameConstructor::ConstructRootFrame(nsIPresShell* aPresShell,
}
// Never create scrollbars for XUL documents
PRBool isScrollable = !isXUL;
// Never create scrollbars for frameset documents.
if (isHTML) {
nsCOMPtr<nsIHTMLDocument> htmlDoc = do_QueryInterface(mDocument);
if (htmlDoc && htmlDoc->GetIsFrameset())
isScrollable = PR_FALSE;
#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 (NS_STYLE_OVERFLOW_HIDDEN == scrolling) {
isScrollable = PR_FALSE;
}
// XXX NS_STYLE_OVERFLOW_SCROLL should create 'always on' scrollbars
}
}
}
}
if (isPaginated) {
@ -5471,7 +5480,7 @@ nsCSSFrameConstructor::ConstructXULFrame(nsIPresShell* aPresShell,
}
// Boxes can scroll.
if (display->IsScrollableOverflow()) {
if (IsScrollable(aPresContext, display)) {
nsIFrame* scrollPort = nsnull;
if (listboxScrollPort) {
@ -5571,7 +5580,7 @@ nsCSSFrameConstructor::ConstructXULFrame(nsIPresShell* aPresShell,
#endif
}
if (mayBeScrollable && display->IsScrollableOverflow()) {
if (mayBeScrollable && IsScrollable(aPresContext, display)) {
// set the top to be the newly created scrollframe
BuildScrollFrame(aPresShell, aPresContext, aState, aContent,
aStyleContext, newFrame, aParentFrame, nsnull,
@ -6079,7 +6088,7 @@ nsCSSFrameConstructor::ConstructFrameByDisplayType(nsIPresShell* aPre
// XXX Ignore tables for the time being
if (aDisplay->IsBlockLevel() &&
aDisplay->mDisplay != NS_STYLE_DISPLAY_TABLE &&
aDisplay->IsScrollableOverflow() &&
IsScrollable(aPresContext, aDisplay) &&
!propagatedScrollToViewport) {
if (!pseudoParent && !aState.mPseudoFrames.IsEmpty()) { // process pending pseudo frames
@ -6485,6 +6494,25 @@ nsCSSFrameConstructor::ConstructFrameByDisplayType(nsIPresShell* aPre
return rv;
}
PRBool
nsCSSFrameConstructor::IsScrollable(nsPresContext* aPresContext,
const nsStyleDisplay* aDisplay)
{
// For the time being it's scrollable if the overflow property is auto or
// scroll, regardless of whether the width or height is fixed in size
switch (aDisplay->mOverflow) {
case NS_STYLE_OVERFLOW_SCROLL:
case NS_STYLE_OVERFLOW_AUTO:
case NS_STYLE_OVERFLOW_HIDDEN:
case NS_STYLE_OVERFLOW_SCROLLBARS_HORIZONTAL:
case NS_STYLE_OVERFLOW_SCROLLBARS_VERTICAL:
return PR_TRUE;
}
return PR_FALSE;
}
nsresult
nsCSSFrameConstructor::InitAndRestoreFrame(nsPresContext* aPresContext,
nsFrameConstructorState& aState,

Просмотреть файл

@ -685,6 +685,8 @@ private:
nsIContent* aChild,
nsIDOMHTMLSelectElement* aSelectElement);
PRBool IsScrollable(nsPresContext* aPresContext, const nsStyleDisplay* aDisplay);
nsIFrame* GetFrameFor(nsIPresShell* aPresShell,
nsPresContext* aPresContext,
nsIContent* aContent);

Просмотреть файл

@ -432,9 +432,10 @@ nsTableCellFrame::Paint(nsPresContext* aPresContext,
nsClipCombine_kIntersect);
}
else {
// XXXldb HIDDEN should really create a scrollframe,
// but use |IsTableClip| here since it doesn't.
if (disp->IsTableClip() ||
if (NS_STYLE_OVERFLOW_CLIP == disp->mOverflow ||
// XXXldb HIDDEN should really create a scrollframe,
// but test here since it doesn't.
NS_STYLE_OVERFLOW_HIDDEN == disp->mOverflow ||
HasPctOverHeight()) {
aRenderingContext.PushState();
pushed = PR_TRUE;

Просмотреть файл

@ -1360,8 +1360,11 @@ nsTableFrame::PaintChildren(nsPresContext* aPresContext,
const nsRect& aDirtyRect,
nsFramePaintLayer aWhichLayer,
PRUint32 aFlags)
{
PRBool clip = GetStyleDisplay()->IsTableClip();
PRUint8 overflow = GetStyleDisplay()->mOverflow;
PRBool clip = overflow == NS_STYLE_OVERFLOW_CLIP ||
overflow == NS_STYLE_OVERFLOW_HIDDEN;
// If overflow is hidden then set the clip rect so that children don't
// leak out of us. Note that because overflow'-clip' only applies to
// the content area we do this after painting the border and background
@ -2073,7 +2076,7 @@ NS_METHOD nsTableFrame::Reflow(nsPresContext* aPresContext,
if (aDesiredSize.mFlags & NS_REFLOW_CALC_MAX_WIDTH) {
aDesiredSize.mMaximumWidth = GetPreferredWidth();
}
if (!aReflowState.mStyleDisplay->IsTableClip()) {
if (NS_STYLE_OVERFLOW_CLIP != aReflowState.mStyleDisplay->mOverflow) {
// collapsed border may leak out
nsMargin bcMargin = GetBCMargin(aPresContext);
nsRect tableRect(0, 0, aDesiredSize.width, aDesiredSize.height) ;

Просмотреть файл

@ -333,7 +333,9 @@ nsTableOuterFrame::Paint(nsPresContext* aPresContext,
// If overflow is hidden then set the clip rect so that children
// don't leak out of us
PRBool clip = GetStyleDisplay()->IsTableClip();
PRUint8 overflow = GetStyleDisplay()->mOverflow;
PRBool clip = overflow == NS_STYLE_OVERFLOW_CLIP ||
overflow == NS_STYLE_OVERFLOW_HIDDEN;
if (clip) {
aRenderingContext.PushState();
SetOverflowClipRect(aRenderingContext);

Просмотреть файл

@ -555,7 +555,9 @@ NS_METHOD nsTableRowFrame::Paint(nsPresContext* aPresContext,
aFlags |= NS_PAINT_FLAG_TABLE_BG_PAINT;
}
PRBool clip = GetStyleDisplay()->IsTableClip();
PRUint8 overflow = GetStyleDisplay()->mOverflow;
PRBool clip = overflow == NS_STYLE_OVERFLOW_CLIP ||
overflow == NS_STYLE_OVERFLOW_HIDDEN;
if (clip) {
aRenderingContext.PushState();
SetOverflowClipRect(aRenderingContext);

Просмотреть файл

@ -98,6 +98,10 @@ input {
text-indent: 0;
}
input > .anonymous-div {
white-space : nowrap;
}
textarea {
margin: 1px 0 1px 0;
border: 2px inset ThreeDFace;
@ -114,7 +118,6 @@ textarea {
-moz-binding: url("resource://gre/res/builtin/platformHTMLBindings.xml#textAreas");
-moz-appearance: textfield;
text-indent: 0;
overflow: auto;
}
textarea > scrollbar {
@ -133,11 +136,6 @@ input > .anonymous-div {
text-decoration: inherit;
}
input > .anonymous-div {
white-space : nowrap;
overflow: hidden ! important;
}
select {
margin: 0;
border-color: ThreeDFace;

Просмотреть файл

@ -731,7 +731,7 @@ struct nsStyleDisplay : public nsStyleStruct {
PRUint8 mBreakType; // [reset] see nsStyleConsts.h NS_STYLE_CLEAR_*
PRPackedBool mBreakBefore; // [reset]
PRPackedBool mBreakAfter; // [reset]
PRUint8 mOverflow; // [reset] see nsStyleConsts.h
PRUint8 mOverflow; // [reset] see nsStyleConsts.h
PRUint8 mClipFlags; // [reset] see nsStyleConsts.h
PRBool IsBlockLevel() const {return (NS_STYLE_DISPLAY_BLOCK == mDisplay) ||
@ -747,18 +747,6 @@ struct nsStyleDisplay : public nsStyleStruct {
PRBool IsPositioned() const {return IsAbsolutelyPositioned() ||
(NS_STYLE_POSITION_RELATIVE == mPosition);}
PRBool IsScrollableOverflow() const {
return mOverflow != NS_STYLE_OVERFLOW_VISIBLE &&
mOverflow != NS_STYLE_OVERFLOW_CLIP;
}
// For table elements that don't support scroll frame creation, we
// support 'overflow: hidden' to mean 'overflow: -moz-hidden-unscrollable'.
PRBool IsTableClip() const {
return mOverflow == NS_STYLE_OVERFLOW_CLIP ||
mOverflow == NS_STYLE_OVERFLOW_HIDDEN;
}
};
struct nsStyleTable: public nsStyleStruct {

Просмотреть файл

@ -432,9 +432,10 @@ nsTableCellFrame::Paint(nsPresContext* aPresContext,
nsClipCombine_kIntersect);
}
else {
// XXXldb HIDDEN should really create a scrollframe,
// but use |IsTableClip| here since it doesn't.
if (disp->IsTableClip() ||
if (NS_STYLE_OVERFLOW_CLIP == disp->mOverflow ||
// XXXldb HIDDEN should really create a scrollframe,
// but test here since it doesn't.
NS_STYLE_OVERFLOW_HIDDEN == disp->mOverflow ||
HasPctOverHeight()) {
aRenderingContext.PushState();
pushed = PR_TRUE;

Просмотреть файл

@ -1360,8 +1360,11 @@ nsTableFrame::PaintChildren(nsPresContext* aPresContext,
const nsRect& aDirtyRect,
nsFramePaintLayer aWhichLayer,
PRUint32 aFlags)
{
PRBool clip = GetStyleDisplay()->IsTableClip();
PRUint8 overflow = GetStyleDisplay()->mOverflow;
PRBool clip = overflow == NS_STYLE_OVERFLOW_CLIP ||
overflow == NS_STYLE_OVERFLOW_HIDDEN;
// If overflow is hidden then set the clip rect so that children don't
// leak out of us. Note that because overflow'-clip' only applies to
// the content area we do this after painting the border and background
@ -2073,7 +2076,7 @@ NS_METHOD nsTableFrame::Reflow(nsPresContext* aPresContext,
if (aDesiredSize.mFlags & NS_REFLOW_CALC_MAX_WIDTH) {
aDesiredSize.mMaximumWidth = GetPreferredWidth();
}
if (!aReflowState.mStyleDisplay->IsTableClip()) {
if (NS_STYLE_OVERFLOW_CLIP != aReflowState.mStyleDisplay->mOverflow) {
// collapsed border may leak out
nsMargin bcMargin = GetBCMargin(aPresContext);
nsRect tableRect(0, 0, aDesiredSize.width, aDesiredSize.height) ;

Просмотреть файл

@ -333,7 +333,9 @@ nsTableOuterFrame::Paint(nsPresContext* aPresContext,
// If overflow is hidden then set the clip rect so that children
// don't leak out of us
PRBool clip = GetStyleDisplay()->IsTableClip();
PRUint8 overflow = GetStyleDisplay()->mOverflow;
PRBool clip = overflow == NS_STYLE_OVERFLOW_CLIP ||
overflow == NS_STYLE_OVERFLOW_HIDDEN;
if (clip) {
aRenderingContext.PushState();
SetOverflowClipRect(aRenderingContext);

Просмотреть файл

@ -555,7 +555,9 @@ NS_METHOD nsTableRowFrame::Paint(nsPresContext* aPresContext,
aFlags |= NS_PAINT_FLAG_TABLE_BG_PAINT;
}
PRBool clip = GetStyleDisplay()->IsTableClip();
PRUint8 overflow = GetStyleDisplay()->mOverflow;
PRBool clip = overflow == NS_STYLE_OVERFLOW_CLIP ||
overflow == NS_STYLE_OVERFLOW_HIDDEN;
if (clip) {
aRenderingContext.PushState();
SetOverflowClipRect(aRenderingContext);

Просмотреть файл

@ -1473,11 +1473,14 @@ nsListboxScrollPortFrame::GetMinSize(nsBoxLayoutState& aBoxLayoutState, nsSize&
outer->GetContent()->GetAttr(kNameSpaceID_None, nsXULAtoms::sizemode, sizeMode);
if (!sizeMode.IsEmpty()) {
nsCOMPtr<nsIScrollableFrame> scrollFrame(do_QueryInterface(mParent));
if (scrollFrame &&
scrollFrame->GetScrollbarStyles().mVertical == NS_STYLE_OVERFLOW_AUTO) {
nsMargin scrollbars =
scrollFrame->GetDesiredScrollbarSizes(&aBoxLayoutState);
aSize.width += scrollbars.left + scrollbars.right;
if (scrollFrame) {
nsIScrollableFrame::nsScrollPref scrollPref;
scrollFrame->GetScrollPreference(aBoxLayoutState.PresContext(), &scrollPref);
if (scrollPref == nsIScrollableFrame::Auto) {
nsMargin scrollbars = scrollFrame->GetDesiredScrollbarSizes(&aBoxLayoutState);
aSize.width += scrollbars.left + scrollbars.right;
}
}
}
else aSize.width = 0;
@ -1507,10 +1510,14 @@ nsListboxScrollPortFrame::GetPrefSize(nsBoxLayoutState& aBoxLayoutState, nsSize&
aSize.height = size*outer->GetRowHeightTwips();
nsCOMPtr<nsIScrollableFrame> scrollFrame(do_QueryInterface(mParent));
if (scrollFrame &&
scrollFrame->GetScrollbarStyles().mVertical == NS_STYLE_OVERFLOW_AUTO) {
nsMargin scrollbars = scrollFrame->GetDesiredScrollbarSizes(&aBoxLayoutState);
aSize.width += scrollbars.left + scrollbars.right;
if (scrollFrame) {
nsIScrollableFrame::nsScrollPref scrollPref;
scrollFrame->GetScrollPreference(aBoxLayoutState.PresContext(), &scrollPref);
if (scrollPref == nsIScrollableFrame::Auto) {
nsMargin scrollbars = scrollFrame->GetDesiredScrollbarSizes(&aBoxLayoutState);
aSize.width += scrollbars.left + scrollbars.right;
}
}
AddMargin(child, aSize);

Просмотреть файл

@ -1007,18 +1007,23 @@ nsMenuFrame::DoLayout(nsBoxLayoutState& aState)
ibox->GetBounds(bounds);
nsCOMPtr<nsIScrollableFrame> scrollframe(do_QueryInterface(child));
if (scrollframe &&
scrollframe->GetScrollbarStyles().mVertical == NS_STYLE_OVERFLOW_AUTO) {
if (bounds.height < prefSize.height) {
// layout the child
ibox->Layout(aState);
if (scrollframe) {
nsIScrollableFrame::nsScrollPref pref;
scrollframe->GetScrollPreference(aState.PresContext(), &pref);
nsMargin scrollbars = scrollframe->GetActualScrollbarSizes();
if (bounds.width < prefSize.width + scrollbars.left + scrollbars.right)
{
bounds.width += scrollbars.left + scrollbars.right;
//printf("Width=%d\n",width);
ibox->SetBounds(aState, bounds);
if (pref == nsIScrollableFrame::Auto)
{
if (bounds.height < prefSize.height) {
// layout the child
ibox->Layout(aState);
nsMargin scrollbars = scrollframe->GetActualScrollbarSizes();
if (bounds.width < prefSize.width + scrollbars.left + scrollbars.right)
{
bounds.width += scrollbars.left + scrollbars.right;
//printf("Width=%d\n",width);
ibox->SetBounds(aState, bounds);
}
}
}
}

Просмотреть файл

@ -252,19 +252,24 @@ nsPopupSetFrame::DoLayout(nsBoxLayoutState& aState)
ibox->GetBounds(bounds);
nsCOMPtr<nsIScrollableFrame> scrollframe = do_QueryInterface(child);
if (scrollframe &&
scrollframe->GetScrollbarStyles().mVertical == NS_STYLE_OVERFLOW_AUTO) {
// if our pref height
if (bounds.height < prefSize.height) {
// layout the child
ibox->Layout(aState);
if (scrollframe) {
nsIScrollableFrame::nsScrollPref pref;
scrollframe->GetScrollPreference(aState.PresContext(), &pref);
nsMargin scrollbars = scrollframe->GetActualScrollbarSizes();
if (bounds.width < prefSize.width + scrollbars.left + scrollbars.right)
{
bounds.width += scrollbars.left + scrollbars.right;
//printf("Width=%d\n",width);
ibox->SetBounds(aState, bounds);
if (pref == nsIScrollableFrame::Auto)
{
// if our pref height
if (bounds.height < prefSize.height) {
// layout the child
ibox->Layout(aState);
nsMargin scrollbars = scrollframe->GetActualScrollbarSizes();
if (bounds.width < prefSize.width + scrollbars.left + scrollbars.right)
{
bounds.width += scrollbars.left + scrollbars.right;
//printf("Width=%d\n",width);
ibox->SetBounds(aState, bounds);
}
}
}
}