Changeset 154152 in webkit


Ignore:
Timestamp:
Aug 15, 2013 4:47:18 PM (11 years ago)
Author:
hmuller@adobe.com
Message:

[CSS Shapes] Add support for shape-outside image values
https://bugs.webkit.org/show_bug.cgi?id=119809

Source/WebCore:

Added minimal support for shape-outside image values. A new method that computes
the excluded intervals for a horizontal line segment was added to the RasterIntervals
class. The stub RasterShape getExcludedIntervals() method has been replaced by
one that uses the new method.

Image shapes are represented by a RasterIntervals object, which just encapsulates a
Region object. The new getExcludedIntervals() method computes the excluded intervals
for a horizontal line segment between y1 and y2. To find the excluded intervals we
vertically expand each of the image shape Region's rectangles that fall within the line
segment, so that they begin at y1 and have height = y2 - y1. The union of the expanded
rectangles produces a new Region whose horizontal projection defines the excluded intervals.

Reviewed by Alexandru Chiculita.

Tests: fast/shapes/shape-outside-floats/shape-outside-floats-image-001.html

fast/shapes/shape-outside-floats/shape-outside-floats-image-002.html

  • rendering/shapes/RasterShape.cpp:

(WebCore::RasterShapeIntervals::getExcludedIntervals): See above.
(WebCore::RasterShape::getExcludedIntervals): Stub method has been replaced by one that uses RasterShapeIntervals::getExcludedIntervals().

  • rendering/shapes/RasterShape.h:
  • rendering/shapes/ShapeOutsideInfo.cpp:

(WebCore::ShapeOutsideInfo::isEnabledFor): Enable Image valued shapes.

LayoutTests:

Two tests to verify that the initial implementation of shape valued images is working
for shape-outside.

Reviewed by Alexandru Chiculita.

  • fast/shapes/shape-outside-floats/shape-outside-floats-image-001-expected.html: Added.
  • fast/shapes/shape-outside-floats/shape-outside-floats-image-001.html: Added.
  • fast/shapes/shape-outside-floats/shape-outside-floats-image-002-expected.html: Added.
  • fast/shapes/shape-outside-floats/shape-outside-floats-image-002.html: Added.
