From f15e8fc2e23be886b371dde388a1e5157ffb70ee Mon Sep 17 00:00:00 2001 From: "hewitt%netscape.com" Date: Tue, 25 Sep 2001 22:17:00 +0000 Subject: [PATCH] 93519 - new box-ordinal-group xul layout feature, r=waterson, sr=hyatt git-svn-id: svn://10.0.0.236/trunk@103733 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/content/base/src/nsStyleContext.cpp | 3 +- .../html/style/src/nsCSSDeclaration.cpp | 51 ++++--- .../content/html/style/src/nsCSSParser.cpp | 2 + .../content/html/style/src/nsCSSStruct.cpp | 51 ++++--- .../content/html/style/src/nsCSSStyleRule.cpp | 4 + .../html/style/src/nsICSSDeclaration.h | 1 + mozilla/content/html/style/src/nsRuleNode.cpp | 8 +- mozilla/content/shared/public/nsCSSPropList.h | 1 + mozilla/content/shared/public/nsStyleStruct.h | 1 + mozilla/content/shared/public/nsXULAtomList.h | 1 + mozilla/content/shared/src/nsStyleStruct.cpp | 6 +- mozilla/layout/style/nsCSSDeclaration.cpp | 51 ++++--- mozilla/layout/style/nsCSSParser.cpp | 2 + mozilla/layout/style/nsCSSPropList.h | 1 + mozilla/layout/style/nsCSSStruct.cpp | 51 ++++--- mozilla/layout/style/nsCSSStyleRule.cpp | 4 + mozilla/layout/style/nsStyleContext.cpp | 3 +- mozilla/layout/style/nsStyleStruct.cpp | 6 +- mozilla/layout/style/nsStyleStruct.h | 1 + .../layout/xul/base/public/nsIBoxObject.idl | 9 ++ mozilla/layout/xul/base/src/nsBox.cpp | 50 +++++++ mozilla/layout/xul/base/src/nsBox.h | 2 + mozilla/layout/xul/base/src/nsBoxFrame.cpp | 52 ++++++- mozilla/layout/xul/base/src/nsBoxFrame.h | 3 +- mozilla/layout/xul/base/src/nsBoxObject.cpp | 118 +++++++++++++++ mozilla/layout/xul/base/src/nsBoxObject.h | 1 + .../layout/xul/base/src/nsContainerBox.cpp | 139 +++++++++++++++++- mozilla/layout/xul/base/src/nsContainerBox.h | 5 +- mozilla/layout/xul/base/src/nsIBox.h | 5 + 29 files changed, 537 insertions(+), 95 deletions(-) diff --git a/mozilla/content/base/src/nsStyleContext.cpp b/mozilla/content/base/src/nsStyleContext.cpp index ca24f3aed8e..25c193b8a37 100644 --- a/mozilla/content/base/src/nsStyleContext.cpp +++ b/mozilla/content/base/src/nsStyleContext.cpp @@ -1144,7 +1144,8 @@ void nsStyleContext::DumpRegressionData(nsIPresContext* aPresContext, FILE* out, (int)xul->mBoxDirection, (int)xul->mBoxFlex, (int)xul->mBoxOrient, - (int)xul->mBoxPack); + (int)xul->mBoxPack, + (int)xul->mBoxOrdinal); fprintf(out, "\" />\n"); #endif //#insert new style structs here# diff --git a/mozilla/content/html/style/src/nsCSSDeclaration.cpp b/mozilla/content/html/style/src/nsCSSDeclaration.cpp index 2b70b259568..3768ae80823 100644 --- a/mozilla/content/html/style/src/nsCSSDeclaration.cpp +++ b/mozilla/content/html/style/src/nsCSSDeclaration.cpp @@ -1005,7 +1005,7 @@ nsCSSXUL::nsCSSXUL(void) nsCSSXUL::nsCSSXUL(const nsCSSXUL& aCopy) : mBoxAlign(aCopy.mBoxAlign), mBoxDirection(aCopy.mBoxDirection), mBoxFlex(aCopy.mBoxFlex), mBoxOrient(aCopy.mBoxOrient), - mBoxPack(aCopy.mBoxPack) + mBoxPack(aCopy.mBoxPack), mBoxOrdinal(aCopy.mBoxOrdinal) { MOZ_COUNT_CTOR(nsCSSXUL); } @@ -1031,6 +1031,7 @@ void nsCSSXUL::List(FILE* out, PRInt32 aIndent) const mBoxFlex.AppendToString(buffer, eCSSProperty_box_flex); mBoxOrient.AppendToString(buffer, eCSSProperty_box_orient); mBoxPack.AppendToString(buffer, eCSSProperty_box_pack); + mBoxOrdinal.AppendToString(buffer, eCSSProperty_box_ordinal_group); fputs(buffer, out); } @@ -1775,13 +1776,15 @@ CSSDeclarationImpl::AppendValue(nsCSSProperty aProperty, const nsCSSValue& aValu case eCSSProperty_box_flex: case eCSSProperty_box_orient: case eCSSProperty_box_pack: + case eCSSProperty_box_ordinal_group: CSS_ENSURE(XUL) { switch (aProperty) { - case eCSSProperty_box_align: mXUL->mBoxAlign = aValue; break; - case eCSSProperty_box_direction: mXUL->mBoxDirection = aValue; break; - case eCSSProperty_box_flex: mXUL->mBoxFlex = aValue; break; - case eCSSProperty_box_orient: mXUL->mBoxOrient = aValue; break; - case eCSSProperty_box_pack: mXUL->mBoxPack = aValue; break; + case eCSSProperty_box_align: mXUL->mBoxAlign = aValue; break; + case eCSSProperty_box_direction: mXUL->mBoxDirection = aValue; break; + case eCSSProperty_box_flex: mXUL->mBoxFlex = aValue; break; + case eCSSProperty_box_orient: mXUL->mBoxOrient = aValue; break; + case eCSSProperty_box_pack: mXUL->mBoxPack = aValue; break; + case eCSSProperty_box_ordinal_group: mXUL->mBoxOrdinal = aValue; break; CSS_BOGUS_DEFAULT; // make compiler happy } } @@ -2536,14 +2539,16 @@ CSSDeclarationImpl::SetValueImportant(nsCSSProperty aProperty) case eCSSProperty_box_flex: case eCSSProperty_box_orient: case eCSSProperty_box_pack: + case eCSSProperty_box_ordinal_group: if (nsnull != mXUL) { CSS_ENSURE_IMPORTANT(XUL) { switch (aProperty) { - CSS_CASE_IMPORTANT(eCSSProperty_box_align, mXUL->mBoxAlign); - CSS_CASE_IMPORTANT(eCSSProperty_box_direction, mXUL->mBoxDirection); - CSS_CASE_IMPORTANT(eCSSProperty_box_flex, mXUL->mBoxFlex); - CSS_CASE_IMPORTANT(eCSSProperty_box_orient, mXUL->mBoxOrient); - CSS_CASE_IMPORTANT(eCSSProperty_box_pack, mXUL->mBoxPack); + CSS_CASE_IMPORTANT(eCSSProperty_box_align, mXUL->mBoxAlign); + CSS_CASE_IMPORTANT(eCSSProperty_box_direction, mXUL->mBoxDirection); + CSS_CASE_IMPORTANT(eCSSProperty_box_flex, mXUL->mBoxFlex); + CSS_CASE_IMPORTANT(eCSSProperty_box_orient, mXUL->mBoxOrient); + CSS_CASE_IMPORTANT(eCSSProperty_box_pack, mXUL->mBoxPack); + CSS_CASE_IMPORTANT(eCSSProperty_box_ordinal_group, mXUL->mBoxOrdinal); CSS_BOGUS_DEFAULT; // make compiler happy } } @@ -3232,13 +3237,15 @@ CSSDeclarationImpl::RemoveProperty(nsCSSProperty aProperty) case eCSSProperty_box_flex: case eCSSProperty_box_orient: case eCSSProperty_box_pack: + case eCSSProperty_box_ordinal_group: CSS_CHECK(XUL) { switch(aProperty) { - case eCSSProperty_box_align: mXUL->mBoxAlign.Reset(); break; - case eCSSProperty_box_direction: mXUL->mBoxDirection.Reset(); break; - case eCSSProperty_box_flex: mXUL->mBoxFlex.Reset(); break; - case eCSSProperty_box_orient: mXUL->mBoxOrient.Reset(); break; - case eCSSProperty_box_pack: mXUL->mBoxPack.Reset(); break; + case eCSSProperty_box_align: mXUL->mBoxAlign.Reset(); break; + case eCSSProperty_box_direction: mXUL->mBoxDirection.Reset(); break; + case eCSSProperty_box_flex: mXUL->mBoxFlex.Reset(); break; + case eCSSProperty_box_orient: mXUL->mBoxOrient.Reset(); break; + case eCSSProperty_box_pack: mXUL->mBoxPack.Reset(); break; + case eCSSProperty_box_ordinal_group: mXUL->mBoxOrdinal.Reset(); break; CSS_BOGUS_DEFAULT; // Make compiler happy } } @@ -3979,13 +3986,15 @@ CSSDeclarationImpl::GetValue(nsCSSProperty aProperty, nsCSSValue& aValue) case eCSSProperty_box_flex: case eCSSProperty_box_orient: case eCSSProperty_box_pack: + case eCSSProperty_box_ordinal_group: if (nsnull != mXUL) { switch (aProperty) { - case eCSSProperty_box_align: aValue = mXUL->mBoxAlign; break; - case eCSSProperty_box_direction: aValue = mXUL->mBoxDirection; break; - case eCSSProperty_box_flex: aValue = mXUL->mBoxFlex; break; - case eCSSProperty_box_orient: aValue = mXUL->mBoxOrient; break; - case eCSSProperty_box_pack: aValue = mXUL->mBoxPack; break; + case eCSSProperty_box_align: aValue = mXUL->mBoxAlign; break; + case eCSSProperty_box_direction: aValue = mXUL->mBoxDirection; break; + case eCSSProperty_box_flex: aValue = mXUL->mBoxFlex; break; + case eCSSProperty_box_orient: aValue = mXUL->mBoxOrient; break; + case eCSSProperty_box_pack: aValue = mXUL->mBoxPack; break; + case eCSSProperty_box_ordinal_group: aValue = mXUL->mBoxOrdinal; break; CSS_BOGUS_DEFAULT; // make compiler happy } } diff --git a/mozilla/content/html/style/src/nsCSSParser.cpp b/mozilla/content/html/style/src/nsCSSParser.cpp index 5b4fc317133..7efcd67dd91 100644 --- a/mozilla/content/html/style/src/nsCSSParser.cpp +++ b/mozilla/content/html/style/src/nsCSSParser.cpp @@ -3573,6 +3573,8 @@ PRBool CSSParserImpl::ParseSingleValueProperty(PRInt32& aErrorCode, case eCSSProperty_box_pack: return ParseVariant(aErrorCode, aValue, VARIANT_HK, nsCSSProps::kBoxPackKTable); + case eCSSProperty_box_ordinal_group: + return ParseVariant(aErrorCode, aValue, VARIANT_INTEGER, nsnull); #endif case eCSSProperty_box_sizing: return ParseVariant(aErrorCode, aValue, VARIANT_HK, diff --git a/mozilla/content/html/style/src/nsCSSStruct.cpp b/mozilla/content/html/style/src/nsCSSStruct.cpp index 2b70b259568..3768ae80823 100644 --- a/mozilla/content/html/style/src/nsCSSStruct.cpp +++ b/mozilla/content/html/style/src/nsCSSStruct.cpp @@ -1005,7 +1005,7 @@ nsCSSXUL::nsCSSXUL(void) nsCSSXUL::nsCSSXUL(const nsCSSXUL& aCopy) : mBoxAlign(aCopy.mBoxAlign), mBoxDirection(aCopy.mBoxDirection), mBoxFlex(aCopy.mBoxFlex), mBoxOrient(aCopy.mBoxOrient), - mBoxPack(aCopy.mBoxPack) + mBoxPack(aCopy.mBoxPack), mBoxOrdinal(aCopy.mBoxOrdinal) { MOZ_COUNT_CTOR(nsCSSXUL); } @@ -1031,6 +1031,7 @@ void nsCSSXUL::List(FILE* out, PRInt32 aIndent) const mBoxFlex.AppendToString(buffer, eCSSProperty_box_flex); mBoxOrient.AppendToString(buffer, eCSSProperty_box_orient); mBoxPack.AppendToString(buffer, eCSSProperty_box_pack); + mBoxOrdinal.AppendToString(buffer, eCSSProperty_box_ordinal_group); fputs(buffer, out); } @@ -1775,13 +1776,15 @@ CSSDeclarationImpl::AppendValue(nsCSSProperty aProperty, const nsCSSValue& aValu case eCSSProperty_box_flex: case eCSSProperty_box_orient: case eCSSProperty_box_pack: + case eCSSProperty_box_ordinal_group: CSS_ENSURE(XUL) { switch (aProperty) { - case eCSSProperty_box_align: mXUL->mBoxAlign = aValue; break; - case eCSSProperty_box_direction: mXUL->mBoxDirection = aValue; break; - case eCSSProperty_box_flex: mXUL->mBoxFlex = aValue; break; - case eCSSProperty_box_orient: mXUL->mBoxOrient = aValue; break; - case eCSSProperty_box_pack: mXUL->mBoxPack = aValue; break; + case eCSSProperty_box_align: mXUL->mBoxAlign = aValue; break; + case eCSSProperty_box_direction: mXUL->mBoxDirection = aValue; break; + case eCSSProperty_box_flex: mXUL->mBoxFlex = aValue; break; + case eCSSProperty_box_orient: mXUL->mBoxOrient = aValue; break; + case eCSSProperty_box_pack: mXUL->mBoxPack = aValue; break; + case eCSSProperty_box_ordinal_group: mXUL->mBoxOrdinal = aValue; break; CSS_BOGUS_DEFAULT; // make compiler happy } } @@ -2536,14 +2539,16 @@ CSSDeclarationImpl::SetValueImportant(nsCSSProperty aProperty) case eCSSProperty_box_flex: case eCSSProperty_box_orient: case eCSSProperty_box_pack: + case eCSSProperty_box_ordinal_group: if (nsnull != mXUL) { CSS_ENSURE_IMPORTANT(XUL) { switch (aProperty) { - CSS_CASE_IMPORTANT(eCSSProperty_box_align, mXUL->mBoxAlign); - CSS_CASE_IMPORTANT(eCSSProperty_box_direction, mXUL->mBoxDirection); - CSS_CASE_IMPORTANT(eCSSProperty_box_flex, mXUL->mBoxFlex); - CSS_CASE_IMPORTANT(eCSSProperty_box_orient, mXUL->mBoxOrient); - CSS_CASE_IMPORTANT(eCSSProperty_box_pack, mXUL->mBoxPack); + CSS_CASE_IMPORTANT(eCSSProperty_box_align, mXUL->mBoxAlign); + CSS_CASE_IMPORTANT(eCSSProperty_box_direction, mXUL->mBoxDirection); + CSS_CASE_IMPORTANT(eCSSProperty_box_flex, mXUL->mBoxFlex); + CSS_CASE_IMPORTANT(eCSSProperty_box_orient, mXUL->mBoxOrient); + CSS_CASE_IMPORTANT(eCSSProperty_box_pack, mXUL->mBoxPack); + CSS_CASE_IMPORTANT(eCSSProperty_box_ordinal_group, mXUL->mBoxOrdinal); CSS_BOGUS_DEFAULT; // make compiler happy } } @@ -3232,13 +3237,15 @@ CSSDeclarationImpl::RemoveProperty(nsCSSProperty aProperty) case eCSSProperty_box_flex: case eCSSProperty_box_orient: case eCSSProperty_box_pack: + case eCSSProperty_box_ordinal_group: CSS_CHECK(XUL) { switch(aProperty) { - case eCSSProperty_box_align: mXUL->mBoxAlign.Reset(); break; - case eCSSProperty_box_direction: mXUL->mBoxDirection.Reset(); break; - case eCSSProperty_box_flex: mXUL->mBoxFlex.Reset(); break; - case eCSSProperty_box_orient: mXUL->mBoxOrient.Reset(); break; - case eCSSProperty_box_pack: mXUL->mBoxPack.Reset(); break; + case eCSSProperty_box_align: mXUL->mBoxAlign.Reset(); break; + case eCSSProperty_box_direction: mXUL->mBoxDirection.Reset(); break; + case eCSSProperty_box_flex: mXUL->mBoxFlex.Reset(); break; + case eCSSProperty_box_orient: mXUL->mBoxOrient.Reset(); break; + case eCSSProperty_box_pack: mXUL->mBoxPack.Reset(); break; + case eCSSProperty_box_ordinal_group: mXUL->mBoxOrdinal.Reset(); break; CSS_BOGUS_DEFAULT; // Make compiler happy } } @@ -3979,13 +3986,15 @@ CSSDeclarationImpl::GetValue(nsCSSProperty aProperty, nsCSSValue& aValue) case eCSSProperty_box_flex: case eCSSProperty_box_orient: case eCSSProperty_box_pack: + case eCSSProperty_box_ordinal_group: if (nsnull != mXUL) { switch (aProperty) { - case eCSSProperty_box_align: aValue = mXUL->mBoxAlign; break; - case eCSSProperty_box_direction: aValue = mXUL->mBoxDirection; break; - case eCSSProperty_box_flex: aValue = mXUL->mBoxFlex; break; - case eCSSProperty_box_orient: aValue = mXUL->mBoxOrient; break; - case eCSSProperty_box_pack: aValue = mXUL->mBoxPack; break; + case eCSSProperty_box_align: aValue = mXUL->mBoxAlign; break; + case eCSSProperty_box_direction: aValue = mXUL->mBoxDirection; break; + case eCSSProperty_box_flex: aValue = mXUL->mBoxFlex; break; + case eCSSProperty_box_orient: aValue = mXUL->mBoxOrient; break; + case eCSSProperty_box_pack: aValue = mXUL->mBoxPack; break; + case eCSSProperty_box_ordinal_group: aValue = mXUL->mBoxOrdinal; break; CSS_BOGUS_DEFAULT; // make compiler happy } } diff --git a/mozilla/content/html/style/src/nsCSSStyleRule.cpp b/mozilla/content/html/style/src/nsCSSStyleRule.cpp index 387397e979f..1fc91d31820 100644 --- a/mozilla/content/html/style/src/nsCSSStyleRule.cpp +++ b/mozilla/content/html/style/src/nsCSSStyleRule.cpp @@ -1718,6 +1718,10 @@ MapXULForDeclaration(nsICSSDeclaration* aDecl, nsCSSXUL& aXUL) if (aXUL.mBoxPack.GetUnit() == eCSSUnit_Null && ourXUL->mBoxPack.GetUnit() != eCSSUnit_Null) aXUL.mBoxPack = ourXUL->mBoxPack; + // box-ordinal-group: number + if (aXUL.mBoxOrdinal.GetUnit() == eCSSUnit_Null && ourXUL->mBoxOrdinal.GetUnit() != eCSSUnit_Null) + aXUL.mBoxOrdinal = ourXUL->mBoxOrdinal; + return NS_OK; } #endif diff --git a/mozilla/content/html/style/src/nsICSSDeclaration.h b/mozilla/content/html/style/src/nsICSSDeclaration.h index 74bd6913dbb..bd30c9b2bf5 100644 --- a/mozilla/content/html/style/src/nsICSSDeclaration.h +++ b/mozilla/content/html/style/src/nsICSSDeclaration.h @@ -425,6 +425,7 @@ struct nsCSSXUL : public nsCSSStruct { nsCSSValue mBoxFlex; nsCSSValue mBoxOrient; nsCSSValue mBoxPack; + nsCSSValue mBoxOrdinal; }; #endif diff --git a/mozilla/content/html/style/src/nsRuleNode.cpp b/mozilla/content/html/style/src/nsRuleNode.cpp index 835ba03ff0b..1521e402ae3 100644 --- a/mozilla/content/html/style/src/nsRuleNode.cpp +++ b/mozilla/content/html/style/src/nsRuleNode.cpp @@ -836,7 +836,8 @@ static const PropertyCheckData XULCheckProperties[] = { CHECKDATA_PROP(nsCSSXUL, mBoxDirection, CHECKDATA_VALUE, PR_FALSE), CHECKDATA_PROP(nsCSSXUL, mBoxFlex, CHECKDATA_VALUE, PR_FALSE), CHECKDATA_PROP(nsCSSXUL, mBoxOrient, CHECKDATA_VALUE, PR_FALSE), - CHECKDATA_PROP(nsCSSXUL, mBoxPack, CHECKDATA_VALUE, PR_FALSE) + CHECKDATA_PROP(nsCSSXUL, mBoxPack, CHECKDATA_VALUE, PR_FALSE), + CHECKDATA_PROP(nsCSSXUL, mBoxOrdinal, CHECKDATA_VALUE, PR_FALSE) }; #endif @@ -4067,6 +4068,11 @@ nsRuleNode::ComputeXULData(nsStyleStruct* aStartStruct, const nsCSSStruct& aData xul->mBoxPack = parentXUL->mBoxPack; } + // box-ordinal-group: integer + if (eCSSUnit_Integer == xulData.mBoxOrdinal.GetUnit()) { + xul->mBoxOrdinal = xulData.mBoxOrdinal.GetIntValue(); + } + if (inherited) // We inherited, and therefore can't be cached in the rule node. We have to be put right on the // style context. diff --git a/mozilla/content/shared/public/nsCSSPropList.h b/mozilla/content/shared/public/nsCSSPropList.h index a900a6ab722..f676ad3c025 100644 --- a/mozilla/content/shared/public/nsCSSPropList.h +++ b/mozilla/content/shared/public/nsCSSPropList.h @@ -128,6 +128,7 @@ CSS_PROP(-moz-box-flex-group, box_flex_group, REFLOW) // XXX bug 3935 CSS_PROP(-moz-box-orient, box_orient, REFLOW) // XXX bug 3935 CSS_PROP(-moz-box-pack, box_pack, REFLOW) // XXX bug 3935 CSS_PROP(-moz-box-sizing, box_sizing, REFLOW) // XXX bug 3935 +CSS_PROP(-moz-box-ordinal-group, box_ordinal_group, FRAMECHANGE) CSS_PROP(caption-side, caption_side, REFLOW) CSS_PROP(clear, clear, REFLOW) CSS_PROP(clip, clip, VISUAL) diff --git a/mozilla/content/shared/public/nsStyleStruct.h b/mozilla/content/shared/public/nsStyleStruct.h index 92f20da4769..3f3da5c7d9a 100644 --- a/mozilla/content/shared/public/nsStyleStruct.h +++ b/mozilla/content/shared/public/nsStyleStruct.h @@ -993,6 +993,7 @@ struct nsStyleXUL : public nsStyleStruct { float mBoxFlex; // [reset] see nsStyleConsts.h PRUint8 mBoxOrient; // [reset] see nsStyleConsts.h PRUint8 mBoxPack; // [reset] see nsStyleConsts.h + PRUint32 mBoxOrdinal; // [reset] see nsStyleConsts.h }; #endif diff --git a/mozilla/content/shared/public/nsXULAtomList.h b/mozilla/content/shared/public/nsXULAtomList.h index 7e3bdcc3ff8..a4eff5bb21b 100644 --- a/mozilla/content/shared/public/nsXULAtomList.h +++ b/mozilla/content/shared/public/nsXULAtomList.h @@ -153,6 +153,7 @@ XUL_ATOM(vbox, "vbox") XUL_ATOM(scrollbox, "scrollbox") XUL_ATOM(mousethrough, "mousethrough") XUL_ATOM(flex, "flex") +XUL_ATOM(ordinal, "ordinal") XUL_ATOM(spring, "spring") XUL_ATOM(orient, "orient") XUL_ATOM(autostretch, "autostretch") diff --git a/mozilla/content/shared/src/nsStyleStruct.cpp b/mozilla/content/shared/src/nsStyleStruct.cpp index d78e2bfd062..8e5cb1c72a6 100644 --- a/mozilla/content/shared/src/nsStyleStruct.cpp +++ b/mozilla/content/shared/src/nsStyleStruct.cpp @@ -645,6 +645,7 @@ nsStyleXUL::nsStyleXUL() mBoxFlex = 0.0f; mBoxOrient = NS_STYLE_BOX_ORIENT_HORIZONTAL; mBoxPack = NS_STYLE_BOX_PACK_START; + mBoxOrdinal = 1; } nsStyleXUL::~nsStyleXUL() @@ -663,8 +664,11 @@ nsStyleXUL::CalcDifference(const nsStyleXUL& aOther) const mBoxDirection == aOther.mBoxDirection && mBoxFlex == aOther.mBoxFlex && mBoxOrient == aOther.mBoxOrient && - mBoxPack == aOther.mBoxPack) + mBoxPack == aOther.mBoxPack && + mBoxOrdinal == aOther.mBoxOrdinal) return NS_STYLE_HINT_NONE; + if (mBoxOrdinal != aOther.mBoxOrdinal) + return NS_STYLE_HINT_FRAMECHANGE; return NS_STYLE_HINT_REFLOW; } diff --git a/mozilla/layout/style/nsCSSDeclaration.cpp b/mozilla/layout/style/nsCSSDeclaration.cpp index 2b70b259568..3768ae80823 100644 --- a/mozilla/layout/style/nsCSSDeclaration.cpp +++ b/mozilla/layout/style/nsCSSDeclaration.cpp @@ -1005,7 +1005,7 @@ nsCSSXUL::nsCSSXUL(void) nsCSSXUL::nsCSSXUL(const nsCSSXUL& aCopy) : mBoxAlign(aCopy.mBoxAlign), mBoxDirection(aCopy.mBoxDirection), mBoxFlex(aCopy.mBoxFlex), mBoxOrient(aCopy.mBoxOrient), - mBoxPack(aCopy.mBoxPack) + mBoxPack(aCopy.mBoxPack), mBoxOrdinal(aCopy.mBoxOrdinal) { MOZ_COUNT_CTOR(nsCSSXUL); } @@ -1031,6 +1031,7 @@ void nsCSSXUL::List(FILE* out, PRInt32 aIndent) const mBoxFlex.AppendToString(buffer, eCSSProperty_box_flex); mBoxOrient.AppendToString(buffer, eCSSProperty_box_orient); mBoxPack.AppendToString(buffer, eCSSProperty_box_pack); + mBoxOrdinal.AppendToString(buffer, eCSSProperty_box_ordinal_group); fputs(buffer, out); } @@ -1775,13 +1776,15 @@ CSSDeclarationImpl::AppendValue(nsCSSProperty aProperty, const nsCSSValue& aValu case eCSSProperty_box_flex: case eCSSProperty_box_orient: case eCSSProperty_box_pack: + case eCSSProperty_box_ordinal_group: CSS_ENSURE(XUL) { switch (aProperty) { - case eCSSProperty_box_align: mXUL->mBoxAlign = aValue; break; - case eCSSProperty_box_direction: mXUL->mBoxDirection = aValue; break; - case eCSSProperty_box_flex: mXUL->mBoxFlex = aValue; break; - case eCSSProperty_box_orient: mXUL->mBoxOrient = aValue; break; - case eCSSProperty_box_pack: mXUL->mBoxPack = aValue; break; + case eCSSProperty_box_align: mXUL->mBoxAlign = aValue; break; + case eCSSProperty_box_direction: mXUL->mBoxDirection = aValue; break; + case eCSSProperty_box_flex: mXUL->mBoxFlex = aValue; break; + case eCSSProperty_box_orient: mXUL->mBoxOrient = aValue; break; + case eCSSProperty_box_pack: mXUL->mBoxPack = aValue; break; + case eCSSProperty_box_ordinal_group: mXUL->mBoxOrdinal = aValue; break; CSS_BOGUS_DEFAULT; // make compiler happy } } @@ -2536,14 +2539,16 @@ CSSDeclarationImpl::SetValueImportant(nsCSSProperty aProperty) case eCSSProperty_box_flex: case eCSSProperty_box_orient: case eCSSProperty_box_pack: + case eCSSProperty_box_ordinal_group: if (nsnull != mXUL) { CSS_ENSURE_IMPORTANT(XUL) { switch (aProperty) { - CSS_CASE_IMPORTANT(eCSSProperty_box_align, mXUL->mBoxAlign); - CSS_CASE_IMPORTANT(eCSSProperty_box_direction, mXUL->mBoxDirection); - CSS_CASE_IMPORTANT(eCSSProperty_box_flex, mXUL->mBoxFlex); - CSS_CASE_IMPORTANT(eCSSProperty_box_orient, mXUL->mBoxOrient); - CSS_CASE_IMPORTANT(eCSSProperty_box_pack, mXUL->mBoxPack); + CSS_CASE_IMPORTANT(eCSSProperty_box_align, mXUL->mBoxAlign); + CSS_CASE_IMPORTANT(eCSSProperty_box_direction, mXUL->mBoxDirection); + CSS_CASE_IMPORTANT(eCSSProperty_box_flex, mXUL->mBoxFlex); + CSS_CASE_IMPORTANT(eCSSProperty_box_orient, mXUL->mBoxOrient); + CSS_CASE_IMPORTANT(eCSSProperty_box_pack, mXUL->mBoxPack); + CSS_CASE_IMPORTANT(eCSSProperty_box_ordinal_group, mXUL->mBoxOrdinal); CSS_BOGUS_DEFAULT; // make compiler happy } } @@ -3232,13 +3237,15 @@ CSSDeclarationImpl::RemoveProperty(nsCSSProperty aProperty) case eCSSProperty_box_flex: case eCSSProperty_box_orient: case eCSSProperty_box_pack: + case eCSSProperty_box_ordinal_group: CSS_CHECK(XUL) { switch(aProperty) { - case eCSSProperty_box_align: mXUL->mBoxAlign.Reset(); break; - case eCSSProperty_box_direction: mXUL->mBoxDirection.Reset(); break; - case eCSSProperty_box_flex: mXUL->mBoxFlex.Reset(); break; - case eCSSProperty_box_orient: mXUL->mBoxOrient.Reset(); break; - case eCSSProperty_box_pack: mXUL->mBoxPack.Reset(); break; + case eCSSProperty_box_align: mXUL->mBoxAlign.Reset(); break; + case eCSSProperty_box_direction: mXUL->mBoxDirection.Reset(); break; + case eCSSProperty_box_flex: mXUL->mBoxFlex.Reset(); break; + case eCSSProperty_box_orient: mXUL->mBoxOrient.Reset(); break; + case eCSSProperty_box_pack: mXUL->mBoxPack.Reset(); break; + case eCSSProperty_box_ordinal_group: mXUL->mBoxOrdinal.Reset(); break; CSS_BOGUS_DEFAULT; // Make compiler happy } } @@ -3979,13 +3986,15 @@ CSSDeclarationImpl::GetValue(nsCSSProperty aProperty, nsCSSValue& aValue) case eCSSProperty_box_flex: case eCSSProperty_box_orient: case eCSSProperty_box_pack: + case eCSSProperty_box_ordinal_group: if (nsnull != mXUL) { switch (aProperty) { - case eCSSProperty_box_align: aValue = mXUL->mBoxAlign; break; - case eCSSProperty_box_direction: aValue = mXUL->mBoxDirection; break; - case eCSSProperty_box_flex: aValue = mXUL->mBoxFlex; break; - case eCSSProperty_box_orient: aValue = mXUL->mBoxOrient; break; - case eCSSProperty_box_pack: aValue = mXUL->mBoxPack; break; + case eCSSProperty_box_align: aValue = mXUL->mBoxAlign; break; + case eCSSProperty_box_direction: aValue = mXUL->mBoxDirection; break; + case eCSSProperty_box_flex: aValue = mXUL->mBoxFlex; break; + case eCSSProperty_box_orient: aValue = mXUL->mBoxOrient; break; + case eCSSProperty_box_pack: aValue = mXUL->mBoxPack; break; + case eCSSProperty_box_ordinal_group: aValue = mXUL->mBoxOrdinal; break; CSS_BOGUS_DEFAULT; // make compiler happy } } diff --git a/mozilla/layout/style/nsCSSParser.cpp b/mozilla/layout/style/nsCSSParser.cpp index 5b4fc317133..7efcd67dd91 100644 --- a/mozilla/layout/style/nsCSSParser.cpp +++ b/mozilla/layout/style/nsCSSParser.cpp @@ -3573,6 +3573,8 @@ PRBool CSSParserImpl::ParseSingleValueProperty(PRInt32& aErrorCode, case eCSSProperty_box_pack: return ParseVariant(aErrorCode, aValue, VARIANT_HK, nsCSSProps::kBoxPackKTable); + case eCSSProperty_box_ordinal_group: + return ParseVariant(aErrorCode, aValue, VARIANT_INTEGER, nsnull); #endif case eCSSProperty_box_sizing: return ParseVariant(aErrorCode, aValue, VARIANT_HK, diff --git a/mozilla/layout/style/nsCSSPropList.h b/mozilla/layout/style/nsCSSPropList.h index a900a6ab722..f676ad3c025 100644 --- a/mozilla/layout/style/nsCSSPropList.h +++ b/mozilla/layout/style/nsCSSPropList.h @@ -128,6 +128,7 @@ CSS_PROP(-moz-box-flex-group, box_flex_group, REFLOW) // XXX bug 3935 CSS_PROP(-moz-box-orient, box_orient, REFLOW) // XXX bug 3935 CSS_PROP(-moz-box-pack, box_pack, REFLOW) // XXX bug 3935 CSS_PROP(-moz-box-sizing, box_sizing, REFLOW) // XXX bug 3935 +CSS_PROP(-moz-box-ordinal-group, box_ordinal_group, FRAMECHANGE) CSS_PROP(caption-side, caption_side, REFLOW) CSS_PROP(clear, clear, REFLOW) CSS_PROP(clip, clip, VISUAL) diff --git a/mozilla/layout/style/nsCSSStruct.cpp b/mozilla/layout/style/nsCSSStruct.cpp index 2b70b259568..3768ae80823 100644 --- a/mozilla/layout/style/nsCSSStruct.cpp +++ b/mozilla/layout/style/nsCSSStruct.cpp @@ -1005,7 +1005,7 @@ nsCSSXUL::nsCSSXUL(void) nsCSSXUL::nsCSSXUL(const nsCSSXUL& aCopy) : mBoxAlign(aCopy.mBoxAlign), mBoxDirection(aCopy.mBoxDirection), mBoxFlex(aCopy.mBoxFlex), mBoxOrient(aCopy.mBoxOrient), - mBoxPack(aCopy.mBoxPack) + mBoxPack(aCopy.mBoxPack), mBoxOrdinal(aCopy.mBoxOrdinal) { MOZ_COUNT_CTOR(nsCSSXUL); } @@ -1031,6 +1031,7 @@ void nsCSSXUL::List(FILE* out, PRInt32 aIndent) const mBoxFlex.AppendToString(buffer, eCSSProperty_box_flex); mBoxOrient.AppendToString(buffer, eCSSProperty_box_orient); mBoxPack.AppendToString(buffer, eCSSProperty_box_pack); + mBoxOrdinal.AppendToString(buffer, eCSSProperty_box_ordinal_group); fputs(buffer, out); } @@ -1775,13 +1776,15 @@ CSSDeclarationImpl::AppendValue(nsCSSProperty aProperty, const nsCSSValue& aValu case eCSSProperty_box_flex: case eCSSProperty_box_orient: case eCSSProperty_box_pack: + case eCSSProperty_box_ordinal_group: CSS_ENSURE(XUL) { switch (aProperty) { - case eCSSProperty_box_align: mXUL->mBoxAlign = aValue; break; - case eCSSProperty_box_direction: mXUL->mBoxDirection = aValue; break; - case eCSSProperty_box_flex: mXUL->mBoxFlex = aValue; break; - case eCSSProperty_box_orient: mXUL->mBoxOrient = aValue; break; - case eCSSProperty_box_pack: mXUL->mBoxPack = aValue; break; + case eCSSProperty_box_align: mXUL->mBoxAlign = aValue; break; + case eCSSProperty_box_direction: mXUL->mBoxDirection = aValue; break; + case eCSSProperty_box_flex: mXUL->mBoxFlex = aValue; break; + case eCSSProperty_box_orient: mXUL->mBoxOrient = aValue; break; + case eCSSProperty_box_pack: mXUL->mBoxPack = aValue; break; + case eCSSProperty_box_ordinal_group: mXUL->mBoxOrdinal = aValue; break; CSS_BOGUS_DEFAULT; // make compiler happy } } @@ -2536,14 +2539,16 @@ CSSDeclarationImpl::SetValueImportant(nsCSSProperty aProperty) case eCSSProperty_box_flex: case eCSSProperty_box_orient: case eCSSProperty_box_pack: + case eCSSProperty_box_ordinal_group: if (nsnull != mXUL) { CSS_ENSURE_IMPORTANT(XUL) { switch (aProperty) { - CSS_CASE_IMPORTANT(eCSSProperty_box_align, mXUL->mBoxAlign); - CSS_CASE_IMPORTANT(eCSSProperty_box_direction, mXUL->mBoxDirection); - CSS_CASE_IMPORTANT(eCSSProperty_box_flex, mXUL->mBoxFlex); - CSS_CASE_IMPORTANT(eCSSProperty_box_orient, mXUL->mBoxOrient); - CSS_CASE_IMPORTANT(eCSSProperty_box_pack, mXUL->mBoxPack); + CSS_CASE_IMPORTANT(eCSSProperty_box_align, mXUL->mBoxAlign); + CSS_CASE_IMPORTANT(eCSSProperty_box_direction, mXUL->mBoxDirection); + CSS_CASE_IMPORTANT(eCSSProperty_box_flex, mXUL->mBoxFlex); + CSS_CASE_IMPORTANT(eCSSProperty_box_orient, mXUL->mBoxOrient); + CSS_CASE_IMPORTANT(eCSSProperty_box_pack, mXUL->mBoxPack); + CSS_CASE_IMPORTANT(eCSSProperty_box_ordinal_group, mXUL->mBoxOrdinal); CSS_BOGUS_DEFAULT; // make compiler happy } } @@ -3232,13 +3237,15 @@ CSSDeclarationImpl::RemoveProperty(nsCSSProperty aProperty) case eCSSProperty_box_flex: case eCSSProperty_box_orient: case eCSSProperty_box_pack: + case eCSSProperty_box_ordinal_group: CSS_CHECK(XUL) { switch(aProperty) { - case eCSSProperty_box_align: mXUL->mBoxAlign.Reset(); break; - case eCSSProperty_box_direction: mXUL->mBoxDirection.Reset(); break; - case eCSSProperty_box_flex: mXUL->mBoxFlex.Reset(); break; - case eCSSProperty_box_orient: mXUL->mBoxOrient.Reset(); break; - case eCSSProperty_box_pack: mXUL->mBoxPack.Reset(); break; + case eCSSProperty_box_align: mXUL->mBoxAlign.Reset(); break; + case eCSSProperty_box_direction: mXUL->mBoxDirection.Reset(); break; + case eCSSProperty_box_flex: mXUL->mBoxFlex.Reset(); break; + case eCSSProperty_box_orient: mXUL->mBoxOrient.Reset(); break; + case eCSSProperty_box_pack: mXUL->mBoxPack.Reset(); break; + case eCSSProperty_box_ordinal_group: mXUL->mBoxOrdinal.Reset(); break; CSS_BOGUS_DEFAULT; // Make compiler happy } } @@ -3979,13 +3986,15 @@ CSSDeclarationImpl::GetValue(nsCSSProperty aProperty, nsCSSValue& aValue) case eCSSProperty_box_flex: case eCSSProperty_box_orient: case eCSSProperty_box_pack: + case eCSSProperty_box_ordinal_group: if (nsnull != mXUL) { switch (aProperty) { - case eCSSProperty_box_align: aValue = mXUL->mBoxAlign; break; - case eCSSProperty_box_direction: aValue = mXUL->mBoxDirection; break; - case eCSSProperty_box_flex: aValue = mXUL->mBoxFlex; break; - case eCSSProperty_box_orient: aValue = mXUL->mBoxOrient; break; - case eCSSProperty_box_pack: aValue = mXUL->mBoxPack; break; + case eCSSProperty_box_align: aValue = mXUL->mBoxAlign; break; + case eCSSProperty_box_direction: aValue = mXUL->mBoxDirection; break; + case eCSSProperty_box_flex: aValue = mXUL->mBoxFlex; break; + case eCSSProperty_box_orient: aValue = mXUL->mBoxOrient; break; + case eCSSProperty_box_pack: aValue = mXUL->mBoxPack; break; + case eCSSProperty_box_ordinal_group: aValue = mXUL->mBoxOrdinal; break; CSS_BOGUS_DEFAULT; // make compiler happy } } diff --git a/mozilla/layout/style/nsCSSStyleRule.cpp b/mozilla/layout/style/nsCSSStyleRule.cpp index 387397e979f..1fc91d31820 100644 --- a/mozilla/layout/style/nsCSSStyleRule.cpp +++ b/mozilla/layout/style/nsCSSStyleRule.cpp @@ -1718,6 +1718,10 @@ MapXULForDeclaration(nsICSSDeclaration* aDecl, nsCSSXUL& aXUL) if (aXUL.mBoxPack.GetUnit() == eCSSUnit_Null && ourXUL->mBoxPack.GetUnit() != eCSSUnit_Null) aXUL.mBoxPack = ourXUL->mBoxPack; + // box-ordinal-group: number + if (aXUL.mBoxOrdinal.GetUnit() == eCSSUnit_Null && ourXUL->mBoxOrdinal.GetUnit() != eCSSUnit_Null) + aXUL.mBoxOrdinal = ourXUL->mBoxOrdinal; + return NS_OK; } #endif diff --git a/mozilla/layout/style/nsStyleContext.cpp b/mozilla/layout/style/nsStyleContext.cpp index ca24f3aed8e..25c193b8a37 100644 --- a/mozilla/layout/style/nsStyleContext.cpp +++ b/mozilla/layout/style/nsStyleContext.cpp @@ -1144,7 +1144,8 @@ void nsStyleContext::DumpRegressionData(nsIPresContext* aPresContext, FILE* out, (int)xul->mBoxDirection, (int)xul->mBoxFlex, (int)xul->mBoxOrient, - (int)xul->mBoxPack); + (int)xul->mBoxPack, + (int)xul->mBoxOrdinal); fprintf(out, "\" />\n"); #endif //#insert new style structs here# diff --git a/mozilla/layout/style/nsStyleStruct.cpp b/mozilla/layout/style/nsStyleStruct.cpp index d78e2bfd062..8e5cb1c72a6 100644 --- a/mozilla/layout/style/nsStyleStruct.cpp +++ b/mozilla/layout/style/nsStyleStruct.cpp @@ -645,6 +645,7 @@ nsStyleXUL::nsStyleXUL() mBoxFlex = 0.0f; mBoxOrient = NS_STYLE_BOX_ORIENT_HORIZONTAL; mBoxPack = NS_STYLE_BOX_PACK_START; + mBoxOrdinal = 1; } nsStyleXUL::~nsStyleXUL() @@ -663,8 +664,11 @@ nsStyleXUL::CalcDifference(const nsStyleXUL& aOther) const mBoxDirection == aOther.mBoxDirection && mBoxFlex == aOther.mBoxFlex && mBoxOrient == aOther.mBoxOrient && - mBoxPack == aOther.mBoxPack) + mBoxPack == aOther.mBoxPack && + mBoxOrdinal == aOther.mBoxOrdinal) return NS_STYLE_HINT_NONE; + if (mBoxOrdinal != aOther.mBoxOrdinal) + return NS_STYLE_HINT_FRAMECHANGE; return NS_STYLE_HINT_REFLOW; } diff --git a/mozilla/layout/style/nsStyleStruct.h b/mozilla/layout/style/nsStyleStruct.h index 92f20da4769..3f3da5c7d9a 100644 --- a/mozilla/layout/style/nsStyleStruct.h +++ b/mozilla/layout/style/nsStyleStruct.h @@ -993,6 +993,7 @@ struct nsStyleXUL : public nsStyleStruct { float mBoxFlex; // [reset] see nsStyleConsts.h PRUint8 mBoxOrient; // [reset] see nsStyleConsts.h PRUint8 mBoxPack; // [reset] see nsStyleConsts.h + PRUint32 mBoxOrdinal; // [reset] see nsStyleConsts.h }; #endif diff --git a/mozilla/layout/xul/base/public/nsIBoxObject.idl b/mozilla/layout/xul/base/public/nsIBoxObject.idl index 3d6e0fd7dbe..09cfbdf08db 100644 --- a/mozilla/layout/xul/base/public/nsIBoxObject.idl +++ b/mozilla/layout/xul/base/public/nsIBoxObject.idl @@ -26,6 +26,8 @@ #include "nsIBoxLayoutManager.idl" #include "nsIBoxPaintManager.idl" +interface nsIDOMElement; + [scriptable, uuid(CAABF76F-9D35-401f-BEAC-3955817C645C)] interface nsIBoxObject : nsISupports { @@ -45,6 +47,13 @@ interface nsIBoxObject : nsISupports void setProperty(in wstring propertyName, in wstring propertyValue); void removeProperty(in wstring propertyName); + // for stepping through content in the expanded dom with box-ordinal-group order + readonly attribute nsIDOMElement parentBox; + readonly attribute nsIDOMElement firstChild; + readonly attribute nsIDOMElement lastChild; + readonly attribute nsIDOMElement nextSibling; + readonly attribute nsIDOMElement previousSibling; + wstring getLookAndFeelMetric(in wstring propertyName); }; diff --git a/mozilla/layout/xul/base/src/nsBox.cpp b/mozilla/layout/xul/base/src/nsBox.cpp index b85992ef477..8b08bdf0b4e 100644 --- a/mozilla/layout/xul/base/src/nsBox.cpp +++ b/mozilla/layout/xul/base/src/nsBox.cpp @@ -464,6 +464,12 @@ nsBox::RelayoutDirtyChild(nsBoxLayoutState& aState, nsIBox* aChild) return NS_OK; } +NS_IMETHODIMP +nsBox::RelayoutChildAtOrdinal(nsBoxLayoutState& aState, nsIBox* aChild) +{ + return NS_OK; +} + NS_IMETHODIMP nsBox::GetVAlign(Valignment& aAlign) { @@ -941,6 +947,15 @@ nsBox::GetFlex(nsBoxLayoutState& aState, nscoord& aFlex) return NS_OK; } +NS_IMETHODIMP +nsBox::GetOrdinal(nsBoxLayoutState& aState, PRUint32& aOrdinal) +{ + aOrdinal = DEFAULT_ORDINAL_GROUP; + nsIBox::AddCSSOrdinal(aState, this, aOrdinal); + + return NS_OK; +} + NS_IMETHODIMP nsBox::GetAscent(nsBoxLayoutState& aState, nscoord& aAscent) { @@ -1377,6 +1392,41 @@ nsIBox::AddCSSCollapsed(nsBoxLayoutState& aState, nsIBox* aBox, PRBool& aCollaps return PR_TRUE; } +PRBool +nsIBox::AddCSSOrdinal(nsBoxLayoutState& aState, nsIBox* aBox, PRUint32& aOrdinal) +{ + PRBool ordinalSet = PR_FALSE; + + nsIFrame* frame = nsnull; + aBox->GetFrame(&frame); + + // get the flexibility + nsCOMPtr content; + frame->GetContent(getter_AddRefs(content)); + + if (content) { + PRInt32 error; + nsAutoString value; + + if (NS_CONTENT_ATTR_HAS_VALUE == content->GetAttr(kNameSpaceID_None, nsXULAtoms::ordinal, value)) { + aOrdinal = value.ToInteger(&error); + ordinalSet = PR_TRUE; + } + else { + // No attribute value. Check CSS. + const nsStyleXUL* boxInfo; + frame->GetStyleData(eStyleStruct_XUL, (const nsStyleStruct*&)boxInfo); + if (boxInfo->mBoxOrdinal > 1) { + // The ordinal group was defined in CSS. + aOrdinal = (nscoord)boxInfo->mBoxOrdinal; + ordinalSet = PR_TRUE; + } + } + } + + return ordinalSet; +} + void nsBox::AddBorderAndPadding(nsSize& aSize) { diff --git a/mozilla/layout/xul/base/src/nsBox.h b/mozilla/layout/xul/base/src/nsBox.h index 2ce86f33e9b..85bb7b7021a 100644 --- a/mozilla/layout/xul/base/src/nsBox.h +++ b/mozilla/layout/xul/base/src/nsBox.h @@ -65,6 +65,7 @@ public: NS_IMETHOD GetMinSize(nsBoxLayoutState& aBoxLayoutState, nsSize& aSize); NS_IMETHOD GetMaxSize(nsBoxLayoutState& aBoxLayoutState, nsSize& aSize); NS_IMETHOD GetFlex(nsBoxLayoutState& aBoxLayoutState, nscoord& aFlex); + NS_IMETHOD GetOrdinal(nsBoxLayoutState& aBoxLayoutState, PRUint32& aOrdinal); NS_IMETHOD GetAscent(nsBoxLayoutState& aBoxLayoutState, nscoord& aAscent); NS_IMETHOD IsCollapsed(nsBoxLayoutState& aBoxLayoutState, PRBool& aCollapsed); NS_IMETHOD Collapse(nsBoxLayoutState& aBoxLayoutState); @@ -79,6 +80,7 @@ public: NS_IMETHOD GetDebug(PRBool& aDebug); NS_IMETHOD RelayoutDirtyChild(nsBoxLayoutState& aState, nsIBox* aChild); NS_IMETHOD RelayoutStyleChange(nsBoxLayoutState& aState, nsIBox* aChild); + NS_IMETHOD RelayoutChildAtOrdinal(nsBoxLayoutState& aState, nsIBox* aChild); NS_IMETHOD GetMouseThrough(PRBool& aMouseThrough); NS_IMETHOD MarkChildrenStyleChange(); diff --git a/mozilla/layout/xul/base/src/nsBoxFrame.cpp b/mozilla/layout/xul/base/src/nsBoxFrame.cpp index 08c2b3a93cf..4a7f42fec15 100644 --- a/mozilla/layout/xul/base/src/nsBoxFrame.cpp +++ b/mozilla/layout/xul/base/src/nsBoxFrame.cpp @@ -226,7 +226,7 @@ nsBoxFrame::nsBoxFrame(nsIPresShell* aPresShell, PRBool aIsRoot, nsIBoxLayout* a mInner->mValign = nsBoxFrame::vAlign_Top; mInner->mHalign = nsBoxFrame::hAlign_Left; - + NeedsRecalc(); // if no layout manager specified us the static sprocket layout @@ -239,6 +239,7 @@ nsBoxFrame::nsBoxFrame(nsIPresShell* aPresShell, PRBool aIsRoot, nsIBoxLayout* a SetLayoutManager(layout); NeedsRecalc(); + } nsBoxFrame::~nsBoxFrame() @@ -275,6 +276,7 @@ nsBoxFrame::SetInitialChildList(nsIPresContext* aPresContext, // initialize our list of infos. nsBoxLayoutState state(shell); InitChildren(state, aChildList); + CheckFrameOrder(); } else { printf("Warning add child failed!!\n"); } @@ -1208,7 +1210,7 @@ nsBoxFrame::InsertFrames(nsIPresContext* aPresContext, // insert the frames to our info list nsBoxLayoutState state(aPresContext); Insert(state, aPrevFrame, aFrameList); - + // insert the frames in out regular frame list mFrames.InsertFrames(this, aPrevFrame, aFrameList); @@ -1216,6 +1218,7 @@ nsBoxFrame::InsertFrames(nsIPresContext* aPresContext, if (mState & NS_STATE_CURRENTLY_IN_DEBUG) SetDebugOnChildList(state, mFirstChild, PR_TRUE); + CheckFrameOrder(); SanityCheck(mFrames); // mark us dirty and generate a reflow command @@ -1244,6 +1247,7 @@ nsBoxFrame::AppendFrames(nsIPresContext* aPresContext, if (mState & NS_STATE_CURRENTLY_IN_DEBUG) SetDebugOnChildList(state, mFirstChild, PR_TRUE); + CheckFrameOrder(); SanityCheck(mFrames); MarkDirtyChildren(state); @@ -1264,7 +1268,21 @@ nsBoxFrame::AttributeChanged(nsIPresContext* aPresContext, nsresult rv = nsContainerFrame::AttributeChanged(aPresContext, aChild, aNameSpaceID, aAttribute, aModType, aHint); - if (aAttribute == nsHTMLAtoms::width || + if (aAttribute == nsXULAtoms::ordinal) { + nsCOMPtr shell; + aPresContext->GetShell(getter_AddRefs(shell)); + nsBoxLayoutState state(shell); + + nsIBox* parent; + GetParentBox(&parent); + parent->RelayoutChildAtOrdinal(state, this); + nsIFrame* parentFrame; + parent->GetFrame(&parentFrame); + nsBoxFrame* parentBoxFrame = (nsBoxFrame*) parentFrame; + if (parentBoxFrame) + parentBoxFrame->CheckFrameOrder(); + parent->MarkDirty(state); + } else if (aAttribute == nsHTMLAtoms::width || aAttribute == nsHTMLAtoms::height || aAttribute == nsHTMLAtoms::align || aAttribute == nsHTMLAtoms::valign || @@ -1392,6 +1410,34 @@ nsBoxFrame::SyncLayout(nsBoxLayoutState& aState) return rv; } +void +nsBoxFrame::CheckFrameOrder() +{ + if (mOrderBoxes) { + // synchronize the frame order with the box order by simply walking + // the box list and linking each frame as its box is linked + nsIBox* box = mFirstChild; + nsIFrame* frame1; + box->GetFrame(&frame1); + + nsIBox* box2; + nsIFrame* frame; + nsIFrame* frame2; + while (box) { + box->GetNextBox(&box2); + box->GetFrame(&frame); + if (box2) + box2->GetFrame(&frame2); + else + frame2 = nsnull; + frame->SetNextSibling(frame2); + box = box2; + } + + mFrames.SetFrames(frame1); + } +} + void nsBoxFrameInner::GetDebugPref(nsIPresContext* aPresContext) { diff --git a/mozilla/layout/xul/base/src/nsBoxFrame.h b/mozilla/layout/xul/base/src/nsBoxFrame.h index 5c00a1ee742..43b9493a93d 100644 --- a/mozilla/layout/xul/base/src/nsBoxFrame.h +++ b/mozilla/layout/xul/base/src/nsBoxFrame.h @@ -166,7 +166,8 @@ public: virtual nsresult GetContentOf(nsIContent** aContent); virtual nsresult SyncLayout(nsBoxLayoutState& aBoxLayoutState); - + virtual void CheckFrameOrder(); + nsBoxFrame(nsIPresShell* aPresShell, PRBool aIsRoot = nsnull, nsIBoxLayout* aLayoutManager = nsnull); static nsresult CreateViewForFrame(nsIPresContext* aPresContext, diff --git a/mozilla/layout/xul/base/src/nsBoxObject.cpp b/mozilla/layout/xul/base/src/nsBoxObject.cpp index 7600f48200f..9e7344f51bc 100644 --- a/mozilla/layout/xul/base/src/nsBoxObject.cpp +++ b/mozilla/layout/xul/base/src/nsBoxObject.cpp @@ -40,6 +40,7 @@ #include "nsIView.h" #include "nsIWidget.h" #include "nsIDOMXULElement.h" +#include "nsIBox.h" // Static IIDs/CIDs. Try to minimize these. static NS_DEFINE_CID(kLookAndFeelCID, NS_LOOKANDFEEL_CID); @@ -479,6 +480,122 @@ nsBoxObject::RemoveProperty(const PRUnichar* aPropertyName) return mPresState->RemoveStateProperty(propertyName); } +NS_IMETHODIMP +nsBoxObject::GetParentBox(nsIDOMElement * *aParentBox) +{ + nsIFrame* frame = GetFrame(); + if (!frame) return NS_OK; + nsIFrame* parent; + frame->GetParent(&parent); + if (!parent) return NS_OK; + + nsCOMPtr content; + parent->GetContent(getter_AddRefs(content)); + nsCOMPtr el = do_QueryInterface(content); + *aParentBox = el; + NS_IF_ADDREF(*aParentBox); + return NS_OK; +} + +NS_IMETHODIMP +nsBoxObject::GetFirstChild(nsIDOMElement * *aFirstVisibleChild) +{ + *aFirstVisibleChild = GetChildByOrdinalAt(0); + NS_IF_ADDREF(*aFirstVisibleChild); + return NS_OK; +} + +NS_IMETHODIMP +nsBoxObject::GetLastChild(nsIDOMElement * *aLastVisibleChild) +{ + PRInt32 count; + mContent->ChildCount(count); + *aLastVisibleChild = GetChildByOrdinalAt(count-1); + NS_IF_ADDREF(*aLastVisibleChild); + return NS_OK; +} + +NS_IMETHODIMP +nsBoxObject::GetNextSibling(nsIDOMElement **aNextOrdinalSibling) +{ + nsIFrame* frame = GetFrame(); + if (!frame) return NS_OK; + nsIFrame* nextFrame; + frame->GetNextSibling(&nextFrame); + if (!nextFrame) return NS_OK; + // get the content for the box and query to a dom element + nsCOMPtr nextContent; + nextFrame->GetContent(getter_AddRefs(nextContent)); + nsCOMPtr el = do_QueryInterface(nextContent); + *aNextOrdinalSibling = el; + NS_IF_ADDREF(*aNextOrdinalSibling); + + return NS_OK; +} + +NS_IMETHODIMP +nsBoxObject::GetPreviousSibling(nsIDOMElement **aPreviousOrdinalSibling) +{ + nsIFrame* frame = GetFrame(); + if (!frame) return NS_OK; + nsIFrame* parentFrame; + frame->GetParent(&parentFrame); + if (!parentFrame) return NS_OK; + + nsCOMPtr presContext; + mPresShell->GetPresContext(getter_AddRefs(presContext)); + + nsIFrame* nextFrame; + parentFrame->FirstChild(presContext, nsnull, &nextFrame); + nsIFrame* prevFrame = nsnull; + while (nextFrame) { + if (nextFrame == frame) + break; + prevFrame = nextFrame; + nextFrame->GetNextSibling(&nextFrame); + } + + if (!prevFrame) return NS_OK; + // get the content for the box and query to a dom element + nsCOMPtr nextContent; + prevFrame->GetContent(getter_AddRefs(nextContent)); + nsCOMPtr el = do_QueryInterface(nextContent); + *aPreviousOrdinalSibling = el; + NS_IF_ADDREF(*aPreviousOrdinalSibling); + + return NS_OK; +} + +nsIDOMElement* +nsBoxObject::GetChildByOrdinalAt(PRUint32 aIndex) +{ + // cast our way down to our nsContainerBox interface + nsIFrame* frame = GetFrame(); + if (!frame) return nsnull; + + nsCOMPtr presContext; + mPresShell->GetPresContext(getter_AddRefs(presContext)); + + // get the first child box + nsIFrame* childFrame; + frame->FirstChild(presContext, nsnull, &childFrame); + + PRUint32 i = 0; + while (childFrame && i < aIndex) { + childFrame->GetNextSibling(&childFrame); + ++i; + } + + if (!childFrame) return nsnull; + + // get the content for the box and query to a dom element + nsCOMPtr content; + childFrame->GetContent(getter_AddRefs(content)); + nsCOMPtr el = do_QueryInterface(content); + + return el; +} + // Creation Routine /////////////////////////////////////////////////////////////////////// nsresult @@ -490,3 +607,4 @@ NS_NewBoxObject(nsIBoxObject** aResult) NS_ADDREF(*aResult); return NS_OK; } + diff --git a/mozilla/layout/xul/base/src/nsBoxObject.h b/mozilla/layout/xul/base/src/nsBoxObject.h index c4395d2032d..d03dc015a7f 100644 --- a/mozilla/layout/xul/base/src/nsBoxObject.h +++ b/mozilla/layout/xul/base/src/nsBoxObject.h @@ -47,6 +47,7 @@ public: virtual nsIFrame* GetFrame(); nsresult GetOffsetRect(nsRect& aRect); nsresult GetScreenRect(nsRect& aRect); + nsIDOMElement* GetChildByOrdinalAt(PRUint32 aIndex); // MEMBER VARIABLES protected: diff --git a/mozilla/layout/xul/base/src/nsContainerBox.cpp b/mozilla/layout/xul/base/src/nsContainerBox.cpp index fe85df7e411..77326d2da8f 100644 --- a/mozilla/layout/xul/base/src/nsContainerBox.cpp +++ b/mozilla/layout/xul/base/src/nsContainerBox.cpp @@ -63,12 +63,17 @@ #include "nsIServiceManager.h" #include "nsContainerBox.h" +#include "nsQuickSort.h" + +int PR_CALLBACK +BoxOrderSortComparison(const void *v1, const void *v2, void *unused); nsContainerBox::nsContainerBox(nsIPresShell* aShell):nsBox(aShell) { mFirstChild = nsnull; mLastChild = nsnull; mChildCount = 0; + mOrderBoxes = PR_FALSE; } nsContainerBox::~nsContainerBox() @@ -124,6 +129,12 @@ nsContainerBox::CreateBoxList(nsBoxLayoutState& aState, nsIFrame* aFrameList, ns aLast->SetParentBox(this); + // check if this box is in a different ordinal group, and requires sorting + PRUint32 ordinal; + aLast->GetOrdinal(aState, ordinal); + if (ordinal != DEFAULT_ORDINAL_GROUP) + mOrderBoxes = PR_TRUE; + last->SetNextBox(aLast); last = aLast; aFrameList->GetNextSibling(&aFrameList); @@ -329,7 +340,9 @@ nsContainerBox::Prepend(nsBoxLayoutState& aState, nsIFrame* aList) last->SetNextBox(mFirstChild); mFirstChild= first; } - + + CheckBoxOrder(aState); + if (mLayoutManager) mLayoutManager->ChildrenInserted(this, aState, nsnull, first); @@ -348,6 +361,8 @@ nsContainerBox::Append(nsBoxLayoutState& aState, nsIFrame* aList) mLastChild= last; + CheckBoxOrder(aState); + if (mLayoutManager) mLayoutManager->ChildrenAppended(this, aState, first); } @@ -365,6 +380,8 @@ nsContainerBox::InsertAfter(nsBoxLayoutState& aState, nsIBox* aPrev, nsIFrame* a if (aPrev == mLastChild) mLastChild = last; + CheckBoxOrder(aState); + if (mLayoutManager) { mLayoutManager->ChildrenInserted(this, aState, aPrev, first); } @@ -376,6 +393,7 @@ nsContainerBox::InitChildren(nsBoxLayoutState& aState, nsIFrame* aList) { ClearChildren(aState); mChildCount += CreateBoxList(aState, aList, mFirstChild, mLastChild); + CheckBoxOrder(aState); if (mLayoutManager) mLayoutManager->ChildrenAppended(this, aState, mFirstChild); @@ -420,6 +438,50 @@ nsContainerBox::SanityCheck(nsFrameList& aFrameList) } } +void +nsContainerBox::CheckBoxOrder(nsBoxLayoutState& aState) +{ + if (mOrderBoxes) { + nsIBox** boxes = new nsIBox*[mChildCount]; + + // turn linked list into array for quick sort + nsIBox* box = mFirstChild; + nsIBox** boxPtr = boxes; + while (box) { + *boxPtr = box; + box->GetNextBox(&box); + ++boxPtr; + } + + // sort the array by ordinal group + NS_QuickSort(boxes, mChildCount, sizeof(nsIBox*), BoxOrderSortComparison, (void*)&aState); + + // turn the array back into linked list, with first and last cached + mFirstChild = boxes[0]; + mLastChild = boxes[mChildCount-1]; + for (PRInt32 i = 0; i < mChildCount; ++i) { + if (i <= mChildCount-2) + boxes[i]->SetNextBox(boxes[i+1]); + else + boxes[i]->SetNextBox(nsnull); + } + } +} + +int PR_CALLBACK +BoxOrderSortComparison(const void *v1, const void *v2, void *unused) +{ + nsIBox* box1 = *(nsIBox**) v1; + nsIBox* box2 = *(nsIBox**) v2; + nsBoxLayoutState state = *((nsBoxLayoutState*)unused); + + PRUint32 ord1; + box1->GetOrdinal(state, ord1); + PRUint32 ord2; + box2->GetOrdinal(state, ord2); + + return ord1 > ord2 ? 1 : (ord2 > ord1 ? -1 : 0); +} NS_IMETHODIMP nsContainerBox::GetPrefSize(nsBoxLayoutState& aState, nsSize& aSize) @@ -593,3 +655,78 @@ nsContainerBox::LayoutChildAt(nsBoxLayoutState& aState, nsIBox* aBox, const nsRe return NS_OK; } +NS_IMETHODIMP +nsContainerBox::RelayoutChildAtOrdinal(nsBoxLayoutState& aState, nsIBox* aChild) +{ + mOrderBoxes = PR_TRUE; + + PRUint32 ord; + aChild->GetOrdinal(aState, ord); + + PRUint32 ordCmp; + nsIBox* box = mFirstChild; + nsIBox* newPrevSib = mFirstChild; + + box->GetOrdinal(aState, ordCmp); + if (ord < ordCmp) { + // new ordinal is lower than the lowest current ordinal, so it will not + // have a previous sibling + newPrevSib = nsnull; + } else { + // search for the box after which we will insert this box + while (box) { + box->GetOrdinal(aState, ordCmp); + if (newPrevSib && ordCmp > ord) + break; + + newPrevSib = box; + box->GetNextBox(&box); + } + } + + // look for the previous sibling of |aChild| + nsIBox* oldPrevSib = mFirstChild; + while (oldPrevSib) { + nsIBox* me; + oldPrevSib->GetNextBox(&me); + if (aChild == me) { + break; + } + oldPrevSib = me; + } + + // if we are moving |mFirstChild|, we'll have to update the |mFirstChild| + // value later on + PRBool firstChildMoved = PR_FALSE; + if (aChild == mFirstChild) + firstChildMoved = PR_TRUE; + + nsIBox* newNextSib; + if (newPrevSib) { + // insert |aChild| between |newPrevSib| and its next sibling + newPrevSib->GetNextBox(&newNextSib); + newPrevSib->SetNextBox(aChild); + } else { + // no |newPrevSib| found, so this box will become |mFirstChild| + newNextSib = mFirstChild; + mFirstChild = aChild; + } + + // link up our new next sibling + nsIBox* oldNextSib; + aChild->GetNextBox(&oldNextSib); + aChild->SetNextBox(newNextSib); + + // link |oldPrevSib| with |oldNextSib| to fill the gap left behind + if (oldPrevSib) + oldPrevSib->SetNextBox(oldNextSib); + + // if |newPrevSib| was the last child, then aChild is the new last child + if (newPrevSib == mLastChild) + mLastChild = aChild; + + if (firstChildMoved) + mFirstChild = oldNextSib; + + return NS_OK; +} diff --git a/mozilla/layout/xul/base/src/nsContainerBox.h b/mozilla/layout/xul/base/src/nsContainerBox.h index 06b5fedf4e4..df4cc01f756 100644 --- a/mozilla/layout/xul/base/src/nsContainerBox.h +++ b/mozilla/layout/xul/base/src/nsContainerBox.h @@ -48,6 +48,7 @@ public: NS_IMETHOD GetMaxSize(nsBoxLayoutState& aBoxLayoutState, nsSize& aSize); NS_IMETHOD GetAscent(nsBoxLayoutState& aBoxLayoutState, nscoord& aAscent); NS_IMETHOD DoLayout(nsBoxLayoutState& aBoxLayoutState); + NS_IMETHOD RelayoutChildAtOrdinal(nsBoxLayoutState& aState, nsIBox* aChild); virtual nsIBox* GetBoxAt(PRInt32 aIndex); virtual nsIBox* GetBox(nsIFrame* aFrame); @@ -65,7 +66,8 @@ public: virtual nsIBox* GetPrevious(nsIFrame* aChild); virtual void SanityCheck(nsFrameList& aFrameList); virtual void SetDebugOnChildList(nsBoxLayoutState& aState, nsIBox* aChild, PRBool aDebug); - + virtual void CheckBoxOrder(nsBoxLayoutState& aState); + static nsresult LayoutChildAt(nsBoxLayoutState& aState, nsIBox* aBox, const nsRect& aRect); @@ -78,6 +80,7 @@ protected: nsIBox* mFirstChild; nsIBox* mLastChild; PRInt32 mChildCount; + PRBool mOrderBoxes; nsCOMPtr mLayoutManager; }; diff --git a/mozilla/layout/xul/base/src/nsIBox.h b/mozilla/layout/xul/base/src/nsIBox.h index cd7ed59953a..73d15ff2c16 100644 --- a/mozilla/layout/xul/base/src/nsIBox.h +++ b/mozilla/layout/xul/base/src/nsIBox.h @@ -42,6 +42,8 @@ struct nsSize; // {162F6B5A-F926-11d3-BA06-001083023C1E} #define NS_IBOX_IID { 0x162f6b5a, 0xf926, 0x11d3, { 0xba, 0x6, 0x0, 0x10, 0x83, 0x2, 0x3c, 0x1e } } +#define DEFAULT_ORDINAL_GROUP 1 + class nsIBox : public nsISupports { public: @@ -65,6 +67,7 @@ public: NS_IMETHOD GetMinSize(nsBoxLayoutState& aBoxLayoutState, nsSize& aSize)=0; NS_IMETHOD GetMaxSize(nsBoxLayoutState& aBoxLayoutState, nsSize& aSize)=0; NS_IMETHOD GetFlex(nsBoxLayoutState& aBoxLayoutState, nscoord& aFlex)=0; + NS_IMETHOD GetOrdinal(nsBoxLayoutState& aBoxLayoutState, PRUint32& aOrdinal)=0; NS_IMETHOD GetAscent(nsBoxLayoutState& aBoxLayoutState, nscoord& aAscent)=0; NS_IMETHOD IsCollapsed(nsBoxLayoutState& aBoxLayoutState, PRBool& aCollapsed)=0; NS_IMETHOD Collapse(nsBoxLayoutState& aBoxLayoutState)=0; @@ -102,6 +105,7 @@ public: NS_IMETHOD GetDebugBoxAt(const nsPoint& aPoint, nsIBox** aBox)=0; NS_IMETHOD RelayoutDirtyChild(nsBoxLayoutState& aState, nsIBox* aChild)=0; NS_IMETHOD RelayoutStyleChange(nsBoxLayoutState& aState, nsIBox* aChild)=0; + NS_IMETHOD RelayoutChildAtOrdinal(nsBoxLayoutState& aState, nsIBox* aChild)=0; NS_IMETHOD GetMouseThrough(PRBool& aMouseThrough)=0; NS_IMETHOD MarkChildrenStyleChange()=0; NS_IMETHOD MarkStyleChange(nsBoxLayoutState& aState)=0; @@ -113,6 +117,7 @@ public: static PRBool AddCSSMaxSize(nsBoxLayoutState& aState, nsIBox* aBox, nsSize& aSize); static PRBool AddCSSFlex(nsBoxLayoutState& aState, nsIBox* aBox, nscoord& aFlex); static PRBool AddCSSCollapsed(nsBoxLayoutState& aState, nsIBox* aBox, PRBool& aCollapsed); + static PRBool AddCSSOrdinal(nsBoxLayoutState& aState, nsIBox* aBox, PRUint32& aOrdinal); };