Changeset 140365 in webkit


Ignore:
Timestamp:
Jan 21, 2013 2:35:28 PM (11 years ago)
Author:
commit-queue@webkit.org
Message:

[CSS Exclusions] shape-outside on floats for rectangle shapes positioning
https://bugs.webkit.org/show_bug.cgi?id=100399

Patch by Bem Jones-Bey <Bem Jones-Bey> on 2013-01-21
Reviewed by David Hyatt.

Source/WebCore:

When a float has a shape-outside with non-zero x or y, the float's
exclusion behavior can happen at a completely different location than
where the float's content is painted. This patch brings initial
support for this behavior.

Test: fast/exclusions/shape-outside-floats/shape-outside-floats-positioning.html

  • rendering/RenderBlock.cpp:

(WebCore::RenderBlock::flipFloatForWritingModeForChild): If called

during painting, make sure to pass that state down to the float
positioning so that it can use the proper position.

(WebCore::RenderBlock::paintFloats): Since this is concerned with

painting, use the position of the float, not the shape.

(WebCore::RenderBlock::positionNewFloats): Set the correct location

for the float, relative to the location of the shape.

(WebCore::RenderBlock::addOverhangingFloats): Add FIXME.

  • rendering/RenderBlock.h:

(WebCore::RenderBlock::xPositionForFloatIncludingMargin):
(WebCore::RenderBlock::yPositionForFloatIncludingMargin): Since the

position of the shape (FloatingObject) can be different from the
position of the float's box (RenderBox), the position needs to be
computed differently for painting than for determining layout.

(WebCore::RenderBlock::flipFloatForWritingModeForChild): Change

signature to take painting flag.

LayoutTests:

  • fast/exclusions/shape-outside-floats/shape-outside-floats-positioning-expected.html: Added.
  • fast/exclusions/shape-outside-floats/shape-outside-floats-positioning.html: Added.
  • fast/exclusions/shape-outside-floats/shape-outside-floats-simple-rectangle-horizontal-multiple.html:

This test had incorrect coordinates for some of the shapes, causing them to break now that x and y are supported for the shapes.

