Implement 'overflow-x' and 'overflow-y' CSS properties, long implemented by IE for Windows and proposed for CSS3. Implement scrolling='yes' and equivalents on frame and iframe. Various pieces of related cleanup (see comment 22 in bug). b=72747 r+sr=roc
git-svn-id: svn://10.0.0.236/trunk@161333 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -2708,7 +2708,7 @@ nsCSSFrameConstructor::ConstructTableRowGroupFrame(nsIPresShell* aPre
|
||||
rv = aTableCreator.CreateTableRowGroupFrame(&aNewFrame);
|
||||
|
||||
nsIFrame* scrollFrame = nsnull;
|
||||
if (IsScrollable(aPresContext, styleDisplay)) {
|
||||
if (styleDisplay->IsScrollableOverflow()) {
|
||||
// Create an area container for the frame
|
||||
BuildScrollFrame(aPresShell, aPresContext, aState, aContent, aStyleContext,
|
||||
aNewFrame, parentFrame, nsnull, scrollFrame, aStyleContext);
|
||||
@@ -3341,6 +3341,21 @@ nsCSSFrameConstructor::ConstructDocElementTableFrame(nsIPresShell* aPresS
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
static PRBool CheckOverflow(nsPresContext* aPresContext,
|
||||
const nsStyleDisplay* aDisplay)
|
||||
{
|
||||
if (aDisplay->mOverflowX == NS_STYLE_OVERFLOW_VISIBLE)
|
||||
return PR_FALSE;
|
||||
|
||||
if (aDisplay->mOverflowX == NS_STYLE_OVERFLOW_CLIP)
|
||||
aPresContext->SetViewportOverflowOverride(NS_STYLE_OVERFLOW_HIDDEN,
|
||||
NS_STYLE_OVERFLOW_HIDDEN);
|
||||
else
|
||||
aPresContext->SetViewportOverflowOverride(aDisplay->mOverflowX,
|
||||
aDisplay->mOverflowY);
|
||||
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
|
||||
@@ -3354,7 +3369,8 @@ nsIContent*
|
||||
nsCSSFrameConstructor::PropagateScrollToViewport(nsPresContext* aPresContext)
|
||||
{
|
||||
// Set default
|
||||
aPresContext->SetViewportOverflowOverride(NS_STYLE_OVERFLOW_AUTO);
|
||||
aPresContext->SetViewportOverflowOverride(NS_STYLE_OVERFLOW_AUTO,
|
||||
NS_STYLE_OVERFLOW_AUTO);
|
||||
|
||||
// We never mess with the viewport scroll state
|
||||
// when printing or in print preview
|
||||
@@ -3366,14 +3382,12 @@ nsCSSFrameConstructor::PropagateScrollToViewport(nsPresContext* aPresContext)
|
||||
|
||||
// Check the style on the document root element
|
||||
nsStyleSet *styleSet = aPresContext->PresShell()->StyleSet();
|
||||
nsRefPtr<nsStyleContext> styleContext;
|
||||
styleContext = styleSet->ResolveStyleFor(docElement, nsnull);
|
||||
if (!styleContext) {
|
||||
nsRefPtr<nsStyleContext> rootStyle;
|
||||
rootStyle = styleSet->ResolveStyleFor(docElement, nsnull);
|
||||
if (!rootStyle) {
|
||||
return nsnull;
|
||||
}
|
||||
const nsStyleDisplay* display = styleContext->GetStyleDisplay();
|
||||
if (display->mOverflow != NS_STYLE_OVERFLOW_VISIBLE) {
|
||||
aPresContext->SetViewportOverflowOverride(display->mOverflow);
|
||||
if (CheckOverflow(aPresContext, rootStyle->GetStyleDisplay())) {
|
||||
// tell caller we stole the overflow style from the root element
|
||||
return docElement;
|
||||
}
|
||||
@@ -3399,15 +3413,13 @@ nsCSSFrameConstructor::PropagateScrollToViewport(nsPresContext* aPresContext)
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
nsRefPtr<nsStyleContext> bodyContext;
|
||||
bodyContext = styleSet->ResolveStyleFor(bodyElement, styleContext);
|
||||
if (!bodyContext) {
|
||||
nsRefPtr<nsStyleContext> bodyStyle;
|
||||
bodyStyle = styleSet->ResolveStyleFor(bodyElement, rootStyle);
|
||||
if (!bodyStyle) {
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
display = bodyContext->GetStyleDisplay();
|
||||
if (display->mOverflow != NS_STYLE_OVERFLOW_VISIBLE) {
|
||||
aPresContext->SetViewportOverflowOverride(display->mOverflow);
|
||||
if (CheckOverflow(aPresContext, bodyStyle->GetStyleDisplay())) {
|
||||
// tell caller we stole the overflow style from the body element
|
||||
return bodyElement;
|
||||
}
|
||||
@@ -3521,7 +3533,7 @@ nsCSSFrameConstructor::ConstructDocElementFrame(nsIPresShell* aPresShell,
|
||||
|
||||
// The document root should not be scrollable in any paginated context,
|
||||
// even in print preview.
|
||||
PRBool isScrollable = IsScrollable(aPresContext, display)
|
||||
PRBool isScrollable = display->IsScrollableOverflow()
|
||||
&& !aPresContext->IsPaginated()
|
||||
&& !propagatedScrollToViewport;
|
||||
|
||||
@@ -3796,7 +3808,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;
|
||||
|
||||
@@ -3809,8 +3820,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;
|
||||
@@ -3820,28 +3829,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 (NS_STYLE_OVERFLOW_HIDDEN == 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) {
|
||||
@@ -5480,7 +5474,7 @@ nsCSSFrameConstructor::ConstructXULFrame(nsIPresShell* aPresShell,
|
||||
}
|
||||
|
||||
// Boxes can scroll.
|
||||
if (IsScrollable(aPresContext, display)) {
|
||||
if (display->IsScrollableOverflow()) {
|
||||
|
||||
nsIFrame* scrollPort = nsnull;
|
||||
if (listboxScrollPort) {
|
||||
@@ -5580,7 +5574,7 @@ nsCSSFrameConstructor::ConstructXULFrame(nsIPresShell* aPresShell,
|
||||
#endif
|
||||
}
|
||||
|
||||
if (mayBeScrollable && IsScrollable(aPresContext, display)) {
|
||||
if (mayBeScrollable && display->IsScrollableOverflow()) {
|
||||
// set the top to be the newly created scrollframe
|
||||
BuildScrollFrame(aPresShell, aPresContext, aState, aContent,
|
||||
aStyleContext, newFrame, aParentFrame, nsnull,
|
||||
@@ -6088,7 +6082,7 @@ nsCSSFrameConstructor::ConstructFrameByDisplayType(nsIPresShell* aPre
|
||||
// XXX Ignore tables for the time being
|
||||
if (aDisplay->IsBlockLevel() &&
|
||||
aDisplay->mDisplay != NS_STYLE_DISPLAY_TABLE &&
|
||||
IsScrollable(aPresContext, aDisplay) &&
|
||||
aDisplay->IsScrollableOverflow() &&
|
||||
!propagatedScrollToViewport) {
|
||||
|
||||
if (!pseudoParent && !aState.mPseudoFrames.IsEmpty()) { // process pending pseudo frames
|
||||
@@ -6494,25 +6488,6 @@ 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,
|
||||
|
||||
Reference in New Issue
Block a user