Changeset 158967 in webkit


Ignore:
Timestamp:
Nov 8, 2013 3:46:57 PM (10 years ago)
Author:
hmuller@adobe.com
Message:

[CSS Shapes] Image valued shape-outside that extends vertically into the margin-box is top-clipped
https://bugs.webkit.org/show_bug.cgi?id=123769

Reviewed by Dirk Schulze.

Source/WebCore:

Remove the assumption that Y coordinates are >= 0 from the RasterShapeIntervals class
and correct its computeShapeMarginIntervals() method. The computeShapeMarginIntervals()
method now generates intervals with Y coordinates that begin at the image shape's
bounds.y - shape-margin, which may be less than 0.

The RasterShapeIntervals::intervalsAt() method now offsets its Y coordinate parameter
by the shape-margin. A non-const overload of the method was added to centralize all
access to m_intervalLists.

Test: fast/shapes/shape-outside-floats/shape-outside-floats-image-margin-004.html

fast/shapes/shape-outside-floats/shape-outside-floats-image-margin-005.html

  • rendering/shapes/RasterShape.cpp:

(WebCore::MarginIntervalGenerator::intervalAt): Don't clip X coordinates to 0 since they can extend into the margin-box.
(WebCore::RasterShapeIntervals::appendInterval): Use the non-const intervalsAt() method.
(WebCore::RasterShapeIntervals::uniteMarginInterval): Ditto.
(WebCore::RasterShapeIntervals::computeShapeMarginIntervals): See above.

  • rendering/shapes/RasterShape.h:

(WebCore::RasterShapeIntervals::RasterShapeIntervals): Added a field for the margin.
(WebCore::RasterShapeIntervals::intervalsAt): Offset y coordinates by the margin; added a non-const overload.

LayoutTests:

Verify that lines overlap a shape-outside that extends into the top of the margin-box
do wrap around the top of the shape as well its side and bottom.

  • fast/shapes/shape-outside-floats/shape-outside-floats-image-margin-004-expected.html: Added.
  • fast/shapes/shape-outside-floats/shape-outside-floats-image-margin-004.html: Added.
  • fast/shapes/shape-outside-floats/shape-outside-floats-image-margin-005-expected.html: Added.
  • fast/shapes/shape-outside-floats/shape-outside-floats-image-margin-005.html: Added.
