From be38660c666bfce95add39ec06730d2d31551133 Mon Sep 17 00:00:00 2001 From: "L. David Baron" Date: Tue, 20 Nov 2012 11:55:14 -0800 Subject: [PATCH] Bug 813373, patch 3: Make sure all style rules have non-empty List implementations. r=bzbarsky --- .../html/content/src/nsHTMLBodyElement.cpp | 2 ++ layout/style/AnimationCommon.cpp | 11 +++++- layout/style/nsCSSRules.cpp | 36 +++++++++++++------ layout/style/nsCSSRules.h | 2 ++ layout/style/nsHTMLStyleSheet.cpp | 4 +++ layout/style/nsStyleSet.cpp | 4 +++ 6 files changed, 48 insertions(+), 11 deletions(-) diff --git a/content/html/content/src/nsHTMLBodyElement.cpp b/content/html/content/src/nsHTMLBodyElement.cpp index 8101df6562c..7f0e02ac098 100644 --- a/content/html/content/src/nsHTMLBodyElement.cpp +++ b/content/html/content/src/nsHTMLBodyElement.cpp @@ -256,6 +256,8 @@ BodyRule::MapRuleInfoInto(nsRuleData* aData) /* virtual */ void BodyRule::List(FILE* out, int32_t aIndent) const { + for (int32_t index = aIndent; --index >= 0; ) fputs(" ", out); + printf("[body rule] {}\n"); } #endif diff --git a/layout/style/AnimationCommon.cpp b/layout/style/AnimationCommon.cpp index 2db9dfe5ada..bd06b43111e 100644 --- a/layout/style/AnimationCommon.cpp +++ b/layout/style/AnimationCommon.cpp @@ -185,7 +185,16 @@ AnimValuesStyleRule::MapRuleInfoInto(nsRuleData* aRuleData) /* virtual */ void AnimValuesStyleRule::List(FILE* out, int32_t aIndent) const { - // WRITE ME? + for (int32_t index = aIndent; --index >= 0; ) fputs(" ", out); + printf("[anim values] { "); + for (uint32_t i = 0, i_end = mPropertyValuePairs.Length(); i < i_end; ++i) { + const PropertyValuePair &pair = mPropertyValuePairs[i]; + nsAutoString value; + nsStyleAnimation::UncomputeValue(pair.mProperty, pair.mValue, value); + printf("%s: %s; ", nsCSSProps::GetStringValue(pair.mProperty).get(), + NS_ConvertUTF16toUTF8(value).get()); + } + printf("}\n"); } #endif diff --git a/layout/style/nsCSSRules.cpp b/layout/style/nsCSSRules.cpp index af451d257a7..2da32d30b7d 100644 --- a/layout/style/nsCSSRules.cpp +++ b/layout/style/nsCSSRules.cpp @@ -1991,7 +1991,14 @@ nsCSSKeyframeRule::MapRuleInfoInto(nsRuleData* aRuleData) void nsCSSKeyframeRule::List(FILE* out, int32_t aIndent) const { - // FIXME: WRITE ME + for (int32_t index = aIndent; --index >= 0; ) fputs(" ", out); + + nsAutoString tmp; + DoGetKeyText(tmp); + fputs(NS_ConvertUTF16toUTF8(tmp).get(), out); + fputs(" ", out); + mDeclaration->List(out, aIndent); + fputs("\n", out); } #endif @@ -2011,7 +2018,7 @@ nsCSSKeyframeRule::GetType(uint16_t* aType) NS_IMETHODIMP nsCSSKeyframeRule::GetCssText(nsAString& aCssText) { - nsCSSKeyframeRule::GetKeyText(aCssText); + DoGetKeyText(aCssText); aCssText.AppendLiteral(" { "); nsAutoString tmp; mDeclaration->ToString(tmp); @@ -2041,6 +2048,13 @@ nsCSSKeyframeRule::GetParentRule(nsIDOMCSSRule** aParentRule) NS_IMETHODIMP nsCSSKeyframeRule::GetKeyText(nsAString& aKeyText) +{ + DoGetKeyText(aKeyText); + return NS_OK; +} + +void +nsCSSKeyframeRule::DoGetKeyText(nsAString& aKeyText) const { aKeyText.Truncate(); uint32_t i = 0, i_end = mKeys.Length(); @@ -2053,7 +2067,6 @@ nsCSSKeyframeRule::GetKeyText(nsAString& aKeyText) } aKeyText.AppendLiteral(", "); } - return NS_OK; } NS_IMETHODIMP @@ -2157,7 +2170,10 @@ NS_INTERFACE_MAP_END_INHERITING(GroupRule) void nsCSSKeyframesRule::List(FILE* out, int32_t aIndent) const { - // FIXME: WRITE ME + for (int32_t indent = aIndent; --indent >= 0; ) fputs(" ", out); + + fprintf(out, "@keyframes %s", NS_ConvertUTF16toUTF8(mName).get()); + GroupRule::List(out, aIndent); } #endif @@ -2440,7 +2456,11 @@ IMPL_STYLE_RULE_INHERIT_GET_DOM_RULE_WEAK(nsCSSPageRule, Rule) void nsCSSPageRule::List(FILE* out, int32_t aIndent) const { - // FIXME: WRITE ME + for (int32_t indent = aIndent; --indent >= 0; ) fputs(" ", out); + + fputs("@page ", out); + mDeclaration->List(out, aIndent); + fputs("\n", out); } #endif @@ -2555,12 +2575,8 @@ CSSSupportsRule::List(FILE* out, int32_t aIndent) const { for (int32_t indent = aIndent; --indent >= 0; ) fputs(" ", out); - nsAutoString buffer; - fputs("@supports ", out); - - fputs(NS_LossyConvertUTF16toASCII(mCondition).get(), out); - + fputs(NS_ConvertUTF16toUTF8(mCondition).get(), out); css::GroupRule::List(out, aIndent); } #endif diff --git a/layout/style/nsCSSRules.h b/layout/style/nsCSSRules.h index eb79435e276..6eb6104ae8f 100644 --- a/layout/style/nsCSSRules.h +++ b/layout/style/nsCSSRules.h @@ -371,6 +371,8 @@ public: virtual size_t SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const MOZ_OVERRIDE; + void DoGetKeyText(nsAString &aKeyText) const; + private: nsAutoTArray mKeys; nsAutoPtr mDeclaration; diff --git a/layout/style/nsHTMLStyleSheet.cpp b/layout/style/nsHTMLStyleSheet.cpp index 4f9b872bb6b..3f03dd12450 100644 --- a/layout/style/nsHTMLStyleSheet.cpp +++ b/layout/style/nsHTMLStyleSheet.cpp @@ -58,6 +58,8 @@ nsHTMLStyleSheet::HTMLColorRule::MapRuleInfoInto(nsRuleData* aRuleData) /* virtual */ void nsHTMLStyleSheet::HTMLColorRule::List(FILE* out, int32_t aIndent) const { + for (int32_t index = aIndent; --index >= 0; ) fputs(" ", out); + printf("[html color rule] {}\n"); } #endif @@ -68,6 +70,8 @@ NS_IMPL_ISUPPORTS1(nsHTMLStyleSheet::GenericTableRule, nsIStyleRule) /* virtual */ void nsHTMLStyleSheet::GenericTableRule::List(FILE* out, int32_t aIndent) const { + for (int32_t index = aIndent; --index >= 0; ) fputs(" ", out); + printf("[generic table rule] {}\n"); } #endif diff --git a/layout/style/nsStyleSet.cpp b/layout/style/nsStyleSet.cpp index 010b06d8561..e735ad2e307 100644 --- a/layout/style/nsStyleSet.cpp +++ b/layout/style/nsStyleSet.cpp @@ -45,6 +45,8 @@ nsEmptyStyleRule::MapRuleInfoInto(nsRuleData* aRuleData) /* virtual */ void nsEmptyStyleRule::List(FILE* out, int32_t aIndent) const { + for (int32_t index = aIndent; --index >= 0; ) fputs(" ", out); + printf("[empty style rule] {}\n"); } #endif @@ -89,6 +91,8 @@ nsInitialStyleRule::MapRuleInfoInto(nsRuleData* aRuleData) /* virtual */ void nsInitialStyleRule::List(FILE* out, int32_t aIndent) const { + for (int32_t index = aIndent; --index >= 0; ) fputs(" ", out); + printf("[initial style rule] {}\n"); } #endif