Changeset 70692 in webkit


Ignore:
Timestamp:
Oct 27, 2010 12:48:16 PM (14 years ago)
Author:
hyatt@apple.com
Message:

https://bugs.webkit.org/show_bug.cgi?id=48449

Reviewed by Beth Dakin.

Make border drawing work correctly with vertical inline flows. The top and bottom edge have to be omitted
rather than the left and right edges.

Also discovered that border-radius is broken with the new path-based-drawing code for all inline flows. This
is a regression from the old drawing code. I patched the code to be correct rather than clipping out stuff
that it shouldn't and applying border-radii on lines that don't even have them.

Added fast/blockflow/border-vertical-lr.html and fast/borders/border-radius-inline-flow.html

WebCore:

  • rendering/RenderBoxModelObject.cpp:

(WebCore::RenderBoxModelObject::paintBorder):
(WebCore::RenderBoxModelObject::clipBorderSidePolygon):

  • rendering/RenderBoxModelObject.h:

LayoutTests:

  • fast/blockflow/border-vertical-lr.html: Added.
  • fast/borders/border-radius-inline-flow.html: Added.
  • platform/mac/fast/blockflow/border-vertical-lr-expected.checksum: Added.
  • platform/mac/fast/blockflow/border-vertical-lr-expected.png: Added.
  • platform/mac/fast/blockflow/border-vertical-lr-expected.txt: Added.
  • platform/mac/fast/borders/border-radius-inline-flow-expected.checksum: Added.
  • platform/mac/fast/borders/border-radius-inline-flow-expected.png: Added.
  • platform/mac/fast/borders/border-radius-inline-flow-expected.txt: Added.
