Changeset 153581 in webkit


Ignore:
Timestamp:
Aug 1, 2013 5:26:44 AM (11 years ago)
Author:
alexis@webkit.org
Message:

Reduce CSSProperty's StylePropertyMetadata memory footprint by half when used inside a ImmutableStylePropertySet.
https://bugs.webkit.org/show_bug.cgi?id=117715

Reviewed by Andreas Kling.

Today CSSProperty holds its metadata in the following way :


| m_propertyID : 14 We use 14 bits because CSSPropertyIDs start at 1001. |
| m_shorthandID : 14 id of the shorthand this property was set, 0 if not part of a shorthand|
| m_important : 1 |
| m_implicit : 1 |
| m_inherited : 1 |


The proposal to decrease the memory footprint on CSSProperty's metadata
only stand when stored inside ImmutableStylePropertySet which uses a custom
way to allocate and lay out the StylePropertyMetadata and the CSSValues in
memory because the idea behind is that the content will not change.
The MutableStylePropertySet uses a regular vector to retrieve, remove
and modify the CSSProperties. ImmutableStylePropertySet is used by default
when parsing up until someone start to access the CSSOM like
div.style which will convert the immutable to a mutable set. It is also good
to note that a CSSProperty is created for every single statement inside a block
in a stylesheet so we do have quite a bunch around. Another consideration is
that the only client to the m_shorthandID is the inspector which uses it
to group the longhands into a shorthand drop down list.

The new proposal is the following one :

  • Reduce m_propertyID to 10 bits by not starting the CSSPropertyIDs from

1001 but rather 0 (or 3 as two are hardcoded CSSPropertyInvalid and CSSPropertyVariable).

  • Use the fact that we statically know which longhand belong to which shorthand. So

we create a static mapping between longhands and shorthands.

Here is the new layout :


| m_propertyID : 10 (up to 1024 properties), we have less than 400 today |
| m_isSetFromShorthand : 1 and then use the mapping in StylePropertyShorthand |
| m_indexInShorthandsVector : 2 |
| m_important : 1 (unchanged) |
| m_implicit : 1 (unchanged) |
| m_inherited : 1 (unchanged) |


it was set from using the new code in StylePropertyShorthand.

  • m_indexInShorthandsVector : 2 bits, unfortunately there are few longhands which belong to multiple

shorthands so we need to store which was this longhand was part at parsing time. Notice
that it does not store the CSSPropertyID of the matching shorthand but rather its position
in the vector of matching shorthands. CSSProperty::m_shorthandID() method make it transparent
for call sites and return the actual CSSPropertyID of the shorthand. So far 2 bits seems
enough as there is only few longhands with ambiguity and they belong to 3 shorthands.

Profiling the benchmark with Intel Vtune to find out the performance regression
showed that copying uint16_t, so StylePropertyMetadata, is not
a fast operation in term of assembly code and has a big penalty on Windows
MSVC over unsigned for example. The latter produces a much faster code
when using unsigned over uint16_t (45% difference in the benchmark).

The patch avoid the copies of StylePropertyMetadata when applicable (by using const ref).

The second part of the fix is avoiding the conversion from an int (enum) to
an uint16_t in a tight loop such as StylePropertySet::findPropertyIndex
(which is the hotspot of the benchmark).

On my Windows 7 64 bits Core i5 machine CSSPropertySetterGetter results are :

  • avg : 2714 runs/s with the patch
  • avg : 2696 runs/s without the patch

According to Andreas Kling this patch save up ~1.8Mb on membuster.

No new tests : refactor, old ones should cover.

  • css/CSSComputedStyleDeclaration.cpp:

(WebCore::ComputedStyleExtractor::getBackgroundShorthandValue):

  • css/CSSParser.cpp:

(WebCore::CSSParser::addPropertyWithPrefixingVariant):
(WebCore::CSSParser::addProperty):

  • css/CSSProperty.cpp:

(WebCore::StylePropertyMetadata::shorthandID):
(WebCore::borderDirections):

  • css/CSSProperty.h:

(WebCore::StylePropertyMetadata::StylePropertyMetadata): Use uint16_t type for bitfields so sizeof() returns 2 bytes.
(WebCore::CSSProperty::CSSProperty):
(WebCore::CSSProperty::isSetFromShorthand):
(WebCore::CSSProperty::shorthandID):

  • css/StylePropertySet.cpp:

(WebCore::ImmutableStylePropertySet::ImmutableStylePropertySet):
(WebCore::getIndexInShorthandVectorForPrefixingVariant):
(WebCore::MutableStylePropertySet::appendPrefixingVariantProperty):
(WebCore::MutableStylePropertySet::setPrefixingVariantProperty):

  • css/StylePropertySet.h:

(WebCore::StylePropertySet::PropertyReference::shorthandID):

  • css/StylePropertyShorthand.cpp:

(WebCore::backgroundShorthand):
(WebCore::backgroundPositionShorthand):
(WebCore::backgroundRepeatShorthand):
(WebCore::borderShorthand):
(WebCore::borderAbridgedShorthand):
(WebCore::borderBottomShorthand):
(WebCore::borderColorShorthand):
(WebCore::borderImageShorthand):
(WebCore::borderLeftShorthand):
(WebCore::borderRadiusShorthand):
(WebCore::webkitBorderRadiusShorthand):
(WebCore::borderRightShorthand):
(WebCore::borderSpacingShorthand):
(WebCore::borderStyleShorthand):
(WebCore::borderTopShorthand):
(WebCore::borderWidthShorthand):
(WebCore::listStyleShorthand):
(WebCore::fontShorthand):
(WebCore::marginShorthand):
(WebCore::markerShorthand):
(WebCore::outlineShorthand):
(WebCore::overflowShorthand):
(WebCore::paddingShorthand):
(WebCore::transitionShorthand):
(WebCore::webkitAnimationShorthand):
(WebCore::webkitAnimationShorthandForParsing):
(WebCore::webkitBorderAfterShorthand):
(WebCore::webkitBorderBeforeShorthand):
(WebCore::webkitBorderEndShorthand):
(WebCore::webkitBorderStartShorthand):
(WebCore::webkitColumnsShorthand):
(WebCore::webkitColumnRuleShorthand):
(WebCore::webkitFlexFlowShorthand):
(WebCore::webkitFlexShorthand):
(WebCore::webkitMarginCollapseShorthand):
(WebCore::webkitGridColumnShorthand):
(WebCore::webkitGridRowShorthand):
(WebCore::webkitMarqueeShorthand):
(WebCore::webkitMaskShorthand):
(WebCore::webkitMaskPositionShorthand):
(WebCore::webkitMaskRepeatShorthand):
(WebCore::webkitTextEmphasisShorthand):
(WebCore::webkitTextStrokeShorthand):
(WebCore::webkitTransitionShorthand):
(WebCore::webkitTransformOriginShorthand):
(WebCore::widthShorthand):
(WebCore::heightShorthand):
(WebCore::matchingShorthandsForLonghand):
(WebCore::indexOfShorthandForLonghand):

  • css/StylePropertyShorthand.h:

(WebCore::StylePropertyShorthand::StylePropertyShorthand):
(WebCore::StylePropertyShorthand::id):

  • css/makeprop.pl:
Location:
trunk/Source/WebCore
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r153566 r153581  
     12013-08-01  Alexis Menard  <alexis@webkit.org>
     2
     3        Reduce CSSProperty's StylePropertyMetadata memory footprint by half when used inside a ImmutableStylePropertySet.
     4        https://bugs.webkit.org/show_bug.cgi?id=117715
     5
     6        Reviewed by Andreas Kling.
     7
     8        Today CSSProperty holds its metadata in the following way :
     9
     10        --------------------------------------------------------------------------------------------
     11        | m_propertyID : 14 We use 14 bits because CSSPropertyIDs start at 1001.                    |
     12        | m_shorthandID : 14 id of the shorthand this property was set, 0 if not part of a shorthand|
     13        | m_important : 1                                                                           |
     14        | m_implicit : 1                                                                            |
     15        | m_inherited : 1                                                                           |
     16        --------------------------------------------------------------------------------------------
     17
     18        The proposal to decrease the memory footprint on CSSProperty's metadata
     19        only stand when stored inside ImmutableStylePropertySet which uses a custom
     20        way to allocate and lay out the StylePropertyMetadata and the CSSValues in
     21        memory because the idea behind is that the content will not change.
     22        The MutableStylePropertySet uses a regular vector to retrieve, remove
     23        and modify the CSSProperties. ImmutableStylePropertySet is used by default
     24        when parsing up until someone start to access the CSSOM like
     25        div.style which will convert the immutable to a mutable set. It is also good
     26        to note that a CSSProperty is created for every single statement inside a block
     27        in a stylesheet so we do have quite a bunch around. Another consideration is
     28        that the only client to the m_shorthandID is the inspector which uses it
     29        to group the longhands into a shorthand drop down list.
     30
     31        The new proposal is the following one :
     32        - Reduce m_propertyID to 10 bits by not starting the CSSPropertyIDs from
     33        1001 but rather 0 (or 3 as two are hardcoded CSSPropertyInvalid and CSSPropertyVariable).
     34        - Use the fact that we statically know which longhand belong to which shorthand. So
     35        we create a static mapping between longhands and shorthands.
     36
     37        Here is the new layout :
     38        ------------------------------------------------------------------------------
     39        | m_propertyID : 10 (up to 1024 properties), we have less than 400 today      |
     40        | m_isSetFromShorthand : 1 and then use the mapping in StylePropertyShorthand |
     41        | m_indexInShorthandsVector : 2                                               |
     42        | m_important : 1 (unchanged)                                                 |
     43        | m_implicit : 1  (unchanged)                                                 |
     44        | m_inherited : 1 (unchanged)                                                 |
     45        ------------------------------------------------------------------------------
     46
     47        it was set from using the new code in StylePropertyShorthand.
     48        - m_indexInShorthandsVector : 2 bits, unfortunately there are few longhands which belong to multiple
     49        shorthands so we need to store which was this longhand was part at parsing time. Notice
     50        that it does not store the CSSPropertyID of the matching shorthand but rather its position
     51        in the vector of matching shorthands. CSSProperty::m_shorthandID() method make it transparent
     52        for call sites and return the actual CSSPropertyID of the shorthand. So far 2 bits seems
     53        enough as there is only few longhands with ambiguity and they belong to 3 shorthands.
     54
     55        Profiling the benchmark with Intel Vtune to find out the performance regression
     56        showed that copying uint16_t, so StylePropertyMetadata, is not
     57        a fast operation in term of assembly code and has a big penalty on Windows
     58        MSVC over unsigned for example. The latter produces a much faster code
     59        when using unsigned over uint16_t (45% difference in the benchmark).
     60
     61        The patch avoid the copies of StylePropertyMetadata when applicable (by using const ref).
     62
     63        The second part of the fix is avoiding the conversion from an int (enum) to
     64        an uint16_t in a tight loop such as StylePropertySet::findPropertyIndex
     65        (which is the hotspot of the benchmark).
     66
     67        On my Windows 7 64 bits Core i5 machine CSSPropertySetterGetter results are :
     68        - avg : 2714 runs/s with the patch
     69        - avg : 2696 runs/s without the patch
     70
     71        According to Andreas Kling this patch save up ~1.8Mb on membuster.
     72
     73        No new tests : refactor, old ones should cover.
     74
     75        * css/CSSComputedStyleDeclaration.cpp:
     76        (WebCore::ComputedStyleExtractor::getBackgroundShorthandValue):
     77        * css/CSSParser.cpp:
     78        (WebCore::CSSParser::addPropertyWithPrefixingVariant):
     79        (WebCore::CSSParser::addProperty):
     80        * css/CSSProperty.cpp:
     81        (WebCore::StylePropertyMetadata::shorthandID):
     82        (WebCore::borderDirections):
     83        * css/CSSProperty.h:
     84        (WebCore::StylePropertyMetadata::StylePropertyMetadata): Use uint16_t type for bitfields so sizeof() returns 2 bytes.
     85        (WebCore::CSSProperty::CSSProperty):
     86        (WebCore::CSSProperty::isSetFromShorthand):
     87        (WebCore::CSSProperty::shorthandID):
     88        * css/StylePropertySet.cpp:
     89        (WebCore::ImmutableStylePropertySet::ImmutableStylePropertySet):
     90        (WebCore::getIndexInShorthandVectorForPrefixingVariant):
     91        (WebCore::MutableStylePropertySet::appendPrefixingVariantProperty):
     92        (WebCore::MutableStylePropertySet::setPrefixingVariantProperty):
     93        * css/StylePropertySet.h:
     94        (WebCore::StylePropertySet::PropertyReference::shorthandID):
     95        * css/StylePropertyShorthand.cpp:
     96        (WebCore::backgroundShorthand):
     97        (WebCore::backgroundPositionShorthand):
     98        (WebCore::backgroundRepeatShorthand):
     99        (WebCore::borderShorthand):
     100        (WebCore::borderAbridgedShorthand):
     101        (WebCore::borderBottomShorthand):
     102        (WebCore::borderColorShorthand):
     103        (WebCore::borderImageShorthand):
     104        (WebCore::borderLeftShorthand):
     105        (WebCore::borderRadiusShorthand):
     106        (WebCore::webkitBorderRadiusShorthand):
     107        (WebCore::borderRightShorthand):
     108        (WebCore::borderSpacingShorthand):
     109        (WebCore::borderStyleShorthand):
     110        (WebCore::borderTopShorthand):
     111        (WebCore::borderWidthShorthand):
     112        (WebCore::listStyleShorthand):
     113        (WebCore::fontShorthand):
     114        (WebCore::marginShorthand):
     115        (WebCore::markerShorthand):
     116        (WebCore::outlineShorthand):
     117        (WebCore::overflowShorthand):
     118        (WebCore::paddingShorthand):
     119        (WebCore::transitionShorthand):
     120        (WebCore::webkitAnimationShorthand):
     121        (WebCore::webkitAnimationShorthandForParsing):
     122        (WebCore::webkitBorderAfterShorthand):
     123        (WebCore::webkitBorderBeforeShorthand):
     124        (WebCore::webkitBorderEndShorthand):
     125        (WebCore::webkitBorderStartShorthand):
     126        (WebCore::webkitColumnsShorthand):
     127        (WebCore::webkitColumnRuleShorthand):
     128        (WebCore::webkitFlexFlowShorthand):
     129        (WebCore::webkitFlexShorthand):
     130        (WebCore::webkitMarginCollapseShorthand):
     131        (WebCore::webkitGridColumnShorthand):
     132        (WebCore::webkitGridRowShorthand):
     133        (WebCore::webkitMarqueeShorthand):
     134        (WebCore::webkitMaskShorthand):
     135        (WebCore::webkitMaskPositionShorthand):
     136        (WebCore::webkitMaskRepeatShorthand):
     137        (WebCore::webkitTextEmphasisShorthand):
     138        (WebCore::webkitTextStrokeShorthand):
     139        (WebCore::webkitTransitionShorthand):
     140        (WebCore::webkitTransformOriginShorthand):
     141        (WebCore::widthShorthand):
     142        (WebCore::heightShorthand):
     143        (WebCore::matchingShorthandsForLonghand):
     144        (WebCore::indexOfShorthandForLonghand):
     145        * css/StylePropertyShorthand.h:
     146        (WebCore::StylePropertyShorthand::StylePropertyShorthand):
     147        (WebCore::StylePropertyShorthand::id):
     148        * css/makeprop.pl:
     149
    11502013-07-31  Andreas Kling  <akling@apple.com>
    2151
  • trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp

    r153347 r153581  
    31603160
    31613161    RefPtr<CSSValueList> list = CSSValueList::createSlashSeparated();
    3162     list->append(getCSSPropertyValuesForShorthandProperties(StylePropertyShorthand(propertiesBeforeSlashSeperator, WTF_ARRAY_LENGTH(propertiesBeforeSlashSeperator))));
    3163     list->append(getCSSPropertyValuesForShorthandProperties(StylePropertyShorthand(propertiesAfterSlashSeperator, WTF_ARRAY_LENGTH(propertiesAfterSlashSeperator))));
     3162    list->append(getCSSPropertyValuesForShorthandProperties(StylePropertyShorthand(CSSPropertyBackground, propertiesBeforeSlashSeperator, WTF_ARRAY_LENGTH(propertiesBeforeSlashSeperator))));
     3163    list->append(getCSSPropertyValuesForShorthandProperties(StylePropertyShorthand(CSSPropertyBackground, propertiesAfterSlashSeperator, WTF_ARRAY_LENGTH(propertiesAfterSlashSeperator))));
    31643164    return list.release();
    31653165}
  • trunk/Source/WebCore/css/CSSParser.cpp

    r153399 r153581  
    15611561    if (prefixingVariant == propId)
    15621562        return;
    1563     addProperty(prefixingVariant, val.release(), important, implicit);
     1563
     1564    if (m_currentShorthand) {
     1565        // We can't use ShorthandScope here as we can already be inside one (e.g we are parsing CSSTransition).
     1566        m_currentShorthand = prefixingVariantForPropertyId(m_currentShorthand);
     1567        addProperty(prefixingVariant, val.release(), important, implicit);
     1568        m_currentShorthand = prefixingVariantForPropertyId(m_currentShorthand);
     1569    } else
     1570        addProperty(prefixingVariant, val.release(), important, implicit);
    15641571}
    15651572
    15661573void CSSParser::addProperty(CSSPropertyID propId, PassRefPtr<CSSValue> value, bool important, bool implicit)
    15671574{
    1568     m_parsedProperties.append(CSSProperty(propId, value, important, m_currentShorthand, m_implicitShorthand || implicit));
     1575#if ENABLE(CSS_VARIABLES)
     1576    CSSPrimitiveValue* primitiveValue = value->isPrimitiveValue() ? static_cast<CSSPrimitiveValue*>(value.get()) : 0;
     1577#endif
     1578    // This property doesn't belong to a shorthand or is a CSS variable (which will be resolved later).
     1579    if (!m_currentShorthand
     1580#if ENABLE(CSS_VARIABLES)
     1581        || (primitiveValue && primitiveValue->isVariableName())
     1582#endif
     1583        ) {
     1584        m_parsedProperties.append(CSSProperty(propId, value, important, false, CSSPropertyInvalid, m_implicitShorthand || implicit));
     1585        return;
     1586    }
     1587
     1588    const Vector<const StylePropertyShorthand*> shorthands = matchingShorthandsForLonghand(propId);
     1589    // The longhand does not belong to multiple shorthands.
     1590    if (shorthands.size() == 1)
     1591        m_parsedProperties.append(CSSProperty(propId, value, important, true, CSSPropertyInvalid, m_implicitShorthand || implicit));
     1592    else
     1593        m_parsedProperties.append(CSSProperty(propId, value, important, true, indexOfShorthandForLonghand(m_currentShorthand, shorthands), m_implicitShorthand || implicit));
    15691594}
    15701595
  • trunk/Source/WebCore/css/CSSProperty.cpp

    r152479 r153581  
    4141COMPILE_ASSERT(sizeof(CSSProperty) == sizeof(SameSizeAsCSSProperty), CSSProperty_should_stay_small);
    4242
     43CSSPropertyID StylePropertyMetadata::shorthandID() const
     44{
     45    if (!m_isSetFromShorthand)
     46        return CSSPropertyInvalid;
     47
     48    const Vector<const StylePropertyShorthand*> shorthands = matchingShorthandsForLonghand(static_cast<CSSPropertyID>(m_propertyID));
     49    ASSERT(shorthands.size() && m_indexInShorthandsVector >= 0 && m_indexInShorthandsVector < shorthands.size());
     50    return shorthands.at(m_indexInShorthandsVector)->id();
     51}
     52
    4353void CSSProperty::wrapValueInCommaSeparatedList()
    4454{
     
    168178{
    169179    static const CSSPropertyID properties[4] = { CSSPropertyBorderTop, CSSPropertyBorderRight, CSSPropertyBorderBottom, CSSPropertyBorderLeft };
    170     DEFINE_STATIC_LOCAL(StylePropertyShorthand, borderDirections, (properties, WTF_ARRAY_LENGTH(properties)));
     180    DEFINE_STATIC_LOCAL(StylePropertyShorthand, borderDirections, (CSSPropertyBorder, properties, WTF_ARRAY_LENGTH(properties)));
    171181    return borderDirections;
    172182}
  • trunk/Source/WebCore/css/CSSProperty.h

    r148921 r153581  
    22 * (C) 1999-2003 Lars Knoll (knoll@kde.org)
    33 * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc.
     4 * Copyright (C) 2013 Intel Corporation. All rights reserved.
    45 *
    56 * This library is free software; you can redistribute it and/or
     
    3233namespace WebCore {
    3334
    34 union StylePropertyMetadata {
    35     StylePropertyMetadata(CSSPropertyID propertyID, CSSPropertyID shorthandID, bool important, bool implicit, bool inherited)
     35struct StylePropertyMetadata {
     36    StylePropertyMetadata(CSSPropertyID propertyID, bool isSetFromShorthand, int indexInShorthandsVector, bool important, bool implicit, bool inherited)
    3637        : m_propertyID(propertyID)
    37         , m_shorthandID(shorthandID)
     38        , m_isSetFromShorthand(isSetFromShorthand)
     39        , m_indexInShorthandsVector(indexInShorthandsVector)
    3840        , m_important(important)
    3941        , m_implicit(implicit)
     
    4244    }
    4345
    44     unsigned m_bits;
    45     struct {
    46         unsigned m_propertyID : 14;
    47         unsigned m_shorthandID : 14; // If this property was set as part of a shorthand, gives the shorthand.
    48         unsigned m_important : 1;
    49         unsigned m_implicit : 1; // Whether or not the property was set implicitly as the result of a shorthand.
    50         unsigned m_inherited : 1;
    51     };
     46    CSSPropertyID shorthandID() const;
     47
     48    uint16_t m_propertyID : 10;
     49    uint16_t m_isSetFromShorthand : 1;
     50    uint16_t m_indexInShorthandsVector : 2; // If this property was set as part of an ambiguous shorthand, gives the index in the shorthands vector.
     51    uint16_t m_important : 1;
     52    uint16_t m_implicit : 1; // Whether or not the property was set implicitly as the result of a shorthand.
     53    uint16_t m_inherited : 1;
    5254};
    5355
    5456class CSSProperty {
    5557public:
    56     CSSProperty(CSSPropertyID propertyID, PassRefPtr<CSSValue> value, bool important = false, CSSPropertyID shorthandID = CSSPropertyInvalid, bool implicit = false)
    57         : m_metadata(propertyID, shorthandID, important, implicit, isInheritedProperty(propertyID))
     58    CSSProperty(CSSPropertyID propertyID, PassRefPtr<CSSValue> value, bool important = false, bool isSetFromShorthand = false, int indexInShorthandsVector = 0, bool implicit = false)
     59        : m_metadata(propertyID, isSetFromShorthand, indexInShorthandsVector, important, implicit, isInheritedProperty(propertyID))
    5860        , m_value(value)
    5961    {
     
    7476
    7577    CSSPropertyID id() const { return static_cast<CSSPropertyID>(m_metadata.m_propertyID); }
    76     CSSPropertyID shorthandID() const { return static_cast<CSSPropertyID>(m_metadata.m_shorthandID); }
     78    bool isSetFromShorthand() const { return m_metadata.m_isSetFromShorthand; };
     79    CSSPropertyID shorthandID() const { return m_metadata.shorthandID(); };
    7780    bool isImportant() const { return m_metadata.m_important; }
    7881
     
    8487    static bool isInheritedProperty(CSSPropertyID);
    8588
    86     StylePropertyMetadata metadata() const { return m_metadata; }
     89    const StylePropertyMetadata& metadata() const { return m_metadata; }
    8790
    8891private:
  • trunk/Source/WebCore/css/StylePropertySet.cpp

    r152935 r153581  
    33 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012, 2013 Apple Inc. All rights reserved.
    44 * Copyright (C) 2011 Research In Motion Limited. All rights reserved.
     5 * Copyright (C) 2013 Intel Corporation. All rights reserved.
    56 *
    67 * This library is free software; you can redistribute it and/or
     
    706707}
    707708
     709static unsigned getIndexInShorthandVectorForPrefixingVariant(const CSSProperty& property, CSSPropertyID prefixingVariant)
     710{
     711    if (!property.isSetFromShorthand())
     712        return 0;
     713
     714    CSSPropertyID prefixedShorthand = prefixingVariantForPropertyId(property.shorthandID());
     715    return indexOfShorthandForLonghand(prefixedShorthand, matchingShorthandsForLonghand(prefixingVariant));
     716}
     717
    708718void MutableStylePropertySet::appendPrefixingVariantProperty(const CSSProperty& property)
    709719{
     
    712722    if (prefixingVariant == property.id())
    713723        return;
    714     m_propertyVector.append(CSSProperty(prefixingVariant, property.value(), property.isImportant(), property.shorthandID(), property.metadata().m_implicit));
     724
     725    m_propertyVector.append(CSSProperty(prefixingVariant, property.value(), property.isImportant(), property.isSetFromShorthand(), getIndexInShorthandVectorForPrefixingVariant(property, prefixingVariant), property.metadata().m_implicit));
    715726}
    716727
     
    719730    CSSPropertyID prefixingVariant = prefixingVariantForPropertyId(property.id());
    720731    CSSProperty* toReplace = findCSSPropertyWithID(prefixingVariant);
    721     if (toReplace)
    722         *toReplace = CSSProperty(prefixingVariant, property.value(), property.isImportant(), property.shorthandID(), property.metadata().m_implicit);
     732    if (toReplace && prefixingVariant != property.id())
     733        *toReplace = CSSProperty(prefixingVariant, property.value(), property.isImportant(), property.isSetFromShorthand(), getIndexInShorthandVectorForPrefixingVariant(property, prefixingVariant), property.metadata().m_implicit);
    723734}
    724735
     
    11281139int StylePropertySet::findPropertyIndex(CSSPropertyID propertyID) const
    11291140{
     1141    // Convert here propertyID into an uint16_t to compare it with the metadata's m_propertyID to avoid
     1142    // the compiler converting it to an int multiple times in the loop.
     1143    uint16_t id = static_cast<uint16_t>(propertyID);
    11301144    for (int n = propertyCount() - 1 ; n >= 0; --n) {
    1131         if (propertyID == propertyAt(n).id())
     1145        if (id == propertyAt(n).propertyMetadata().m_propertyID)
    11321146            return n;
    11331147    }
  • trunk/Source/WebCore/css/StylePropertySet.h

    r152935 r153581  
    22 * (C) 1999-2003 Lars Knoll (knoll@kde.org)
    33 * Copyright (C) 2004, 2005, 2006, 2008, 2012, 2013 Apple Inc. All rights reserved.
     4 * Copyright (C) 2013 Intel Corporation. All rights reserved.
    45 *
    56 * This library is free software; you can redistribute it and/or
     
    6061
    6162        CSSPropertyID id() const { return static_cast<CSSPropertyID>(propertyMetadata().m_propertyID); }
    62         CSSPropertyID shorthandID() const { return static_cast<CSSPropertyID>(propertyMetadata().m_shorthandID); }
     63        CSSPropertyID shorthandID() const { return propertyMetadata().shorthandID(); }
    6364
    6465        bool isImportant() const { return propertyMetadata().m_important; }
     
    7576        // FIXME: Remove this.
    7677        CSSProperty toCSSProperty() const { return CSSProperty(propertyMetadata(), const_cast<CSSValue*>(propertyValue())); }
     78        const StylePropertyMetadata& propertyMetadata() const;
    7779
    7880    private:
    79         StylePropertyMetadata propertyMetadata() const;
    8081        const CSSValue* propertyValue() const;
    8182
     
    171172inline const CSSValue** ImmutableStylePropertySet::valueArray() const
    172173{
    173     return reinterpret_cast<const CSSValue**>(const_cast<const void**>((&static_cast<const ImmutableStylePropertySet*>(this)->m_storage)));
     174    return reinterpret_cast<const CSSValue**>(const_cast<const void**>((&(this->m_storage))));
    174175}
    175176
    176177inline const StylePropertyMetadata* ImmutableStylePropertySet::metadataArray() const
    177178{
    178     return reinterpret_cast<const StylePropertyMetadata*>(&reinterpret_cast<const char*>((&static_cast<const ImmutableStylePropertySet*>(this)->m_storage))[m_arraySize * sizeof(CSSValue*)]);
     179    return reinterpret_cast<const StylePropertyMetadata*>(&reinterpret_cast<const char*>(&(this->m_storage))[m_arraySize * sizeof(CSSValue*)]);
    179180}
    180181
     
    235236};
    236237
    237 inline StylePropertyMetadata StylePropertySet::PropertyReference::propertyMetadata() const
     238inline const StylePropertyMetadata& StylePropertySet::PropertyReference::propertyMetadata() const
    238239{
    239240    if (m_propertySet.isMutable())
  • trunk/Source/WebCore/css/StylePropertyShorthand.cpp

    r149623 r153581  
    22 * (C) 1999-2003 Lars Knoll (knoll@kde.org)
    33 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
     4 * Copyright (C) 2013 Intel Corporation. All rights reserved.
    45 *
    56 * This library is free software; you can redistribute it and/or
     
    2223#include "StylePropertyShorthand.h"
    2324
     25#include <wtf/HashMap.h>
    2426#include <wtf/StdLibExtras.h>
    2527
     
    4042        CSSPropertyBackgroundColor
    4143    };
    42     DEFINE_STATIC_LOCAL(StylePropertyShorthand, backgroundShorthand, (backgroundProperties, WTF_ARRAY_LENGTH(backgroundProperties)));
     44    DEFINE_STATIC_LOCAL(StylePropertyShorthand, backgroundShorthand, (CSSPropertyBackground, backgroundProperties, WTF_ARRAY_LENGTH(backgroundProperties)));
    4345    return backgroundShorthand;
    4446}
     
    4749{
    4850    static const CSSPropertyID backgroundPositionProperties[] = { CSSPropertyBackgroundPositionX, CSSPropertyBackgroundPositionY };
    49     DEFINE_STATIC_LOCAL(StylePropertyShorthand, backgroundPositionLonghands, (backgroundPositionProperties, WTF_ARRAY_LENGTH(backgroundPositionProperties)));
     51    DEFINE_STATIC_LOCAL(StylePropertyShorthand, backgroundPositionLonghands, (CSSPropertyBackgroundPosition, backgroundPositionProperties, WTF_ARRAY_LENGTH(backgroundPositionProperties)));
    5052    return backgroundPositionLonghands;
    5153}
     
    5456{
    5557    static const CSSPropertyID backgroundRepeatProperties[] = { CSSPropertyBackgroundRepeatX, CSSPropertyBackgroundRepeatY };
    56     DEFINE_STATIC_LOCAL(StylePropertyShorthand, backgroundRepeatLonghands, (backgroundRepeatProperties, WTF_ARRAY_LENGTH(backgroundRepeatProperties)));
     58    DEFINE_STATIC_LOCAL(StylePropertyShorthand, backgroundRepeatLonghands, (CSSPropertyBackgroundRepeat, backgroundRepeatProperties, WTF_ARRAY_LENGTH(backgroundRepeatProperties)));
    5759    return backgroundRepeatLonghands;
    5860}
     
    6769        { CSSPropertyBorderLeftColor, CSSPropertyBorderLeftStyle, CSSPropertyBorderLeftWidth }
    6870    };
    69     DEFINE_STATIC_LOCAL(StylePropertyShorthand, borderLonghands, (borderProperties[0], sizeof(borderProperties) / sizeof(borderProperties[0][0])));
     71    DEFINE_STATIC_LOCAL(StylePropertyShorthand, borderLonghands, (CSSPropertyBorder, borderProperties[0], sizeof(borderProperties) / sizeof(borderProperties[0][0])));
    7072    return borderLonghands;
    7173}
     
    8082    };
    8183    DEFINE_STATIC_LOCAL(StylePropertyShorthand, borderAbridgedLonghands,
    82         (borderAbridgedProperties, propertiesForInitialization, WTF_ARRAY_LENGTH(borderAbridgedProperties)));
     84        (CSSPropertyBorder, borderAbridgedProperties, propertiesForInitialization, WTF_ARRAY_LENGTH(borderAbridgedProperties)));
    8385    return borderAbridgedLonghands;
    8486}
     
    8789{
    8890    static const CSSPropertyID borderBottomProperties[] = { CSSPropertyBorderBottomWidth, CSSPropertyBorderBottomStyle, CSSPropertyBorderBottomColor };
    89     DEFINE_STATIC_LOCAL(StylePropertyShorthand, borderBottomLonghands, (borderBottomProperties, WTF_ARRAY_LENGTH(borderBottomProperties)));
     91    DEFINE_STATIC_LOCAL(StylePropertyShorthand, borderBottomLonghands, (CSSPropertyBorderBottom, borderBottomProperties, WTF_ARRAY_LENGTH(borderBottomProperties)));
    9092    return borderBottomLonghands;
    9193}
     
    99101        CSSPropertyBorderLeftColor
    100102    };
    101     DEFINE_STATIC_LOCAL(StylePropertyShorthand, borderColorLonghands, (borderColorProperties, WTF_ARRAY_LENGTH(borderColorProperties)));
     103    DEFINE_STATIC_LOCAL(StylePropertyShorthand, borderColorLonghands, (CSSPropertyBorderColor, borderColorProperties, WTF_ARRAY_LENGTH(borderColorProperties)));
    102104    return borderColorLonghands;
    103105}
     
    112114        CSSPropertyBorderImageRepeat
    113115    };
    114     DEFINE_STATIC_LOCAL(StylePropertyShorthand, borderImageLonghands, (borderImageProperties, WTF_ARRAY_LENGTH(borderImageProperties)));
     116    DEFINE_STATIC_LOCAL(StylePropertyShorthand, borderImageLonghands, (CSSPropertyBorderImage, borderImageProperties, WTF_ARRAY_LENGTH(borderImageProperties)));
    115117    return borderImageLonghands;
    116118}
     
    119121{
    120122    static const CSSPropertyID borderLeftProperties[] = { CSSPropertyBorderLeftWidth, CSSPropertyBorderLeftStyle, CSSPropertyBorderLeftColor };
    121     DEFINE_STATIC_LOCAL(StylePropertyShorthand, borderLeftLonghands, (borderLeftProperties, WTF_ARRAY_LENGTH(borderLeftProperties)));
     123    DEFINE_STATIC_LOCAL(StylePropertyShorthand, borderLeftLonghands, (CSSPropertyBorderLeft, borderLeftProperties, WTF_ARRAY_LENGTH(borderLeftProperties)));
    122124    return borderLeftLonghands;
    123125}
     
    131133        CSSPropertyBorderBottomLeftRadius
    132134    };
    133     DEFINE_STATIC_LOCAL(StylePropertyShorthand, borderRadiusLonghands, (borderRadiusProperties, WTF_ARRAY_LENGTH(borderRadiusProperties)));
     135    DEFINE_STATIC_LOCAL(StylePropertyShorthand, borderRadiusLonghands, (CSSPropertyBorderRadius, borderRadiusProperties, WTF_ARRAY_LENGTH(borderRadiusProperties)));
    134136    return borderRadiusLonghands;
    135137}
    136138
     139const StylePropertyShorthand& webkitBorderRadiusShorthand()
     140{
     141    static const CSSPropertyID borderRadiusProperties[] = {
     142        CSSPropertyBorderTopLeftRadius,
     143        CSSPropertyBorderTopRightRadius,
     144        CSSPropertyBorderBottomRightRadius,
     145        CSSPropertyBorderBottomLeftRadius
     146    };
     147    DEFINE_STATIC_LOCAL(StylePropertyShorthand, borderRadiusLonghands, (CSSPropertyWebkitBorderRadius, borderRadiusProperties, WTF_ARRAY_LENGTH(borderRadiusProperties)));
     148    return borderRadiusLonghands;
     149}
     150
    137151const StylePropertyShorthand& borderRightShorthand()
    138152{
    139153    static const CSSPropertyID borderRightProperties[] = { CSSPropertyBorderRightWidth, CSSPropertyBorderRightStyle, CSSPropertyBorderRightColor };
    140     DEFINE_STATIC_LOCAL(StylePropertyShorthand, borderRightLonghands, (borderRightProperties, WTF_ARRAY_LENGTH(borderRightProperties)));
     154    DEFINE_STATIC_LOCAL(StylePropertyShorthand, borderRightLonghands, (CSSPropertyBorderRight, borderRightProperties, WTF_ARRAY_LENGTH(borderRightProperties)));
    141155    return borderRightLonghands;
    142156}
     
    145159{
    146160    static const CSSPropertyID borderSpacingProperties[] = { CSSPropertyWebkitBorderHorizontalSpacing, CSSPropertyWebkitBorderVerticalSpacing };
    147     DEFINE_STATIC_LOCAL(StylePropertyShorthand, borderSpacingLonghands, (borderSpacingProperties, WTF_ARRAY_LENGTH(borderSpacingProperties)));
     161    DEFINE_STATIC_LOCAL(StylePropertyShorthand, borderSpacingLonghands, (CSSPropertyBorderSpacing, borderSpacingProperties, WTF_ARRAY_LENGTH(borderSpacingProperties)));
    148162    return borderSpacingLonghands;
    149163}
     
    157171        CSSPropertyBorderLeftStyle
    158172    };
    159     DEFINE_STATIC_LOCAL(StylePropertyShorthand, borderStyleLonghands, (borderStyleProperties, WTF_ARRAY_LENGTH(borderStyleProperties)));
     173    DEFINE_STATIC_LOCAL(StylePropertyShorthand, borderStyleLonghands, (CSSPropertyBorderStyle, borderStyleProperties, WTF_ARRAY_LENGTH(borderStyleProperties)));
    160174    return borderStyleLonghands;
    161175}
     
    164178{
    165179    static const CSSPropertyID borderTopProperties[] = { CSSPropertyBorderTopWidth, CSSPropertyBorderTopStyle, CSSPropertyBorderTopColor };
    166     DEFINE_STATIC_LOCAL(StylePropertyShorthand, borderTopLonghands, (borderTopProperties, WTF_ARRAY_LENGTH(borderTopProperties)));
     180    DEFINE_STATIC_LOCAL(StylePropertyShorthand, borderTopLonghands, (CSSPropertyBorderTop, borderTopProperties, WTF_ARRAY_LENGTH(borderTopProperties)));
    167181    return borderTopLonghands;
    168182}
     
    176190        CSSPropertyBorderLeftWidth
    177191    };
    178     DEFINE_STATIC_LOCAL(StylePropertyShorthand, borderWidthLonghands, (borderWidthProperties, WTF_ARRAY_LENGTH(borderWidthProperties)));
     192    DEFINE_STATIC_LOCAL(StylePropertyShorthand, borderWidthLonghands, (CSSPropertyBorderWidth, borderWidthProperties, WTF_ARRAY_LENGTH(borderWidthProperties)));
    179193    return borderWidthLonghands;
    180194}
     
    187201        CSSPropertyListStyleImage
    188202    };
    189     DEFINE_STATIC_LOCAL(StylePropertyShorthand, listStyleLonghands, (listStyleProperties, WTF_ARRAY_LENGTH(listStyleProperties)));
     203    DEFINE_STATIC_LOCAL(StylePropertyShorthand, listStyleLonghands, (CSSPropertyListStyle, listStyleProperties, WTF_ARRAY_LENGTH(listStyleProperties)));
    190204    return listStyleLonghands;
    191205}
     
    201215        CSSPropertyLineHeight
    202216    };
    203     DEFINE_STATIC_LOCAL(StylePropertyShorthand, fontLonghands, (fontProperties, WTF_ARRAY_LENGTH(fontProperties)));
     217    DEFINE_STATIC_LOCAL(StylePropertyShorthand, fontLonghands, (CSSPropertyFont, fontProperties, WTF_ARRAY_LENGTH(fontProperties)));
    204218    return fontLonghands;
    205219}
     
    213227        CSSPropertyMarginLeft
    214228    };
    215     DEFINE_STATIC_LOCAL(StylePropertyShorthand, marginLonghands, (marginProperties, WTF_ARRAY_LENGTH(marginProperties)));
     229    DEFINE_STATIC_LOCAL(StylePropertyShorthand, marginLonghands, (CSSPropertyMargin, marginProperties, WTF_ARRAY_LENGTH(marginProperties)));
    216230    return marginLonghands;
     231}
     232
     233const StylePropertyShorthand& markerShorthand()
     234{
     235    static const CSSPropertyID markerProperties[] = {
     236        CSSPropertyMarkerStart,
     237        CSSPropertyMarkerMid,
     238        CSSPropertyMarkerEnd
     239    };
     240    DEFINE_STATIC_LOCAL(StylePropertyShorthand, markerLonghands, (CSSPropertyMarker, markerProperties, WTF_ARRAY_LENGTH(markerProperties)));
     241    return markerLonghands;
    217242}
    218243
     
    224249        CSSPropertyOutlineWidth
    225250    };
    226     DEFINE_STATIC_LOCAL(StylePropertyShorthand, outlineLonghands, (outlineProperties, WTF_ARRAY_LENGTH(outlineProperties)));
     251    DEFINE_STATIC_LOCAL(StylePropertyShorthand, outlineLonghands, (CSSPropertyOutline, outlineProperties, WTF_ARRAY_LENGTH(outlineProperties)));
    227252    return outlineLonghands;
    228253}
     
    231256{
    232257    static const CSSPropertyID overflowProperties[] = { CSSPropertyOverflowX, CSSPropertyOverflowY };
    233     DEFINE_STATIC_LOCAL(StylePropertyShorthand, overflowLonghands, (overflowProperties, WTF_ARRAY_LENGTH(overflowProperties)));
     258    DEFINE_STATIC_LOCAL(StylePropertyShorthand, overflowLonghands, (CSSPropertyOverflow, overflowProperties, WTF_ARRAY_LENGTH(overflowProperties)));
    234259    return overflowLonghands;
    235260}
     
    243268        CSSPropertyPaddingLeft
    244269    };
    245     DEFINE_STATIC_LOCAL(StylePropertyShorthand, paddingLonghands, (paddingProperties, WTF_ARRAY_LENGTH(paddingProperties)));
     270    DEFINE_STATIC_LOCAL(StylePropertyShorthand, paddingLonghands, (CSSPropertyPadding, paddingProperties, WTF_ARRAY_LENGTH(paddingProperties)));
    246271    return paddingLonghands;
    247272}
     
    255280        CSSPropertyTransitionDelay
    256281    };
    257     DEFINE_STATIC_LOCAL(StylePropertyShorthand, transitionLonghands, (transitionProperties, WTF_ARRAY_LENGTH(transitionProperties)));
     282    DEFINE_STATIC_LOCAL(StylePropertyShorthand, transitionLonghands, (CSSPropertyTransition, transitionProperties, WTF_ARRAY_LENGTH(transitionProperties)));
    258283    return transitionLonghands;
    259284}
     
    270295        CSSPropertyWebkitAnimationFillMode
    271296    };
    272     DEFINE_STATIC_LOCAL(StylePropertyShorthand, webkitAnimationLonghands, (animationProperties, WTF_ARRAY_LENGTH(animationProperties)));
     297    DEFINE_STATIC_LOCAL(StylePropertyShorthand, webkitAnimationLonghands, (CSSPropertyWebkitAnimation, animationProperties, WTF_ARRAY_LENGTH(animationProperties)));
    273298    return webkitAnimationLonghands;
    274299}
     
    295320    };
    296321
    297     DEFINE_STATIC_LOCAL(StylePropertyShorthand, webkitAnimationLonghandsForParsing, (animationPropertiesForParsing, WTF_ARRAY_LENGTH(animationPropertiesForParsing)));
     322    DEFINE_STATIC_LOCAL(StylePropertyShorthand, webkitAnimationLonghandsForParsing, (CSSPropertyWebkitAnimation, animationPropertiesForParsing, WTF_ARRAY_LENGTH(animationPropertiesForParsing)));
    298323    return webkitAnimationLonghandsForParsing;
    299324}
     
    302327{
    303328    static const CSSPropertyID borderAfterProperties[] = { CSSPropertyWebkitBorderAfterWidth, CSSPropertyWebkitBorderAfterStyle, CSSPropertyWebkitBorderAfterColor  };
    304     DEFINE_STATIC_LOCAL(StylePropertyShorthand, webkitBorderAfterLonghands, (borderAfterProperties, WTF_ARRAY_LENGTH(borderAfterProperties)));
     329    DEFINE_STATIC_LOCAL(StylePropertyShorthand, webkitBorderAfterLonghands, (CSSPropertyWebkitBorderAfter, borderAfterProperties, WTF_ARRAY_LENGTH(borderAfterProperties)));
    305330    return webkitBorderAfterLonghands;
    306331}
     
    309334{
    310335    static const CSSPropertyID borderBeforeProperties[] = { CSSPropertyWebkitBorderBeforeWidth, CSSPropertyWebkitBorderBeforeStyle, CSSPropertyWebkitBorderBeforeColor  };
    311     DEFINE_STATIC_LOCAL(StylePropertyShorthand, webkitBorderBeforeLonghands, (borderBeforeProperties, WTF_ARRAY_LENGTH(borderBeforeProperties)));
     336    DEFINE_STATIC_LOCAL(StylePropertyShorthand, webkitBorderBeforeLonghands, (CSSPropertyWebkitBorderBefore, borderBeforeProperties, WTF_ARRAY_LENGTH(borderBeforeProperties)));
    312337    return webkitBorderBeforeLonghands;
    313338}
     
    316341{
    317342    static const CSSPropertyID borderEndProperties[] = { CSSPropertyWebkitBorderEndWidth, CSSPropertyWebkitBorderEndStyle, CSSPropertyWebkitBorderEndColor };
    318     DEFINE_STATIC_LOCAL(StylePropertyShorthand, webkitBorderEndLonghands, (borderEndProperties, WTF_ARRAY_LENGTH(borderEndProperties)));
     343    DEFINE_STATIC_LOCAL(StylePropertyShorthand, webkitBorderEndLonghands, (CSSPropertyWebkitBorderEnd, borderEndProperties, WTF_ARRAY_LENGTH(borderEndProperties)));
    319344    return webkitBorderEndLonghands;
    320345}
     
    323348{
    324349    static const CSSPropertyID borderStartProperties[] = { CSSPropertyWebkitBorderStartWidth, CSSPropertyWebkitBorderStartStyle, CSSPropertyWebkitBorderStartColor };
    325     DEFINE_STATIC_LOCAL(StylePropertyShorthand, webkitBorderStartLonghands, (borderStartProperties, WTF_ARRAY_LENGTH(borderStartProperties)));
     350    DEFINE_STATIC_LOCAL(StylePropertyShorthand, webkitBorderStartLonghands, (CSSPropertyWebkitBorderStart, borderStartProperties, WTF_ARRAY_LENGTH(borderStartProperties)));
    326351    return webkitBorderStartLonghands;
    327352}
     
    330355{
    331356    static const CSSPropertyID columnsProperties[] = { CSSPropertyWebkitColumnWidth, CSSPropertyWebkitColumnCount };
    332     DEFINE_STATIC_LOCAL(StylePropertyShorthand, webkitColumnsLonghands, (columnsProperties, WTF_ARRAY_LENGTH(columnsProperties)));
     357    DEFINE_STATIC_LOCAL(StylePropertyShorthand, webkitColumnsLonghands, (CSSPropertyWebkitColumns, columnsProperties, WTF_ARRAY_LENGTH(columnsProperties)));
    333358    return webkitColumnsLonghands;
    334359}
     
    341366        CSSPropertyWebkitColumnRuleColor,
    342367    };
    343     DEFINE_STATIC_LOCAL(StylePropertyShorthand, webkitColumnRuleLonghands, (columnRuleProperties, WTF_ARRAY_LENGTH(columnRuleProperties)));
     368    DEFINE_STATIC_LOCAL(StylePropertyShorthand, webkitColumnRuleLonghands, (CSSPropertyWebkitColumnRule, columnRuleProperties, WTF_ARRAY_LENGTH(columnRuleProperties)));
    344369    return webkitColumnRuleLonghands;
    345370}
     
    348373{
    349374    static const CSSPropertyID flexFlowProperties[] = { CSSPropertyWebkitFlexDirection, CSSPropertyWebkitFlexWrap };
    350     DEFINE_STATIC_LOCAL(StylePropertyShorthand, webkitFlexFlowLonghands, (flexFlowProperties, WTF_ARRAY_LENGTH(flexFlowProperties)));
     375    DEFINE_STATIC_LOCAL(StylePropertyShorthand, webkitFlexFlowLonghands, (CSSPropertyWebkitFlexFlow, flexFlowProperties, WTF_ARRAY_LENGTH(flexFlowProperties)));
    351376    return webkitFlexFlowLonghands;
    352377}
     
    355380{
    356381    static const CSSPropertyID flexProperties[] = { CSSPropertyWebkitFlexGrow, CSSPropertyWebkitFlexShrink, CSSPropertyWebkitFlexBasis };
    357     DEFINE_STATIC_LOCAL(StylePropertyShorthand, webkitFlexLonghands, (flexProperties, WTF_ARRAY_LENGTH(flexProperties)));
     382    DEFINE_STATIC_LOCAL(StylePropertyShorthand, webkitFlexLonghands, (CSSPropertyWebkitFlex, flexProperties, WTF_ARRAY_LENGTH(flexProperties)));
    358383    return webkitFlexLonghands;
    359384}
     
    362387{
    363388    static const CSSPropertyID marginCollapseProperties[] = { CSSPropertyWebkitMarginBeforeCollapse, CSSPropertyWebkitMarginAfterCollapse };
    364     DEFINE_STATIC_LOCAL(StylePropertyShorthand, webkitMarginCollapseLonghands, (marginCollapseProperties, WTF_ARRAY_LENGTH(marginCollapseProperties)));
     389    DEFINE_STATIC_LOCAL(StylePropertyShorthand, webkitMarginCollapseLonghands, (CSSPropertyWebkitMarginCollapse, marginCollapseProperties, WTF_ARRAY_LENGTH(marginCollapseProperties)));
    365390    return webkitMarginCollapseLonghands;
    366391}
     
    372397        CSSPropertyWebkitGridEnd
    373398    };
    374     DEFINE_STATIC_LOCAL(StylePropertyShorthand, webkitGridColumnLonghands, (webkitGridColumnProperties, WTF_ARRAY_LENGTH(webkitGridColumnProperties)));
     399    DEFINE_STATIC_LOCAL(StylePropertyShorthand, webkitGridColumnLonghands, (CSSPropertyWebkitGridColumn, webkitGridColumnProperties, WTF_ARRAY_LENGTH(webkitGridColumnProperties)));
    375400    return webkitGridColumnLonghands;
    376401
     
    383408        CSSPropertyWebkitGridAfter
    384409    };
    385     DEFINE_STATIC_LOCAL(StylePropertyShorthand, webkitGridRowLonghands, (webkitGridRowProperties, WTF_ARRAY_LENGTH(webkitGridRowProperties)));
     410    DEFINE_STATIC_LOCAL(StylePropertyShorthand, webkitGridRowLonghands, (CSSPropertyWebkitGridRow, webkitGridRowProperties, WTF_ARRAY_LENGTH(webkitGridRowProperties)));
    386411    return webkitGridRowLonghands;
    387412
     
    397422        CSSPropertyWebkitMarqueeSpeed
    398423    };
    399     DEFINE_STATIC_LOCAL(StylePropertyShorthand, webkitMarqueeLonghands, (marqueeProperties, WTF_ARRAY_LENGTH(marqueeProperties)));
     424    DEFINE_STATIC_LOCAL(StylePropertyShorthand, webkitMarqueeLonghands, (CSSPropertyWebkitMarquee, marqueeProperties, WTF_ARRAY_LENGTH(marqueeProperties)));
    400425    return webkitMarqueeLonghands;
    401426}
     
    413438        CSSPropertyWebkitMaskClip
    414439    };
    415     DEFINE_STATIC_LOCAL(StylePropertyShorthand, webkitMaskLonghands, (maskProperties, WTF_ARRAY_LENGTH(maskProperties)));
     440    DEFINE_STATIC_LOCAL(StylePropertyShorthand, webkitMaskLonghands, (CSSPropertyWebkitMask, maskProperties, WTF_ARRAY_LENGTH(maskProperties)));
    416441    return webkitMaskLonghands;
    417442}
     
    420445{
    421446    static const CSSPropertyID maskPositionProperties[] = { CSSPropertyWebkitMaskPositionX, CSSPropertyWebkitMaskPositionY };
    422     DEFINE_STATIC_LOCAL(StylePropertyShorthand, webkitMaskPositionLonghands, (maskPositionProperties, WTF_ARRAY_LENGTH(maskPositionProperties)));
     447    DEFINE_STATIC_LOCAL(StylePropertyShorthand, webkitMaskPositionLonghands, (CSSPropertyWebkitMaskPosition, maskPositionProperties, WTF_ARRAY_LENGTH(maskPositionProperties)));
    423448    return webkitMaskPositionLonghands;
    424449}
     
    427452{
    428453    static const CSSPropertyID maskRepeatProperties[] = { CSSPropertyWebkitMaskRepeatX, CSSPropertyWebkitMaskRepeatY };
    429     DEFINE_STATIC_LOCAL(StylePropertyShorthand, webkitMaskRepeatLonghands, (maskRepeatProperties, WTF_ARRAY_LENGTH(maskRepeatProperties)));
     454    DEFINE_STATIC_LOCAL(StylePropertyShorthand, webkitMaskRepeatLonghands, (CSSPropertyWebkitMaskRepeat, maskRepeatProperties, WTF_ARRAY_LENGTH(maskRepeatProperties)));
    430455    return webkitMaskRepeatLonghands;
    431456}
     
    437462        CSSPropertyWebkitTextEmphasisColor
    438463    };
    439     DEFINE_STATIC_LOCAL(StylePropertyShorthand, webkitTextEmphasisLonghands, (textEmphasisProperties, WTF_ARRAY_LENGTH(textEmphasisProperties)));
     464    DEFINE_STATIC_LOCAL(StylePropertyShorthand, webkitTextEmphasisLonghands, (CSSPropertyWebkitTextEmphasis, textEmphasisProperties, WTF_ARRAY_LENGTH(textEmphasisProperties)));
    440465    return webkitTextEmphasisLonghands;
    441466}
     
    444469{
    445470    static const CSSPropertyID textStrokeProperties[] = { CSSPropertyWebkitTextStrokeWidth, CSSPropertyWebkitTextStrokeColor };
    446     DEFINE_STATIC_LOCAL(StylePropertyShorthand, webkitTextStrokeLonghands, (textStrokeProperties, WTF_ARRAY_LENGTH(textStrokeProperties)));
     471    DEFINE_STATIC_LOCAL(StylePropertyShorthand, webkitTextStrokeLonghands, (CSSPropertyWebkitTextStroke, textStrokeProperties, WTF_ARRAY_LENGTH(textStrokeProperties)));
    447472    return webkitTextStrokeLonghands;
    448473}
     
    456481        CSSPropertyWebkitTransitionDelay
    457482    };
    458     DEFINE_STATIC_LOCAL(StylePropertyShorthand, webkitTransitionLonghands, (transitionProperties, WTF_ARRAY_LENGTH(transitionProperties)));
     483    DEFINE_STATIC_LOCAL(StylePropertyShorthand, webkitTransitionLonghands, (CSSPropertyWebkitTransition, transitionProperties, WTF_ARRAY_LENGTH(transitionProperties)));
    459484    return webkitTransitionLonghands;
    460485}
     
    467492        CSSPropertyWebkitTransformOriginZ
    468493    };
    469     DEFINE_STATIC_LOCAL(StylePropertyShorthand, webkitTransformOriginLonghands, (transformOriginProperties, WTF_ARRAY_LENGTH(transformOriginProperties)));
     494    DEFINE_STATIC_LOCAL(StylePropertyShorthand, webkitTransformOriginLonghands, (CSSPropertyWebkitTransformOrigin, transformOriginProperties, WTF_ARRAY_LENGTH(transformOriginProperties)));
    470495    return webkitTransformOriginLonghands;
     496}
     497
     498const StylePropertyShorthand& widthShorthand()
     499{
     500    static const CSSPropertyID widthProperties[] = {
     501        CSSPropertyMinWidth,
     502        CSSPropertyMaxWidth
     503    };
     504    DEFINE_STATIC_LOCAL(StylePropertyShorthand, widthLonghands, (CSSPropertyWidth, widthProperties, WTF_ARRAY_LENGTH(widthProperties)));
     505    return widthLonghands;
     506}
     507
     508const StylePropertyShorthand& heightShorthand()
     509{
     510    static const CSSPropertyID heightProperties[] = {
     511        CSSPropertyMinHeight,
     512        CSSPropertyMaxHeight
     513    };
     514    DEFINE_STATIC_LOCAL(StylePropertyShorthand, heightLonghands, (CSSPropertyHeight, heightProperties, WTF_ARRAY_LENGTH(heightProperties)));
     515    return heightLonghands;
    471516}
    472517
     
    578623}
    579624
     625// FIXME : We need to generate all of this.
     626typedef HashMap<CSSPropertyID, Vector<const StylePropertyShorthand*> > longhandsMap;
     627const Vector<const StylePropertyShorthand*> matchingShorthandsForLonghand(CSSPropertyID propertyID)
     628{
     629    DEFINE_STATIC_LOCAL(longhandsMap, map, ());
     630    if (map.isEmpty()) {
     631        Vector<const StylePropertyShorthand*, 1> background;
     632        background.uncheckedAppend(&backgroundShorthand());
     633        map.set(CSSPropertyBackgroundImage, background);
     634        map.set(CSSPropertyBackgroundSize, background);
     635        map.set(CSSPropertyBackgroundAttachment, background);
     636        map.set(CSSPropertyBackgroundOrigin, background);
     637        map.set(CSSPropertyBackgroundClip, background);
     638        map.set(CSSPropertyBackgroundColor, background);
     639
     640        Vector<const StylePropertyShorthand*, 2> positionShorthands;
     641        positionShorthands.uncheckedAppend(&backgroundShorthand());
     642        positionShorthands.uncheckedAppend(&backgroundPositionShorthand());
     643        map.set(CSSPropertyBackgroundPositionX, positionShorthands);
     644        map.set(CSSPropertyBackgroundPositionY, positionShorthands);
     645
     646        Vector<const StylePropertyShorthand*, 2> repeatShorthands;
     647        repeatShorthands.uncheckedAppend(&backgroundShorthand());
     648        repeatShorthands.uncheckedAppend(&backgroundRepeatShorthand());
     649        map.set(CSSPropertyBackgroundRepeatX, repeatShorthands);
     650        map.set(CSSPropertyBackgroundRepeatY, repeatShorthands);
     651
     652        Vector<const StylePropertyShorthand*, 3> bottomWidthShorthands;
     653        bottomWidthShorthands.uncheckedAppend(&borderShorthand());
     654        bottomWidthShorthands.uncheckedAppend(&borderBottomShorthand());
     655        bottomWidthShorthands.uncheckedAppend(&borderWidthShorthand());
     656        map.set(CSSPropertyBorderBottomWidth, bottomWidthShorthands);
     657
     658        Vector<const StylePropertyShorthand*, 3> topColorShorthands;
     659        topColorShorthands.uncheckedAppend(&borderShorthand());
     660        topColorShorthands.uncheckedAppend(&borderTopShorthand());
     661        topColorShorthands.uncheckedAppend(&borderColorShorthand());
     662        map.set(CSSPropertyBorderTopColor, topColorShorthands);
     663
     664        Vector<const StylePropertyShorthand*, 3> rightColorShorthands;
     665        rightColorShorthands.uncheckedAppend(&borderShorthand());
     666        rightColorShorthands.uncheckedAppend(&borderRightShorthand());
     667        rightColorShorthands.uncheckedAppend(&borderColorShorthand());
     668        map.set(CSSPropertyBorderRightColor, rightColorShorthands);
     669
     670        Vector<const StylePropertyShorthand*, 3> leftColorShorthands;
     671        leftColorShorthands.uncheckedAppend(&borderShorthand());
     672        leftColorShorthands.uncheckedAppend(&borderLeftShorthand());
     673        leftColorShorthands.uncheckedAppend(&borderColorShorthand());
     674        map.set(CSSPropertyBorderLeftColor, leftColorShorthands);
     675
     676        Vector<const StylePropertyShorthand*, 3> bottomColorShorthands;
     677        bottomColorShorthands.uncheckedAppend(&borderShorthand());
     678        bottomColorShorthands.uncheckedAppend(&borderBottomShorthand());
     679        bottomColorShorthands.uncheckedAppend(&borderColorShorthand());
     680        map.set(CSSPropertyBorderBottomColor, bottomColorShorthands);
     681
     682        Vector<const StylePropertyShorthand*, 1> borderImage;
     683        borderImage.uncheckedAppend(&borderImageShorthand());
     684        map.set(CSSPropertyBorderImageSource, borderImage);
     685        map.set(CSSPropertyBorderImageSlice, borderImage);
     686        map.set(CSSPropertyBorderImageWidth, borderImage);
     687        map.set(CSSPropertyBorderImageOutset, borderImage);
     688        map.set(CSSPropertyBorderImageRepeat, borderImage);
     689
     690        Vector<const StylePropertyShorthand*, 3> leftWidthShorthands;
     691        leftWidthShorthands.uncheckedAppend(&borderShorthand());
     692        leftWidthShorthands.uncheckedAppend(&borderLeftShorthand());
     693        leftWidthShorthands.uncheckedAppend(&borderWidthShorthand());
     694        map.set(CSSPropertyBorderLeftWidth, leftWidthShorthands);
     695
     696        Vector<const StylePropertyShorthand*, 2> radiusShorthands;
     697        radiusShorthands.uncheckedAppend(&borderRadiusShorthand());
     698        radiusShorthands.uncheckedAppend(&webkitBorderRadiusShorthand());
     699        map.set(CSSPropertyBorderTopLeftRadius, radiusShorthands);
     700        map.set(CSSPropertyBorderTopRightRadius, radiusShorthands);
     701        map.set(CSSPropertyBorderBottomRightRadius, radiusShorthands);
     702        map.set(CSSPropertyBorderBottomLeftRadius, radiusShorthands);
     703
     704        Vector<const StylePropertyShorthand*, 3> rightWidthShorthands;
     705        rightWidthShorthands.uncheckedAppend(&borderShorthand());
     706        rightWidthShorthands.uncheckedAppend(&borderRightShorthand());
     707        rightWidthShorthands.uncheckedAppend(&borderWidthShorthand());
     708        map.set(CSSPropertyBorderRightWidth, rightWidthShorthands);
     709
     710        Vector<const StylePropertyShorthand*, 1> spacingShorthand;
     711        spacingShorthand.uncheckedAppend(&borderSpacingShorthand());
     712        map.set(CSSPropertyWebkitBorderHorizontalSpacing, spacingShorthand);
     713        map.set(CSSPropertyWebkitBorderVerticalSpacing, spacingShorthand);
     714
     715        Vector<const StylePropertyShorthand*, 3> topStyleShorthands;
     716        topStyleShorthands.uncheckedAppend(&borderShorthand());
     717        topStyleShorthands.uncheckedAppend(&borderTopShorthand());
     718        topStyleShorthands.uncheckedAppend(&borderStyleShorthand());
     719        map.set(CSSPropertyBorderTopStyle, topStyleShorthands);
     720
     721        Vector<const StylePropertyShorthand*, 3> bottomStyleShorthands;
     722        bottomStyleShorthands.uncheckedAppend(&borderShorthand());
     723        bottomStyleShorthands.uncheckedAppend(&borderBottomShorthand());
     724        bottomStyleShorthands.uncheckedAppend(&borderStyleShorthand());
     725        map.set(CSSPropertyBorderBottomStyle, bottomStyleShorthands);
     726
     727        Vector<const StylePropertyShorthand*, 3> leftStyleShorthands;
     728        leftStyleShorthands.uncheckedAppend(&borderShorthand());
     729        leftStyleShorthands.uncheckedAppend(&borderLeftShorthand());
     730        leftStyleShorthands.uncheckedAppend(&borderStyleShorthand());
     731        map.set(CSSPropertyBorderLeftStyle, leftStyleShorthands);
     732
     733        Vector<const StylePropertyShorthand*, 3> rightStyleShorthands;
     734        rightStyleShorthands.uncheckedAppend(&borderShorthand());
     735        rightStyleShorthands.uncheckedAppend(&borderRightShorthand());
     736        rightStyleShorthands.uncheckedAppend(&borderStyleShorthand());
     737        map.set(CSSPropertyBorderRightStyle, rightStyleShorthands);
     738
     739        Vector<const StylePropertyShorthand*, 3> topWidthShorthands;
     740        topWidthShorthands.uncheckedAppend(&borderShorthand());
     741        topWidthShorthands.uncheckedAppend(&borderTopShorthand());
     742        topWidthShorthands.uncheckedAppend(&borderWidthShorthand());
     743        map.set(CSSPropertyBorderTopWidth, topWidthShorthands);
     744
     745        Vector<const StylePropertyShorthand*, 1> listStyle;
     746        listStyle.uncheckedAppend(&listStyleShorthand());
     747        map.set(CSSPropertyListStyleType, listStyle);
     748        map.set(CSSPropertyListStylePosition, listStyle);
     749        map.set(CSSPropertyListStyleImage, listStyle);
     750
     751        Vector<const StylePropertyShorthand*, 1> font;
     752        font.uncheckedAppend(&fontShorthand());
     753        map.set(CSSPropertyFontFamily, font);
     754        map.set(CSSPropertyFontSize, font);
     755        map.set(CSSPropertyFontStyle, font);
     756        map.set(CSSPropertyFontVariant, font);
     757        map.set(CSSPropertyFontWeight, font);
     758        map.set(CSSPropertyLineHeight, font);
     759
     760        Vector<const StylePropertyShorthand*, 1> margin;
     761        margin.uncheckedAppend(&marginShorthand());
     762        map.set(CSSPropertyMarginTop, margin);
     763        map.set(CSSPropertyMarginRight, margin);
     764        map.set(CSSPropertyMarginBottom, margin);
     765        map.set(CSSPropertyMarginLeft, margin);
     766
     767        Vector<const StylePropertyShorthand*, 1> marker;
     768        marker.uncheckedAppend(&markerShorthand());
     769        map.set(CSSPropertyMarkerStart, marker);
     770        map.set(CSSPropertyMarkerMid, marker);
     771        map.set(CSSPropertyMarkerEnd, marker);
     772
     773        Vector<const StylePropertyShorthand*, 1> outline;
     774        outline.uncheckedAppend(&outlineShorthand());
     775        map.set(CSSPropertyOutlineColor, outline);
     776        map.set(CSSPropertyOutlineStyle, outline);
     777        map.set(CSSPropertyOutlineWidth, outline);
     778
     779        Vector<const StylePropertyShorthand*, 1> padding;
     780        padding.uncheckedAppend(&paddingShorthand());
     781        map.set(CSSPropertyPaddingTop, padding);
     782        map.set(CSSPropertyPaddingRight, padding);
     783        map.set(CSSPropertyPaddingBottom, padding);
     784        map.set(CSSPropertyPaddingLeft, padding);
     785
     786        Vector<const StylePropertyShorthand*, 1> overflow;
     787        overflow.uncheckedAppend(&overflowShorthand());
     788        map.set(CSSPropertyOverflowX, overflow);
     789        map.set(CSSPropertyOverflowY, overflow);
     790
     791        Vector<const StylePropertyShorthand*, 1> transition;
     792        transition.uncheckedAppend(&transitionShorthand());
     793        map.set(CSSPropertyTransitionProperty, transition);
     794        map.set(CSSPropertyTransitionDuration, transition);
     795        map.set(CSSPropertyTransitionTimingFunction, transition);
     796        map.set(CSSPropertyTransitionDelay, transition);
     797
     798        Vector<const StylePropertyShorthand*, 1> animation;
     799        animation.uncheckedAppend(&webkitAnimationShorthand());
     800        map.set(CSSPropertyWebkitAnimationName, animation);
     801        map.set(CSSPropertyWebkitAnimationDuration, animation);
     802        map.set(CSSPropertyWebkitAnimationTimingFunction, animation);
     803        map.set(CSSPropertyWebkitAnimationDelay, animation);
     804        map.set(CSSPropertyWebkitAnimationIterationCount, animation);
     805        map.set(CSSPropertyWebkitAnimationDirection, animation);
     806        map.set(CSSPropertyWebkitAnimationFillMode, animation);
     807
     808        Vector<const StylePropertyShorthand*, 1> borderAfter;
     809        borderAfter.uncheckedAppend(&webkitBorderAfterShorthand());
     810        map.set(CSSPropertyWebkitBorderAfterWidth, borderAfter);
     811        map.set(CSSPropertyWebkitBorderAfterStyle, borderAfter);
     812        map.set(CSSPropertyWebkitBorderAfterColor, borderAfter);
     813
     814        Vector<const StylePropertyShorthand*, 1> borderBefore;
     815        borderBefore.uncheckedAppend(&webkitBorderBeforeShorthand());
     816        map.set(CSSPropertyWebkitBorderBeforeWidth, borderBefore);
     817        map.set(CSSPropertyWebkitBorderBeforeStyle, borderBefore);
     818        map.set(CSSPropertyWebkitBorderBeforeColor, borderBefore);
     819
     820        Vector<const StylePropertyShorthand*, 1> borderEnd;
     821        borderEnd.uncheckedAppend(&webkitBorderEndShorthand());
     822        map.set(CSSPropertyWebkitBorderEndWidth, borderEnd);
     823        map.set(CSSPropertyWebkitBorderEndStyle, borderEnd);
     824        map.set(CSSPropertyWebkitBorderEndColor, borderEnd);
     825
     826        Vector<const StylePropertyShorthand*, 1> borderStart;
     827        borderStart.uncheckedAppend(&webkitBorderStartShorthand());
     828        map.set(CSSPropertyWebkitBorderStartWidth, borderStart);
     829        map.set(CSSPropertyWebkitBorderStartStyle, borderStart);
     830        map.set(CSSPropertyWebkitBorderStartColor, borderStart);
     831
     832        Vector<const StylePropertyShorthand*, 1> columns;
     833        columns.uncheckedAppend(&webkitColumnsShorthand());
     834        map.set(CSSPropertyWebkitColumnWidth, columns);
     835        map.set(CSSPropertyWebkitColumnCount, columns);
     836
     837        Vector<const StylePropertyShorthand*, 1> columnRule;
     838        columnRule.uncheckedAppend(&webkitColumnRuleShorthand());
     839        map.set(CSSPropertyWebkitColumnRuleWidth, columnRule);
     840        map.set(CSSPropertyWebkitColumnRuleStyle, columnRule);
     841        map.set(CSSPropertyWebkitColumnRuleColor, columnRule);
     842
     843        Vector<const StylePropertyShorthand*, 1> flex;
     844        flex.uncheckedAppend(&webkitFlexShorthand());
     845        map.set(CSSPropertyWebkitFlexGrow, flex);
     846        map.set(CSSPropertyWebkitFlexShrink, flex);
     847        map.set(CSSPropertyWebkitFlexBasis, flex);
     848
     849        Vector<const StylePropertyShorthand*, 1> flexFlow;
     850        flexFlow.uncheckedAppend(&webkitFlexFlowShorthand());
     851        map.set(CSSPropertyWebkitFlexDirection, flexFlow);
     852        map.set(CSSPropertyWebkitFlexWrap, flexFlow);
     853
     854        Vector<const StylePropertyShorthand*, 1> grid;
     855        grid.uncheckedAppend(&webkitGridColumnShorthand());
     856        map.set(CSSPropertyWebkitGridStart, grid);
     857        map.set(CSSPropertyWebkitGridEnd, grid);
     858
     859        Vector<const StylePropertyShorthand*, 1> gridAfter;
     860        gridAfter.uncheckedAppend(&webkitGridRowShorthand());
     861        map.set(CSSPropertyWebkitGridBefore, gridAfter);
     862        map.set(CSSPropertyWebkitGridAfter, gridAfter);
     863
     864        Vector<const StylePropertyShorthand*, 1> marginCollapse;
     865        marginCollapse.uncheckedAppend(&webkitMarginCollapseShorthand());
     866        map.set(CSSPropertyWebkitMarginBeforeCollapse, marginCollapse);
     867        map.set(CSSPropertyWebkitMarginAfterCollapse, marginCollapse);
     868
     869        Vector<const StylePropertyShorthand*, 1> marquee;
     870        marquee.uncheckedAppend(&webkitMarqueeShorthand());
     871        map.set(CSSPropertyWebkitMarqueeDirection, marquee);
     872        map.set(CSSPropertyWebkitMarqueeIncrement, marquee);
     873        map.set(CSSPropertyWebkitMarqueeRepetition, marquee);
     874        map.set(CSSPropertyWebkitMarqueeStyle, marquee);
     875        map.set(CSSPropertyWebkitMarqueeSpeed, marquee);
     876
     877        Vector<const StylePropertyShorthand*, 1> mask;
     878        mask.uncheckedAppend(&webkitMaskShorthand());
     879        map.set(CSSPropertyWebkitMaskImage, mask);
     880        map.set(CSSPropertyWebkitMaskSize, mask);
     881        map.set(CSSPropertyWebkitMaskOrigin, mask);
     882        map.set(CSSPropertyWebkitMaskClip, mask);
     883
     884        Vector<const StylePropertyShorthand*, 1> maskPosition;
     885        maskPosition.uncheckedAppend(&webkitMaskPositionShorthand());
     886        map.set(CSSPropertyWebkitMaskPositionX, maskPosition);
     887        map.set(CSSPropertyWebkitMaskPositionY, maskPosition);
     888
     889        Vector<const StylePropertyShorthand*, 1> maskRepeat;
     890        maskRepeat.uncheckedAppend(&webkitMaskRepeatShorthand());
     891        map.set(CSSPropertyWebkitMaskRepeatX, maskRepeat);
     892        map.set(CSSPropertyWebkitMaskRepeatY, maskRepeat);
     893
     894        Vector<const StylePropertyShorthand*, 1> textEmphasis;
     895        textEmphasis.uncheckedAppend(&webkitTextEmphasisShorthand());
     896        map.set(CSSPropertyWebkitTextEmphasisStyle, textEmphasis);
     897        map.set(CSSPropertyWebkitTextEmphasisColor, textEmphasis);
     898
     899        Vector<const StylePropertyShorthand*, 1> textStroke;
     900        textStroke.uncheckedAppend(&webkitTextStrokeShorthand());
     901        map.set(CSSPropertyWebkitTextStrokeWidth, textStroke);
     902        map.set(CSSPropertyWebkitTextStrokeColor, textStroke);
     903
     904        Vector<const StylePropertyShorthand*, 1> webkitTransition;
     905        webkitTransition.uncheckedAppend(&webkitTransitionShorthand());
     906        map.set(CSSPropertyWebkitTransitionProperty, webkitTransition);
     907        map.set(CSSPropertyWebkitTransitionDuration, webkitTransition);
     908        map.set(CSSPropertyWebkitTransitionTimingFunction, webkitTransition);
     909        map.set(CSSPropertyWebkitTransitionDelay, webkitTransition);
     910
     911        Vector<const StylePropertyShorthand*, 1> transform;
     912        transform.uncheckedAppend(&webkitTransformOriginShorthand());
     913        map.set(CSSPropertyWebkitTransformOriginX, transform);
     914        map.set(CSSPropertyWebkitTransformOriginY, transform);
     915        map.set(CSSPropertyWebkitTransformOriginZ, transform);
     916
     917        Vector<const StylePropertyShorthand*, 1> width;
     918        width.uncheckedAppend(&widthShorthand());
     919        map.set(CSSPropertyMinWidth, width);
     920        map.set(CSSPropertyMaxWidth, width);
     921
     922        Vector<const StylePropertyShorthand*, 1> height;
     923        height.uncheckedAppend(&heightShorthand());
     924        map.set(CSSPropertyMinHeight, height);
     925        map.set(CSSPropertyMaxHeight, height);
     926    }
     927    return map.get(propertyID);
     928}
     929
     930unsigned indexOfShorthandForLonghand(CSSPropertyID shorthandID, const Vector<const StylePropertyShorthand*>& shorthands)
     931{
     932    for (unsigned i = 0; i < shorthands.size(); ++i) {
     933        if (shorthands.at(i)->id() == shorthandID)
     934            return i;
     935    }
     936    ASSERT_NOT_REACHED();
     937    return 0;
     938}
     939
    580940} // namespace WebCore
  • trunk/Source/WebCore/css/StylePropertyShorthand.h

    r149623 r153581  
    22 * (C) 1999-2003 Lars Knoll (knoll@kde.org)
    33 * Copyright (C) 2004, 2005, 2006, 2008 Apple Inc. All rights reserved.
     4 * Copyright (C) 2013 Intel Corporation. All rights reserved.
    45 *
    56 * This library is free software; you can redistribute it and/or
     
    2324
    2425#include "CSSPropertyNames.h"
     26#include <wtf/Vector.h>
    2527
    2628namespace WebCore {
     
    3335        , m_propertiesForInitialization(0)
    3436        , m_length(0)
     37        , m_shorthandID(CSSPropertyInvalid)
    3538    {
    3639    }
    3740
    38     StylePropertyShorthand(const CSSPropertyID* properties, unsigned numProperties)
     41    StylePropertyShorthand(CSSPropertyID id, const CSSPropertyID* properties, unsigned numProperties)
    3942        : m_properties(properties)
    4043        , m_propertiesForInitialization(0)
    4144        , m_length(numProperties)
     45        , m_shorthandID(id)
    4246    {
    4347    }
    4448
    45     StylePropertyShorthand(const CSSPropertyID* properties, const StylePropertyShorthand** propertiesForInitialization, unsigned numProperties)
     49    StylePropertyShorthand(CSSPropertyID id, const CSSPropertyID* properties, const StylePropertyShorthand** propertiesForInitialization, unsigned numProperties)
    4650        : m_properties(properties)
    4751        , m_propertiesForInitialization(propertiesForInitialization)
    4852        , m_length(numProperties)
     53        , m_shorthandID(id)
    4954    {
    5055    }
     
    5358    const StylePropertyShorthand** propertiesForInitialization() const { return m_propertiesForInitialization; }
    5459    unsigned length() const { return m_length; }
     60    CSSPropertyID id() const { return m_shorthandID; }
    5561
    5662private:
     
    5864    const StylePropertyShorthand** m_propertiesForInitialization;
    5965    unsigned m_length;
     66    CSSPropertyID m_shorthandID;
    6067};
    6168
     
    7784const StylePropertyShorthand& listStyleShorthand();
    7885const StylePropertyShorthand& fontShorthand();
     86const StylePropertyShorthand& heightShorthand();
    7987const StylePropertyShorthand& marginShorthand();
     88const StylePropertyShorthand& markerShorthand();
    8089const StylePropertyShorthand& outlineShorthand();
    8190const StylePropertyShorthand& overflowShorthand();
     
    8796const StylePropertyShorthand& webkitBorderBeforeShorthand();
    8897const StylePropertyShorthand& webkitBorderEndShorthand();
     98const StylePropertyShorthand& webkitBorderRadiusShorthand();
    8999const StylePropertyShorthand& webkitBorderStartShorthand();
    90100const StylePropertyShorthand& webkitColumnsShorthand();
     
    103113const StylePropertyShorthand& webkitTransitionShorthand();
    104114const StylePropertyShorthand& webkitTransformOriginShorthand();
     115const StylePropertyShorthand& widthShorthand();
    105116
    106 // Returns an empty list if the property is not a shorthand
     117// Returns an empty list if the property is not a shorthand.
    107118const StylePropertyShorthand& shorthandForProperty(CSSPropertyID);
     119
     120// Return the list of shorthands for a given longhand.
     121const Vector<const StylePropertyShorthand*> matchingShorthandsForLonghand(CSSPropertyID);
     122unsigned indexOfShorthandForLonghand(CSSPropertyID, const Vector<const StylePropertyShorthand*>&);
    108123
    109124bool isExpandedShorthand(CSSPropertyID);
  • trunk/Source/WebCore/css/makeprop.pl

    r125934 r153581  
    3333
    3434my @NAMES = applyPreprocessor("CSSPropertyNames.in", $defines, $preprocessor);
     35die "We've reached more than 1024 CSS properties, please make sure to update CSSProperty/StylePropertyMetadata accordingly" if (scalar(@NAMES) > 1024);
    3536
    3637my %namesHash;
     
    204205EOF
    205206
    206 my $first = 1001;
    207 my $i = 1001;
     207my $first = 3;
     208my $i = 3;
    208209my $maxLen = 0;
    209210foreach my $name (@names) {
Note: See TracChangeset for help on using the changeset viewer.