Bug 649142 - Part 6: Remove support for shorthand-implemented logical properties. r=dbaron

This includes removing:

* the box property directional source constants
* the CSS_PROPERTY_DIRECTIONAL_SOURCE property flag
* the CSS_PROPERTY_REPORT_OTHER_NAME property flag
* nsCSSProps::OtherNameFor
* methods on the CSS parser to parse directional box properties and set
  the old *-source and *-value properties
* the resolution of logical and physical properties in nsRuleNode during
  style computation, since that's now done as part of the cascade in
  nsCSSExpandedDataBlock::MapRuleInfoInto
This commit is contained in:
Cameron McCormack 2014-12-31 12:18:16 +11:00
parent f3b4838e87
commit 26febeb99d
11 changed files with 7 additions and 190 deletions

View File

@ -2754,18 +2754,10 @@ nsDOMWindowUtils::ComputeAnimationDistance(nsIDOMElement* aElement,
nsCOMPtr<nsIContent> content = do_QueryInterface(aElement, &rv);
NS_ENSURE_SUCCESS(rv, rv);
// Convert direction-dependent properties as appropriate, e.g.,
// border-left to border-left-value.
nsCSSProperty property =
nsCSSProps::LookupProperty(aProperty, nsCSSProps::eIgnoreEnabledState);
if (property != eCSSProperty_UNKNOWN && nsCSSProps::IsShorthand(property)) {
nsCSSProperty subprop0 = *nsCSSProps::SubpropertyEntryFor(property);
if (nsCSSProps::PropHasFlags(subprop0, CSS_PROPERTY_REPORT_OTHER_NAME) &&
nsCSSProps::OtherNameFor(subprop0) == property) {
property = subprop0;
} else {
property = eCSSProperty_UNKNOWN;
}
property = eCSSProperty_UNKNOWN;
}
NS_ABORT_IF_FALSE(property == eCSSProperty_UNKNOWN ||

View File

@ -522,7 +522,7 @@ static void GetKeywordsForProperty(const nsCSSProperty aProperty,
}
const nsCSSProps::KTableValue *keywordTable =
nsCSSProps::kKeywordTableTable[aProperty];
if (keywordTable && keywordTable != nsCSSProps::kBoxPropSourceKTable) {
if (keywordTable) {
size_t i = 0;
while (nsCSSKeyword(keywordTable[i]) != eCSSKeyword_UNKNOWN) {
nsCSSKeyword word = nsCSSKeyword(keywordTable[i]);

View File

@ -169,9 +169,8 @@ Declaration::GetValue(nsCSSProperty aProperty, nsAString& aValue,
initialCount = 0, inheritCount = 0, unsetCount = 0,
matchingTokenStreamCount = 0, nonMatchingTokenStreamCount = 0;
CSSPROPS_FOR_SHORTHAND_SUBPROPERTIES(p, aProperty) {
if (*p == eCSSProperty__x_system_font ||
nsCSSProps::PropHasFlags(*p, CSS_PROPERTY_DIRECTIONAL_SOURCE)) {
// The system-font subproperty and the *-source properties don't count.
if (*p == eCSSProperty__x_system_font) {
// The system-font subproperty doesn't count.
continue;
}
++totalCount;

View File

@ -2539,13 +2539,9 @@ StyleAnimationValue::ComputeValue(nsCSSProperty aProperty,
"we should only be able to actively animate nodes that "
"are in a document");
nsCSSProperty propToParse =
nsCSSProps::PropHasFlags(aProperty, CSS_PROPERTY_REPORT_OTHER_NAME)
? nsCSSProps::OtherNameFor(aProperty) : aProperty;
// Parse specified value into a temporary css::StyleRule
nsRefPtr<css::StyleRule> styleRule =
BuildStyleRule(propToParse, aTargetElement, aSpecifiedValue, aUseSVGMode);
BuildStyleRule(aProperty, aTargetElement, aSpecifiedValue, aUseSVGMode);
if (!styleRule) {
return false;
}

View File

@ -630,8 +630,6 @@ protected:
bool ParseTreePseudoElement(nsAtomList **aPseudoElementArgs);
#endif
void InitBoxPropsAsPhysical(const nsCSSProperty *aSourceProperties);
// Property specific parsing routines
bool ParseBackground();
@ -688,8 +686,6 @@ protected:
bool ParseBorderSpacing();
bool ParseBorderSide(const nsCSSProperty aPropIDs[],
bool aSetAllSides);
bool ParseDirectionalBorderSide(const nsCSSProperty aPropIDs[],
int32_t aSourceType);
bool ParseBorderStyle();
bool ParseBorderWidth();
@ -889,8 +885,6 @@ protected:
bool ParseBoxProperties(const nsCSSProperty aPropIDs[]);
bool ParseGroupedBoxProperty(int32_t aVariantMask,
nsCSSValue& aValue);
bool ParseDirectionalBoxProperty(nsCSSProperty aProperty,
int32_t aSourceType);
bool ParseBoxCornerRadius(const nsCSSProperty aPropID);
bool ParseBoxCornerRadiiInternals(nsCSSValue array[]);
bool ParseBoxCornerRadii(const nsCSSProperty aPropIDs[]);
@ -9319,25 +9313,6 @@ CSSParserImpl::ParseGroupedBoxProperty(int32_t aVariantMask,
return true;
}
bool
CSSParserImpl::ParseDirectionalBoxProperty(nsCSSProperty aProperty,
int32_t aSourceType)
{
const nsCSSProperty* subprops = nsCSSProps::SubpropertyEntryFor(aProperty);
NS_ASSERTION(subprops[3] == eCSSProperty_UNKNOWN,
"not box property with physical vs. logical cascading");
nsCSSValue value;
if (!ParseSingleValueProperty(value, subprops[0])) {
return false;
}
AppendValue(subprops[0], value);
nsCSSValue typeVal(aSourceType, eCSSUnit_Enumerated);
AppendValue(subprops[1], typeVal);
AppendValue(subprops[2], typeVal);
return true;
}
bool
CSSParserImpl::ParseBoxCornerRadius(nsCSSProperty aPropID)
{
@ -10052,16 +10027,6 @@ CSSParserImpl::ParseFontDescriptorValue(nsCSSFontDesc aDescID,
return false;
}
void
CSSParserImpl::InitBoxPropsAsPhysical(const nsCSSProperty *aSourceProperties)
{
nsCSSValue physical(NS_BOXPROP_SOURCE_PHYSICAL, eCSSUnit_Enumerated);
for (const nsCSSProperty *prop = aSourceProperties;
*prop != eCSSProperty_UNKNOWN; ++prop) {
AppendValue(*prop, physical);
}
}
static nsCSSValue
BoxPositionMaskToCSSValue(int32_t aMask, bool isX)
{
@ -11158,40 +11123,6 @@ CSSParserImpl::ParseBorderSide(const nsCSSProperty aPropIDs[],
return true;
}
bool
CSSParserImpl::ParseDirectionalBorderSide(const nsCSSProperty aPropIDs[],
int32_t aSourceType)
{
const int32_t numProps = 3;
nsCSSValue values[numProps];
int32_t found = ParseChoice(values, aPropIDs, numProps);
if (found < 1) {
return false;
}
if ((found & 1) == 0) { // Provide default border-width
values[0].SetIntValue(NS_STYLE_BORDER_WIDTH_MEDIUM, eCSSUnit_Enumerated);
}
if ((found & 2) == 0) { // Provide default border-style
values[1].SetIntValue(NS_STYLE_BORDER_STYLE_NONE, eCSSUnit_Enumerated);
}
if ((found & 4) == 0) { // text color will be used
values[2].SetIntValue(NS_STYLE_COLOR_MOZ_USE_TEXT_COLOR, eCSSUnit_Enumerated);
}
for (int32_t index = 0; index < numProps; index++) {
const nsCSSProperty* subprops =
nsCSSProps::SubpropertyEntryFor(aPropIDs[index + numProps]);
NS_ASSERTION(subprops[3] == eCSSProperty_UNKNOWN,
"not box property with physical vs. logical cascading");
AppendValue(subprops[0], values[index]);
nsCSSValue typeVal(aSourceType, eCSSUnit_Enumerated);
AppendValue(subprops[1], typeVal);
AppendValue(subprops[2], typeVal);
}
return true;
}
bool
CSSParserImpl::ParseBorderStyle()
{

View File

@ -558,13 +558,6 @@ nsCSSProps::GetStringValue(nsCSSCounterDesc aCounterDesc)
}
}
nsCSSProperty
nsCSSProps::OtherNameFor(nsCSSProperty aProperty)
{
NS_ABORT_IF_FALSE(false, "bad caller");
return eCSSProperty_UNKNOWN;
}
/***************************************************************************/
const KTableValue nsCSSProps::kAnimationDirectionKTable[] = {
@ -842,12 +835,6 @@ const KTableValue nsCSSProps::kBorderWidthKTable[] = {
eCSSKeyword_UNKNOWN,-1
};
const KTableValue nsCSSProps::kBoxPropSourceKTable[] = {
eCSSKeyword_physical, NS_BOXPROP_SOURCE_PHYSICAL,
eCSSKeyword_logical, NS_BOXPROP_SOURCE_LOGICAL,
eCSSKeyword_UNKNOWN,-1
};
const KTableValue nsCSSProps::kBoxDecorationBreakKTable[] = {
eCSSKeyword_slice, NS_STYLE_BOX_DECORATION_BREAK_SLICE,
eCSSKeyword_clone, NS_STYLE_BOX_DECORATION_BREAK_CLONE,

View File

@ -103,9 +103,7 @@
// Flags for the kFlagsTable bitfield (flags_ in nsCSSPropList.h)
// A property that is a *-ltr-source or *-rtl-source property for one of
// the directional pseudo-shorthand properties.
#define CSS_PROPERTY_DIRECTIONAL_SOURCE (1<<0)
// Flag (1<<0) is currently free.
#define CSS_PROPERTY_VALUE_LIST_USES_COMMAS (1<<1) /* otherwise spaces */
@ -131,12 +129,7 @@
// 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)
// Flag (1<<7) is currently free.
// This property allows calc() between lengths and percentages and
// stores such calc() expressions in its style structs (typically in an
@ -329,11 +322,6 @@ public:
static const nsAFlatCString& GetStringValue(nsCSSFontDesc aFontDesc);
static const nsAFlatCString& GetStringValue(nsCSSCounterDesc aCounterDesc);
// 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

View File

@ -2572,65 +2572,6 @@ nsRuleNode::SetDefaultOnRoot(const nsStyleStructID aSID, nsStyleContext* aContex
return nullptr;
}
/*
* This function handles cascading of *-left or *-right box properties
* against *-start (which is L for LTR and R for RTL) or *-end (which is
* R for LTR and L for RTL).
*
* Cascading these properties correctly is hard because we need to
* cascade two properties as one, but which two properties depends on a
* third property ('direction'). We solve this by treating each of
* these properties (say, 'margin-start') as a shorthand that sets a
* property containing the value of the property specified
* ('margin-start-value') and sets a pair of properties
* ('margin-left-ltr-source' and 'margin-right-rtl-source') saying which
* of the properties we use. Thus, when we want to compute the value of
* 'margin-left' when 'direction' is 'ltr', we look at the value of
* 'margin-left-ltr-source', which tells us whether to use the highest
* 'margin-left' in the cascade or the highest 'margin-start'.
*
* Finally, since we can compute the normal (*-left and *-right)
* properties in a loop, this function works by modifying the data we
* will use in that loop (which the caller must copy from the const
* input).
*/
void
nsRuleNode::AdjustLogicalBoxProp(nsStyleContext* aContext,
const nsCSSValue& aLTRSource,
const nsCSSValue& aRTLSource,
const nsCSSValue& aLTRLogicalValue,
const nsCSSValue& aRTLLogicalValue,
mozilla::css::Side aSide,
nsCSSRect& aValueRect,
bool& aCanStoreInRuleTree)
{
bool LTRlogical = aLTRSource.GetUnit() == eCSSUnit_Enumerated &&
aLTRSource.GetIntValue() == NS_BOXPROP_SOURCE_LOGICAL;
bool RTLlogical = aRTLSource.GetUnit() == eCSSUnit_Enumerated &&
aRTLSource.GetIntValue() == NS_BOXPROP_SOURCE_LOGICAL;
if (LTRlogical || RTLlogical) {
// We can't cache anything on the rule tree if we use any data from
// the style context, since data cached in the rule tree could be
// used with a style context with a different value.
aCanStoreInRuleTree = false;
uint8_t dir = aContext->StyleVisibility()->mDirection;
if (dir == NS_STYLE_DIRECTION_LTR) {
if (LTRlogical)
aValueRect.*(nsCSSRect::sides[aSide]) = aLTRLogicalValue;
} else {
if (RTLlogical)
aValueRect.*(nsCSSRect::sides[aSide]) = aRTLLogicalValue;
}
} else if (aLTRLogicalValue.GetUnit() == eCSSUnit_Inherit ||
aRTLLogicalValue.GetUnit() == eCSSUnit_Inherit) {
// It actually is valid to store this in the ruletree, since
// LTRlogical and RTLlogical are both false, but doing that will
// trigger asserts. Silence those.
aCanStoreInRuleTree = false;
}
}
/**
* Begin an nsRuleNode::Compute*Data function for an inherited struct.
*

View File

@ -643,15 +643,6 @@ protected:
uint8_t aGenericFontID,
nsStyleFont* aFont);
void AdjustLogicalBoxProp(nsStyleContext* aContext,
const nsCSSValue& aLTRSource,
const nsCSSValue& aRTLSource,
const nsCSSValue& aLTRLogicalValue,
const nsCSSValue& aRTLLogicalValue,
mozilla::css::Side aSide,
nsCSSRect& aValueRect,
bool& aCanStoreInRuleTree);
inline RuleDetail CheckSpecifiedProperties(const nsStyleStructID aSID,
const nsRuleData* aRuleData);

View File

@ -56,10 +56,6 @@ static inline mozilla::css::Side operator++(mozilla::css::Side& side, int) {
#define NS_SIDE_TO_HALF_CORNER(side_, second_, parallel_) \
((((side_) + !!(second_))*2 + ((side_) + !(parallel_))%2) % 8)
// {margin,border-{width,style,color},padding}-{left,right}-{ltr,rtl}-source
#define NS_BOXPROP_SOURCE_PHYSICAL 0
#define NS_BOXPROP_SOURCE_LOGICAL 1
// box-sizing
#define NS_STYLE_BOX_SIZING_CONTENT 0
#define NS_STYLE_BOX_SIZING_PADDING 1

View File

@ -695,10 +695,6 @@ nsTransitionManager::FlushTransitions(FlushFlags aFlags)
MOZ_ASSERT(player->GetSource()->Properties().Length() == 1,
"Should have one animation property for a transition");
nsCSSProperty prop = player->GetSource()->Properties()[0].mProperty;
if (nsCSSProps::PropHasFlags(prop, CSS_PROPERTY_REPORT_OTHER_NAME))
{
prop = nsCSSProps::OtherNameFor(prop);
}
TimeDuration duration =
player->GetSource()->Timing().mIterationDuration;
events.AppendElement(