diff --git a/mozilla/content/base/src/nsDocumentViewer.cpp b/mozilla/content/base/src/nsDocumentViewer.cpp index 06c9ec4b1ea..887f89e66e5 100644 --- a/mozilla/content/base/src/nsDocumentViewer.cpp +++ b/mozilla/content/base/src/nsDocumentViewer.cpp @@ -120,7 +120,7 @@ #include "nsIFocusController.h" #include "nsIScrollableView.h" -#include "nsIScrollable.h" +#include "nsIHTMLDocument.h" #include "nsITimelineService.h" #include "nsGfxCIID.h" @@ -678,23 +678,11 @@ DocumentViewerImpl::InitPresentationStuff(PRBool aDoInitialReflow) mViewManager->SetDefaultBackgroundColor(mPresContext->DefaultBackgroundColor()); if (aDoInitialReflow) { - nsCOMPtr sc = do_QueryInterface(mContainer); - - if (sc) { - nsCOMPtr frameset(do_QueryInterface(mDocument->GetRootContent())); - - if (frameset) { - // If this is a frameset (i.e. not a frame) then we never want - // scrollbars on it, the scrollbars go inside the frames - // inside the frameset... - - sc->SetCurrentScrollbarPreferences(nsIScrollable::ScrollOrientation_Y, - NS_STYLE_OVERFLOW_HIDDEN); - sc->SetCurrentScrollbarPreferences(nsIScrollable::ScrollOrientation_X, - NS_STYLE_OVERFLOW_HIDDEN); - } else { - sc->ResetScrollbarPreferences(); - } + nsCOMPtr htmlDoc = do_QueryInterface(mDocument); + if (htmlDoc) { + nsCOMPtr frameset = + do_QueryInterface(mDocument->GetRootContent()); + htmlDoc->SetIsFrameset(frameset != nsnull); } // Initial reflow diff --git a/mozilla/content/base/src/nsRuleNode.cpp b/mozilla/content/base/src/nsRuleNode.cpp index 70b8ddb1114..2c0a7cafc20 100644 --- a/mozilla/content/base/src/nsRuleNode.cpp +++ b/mozilla/content/base/src/nsRuleNode.cpp @@ -2614,16 +2614,55 @@ nsRuleNode::ComputeDisplayData(nsStyleStruct* aStartStruct, display->mFloats = parentDisplay->mFloats; } - // overflow: enum, auto, inherit - if (eCSSUnit_Enumerated == displayData.mOverflow.GetUnit()) { - display->mOverflow = displayData.mOverflow.GetIntValue(); + // overflow-x: enum, auto, inherit + if (eCSSUnit_Enumerated == displayData.mOverflowX.GetUnit()) { + display->mOverflowX = displayData.mOverflowX.GetIntValue(); } - else if (eCSSUnit_Auto == displayData.mOverflow.GetUnit()) { - display->mOverflow = NS_STYLE_OVERFLOW_AUTO; + else if (eCSSUnit_Auto == displayData.mOverflowX.GetUnit()) { + display->mOverflowX = NS_STYLE_OVERFLOW_AUTO; } - else if (eCSSUnit_Inherit == displayData.mOverflow.GetUnit()) { + else if (eCSSUnit_Inherit == displayData.mOverflowX.GetUnit()) { inherited = PR_TRUE; - display->mOverflow = parentDisplay->mOverflow; + display->mOverflowX = parentDisplay->mOverflowX; + } + + // overflow-y: enum, auto, inherit + if (eCSSUnit_Enumerated == displayData.mOverflowY.GetUnit()) { + display->mOverflowY = displayData.mOverflowY.GetIntValue(); + } + else if (eCSSUnit_Auto == displayData.mOverflowY.GetUnit()) { + display->mOverflowY = NS_STYLE_OVERFLOW_AUTO; + } + else if (eCSSUnit_Inherit == displayData.mOverflowY.GetUnit()) { + inherited = PR_TRUE; + display->mOverflowY = parentDisplay->mOverflowY; + } + + // CSS3 overflow-x and overflow-y require some fixup as well in some + // cases. NS_STYLE_OVERFLOW_VISIBLE and NS_STYLE_OVERFLOW_CLIP are + // meaningful only when used in both dimensions. + if (display->mOverflowX != display->mOverflowY && + (display->mOverflowX == NS_STYLE_OVERFLOW_VISIBLE || + display->mOverflowX == NS_STYLE_OVERFLOW_CLIP || + display->mOverflowY == NS_STYLE_OVERFLOW_VISIBLE || + display->mOverflowY == NS_STYLE_OVERFLOW_CLIP)) { + // We can't store in the rule tree since a more specific rule might + // change these conditions. + inherited = PR_TRUE; + + // NS_STYLE_OVERFLOW_CLIP is a deprecated value, so if it's specified + // in only one dimension, convert it to NS_STYLE_OVERFLOW_HIDDEN. + if (display->mOverflowX == NS_STYLE_OVERFLOW_CLIP) + display->mOverflowX = NS_STYLE_OVERFLOW_HIDDEN; + if (display->mOverflowY == NS_STYLE_OVERFLOW_CLIP) + display->mOverflowY = NS_STYLE_OVERFLOW_HIDDEN; + + // If 'visible' is specified but doesn't match the other dimension, it + // turns into 'auto'. + if (display->mOverflowX == NS_STYLE_OVERFLOW_VISIBLE) + display->mOverflowX = NS_STYLE_OVERFLOW_AUTO; + if (display->mOverflowY == NS_STYLE_OVERFLOW_VISIBLE) + display->mOverflowY = NS_STYLE_OVERFLOW_AUTO; } // clip property: length, auto, inherit diff --git a/mozilla/content/html/content/src/nsGenericHTMLElement.cpp b/mozilla/content/html/content/src/nsGenericHTMLElement.cpp index 79437d43c21..25493ac282f 100644 --- a/mozilla/content/html/content/src/nsGenericHTMLElement.cpp +++ b/mozilla/content/html/content/src/nsGenericHTMLElement.cpp @@ -3028,34 +3028,39 @@ nsGenericHTMLElement::MapScrollingAttributeInto(const nsMappedAttributes* aAttri return; // scrolling - if (aData->mDisplayData->mOverflow.GetUnit() == eCSSUnit_Null) { - const nsAttrValue* value = aAttributes->GetAttr(nsHTMLAtoms::scrolling); - if (value && value->Type() == nsAttrValue::eEnum) { - PRInt32 mappedValue; - switch (value->GetEnumValue()) { - case NS_STYLE_FRAME_ON: - case NS_STYLE_FRAME_SCROLL: - case NS_STYLE_FRAME_YES: - mappedValue = NS_STYLE_OVERFLOW_SCROLL; - break; + nsCSSValue* overflowValues[2] = { + &aData->mDisplayData->mOverflowX, + &aData->mDisplayData->mOverflowY, + }; + for (PRInt32 i = 0; i < NS_ARRAY_LENGTH(overflowValues); ++i) { + if (overflowValues[i]->GetUnit() == eCSSUnit_Null) { + const nsAttrValue* value = aAttributes->GetAttr(nsHTMLAtoms::scrolling); + if (value && value->Type() == nsAttrValue::eEnum) { + PRInt32 mappedValue; + switch (value->GetEnumValue()) { + case NS_STYLE_FRAME_ON: + case NS_STYLE_FRAME_SCROLL: + case NS_STYLE_FRAME_YES: + mappedValue = NS_STYLE_OVERFLOW_SCROLL; + break; - case NS_STYLE_FRAME_OFF: - case NS_STYLE_FRAME_NOSCROLL: - case NS_STYLE_FRAME_NO: - mappedValue = NS_STYLE_OVERFLOW_HIDDEN; - break; - - case NS_STYLE_FRAME_AUTO: - mappedValue = NS_STYLE_OVERFLOW_AUTO; - break; + case NS_STYLE_FRAME_OFF: + case NS_STYLE_FRAME_NOSCROLL: + case NS_STYLE_FRAME_NO: + mappedValue = NS_STYLE_OVERFLOW_HIDDEN; + break; + + case NS_STYLE_FRAME_AUTO: + mappedValue = NS_STYLE_OVERFLOW_AUTO; + break; - default: - NS_NOTREACHED("unexpected value"); - mappedValue = NS_STYLE_OVERFLOW_AUTO; - break; + default: + NS_NOTREACHED("unexpected value"); + mappedValue = NS_STYLE_OVERFLOW_AUTO; + break; + } + overflowValues[i]->SetIntValue(mappedValue, eCSSUnit_Enumerated); } - aData->mDisplayData->mOverflow.SetIntValue(mappedValue, - eCSSUnit_Enumerated); } } } diff --git a/mozilla/content/html/document/src/nsHTMLContentSink.cpp b/mozilla/content/html/document/src/nsHTMLContentSink.cpp index 0b99103f65b..f2f2fefb770 100644 --- a/mozilla/content/html/document/src/nsHTMLContentSink.cpp +++ b/mozilla/content/html/document/src/nsHTMLContentSink.cpp @@ -108,7 +108,6 @@ #include "nsTimer.h" #include "nsITimer.h" #include "nsDOMError.h" -#include "nsIScrollable.h" #include "nsContentPolicyUtils.h" #include "nsIScriptContext.h" #include "nsStyleLinkElement.h" @@ -3646,24 +3645,9 @@ HTMLContentSink::StartLayout() mLastNotificationTime = PR_Now(); - // If it's a frameset document then disable scrolling. - // Else, reset scrolling to default settings for this shell. - // This must happen before the initial reflow, when we create the root frame - nsCOMPtr scrollableContainer = do_QueryInterface(mDocShell); - if (scrollableContainer) { - if (mFrameset) { - scrollableContainer-> - SetCurrentScrollbarPreferences(nsIScrollable::ScrollOrientation_Y, - NS_STYLE_OVERFLOW_HIDDEN); - scrollableContainer-> - SetCurrentScrollbarPreferences(nsIScrollable::ScrollOrientation_X, - NS_STYLE_OVERFLOW_HIDDEN); - } else { - scrollableContainer->ResetScrollbarPreferences(); - } - } + mHTMLDocument->SetIsFrameset(mFrameset != nsnull); - nsContentSink::StartLayout(!!mFrameset); + nsContentSink::StartLayout(mFrameset != nsnull); } void diff --git a/mozilla/content/html/document/src/nsHTMLDocument.h b/mozilla/content/html/document/src/nsHTMLDocument.h index 3ff0e760270..3b0037b6e86 100644 --- a/mozilla/content/html/document/src/nsHTMLDocument.h +++ b/mozilla/content/html/document/src/nsHTMLDocument.h @@ -119,6 +119,9 @@ public: return mWriteLevel != PRUint32(0); } + virtual PRBool GetIsFrameset() { return mIsFrameset; } + virtual void SetIsFrameset(PRBool aFrameset) { mIsFrameset = aFrameset; } + virtual void ContentAppended(nsIContent* aContainer, PRInt32 aNewIndexInContainer); virtual void ContentInserted(nsIContent* aContainer, @@ -319,6 +322,8 @@ protected: */ PRPackedBool mDomainWasSet; + PRPackedBool mIsFrameset; + PLDHashTable mIdAndNameHashTable; nsCOMPtr mWyciwygChannel; diff --git a/mozilla/content/html/document/src/nsIHTMLDocument.h b/mozilla/content/html/document/src/nsIHTMLDocument.h index ab9848cfbc8..12eae9914b5 100644 --- a/mozilla/content/html/document/src/nsIHTMLDocument.h +++ b/mozilla/content/html/document/src/nsIHTMLDocument.h @@ -111,6 +111,9 @@ public: virtual PRInt32 GetNumFormsSynchronous() = 0; virtual PRBool IsWriting() = 0; + + virtual PRBool GetIsFrameset() = 0; + virtual void SetIsFrameset(PRBool aFrameset) = 0; }; #endif /* nsIHTMLDocument_h___ */ diff --git a/mozilla/content/html/document/src/nsMediaDocument.cpp b/mozilla/content/html/document/src/nsMediaDocument.cpp index c23378527df..2fe13f86d56 100644 --- a/mozilla/content/html/document/src/nsMediaDocument.cpp +++ b/mozilla/content/html/document/src/nsMediaDocument.cpp @@ -267,13 +267,6 @@ nsMediaDocument::CreateSyntheticDocument() nsresult nsMediaDocument::StartLayout() { - // Reset scrolling to default settings for this shell. - // This must happen before the initial reflow, when we create the root frame - nsCOMPtr scrollableContainer(do_QueryReferent(mDocumentContainer)); - if (scrollableContainer) { - scrollableContainer->ResetScrollbarPreferences(); - } - PRUint32 numberOfShells = GetNumberOfShells(); for (PRUint32 i = 0; i < numberOfShells; i++) { nsIPresShell *shell = GetShellAt(i); diff --git a/mozilla/content/html/style/src/nsCSSDeclaration.cpp b/mozilla/content/html/style/src/nsCSSDeclaration.cpp index 66ad6686027..84df769f526 100644 --- a/mozilla/content/html/style/src/nsCSSDeclaration.cpp +++ b/mozilla/content/html/style/src/nsCSSDeclaration.cpp @@ -500,6 +500,7 @@ nsCSSDeclaration::GetValue(nsCSSProperty aProperty, // shorthands // XXX What about checking the consistency of '!important'? + // XXXldb Can we share shorthand logic with ToString? switch (aProperty) { case eCSSProperty_margin: case eCSSProperty_padding: @@ -629,6 +630,14 @@ nsCSSDeclaration::GetValue(nsCSSProperty aProperty, aValue.Append(PRUnichar(' ')); AppendValueToString(eCSSProperty_list_style_image, aValue); break; + case eCSSProperty_overflow: { + nsCSSValue xValue, yValue; + GetValueOrImportantValue(eCSSProperty_overflow_x, xValue); + GetValueOrImportantValue(eCSSProperty_overflow_y, yValue); + if (xValue == yValue) + AppendValueToString(eCSSProperty_overflow_x, aValue); + break; + } case eCSSProperty_pause: { if (AppendValueToString(eCSSProperty_pause_after, aValue)) { aValue.Append(PRUnichar(' ')); @@ -968,6 +977,27 @@ nsCSSDeclaration::UseBackgroundPosition(nsAString & aString, aBgPositionY = 0; } +void +nsCSSDeclaration::TryOverflowShorthand(nsAString & aString, + PRInt32 & aOverflowX, + PRInt32 & aOverflowY) const +{ + PRBool isImportant; + if (aOverflowX && aOverflowY && + AllPropertiesSameImportance(aOverflowX, aOverflowY, + 0, 0, 0, 0, isImportant)) { + nsCSSValue xValue, yValue; + GetValueOrImportantValue(eCSSProperty_overflow_x, xValue); + GetValueOrImportantValue(eCSSProperty_overflow_y, yValue); + if (xValue == yValue) { + AppendCSSValueToString(eCSSProperty_overflow_x, xValue, aString); + AppendImportanceToString(isImportant, aString); + aString.AppendLiteral("; "); + aOverflowX = aOverflowY = 0; + } + } +} + #define NS_CASE_OUTPUT_PROPERTY_VALUE(_prop, _index) \ case _prop: \ if (_index) { \ @@ -1012,6 +1042,7 @@ nsCSSDeclaration::ToString(nsAString& aString) const PRInt32 paddingTop = 0, paddingBottom = 0, paddingLeft = 0, paddingRight = 0; PRInt32 bgColor = 0, bgImage = 0, bgRepeat = 0, bgAttachment = 0; PRInt32 bgPositionX = 0, bgPositionY = 0; + PRInt32 overflowX = 0, overflowY = 0; PRUint32 borderPropertiesSet = 0, finalBorderPropertiesToSet = 0; for (index = 0; index < count; index++) { nsCSSProperty property = OrderValueAt(index); @@ -1055,23 +1086,27 @@ nsCSSDeclaration::ToString(nsAString& aString) const PropertyIsSet(borderRightColor, index, borderPropertiesSet, B_BORDER_RIGHT_COLOR); break; - case eCSSProperty_margin_top: marginTop = index+1; break; - case eCSSProperty_margin_bottom: marginBottom = index+1; break; - case eCSSProperty_margin_left_value: marginLeft = index+1; break; - case eCSSProperty_margin_right_value: marginRight = index+1; break; + case eCSSProperty_margin_top: marginTop = index+1; break; + case eCSSProperty_margin_bottom: marginBottom = index+1; break; + case eCSSProperty_margin_left_value: marginLeft = index+1; break; + case eCSSProperty_margin_right_value: marginRight = index+1; break; - case eCSSProperty_padding_top: paddingTop = index+1; break; - case eCSSProperty_padding_bottom: paddingBottom = index+1; break; - case eCSSProperty_padding_left_value: paddingLeft = index+1; break; - case eCSSProperty_padding_right_value: paddingRight = index+1; break; + case eCSSProperty_padding_top: paddingTop = index+1; break; + case eCSSProperty_padding_bottom: paddingBottom = index+1; break; + case eCSSProperty_padding_left_value: paddingLeft = index+1; break; + case eCSSProperty_padding_right_value: paddingRight = index+1; break; - case eCSSProperty_background_color: bgColor = index+1; break; - case eCSSProperty_background_image: bgImage = index+1; break; - case eCSSProperty_background_repeat: bgRepeat = index+1; break; - case eCSSProperty_background_attachment: bgAttachment = index+1; break; - case eCSSProperty_background_x_position: bgPositionX = index+1; break; - case eCSSProperty_background_y_position: bgPositionY = index+1; break; - default: ; + case eCSSProperty_background_color: bgColor = index+1; break; + case eCSSProperty_background_image: bgImage = index+1; break; + case eCSSProperty_background_repeat: bgRepeat = index+1; break; + case eCSSProperty_background_attachment: bgAttachment = index+1; break; + case eCSSProperty_background_x_position: bgPositionX = index+1; break; + case eCSSProperty_background_y_position: bgPositionY = index+1; break; + + case eCSSProperty_overflow_x: overflowX = index+1; break; + case eCSSProperty_overflow_y: overflowY = index+1; break; + + default: break; } } @@ -1139,6 +1174,7 @@ nsCSSDeclaration::ToString(nsAString& aString) const TryBackgroundShorthand(aString, bgColor, bgImage, bgRepeat, bgAttachment, bgPositionX, bgPositionY); + TryOverflowShorthand(aString, overflowX, overflowY); for (index = 0; index < count; index++) { nsCSSProperty property = OrderValueAt(index); @@ -1214,6 +1250,9 @@ nsCSSDeclaration::ToString(nsAString& aString) const break; } + NS_CASE_OUTPUT_PROPERTY_VALUE(eCSSProperty_overflow_x, overflowX) + NS_CASE_OUTPUT_PROPERTY_VALUE(eCSSProperty_overflow_y, overflowY) + case eCSSProperty_margin_left_ltr_source: case eCSSProperty_margin_left_rtl_source: case eCSSProperty_margin_right_ltr_source: diff --git a/mozilla/content/html/style/src/nsCSSDeclaration.h b/mozilla/content/html/style/src/nsCSSDeclaration.h index fe7a3bb0d83..ead908df86a 100644 --- a/mozilla/content/html/style/src/nsCSSDeclaration.h +++ b/mozilla/content/html/style/src/nsCSSDeclaration.h @@ -190,6 +190,8 @@ private: void UseBackgroundPosition(nsAString & aString, PRInt32 & aBgPositionX, PRInt32 & aBgPositionY) const; + void TryOverflowShorthand(nsAString & aString, + PRInt32 & aOverflowX, PRInt32 & aOverflowY) const; PRBool AllPropertiesSameImportance(PRInt32 aFirst, PRInt32 aSecond, PRInt32 aThird, PRInt32 aFourth, diff --git a/mozilla/content/html/style/src/nsCSSParser.cpp b/mozilla/content/html/style/src/nsCSSParser.cpp index 58f254ef2d8..8a92cad5468 100644 --- a/mozilla/content/html/style/src/nsCSSParser.cpp +++ b/mozilla/content/html/style/src/nsCSSParser.cpp @@ -261,6 +261,7 @@ protected: #ifdef ENABLE_OUTLINE PRBool ParseOutline(nsresult& aErrorCode); #endif + PRBool ParseOverflow(nsresult& aErrorCode); PRBool ParsePadding(nsresult& aErrorCode); PRBool ParsePause(nsresult& aErrorCode); PRBool ParsePlayDuring(nsresult& aErrorCode); @@ -4024,6 +4025,8 @@ PRBool CSSParserImpl::ParseProperty(nsresult& aErrorCode, case eCSSProperty__moz_outline: return ParseOutline(aErrorCode); #endif + case eCSSProperty_overflow: + return ParseOverflow(aErrorCode); case eCSSProperty_padding: return ParsePadding(aErrorCode); case eCSSProperty_padding_end: @@ -4157,6 +4160,7 @@ PRBool CSSParserImpl::ParseSingleValueProperty(nsresult& aErrorCode, case eCSSProperty__moz_outline: case eCSSProperty__moz_outline_radius: #endif + case eCSSProperty_overflow: case eCSSProperty_padding: case eCSSProperty_padding_end: case eCSSProperty_padding_left: @@ -4443,9 +4447,10 @@ PRBool CSSParserImpl::ParseSingleValueProperty(nsresult& aErrorCode, return ParseVariant(aErrorCode, aValue, VARIANT_HKL, nsCSSProps::kBorderWidthKTable); #endif - case eCSSProperty_overflow: + case eCSSProperty_overflow_x: + case eCSSProperty_overflow_y: return ParseVariant(aErrorCode, aValue, VARIANT_AHK, - nsCSSProps::kOverflowKTable); + nsCSSProps::kOverflowSubKTable); case eCSSProperty_padding_bottom: case eCSSProperty_padding_end_value: // for internal use case eCSSProperty_padding_left_value: // for internal use @@ -5554,6 +5559,33 @@ PRBool CSSParserImpl::ParseOutline(nsresult& aErrorCode) } #endif +PRBool CSSParserImpl::ParseOverflow(nsresult& aErrorCode) +{ + nsCSSValue overflow; + if (!ParseVariant(aErrorCode, overflow, VARIANT_AHK, + nsCSSProps::kOverflowKTable) || + !ExpectEndProperty(aErrorCode, PR_TRUE)) + return PR_FALSE; + + nsCSSValue overflowX(overflow); + nsCSSValue overflowY(overflow); + if (eCSSUnit_Enumerated == overflow.GetUnit()) + switch(overflow.GetIntValue()) { + case NS_STYLE_OVERFLOW_SCROLLBARS_HORIZONTAL: + overflowX.SetIntValue(NS_STYLE_OVERFLOW_SCROLL, eCSSUnit_Enumerated); + overflowY.SetIntValue(NS_STYLE_OVERFLOW_HIDDEN, eCSSUnit_Enumerated); + break; + case NS_STYLE_OVERFLOW_SCROLLBARS_VERTICAL: + overflowX.SetIntValue(NS_STYLE_OVERFLOW_HIDDEN, eCSSUnit_Enumerated); + overflowY.SetIntValue(NS_STYLE_OVERFLOW_SCROLL, eCSSUnit_Enumerated); + break; + } + AppendValue(eCSSProperty_overflow_x, overflowX); + AppendValue(eCSSProperty_overflow_y, overflowY); + aErrorCode = NS_OK; + return PR_TRUE; +} + PRBool CSSParserImpl::ParsePadding(nsresult& aErrorCode) { static const nsCSSProperty kPaddingSideIDs[] = { diff --git a/mozilla/content/html/style/src/nsCSSStruct.cpp b/mozilla/content/html/style/src/nsCSSStruct.cpp index 1470519b68b..a4cac3eaa95 100644 --- a/mozilla/content/html/style/src/nsCSSStruct.cpp +++ b/mozilla/content/html/style/src/nsCSSStruct.cpp @@ -487,7 +487,8 @@ nsCSSDisplay::nsCSSDisplay(const nsCSSDisplay& aCopy) mFloat(aCopy.mFloat), mClear(aCopy.mClear), mClip(aCopy.mClip), - mOverflow(aCopy.mOverflow), + mOverflowX(aCopy.mOverflowX), + mOverflowY(aCopy.mOverflowY), mVisibility(aCopy.mVisibility), mOpacity(aCopy.mOpacity), // temp fix for bug 24000 @@ -523,7 +524,8 @@ void nsCSSDisplay::List(FILE* out, PRInt32 aIndent) const fputs(NS_LossyConvertUCS2toASCII(buffer).get(), out); mClip.List(out, eCSSProperty_clip); buffer.SetLength(0); - mOverflow.AppendToString(buffer, eCSSProperty_overflow); + mOverflowX.AppendToString(buffer, eCSSProperty_overflow_x); + mOverflowY.AppendToString(buffer, eCSSProperty_overflow_y); fputs(NS_LossyConvertUCS2toASCII(buffer).get(), out); } #endif diff --git a/mozilla/content/html/style/src/nsCSSStruct.h b/mozilla/content/html/style/src/nsCSSStruct.h index a5a06ad9d83..ae641fcff59 100644 --- a/mozilla/content/html/style/src/nsCSSStruct.h +++ b/mozilla/content/html/style/src/nsCSSStruct.h @@ -234,7 +234,8 @@ struct nsCSSDisplay : public nsCSSStruct { nsCSSValue mFloat; nsCSSValue mClear; nsCSSRect mClip; - nsCSSValue mOverflow; + nsCSSValue mOverflowX; + nsCSSValue mOverflowY; nsCSSValue mVisibility; nsCSSValue mOpacity; diff --git a/mozilla/content/html/style/src/nsComputedDOMStyle.cpp b/mozilla/content/html/style/src/nsComputedDOMStyle.cpp index af6f875d0f8..dbdd5b85c35 100644 --- a/mozilla/content/html/style/src/nsComputedDOMStyle.cpp +++ b/mozilla/content/html/style/src/nsComputedDOMStyle.cpp @@ -2344,10 +2344,56 @@ nsComputedDOMStyle::GetOverflow(nsIFrame *aFrame, const nsStyleDisplay* display = nsnull; GetStyleData(eStyleStruct_Display, (const nsStyleStruct*&)display, aFrame); - if (display && display->mOverflow != NS_STYLE_OVERFLOW_AUTO) { + if (display && display->mOverflowX == display->mOverflowY) { + if (display->mOverflowX != NS_STYLE_OVERFLOW_AUTO) { + const nsAFlatCString& overflow = + nsCSSProps::SearchKeywordTable(display->mOverflowX, + nsCSSProps::kOverflowKTable); + val->SetIdent(overflow); + } else { + val->SetIdent(nsLayoutAtoms::autoAtom); + } + } // XXX else what? + + return CallQueryInterface(val, aValue); +} + +nsresult +nsComputedDOMStyle::GetOverflowX(nsIFrame *aFrame, + nsIDOMCSSValue** aValue) +{ + nsROCSSPrimitiveValue* val = GetROCSSPrimitiveValue(); + NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY); + + const nsStyleDisplay* display = nsnull; + GetStyleData(eStyleStruct_Display, (const nsStyleStruct*&)display, aFrame); + + if (display && display->mOverflowX != NS_STYLE_OVERFLOW_AUTO) { const nsAFlatCString& overflow = - nsCSSProps::SearchKeywordTable(display->mOverflow, - nsCSSProps::kOverflowKTable); + nsCSSProps::SearchKeywordTable(display->mOverflowX, + nsCSSProps::kOverflowSubKTable); + val->SetIdent(overflow); + } else { + val->SetIdent(nsLayoutAtoms::autoAtom); + } + + return CallQueryInterface(val, aValue); +} + +nsresult +nsComputedDOMStyle::GetOverflowY(nsIFrame *aFrame, + nsIDOMCSSValue** aValue) +{ + nsROCSSPrimitiveValue* val = GetROCSSPrimitiveValue(); + NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY); + + const nsStyleDisplay* display = nsnull; + GetStyleData(eStyleStruct_Display, (const nsStyleStruct*&)display, aFrame); + + if (display && display->mOverflowY != NS_STYLE_OVERFLOW_AUTO) { + const nsAFlatCString& overflow = + nsCSSProps::SearchKeywordTable(display->mOverflowY, + nsCSSProps::kOverflowSubKTable); val->SetIdent(overflow); } else { val->SetIdent(nsLayoutAtoms::autoAtom); @@ -3533,6 +3579,8 @@ nsComputedDOMStyle::GetQueryablePropertyMap(PRUint32* aLength) // COMPUTED_STYLE_MAP_ENTRY(outline_style, OutlineStyle), // COMPUTED_STYLE_MAP_ENTRY(outline_width, OutlineWidth), COMPUTED_STYLE_MAP_ENTRY(overflow, Overflow), + COMPUTED_STYLE_MAP_ENTRY(overflow_x, OverflowX), + COMPUTED_STYLE_MAP_ENTRY(overflow_y, OverflowY), //// COMPUTED_STYLE_MAP_ENTRY(padding, Padding), COMPUTED_STYLE_MAP_ENTRY(padding_bottom, PaddingBottom), COMPUTED_STYLE_MAP_ENTRY(padding_left, PaddingLeft), diff --git a/mozilla/content/html/style/src/nsComputedDOMStyle.h b/mozilla/content/html/style/src/nsComputedDOMStyle.h index f5bff76c134..89ea422be79 100644 --- a/mozilla/content/html/style/src/nsComputedDOMStyle.h +++ b/mozilla/content/html/style/src/nsComputedDOMStyle.h @@ -272,6 +272,8 @@ private: nsresult GetPosition(nsIFrame *aFrame, nsIDOMCSSValue** aValue); nsresult GetClip(nsIFrame *aFrame, nsIDOMCSSValue** aValue); nsresult GetOverflow(nsIFrame *aFrame, nsIDOMCSSValue** aValue); + nsresult GetOverflowX(nsIFrame *aFrame, nsIDOMCSSValue** aValue); + nsresult GetOverflowY(nsIFrame *aFrame, nsIDOMCSSValue** aValue); /* User interface properties */ nsresult GetCursor(nsIFrame *aFrame, nsIDOMCSSValue** aValue); diff --git a/mozilla/content/html/style/src/nsHTMLCSSStyleSheet.cpp b/mozilla/content/html/style/src/nsHTMLCSSStyleSheet.cpp index cf65efc5a68..0ade20aeea4 100644 --- a/mozilla/content/html/style/src/nsHTMLCSSStyleSheet.cpp +++ b/mozilla/content/html/style/src/nsHTMLCSSStyleSheet.cpp @@ -184,7 +184,8 @@ CSSDisablePropsRule::CommonMapRuleInfoInto(nsRuleData* aData) aData->mDisplayData->mPosition = staticposition; nsCSSValue visible(NS_STYLE_OVERFLOW_VISIBLE, eCSSUnit_Enumerated); - aData->mDisplayData->mOverflow = visible; + aData->mDisplayData->mOverflowX = visible; + aData->mDisplayData->mOverflowY = visible; // Nobody will care about 'break-before' or 'break-after', since // they only apply to blocks (assuming we implement them correctly). diff --git a/mozilla/content/shared/public/nsCSSPropList.h b/mozilla/content/shared/public/nsCSSPropList.h index cae3293be7e..bdab54964bd 100644 --- a/mozilla/content/shared/public/nsCSSPropList.h +++ b/mozilla/content/shared/public/nsCSSPropList.h @@ -406,7 +406,9 @@ CSS_PROP_SHORTHAND(-moz-outline, _moz_outline, MozOutline) // XXX This is tempo CSS_PROP_OUTLINE(-moz-outline-color, _moz_outline_color, MozOutlineColor, Margin, mOutlineColor, eCSSType_Value, PR_FALSE, kOutlineColorKTable) // XXX bug 48973 CSS_PROP_OUTLINE(-moz-outline-style, _moz_outline_style, MozOutlineStyle, Margin, mOutlineStyle, eCSSType_Value, PR_FALSE, kBorderStyleKTable) // XXX bug 48973 CSS_PROP_OUTLINE(-moz-outline-width, _moz_outline_width, MozOutlineWidth, Margin, mOutlineWidth, eCSSType_Value, PR_TRUE, kBorderWidthKTable) // XXX bug 48973 -CSS_PROP_DISPLAY(overflow, overflow, Overflow, Display, mOverflow, eCSSType_Value, PR_FALSE, kOverflowKTable) +CSS_PROP_SHORTHAND(overflow, overflow, Overflow) +CSS_PROP_DISPLAY(overflow-x, overflow_x, OverflowX, Display, mOverflowX, eCSSType_Value, PR_FALSE, kOverflowSubKTable) +CSS_PROP_DISPLAY(overflow-y, overflow_y, OverflowY, Display, mOverflowY, eCSSType_Value, PR_FALSE, kOverflowSubKTable) CSS_PROP_SHORTHAND(padding, padding, Padding) CSS_PROP_PADDING(padding-bottom, padding_bottom, PaddingBottom, Margin, mPadding.mBottom, eCSSType_Value, PR_TRUE, nsnull) CSS_PROP_SHORTHAND(-moz-padding-end, padding_end, MozPaddingEnd) diff --git a/mozilla/content/shared/public/nsCSSProps.h b/mozilla/content/shared/public/nsCSSProps.h index 0da4a705dcc..57c70d3e45a 100644 --- a/mozilla/content/shared/public/nsCSSProps.h +++ b/mozilla/content/shared/public/nsCSSProps.h @@ -149,6 +149,7 @@ public: static const PRInt32 kListStyleKTable[]; static const PRInt32 kOutlineColorKTable[]; static const PRInt32 kOverflowKTable[]; + static const PRInt32 kOverflowSubKTable[]; static const PRInt32 kPageBreakKTable[]; static const PRInt32 kPageBreakInsideKTable[]; static const PRInt32 kPageMarksKTable[]; diff --git a/mozilla/content/shared/public/nsStyleStruct.h b/mozilla/content/shared/public/nsStyleStruct.h index 305c4e2ec01..4d9fdf026d0 100644 --- a/mozilla/content/shared/public/nsStyleStruct.h +++ b/mozilla/content/shared/public/nsStyleStruct.h @@ -731,7 +731,8 @@ 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 mOverflowX; // [reset] see nsStyleConsts.h + PRUint8 mOverflowY; // [reset] see nsStyleConsts.h PRUint8 mClipFlags; // [reset] see nsStyleConsts.h PRBool IsBlockLevel() const {return (NS_STYLE_DISPLAY_BLOCK == mDisplay) || @@ -747,6 +748,21 @@ struct nsStyleDisplay : public nsStyleStruct { PRBool IsPositioned() const {return IsAbsolutelyPositioned() || (NS_STYLE_POSITION_RELATIVE == mPosition);} + + PRBool IsScrollableOverflow() const { + // mOverflowX and mOverflowY always match when one of them is + // NS_STYLE_OVERFLOW_VISIBLE or NS_STYLE_OVERFLOW_CLIP. + return mOverflowX != NS_STYLE_OVERFLOW_VISIBLE && + mOverflowX != 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 mOverflowX == NS_STYLE_OVERFLOW_CLIP || + (mOverflowX == NS_STYLE_OVERFLOW_HIDDEN && + mOverflowY == NS_STYLE_OVERFLOW_HIDDEN); + } }; struct nsStyleTable: public nsStyleStruct { diff --git a/mozilla/content/shared/src/nsCSSProps.cpp b/mozilla/content/shared/src/nsCSSProps.cpp index e90497b114c..e9d144ce36e 100644 --- a/mozilla/content/shared/src/nsCSSProps.cpp +++ b/mozilla/content/shared/src/nsCSSProps.cpp @@ -679,6 +679,7 @@ const PRInt32 nsCSSProps::kOverflowKTable[] = { eCSSKeyword_visible, NS_STYLE_OVERFLOW_VISIBLE, eCSSKeyword_hidden, NS_STYLE_OVERFLOW_HIDDEN, eCSSKeyword_scroll, NS_STYLE_OVERFLOW_SCROLL, + // Deprecated: eCSSKeyword__moz_scrollbars_none, NS_STYLE_OVERFLOW_HIDDEN, eCSSKeyword__moz_scrollbars_horizontal, NS_STYLE_OVERFLOW_SCROLLBARS_HORIZONTAL, eCSSKeyword__moz_scrollbars_vertical, NS_STYLE_OVERFLOW_SCROLLBARS_VERTICAL, @@ -686,6 +687,15 @@ const PRInt32 nsCSSProps::kOverflowKTable[] = { -1,-1 }; +const PRInt32 nsCSSProps::kOverflowSubKTable[] = { + eCSSKeyword_visible, NS_STYLE_OVERFLOW_VISIBLE, + eCSSKeyword_hidden, NS_STYLE_OVERFLOW_HIDDEN, + eCSSKeyword_scroll, NS_STYLE_OVERFLOW_SCROLL, + // Deprecated: + eCSSKeyword__moz_hidden_unscrollable, NS_STYLE_OVERFLOW_CLIP, + -1,-1 +}; + const PRInt32 nsCSSProps::kPageBreakKTable[] = { eCSSKeyword_always, NS_STYLE_PAGE_BREAK_ALWAYS, eCSSKeyword_avoid, NS_STYLE_PAGE_BREAK_AVOID, @@ -1316,6 +1326,12 @@ static const nsCSSProperty gMozOutlineSubpropTable[] = { eCSSProperty_UNKNOWN }; +static const nsCSSProperty gOverflowSubpropTable[] = { + eCSSProperty_overflow_x, + eCSSProperty_overflow_y, + eCSSProperty_UNKNOWN +}; + static const nsCSSProperty gPaddingSubpropTable[] = { // Code relies on these being in top-right-bottom-left order. eCSSProperty_padding_top, diff --git a/mozilla/content/shared/src/nsStyleStruct.cpp b/mozilla/content/shared/src/nsStyleStruct.cpp index fe11994fb64..eb4e27f48c2 100644 --- a/mozilla/content/shared/src/nsStyleStruct.cpp +++ b/mozilla/content/shared/src/nsStyleStruct.cpp @@ -1102,7 +1102,8 @@ nsStyleDisplay::nsStyleDisplay() mBreakType = NS_STYLE_CLEAR_NONE; mBreakBefore = PR_FALSE; mBreakAfter = PR_FALSE; - mOverflow = NS_STYLE_OVERFLOW_VISIBLE; + mOverflowX = NS_STYLE_OVERFLOW_VISIBLE; + mOverflowY = NS_STYLE_OVERFLOW_VISIBLE; mClipFlags = NS_STYLE_CLIP_AUTO; mClip.SetRect(0,0,0,0); mOpacity = 1.0f; @@ -1119,7 +1120,8 @@ nsStyleDisplay::nsStyleDisplay(const nsStyleDisplay& aSource) mBreakType = aSource.mBreakType; mBreakBefore = aSource.mBreakBefore; mBreakAfter = aSource.mBreakAfter; - mOverflow = aSource.mOverflow; + mOverflowX = aSource.mOverflowX; + mOverflowY = aSource.mOverflowY; mClipFlags = aSource.mClipFlags; mClip = aSource.mClip; mOpacity = aSource.mOpacity; @@ -1133,7 +1135,8 @@ nsChangeHint nsStyleDisplay::CalcDifference(const nsStyleDisplay& aOther) const || mPosition != aOther.mPosition || mDisplay != aOther.mDisplay || (mFloats == NS_STYLE_FLOAT_NONE) != (aOther.mFloats == NS_STYLE_FLOAT_NONE) - || mOverflow != aOther.mOverflow + || mOverflowX != aOther.mOverflowX + || mOverflowY != aOther.mOverflowY // might need to create a view to handle change from 1.0 to partial opacity || (mOpacity != aOther.mOpacity && ((mOpacity < 1.0) != (aOther.mOpacity < 1.0)))) diff --git a/mozilla/content/xml/document/src/nsXMLContentSink.cpp b/mozilla/content/xml/document/src/nsXMLContentSink.cpp index 4c8ba67f5aa..5a87993f2ba 100644 --- a/mozilla/content/xml/document/src/nsXMLContentSink.cpp +++ b/mozilla/content/xml/document/src/nsXMLContentSink.cpp @@ -78,7 +78,6 @@ #include "prlog.h" #include "prmem.h" #include "nsParserUtils.h" -#include "nsIScrollable.h" #include "nsRect.h" #include "nsGenericElement.h" #include "nsIWebNavigation.h" @@ -832,12 +831,6 @@ nsXMLContentSink::PopContent() void nsXMLContentSink::StartLayout() { - // Reset scrolling to default settings for this shell. - // This must happen before the initial reflow, when we create the root frame - nsCOMPtr scrollableContainer(do_QueryInterface(mDocShell)); - if (scrollableContainer) { - scrollableContainer->ResetScrollbarPreferences(); - } PRBool topLevelFrameset = PR_FALSE; nsCOMPtr docShellAsItem(do_QueryInterface(mDocShell)); if (docShellAsItem) { diff --git a/mozilla/docshell/base/nsDocShell.cpp b/mozilla/docshell/base/nsDocShell.cpp index 226e5153b69..2499b817d0e 100644 --- a/mozilla/docshell/base/nsDocShell.cpp +++ b/mozilla/docshell/base/nsDocShell.cpp @@ -268,8 +268,7 @@ nsDocShell::nsDocShell(): mMarginHeight(0), mItemType(typeContent), mContentListener(nsnull), - mCurrentScrollbarPref(-1, -1), - mDefaultScrollbarPref(-1, -1), + mDefaultScrollbarPref(Scrollbar_Auto, Scrollbar_Auto), mEditorData(nsnull), mParent(nsnull), mTreeOwner(nsnull), @@ -3652,29 +3651,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, @@ -3696,39 +3672,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) 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 // -// 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, @@ -3749,19 +3700,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.