⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 197097 in webkit


Ignore:
Timestamp:
Feb 25, 2016, 4:01:32 AM (11 years ago)
Author:
Carlos Garcia Campos
Message:

Merge r196960 - Repeated background images have the wrong position when using bottom/right-relative background-position
​https://bugs.webkit.org/show_bug.cgi?id=154478

Reviewed by Dave Hyatt.
Source/WebCore:

Fix RenderBoxModelObject::calculateBackgroundImageGeometry() to use the right position when
painting repeated background images when right/bottom edges are used.

Also rename BackgroundEdgeOrigin to Edge

Test: fast/images/background-position.html

  • css/CSSPrimitiveValueMappings.h:

(WebCore::CSSPrimitiveValue::CSSPrimitiveValue):
(WebCore::CSSPrimitiveValue::operator Edge):
(WebCore::CSSPrimitiveValue::operator BackgroundEdgeOrigin): Deleted.

  • rendering/RenderBoxModelObject.cpp:

(WebCore::resolveEdgeRelativeLength):
(WebCore::RenderBoxModelObject::calculateBackgroundImageGeometry):

  • rendering/style/FillLayer.cpp:

(WebCore::FillLayer::FillLayer):

  • rendering/style/FillLayer.h:

(WebCore::FillLayer::backgroundXOrigin):
(WebCore::FillLayer::backgroundYOrigin):
(WebCore::FillLayer::setBackgroundXOrigin):
(WebCore::FillLayer::setBackgroundYOrigin):

  • rendering/style/RenderStyleConstants.cpp:

(WebCore::operator<<):

  • rendering/style/RenderStyleConstants.h:

LayoutTests:

Enhanced background-position-serialize.html to test values that use right/bottom edge specifiers.

Ref test for background-position.

  • fast/css/background-position-serialize-expected.txt:
  • fast/css/background-position-serialize.html:
  • fast/images/background-position-expected.html: Added.
  • fast/images/background-position.html: Added.
  • fast/images/resources/checker.png: Added.
Location:
releases/WebKitGTK/webkit-2.12
Files:
2 added
10 edited

Legend:

Unmodified
Added
Removed
  • releases/WebKitGTK/webkit-2.12/LayoutTests/ChangeLog

    r197095 r197097  
     12016-02-22  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Repeated background images have the wrong position when using bottom/right-relative background-position
     4        https://bugs.webkit.org/show_bug.cgi?id=154478
     5
     6        Reviewed by Dave Hyatt.
     7       
     8        Enhanced background-position-serialize.html to test values that use right/bottom edge specifiers.
     9       
     10        Ref test for background-position.
     11
     12        * fast/css/background-position-serialize-expected.txt:
     13        * fast/css/background-position-serialize.html:
     14        * fast/images/background-position-expected.html: Added.
     15        * fast/images/background-position.html: Added.
     16        * fast/images/resources/checker.png: Added.
     17
    1182016-02-21  Chris Dumez  <cdumez@apple.com>
    219
  • releases/WebKitGTK/webkit-2.12/LayoutTests/fast/css/background-position-serialize-expected.txt

    r112177 r197097  
    5757PASS: t.style.backgroundPositionY should be 15px, 25px, 35px and is.
    5858PASS: t.style.cssText should be background-position: 10px 15px, 20px 25px, 30px 35px; and is.
     59t.setAttribute('style', 'background-position: bottom 10px right 20px');
     60PASS: t.style.backgroundPosition should be right 20px bottom 10px and is.
     61PASS: window.getComputedStyle(t).backgroundPosition should be right 20px bottom 10px and is.
     62t.setAttribute('style', 'background-position: top 10px right 20px');
     63PASS: t.style.backgroundPosition should be right 20px top 10px and is.
     64PASS: window.getComputedStyle(t).backgroundPosition should be right 20px top 10px and is.
     65t.setAttribute('style', 'background-position: 50% left');
     66PASS: t.style.backgroundPosition should be and is.
     67t.setAttribute('style', 'background-position-x: right 20px');
     68PASS: window.getComputedStyle(t).backgroundPositionX should be 0% and is.
     69t.setAttribute('style', 'background-position: right 20px bottom 10px');
     70PASS: window.getComputedStyle(t).backgroundPosition should be right 20px bottom 10px and is.
     71PASS: window.getComputedStyle(t).backgroundPositionX should be 20px and is.
    5972t.setAttribute('style', 'background: url(about:blank) 80% 80%;');
    6073t.style.backgroundPositionY = '50px'
  • releases/WebKitGTK/webkit-2.12/LayoutTests/fast/css/background-position-serialize.html

    r126656 r197097  
    11<html>
    22<body>
    3 <div id=t></div>
    4 <div id=console></div>
     3<div id="t"></div>
     4<div id="console"></div>
    55<script>
    66function print(message, color)
    … …  
    112112shouldBe("t.style.cssText", "background-position: 10px 15px, 20px 25px, 30px 35px;");
    113113
     114run("t.setAttribute('style', 'background-position: bottom 10px right 20px');");
     115shouldBe("t.style.backgroundPosition", "right 20px bottom 10px");
     116shouldBe("window.getComputedStyle(t).backgroundPosition", "right 20px bottom 10px");
     117
     118run("t.setAttribute('style', 'background-position: top 10px right 20px');");
     119shouldBe("t.style.backgroundPosition", "right 20px top 10px");
     120shouldBe("window.getComputedStyle(t).backgroundPosition", "right 20px top 10px");
     121
     122run("t.setAttribute('style', 'background-position: 50% left');"); // Invalid per spec.
     123shouldBe("t.style.backgroundPosition", "");
     124
     125run("t.setAttribute('style', 'background-position-x: right 20px');"); // This does not parse, but perhaps it should.
     126shouldBe("window.getComputedStyle(t).backgroundPositionX", "0%");
     127
     128run("t.setAttribute('style', 'background-position: right 20px bottom 10px');");
     129shouldBe("window.getComputedStyle(t).backgroundPosition", "right 20px bottom 10px");
     130shouldBe("window.getComputedStyle(t).backgroundPositionX", "20px"); // This is a bug. webkit.org/b/154551
     131
    114132run("t.setAttribute('style', 'background: url(about:blank) 80% 80%;');");
    115133run("t.style.backgroundPositionY = '50px'");
  • releases/WebKitGTK/webkit-2.12/Source/WebCore/ChangeLog

    r197091 r197097  
     12016-02-22  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Repeated background images have the wrong position when using bottom/right-relative background-position
     4        https://bugs.webkit.org/show_bug.cgi?id=154478
     5
     6        Reviewed by Dave Hyatt.
     7
     8        Fix RenderBoxModelObject::calculateBackgroundImageGeometry() to use the right position when
     9        painting repeated background images when right/bottom edges are used.
     10
     11        Also rename BackgroundEdgeOrigin to Edge
     12
     13        Test: fast/images/background-position.html
     14
     15        * css/CSSPrimitiveValueMappings.h:
     16        (WebCore::CSSPrimitiveValue::CSSPrimitiveValue):
     17        (WebCore::CSSPrimitiveValue::operator Edge):
     18        (WebCore::CSSPrimitiveValue::operator BackgroundEdgeOrigin): Deleted.
     19        * rendering/RenderBoxModelObject.cpp:
     20        (WebCore::resolveEdgeRelativeLength):
     21        (WebCore::RenderBoxModelObject::calculateBackgroundImageGeometry):
     22        * rendering/style/FillLayer.cpp:
     23        (WebCore::FillLayer::FillLayer):
     24        * rendering/style/FillLayer.h:
     25        (WebCore::FillLayer::backgroundXOrigin):
     26        (WebCore::FillLayer::backgroundYOrigin):
     27        (WebCore::FillLayer::setBackgroundXOrigin):
     28        (WebCore::FillLayer::setBackgroundYOrigin):
     29        * rendering/style/RenderStyleConstants.cpp:
     30        (WebCore::operator<<):
     31        * rendering/style/RenderStyleConstants.h:
     32
    1332016-02-21  Chris Dumez  <cdumez@apple.com>
    234
  • releases/WebKitGTK/webkit-2.12/Source/WebCore/css/CSSPrimitiveValueMappings.h

    r196075 r197097  
    903903#endif
    904904
    905 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(BackgroundEdgeOrigin e)
    906     : CSSValue(PrimitiveClass)
    907 {
    908     m_primitiveUnitType = CSS_VALUE_ID;
    909     switch (e) {
    910     case TopEdge:
     905template<> inline CSSPrimitiveValue::CSSPrimitiveValue(Edge e)
     906    : CSSValue(PrimitiveClass)
     907{
     908    m_primitiveUnitType = CSS_VALUE_ID;
     909    switch (e) {
     910    case Edge::Top:
    911911        m_value.valueID = CSSValueTop;
    912912        break;
    913     case RightEdge:
     913    case Edge::Right:
    914914        m_value.valueID = CSSValueRight;
    915915        break;
    916     case BottomEdge:
     916    case Edge::Bottom:
    917917        m_value.valueID = CSSValueBottom;
    918918        break;
    919     case LeftEdge:
     919    case Edge::Left:
    920920        m_value.valueID = CSSValueLeft;
    921921        break;
    … …  
    923923}
    924924
    925 template<> inline CSSPrimitiveValue::operator BackgroundEdgeOrigin() const
     925template<> inline CSSPrimitiveValue::operator Edge() const
    926926{
    927927    ASSERT(isValueID());
    … …  
    929929    switch (m_value.valueID) {
    930930    case CSSValueTop:
    931         return TopEdge;
     931        return Edge::Top;
    932932    case CSSValueRight:
    933         return RightEdge;
     933        return Edge::Right;
    934934    case CSSValueBottom:
    935         return BottomEdge;
     935        return Edge::Bottom;
    936936    case CSSValueLeft:
    937         return LeftEdge;
    938     default:
    939         break;
    940     }
    941 
    942     ASSERT_NOT_REACHED();
    943     return TopEdge;
     937        return Edge::Left;
     938    default:
     939        break;
     940    }
     941
     942    ASSERT_NOT_REACHED();
     943    return Edge::Top;
    944944}
    945945
  • releases/WebKitGTK/webkit-2.12/Source/WebCore/rendering/RenderBoxModelObject.cpp

    r195848 r197097  
    10451045}
    10461046
     1047static LayoutUnit resolveEdgeRelativeLength(const Length& length, Edge edge, LayoutUnit availableSpace, const LayoutSize& areaSize, const LayoutSize& tileSize)
     1048{
     1049    LayoutUnit result = minimumValueForLength(length, availableSpace, false);
     1050
     1051    if (edge == Edge::Right)
     1052        return areaSize.width() - tileSize.width() - result;
     1053   
     1054    if (edge == Edge::Bottom)
     1055        return areaSize.height() - tileSize.height() - result;
     1056
     1057    return result;
     1058}
     1059
    10471060BackgroundImageGeometry RenderBoxModelObject::calculateBackgroundImageGeometry(const RenderLayerModelObject* paintContainer, const FillLayer& fillLayer, const LayoutPoint& paintOffset,
    10481061    const LayoutRect& borderBoxRect, RenderElement* backgroundObject) const
    … …  
    11481161    LayoutSize phase;
    11491162    LayoutSize noRepeat;
    1150     LayoutUnit computedXPosition = minimumValueForLength(fillLayer.xPosition(), availableWidth, false);
     1163    LayoutUnit computedXPosition = resolveEdgeRelativeLength(fillLayer.xPosition(), fillLayer.backgroundXOrigin(), availableWidth, positioningAreaSize, tileSize);
    11511164    if (backgroundRepeatX == RoundFill && positioningAreaSize.width() > 0 && tileSize.width() > 0) {
    11521165        int numTiles = std::max(1, roundToInt(positioningAreaSize.width() / tileSize.width()));
    … …  
    11581171    }
    11591172
    1160     LayoutUnit computedYPosition = minimumValueForLength(fillLayer.yPosition(), availableHeight, false);
     1173    LayoutUnit computedYPosition = resolveEdgeRelativeLength(fillLayer.yPosition(), fillLayer.backgroundYOrigin(), availableHeight, positioningAreaSize, tileSize);
    11611174    if (backgroundRepeatY == RoundFill && positioningAreaSize.height() > 0 && tileSize.height() > 0) {
    11621175        int numTiles = std::max(1, roundToInt(positioningAreaSize.height() / tileSize.height()));
    … …  
    11821195            backgroundRepeatX = NoRepeatFill;
    11831196    }
     1197
    11841198    if (backgroundRepeatX == NoRepeatFill) {
    1185         LayoutUnit xOffset = left + (fillLayer.backgroundXOrigin() == RightEdge ? availableWidth - computedXPosition : computedXPosition);
     1199        LayoutUnit xOffset = left + computedXPosition;
    11861200        if (xOffset > 0)
    11871201            destinationRect.move(xOffset, 0);
    … …  
    12071221    }
    12081222    if (backgroundRepeatY == NoRepeatFill) {
    1209         LayoutUnit yOffset = top + (fillLayer.backgroundYOrigin() == BottomEdge ? availableHeight - computedYPosition : computedYPosition);
     1223        LayoutUnit yOffset = top + computedYPosition;
    12101224        if (yOffset > 0)
    12111225            destinationRect.move(0, yOffset);
  • releases/WebKitGTK/webkit-2.12/Source/WebCore/rendering/style/FillLayer.cpp

    r194496 r197097  
    6666    , m_yPosSet(false)
    6767    , m_backgroundOriginSet(false)
    68     , m_backgroundXOrigin(LeftEdge)
    69     , m_backgroundYOrigin(TopEdge)
     68    , m_backgroundXOrigin(static_cast<unsigned>(Edge::Left))
     69    , m_backgroundYOrigin(static_cast<unsigned>(Edge::Top))
    7070    , m_compositeSet(type == MaskFillLayer)
    7171    , m_blendModeSet(false)
  • releases/WebKitGTK/webkit-2.12/Source/WebCore/rendering/style/FillLayer.h

    r194496 r197097  
    7171    const Length& xPosition() const { return m_xPosition; }
    7272    const Length& yPosition() const { return m_yPosition; }
    73     BackgroundEdgeOrigin backgroundXOrigin() const { return static_cast<BackgroundEdgeOrigin>(m_backgroundXOrigin); }
    74     BackgroundEdgeOrigin backgroundYOrigin() const { return static_cast<BackgroundEdgeOrigin>(m_backgroundYOrigin); }
     73    Edge backgroundXOrigin() const { return static_cast<Edge>(m_backgroundXOrigin); }
     74    Edge backgroundYOrigin() const { return static_cast<Edge>(m_backgroundYOrigin); }
    7575    EFillAttachment attachment() const { return static_cast<EFillAttachment>(m_attachment); }
    7676    EFillBox clip() const { return static_cast<EFillBox>(m_clip); }
    … …  
    105105    void setXPosition(Length length) { m_xPosition = WTFMove(length); m_xPosSet = true; }
    106106    void setYPosition(Length length) { m_yPosition = WTFMove(length); m_yPosSet = true; }
    107     void setBackgroundXOrigin(BackgroundEdgeOrigin o) { m_backgroundXOrigin = o; m_backgroundOriginSet = true; }
    108     void setBackgroundYOrigin(BackgroundEdgeOrigin o) { m_backgroundYOrigin = o; m_backgroundOriginSet = true; }
     107    void setBackgroundXOrigin(Edge o) { m_backgroundXOrigin = static_cast<unsigned>(o); m_backgroundOriginSet = true; }
     108    void setBackgroundYOrigin(Edge o) { m_backgroundYOrigin = static_cast<unsigned>(o); m_backgroundOriginSet = true; }
    109109    void setAttachment(EFillAttachment attachment) { m_attachment = attachment; m_attachmentSet = true; }
    110110    void setClip(EFillBox b) { m_clip = b; m_clipSet = true; }
    … …  
    203203    unsigned m_yPosSet : 1;
    204204    unsigned m_backgroundOriginSet : 1;
    205     unsigned m_backgroundXOrigin : 2; // BackgroundEdgeOrigin
    206     unsigned m_backgroundYOrigin : 2; // BackgroundEdgeOrigin
     205    unsigned m_backgroundXOrigin : 2; // Edge
     206    unsigned m_backgroundYOrigin : 2; // Edge
    207207    unsigned m_compositeSet : 1;
    208208    unsigned m_blendModeSet : 1;
  • releases/WebKitGTK/webkit-2.12/Source/WebCore/rendering/style/RenderStyleConstants.cpp

    r195892 r197097  
    8686}
    8787
    88 TextStream& operator<<(TextStream& ts, BackgroundEdgeOrigin edge)
     88TextStream& operator<<(TextStream& ts, Edge edge)
    8989{
    9090    switch (edge) {
    91     case TopEdge: ts << "top"; break;
    92     case RightEdge: ts << "right"; break;
    93     case BottomEdge: ts << "bottom"; break;
    94     case LeftEdge: ts << "left"; break;
     91    case Edge::Top: ts << "top"; break;
     92    case Edge::Right: ts << "right"; break;
     93    case Edge::Bottom: ts << "bottom"; break;
     94    case Edge::Left: ts << "left"; break;
    9595    }
    9696    return ts;
  • releases/WebKitGTK/webkit-2.12/Source/WebCore/rendering/style/RenderStyleConstants.h

    r196075 r197097  
    231231enum EFillSizeType { Contain, Cover, SizeLength, SizeNone };
    232232
    233 // CSS3 Background Position
    234 enum BackgroundEdgeOrigin { TopEdge, RightEdge, BottomEdge, LeftEdge };
     233// CSS3 <position>
     234enum class Edge { Top, Right, Bottom, Left };
    235235
    236236// CSS3 Mask Source Types
    … …  
    695695TextStream& operator<<(TextStream&, EFillRepeat);
    696696TextStream& operator<<(TextStream&, EMaskSourceType);
    697 TextStream& operator<<(TextStream&, BackgroundEdgeOrigin);
     697TextStream& operator<<(TextStream&, Edge);
    698698
    699699} // namespace WebCore
Note: See TracChangeset for help on using the changeset viewer.