Ignore:
Timestamp:
Dec 3, 2012, 3:55:28 AM (13 years ago)
Author:
[email protected]
Message:

[CSS3 Backgrounds and Borders] Implement CSS3 background-position offsets rendering.
https://bugs.webkit.org/show_bug.cgi?id=103440

Reviewed by Julien Chaffraix.

Source/WebCore:

Add the rendering bits of the new background-position offsets. It adds
new bits in FillLayer to store the edges used to position the
background. The old x and y members are used the same way as before, to
store the value of the offset.

Test: fast/backgrounds/background-position-rendering.html

  • css/CSSComputedStyleDeclaration.cpp:

(WebCore::createPositionListForLayer): Refactor into a function the
code duplicated in getPropertyCSSValue to avoid more code
duplication.
(WebCore):
(WebCore::CSSComputedStyleDeclaration::getPropertyCSSValue):

  • css/CSSPrimitiveValueMappings.h:

(WebCore):
(WebCore::CSSPrimitiveValue::CSSPrimitiveValue):
Add implicit conversion from the enums used in the rendering code to
CSS values.
(WebCore::CSSPrimitiveValue::operator BackgroundEdgeOrigin):

  • css/CSSToStyleMap.cpp:

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

  • rendering/RenderBoxModelObject.cpp:

(WebCore::RenderBoxModelObject::calculateBackgroundImageGeometry): Add
support for the new positioning and refactor a little naming of the
variables for better readability.

  • rendering/style/FillLayer.cpp:

(SameSizeAsFillLayer):
(WebCore::FillLayer::FillLayer):
(WebCore::FillLayer::operator=):
(WebCore::FillLayer::operator==):
(WebCore::FillLayer::fillUnsetProperties):
(WebCore::FillLayer::fillUnsetProperties): When filling the layer with
unset properties make sure we also set the x and y origins of the
background in case they were set.

  • rendering/style/FillLayer.h:

(WebCore::FillLayer::backgroundXOrigin):
(WebCore::FillLayer::backgroundYOrigin):
(WebCore::FillLayer::isBackgroundOriginSet):
(FillLayer):
(WebCore::FillLayer::setBackgroundXOrigin):
(WebCore::FillLayer::setBackgroundYOrigin):
(WebCore::FillLayer::clearPositionX):
(WebCore::FillLayer::clearPositionY):

  • rendering/style/RenderStyleConstants.h:

LayoutTests:

Uncomment the computed style tests from background-position-parsing-2
and add the expected output. Add a new
background-position-rendering test to verify that the background has a
correct position with the new <position> value. I also covered some old
CSS 2.1 values for verification.

  • fast/backgrounds/background-position-parsing-2-expected.txt:
  • fast/backgrounds/background-position-parsing-2.html:
  • fast/backgrounds/background-position-rendering-expected.html: Added.
  • fast/backgrounds/background-position-rendering.html: Added.
  • platform/chromium/TestExpectations:
  • platform/efl/TestExpectations:
  • platform/gtk/TestExpectations:
  • platform/mac/TestExpectations:
  • platform/qt/TestExpectations:
  • platform/win/TestExpectations:
  • platform/wincairo/TestExpectations:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/css/CSSToStyleMap.cpp

    r127045 r136378  
    214214}
    215215
    216 void CSSToStyleMap::mapFillXPosition(CSSPropertyID, FillLayer* layer, CSSValue* value)
     216void CSSToStyleMap::mapFillXPosition(CSSPropertyID propertyID, FillLayer* layer, CSSValue* value)
    217217{
    218218    if (value->isInitialValue()) {
     
    227227
    228228    CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value);
     229#if ENABLE(CSS3_BACKGROUND)
     230    Pair* pair = primitiveValue->getPairValue();
     231    if (pair) {
     232        ASSERT(propertyID == CSSPropertyBackgroundPositionX);
     233        primitiveValue = pair->second();
     234    }
     235#else
     236    UNUSED_PARAM(propertyID);
     237#endif
    229238    Length length;
    230239    if (primitiveValue->isLength())
     
    239248        return;
    240249    layer->setXPosition(length);
    241 }
    242 
    243 void CSSToStyleMap::mapFillYPosition(CSSPropertyID, FillLayer* layer, CSSValue* value)
     250#if ENABLE(CSS3_BACKGROUND)
     251    if (pair)
     252        layer->setBackgroundXOrigin(*(pair->first()));
     253#endif
     254}
     255
     256void CSSToStyleMap::mapFillYPosition(CSSPropertyID propertyID, FillLayer* layer, CSSValue* value)
    244257{
    245258    if (value->isInitialValue()) {
     
    254267
    255268    CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value);
     269#if ENABLE(CSS3_BACKGROUND)
     270    Pair* pair = primitiveValue->getPairValue();
     271    if (pair) {
     272        ASSERT(propertyID == CSSPropertyBackgroundPositionY);
     273        primitiveValue = pair->second();
     274    }
     275#else
     276    UNUSED_PARAM(propertyID);
     277#endif
    256278    Length length;
    257279    if (primitiveValue->isLength())
     
    266288        return;
    267289    layer->setYPosition(length);
     290#if ENABLE(CSS3_BACKGROUND)
     291    if (pair)
     292        layer->setBackgroundYOrigin(*(pair->first()));
     293#endif
    268294}
    269295
Note: See TracChangeset for help on using the changeset viewer.