Changeset 142164 in webkit


Ignore:
Timestamp:
Feb 7, 2013 12:50:21 PM (11 years ago)
Author:
commit-queue@webkit.org
Message:

[CSS Exclusions] shape-inside does not properly handle padding or border
https://bugs.webkit.org/show_bug.cgi?id=102715

Patch by Bear Travis <betravis@adobe.com> on 2013-02-07
Reviewed by David Hyatt.

Source/WebCore:

This patch positions the exclusion shape based on the value of the css box sizing
property. Geometry calculations happen in the shape coordinate space. For layout,
these coordinates are translated to the border-box coordinate system by adding
the appropriate offsets.

Test: fast/exclusions/shape-inside/shape-inside-box-sizing.html

  • rendering/ExclusionShapeInfo.cpp:

(WebCore::::computedShape): Pass m_shapeLogicalWidth to the exclusion shape
geometry code.

  • rendering/ExclusionShapeInfo.h:

(WebCore::ExclusionShapeInfo::setShapeSize): Adjust block layout dimensions to
shape dimensions when checking to see if the shape geometry must be recalculated.
(WebCore::ExclusionShapeInfo::shapeLogicalTop): Account for layout offsets.
(WebCore::ExclusionShapeInfo::shapeLogicalBottom): Ditto.
(WebCore::ExclusionShapeInfo::shapeLogicalLeft): Ditto.
(WebCore::ExclusionShapeInfo::shapeLogicalRight): Ditto.
(WebCore::ExclusionShapeInfo::logicalTopOffset): Return the offset from the logical
top of the border box to the logical top of the shape.
(WebCore::ExclusionShapeInfo::logicalLeftOffset): Return the offset from the logical
left of the border box to the logical left of the shape.
(ExclusionShapeInfo):

  • rendering/ExclusionShapeInsideInfo.cpp:

(WebCore::ExclusionShapeInsideInfo::computeSegmentsForLine): Adjust line top to
be in shape coordinates.
(WebCore::ExclusionShapeInsideInfo::adjustLogicalLineTop): Ditto.

  • rendering/ExclusionShapeInsideInfo.h:

(WebCore::ExclusionShapeInsideInfo::lineOverlapsShapeBounds): Use consistent
coordinate system (border box) to test for whether a line overlaps a shape.
(WebCore::ExclusionShapeInsideInfo::logicalLineTop): Include the logical offset
from the border box.
(WebCore::ExclusionShapeInsideInfo::logicalLineBottom): Ditto.

LayoutTests:

Test that borders and padding are properly accounted for when laying out text in
a shape inside.

  • fast/exclusions/shape-inside/shape-inside-bottom-edge.html: Modified to no longer

use padding.

  • fast/exclusions/shape-inside/shape-inside-box-sizing-expected.html: Added.
  • fast/exclusions/shape-inside/shape-inside-box-sizing.html: Added.