Location:
trunk
Files:
4 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r154150 r154152  
     12013-08-15  Hans Muller  <hmuller@adobe.com>
     2
     3        [CSS Shapes] Add support for shape-outside image values
     4        https://bugs.webkit.org/show_bug.cgi?id=119809
     5
     6        Two tests to verify that the initial implementation of shape valued images is working
     7        for shape-outside.
     8
     9        Reviewed by Alexandru Chiculita.
     10
     11        * fast/shapes/shape-outside-floats/shape-outside-floats-image-001-expected.html: Added.
     12        * fast/shapes/shape-outside-floats/shape-outside-floats-image-001.html: Added.
     13        * fast/shapes/shape-outside-floats/shape-outside-floats-image-002-expected.html: Added.
     14        * fast/shapes/shape-outside-floats/shape-outside-floats-image-002.html: Added.
     15
    1162013-08-15  Ryosuke Niwa  <rniwa@webkit.org>
    217
  • trunk/Source/WebCore/ChangeLog

    r154147 r154152  
     12013-08-15  Hans Muller  <hmuller@adobe.com>
     2
     3        [CSS Shapes] Add support for shape-outside image values
     4        https://bugs.webkit.org/show_bug.cgi?id=119809
     5
     6        Added minimal support for shape-outside image values. A new method that computes
     7        the excluded intervals for a horizontal line segment was added to the RasterIntervals
     8        class. The stub RasterShape getExcludedIntervals() method has been replaced by
     9        one that uses the new method.
     10
     11        Image shapes are represented by a RasterIntervals object, which just encapsulates a
     12        Region object. The new getExcludedIntervals() method computes the excluded intervals
     13        for a horizontal line segment between y1 and y2. To find the excluded intervals we
     14        vertically expand each of the image shape Region's rectangles that fall within the line
     15        segment, so that they begin at y1 and have height = y2 - y1. The union of the expanded
     16        rectangles produces a new Region whose horizontal projection defines the excluded intervals.
     17
     18        Reviewed by Alexandru Chiculita.
     19
     20        Tests: fast/shapes/shape-outside-floats/shape-outside-floats-image-001.html
     21               fast/shapes/shape-outside-floats/shape-outside-floats-image-002.html
     22
     23        * rendering/shapes/RasterShape.cpp:
     24        (WebCore::RasterShapeIntervals::getExcludedIntervals): See above.
     25        (WebCore::RasterShape::getExcludedIntervals): Stub method has been replaced by one that uses RasterShapeIntervals::getExcludedIntervals().
     26        * rendering/shapes/RasterShape.h:
     27        * rendering/shapes/ShapeOutsideInfo.cpp:
     28        (WebCore::ShapeOutsideInfo::isEnabledFor): Enable Image valued shapes.
     29
    1302013-08-15  Simon Fraser  <simon.fraser@apple.com>
    231
  • trunk/Source/WebCore/rendering/shapes/RasterShape.cpp

    r154081 r154152  
    8989}
    9090
     91void RasterShapeIntervals::getExcludedIntervals(int y1, int y2, SegmentList& result) const
     92{
     93    ASSERT(y2 >= y1);
     94
     95    IntRect lineRect(bounds().x(), y1, bounds().width(), y2 - y1);
     96    Region lineRegion(lineRect);
     97    lineRegion.intersect(m_region);
     98    if (lineRegion.isEmpty())
     99        return;
     100
     101    Vector<IntRect> lineRects = lineRegion.rects();
     102    ASSERT(lineRects.size() > 0);
     103
     104    Region segmentsRegion;
     105    for (unsigned i = 0; i < lineRects.size(); i++)
     106        segmentsRegion.unite(Region(alignedRect(lineRects[i], y1, y2)));
     107
     108    Vector<IntRect> segmentRects = segmentsRegion.rects();
     109    for (unsigned i = 0; i < segmentRects.size(); i++)
     110        result.append(LineSegment(segmentRects[i].x(), segmentRects[i].maxX() + 1));
     111}
     112
    91113const RasterShapeIntervals& RasterShape::marginIntervals() const
    92114{
     
    109131}
    110132
    111 void RasterShape::getExcludedIntervals(LayoutUnit, LayoutUnit, SegmentList&) const
     133void RasterShape::getExcludedIntervals(LayoutUnit logicalTop, LayoutUnit logicalHeight, SegmentList& result) const
    112134{
    113     // FIXME: this method is only a stub, see https://bugs.webkit.org/show_bug.cgi?id=119809.
     135    const RasterShapeIntervals& intervals = marginIntervals();
     136    if (intervals.isEmpty())
     137        return;
     138
     139    float y1 = logicalTop;
     140    float y2 = logicalTop + logicalHeight;
     141
     142    if (y2 < intervals.bounds().y() || y1 >= intervals.bounds().maxY())
     143        return;
     144
     145    intervals.getExcludedIntervals(y1, y2, result);
    114146}
    115147
  • trunk/Source/WebCore/rendering/shapes/RasterShape.h

    r154081 r154152  
    4747    void addInterval(int y, int x1, int x2);
    4848    void getIncludedIntervals(int y1, int y2, SegmentList&) const;
     49    void getExcludedIntervals(int y1, int y2, SegmentList&) const;
    4950
    5051private:
  • trunk/Source/WebCore/rendering/shapes/ShapeOutsideInfo.cpp

    r154081 r154152  
    4747        return shapeValue->shape();
    4848    case ShapeValue::Image:
    49         return false; // FIXME, see https://bugs.webkit.org/show_bug.cgi?id=119809.
     49        return shapeValue->isImageValid();
    5050    default:
    5151        return false;
Note: See TracChangeset for help on using the changeset viewer.