Changeset 207556 in webkit


Ignore:
Timestamp:
Oct 19, 2016 12:19:27 PM (8 years ago)
Author:
hyatt@apple.com
Message:

[CSS Parser] Fix background-position parsing
https://bugs.webkit.org/show_bug.cgi?id=163681

Reviewed by Dean Jackson.

The new parser has a more efficient parsed representation of background positions. When
background-position is "center" or when no length unit is specified for a dimension,
then rather than creating a pair, the new parser makes a singleton primitive value.

Patch the StyleBuilder code to handle this case, resolving center to (left,50%) or
(top,50%) as appropriate and also handling top/left without any associated length.

  • css/CSSToStyleMap.cpp:

(WebCore::CSSToStyleMap::mapFillXPosition):
(WebCore::CSSToStyleMap::mapFillYPosition):

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r207554 r207556  
     12016-10-19  Dave Hyatt  <hyatt@apple.com>
     2
     3        [CSS Parser] Fix background-position parsing
     4        https://bugs.webkit.org/show_bug.cgi?id=163681
     5
     6        Reviewed by Dean Jackson.
     7
     8        The new parser has a more efficient parsed representation of background positions. When
     9        background-position is "center" or when no length unit is specified for a dimension,
     10        then rather than creating a pair, the new parser makes a singleton primitive value.
     11
     12        Patch the StyleBuilder code to handle this case, resolving center to (left,50%) or
     13        (top,50%) as appropriate and also handling top/left without any associated length.
     14
     15        * css/CSSToStyleMap.cpp:
     16        (WebCore::CSSToStyleMap::mapFillXPosition):
     17        (WebCore::CSSToStyleMap::mapFillYPosition):
     18
    1192016-10-19  Antoine Quint  <graouts@apple.com>
    220
  • trunk/Source/WebCore/css/CSSToStyleMap.cpp

    r207396 r207556  
    239239        ASSERT_UNUSED(propertyID, propertyID == CSSPropertyBackgroundPositionX || propertyID == CSSPropertyWebkitMaskPositionX);
    240240        primitiveValue = pair->second();
     241    } else if (primitiveValue->isValueID()) {
     242        if (primitiveValue->valueID() == CSSValueCenter) {
     243            layer.setBackgroundXOrigin(Edge::Left);
     244            layer.setXPosition(Length(50, Percent));
     245        } else {
     246            layer.setBackgroundXOrigin(*primitiveValue);
     247            layer.setXPosition(Length());
     248        }
     249        return;
    241250    }
    242251
     
    271280        ASSERT_UNUSED(propertyID, propertyID == CSSPropertyBackgroundPositionY || propertyID == CSSPropertyWebkitMaskPositionY);
    272281        primitiveValue = pair->second();
     282    } else if (primitiveValue->isValueID()) {
     283        if (primitiveValue->valueID() == CSSValueCenter) {
     284            layer.setBackgroundYOrigin(Edge::Top);
     285            layer.setYPosition(Length(50, Percent));
     286        } else {
     287            layer.setBackgroundYOrigin(*primitiveValue);
     288            layer.setYPosition(Length());
     289        }
     290        return;
    273291    }
    274292
Note: See TracChangeset for help on using the changeset viewer.