From f8fdf5f9c2e249bcec7ec29bd78c992abeedf083 Mon Sep 17 00:00:00 2001 From: "roc+%cs.cmu.edu" Date: Thu, 17 Jun 2004 11:57:37 +0000 Subject: [PATCH] Bug 245297. Add basic style system support for columns. r+sr=dbaron git-svn-id: svn://10.0.0.236/trunk@158023 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/content/base/src/nsRuleNode.cpp | 84 +++++++++++++++++++ mozilla/content/base/src/nsStyleContext.cpp | 10 +++ .../content/html/style/src/nsCSSDataBlock.h | 1 + .../content/html/style/src/nsCSSParser.cpp | 4 + .../content/html/style/src/nsCSSStruct.cpp | 31 +++++++ mozilla/content/html/style/src/nsCSSStruct.h | 16 ++++ .../html/style/src/nsComputedDOMStyle.cpp | 53 ++++++++++++ .../html/style/src/nsComputedDOMStyle.h | 4 + mozilla/content/shared/public/nsCSSPropList.h | 12 +++ mozilla/content/shared/public/nsRuleNode.h | 10 ++- mozilla/content/shared/public/nsStyleStruct.h | 21 +++++ .../content/shared/public/nsStyleStructList.h | 25 +++--- mozilla/content/shared/src/nsCSSProps.cpp | 2 + mozilla/content/shared/src/nsStyleStruct.cpp | 26 ++++++ .../public/idl/css/nsIDOMCSS2Properties.idl | 8 +- mozilla/layout/base/nsStyleConsts.h | 4 + mozilla/layout/base/public/nsStyleConsts.h | 4 + mozilla/layout/style/nsCSSDataBlock.h | 1 + mozilla/layout/style/nsCSSParser.cpp | 4 + mozilla/layout/style/nsCSSPropList.h | 12 +++ mozilla/layout/style/nsCSSProps.cpp | 2 + mozilla/layout/style/nsCSSStruct.cpp | 31 +++++++ mozilla/layout/style/nsCSSStruct.h | 16 ++++ mozilla/layout/style/nsComputedDOMStyle.cpp | 53 ++++++++++++ mozilla/layout/style/nsComputedDOMStyle.h | 4 + mozilla/layout/style/nsRuleNode.cpp | 84 +++++++++++++++++++ mozilla/layout/style/nsRuleNode.h | 10 ++- mozilla/layout/style/nsStyleContext.cpp | 10 +++ mozilla/layout/style/nsStyleStruct.cpp | 26 ++++++ mozilla/layout/style/nsStyleStruct.h | 21 +++++ mozilla/layout/style/nsStyleStructList.h | 25 +++--- 31 files changed, 585 insertions(+), 29 deletions(-) diff --git a/mozilla/content/base/src/nsRuleNode.cpp b/mozilla/content/base/src/nsRuleNode.cpp index 6cc5ff1ec71..2900363190f 100644 --- a/mozilla/content/base/src/nsRuleNode.cpp +++ b/mozilla/content/base/src/nsRuleNode.cpp @@ -247,6 +247,7 @@ nscoord CalcLength(const nsCSSValue& aValue, #define SETCOORD_LP (SETCOORD_LENGTH | SETCOORD_PERCENT) #define SETCOORD_LH (SETCOORD_LENGTH | SETCOORD_INHERIT) #define SETCOORD_AH (SETCOORD_AUTO | SETCOORD_INHERIT) +#define SETCOORD_LAH (SETCOORD_AUTO | SETCOORD_LENGTH | SETCOORD_INHERIT) #define SETCOORD_LPH (SETCOORD_LP | SETCOORD_INHERIT) #define SETCOORD_LPAH (SETCOORD_LP | SETCOORD_AH) #define SETCOORD_LPEH (SETCOORD_LP | SETCOORD_ENUMERATED | SETCOORD_INHERIT) @@ -797,6 +798,13 @@ static const PropertyCheckData SVGResetCheckProperties[] = { }; #endif +static const PropertyCheckData ColumnCheckProperties[] = { +#define CSS_PROP_COLUMN(name_, id_, method_, datastruct_, member_, type_, iscoord_, kwtable_) \ + { offsetof(nsRuleData##datastruct_, member_), type_ }, +#include "nsCSSPropList.h" +#undef CSS_PROP_COLUMN +}; + #undef CSS_PROP_INCLUDE_NOT_CSS static const StructCheckData gCheckProperties[] = { @@ -1187,6 +1195,16 @@ nsRuleNode::GetXULData(nsStyleContext* aContext) return WalkRuleTree(eStyleStruct_XUL, aContext, &ruleData, &xulData); } +const nsStyleStruct* +nsRuleNode::GetColumnData(nsStyleContext* aContext) +{ + nsRuleDataColumn columnData; // Declare a struct with null CSS values. + nsRuleData ruleData(eStyleStruct_Column, mPresContext, aContext); + ruleData.mColumnData = &columnData; + + return WalkRuleTree(eStyleStruct_Column, aContext, &ruleData, &columnData); +} + #ifdef MOZ_SVG const nsStyleStruct* nsRuleNode::GetSVGData(nsStyleContext* aContext) @@ -1508,6 +1526,13 @@ nsRuleNode::SetDefaultOnRoot(const nsStyleStructID aSID, nsStyleContext* aContex return xul; } + case eStyleStruct_Column: + { + nsStyleColumn* column = new (mPresContext) nsStyleColumn(); + aContext->SetStyle(eStyleStruct_Column, column); + return column; + } + #ifdef MOZ_SVG case eStyleStruct_SVG: { @@ -4195,6 +4220,65 @@ nsRuleNode::ComputeXULData(nsStyleStruct* aStartStruct, return xul; } +const nsStyleStruct* +nsRuleNode::ComputeColumnData(nsStyleStruct* aStartStruct, + const nsRuleDataStruct& aData, + nsStyleContext* aContext, + nsRuleNode* aHighestNode, + const RuleDetail& aRuleDetail, PRBool aInherited) +{ + nsStyleContext* parentContext = aContext->GetParent(); + + const nsRuleDataColumn& columnData = NS_STATIC_CAST(const nsRuleDataColumn&, aData); + nsStyleColumn* column = nsnull; + + if (aStartStruct) + // We only need to compute the delta between this computed data and our + // computed data. + column = new (mPresContext) nsStyleColumn(*NS_STATIC_CAST(nsStyleColumn*, aStartStruct)); + else + column = new (mPresContext) nsStyleColumn(); + + const nsStyleColumn* parent = column; + if (parentContext && + aRuleDetail != eRuleFullReset && + aRuleDetail != eRulePartialReset && + aRuleDetail != eRuleNone) + parent = parentContext->GetStyleColumn(); + + PRBool inherited = aInherited; + + // column-width: length, auto, inherit + SetCoord(columnData.mColumnWidth, + column->mColumnWidth, parent->mColumnWidth, SETCOORD_LAH, + aContext, mPresContext, inherited); + + // column-count: auto, integer, inherit + if (eCSSUnit_Auto == columnData.mColumnCount.GetUnit()) { + column->mColumnCount = NS_STYLE_COLUMN_COUNT_AUTO; + } else if (eCSSUnit_Integer == columnData.mColumnCount.GetUnit()) { + column->mColumnCount = columnData.mColumnCount.GetIntValue(); + } else if (eCSSUnit_Inherit == columnData.mColumnCount.GetUnit()) { + inherited = PR_TRUE; + column->mColumnCount = parent->mColumnCount; + } + + if (inherited) + // We inherited, and therefore can't be cached in the rule node. We have to be put right on the + // style context. + aContext->SetStyle(eStyleStruct_Column, column); + else { + // We were fully specified and can therefore be cached right on the rule node. + if (!aHighestNode->mStyleData.mResetData) + aHighestNode->mStyleData.mResetData = new (mPresContext) nsResetStyleData; + aHighestNode->mStyleData.mResetData->mColumnData = column; + // Propagate the bit down. + PropagateDependentBit(NS_STYLE_INHERIT_BIT(Column), aHighestNode); + } + + return column; +} + #ifdef MOZ_SVG static void SetSVGPaint(const nsCSSValue& aValue, const nsStyleSVGPaint& parentPaint, diff --git a/mozilla/content/base/src/nsStyleContext.cpp b/mozilla/content/base/src/nsStyleContext.cpp index bdad63db4e6..687fd51fa1a 100644 --- a/mozilla/content/base/src/nsStyleContext.cpp +++ b/mozilla/content/base/src/nsStyleContext.cpp @@ -451,6 +451,7 @@ nsStyleContext::CalcStyleDifference(nsStyleContext* aOther) // Visibility, Quotes DO_STRUCT_DIFFERENCE(Display); DO_STRUCT_DIFFERENCE(XUL); + DO_STRUCT_DIFFERENCE(Column); DO_STRUCT_DIFFERENCE(Content); DO_STRUCT_DIFFERENCE(UserInterface); DO_STRUCT_DIFFERENCE(Visibility); @@ -806,6 +807,15 @@ void nsStyleContext::DumpRegressionData(nsIPresContext* aPresContext, FILE* out, (int)uiReset->mUserSelect, (int)uiReset->mKeyEquivalent); + // Column + IndentBy(out,aIndent); + const nsStyleColumn* column = GetStyleColumn(); + fprintf(out, "mColumnCount); + column->mColumnWidth.ToString(str); + fprintf(out, "%s", NS_ConvertUCS2toUTF8(str).get()); + fprintf(out, "\" />\n"); + // XUL IndentBy(out,aIndent); const nsStyleXUL* xul = GetStyleXUL(); diff --git a/mozilla/content/html/style/src/nsCSSDataBlock.h b/mozilla/content/html/style/src/nsCSSDataBlock.h index f8538a4d134..2ddef369e66 100644 --- a/mozilla/content/html/style/src/nsCSSDataBlock.h +++ b/mozilla/content/html/style/src/nsCSSDataBlock.h @@ -138,6 +138,7 @@ public: #ifdef MOZ_SVG nsCSSSVG mSVG; #endif + nsCSSColumn mColumn; /** * Transfer all of the state from the compressed block to this diff --git a/mozilla/content/html/style/src/nsCSSParser.cpp b/mozilla/content/html/style/src/nsCSSParser.cpp index 61cfa087325..d668cdf16c7 100644 --- a/mozilla/content/html/style/src/nsCSSParser.cpp +++ b/mozilla/content/html/style/src/nsCSSParser.cpp @@ -4118,6 +4118,10 @@ PRBool CSSParserImpl::ParseSingleValueProperty(nsresult& aErrorCode, case eCSSProperty__moz_border_radius_bottomRight: case eCSSProperty__moz_border_radius_bottomLeft: return ParseVariant(aErrorCode, aValue, VARIANT_HLP, nsnull); + case eCSSProperty__moz_column_count: + return ParsePositiveVariant(aErrorCode, aValue, VARIANT_AHI, nsnull); + case eCSSProperty__moz_column_width: + return ParseVariant(aErrorCode, aValue, VARIANT_AHL, nsnull); #ifdef ENABLE_OUTLINE case eCSSProperty__moz_outline_radius_topLeft: case eCSSProperty__moz_outline_radius_topRight: diff --git a/mozilla/content/html/style/src/nsCSSStruct.cpp b/mozilla/content/html/style/src/nsCSSStruct.cpp index f54b9077215..51d968e8b95 100644 --- a/mozilla/content/html/style/src/nsCSSStruct.cpp +++ b/mozilla/content/html/style/src/nsCSSStruct.cpp @@ -1153,6 +1153,37 @@ void nsCSSXUL::List(FILE* out, PRInt32 aIndent) const } #endif +// --- nsCSSColumn ----------------- + +nsCSSColumn::nsCSSColumn(void) +{ + MOZ_COUNT_CTOR(nsCSSColumn); +} + +nsCSSColumn::nsCSSColumn(const nsCSSColumn& aCopy) + : mColumnCount(aCopy.mColumnCount), mColumnWidth(aCopy.mColumnWidth) +{ + MOZ_COUNT_CTOR(nsCSSColumn); +} + +nsCSSColumn::~nsCSSColumn(void) +{ + MOZ_COUNT_DTOR(nsCSSColumn); +} + +#ifdef DEBUG +void nsCSSColumn::List(FILE* out, PRInt32 aIndent) const +{ + for (PRInt32 index = aIndent; --index >= 0; ) fputs(" ", out); + + nsAutoString buffer; + + mColumnWidth.AppendToString(buffer, eCSSProperty__moz_column_width); + mColumnCount.AppendToString(buffer, eCSSProperty__moz_column_count); + fputs(NS_LossyConvertUCS2toASCII(buffer).get(), out); +} +#endif + #ifdef MOZ_SVG // --- nsCSSSVG ----------------- diff --git a/mozilla/content/html/style/src/nsCSSStruct.h b/mozilla/content/html/style/src/nsCSSStruct.h index 7fa11868cc9..9342dd98ce7 100644 --- a/mozilla/content/html/style/src/nsCSSStruct.h +++ b/mozilla/content/html/style/src/nsCSSStruct.h @@ -507,6 +507,22 @@ struct nsCSSXUL : public nsCSSStruct { struct nsRuleDataXUL : public nsCSSXUL { }; +struct nsCSSColumn : public nsCSSStruct { + nsCSSColumn(void); + nsCSSColumn(const nsCSSColumn& aCopy); + ~nsCSSColumn(void); + +#ifdef DEBUG + void List(FILE* out = stdout, PRInt32 aIndent = 0) const; +#endif + + nsCSSValue mColumnCount; + nsCSSValue mColumnWidth; +}; + +struct nsRuleDataColumn : public nsCSSColumn { +}; + #ifdef MOZ_SVG struct nsCSSSVG : public nsCSSStruct { nsCSSSVG(void); diff --git a/mozilla/content/html/style/src/nsComputedDOMStyle.cpp b/mozilla/content/html/style/src/nsComputedDOMStyle.cpp index fee64e77835..4bf2bdde06b 100644 --- a/mozilla/content/html/style/src/nsComputedDOMStyle.cpp +++ b/mozilla/content/html/style/src/nsComputedDOMStyle.cpp @@ -519,6 +519,57 @@ nsComputedDOMStyle::GetOpacity(nsIFrame *aFrame, return CallQueryInterface(val, aValue); } +nsresult +nsComputedDOMStyle::GetColumnCount(nsIFrame *aFrame, + nsIDOMCSSValue** aValue) +{ + nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue(); + NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY); + + const nsStyleColumn* column = nsnull; + GetStyleData(eStyleStruct_Column, (const nsStyleStruct*&)column, aFrame); + + if (column) { + if (column->mColumnCount == NS_STYLE_COLUMN_COUNT_AUTO) { + val->SetIdent(nsLayoutAtoms::autoAtom); + } else { + val->SetNumber(column->mColumnCount); + } + } + + return CallQueryInterface(val, aValue); +} + +nsresult +nsComputedDOMStyle::GetColumnWidth(nsIFrame *aFrame, + nsIDOMCSSValue** aValue) +{ + nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue(); + NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY); + + const nsStyleColumn* column = nsnull; + GetStyleData(eStyleStruct_Column, (const nsStyleStruct*&)column, aFrame); + + if (column) { + switch (column->mColumnWidth.GetUnit()) { + case eStyleUnit_Coord: + val->SetTwips(column->mColumnWidth.GetCoordValue()); + break; + case eStyleUnit_Auto: + // XXX fix this. When we actually have a column frame, I think + // we should return the computed column width. + val->SetIdent(nsLayoutAtoms::autoAtom); + break; + default: + NS_WARNING("Bad column width unit"); + val->SetTwips(0); + break; + } + } + + return CallQueryInterface(val, aValue); +} + nsresult nsComputedDOMStyle::GetFontFamily(nsIFrame *aFrame, nsIDOMCSSValue** aValue) @@ -3522,6 +3573,8 @@ nsComputedDOMStyle::GetQueryablePropertyMap(PRUint32* aLength) COMPUTED_STYLE_MAP_ENTRY(box_orient, BoxOrient), COMPUTED_STYLE_MAP_ENTRY(box_pack, BoxPack), COMPUTED_STYLE_MAP_ENTRY(box_sizing, BoxSizing), + COMPUTED_STYLE_MAP_ENTRY(_moz_column_count, ColumnCount), + COMPUTED_STYLE_MAP_ENTRY(_moz_column_width, ColumnWidth), COMPUTED_STYLE_MAP_ENTRY(float_edge, FloatEdge), COMPUTED_STYLE_MAP_ENTRY(image_region, ImageRegion), COMPUTED_STYLE_MAP_ENTRY(opacity, Opacity), diff --git a/mozilla/content/html/style/src/nsComputedDOMStyle.h b/mozilla/content/html/style/src/nsComputedDOMStyle.h index 43d71f8373e..45adc77e1cf 100644 --- a/mozilla/content/html/style/src/nsComputedDOMStyle.h +++ b/mozilla/content/html/style/src/nsComputedDOMStyle.h @@ -280,6 +280,10 @@ private: nsresult GetUserModify(nsIFrame *aFrame, nsIDOMCSSValue** aValue); nsresult GetUserSelect(nsIFrame *aFrame, nsIDOMCSSValue** aValue); + /* Column properties */ + nsresult GetColumnCount(nsIFrame *aFrame, nsIDOMCSSValue** aValue); + nsresult GetColumnWidth(nsIFrame *aFrame, nsIDOMCSSValue** aValue); + nsROCSSPrimitiveValue* GetROCSSPrimitiveValue(); nsDOMCSSValueList* GetROCSSValueList(PRBool aCommaDelimited); nsDOMCSSRGBColor* GetDOMCSSRGBColor(nscolor aColor); diff --git a/mozilla/content/shared/public/nsCSSPropList.h b/mozilla/content/shared/public/nsCSSPropList.h index 1281a2fc4c8..6146c431bca 100644 --- a/mozilla/content/shared/public/nsCSSPropList.h +++ b/mozilla/content/shared/public/nsCSSPropList.h @@ -133,6 +133,7 @@ #define CSS_PROP_BORDER(name_, id_, method_, datastruct_, member_, type_, iscoord_, kwtable_) CSS_PROP(name_, id_, method_, datastruct_, member_, type_, iscoord_, kwtable_) #define CSS_PROP_OUTLINE(name_, id_, method_, datastruct_, member_, type_, iscoord_, kwtable_) CSS_PROP(name_, id_, method_, datastruct_, member_, type_, iscoord_, kwtable_) #define CSS_PROP_XUL(name_, id_, method_, datastruct_, member_, type_, iscoord_, kwtable_) CSS_PROP(name_, id_, method_, datastruct_, member_, type_, iscoord_, kwtable_) +#define CSS_PROP_COLUMN(name_, id_, method_, datastruct_, member_, type_, iscoord_, kwtable_) CSS_PROP(name_, id_, method_, datastruct_, member_, type_, iscoord_, kwtable_) #ifdef MOZ_SVG #define CSS_PROP_SVG(name_, id_, method_, datastruct_, member_, type_, iscoord_, kwtable_) CSS_PROP(name_, id_, method_, datastruct_, member_, type_, iscoord_, kwtable_) #define CSS_PROP_SVGRESET(name_, id_, method_, datastruct_, member_, type_, iscoord_, kwtable_) CSS_PROP(name_, id_, method_, datastruct_, member_, type_, iscoord_, kwtable_) @@ -232,6 +233,10 @@ #define CSS_PROP_XUL(name_, id_, method_, datastruct_, member_, type_, iscoord_, kwtable_) /* nothing */ #define DEFINED_CSS_PROP_XUL #endif +#ifndef CSS_PROP_COLUMN +#define CSS_PROP_COLUMN(name_, id_, method_, datastruct_, member_, type_, iscoord_, kwtable_) /* nothing */ +#define DEFINED_CSS_PROP_COLUMN +#endif #ifdef MOZ_SVG #ifndef CSS_PROP_SVG #define CSS_PROP_SVG(name_, id_, method_, datastruct_, member_, type_, iscoord_, kwtable_) /* nothing */ @@ -325,6 +330,8 @@ CSS_PROP_TABLEBORDER(caption-side, caption_side, CaptionSide, Table, mCaptionSid CSS_PROP_DISPLAY(clear, clear, Clear, Display, mClear, eCSSType_Value, PR_FALSE, kClearKTable) CSS_PROP_DISPLAY(clip, clip, Clip, Display, mClip, eCSSType_Rect, PR_FALSE, nsnull) CSS_PROP_COLOR(color, color, Color, Color, mColor, eCSSType_Value, PR_FALSE, nsnull) +CSS_PROP_COLUMN(-moz-column-count, _moz_column_count, MozColumnCount, Column, mColumnCount, eCSSType_Value, PR_FALSE, nsnull) +CSS_PROP_COLUMN(-moz-column-width, _moz_column_width, MozColumnWidth, Column, mColumnWidth, eCSSType_Value, PR_TRUE, nsnull) CSS_PROP_CONTENT(content, content, Content, Content, mContent, eCSSType_ValueList, PR_FALSE, kContentKTable) CSS_PROP_NOTIMPLEMENTED(counter-increment, counter_increment, CounterIncrement) CSS_PROP_NOTIMPLEMENTED(counter-reset, counter_reset, CounterReset) @@ -540,6 +547,7 @@ CSS_PROP_TABLE(X, X, X, Table, mSpan, eCSSType_Value, PR_FALSE, nsnull) #undef CSS_PROP_BORDER #undef CSS_PROP_OUTLINE #undef CSS_PROP_XUL +#undef CSS_PROP_COLUMN #ifdef MOZ_SVG #undef CSS_PROP_SVG #undef CSS_PROP_SVGRESET @@ -631,6 +639,10 @@ CSS_PROP_TABLE(X, X, X, Table, mSpan, eCSSType_Value, PR_FALSE, nsnull) #undef CSS_PROP_XUL #undef DEFINED_CSS_PROP_XUL #endif +#ifdef DEFINED_CSS_PROP_COLUMN +#undef CSS_PROP_COLUMN +#undef DEFINED_CSS_PROP_COLUMN +#endif #ifdef MOZ_SVG #ifdef DEFINED_CSS_PROP_SVG #undef CSS_PROP_SVG diff --git a/mozilla/content/shared/public/nsRuleNode.h b/mozilla/content/shared/public/nsRuleNode.h index 11d1287a96f..6781f033dd6 100644 --- a/mozilla/content/shared/public/nsRuleNode.h +++ b/mozilla/content/shared/public/nsRuleNode.h @@ -258,11 +258,13 @@ struct nsRuleData nsRuleDataSVG* mSVGData; #endif + nsRuleDataColumn* mColumnData; + nsRuleData(const nsStyleStructID& aSID, nsIPresContext* aContext, nsStyleContext* aStyleContext) :mSID(aSID), mPresContext(aContext), mStyleContext(aStyleContext), mPostResolveCallback(nsnull), mFontData(nsnull), mDisplayData(nsnull), mMarginData(nsnull), mListData(nsnull), mPositionData(nsnull), mTableData(nsnull), mColorData(nsnull), mContentData(nsnull), mTextData(nsnull), - mUserInterfaceData(nsnull) + mUserInterfaceData(nsnull), mColumnData(nsnull) { mCanStoreInRuleTree = PR_TRUE; mXULData = nsnull; @@ -523,6 +525,11 @@ protected: nsStyleContext* aContext, nsRuleNode* aHighestNode, const RuleDetail& aRuleDetail, PRBool aInherited); + NS_HIDDEN_(const nsStyleStruct*) + ComputeColumnData(nsStyleStruct* aStartColumn, const nsRuleDataStruct& aColumnData, + nsStyleContext* aContext, nsRuleNode* aHighestNode, + const RuleDetail& aRuleDetail, PRBool aInherited); + #ifdef MOZ_SVG NS_HIDDEN_(const nsStyleStruct*) ComputeSVGData(nsStyleStruct* aStartSVG, const nsRuleDataStruct& aSVGData, @@ -593,6 +600,7 @@ protected: NS_HIDDEN_(const nsStyleStruct*) GetUIResetData(nsStyleContext* aContext); NS_HIDDEN_(const nsStyleStruct*) GetXULData(nsStyleContext* aContext); + NS_HIDDEN_(const nsStyleStruct*) GetColumnData(nsStyleContext* aContext); #ifdef MOZ_SVG NS_HIDDEN_(const nsStyleStruct*) GetSVGData(nsStyleContext* aContext); NS_HIDDEN_(const nsStyleStruct*) GetSVGResetData(nsStyleContext* aContext); diff --git a/mozilla/content/shared/public/nsStyleStruct.h b/mozilla/content/shared/public/nsStyleStruct.h index fc3922faad8..1c9d3513963 100644 --- a/mozilla/content/shared/public/nsStyleStruct.h +++ b/mozilla/content/shared/public/nsStyleStruct.h @@ -1132,6 +1132,27 @@ struct nsStyleXUL : public nsStyleStruct { PRUint8 mBoxPack; // [reset] see nsStyleConsts.h }; +struct nsStyleColumn : public nsStyleStruct { + nsStyleColumn(); + nsStyleColumn(const nsStyleColumn& aSource); + ~nsStyleColumn(); + + NS_DEFINE_STATIC_STYLESTRUCTID_ACCESSOR(eStyleStruct_Column) + + void* operator new(size_t sz, nsIPresContext* aContext) CPP_THROW_NEW { + return aContext->AllocateFromShell(sz); + } + void Destroy(nsIPresContext* aContext) { + this->~nsStyleColumn(); + aContext->FreeToShell(sizeof(nsStyleColumn), this); + }; + + nsChangeHint CalcDifference(const nsStyleColumn& aOther) const; + + PRUint32 mColumnCount; // [reset] see nsStyleConsts.h + nsStyleCoord mColumnWidth; // [reset] see nsStyleConsts.h +}; + #ifdef MOZ_SVG enum nsStyleSVGPaintType { eStyleSVGPaintType_None = 0, diff --git a/mozilla/content/shared/public/nsStyleStructList.h b/mozilla/content/shared/public/nsStyleStructList.h index 382b5bf5948..90758bb4954 100644 --- a/mozilla/content/shared/public/nsStyleStructList.h +++ b/mozilla/content/shared/public/nsStyleStructList.h @@ -121,36 +121,35 @@ STYLE_STRUCT_RESET(Margin, nsnull, ()) STYLE_STRUCT_TEST_CODE( }) STYLE_STRUCT_TEST_CODE( }) STYLE_STRUCT_TEST_CODE( }) - STYLE_STRUCT_TEST_CODE(} else {) + STYLE_STRUCT_TEST_CODE(} else if (STYLE_STRUCT_TEST < 20) {) STYLE_STRUCT_TEST_CODE( if (STYLE_STRUCT_TEST < 18) {) STYLE_STRUCT_TEST_CODE( if (STYLE_STRUCT_TEST == 16) {) STYLE_STRUCT_RESET(Padding, nsnull, ()) STYLE_STRUCT_TEST_CODE( } else {) STYLE_STRUCT_RESET(Border, nsnull, ()) STYLE_STRUCT_TEST_CODE( }) -#ifndef MOZ_SVG - STYLE_STRUCT_TEST_CODE( } else if (STYLE_STRUCT_TEST == 18) {) -STYLE_STRUCT_RESET(Outline, nsnull, (SSARG_PRESCONTEXT)) STYLE_STRUCT_TEST_CODE( } else {) - STYLE_STRUCT_TEST_CODE( NS_ASSERTION(STYLE_STRUCT_TEST == 19, "out of range");) -STYLE_STRUCT_RESET(XUL, nsnull, ()) - STYLE_STRUCT_TEST_CODE( }) - STYLE_STRUCT_TEST_CODE(}) -#else // MOZ_SVG - STYLE_STRUCT_TEST_CODE( } else if (STYLE_STRUCT_TEST < 20) {) STYLE_STRUCT_TEST_CODE( if (STYLE_STRUCT_TEST == 18) {) STYLE_STRUCT_RESET(Outline, nsnull, (SSARG_PRESCONTEXT)) STYLE_STRUCT_TEST_CODE( } else {) STYLE_STRUCT_RESET(XUL, nsnull, ()) STYLE_STRUCT_TEST_CODE( }) - STYLE_STRUCT_TEST_CODE( } else if (STYLE_STRUCT_TEST == 20) {) + STYLE_STRUCT_TEST_CODE( }) +#ifndef MOZ_SVG + STYLE_STRUCT_TEST_CODE(} else {) + STYLE_STRUCT_TEST_CODE( NS_ASSERTION(STYLE_STRUCT_TEST == 20, "out of range");) +#else + STYLE_STRUCT_TEST_CODE(} else if (STYLE_STRUCT_TEST < 22) {) + STYLE_STRUCT_TEST_CODE( if (STYLE_STRUCT_TEST == 20) {) STYLE_STRUCT_INHERITED(SVG, nsnull, ()) STYLE_STRUCT_TEST_CODE( } else {) - STYLE_STRUCT_TEST_CODE( NS_ASSERTION(STYLE_STRUCT_TEST == 21, "out of range");) STYLE_STRUCT_RESET(SVGReset,nsnull, ()) STYLE_STRUCT_TEST_CODE( }) - STYLE_STRUCT_TEST_CODE(}) + STYLE_STRUCT_TEST_CODE(} else {) + STYLE_STRUCT_TEST_CODE( NS_ASSERTION(STYLE_STRUCT_TEST == 22, "out of range");) #endif + STYLE_STRUCT_RESET(Column, nsnull, ()) +STYLE_STRUCT_TEST_CODE(}) #ifdef UNDEF_STYLE_STRUCT_INHERITED #undef STYLE_STRUCT_INHERITED diff --git a/mozilla/content/shared/src/nsCSSProps.cpp b/mozilla/content/shared/src/nsCSSProps.cpp index 510efc345c0..1e325321917 100644 --- a/mozilla/content/shared/src/nsCSSProps.cpp +++ b/mozilla/content/shared/src/nsCSSProps.cpp @@ -1080,6 +1080,7 @@ const nsStyleStructID nsCSSProps::kSIDTable[eCSSProperty_COUNT_no_shorthands] = #define CSS_PROP_SVG(name_, id_, method_, datastruct_, member_, type_, iscoord_, kwtable_) eStyleStruct_SVG, #define CSS_PROP_SVGRESET(name_, id_, method_, datastruct_, member_, type_, iscoord_, kwtable_) eStyleStruct_SVGReset, #endif /* defined(MOZ_SVG) */ + #define CSS_PROP_COLUMN(name_, id_, method_, datastruct_, member_, type_, iscoord_, kwtable_) eStyleStruct_Column, // This shouldn't matter, but we need something to go here. #define CSS_PROP_BACKENDONLY(name_, id_, method_, datastruct_, member_, type_, iscoord_, kwtable_) nsStyleStructID(-1), @@ -1109,6 +1110,7 @@ const nsStyleStructID nsCSSProps::kSIDTable[eCSSProperty_COUNT_no_shorthands] = #undef CSS_PROP_SVG #undef CSS_PROP_SVGRESET #endif /* undefd(MOZ_SVG) */ + #undef CSS_PROP_COLUMN #undef CSS_PROP_BACKENDONLY }; diff --git a/mozilla/content/shared/src/nsStyleStruct.cpp b/mozilla/content/shared/src/nsStyleStruct.cpp index 7acdbe101c7..424ad899f6e 100644 --- a/mozilla/content/shared/src/nsStyleStruct.cpp +++ b/mozilla/content/shared/src/nsStyleStruct.cpp @@ -720,6 +720,32 @@ nsChangeHint nsStyleXUL::CalcDifference(const nsStyleXUL& aOther) const return NS_STYLE_HINT_REFLOW; } +// -------------------- +// nsStyleColumn +// +nsStyleColumn::nsStyleColumn() +{ + mColumnCount = NS_STYLE_COLUMN_COUNT_AUTO; + mColumnWidth.SetAutoValue(); +} + +nsStyleColumn::~nsStyleColumn() +{ +} + +nsStyleColumn::nsStyleColumn(const nsStyleColumn& aSource) +{ + memcpy((nsStyleColumn*)this, &aSource, sizeof(nsStyleColumn)); +} + +nsChangeHint nsStyleColumn::CalcDifference(const nsStyleColumn& aOther) const +{ + if (mColumnWidth == aOther.mColumnWidth && + mColumnCount == aOther.mColumnCount) + return NS_STYLE_HINT_NONE; + return nsChangeHint_ReconstructFrame; +} + #ifdef MOZ_SVG // -------------------- // nsStyleSVG diff --git a/mozilla/dom/public/idl/css/nsIDOMCSS2Properties.idl b/mozilla/dom/public/idl/css/nsIDOMCSS2Properties.idl index 7453b649233..75f9f92a6ff 100644 --- a/mozilla/dom/public/idl/css/nsIDOMCSS2Properties.idl +++ b/mozilla/dom/public/idl/css/nsIDOMCSS2Properties.idl @@ -409,7 +409,7 @@ interface nsIDOMCSS2Properties : nsISupports // raises(DOMException) on setting }; -[scriptable, uuid(6e80997d-98ae-47c1-95df-90a8fd9f0c0a)] +[scriptable, uuid(9dec6a34-beb2-4796-9e39-ba8b45b95777)] interface nsIDOMNSCSS2Properties : nsIDOMCSS2Properties { /* Non-DOM 2 extensions */ @@ -478,6 +478,12 @@ interface nsIDOMNSCSS2Properties : nsIDOMCSS2Properties attribute DOMString MozBoxSizing; // raises(DOMException) on setting + attribute DOMString MozColumnCount; + // raises(DOMException) on setting + + attribute DOMString MozColumnWidth; + // raises(DOMException) on setting + attribute DOMString MozCounterIncrement; // raises(DOMException) on setting diff --git a/mozilla/layout/base/nsStyleConsts.h b/mozilla/layout/base/nsStyleConsts.h index 5450842a04d..696c65a6753 100644 --- a/mozilla/layout/base/nsStyleConsts.h +++ b/mozilla/layout/base/nsStyleConsts.h @@ -622,6 +622,10 @@ #define NS_STYLE_PAGE_BREAK_LEFT 3 #define NS_STYLE_PAGE_BREAK_RIGHT 4 +// See nsStyleColumn +#define NS_STYLE_COLUMN_COUNT_AUTO 0 +#define NS_STYLE_COLUMN_COUNT_UNLIMITED (-1) + #ifdef MOZ_SVG // Some of our constants must map to the same values as those defined in // nsISVG{,Path,Glyph}GeometrySource.idl/ diff --git a/mozilla/layout/base/public/nsStyleConsts.h b/mozilla/layout/base/public/nsStyleConsts.h index 5450842a04d..696c65a6753 100644 --- a/mozilla/layout/base/public/nsStyleConsts.h +++ b/mozilla/layout/base/public/nsStyleConsts.h @@ -622,6 +622,10 @@ #define NS_STYLE_PAGE_BREAK_LEFT 3 #define NS_STYLE_PAGE_BREAK_RIGHT 4 +// See nsStyleColumn +#define NS_STYLE_COLUMN_COUNT_AUTO 0 +#define NS_STYLE_COLUMN_COUNT_UNLIMITED (-1) + #ifdef MOZ_SVG // Some of our constants must map to the same values as those defined in // nsISVG{,Path,Glyph}GeometrySource.idl/ diff --git a/mozilla/layout/style/nsCSSDataBlock.h b/mozilla/layout/style/nsCSSDataBlock.h index f8538a4d134..2ddef369e66 100644 --- a/mozilla/layout/style/nsCSSDataBlock.h +++ b/mozilla/layout/style/nsCSSDataBlock.h @@ -138,6 +138,7 @@ public: #ifdef MOZ_SVG nsCSSSVG mSVG; #endif + nsCSSColumn mColumn; /** * Transfer all of the state from the compressed block to this diff --git a/mozilla/layout/style/nsCSSParser.cpp b/mozilla/layout/style/nsCSSParser.cpp index 61cfa087325..d668cdf16c7 100644 --- a/mozilla/layout/style/nsCSSParser.cpp +++ b/mozilla/layout/style/nsCSSParser.cpp @@ -4118,6 +4118,10 @@ PRBool CSSParserImpl::ParseSingleValueProperty(nsresult& aErrorCode, case eCSSProperty__moz_border_radius_bottomRight: case eCSSProperty__moz_border_radius_bottomLeft: return ParseVariant(aErrorCode, aValue, VARIANT_HLP, nsnull); + case eCSSProperty__moz_column_count: + return ParsePositiveVariant(aErrorCode, aValue, VARIANT_AHI, nsnull); + case eCSSProperty__moz_column_width: + return ParseVariant(aErrorCode, aValue, VARIANT_AHL, nsnull); #ifdef ENABLE_OUTLINE case eCSSProperty__moz_outline_radius_topLeft: case eCSSProperty__moz_outline_radius_topRight: diff --git a/mozilla/layout/style/nsCSSPropList.h b/mozilla/layout/style/nsCSSPropList.h index 1281a2fc4c8..6146c431bca 100644 --- a/mozilla/layout/style/nsCSSPropList.h +++ b/mozilla/layout/style/nsCSSPropList.h @@ -133,6 +133,7 @@ #define CSS_PROP_BORDER(name_, id_, method_, datastruct_, member_, type_, iscoord_, kwtable_) CSS_PROP(name_, id_, method_, datastruct_, member_, type_, iscoord_, kwtable_) #define CSS_PROP_OUTLINE(name_, id_, method_, datastruct_, member_, type_, iscoord_, kwtable_) CSS_PROP(name_, id_, method_, datastruct_, member_, type_, iscoord_, kwtable_) #define CSS_PROP_XUL(name_, id_, method_, datastruct_, member_, type_, iscoord_, kwtable_) CSS_PROP(name_, id_, method_, datastruct_, member_, type_, iscoord_, kwtable_) +#define CSS_PROP_COLUMN(name_, id_, method_, datastruct_, member_, type_, iscoord_, kwtable_) CSS_PROP(name_, id_, method_, datastruct_, member_, type_, iscoord_, kwtable_) #ifdef MOZ_SVG #define CSS_PROP_SVG(name_, id_, method_, datastruct_, member_, type_, iscoord_, kwtable_) CSS_PROP(name_, id_, method_, datastruct_, member_, type_, iscoord_, kwtable_) #define CSS_PROP_SVGRESET(name_, id_, method_, datastruct_, member_, type_, iscoord_, kwtable_) CSS_PROP(name_, id_, method_, datastruct_, member_, type_, iscoord_, kwtable_) @@ -232,6 +233,10 @@ #define CSS_PROP_XUL(name_, id_, method_, datastruct_, member_, type_, iscoord_, kwtable_) /* nothing */ #define DEFINED_CSS_PROP_XUL #endif +#ifndef CSS_PROP_COLUMN +#define CSS_PROP_COLUMN(name_, id_, method_, datastruct_, member_, type_, iscoord_, kwtable_) /* nothing */ +#define DEFINED_CSS_PROP_COLUMN +#endif #ifdef MOZ_SVG #ifndef CSS_PROP_SVG #define CSS_PROP_SVG(name_, id_, method_, datastruct_, member_, type_, iscoord_, kwtable_) /* nothing */ @@ -325,6 +330,8 @@ CSS_PROP_TABLEBORDER(caption-side, caption_side, CaptionSide, Table, mCaptionSid CSS_PROP_DISPLAY(clear, clear, Clear, Display, mClear, eCSSType_Value, PR_FALSE, kClearKTable) CSS_PROP_DISPLAY(clip, clip, Clip, Display, mClip, eCSSType_Rect, PR_FALSE, nsnull) CSS_PROP_COLOR(color, color, Color, Color, mColor, eCSSType_Value, PR_FALSE, nsnull) +CSS_PROP_COLUMN(-moz-column-count, _moz_column_count, MozColumnCount, Column, mColumnCount, eCSSType_Value, PR_FALSE, nsnull) +CSS_PROP_COLUMN(-moz-column-width, _moz_column_width, MozColumnWidth, Column, mColumnWidth, eCSSType_Value, PR_TRUE, nsnull) CSS_PROP_CONTENT(content, content, Content, Content, mContent, eCSSType_ValueList, PR_FALSE, kContentKTable) CSS_PROP_NOTIMPLEMENTED(counter-increment, counter_increment, CounterIncrement) CSS_PROP_NOTIMPLEMENTED(counter-reset, counter_reset, CounterReset) @@ -540,6 +547,7 @@ CSS_PROP_TABLE(X, X, X, Table, mSpan, eCSSType_Value, PR_FALSE, nsnull) #undef CSS_PROP_BORDER #undef CSS_PROP_OUTLINE #undef CSS_PROP_XUL +#undef CSS_PROP_COLUMN #ifdef MOZ_SVG #undef CSS_PROP_SVG #undef CSS_PROP_SVGRESET @@ -631,6 +639,10 @@ CSS_PROP_TABLE(X, X, X, Table, mSpan, eCSSType_Value, PR_FALSE, nsnull) #undef CSS_PROP_XUL #undef DEFINED_CSS_PROP_XUL #endif +#ifdef DEFINED_CSS_PROP_COLUMN +#undef CSS_PROP_COLUMN +#undef DEFINED_CSS_PROP_COLUMN +#endif #ifdef MOZ_SVG #ifdef DEFINED_CSS_PROP_SVG #undef CSS_PROP_SVG diff --git a/mozilla/layout/style/nsCSSProps.cpp b/mozilla/layout/style/nsCSSProps.cpp index 510efc345c0..1e325321917 100644 --- a/mozilla/layout/style/nsCSSProps.cpp +++ b/mozilla/layout/style/nsCSSProps.cpp @@ -1080,6 +1080,7 @@ const nsStyleStructID nsCSSProps::kSIDTable[eCSSProperty_COUNT_no_shorthands] = #define CSS_PROP_SVG(name_, id_, method_, datastruct_, member_, type_, iscoord_, kwtable_) eStyleStruct_SVG, #define CSS_PROP_SVGRESET(name_, id_, method_, datastruct_, member_, type_, iscoord_, kwtable_) eStyleStruct_SVGReset, #endif /* defined(MOZ_SVG) */ + #define CSS_PROP_COLUMN(name_, id_, method_, datastruct_, member_, type_, iscoord_, kwtable_) eStyleStruct_Column, // This shouldn't matter, but we need something to go here. #define CSS_PROP_BACKENDONLY(name_, id_, method_, datastruct_, member_, type_, iscoord_, kwtable_) nsStyleStructID(-1), @@ -1109,6 +1110,7 @@ const nsStyleStructID nsCSSProps::kSIDTable[eCSSProperty_COUNT_no_shorthands] = #undef CSS_PROP_SVG #undef CSS_PROP_SVGRESET #endif /* undefd(MOZ_SVG) */ + #undef CSS_PROP_COLUMN #undef CSS_PROP_BACKENDONLY }; diff --git a/mozilla/layout/style/nsCSSStruct.cpp b/mozilla/layout/style/nsCSSStruct.cpp index f54b9077215..51d968e8b95 100644 --- a/mozilla/layout/style/nsCSSStruct.cpp +++ b/mozilla/layout/style/nsCSSStruct.cpp @@ -1153,6 +1153,37 @@ void nsCSSXUL::List(FILE* out, PRInt32 aIndent) const } #endif +// --- nsCSSColumn ----------------- + +nsCSSColumn::nsCSSColumn(void) +{ + MOZ_COUNT_CTOR(nsCSSColumn); +} + +nsCSSColumn::nsCSSColumn(const nsCSSColumn& aCopy) + : mColumnCount(aCopy.mColumnCount), mColumnWidth(aCopy.mColumnWidth) +{ + MOZ_COUNT_CTOR(nsCSSColumn); +} + +nsCSSColumn::~nsCSSColumn(void) +{ + MOZ_COUNT_DTOR(nsCSSColumn); +} + +#ifdef DEBUG +void nsCSSColumn::List(FILE* out, PRInt32 aIndent) const +{ + for (PRInt32 index = aIndent; --index >= 0; ) fputs(" ", out); + + nsAutoString buffer; + + mColumnWidth.AppendToString(buffer, eCSSProperty__moz_column_width); + mColumnCount.AppendToString(buffer, eCSSProperty__moz_column_count); + fputs(NS_LossyConvertUCS2toASCII(buffer).get(), out); +} +#endif + #ifdef MOZ_SVG // --- nsCSSSVG ----------------- diff --git a/mozilla/layout/style/nsCSSStruct.h b/mozilla/layout/style/nsCSSStruct.h index 7fa11868cc9..9342dd98ce7 100644 --- a/mozilla/layout/style/nsCSSStruct.h +++ b/mozilla/layout/style/nsCSSStruct.h @@ -507,6 +507,22 @@ struct nsCSSXUL : public nsCSSStruct { struct nsRuleDataXUL : public nsCSSXUL { }; +struct nsCSSColumn : public nsCSSStruct { + nsCSSColumn(void); + nsCSSColumn(const nsCSSColumn& aCopy); + ~nsCSSColumn(void); + +#ifdef DEBUG + void List(FILE* out = stdout, PRInt32 aIndent = 0) const; +#endif + + nsCSSValue mColumnCount; + nsCSSValue mColumnWidth; +}; + +struct nsRuleDataColumn : public nsCSSColumn { +}; + #ifdef MOZ_SVG struct nsCSSSVG : public nsCSSStruct { nsCSSSVG(void); diff --git a/mozilla/layout/style/nsComputedDOMStyle.cpp b/mozilla/layout/style/nsComputedDOMStyle.cpp index fee64e77835..4bf2bdde06b 100644 --- a/mozilla/layout/style/nsComputedDOMStyle.cpp +++ b/mozilla/layout/style/nsComputedDOMStyle.cpp @@ -519,6 +519,57 @@ nsComputedDOMStyle::GetOpacity(nsIFrame *aFrame, return CallQueryInterface(val, aValue); } +nsresult +nsComputedDOMStyle::GetColumnCount(nsIFrame *aFrame, + nsIDOMCSSValue** aValue) +{ + nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue(); + NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY); + + const nsStyleColumn* column = nsnull; + GetStyleData(eStyleStruct_Column, (const nsStyleStruct*&)column, aFrame); + + if (column) { + if (column->mColumnCount == NS_STYLE_COLUMN_COUNT_AUTO) { + val->SetIdent(nsLayoutAtoms::autoAtom); + } else { + val->SetNumber(column->mColumnCount); + } + } + + return CallQueryInterface(val, aValue); +} + +nsresult +nsComputedDOMStyle::GetColumnWidth(nsIFrame *aFrame, + nsIDOMCSSValue** aValue) +{ + nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue(); + NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY); + + const nsStyleColumn* column = nsnull; + GetStyleData(eStyleStruct_Column, (const nsStyleStruct*&)column, aFrame); + + if (column) { + switch (column->mColumnWidth.GetUnit()) { + case eStyleUnit_Coord: + val->SetTwips(column->mColumnWidth.GetCoordValue()); + break; + case eStyleUnit_Auto: + // XXX fix this. When we actually have a column frame, I think + // we should return the computed column width. + val->SetIdent(nsLayoutAtoms::autoAtom); + break; + default: + NS_WARNING("Bad column width unit"); + val->SetTwips(0); + break; + } + } + + return CallQueryInterface(val, aValue); +} + nsresult nsComputedDOMStyle::GetFontFamily(nsIFrame *aFrame, nsIDOMCSSValue** aValue) @@ -3522,6 +3573,8 @@ nsComputedDOMStyle::GetQueryablePropertyMap(PRUint32* aLength) COMPUTED_STYLE_MAP_ENTRY(box_orient, BoxOrient), COMPUTED_STYLE_MAP_ENTRY(box_pack, BoxPack), COMPUTED_STYLE_MAP_ENTRY(box_sizing, BoxSizing), + COMPUTED_STYLE_MAP_ENTRY(_moz_column_count, ColumnCount), + COMPUTED_STYLE_MAP_ENTRY(_moz_column_width, ColumnWidth), COMPUTED_STYLE_MAP_ENTRY(float_edge, FloatEdge), COMPUTED_STYLE_MAP_ENTRY(image_region, ImageRegion), COMPUTED_STYLE_MAP_ENTRY(opacity, Opacity), diff --git a/mozilla/layout/style/nsComputedDOMStyle.h b/mozilla/layout/style/nsComputedDOMStyle.h index 43d71f8373e..45adc77e1cf 100644 --- a/mozilla/layout/style/nsComputedDOMStyle.h +++ b/mozilla/layout/style/nsComputedDOMStyle.h @@ -280,6 +280,10 @@ private: nsresult GetUserModify(nsIFrame *aFrame, nsIDOMCSSValue** aValue); nsresult GetUserSelect(nsIFrame *aFrame, nsIDOMCSSValue** aValue); + /* Column properties */ + nsresult GetColumnCount(nsIFrame *aFrame, nsIDOMCSSValue** aValue); + nsresult GetColumnWidth(nsIFrame *aFrame, nsIDOMCSSValue** aValue); + nsROCSSPrimitiveValue* GetROCSSPrimitiveValue(); nsDOMCSSValueList* GetROCSSValueList(PRBool aCommaDelimited); nsDOMCSSRGBColor* GetDOMCSSRGBColor(nscolor aColor); diff --git a/mozilla/layout/style/nsRuleNode.cpp b/mozilla/layout/style/nsRuleNode.cpp index 6cc5ff1ec71..2900363190f 100644 --- a/mozilla/layout/style/nsRuleNode.cpp +++ b/mozilla/layout/style/nsRuleNode.cpp @@ -247,6 +247,7 @@ nscoord CalcLength(const nsCSSValue& aValue, #define SETCOORD_LP (SETCOORD_LENGTH | SETCOORD_PERCENT) #define SETCOORD_LH (SETCOORD_LENGTH | SETCOORD_INHERIT) #define SETCOORD_AH (SETCOORD_AUTO | SETCOORD_INHERIT) +#define SETCOORD_LAH (SETCOORD_AUTO | SETCOORD_LENGTH | SETCOORD_INHERIT) #define SETCOORD_LPH (SETCOORD_LP | SETCOORD_INHERIT) #define SETCOORD_LPAH (SETCOORD_LP | SETCOORD_AH) #define SETCOORD_LPEH (SETCOORD_LP | SETCOORD_ENUMERATED | SETCOORD_INHERIT) @@ -797,6 +798,13 @@ static const PropertyCheckData SVGResetCheckProperties[] = { }; #endif +static const PropertyCheckData ColumnCheckProperties[] = { +#define CSS_PROP_COLUMN(name_, id_, method_, datastruct_, member_, type_, iscoord_, kwtable_) \ + { offsetof(nsRuleData##datastruct_, member_), type_ }, +#include "nsCSSPropList.h" +#undef CSS_PROP_COLUMN +}; + #undef CSS_PROP_INCLUDE_NOT_CSS static const StructCheckData gCheckProperties[] = { @@ -1187,6 +1195,16 @@ nsRuleNode::GetXULData(nsStyleContext* aContext) return WalkRuleTree(eStyleStruct_XUL, aContext, &ruleData, &xulData); } +const nsStyleStruct* +nsRuleNode::GetColumnData(nsStyleContext* aContext) +{ + nsRuleDataColumn columnData; // Declare a struct with null CSS values. + nsRuleData ruleData(eStyleStruct_Column, mPresContext, aContext); + ruleData.mColumnData = &columnData; + + return WalkRuleTree(eStyleStruct_Column, aContext, &ruleData, &columnData); +} + #ifdef MOZ_SVG const nsStyleStruct* nsRuleNode::GetSVGData(nsStyleContext* aContext) @@ -1508,6 +1526,13 @@ nsRuleNode::SetDefaultOnRoot(const nsStyleStructID aSID, nsStyleContext* aContex return xul; } + case eStyleStruct_Column: + { + nsStyleColumn* column = new (mPresContext) nsStyleColumn(); + aContext->SetStyle(eStyleStruct_Column, column); + return column; + } + #ifdef MOZ_SVG case eStyleStruct_SVG: { @@ -4195,6 +4220,65 @@ nsRuleNode::ComputeXULData(nsStyleStruct* aStartStruct, return xul; } +const nsStyleStruct* +nsRuleNode::ComputeColumnData(nsStyleStruct* aStartStruct, + const nsRuleDataStruct& aData, + nsStyleContext* aContext, + nsRuleNode* aHighestNode, + const RuleDetail& aRuleDetail, PRBool aInherited) +{ + nsStyleContext* parentContext = aContext->GetParent(); + + const nsRuleDataColumn& columnData = NS_STATIC_CAST(const nsRuleDataColumn&, aData); + nsStyleColumn* column = nsnull; + + if (aStartStruct) + // We only need to compute the delta between this computed data and our + // computed data. + column = new (mPresContext) nsStyleColumn(*NS_STATIC_CAST(nsStyleColumn*, aStartStruct)); + else + column = new (mPresContext) nsStyleColumn(); + + const nsStyleColumn* parent = column; + if (parentContext && + aRuleDetail != eRuleFullReset && + aRuleDetail != eRulePartialReset && + aRuleDetail != eRuleNone) + parent = parentContext->GetStyleColumn(); + + PRBool inherited = aInherited; + + // column-width: length, auto, inherit + SetCoord(columnData.mColumnWidth, + column->mColumnWidth, parent->mColumnWidth, SETCOORD_LAH, + aContext, mPresContext, inherited); + + // column-count: auto, integer, inherit + if (eCSSUnit_Auto == columnData.mColumnCount.GetUnit()) { + column->mColumnCount = NS_STYLE_COLUMN_COUNT_AUTO; + } else if (eCSSUnit_Integer == columnData.mColumnCount.GetUnit()) { + column->mColumnCount = columnData.mColumnCount.GetIntValue(); + } else if (eCSSUnit_Inherit == columnData.mColumnCount.GetUnit()) { + inherited = PR_TRUE; + column->mColumnCount = parent->mColumnCount; + } + + if (inherited) + // We inherited, and therefore can't be cached in the rule node. We have to be put right on the + // style context. + aContext->SetStyle(eStyleStruct_Column, column); + else { + // We were fully specified and can therefore be cached right on the rule node. + if (!aHighestNode->mStyleData.mResetData) + aHighestNode->mStyleData.mResetData = new (mPresContext) nsResetStyleData; + aHighestNode->mStyleData.mResetData->mColumnData = column; + // Propagate the bit down. + PropagateDependentBit(NS_STYLE_INHERIT_BIT(Column), aHighestNode); + } + + return column; +} + #ifdef MOZ_SVG static void SetSVGPaint(const nsCSSValue& aValue, const nsStyleSVGPaint& parentPaint, diff --git a/mozilla/layout/style/nsRuleNode.h b/mozilla/layout/style/nsRuleNode.h index 11d1287a96f..6781f033dd6 100644 --- a/mozilla/layout/style/nsRuleNode.h +++ b/mozilla/layout/style/nsRuleNode.h @@ -258,11 +258,13 @@ struct nsRuleData nsRuleDataSVG* mSVGData; #endif + nsRuleDataColumn* mColumnData; + nsRuleData(const nsStyleStructID& aSID, nsIPresContext* aContext, nsStyleContext* aStyleContext) :mSID(aSID), mPresContext(aContext), mStyleContext(aStyleContext), mPostResolveCallback(nsnull), mFontData(nsnull), mDisplayData(nsnull), mMarginData(nsnull), mListData(nsnull), mPositionData(nsnull), mTableData(nsnull), mColorData(nsnull), mContentData(nsnull), mTextData(nsnull), - mUserInterfaceData(nsnull) + mUserInterfaceData(nsnull), mColumnData(nsnull) { mCanStoreInRuleTree = PR_TRUE; mXULData = nsnull; @@ -523,6 +525,11 @@ protected: nsStyleContext* aContext, nsRuleNode* aHighestNode, const RuleDetail& aRuleDetail, PRBool aInherited); + NS_HIDDEN_(const nsStyleStruct*) + ComputeColumnData(nsStyleStruct* aStartColumn, const nsRuleDataStruct& aColumnData, + nsStyleContext* aContext, nsRuleNode* aHighestNode, + const RuleDetail& aRuleDetail, PRBool aInherited); + #ifdef MOZ_SVG NS_HIDDEN_(const nsStyleStruct*) ComputeSVGData(nsStyleStruct* aStartSVG, const nsRuleDataStruct& aSVGData, @@ -593,6 +600,7 @@ protected: NS_HIDDEN_(const nsStyleStruct*) GetUIResetData(nsStyleContext* aContext); NS_HIDDEN_(const nsStyleStruct*) GetXULData(nsStyleContext* aContext); + NS_HIDDEN_(const nsStyleStruct*) GetColumnData(nsStyleContext* aContext); #ifdef MOZ_SVG NS_HIDDEN_(const nsStyleStruct*) GetSVGData(nsStyleContext* aContext); NS_HIDDEN_(const nsStyleStruct*) GetSVGResetData(nsStyleContext* aContext); diff --git a/mozilla/layout/style/nsStyleContext.cpp b/mozilla/layout/style/nsStyleContext.cpp index bdad63db4e6..687fd51fa1a 100644 --- a/mozilla/layout/style/nsStyleContext.cpp +++ b/mozilla/layout/style/nsStyleContext.cpp @@ -451,6 +451,7 @@ nsStyleContext::CalcStyleDifference(nsStyleContext* aOther) // Visibility, Quotes DO_STRUCT_DIFFERENCE(Display); DO_STRUCT_DIFFERENCE(XUL); + DO_STRUCT_DIFFERENCE(Column); DO_STRUCT_DIFFERENCE(Content); DO_STRUCT_DIFFERENCE(UserInterface); DO_STRUCT_DIFFERENCE(Visibility); @@ -806,6 +807,15 @@ void nsStyleContext::DumpRegressionData(nsIPresContext* aPresContext, FILE* out, (int)uiReset->mUserSelect, (int)uiReset->mKeyEquivalent); + // Column + IndentBy(out,aIndent); + const nsStyleColumn* column = GetStyleColumn(); + fprintf(out, "mColumnCount); + column->mColumnWidth.ToString(str); + fprintf(out, "%s", NS_ConvertUCS2toUTF8(str).get()); + fprintf(out, "\" />\n"); + // XUL IndentBy(out,aIndent); const nsStyleXUL* xul = GetStyleXUL(); diff --git a/mozilla/layout/style/nsStyleStruct.cpp b/mozilla/layout/style/nsStyleStruct.cpp index 7acdbe101c7..424ad899f6e 100644 --- a/mozilla/layout/style/nsStyleStruct.cpp +++ b/mozilla/layout/style/nsStyleStruct.cpp @@ -720,6 +720,32 @@ nsChangeHint nsStyleXUL::CalcDifference(const nsStyleXUL& aOther) const return NS_STYLE_HINT_REFLOW; } +// -------------------- +// nsStyleColumn +// +nsStyleColumn::nsStyleColumn() +{ + mColumnCount = NS_STYLE_COLUMN_COUNT_AUTO; + mColumnWidth.SetAutoValue(); +} + +nsStyleColumn::~nsStyleColumn() +{ +} + +nsStyleColumn::nsStyleColumn(const nsStyleColumn& aSource) +{ + memcpy((nsStyleColumn*)this, &aSource, sizeof(nsStyleColumn)); +} + +nsChangeHint nsStyleColumn::CalcDifference(const nsStyleColumn& aOther) const +{ + if (mColumnWidth == aOther.mColumnWidth && + mColumnCount == aOther.mColumnCount) + return NS_STYLE_HINT_NONE; + return nsChangeHint_ReconstructFrame; +} + #ifdef MOZ_SVG // -------------------- // nsStyleSVG diff --git a/mozilla/layout/style/nsStyleStruct.h b/mozilla/layout/style/nsStyleStruct.h index fc3922faad8..1c9d3513963 100644 --- a/mozilla/layout/style/nsStyleStruct.h +++ b/mozilla/layout/style/nsStyleStruct.h @@ -1132,6 +1132,27 @@ struct nsStyleXUL : public nsStyleStruct { PRUint8 mBoxPack; // [reset] see nsStyleConsts.h }; +struct nsStyleColumn : public nsStyleStruct { + nsStyleColumn(); + nsStyleColumn(const nsStyleColumn& aSource); + ~nsStyleColumn(); + + NS_DEFINE_STATIC_STYLESTRUCTID_ACCESSOR(eStyleStruct_Column) + + void* operator new(size_t sz, nsIPresContext* aContext) CPP_THROW_NEW { + return aContext->AllocateFromShell(sz); + } + void Destroy(nsIPresContext* aContext) { + this->~nsStyleColumn(); + aContext->FreeToShell(sizeof(nsStyleColumn), this); + }; + + nsChangeHint CalcDifference(const nsStyleColumn& aOther) const; + + PRUint32 mColumnCount; // [reset] see nsStyleConsts.h + nsStyleCoord mColumnWidth; // [reset] see nsStyleConsts.h +}; + #ifdef MOZ_SVG enum nsStyleSVGPaintType { eStyleSVGPaintType_None = 0, diff --git a/mozilla/layout/style/nsStyleStructList.h b/mozilla/layout/style/nsStyleStructList.h index 382b5bf5948..90758bb4954 100644 --- a/mozilla/layout/style/nsStyleStructList.h +++ b/mozilla/layout/style/nsStyleStructList.h @@ -121,36 +121,35 @@ STYLE_STRUCT_RESET(Margin, nsnull, ()) STYLE_STRUCT_TEST_CODE( }) STYLE_STRUCT_TEST_CODE( }) STYLE_STRUCT_TEST_CODE( }) - STYLE_STRUCT_TEST_CODE(} else {) + STYLE_STRUCT_TEST_CODE(} else if (STYLE_STRUCT_TEST < 20) {) STYLE_STRUCT_TEST_CODE( if (STYLE_STRUCT_TEST < 18) {) STYLE_STRUCT_TEST_CODE( if (STYLE_STRUCT_TEST == 16) {) STYLE_STRUCT_RESET(Padding, nsnull, ()) STYLE_STRUCT_TEST_CODE( } else {) STYLE_STRUCT_RESET(Border, nsnull, ()) STYLE_STRUCT_TEST_CODE( }) -#ifndef MOZ_SVG - STYLE_STRUCT_TEST_CODE( } else if (STYLE_STRUCT_TEST == 18) {) -STYLE_STRUCT_RESET(Outline, nsnull, (SSARG_PRESCONTEXT)) STYLE_STRUCT_TEST_CODE( } else {) - STYLE_STRUCT_TEST_CODE( NS_ASSERTION(STYLE_STRUCT_TEST == 19, "out of range");) -STYLE_STRUCT_RESET(XUL, nsnull, ()) - STYLE_STRUCT_TEST_CODE( }) - STYLE_STRUCT_TEST_CODE(}) -#else // MOZ_SVG - STYLE_STRUCT_TEST_CODE( } else if (STYLE_STRUCT_TEST < 20) {) STYLE_STRUCT_TEST_CODE( if (STYLE_STRUCT_TEST == 18) {) STYLE_STRUCT_RESET(Outline, nsnull, (SSARG_PRESCONTEXT)) STYLE_STRUCT_TEST_CODE( } else {) STYLE_STRUCT_RESET(XUL, nsnull, ()) STYLE_STRUCT_TEST_CODE( }) - STYLE_STRUCT_TEST_CODE( } else if (STYLE_STRUCT_TEST == 20) {) + STYLE_STRUCT_TEST_CODE( }) +#ifndef MOZ_SVG + STYLE_STRUCT_TEST_CODE(} else {) + STYLE_STRUCT_TEST_CODE( NS_ASSERTION(STYLE_STRUCT_TEST == 20, "out of range");) +#else + STYLE_STRUCT_TEST_CODE(} else if (STYLE_STRUCT_TEST < 22) {) + STYLE_STRUCT_TEST_CODE( if (STYLE_STRUCT_TEST == 20) {) STYLE_STRUCT_INHERITED(SVG, nsnull, ()) STYLE_STRUCT_TEST_CODE( } else {) - STYLE_STRUCT_TEST_CODE( NS_ASSERTION(STYLE_STRUCT_TEST == 21, "out of range");) STYLE_STRUCT_RESET(SVGReset,nsnull, ()) STYLE_STRUCT_TEST_CODE( }) - STYLE_STRUCT_TEST_CODE(}) + STYLE_STRUCT_TEST_CODE(} else {) + STYLE_STRUCT_TEST_CODE( NS_ASSERTION(STYLE_STRUCT_TEST == 22, "out of range");) #endif + STYLE_STRUCT_RESET(Column, nsnull, ()) +STYLE_STRUCT_TEST_CODE(}) #ifdef UNDEF_STYLE_STRUCT_INHERITED #undef STYLE_STRUCT_INHERITED