Location:
trunk
Files:
2 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r142152 r142164  
     12013-02-07  Bear Travis  <betravis@adobe.com>
     2
     3        [CSS Exclusions] shape-inside does not properly handle padding or border
     4        https://bugs.webkit.org/show_bug.cgi?id=102715
     5
     6        Reviewed by David Hyatt.
     7
     8        Test that borders and padding are properly accounted for when laying out text in
     9        a shape inside.
     10
     11        * fast/exclusions/shape-inside/shape-inside-bottom-edge.html: Modified to no longer
     12        use padding.
     13        * fast/exclusions/shape-inside/shape-inside-box-sizing-expected.html: Added.
     14        * fast/exclusions/shape-inside/shape-inside-box-sizing.html: Added.
     15
    1162013-01-27  Robert Hogan  <robert@webkit.org>
    217
  • trunk/LayoutTests/fast/exclusions/shape-inside/shape-inside-bottom-edge.html

    r132127 r142164  
    2929#shape-inside-no-overlap {
    3030    top: 0px;
    31     padding-top: 150px;
    3231}
    33 
     32#shape-inside-no-overlap::before, #shape-inside-overlap::before {
     33    display: block;
     34    height: 150px;
     35    content: ' ';
     36}
     37#shape-inside-overlap::before {
     38    height: 149.9px;
     39}
    3440#shape-background-overlap {
    3541    top: 250px;
     
    3844#shape-inside-overlap {
    3945    top: 200px;
    40     padding-top: 149.9px;
    4146}
    4247</style>
  • trunk/Source/WebCore/ChangeLog

    r142163 r142164  
     12013-02-07  Bear Travis  <betravis@adobe.com>
     2
     3        [CSS Exclusions] shape-inside does not properly handle padding or border
     4        https://bugs.webkit.org/show_bug.cgi?id=102715
     5
     6        Reviewed by David Hyatt.
     7
     8        This patch positions the exclusion shape based on the value of the css box sizing
     9        property. Geometry calculations happen in the shape coordinate space. For layout,
     10        these coordinates are translated to the border-box coordinate system by adding
     11        the appropriate offsets.
     12
     13        Test: fast/exclusions/shape-inside/shape-inside-box-sizing.html
     14
     15        * rendering/ExclusionShapeInfo.cpp:
     16        (WebCore::::computedShape): Pass m_shapeLogicalWidth to the exclusion shape
     17        geometry code.
     18        * rendering/ExclusionShapeInfo.h:
     19        (WebCore::ExclusionShapeInfo::setShapeSize): Adjust block layout dimensions to
     20        shape dimensions when checking to see if the shape geometry must be recalculated.
     21        (WebCore::ExclusionShapeInfo::shapeLogicalTop): Account for layout offsets.
     22        (WebCore::ExclusionShapeInfo::shapeLogicalBottom): Ditto.
     23        (WebCore::ExclusionShapeInfo::shapeLogicalLeft): Ditto.
     24        (WebCore::ExclusionShapeInfo::shapeLogicalRight): Ditto.
     25        (WebCore::ExclusionShapeInfo::logicalTopOffset): Return the offset from the logical
     26        top of the border box to the logical top of the shape.
     27        (WebCore::ExclusionShapeInfo::logicalLeftOffset): Return the offset from the logical
     28        left of the border box to the logical left of the shape.
     29        (ExclusionShapeInfo):
     30        * rendering/ExclusionShapeInsideInfo.cpp:
     31        (WebCore::ExclusionShapeInsideInfo::computeSegmentsForLine): Adjust line top to
     32        be in shape coordinates.
     33        (WebCore::ExclusionShapeInsideInfo::adjustLogicalLineTop): Ditto.
     34        * rendering/ExclusionShapeInsideInfo.h:
     35        (WebCore::ExclusionShapeInsideInfo::lineOverlapsShapeBounds): Use consistent
     36        coordinate system (border box) to test for whether a line overlaps a shape.
     37        (WebCore::ExclusionShapeInsideInfo::logicalLineTop): Include the logical offset
     38        from the border box.
     39        (WebCore::ExclusionShapeInsideInfo::logicalLineBottom): Ditto.
     40
    1412013-02-07  Benjamin Poulain  <bpoulain@apple.com>
    242
  • trunk/Source/WebCore/rendering/ExclusionShapeInfo.cpp

    r140978 r142164  
    5050    ASSERT(shape);
    5151
    52     m_shape = ExclusionShape::createExclusionShape(shape, m_logicalWidth, m_logicalHeight, m_renderer->style()->writingMode());
     52    m_shape = ExclusionShape::createExclusionShape(shape, m_shapeLogicalWidth, m_shapeLogicalHeight, m_renderer->style()->writingMode());
    5353    ASSERT(m_shape);
    5454    return m_shape.get();
  • trunk/Source/WebCore/rendering/ExclusionShapeInfo.h

    r140978 r142164  
    7373    void setShapeSize(LayoutUnit logicalWidth, LayoutUnit logicalHeight)
    7474    {
    75         if (m_logicalWidth == logicalWidth && m_logicalHeight == logicalHeight)
     75        if (m_renderer->style()->boxSizing() == CONTENT_BOX) {
     76            logicalWidth -= m_renderer->borderAndPaddingLogicalWidth();
     77            logicalHeight -= m_renderer->borderAndPaddingLogicalHeight();
     78        }
     79
     80        if (m_shapeLogicalWidth == logicalWidth && m_shapeLogicalHeight == logicalHeight)
    7681            return;
    7782        dirtyShapeSize();
    78         m_logicalWidth = logicalWidth;
    79         m_logicalHeight = logicalHeight;
     83        m_shapeLogicalWidth = logicalWidth;
     84        m_shapeLogicalHeight = logicalHeight;
    8085    }
    8186
    82     LayoutUnit shapeLogicalTop() const { return floatLogicalTopToLayoutUnit(computedShape()->shapeLogicalBoundingBox().y()); }
    83     LayoutUnit shapeLogicalBottom() const { return floatLogicalBottomToLayoutUnit(computedShape()->shapeLogicalBoundingBox().maxY()); }
    84     LayoutUnit shapeLogicalLeft() const { return computedShape()->shapeLogicalBoundingBox().x(); }
    85     LayoutUnit shapeLogicalRight() const { return computedShape()->shapeLogicalBoundingBox().y(); }
     87    LayoutUnit shapeLogicalTop() const { return floatLogicalTopToLayoutUnit(computedShape()->shapeLogicalBoundingBox().y()) + logicalTopOffset(); }
     88    LayoutUnit shapeLogicalBottom() const { return floatLogicalBottomToLayoutUnit(computedShape()->shapeLogicalBoundingBox().maxY()) + logicalTopOffset(); }
     89    LayoutUnit shapeLogicalLeft() const { return computedShape()->shapeLogicalBoundingBox().x() + logicalLeftOffset(); }
     90    LayoutUnit shapeLogicalRight() const { return computedShape()->shapeLogicalBoundingBox().y() + logicalLeftOffset(); }
    8691    LayoutUnit shapeLogicalWidth() const { return computedShape()->shapeLogicalBoundingBox().width(); }
    8792    LayoutUnit shapeLogicalHeight() const { return computedShape()->shapeLogicalBoundingBox().height(); }
     
    99104    LayoutUnit floatLogicalBottomToLayoutUnit(float logicalBottom) const { return LayoutUnit::fromFloatFloor(logicalBottom); }
    100105
     106    LayoutUnit logicalTopOffset() const { return m_renderer->style()->boxSizing() == CONTENT_BOX ? m_renderer->borderBefore() + m_renderer->paddingBefore() : LayoutUnit(); }
     107    LayoutUnit logicalLeftOffset() const { return m_renderer->style()->boxSizing() == CONTENT_BOX ? m_renderer->borderStart() + m_renderer->paddingStart() : LayoutUnit(); }
     108
    101109private:
    102110    mutable OwnPtr<ExclusionShape> m_shape;
    103111
    104     LayoutUnit m_logicalWidth;
    105     LayoutUnit m_logicalHeight;
     112    LayoutUnit m_shapeLogicalWidth;
     113    LayoutUnit m_shapeLogicalHeight;
    106114    const RenderType* m_renderer;
    107115};
  • trunk/Source/WebCore/rendering/ExclusionShapeInsideInfo.cpp

    r140978 r142164  
    3939{
    4040    ASSERT(lineHeight >= 0);
    41     m_lineTop = lineTop;
     41    m_shapeLineTop = lineTop - logicalTopOffset();
    4242    m_lineHeight = lineHeight;
    4343    m_segments.clear();
    4444    m_segmentRanges.clear();
    4545
    46     if (lineOverlapsShapeBounds()) {
    47         computedShape()->getIncludedIntervals(lineTop, std::min(lineHeight, shapeLogicalBottom() - lineTop), m_segments);
     46    if (lineOverlapsShapeBounds())
     47        computedShape()->getIncludedIntervals(m_shapeLineTop, std::min(m_lineHeight, shapeLogicalBottom() - lineTop), m_segments);
     48
     49    LayoutUnit logicalLeftOffset = this->logicalLeftOffset();
     50    for (size_t i = 0; i < m_segments.size(); i++) {
     51        m_segments[i].logicalLeft += logicalLeftOffset;
     52        m_segments[i].logicalRight += logicalLeftOffset;
    4853    }
    4954    return m_segments.size();
     
    5358{
    5459    const ExclusionShape* shape = computedShape();
    55     if (!shape || m_lineHeight <= 0 || m_lineTop > shapeLogicalBottom())
     60    if (!shape || m_lineHeight <= 0 || logicalLineTop() > shapeLogicalBottom())
    5661        return false;
    5762
    5863    float floatNewLineTop;
    59     if (shape->firstIncludedIntervalLogicalTop(m_lineTop, FloatSize(minSegmentWidth, m_lineHeight), floatNewLineTop)) {
     64    if (shape->firstIncludedIntervalLogicalTop(m_shapeLineTop, FloatSize(minSegmentWidth, m_lineHeight), floatNewLineTop)) {
    6065        LayoutUnit newLineTop = floatLogicalTopToLayoutUnit(floatNewLineTop);
    61         if (newLineTop > m_lineTop) {
    62             m_lineTop = newLineTop;
     66        if (newLineTop > m_shapeLineTop) {
     67            m_shapeLineTop = newLineTop;
    6368            return true;
    6469        }
  • trunk/Source/WebCore/rendering/ExclusionShapeInsideInfo.h

    r140978 r142164  
    6464        return shape && (shape->type() == BasicShape::BASIC_SHAPE_RECTANGLE || shape->type() == BasicShape::BASIC_SHAPE_POLYGON);
    6565    }
    66     bool lineOverlapsShapeBounds() const { return m_lineTop < shapeLogicalBottom() && m_lineTop + m_lineHeight >= shapeLogicalTop(); }
     66    bool lineOverlapsShapeBounds() const { return logicalLineTop() < shapeLogicalBottom() && logicalLineBottom() >= shapeLogicalTop(); }
    6767
    6868    bool hasSegments() const
     
    8686    bool computeSegmentsForLine(LayoutUnit lineTop, LayoutUnit lineHeight);
    8787    bool adjustLogicalLineTop(float minSegmentWidth);
    88     LayoutUnit logicalLineTop() const { return m_lineTop; }
     88    LayoutUnit logicalLineTop() const { return m_shapeLineTop + logicalTopOffset(); }
     89    LayoutUnit logicalLineBottom() const { return m_shapeLineTop + m_lineHeight + logicalTopOffset(); }
    8990
    9091private:
    9192    ExclusionShapeInsideInfo(const RenderBlock* renderer) : ExclusionShapeInfo<RenderBlock, &RenderStyle::shapeInside>(renderer) { }
    9293
    93     LayoutUnit m_lineTop;
     94    LayoutUnit m_shapeLineTop;
    9495    LayoutUnit m_lineHeight;
    9596
Note: See TracChangeset for help on using the changeset viewer.