Location:
trunk
Files:
4 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r158965 r158967  
     12013-11-08  Hans Muller  <hmuller@adobe.com>
     2
     3        [CSS Shapes] Image valued shape-outside that extends vertically into the margin-box is top-clipped
     4        https://bugs.webkit.org/show_bug.cgi?id=123769
     5
     6        Reviewed by Dirk Schulze.
     7
     8        Verify that lines overlap a shape-outside that extends into the top of the margin-box
     9        do wrap around the top of the shape as well its side and bottom.
     10
     11        * fast/shapes/shape-outside-floats/shape-outside-floats-image-margin-004-expected.html: Added.
     12        * fast/shapes/shape-outside-floats/shape-outside-floats-image-margin-004.html: Added.
     13        * fast/shapes/shape-outside-floats/shape-outside-floats-image-margin-005-expected.html: Added.
     14        * fast/shapes/shape-outside-floats/shape-outside-floats-image-margin-005.html: Added.
     15
    1162013-11-08  Piotr Grad  <p.grad@samsung.com>
    217
  • trunk/Source/WebCore/ChangeLog

    r158965 r158967  
     12013-11-08  Hans Muller  <hmuller@adobe.com>
     2
     3        [CSS Shapes] Image valued shape-outside that extends vertically into the margin-box is top-clipped
     4        https://bugs.webkit.org/show_bug.cgi?id=123769
     5
     6        Reviewed by Dirk Schulze.
     7
     8        Remove the assumption that Y coordinates are >= 0 from the RasterShapeIntervals class
     9        and correct its computeShapeMarginIntervals() method. The computeShapeMarginIntervals()
     10        method now generates intervals with Y coordinates that begin at the image shape's
     11        bounds.y - shape-margin, which may be less than 0.
     12
     13        The RasterShapeIntervals::intervalsAt() method now offsets its Y coordinate parameter
     14        by the shape-margin. A non-const overload of the method was added to centralize all
     15        access to m_intervalLists.
     16
     17        Test: fast/shapes/shape-outside-floats/shape-outside-floats-image-margin-004.html
     18              fast/shapes/shape-outside-floats/shape-outside-floats-image-margin-005.html
     19
     20        * rendering/shapes/RasterShape.cpp:
     21        (WebCore::MarginIntervalGenerator::intervalAt): Don't clip X coordinates to 0 since they can extend into the margin-box.
     22        (WebCore::RasterShapeIntervals::appendInterval): Use the non-const intervalsAt() method.
     23        (WebCore::RasterShapeIntervals::uniteMarginInterval): Ditto.
     24        (WebCore::RasterShapeIntervals::computeShapeMarginIntervals): See above.
     25        * rendering/shapes/RasterShape.h:
     26        (WebCore::RasterShapeIntervals::RasterShapeIntervals): Added a field for the margin.
     27        (WebCore::RasterShapeIntervals::intervalsAt): Offset y coordinates by the margin; added a non-const overload.
     28
    1292013-11-08  Piotr Grad  <p.grad@samsung.com>
    230
  • trunk/Source/WebCore/rendering/shapes/RasterShape.cpp

    r158898 r158967  
    7171    unsigned xInterceptsIndex = abs(y - m_y);
    7272    int dx = (xInterceptsIndex >= m_xIntercepts.size()) ? 0 : m_xIntercepts[xInterceptsIndex];
    73     return IntShapeInterval(std::max(0, m_x1 - dx), m_x2 + dx);
     73    return IntShapeInterval(m_x1 - dx, m_x2 + dx);
    7474}
    7575
    7676void RasterShapeIntervals::appendInterval(int y, int x1, int x2)
    7777{
    78     ASSERT(y >= 0 && y < size() && x1 >= 0 && x2 > x1 && (m_intervalLists[y].isEmpty() || x1 > m_intervalLists[y].last().x2()));
    79 
     78    ASSERT(x2 > x1 && (intervalsAt(y).isEmpty() || x1 > intervalsAt(y).last().x2()));
    8079    m_bounds.unite(IntRect(x1, y, x2 - x1, 1));
    81     m_intervalLists[y].append(IntShapeInterval(x1, x2));
     80    intervalsAt(y).append(IntShapeInterval(x1, x2));
    8281}
    8382
    8483void RasterShapeIntervals::uniteMarginInterval(int y, const IntShapeInterval& interval)
    8584{
    86     ASSERT(m_intervalLists[y].size() <= 1); // Each m_intervalLists entry has 0 or one interval.
    87 
    88     if (m_intervalLists[y].isEmpty())
    89         m_intervalLists[y].append(interval);
     85    ASSERT(intervalsAt(y).size() <= 1); // Each m_intervalLists entry has 0 or one interval.
     86
     87    if (intervalsAt(y).isEmpty())
     88        intervalsAt(y).append(interval);
    9089    else {
    91         IntShapeInterval& resultInterval = m_intervalLists[y][0];
     90        IntShapeInterval& resultInterval = intervalsAt(y)[0];
    9291        resultInterval.set(std::min(resultInterval.x1(), interval.x1()), std::max(resultInterval.x2(), interval.x2()));
    9392    }
     
    219218// Currently limited to computing the margin boundary for shape-outside for floats, see https://bugs.webkit.org/show_bug.cgi?id=116348.
    220219
    221 PassOwnPtr<RasterShapeIntervals> RasterShapeIntervals::computeShapeMarginIntervals(unsigned margin) const
    222 {
    223     OwnPtr<RasterShapeIntervals> result = adoptPtr(new RasterShapeIntervals(size() + margin));
    224     MarginIntervalGenerator marginIntervalGenerator(margin);
    225 
    226     for (int y = bounds().y(); y < bounds().maxY(); ++y) {
     220PassOwnPtr<RasterShapeIntervals> RasterShapeIntervals::computeShapeMarginIntervals(unsigned shapeMargin) const
     221{
     222    OwnPtr<RasterShapeIntervals> result = adoptPtr(new RasterShapeIntervals(size(), shapeMargin));
     223    MarginIntervalGenerator marginIntervalGenerator(shapeMargin);
     224
     225    int minY = bounds().y();
     226    int maxY = bounds().maxY();
     227
     228    for (int y = minY; y < maxY; ++y) {
    227229        const IntShapeInterval& intervalAtY = limitIntervalAt(y);
    228230        if (intervalAtY.isEmpty())
     
    230232
    231233        marginIntervalGenerator.set(y, intervalAtY);
    232         int marginY0 = std::max(0, clampToPositiveInteger(y - margin));
    233         int marginY1 = std::min(result->size() - 1, clampToPositiveInteger(y + margin));
     234        int marginY0 = y - clampToInteger(shapeMargin);
     235        int marginY1 = y + clampToInteger(shapeMargin);
    234236
    235237        for (int marginY = y - 1; marginY >= marginY0; --marginY) {
    236             if (limitIntervalAt(marginY).contains(intervalAtY))
     238            if (marginY > minY && limitIntervalAt(marginY).contains(intervalAtY))
    237239                break;
    238240            result->uniteMarginInterval(marginY, marginIntervalGenerator.intervalAt(marginY));
     
    242244
    243245        for (int marginY = y + 1; marginY <= marginY1; ++marginY) {
    244             if (marginY < size() && limitIntervalAt(marginY).contains(intervalAtY))
     246            if (marginY < maxY && limitIntervalAt(marginY).contains(intervalAtY))
    245247                break;
    246248            result->uniteMarginInterval(marginY, marginIntervalGenerator.intervalAt(marginY));
  • trunk/Source/WebCore/rendering/shapes/RasterShape.h

    r157574 r158967  
    4141class RasterShapeIntervals {
    4242public:
    43     RasterShapeIntervals(unsigned size)
     43    RasterShapeIntervals(unsigned size, unsigned shapeMargin = 0)
     44        : m_shapeMargin(shapeMargin)
    4445    {
    45         m_intervalLists.resize(size);
     46        m_intervalLists.resize(size + shapeMargin * 2);
    4647    }
    4748
     
    5354    void getExcludedIntervals(int y1, int y2, IntShapeIntervals& result) const;
    5455    bool firstIncludedIntervalY(int minY, const IntSize& minSize, LayoutUnit& result) const;
    55     PassOwnPtr<RasterShapeIntervals> computeShapeMarginIntervals(unsigned margin) const;
     56    PassOwnPtr<RasterShapeIntervals> computeShapeMarginIntervals(unsigned shapeMargin) const;
    5657
    5758private:
    5859    int size() const { return m_intervalLists.size(); }
    5960
     61    IntShapeIntervals& intervalsAt(int y)
     62    {
     63        ASSERT(y + m_shapeMargin >= 0 && y + m_shapeMargin < m_intervalLists.size());
     64        return m_intervalLists[y + m_shapeMargin];
     65    }
     66
    6067    const IntShapeIntervals& intervalsAt(int y) const
    6168    {
    62         ASSERT(y >= 0 && y < size());
    63         return m_intervalLists[y];
     69        ASSERT(y + m_shapeMargin >= 0 && y + m_shapeMargin < m_intervalLists.size());
     70        return m_intervalLists[y + m_shapeMargin];
    6471    }
    6572
     
    7582    IntRect m_bounds;
    7683    Vector<IntShapeIntervals> m_intervalLists;
     84    unsigned m_shapeMargin;
    7785};
    7886
Note: See TracChangeset for help on using the changeset viewer.