From 68e63e11834a238c86ff8ea12dcf1d70f7713ea7 Mon Sep 17 00:00:00 2001 From: "L. David Baron" Date: Wed, 23 Dec 2009 14:10:31 -0500 Subject: [PATCH] Add mechanism for returning computed value name of certain longhand properties of our fake shorthands. (Bug 531585) r=bzbarsky --- layout/style/nsCSSPropList.h | 30 ++++++++++++++++++++---------- layout/style/nsCSSProps.cpp | 29 +++++++++++++++++++++++++++++ layout/style/nsCSSProps.h | 12 ++++++++++++ 3 files changed, 61 insertions(+), 10 deletions(-) diff --git a/layout/style/nsCSSPropList.h b/layout/style/nsCSSPropList.h index e6f7ab55ffd..a9b2372fbb7 100644 --- a/layout/style/nsCSSPropList.h +++ b/layout/style/nsCSSPropList.h @@ -717,7 +717,8 @@ CSS_PROP_BORDER( border_left_color_value, X, CSS_PROPERTY_APPLIES_TO_FIRST_LETTER | - CSS_PROPERTY_IGNORED_WHEN_COLORS_DISABLED, + CSS_PROPERTY_IGNORED_WHEN_COLORS_DISABLED | + CSS_PROPERTY_REPORT_OTHER_NAME, Margin, mBorderColor.mLeft, eCSSType_Value, @@ -773,7 +774,8 @@ CSS_PROP_BORDER( border-left-style-value, border_left_style_value, X, - CSS_PROPERTY_APPLIES_TO_FIRST_LETTER, + CSS_PROPERTY_APPLIES_TO_FIRST_LETTER | + CSS_PROPERTY_REPORT_OTHER_NAME, Margin, mBorderStyle.mLeft, eCSSType_Value, @@ -815,7 +817,8 @@ CSS_PROP_BORDER( border-left-width-value, border_left_width_value, X, - CSS_PROPERTY_APPLIES_TO_FIRST_LETTER, + CSS_PROPERTY_APPLIES_TO_FIRST_LETTER | + CSS_PROPERTY_REPORT_OTHER_NAME, Margin, mBorderWidth.mLeft, eCSSType_Value, @@ -863,7 +866,8 @@ CSS_PROP_BORDER( border_right_color_value, X, CSS_PROPERTY_APPLIES_TO_FIRST_LETTER | - CSS_PROPERTY_IGNORED_WHEN_COLORS_DISABLED, + CSS_PROPERTY_IGNORED_WHEN_COLORS_DISABLED | + CSS_PROPERTY_REPORT_OTHER_NAME, Margin, mBorderColor.mRight, eCSSType_Value, @@ -919,7 +923,8 @@ CSS_PROP_BORDER( border-right-style-value, border_right_style_value, X, - CSS_PROPERTY_APPLIES_TO_FIRST_LETTER, + CSS_PROPERTY_APPLIES_TO_FIRST_LETTER | + CSS_PROPERTY_REPORT_OTHER_NAME, Margin, mBorderStyle.mRight, eCSSType_Value, @@ -961,7 +966,8 @@ CSS_PROP_BORDER( border-right-width-value, border_right_width_value, X, - CSS_PROPERTY_APPLIES_TO_FIRST_LETTER, + CSS_PROPERTY_APPLIES_TO_FIRST_LETTER | + CSS_PROPERTY_REPORT_OTHER_NAME, Margin, mBorderWidth.mRight, eCSSType_Value, @@ -1651,7 +1657,8 @@ CSS_PROP_MARGIN( margin-left-value, margin_left_value, X, - CSS_PROPERTY_APPLIES_TO_FIRST_LETTER, + CSS_PROPERTY_APPLIES_TO_FIRST_LETTER | + CSS_PROPERTY_REPORT_OTHER_NAME, Margin, mMargin.mLeft, eCSSType_Value, @@ -1693,7 +1700,8 @@ CSS_PROP_MARGIN( margin-right-value, margin_right_value, X, - CSS_PROPERTY_APPLIES_TO_FIRST_LETTER, + CSS_PROPERTY_APPLIES_TO_FIRST_LETTER | + CSS_PROPERTY_REPORT_OTHER_NAME, Margin, mMargin.mRight, eCSSType_Value, @@ -1958,7 +1966,8 @@ CSS_PROP_PADDING( padding-left-value, padding_left_value, X, - CSS_PROPERTY_APPLIES_TO_FIRST_LETTER, + CSS_PROPERTY_APPLIES_TO_FIRST_LETTER | + CSS_PROPERTY_REPORT_OTHER_NAME, Margin, mPadding.mLeft, eCSSType_Value, @@ -2000,7 +2009,8 @@ CSS_PROP_PADDING( padding-right-value, padding_right_value, X, - CSS_PROPERTY_APPLIES_TO_FIRST_LETTER, + CSS_PROPERTY_APPLIES_TO_FIRST_LETTER | + CSS_PROPERTY_REPORT_OTHER_NAME, Margin, mPadding.mRight, eCSSType_Value, diff --git a/layout/style/nsCSSProps.cpp b/layout/style/nsCSSProps.cpp index b313883994f..ac6ac7b36a3 100644 --- a/layout/style/nsCSSProps.cpp +++ b/layout/style/nsCSSProps.cpp @@ -370,6 +370,35 @@ nsCSSProps::GetStringValue(nsCSSFontDesc aFontDescID) } } +nsCSSProperty +nsCSSProps::OtherNameFor(nsCSSProperty aProperty) +{ + switch (aProperty) { + case eCSSProperty_border_left_color_value: + return eCSSProperty_border_left_color; + case eCSSProperty_border_left_style_value: + return eCSSProperty_border_left_style; + case eCSSProperty_border_left_width_value: + return eCSSProperty_border_left_width; + case eCSSProperty_border_right_color_value: + return eCSSProperty_border_right_color; + case eCSSProperty_border_right_style_value: + return eCSSProperty_border_right_style; + case eCSSProperty_border_right_width_value: + return eCSSProperty_border_right_width; + case eCSSProperty_margin_left_value: + return eCSSProperty_margin_left; + case eCSSProperty_margin_right_value: + return eCSSProperty_margin_right; + case eCSSProperty_padding_left_value: + return eCSSProperty_padding_left; + case eCSSProperty_padding_right_value: + return eCSSProperty_padding_right; + default: + NS_ABORT_IF_FALSE(PR_FALSE, "bad caller"); + } + return eCSSProperty_UNKNOWN; +} /***************************************************************************/ diff --git a/layout/style/nsCSSProps.h b/layout/style/nsCSSProps.h index bcbb0d95c36..2681824b6ea 100644 --- a/layout/style/nsCSSProps.h +++ b/layout/style/nsCSSProps.h @@ -79,6 +79,13 @@ // list. #define CSS_PROPERTY_IMAGE_IS_IN_ARRAY_0 (1<<6) +// This is a property for which the computed value should generally be +// reported as the computed value of a property of a different name. In +// particular, the directional box properties (margin-left-value, etc.) +// should be reported as being margin-left, etc. Call +// nsCSSProps::OtherNameFor to get the other property. +#define CSS_PROPERTY_REPORT_OTHER_NAME (1<<7) + /** * Types of animatable values. */ @@ -152,6 +159,11 @@ public: static const nsAFlatCString& GetStringValue(nsCSSProperty aProperty); static const nsAFlatCString& GetStringValue(nsCSSFontDesc aFontDesc); + // Get the property to report the computed value of aProperty as being + // the computed value of. aProperty must have the + // CSS_PROPERTY_REPORT_OTHER_NAME bit set. + static nsCSSProperty OtherNameFor(nsCSSProperty aProperty); + // Given a CSS Property and a Property Enum Value // Return back a const nsString& representation of the // value. Return back nullstr if no value is found