Location:
trunk
Files:
2 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r140364 r140365  
     12013-01-21  Bem Jones-Bey  <bjonesbe@adobe.com>
     2
     3        [CSS Exclusions] shape-outside on floats for rectangle shapes positioning
     4        https://bugs.webkit.org/show_bug.cgi?id=100399
     5
     6        Reviewed by David Hyatt.
     7
     8        * fast/exclusions/shape-outside-floats/shape-outside-floats-positioning-expected.html: Added.
     9        * fast/exclusions/shape-outside-floats/shape-outside-floats-positioning.html: Added.
     10        * fast/exclusions/shape-outside-floats/shape-outside-floats-simple-rectangle-horizontal-multiple.html:
     11            This test had incorrect coordinates for some of the shapes, causing them to break now that x and y are supported for the shapes.
     12
    1132013-01-21  Robert Hogan  <robert@webkit.org>
    214
  • trunk/LayoutTests/fast/exclusions/shape-outside-floats/shape-outside-floats-simple-rectangle-horizontal-multiple.html

    r137930 r140365  
    3838    }
    3939    .float-right-exclusion {
    40         -webkit-shape-outside: rectangle(10px, 0px, 10px, 20px);
     40        -webkit-shape-outside: rectangle(0px, 0px, 10px, 20px);
    4141        float: right;
    4242        height: 20px;
     
    5050    }
    5151    .float-right-vertical-exclusion {
    52         -webkit-shape-outside: rectangle(0px, 10px, 20px, 10px);
     52        -webkit-shape-outside: rectangle(0px, 0px, 20px, 10px);
    5353        float: right;
    5454        height: 20px;
  • trunk/Source/WebCore/ChangeLog

    r140359 r140365  
     12013-01-21  Bem Jones-Bey  <bjonesbe@adobe.com>
     2
     3        [CSS Exclusions] shape-outside on floats for rectangle shapes positioning
     4        https://bugs.webkit.org/show_bug.cgi?id=100399
     5
     6        Reviewed by David Hyatt.
     7
     8        When a float has a shape-outside with non-zero x or y, the float's
     9        exclusion behavior can happen at a completely different location than
     10        where the float's content is painted. This patch brings initial
     11        support for this behavior.
     12
     13        Test: fast/exclusions/shape-outside-floats/shape-outside-floats-positioning.html
     14
     15        * rendering/RenderBlock.cpp:
     16        (WebCore::RenderBlock::flipFloatForWritingModeForChild): If called
     17            during painting, make sure to pass that state down to the float
     18            positioning so that it can use the proper position.
     19        (WebCore::RenderBlock::paintFloats): Since this is concerned with
     20            painting, use the position of the float, not the shape.
     21        (WebCore::RenderBlock::positionNewFloats): Set the correct location
     22            for the float, relative to the location of the shape.
     23        (WebCore::RenderBlock::addOverhangingFloats): Add FIXME.
     24        * rendering/RenderBlock.h:
     25        (WebCore::RenderBlock::xPositionForFloatIncludingMargin):
     26        (WebCore::RenderBlock::yPositionForFloatIncludingMargin): Since the
     27            position of the shape (FloatingObject) can be different from the
     28            position of the float's box (RenderBox), the position needs to be
     29            computed differently for painting than for determining layout.
     30        (WebCore::RenderBlock::flipFloatForWritingModeForChild): Change
     31            signature to take painting flag.
     32
    1332013-01-21  Eric Carlson  <eric.carlson@apple.com>
    234
  • trunk/Source/WebCore/rendering/RenderBlock.cpp

    r140358 r140365  
    31243124}
    31253125
    3126 LayoutPoint RenderBlock::flipFloatForWritingModeForChild(const FloatingObject* child, const LayoutPoint& point) const
     3126LayoutPoint RenderBlock::flipFloatForWritingModeForChild(const FloatingObject* child, const LayoutPoint& point, FloatRenderingState renderingState) const
    31273127{
    31283128    if (!style()->isFlippedBlocksWritingMode())
     
    31333133    // case.
    31343134    if (isHorizontalWritingMode())
    3135         return LayoutPoint(point.x(), point.y() + height() - child->renderer()->height() - 2 * yPositionForFloatIncludingMargin(child));
    3136     return LayoutPoint(point.x() + width() - child->renderer()->width() - 2 * xPositionForFloatIncludingMargin(child), point.y());
     3135        return LayoutPoint(point.x(), point.y() + height() - child->renderer()->height() - 2 * yPositionForFloatIncludingMargin(child, renderingState));
     3136    return LayoutPoint(point.x() + width() - child->renderer()->width() - 2 * xPositionForFloatIncludingMargin(child, renderingState), point.y());
    31373137}
    31383138
     
    31503150            PaintInfo currentPaintInfo(paintInfo);
    31513151            currentPaintInfo.phase = preservePhase ? paintInfo.phase : PaintPhaseBlockBackground;
    3152             LayoutPoint childPoint = flipFloatForWritingModeForChild(r, LayoutPoint(paintOffset.x() + xPositionForFloatIncludingMargin(r) - r->m_renderer->x(), paintOffset.y() + yPositionForFloatIncludingMargin(r) - r->m_renderer->y()));
     3152            LayoutPoint childPoint = flipFloatForWritingModeForChild(r, LayoutPoint(paintOffset.x() + xPositionForFloatIncludingMargin(r, FloatPaint) - r->m_renderer->x(), paintOffset.y() + yPositionForFloatIncludingMargin(r, FloatPaint) - r->m_renderer->y()), FloatPaint);
    31533153            r->m_renderer->paint(currentPaintInfo, childPoint);
    31543154            if (!preservePhase) {
     
    40094009        setLogicalLeftForFloat(floatingObject, floatLogicalLocation.x());
    40104010
    4011         bool hasShapeOutside = false;
    40124011#if ENABLE(CSS_EXCLUSIONS)
    4013         hasShapeOutside = floatingObject->renderer()->exclusionShapeOutsideInfo();
     4012        if (childBox->exclusionShapeOutsideInfo()) {
     4013            // The CSS Exclusions specification says that the margins are ignored when a float has a shape outside.
     4014            setLogicalLeftForChild(childBox, floatLogicalLocation.x() - childBox->exclusionShapeOutsideInfo()->shapeLogicalLeft());
     4015            setLogicalTopForChild(childBox, floatLogicalLocation.y() - childBox->exclusionShapeOutsideInfo()->shapeLogicalTop());
     4016        } else {
    40144017#endif
    4015         // The CSS Exclusions specification says that the margins are ignored when a float has a shape outside.
    4016         setLogicalLeftForChild(childBox, floatLogicalLocation.x() + (hasShapeOutside ? LayoutUnit() : childLogicalLeftMargin));
    4017         setLogicalTopForChild(childBox, floatLogicalLocation.y() + (hasShapeOutside ? LayoutUnit() : marginBeforeForChild(childBox)));
     4018            setLogicalLeftForChild(childBox, floatLogicalLocation.x() + childLogicalLeftMargin);
     4019            setLogicalTopForChild(childBox, floatLogicalLocation.y() + marginBeforeForChild(childBox));
     4020#if ENABLE(CSS_EXCLUSIONS)
     4021        }
     4022#endif
    40184023
    40194024        LayoutState* layoutState = view()->layoutState();
     
    40444049                setLogicalLeftForFloat(floatingObject, floatLogicalLocation.x());
    40454050
    4046                 // The CSS Exclusions specification says that the margins are ignored when a float has a shape outside.
    4047                 setLogicalLeftForChild(childBox, floatLogicalLocation.x() + (hasShapeOutside ? LayoutUnit() : childLogicalLeftMargin));
    4048                 setLogicalTopForChild(childBox, floatLogicalLocation.y() + (hasShapeOutside ? LayoutUnit() : marginBeforeForChild(childBox)));
     4051#if ENABLE(CSS_EXCLUSIONS)
     4052                if (childBox->exclusionShapeOutsideInfo()) {
     4053                    // The CSS Exclusions specification says that the margins are ignored when a float has a shape outside.
     4054                    setLogicalLeftForChild(childBox, floatLogicalLocation.x() - childBox->exclusionShapeOutsideInfo()->shapeLogicalLeft());
     4055                    setLogicalTopForChild(childBox, floatLogicalLocation.y() - childBox->exclusionShapeOutsideInfo()->shapeLogicalTop());
     4056                } else {
     4057#endif
     4058                    setLogicalLeftForChild(childBox, floatLogicalLocation.x() + childLogicalLeftMargin);
     4059                    setLogicalTopForChild(childBox, floatLogicalLocation.y() + marginBeforeForChild(childBox));
     4060#if ENABLE(CSS_EXCLUSIONS)
     4061                }
     4062#endif
     4063
    40494064       
    40504065                if (childBlock)
     
    40564071        setLogicalTopForFloat(floatingObject, floatLogicalLocation.y());
    40574072#if ENABLE(CSS_EXCLUSIONS)
    4058         if (hasShapeOutside)
    4059             setLogicalHeightForFloat(floatingObject, floatingObject->renderer()->exclusionShapeOutsideInfo()->shapeLogicalHeight());
     4073        if (childBox->exclusionShapeOutsideInfo())
     4074            setLogicalHeightForFloat(floatingObject, childBox->exclusionShapeOutsideInfo()->shapeLogicalHeight());
    40604075        else
    40614076#endif
     
    45394554        lowestFloatLogicalBottom = max(lowestFloatLogicalBottom, logicalBottom);
    45404555
     4556        // FIXME: Bug 106927 Handle situations where float and shape-outside overflow differently.
    45414557        if (logicalBottom > logicalHeight()) {
    45424558            // If the object is not in the list, we add it now.
  • trunk/Source/WebCore/rendering/RenderBlock.h

    r140291 r140365  
    689689    };
    690690
    691     LayoutPoint flipFloatForWritingModeForChild(const FloatingObject*, const LayoutPoint&) const;
     691    // When a float has shape outside, it needs to be handled differently at
     692    // paint time and at layout time, since the coordinates of the shape
     693    // (affecting layout) and the coordinates of the float itself (affecting
     694    // where the content of the float is) can be in different places. This enum
     695    // is used to change behavior based on that state.
     696    enum FloatRenderingState { FloatLayout, FloatPaint };
     697
     698    LayoutPoint flipFloatForWritingModeForChild(const FloatingObject*, const LayoutPoint&, FloatRenderingState = FloatLayout) const;
    692699
    693700    LayoutUnit logicalTopForFloat(const FloatingObject* child) const { return isHorizontalWritingMode() ? child->y() : child->x(); }
     
    731738    }
    732739
    733     LayoutUnit xPositionForFloatIncludingMargin(const FloatingObject* child) const
    734     {
     740    LayoutUnit xPositionForFloatIncludingMargin(const FloatingObject* child, FloatRenderingState renderingState = FloatLayout) const
     741    {
     742#if ENABLE(CSS_EXCLUSIONS)
     743        ExclusionShapeOutsideInfo *shapeOutside = child->renderer()->exclusionShapeOutsideInfo();
     744        if (renderingState == FloatPaint && shapeOutside)
     745            return child->x() - (isHorizontalWritingMode() ? shapeOutside->shapeLogicalLeft() : shapeOutside->shapeLogicalTop());
     746        // FIXME: Bug 106928 This needs to properly handle the margin for floats with shape-outside for non-paint time.
     747#endif
     748
    735749        if (isHorizontalWritingMode())
    736750            return child->x() + child->renderer()->marginLeft();
     
    739753    }
    740754       
    741     LayoutUnit yPositionForFloatIncludingMargin(const FloatingObject* child) const
    742     {
     755    LayoutUnit yPositionForFloatIncludingMargin(const FloatingObject* child, FloatRenderingState renderingState = FloatLayout) const
     756    {
     757#if ENABLE(CSS_EXCLUSIONS)
     758        ExclusionShapeOutsideInfo *shapeOutside = child->renderer()->exclusionShapeOutsideInfo();
     759        if (renderingState == FloatPaint && shapeOutside)
     760            return child->y() - (isHorizontalWritingMode() ? shapeOutside->shapeLogicalTop() : shapeOutside->shapeLogicalLeft());
     761        // FIXME: Bug 106928 This needs to properly handle the margin for floats with shape-outside.
     762#endif
     763
    743764        if (isHorizontalWritingMode())
    744765            return child->y() + marginBeforeForChild(child->renderer());
Note: See TracChangeset for help on using the changeset viewer.