Location:
trunk
Files:
8 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r70691 r70692  
     12010-10-27  David Hyatt  <hyatt@apple.com>
     2
     3        Reviewed by Beth Dakin.
     4
     5        https://bugs.webkit.org/show_bug.cgi?id=48449
     6       
     7        Make border drawing work correctly with vertical inline flows.  The top and bottom edge have to be omitted
     8        rather than the left and right edges.
     9       
     10        Also discovered that border-radius is broken with the new path-based-drawing code for all inline flows.  This
     11        is a regression from the old drawing code.  I patched the code to be correct rather than clipping out stuff
     12        that it shouldn't and applying border-radii on lines that don't even have them.
     13
     14        Added fast/blockflow/border-vertical-lr.html and fast/borders/border-radius-inline-flow.html
     15
     16        * fast/blockflow/border-vertical-lr.html: Added.
     17        * fast/borders/border-radius-inline-flow.html: Added.
     18        * platform/mac/fast/blockflow/border-vertical-lr-expected.checksum: Added.
     19        * platform/mac/fast/blockflow/border-vertical-lr-expected.png: Added.
     20        * platform/mac/fast/blockflow/border-vertical-lr-expected.txt: Added.
     21        * platform/mac/fast/borders/border-radius-inline-flow-expected.checksum: Added.
     22        * platform/mac/fast/borders/border-radius-inline-flow-expected.png: Added.
     23        * platform/mac/fast/borders/border-radius-inline-flow-expected.txt: Added.
     24
    1252010-10-27  Adam Roben  <aroben@apple.com>
    226
  • trunk/WebCore/ChangeLog

    r70688 r70692  
     12010-10-27  David Hyatt  <hyatt@apple.com>
     2
     3        Reviewed by Beth Dakin.
     4
     5        https://bugs.webkit.org/show_bug.cgi?id=48449
     6       
     7        Make border drawing work correctly with vertical inline flows.  The top and bottom edge have to be omitted
     8        rather than the left and right edges.
     9       
     10        Also discovered that border-radius is broken with the new path-based-drawing code for all inline flows.  This
     11        is a regression from the old drawing code.  I patched the code to be correct rather than clipping out stuff
     12        that it shouldn't and applying border-radii on lines that don't even have them.
     13
     14        Added fast/blockflow/border-vertical-lr.html and fast/borders/border-radius-inline-flow.html
     15
     16        * rendering/RenderBoxModelObject.cpp:
     17        (WebCore::RenderBoxModelObject::paintBorder):
     18        (WebCore::RenderBoxModelObject::clipBorderSidePolygon):
     19        * rendering/RenderBoxModelObject.h:
     20
    1212010-10-27  Martin Robinson  <mrobinson@igalia.com>
    222
  • trunk/WebCore/rendering/RenderBoxModelObject.cpp

    r70072 r70692  
    10031003
    10041004void RenderBoxModelObject::paintBorder(GraphicsContext* graphicsContext, int tx, int ty, int w, int h,
    1005                                        const RenderStyle* style, bool begin, bool end)
     1005                                       const RenderStyle* style, bool includeLogicalLeftEdge, bool includeLogicalRightEdge)
    10061006{
    10071007    if (paintNinePieceImage(graphicsContext, tx, ty, w, h, style, style->borderImage()))
     
    10261026    EBorderStyle rightStyle = style->borderRightStyle();
    10271027
    1028     bool renderTop = topStyle > BHIDDEN && !topTransparent;
    1029     bool renderLeft = leftStyle > BHIDDEN && begin && !leftTransparent;
    1030     bool renderRight = rightStyle > BHIDDEN && end && !rightTransparent;
    1031     bool renderBottom = bottomStyle > BHIDDEN && !bottomTransparent;
     1028    bool horizontal = style->isHorizontalWritingMode();
     1029
     1030    bool renderTop = topStyle > BHIDDEN && !topTransparent && (horizontal || includeLogicalLeftEdge);
     1031    bool renderLeft = leftStyle > BHIDDEN && !leftTransparent && (!horizontal || includeLogicalLeftEdge);
     1032    bool renderRight = rightStyle > BHIDDEN && !rightTransparent && (!horizontal || includeLogicalRightEdge);
     1033    bool renderBottom = bottomStyle > BHIDDEN && !bottomTransparent && (horizontal || includeLogicalRightEdge);
    10321034
    10331035    bool renderRadii = false;
     
    10401042        style->getBorderRadiiForRect(borderRect, topLeftRadius, topRightRadius, bottomLeftRadius, bottomRightRadius);
    10411043
    1042         IntRect innerBorderRect = borderInnerRect(borderRect, style->borderTopWidth(), style->borderBottomWidth(),
    1043             style->borderLeftWidth(), style->borderRightWidth());
    1044 
     1044        int leftWidth = (!horizontal || includeLogicalLeftEdge) ? style->borderLeftWidth() : 0;
     1045        int rightWidth = (!horizontal || includeLogicalRightEdge) ? style->borderRightWidth() : 0;
     1046        int topWidth = (horizontal || includeLogicalLeftEdge) ? style->borderTopWidth() : 0;
     1047        int bottomWidth = (horizontal || includeLogicalRightEdge) ? style->borderBottomWidth() : 0;
     1048
     1049        IntRect innerBorderRect = borderInnerRect(borderRect, topWidth, bottomWidth, leftWidth, rightWidth);
    10451050        IntSize innerTopLeftRadius, innerTopRightRadius, innerBottomLeftRadius, innerBottomRightRadius;
    1046         style->getInnerBorderRadiiForRectWithBorderWidths(innerBorderRect, style->borderTopWidth(), style->borderBottomWidth(),
    1047             style->borderLeftWidth(), style->borderRightWidth(), innerTopLeftRadius, innerTopRightRadius,
    1048             innerBottomLeftRadius, innerBottomRightRadius);
    1049 
    1050         if (begin) {
     1051       
     1052        style->getInnerBorderRadiiForRectWithBorderWidths(innerBorderRect, topWidth, bottomWidth, leftWidth, rightWidth, innerTopLeftRadius, innerTopRightRadius, innerBottomLeftRadius, innerBottomRightRadius);
     1053
     1054        IntSize innerTopLeft, innerTopRight, innerBottomLeft, innerBottomRight;
     1055
     1056        if (includeLogicalLeftEdge) {
    10511057            topLeft = topLeftRadius;
    1052             bottomLeft = bottomLeftRadius;
    1053         }
    1054         if (end) {
    1055             topRight = topRightRadius;
     1058            innerTopLeft = innerTopLeftRadius;
     1059            if (horizontal) {
     1060                bottomLeft = bottomLeftRadius;
     1061                innerBottomLeft = innerBottomLeftRadius;
     1062            } else {
     1063                topRight = topRightRadius;
     1064                innerTopRight = innerTopRightRadius;
     1065            }
     1066        }
     1067
     1068        if (includeLogicalRightEdge) {
     1069            if (horizontal) {
     1070                topRight = topRightRadius;
     1071                innerTopRight = innerTopRightRadius;
     1072            } else {
     1073                bottomLeft = bottomLeftRadius;
     1074                innerBottomLeft = innerBottomLeftRadius;
     1075            }
    10561076            bottomRight = bottomRightRadius;
    1057         }
    1058 
    1059         renderRadii = true;
    1060 
    1061         // Clip to the inner and outer radii rects.
    1062         graphicsContext->save();
    1063         graphicsContext->addRoundedRectClip(borderRect, topLeft, topRight, bottomLeft, bottomRight);
    1064         graphicsContext->clipOutRoundedRect(innerBorderRect, innerTopLeftRadius, innerTopRightRadius, innerBottomLeftRadius, innerBottomRightRadius);
    1065 
    1066         roundedPath.addRoundedRect(borderRect, topLeft, topRight, bottomLeft, bottomRight);
    1067         graphicsContext->addPath(roundedPath);
     1077            innerBottomRight = innerBottomRightRadius;
     1078        }
     1079
     1080        renderRadii = !topLeft.isZero() || !topRight.isZero() || !bottomLeft.isZero() || !bottomRight.isZero();
     1081       
     1082        if (renderRadii) {
     1083            // Clip to the inner and outer radii rects.
     1084            graphicsContext->save();
     1085            graphicsContext->addRoundedRectClip(borderRect, topLeft, topRight, bottomLeft, bottomRight);
     1086            graphicsContext->clipOutRoundedRect(innerBorderRect, innerTopLeft, innerTopRight, innerBottomLeft, innerBottomRight);
     1087            roundedPath.addRoundedRect(borderRect, topLeft, topRight, bottomLeft, bottomRight);
     1088            graphicsContext->addPath(roundedPath);
     1089        }
    10681090    }
    10691091
     
    10791101        if (renderRadii && borderWillArcInnerEdge(topLeft, topRight, style->borderLeftWidth(), style->borderRightWidth(), style->borderTopWidth())) {
    10801102            graphicsContext->save();
    1081             clipBorderSidePolygon(graphicsContext, borderRect, topLeft, topRight, bottomLeft, bottomRight, BSTop, upperLeftBorderStylesMatch, upperRightBorderStylesMatch, style);
     1103            clipBorderSidePolygon(graphicsContext, borderRect, topLeft, topRight, bottomLeft, bottomRight, BSTop, upperLeftBorderStylesMatch, upperRightBorderStylesMatch, style, includeLogicalLeftEdge, includeLogicalRightEdge);
    10821104            float thickness = max(max(style->borderTopWidth(), style->borderLeftWidth()), style->borderRightWidth());
    10831105            drawBoxSideFromPath(graphicsContext, borderRect, roundedPath, style->borderTopWidth(), thickness, BSTop, style, topColor, topStyle);
     
    11001122        if (renderRadii && borderWillArcInnerEdge(bottomLeft, bottomRight, style->borderLeftWidth(), style->borderRightWidth(), style->borderBottomWidth())) {
    11011123            graphicsContext->save();
    1102             clipBorderSidePolygon(graphicsContext, borderRect, topLeft, topRight, bottomLeft, bottomRight, BSBottom, lowerLeftBorderStylesMatch, lowerRightBorderStylesMatch, style);
     1124            clipBorderSidePolygon(graphicsContext, borderRect, topLeft, topRight, bottomLeft, bottomRight, BSBottom, lowerLeftBorderStylesMatch, lowerRightBorderStylesMatch, style, includeLogicalLeftEdge, includeLogicalRightEdge);
    11031125            float thickness = max(max(style->borderBottomWidth(), style->borderLeftWidth()), style->borderRightWidth());
    11041126            drawBoxSideFromPath(graphicsContext, borderRect, roundedPath, style->borderBottomWidth(), thickness, BSBottom, style, bottomColor, bottomStyle);
     
    11231145        if (renderRadii && borderWillArcInnerEdge(bottomLeft, topLeft, style->borderBottomWidth(), style->borderTopWidth(), style->borderLeftWidth())) {
    11241146            graphicsContext->save();
    1125             clipBorderSidePolygon(graphicsContext, borderRect, topLeft, topRight, bottomLeft, bottomRight, BSLeft, upperLeftBorderStylesMatch, lowerLeftBorderStylesMatch, style);
     1147            clipBorderSidePolygon(graphicsContext, borderRect, topLeft, topRight, bottomLeft, bottomRight, BSLeft, upperLeftBorderStylesMatch, lowerLeftBorderStylesMatch, style, includeLogicalLeftEdge, includeLogicalRightEdge);
    11261148            float thickness = max(max(style->borderLeftWidth(), style->borderTopWidth()), style->borderBottomWidth());
    11271149            drawBoxSideFromPath(graphicsContext, borderRect, roundedPath, style->borderLeftWidth(), thickness, BSLeft, style, leftColor, leftStyle);
     
    11421164        if (renderRadii && borderWillArcInnerEdge(bottomRight, topRight, style->borderBottomWidth(), style->borderTopWidth(), style->borderRightWidth())) {
    11431165            graphicsContext->save();
    1144             clipBorderSidePolygon(graphicsContext, borderRect, topLeft, topRight, bottomLeft, bottomRight, BSRight, upperRightBorderStylesMatch, lowerRightBorderStylesMatch, style);
     1166            clipBorderSidePolygon(graphicsContext, borderRect, topLeft, topRight, bottomLeft, bottomRight, BSRight, upperRightBorderStylesMatch, lowerRightBorderStylesMatch, style, includeLogicalLeftEdge, includeLogicalRightEdge);
    11451167            float thickness = max(max(style->borderRightWidth(), style->borderTopWidth()), style->borderBottomWidth());
    11461168            drawBoxSideFromPath(graphicsContext, borderRect, roundedPath, style->borderRightWidth(), thickness, BSRight, style, rightColor, rightStyle);
     
    11691191#else
    11701192void RenderBoxModelObject::paintBorder(GraphicsContext* graphicsContext, int tx, int ty, int w, int h,
    1171                                        const RenderStyle* style, bool begin, bool end)
     1193                                       const RenderStyle* style, bool includeLogicalLeftEdge, bool includeLogicalRightEdge)
    11721194{
    11731195    // FIXME: This old version of paintBorder should be removed when all ports implement
     
    11911213    EBorderStyle rightStyle = style->borderRightStyle();
    11921214
    1193     bool renderTop = topStyle > BHIDDEN && !topTransparent;
    1194     bool renderLeft = leftStyle > BHIDDEN && begin && !leftTransparent;
    1195     bool renderRight = rightStyle > BHIDDEN && end && !rightTransparent;
    1196     bool renderBottom = bottomStyle > BHIDDEN && !bottomTransparent;
     1215    bool renderTop = topStyle > BHIDDEN && !topTransparent && (horizontal || includeLogicalLeftEdge);
     1216    bool renderLeft = leftStyle > BHIDDEN && !leftTransparent && (!horizontal || includeLogicalLeftEdge);
     1217    bool renderRight = rightStyle > BHIDDEN && !rightTransparent && (!horizontal || includeLogicalRightEdge);
     1218    bool renderBottom = bottomStyle > BHIDDEN && !bottomTransparent && (horizontal || includeLogicalRightEdge);
    11971219
    11981220    bool renderRadii = false;
     
    12051227        style->getBorderRadiiForRect(borderRect, topLeftRadius, topRightRadius, bottomLeftRadius, bottomRightRadius);
    12061228
    1207         if (begin) {
     1229        if (includeLogicalLeftEdge) {
    12081230            topLeft = topLeftRadius;
    1209             bottomLeft = bottomLeftRadius;
    1210         }
    1211         if (end) {
    1212             topRight = topRightRadius;
     1231            if (horizontal)
     1232                bottomLeft = bottomLeftRadius;
     1233            else
     1234                topRight = topRightRadius;
     1235        }
     1236       
     1237        if (includeLogicalRightEdge) {
     1238            if (horizontal)
     1239                topRight = topRightRadius;
     1240            else
     1241                bottomLeft = bottomLeftRadius;
    12131242            bottomRight = bottomRightRadius;
    12141243        }
    12151244
    1216         renderRadii = true;
    1217 
    1218         // Clip to the rounded rectangle.
    1219         graphicsContext->save();
    1220         graphicsContext->addRoundedRectClip(borderRect, topLeft, topRight, bottomLeft, bottomRight);
     1245        renderRadii = !topLeft.isZero() || !topRight.isZero() || !bottomLeft.isZero() || !bottomRight.isZero();
     1246       
     1247        if (renderRadii) {
     1248            // Clip to the rounded rectangle.
     1249            graphicsContext->save();
     1250            graphicsContext->addRoundedRectClip(borderRect, topLeft, topRight, bottomLeft, bottomRight);
     1251        }
    12211252    }
    12221253
     
    15201551#endif
    15211552
    1522 void RenderBoxModelObject::clipBorderSidePolygon(GraphicsContext* graphicsContext, const IntRect& box, const IntSize& topLeft, const IntSize& topRight, const IntSize& bottomLeft, const IntSize& bottomRight, const BoxSide side, bool firstEdgeMatches, bool secondEdgeMatches, const RenderStyle* style)
     1553void RenderBoxModelObject::clipBorderSidePolygon(GraphicsContext* graphicsContext, const IntRect& box, const IntSize& topLeft, const IntSize& topRight, const IntSize& bottomLeft, const IntSize& bottomRight,
     1554                                                 const BoxSide side, bool firstEdgeMatches, bool secondEdgeMatches, const RenderStyle* style,
     1555                                                 bool includeLogicalLeftEdge, bool includeLogicalRightEdge)
    15231556{
    15241557    FloatPoint quad[4];
     
    15281561    int h = box.height();
    15291562
     1563    bool horizontal = style->isHorizontalWritingMode();
     1564    int leftWidth = (!horizontal || includeLogicalLeftEdge) ? style->borderLeftWidth() : 0;
     1565    int rightWidth = (!horizontal || includeLogicalRightEdge) ? style->borderRightWidth() : 0;
     1566    int topWidth = (horizontal || includeLogicalLeftEdge) ? style->borderTopWidth() : 0;
     1567    int bottomWidth = (horizontal || includeLogicalRightEdge) ? style->borderBottomWidth() : 0;
     1568
    15301569    // For each side, create an array of FloatPoints where each point is based on whichever value in each corner
    15311570    // is larger -- the radius width/height or the border width/height -- as appropriate.
     
    15331572    case BSTop:
    15341573        quad[0] = FloatPoint(tx, ty);
    1535         quad[1] = FloatPoint(
    1536             tx + max(topLeft.width(), (int) style->borderLeftWidth()),
    1537             ty + max(topLeft.height(), (int) style->borderTopWidth()));
    1538         quad[2] = FloatPoint(
    1539             tx + w - max(topRight.width(), (int) style->borderRightWidth()),
    1540             ty + max(topRight.height(), (int)style->borderTopWidth()));
     1574        quad[1] = FloatPoint(tx + max(topLeft.width(), leftWidth), ty + max(topLeft.height(), topWidth));
     1575        quad[2] = FloatPoint(tx + w - max(topRight.width(), rightWidth), ty + max(topRight.height(), topWidth));
    15411576        quad[3] = FloatPoint(tx + w, ty);
    15421577        break;
    15431578    case BSLeft:
    15441579        quad[0] = FloatPoint(tx, ty);
    1545         quad[1] = FloatPoint(
    1546             tx + max(topLeft.width(), (int) style->borderLeftWidth()),
    1547             ty + max(topLeft.height(), (int) style->borderTopWidth()));
    1548         quad[2] = FloatPoint(
    1549             tx + max(bottomLeft.width(), (int) style->borderLeftWidth()),
    1550             ty + h - max(bottomLeft.height(), (int)style->borderBottomWidth()));
     1580        quad[1] = FloatPoint(tx + max(topLeft.width(), leftWidth), ty + max(topLeft.height(), topWidth));
     1581        quad[2] = FloatPoint(tx + max(bottomLeft.width(), leftWidth), ty + h - max(bottomLeft.height(), bottomWidth));
    15511582        quad[3] = FloatPoint(tx, ty + h);
    15521583        break;
    15531584    case BSBottom:
    15541585        quad[0] = FloatPoint(tx, ty + h);
    1555         quad[1] = FloatPoint(
    1556             tx + max(bottomLeft.width(), (int) style->borderLeftWidth()),
    1557             ty + h - max(bottomLeft.height(), (int)style->borderBottomWidth()));
    1558         quad[2] = FloatPoint(
    1559             tx + w - max(bottomRight.width(), (int) style->borderRightWidth()),
    1560             ty + h - max(bottomRight.height(), (int)style->borderBottomWidth()));
     1586        quad[1] = FloatPoint(tx + max(bottomLeft.width(), leftWidth), ty + h - max(bottomLeft.height(), bottomWidth));
     1587        quad[2] = FloatPoint(tx + w - max(bottomRight.width(), rightWidth), ty + h - max(bottomRight.height(), bottomWidth));
    15611588        quad[3] = FloatPoint(tx + w, ty + h);
    15621589        break;
    15631590    case BSRight:
    15641591        quad[0] = FloatPoint(tx + w, ty);
    1565         quad[1] = FloatPoint(
    1566             tx + w - max(topRight.width(), (int) style->borderRightWidth()),
    1567             ty + max(topRight.height(), (int) style->borderTopWidth()));
    1568         quad[2] = FloatPoint(
    1569             tx + w - max(bottomRight.width(), (int) style->borderRightWidth()),
    1570             ty + h - max(bottomRight.height(), (int)style->borderBottomWidth()));
     1592        quad[1] = FloatPoint(tx + w - max(topRight.width(), rightWidth), ty + max(topRight.height(), topWidth));
     1593        quad[2] = FloatPoint(tx + w - max(bottomRight.width(), rightWidth), ty + h - max(bottomRight.height(), bottomWidth));
    15711594        quad[3] = FloatPoint(tx + w, ty + h);
    15721595        break;
  • trunk/WebCore/rendering/RenderBoxModelObject.h

    r70072 r70692  
    110110    virtual void childBecameNonInline(RenderObject* /*child*/) { }
    111111
    112     void paintBorder(GraphicsContext*, int tx, int ty, int w, int h, const RenderStyle*, bool begin = true, bool end = true);
     112    void paintBorder(GraphicsContext*, int tx, int ty, int w, int h, const RenderStyle*, bool includeLogicalLeftEdge = true, bool includeLogicalRightEdge = true);
    113113    bool paintNinePieceImage(GraphicsContext*, int tx, int ty, int w, int h, const RenderStyle*, const NinePieceImage&, CompositeOperator = CompositeSourceOver);
    114114    void paintBoxShadow(GraphicsContext*, int tx, int ty, int w, int h, const RenderStyle*, ShadowStyle, bool begin = true, bool end = true);
     
    138138    IntSize calculateFillTileSize(const FillLayer*, IntSize scaledSize) const;
    139139
    140     void clipBorderSidePolygon(GraphicsContext*, const IntRect&, const IntSize& topLeft, const IntSize& topRight, const IntSize& bottomLeft, const IntSize& bottomRight, const BoxSide side, bool firstEdgeMatches, bool secondEdgeMatches, const RenderStyle* style);
     140    void clipBorderSidePolygon(GraphicsContext*, const IntRect&, const IntSize& topLeft, const IntSize& topRight, const IntSize& bottomLeft,
     141                               const IntSize& bottomRight, const BoxSide side, bool firstEdgeMatches, bool secondEdgeMatches, const RenderStyle* style,
     142                               bool includeLogicalLeftEdge, bool includeLogicalRightEdge);
    141143
    142144    friend class RenderView;
Note: See TracChangeset for help on using the changeset viewer.