Changeset 112254 in webkit


Ignore:
Timestamp:
Mar 27, 2012 5:00:52 AM (12 years ago)
Author:
alexis.menard@openbossa.org
Message:

Increase code sharing between CSSComputedStyleDeclaration and CSSPropertyLonghand.
https://bugs.webkit.org/show_bug.cgi?id=82261

Reviewed by Ryosuke Niwa.

Source/WebCore:

Use longhands declaration from CSSPropertyLonghand in CSSComputedStyleDeclaration to avoid
code duplication.

No new tests : refactoring only, we shouldn't have any behavior difference.

  • css/CSSComputedStyleDeclaration.cpp:

(WebCore::CSSComputedStyleDeclaration::getPropertyCSSValue):
(WebCore::CSSComputedStyleDeclaration::getCSSPropertyValuesForShorthandProperties):
(WebCore::CSSComputedStyleDeclaration::getCSSPropertyValuesForSidesShorthand):

  • css/CSSComputedStyleDeclaration.h:

(WebCore):
(CSSComputedStyleDeclaration):

  • css/CSSPropertyLonghand.cpp:

(WebCore::outlineLonghand):
Re-order to match the spec default order and also remove outline-offset as it is not part
of the shorthand (http://www.w3.org/TR/css3-ui/#outline). Luckily this was cover by a layout test.

LayoutTests:

Update expectation as it was relying on inaccurate order. All other outline related tests
are expecting the same order (e.g. fast/getComputedStyle/getComputedStyle-outline-shorthand) as well
as Opera.

  • fast/css/cssText-shorthand-expected.txt:
  • fast/css/cssText-shorthand.html:
Location:
trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r112247 r112254  
     12012-03-27  Alexis Menard  <alexis.menard@openbossa.org>
     2
     3        Increase code sharing between CSSComputedStyleDeclaration and CSSPropertyLonghand.
     4        https://bugs.webkit.org/show_bug.cgi?id=82261
     5
     6        Reviewed by Ryosuke Niwa.
     7
     8        Update expectation as it was relying on inaccurate order. All other outline related tests
     9        are expecting the same order (e.g. fast/getComputedStyle/getComputedStyle-outline-shorthand) as well
     10        as Opera.
     11
     12        * fast/css/cssText-shorthand-expected.txt:
     13        * fast/css/cssText-shorthand.html:
     14
    1152012-03-27  Nikolas Zimmermann  <nzimmermann@rim.com>
    216
  • trunk/LayoutTests/fast/css/cssText-shorthand-expected.txt

    r112177 r112254  
    1818PASS normalizeCssText(element.style.cssText) is "list-style: circle inside"
    1919PASS normalizeCssText(element.style.cssText) is "margin: 1px 2px 3px 4px"
    20 PASS normalizeCssText(element.style.cssText) is "outline: 2px dotted blue"
     20PASS normalizeCssText(element.style.cssText) is "outline: blue dotted 2px"
    2121FAIL normalizeCssText(element.style.cssText) should be overflow: scroll hidden. Was overflow-x: scroll; overflow-y: hidden.
    2222PASS normalizeCssText(element.style.cssText) is "padding: 1px 2px 3px 4px"
  • trunk/LayoutTests/fast/css/cssText-shorthand.html

    r112177 r112254  
    3232    ['list-style-type: circle; list-style-position: inside;', 'list-style: circle inside;'],
    3333    ['margin-top: 1px; margin-right: 2px; margin-bottom: 3px; margin-left: 4px;', 'margin: 1px 2px 3px 4px;'],
    34     ['outline-width: 2px; outline-style: dotted; outline-color: blue;', 'outline: 2px dotted blue;'],
     34    ['outline-width: 2px; outline-style: dotted; outline-color: blue;', 'outline: blue dotted 2px;'],
    3535    ['overflow-x: scroll; overflow-y: hidden;', 'overflow: scroll hidden;'],
    3636    ['padding-top: 1px; padding-right: 2px; padding-bottom: 3px; padding-left: 4px;', 'padding: 1px 2px 3px 4px;'],
  • trunk/Source/WebCore/ChangeLog

    r112251 r112254  
     12012-03-27  Alexis Menard  <alexis.menard@openbossa.org>
     2
     3        Increase code sharing between CSSComputedStyleDeclaration and CSSPropertyLonghand.
     4        https://bugs.webkit.org/show_bug.cgi?id=82261
     5
     6        Reviewed by Ryosuke Niwa.
     7
     8        Use longhands declaration from CSSPropertyLonghand in CSSComputedStyleDeclaration to avoid
     9        code duplication.
     10
     11        No new tests : refactoring only, we shouldn't have any behavior difference.
     12
     13        * css/CSSComputedStyleDeclaration.cpp:
     14        (WebCore::CSSComputedStyleDeclaration::getPropertyCSSValue):
     15        (WebCore::CSSComputedStyleDeclaration::getCSSPropertyValuesForShorthandProperties):
     16        (WebCore::CSSComputedStyleDeclaration::getCSSPropertyValuesForSidesShorthand):
     17        * css/CSSComputedStyleDeclaration.h:
     18        (WebCore):
     19        (CSSComputedStyleDeclaration):
     20        * css/CSSPropertyLonghand.cpp:
     21        (WebCore::outlineLonghand):
     22        Re-order to match the spec default order and also remove outline-offset as it is not part
     23        of the shorthand (http://www.w3.org/TR/css3-ui/#outline). Luckily this was cover by a layout test.
     24
    1252012-03-27  Vsevolod Vlasov  <vsevik@chromium.org>
    226
  • trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp

    r112198 r112254  
    3333#include "CSSPrimitiveValueMappings.h"
    3434#include "CSSProperty.h"
     35#include "CSSPropertyLonghand.h"
    3536#include "CSSPropertyNames.h"
    3637#include "CSSReflectValue.h"
     
    23352336                                        CSSPropertyBackgroundRepeat, CSSPropertyBackgroundAttachment,
    23362337                                        CSSPropertyBackgroundPosition };
    2337             return getCSSPropertyValuesForShorthandProperties(properties, WTF_ARRAY_LENGTH(properties));
     2338            return getCSSPropertyValuesForShorthandProperties(CSSPropertyLonghand(properties, WTF_ARRAY_LENGTH(properties)));
    23382339        }
    23392340        case CSSPropertyBorder: {
     
    23472348            return value.release();
    23482349        }
    2349         case CSSPropertyBorderBottom: {
    2350             const int properties[3] = { CSSPropertyBorderBottomWidth, CSSPropertyBorderBottomStyle,
    2351                                         CSSPropertyBorderBottomColor };
    2352             return getCSSPropertyValuesForShorthandProperties(properties, WTF_ARRAY_LENGTH(properties));
    2353         }
    2354         case CSSPropertyBorderColor: {
    2355             const int properties[4] = { CSSPropertyBorderTopColor, CSSPropertyBorderRightColor,
    2356                                         CSSPropertyBorderBottomColor, CSSPropertyBorderLeftColor };
    2357             return getCSSPropertyValuesForSidesShorthand(properties);
    2358         }
    2359         case CSSPropertyBorderLeft: {
    2360             const int properties[3] = { CSSPropertyBorderLeftWidth, CSSPropertyBorderLeftStyle,
    2361                                         CSSPropertyBorderLeftColor };
    2362             return getCSSPropertyValuesForShorthandProperties(properties, WTF_ARRAY_LENGTH(properties));
    2363         }
     2350        case CSSPropertyBorderBottom:
     2351            return getCSSPropertyValuesForShorthandProperties(borderBottomLonghand());
     2352        case CSSPropertyBorderColor:
     2353            return getCSSPropertyValuesForSidesShorthand(borderColorLonghand());
     2354        case CSSPropertyBorderLeft:
     2355            return getCSSPropertyValuesForShorthandProperties(borderLeftLonghand());
    23642356        case CSSPropertyBorderImage:
    23652357            return valueForNinePieceImage(style->borderImage(), cssValuePool);
    23662358        case CSSPropertyBorderRadius:
    23672359            return getBorderRadiusShorthandValue(style.get(), cssValuePool);
    2368         case CSSPropertyBorderRight: {
    2369             const int properties[3] = { CSSPropertyBorderRightWidth, CSSPropertyBorderRightStyle,
    2370                                         CSSPropertyBorderRightColor };
    2371             return getCSSPropertyValuesForShorthandProperties(properties, WTF_ARRAY_LENGTH(properties));
    2372         }
    2373         case CSSPropertyBorderStyle: {
    2374             const int properties[4] = { CSSPropertyBorderTopStyle, CSSPropertyBorderRightStyle,
    2375                                         CSSPropertyBorderBottomStyle, CSSPropertyBorderLeftStyle };
    2376             return getCSSPropertyValuesForSidesShorthand(properties);
    2377         }
    2378         case CSSPropertyBorderTop: {
    2379             const int properties[3] = { CSSPropertyBorderTopWidth, CSSPropertyBorderTopStyle,
    2380                                         CSSPropertyBorderTopColor };
    2381             return getCSSPropertyValuesForShorthandProperties(properties, WTF_ARRAY_LENGTH(properties));
    2382         }
    2383         case CSSPropertyBorderWidth: {
    2384             const int properties[4] = { CSSPropertyBorderTopWidth, CSSPropertyBorderRightWidth,
    2385                                         CSSPropertyBorderBottomWidth, CSSPropertyBorderLeftWidth };
    2386             return getCSSPropertyValuesForSidesShorthand(properties);
    2387         }
    2388         case CSSPropertyListStyle: {
    2389             const int properties[3] = { CSSPropertyListStyleType, CSSPropertyListStylePosition,
    2390                                         CSSPropertyListStyleImage };
    2391             return getCSSPropertyValuesForShorthandProperties(properties, WTF_ARRAY_LENGTH(properties));
    2392         }
    2393         case CSSPropertyMargin: {
    2394             const int properties[4] = { CSSPropertyMarginTop, CSSPropertyMarginRight,
    2395                                         CSSPropertyMarginBottom, CSSPropertyMarginLeft };
    2396             return getCSSPropertyValuesForSidesShorthand(properties);
    2397         }
    2398         case CSSPropertyOutline: {
    2399             const int properties[3] = { CSSPropertyOutlineColor, CSSPropertyOutlineStyle,
    2400                                         CSSPropertyOutlineWidth };
    2401             return getCSSPropertyValuesForShorthandProperties(properties, WTF_ARRAY_LENGTH(properties));
    2402         }
    2403         case CSSPropertyPadding: {
    2404             const int properties[4] = { CSSPropertyPaddingTop, CSSPropertyPaddingRight,
    2405                                         CSSPropertyPaddingBottom, CSSPropertyPaddingLeft };
    2406             return getCSSPropertyValuesForSidesShorthand(properties);
    2407         }
     2360        case CSSPropertyBorderRight:
     2361            return getCSSPropertyValuesForShorthandProperties(borderRightLonghand());
     2362        case CSSPropertyBorderStyle:
     2363            return getCSSPropertyValuesForSidesShorthand(borderStyleLonghand());
     2364        case CSSPropertyBorderTop:
     2365            return getCSSPropertyValuesForShorthandProperties(borderTopLonghand());
     2366        case CSSPropertyBorderWidth:
     2367            return getCSSPropertyValuesForSidesShorthand(borderWidthLonghand());
     2368        case CSSPropertyListStyle:
     2369            return getCSSPropertyValuesForShorthandProperties(listStyleLonghand());
     2370        case CSSPropertyMargin:
     2371            return getCSSPropertyValuesForSidesShorthand(marginLonghand());
     2372        case CSSPropertyOutline:
     2373            return getCSSPropertyValuesForShorthandProperties(outlineLonghand());
     2374        case CSSPropertyPadding:
     2375            return getCSSPropertyValuesForSidesShorthand(paddingLonghand());
    24082376        /* Individual properties not part of the spec */
    24092377        case CSSPropertyBackgroundRepeatX:
     
    26022570}
    26032571
    2604 PassRefPtr<CSSValueList> CSSComputedStyleDeclaration::getCSSPropertyValuesForShorthandProperties(const int* properties, size_t size) const
     2572PassRefPtr<CSSValueList> CSSComputedStyleDeclaration::getCSSPropertyValuesForShorthandProperties(const CSSPropertyLonghand& longhand) const
    26052573{
    26062574    RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
    2607     for (size_t i = 0; i < size; ++i) {
    2608         RefPtr<CSSValue> value = getPropertyCSSValue(properties[i], DoNotUpdateLayout);
     2575    for (size_t i = 0; i < longhand.length(); ++i) {
     2576        RefPtr<CSSValue> value = getPropertyCSSValue(longhand.properties()[i], DoNotUpdateLayout);
    26092577        list->append(value);
    26102578    }
     
    26122580}
    26132581
    2614 PassRefPtr<CSSValueList> CSSComputedStyleDeclaration::getCSSPropertyValuesForSidesShorthand(const int* properties) const
     2582PassRefPtr<CSSValueList> CSSComputedStyleDeclaration::getCSSPropertyValuesForSidesShorthand(const CSSPropertyLonghand& longhand) const
    26152583{
    26162584    RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
    26172585    // Assume the properties are in the usual order top, right, bottom, left.
    2618     RefPtr<CSSValue> topValue = getPropertyCSSValue(properties[0], DoNotUpdateLayout);
    2619     RefPtr<CSSValue> rightValue = getPropertyCSSValue(properties[1], DoNotUpdateLayout);
    2620     RefPtr<CSSValue> bottomValue = getPropertyCSSValue(properties[2], DoNotUpdateLayout);
    2621     RefPtr<CSSValue> leftValue = getPropertyCSSValue(properties[3], DoNotUpdateLayout);
     2586    RefPtr<CSSValue> topValue = getPropertyCSSValue(longhand.properties()[0], DoNotUpdateLayout);
     2587    RefPtr<CSSValue> rightValue = getPropertyCSSValue(longhand.properties()[1], DoNotUpdateLayout);
     2588    RefPtr<CSSValue> bottomValue = getPropertyCSSValue(longhand.properties()[2], DoNotUpdateLayout);
     2589    RefPtr<CSSValue> leftValue = getPropertyCSSValue(longhand.properties()[3], DoNotUpdateLayout);
    26222590
    26232591    // All 4 properties must be specified.
  • trunk/Source/WebCore/css/CSSComputedStyleDeclaration.h

    r107407 r112254  
    3030
    3131class CSSPrimitiveValue;
     32class CSSPropertyLonghand;
    3233class CSSValueList;
    3334class CSSValuePool;
     
    110111#endif
    111112
    112     PassRefPtr<CSSValueList> getCSSPropertyValuesForShorthandProperties(const int* properties, size_t) const;
    113     PassRefPtr<CSSValueList> getCSSPropertyValuesForSidesShorthand(const int* properties) const;
     113    PassRefPtr<CSSValueList> getCSSPropertyValuesForShorthandProperties(const CSSPropertyLonghand&) const;
     114    PassRefPtr<CSSValueList> getCSSPropertyValuesForSidesShorthand(const CSSPropertyLonghand&) const;
    114115
    115116    RefPtr<Node> m_node;
  • trunk/Source/WebCore/css/CSSPropertyLonghand.cpp

    r112078 r112254  
    221221{
    222222    static const int outlineProperties[] = {
    223         CSSPropertyOutlineWidth,
     223        CSSPropertyOutlineColor,
    224224        CSSPropertyOutlineStyle,
    225         CSSPropertyOutlineColor,
    226         CSSPropertyOutlineOffset
     225        CSSPropertyOutlineWidth
    227226    };
    228227    DEFINE_STATIC_LOCAL(CSSPropertyLonghand, outlineLonghand, (outlineProperties, WTF_ARRAY_LENGTH(outlineProperties)));
Note: See TracChangeset for help on using the changeset viewer.