Changeset 108719 in webkit
- Timestamp:
- Feb 23, 2012 7:55:53 PM (12 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r108715 r108719 1 2012-02-23 Levi Weintraub <leviw@chromium.org> 2 3 Switch drawLineForBoxSide to use integers 4 https://bugs.webkit.org/show_bug.cgi?id=78647 5 6 Reviewed by Eric Seidel. 7 8 drawLineForBoxSide handles painting lines for boxes which must be done on pixel boundaries. 9 Its interface doesn't make it possible to pixel snap properly within the function itself -- 10 it draws one side of the box at a time, and the logical right and bottom lines can only be 11 properly determined using the logical top and left positions -- so it needs to be treated 12 like a graphics context function, whereby the caller handles the proper pixel snapping before 13 passing the values in. 14 15 No new tests. No change in behavior. 16 17 * rendering/LayoutTypes.h: 18 (WebCore::pixelSnappedIntRectFromEdges): convenience function for returning a pixel snapped 19 int rect from four LayoutUnits that are its edges (as opposed to position and size). 20 * rendering/RenderBlock.cpp: 21 (WebCore::RenderBlock::paintColumnRules): Pixel snapping the column rule rect. 22 * rendering/RenderBoxModelObject.cpp: 23 (WebCore::RenderBoxModelObject::paintOneBorderSide): Side rects are now IntRects by the time 24 they get to paintOneBorderSide. 25 (WebCore::calculateSideRect): Properly use RoundedRect as IntRects instead of LayoutRects. 26 (WebCore::RenderBoxModelObject::paintBorderSides): Ditto. 27 (WebCore::RenderBoxModelObject::paintBorder): Ditto. 28 (WebCore::calculateSideRectIncludingInner): Ditto. 29 * rendering/RenderBoxModelObject.h: 30 (RenderBoxModelObject): 31 * rendering/RenderInline.cpp: 32 (WebCore::RenderInline::paintOutlineForLine): Outline widths are related to borders and stored 33 as ints. Removing an unnecessary conversion to LayoutUnits. Pixel snapping the edges of the box. 34 * rendering/RenderObject.cpp: 35 (WebCore::RenderObject::drawLineForBoxSide): Moving back to integers and removing an 36 unnecessary pixelSnappedIntRect call. 37 (WebCore::RenderObject::paintOutline): Pixel snapping the column rule rect and using an integer 38 for outlineOffset. 39 * rendering/RenderObject.h: 40 (RenderObject): 41 1 42 2012-02-23 Leo Yang <leo.yang@torchmobile.com.cn> 2 43 -
trunk/Source/WebCore/rendering/LayoutTypes.h
r107880 r108719 57 57 { 58 58 return rect; 59 } 60 61 inline IntRect pixelSnappedIntRectFromEdges(LayoutUnit left, LayoutUnit top, LayoutUnit right, LayoutUnit bottom) 62 { 63 return IntRect(left, top, right - left, bottom - top); 59 64 } 60 65 -
trunk/Source/WebCore/rendering/RenderBlock.cpp
r108645 r108719 2594 2594 LayoutUnit ruleTop = isHorizontalWritingMode() ? paintOffset.y() + borderTop() + paddingTop() : paintOffset.y() + ruleLogicalLeft - ruleThickness / 2 + ruleAdd; 2595 2595 LayoutUnit ruleBottom = isHorizontalWritingMode() ? ruleTop + contentHeight() : ruleTop + ruleThickness; 2596 drawLineForBoxSide(paintInfo.context, ruleLeft, ruleTop, ruleRight, ruleBottom, boxSide, ruleColor, ruleStyle, 0, 0, antialias); 2596 IntRect pixelSnappedRuleRect = pixelSnappedIntRectFromEdges(ruleLeft, ruleTop, ruleRight, ruleBottom); 2597 drawLineForBoxSide(paintInfo.context, pixelSnappedRuleRect.x(), pixelSnappedRuleRect.y(), pixelSnappedRuleRect.maxX(), pixelSnappedRuleRect.maxY(), boxSide, ruleColor, ruleStyle, 0, 0, antialias); 2597 2598 } 2598 2599 … … 2619 2620 for (unsigned i = 1; i < colCount; i++) { 2620 2621 ruleRect.move(step); 2621 drawLineForBoxSide(paintInfo.context, ruleRect.x(), ruleRect.y(), ruleRect.maxX(), ruleRect.maxY(), boxSide, ruleColor, ruleStyle, 0, 0, antialias); 2622 IntRect pixelSnappedRuleRect = pixelSnappedIntRect(ruleRect); 2623 drawLineForBoxSide(paintInfo.context, pixelSnappedRuleRect.x(), pixelSnappedRuleRect.y(), pixelSnappedRuleRect.maxX(), pixelSnappedRuleRect.maxY(), boxSide, ruleColor, ruleStyle, 0, 0, antialias); 2622 2624 } 2623 2625 } -
trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp
r108494 r108719 1586 1586 1587 1587 void RenderBoxModelObject::paintOneBorderSide(GraphicsContext* graphicsContext, const RenderStyle* style, const RoundedRect& outerBorder, const RoundedRect& innerBorder, 1588 const LayoutRect& sideRect, BoxSide side, BoxSide adjacentSide1, BoxSide adjacentSide2, const BorderEdge edges[], const Path* path,1588 const IntRect& sideRect, BoxSide side, BoxSide adjacentSide1, BoxSide adjacentSide2, const BorderEdge edges[], const Path* path, 1589 1589 BackgroundBleedAvoidance bleedAvoidance, bool includeLogicalLeftEdge, bool includeLogicalRightEdge, bool antialias, const Color* overrideColor) 1590 1590 { … … 1631 1631 } 1632 1632 1633 static LayoutRect calculateSideRect(const RoundedRect& outerBorder, const BorderEdge edges[], int side)1634 { 1635 LayoutRect sideRect = outerBorder.rect();1633 static IntRect calculateSideRect(const RoundedRect& outerBorder, const BorderEdge edges[], int side) 1634 { 1635 IntRect sideRect = outerBorder.rect(); 1636 1636 int width = edges[side].width; 1637 1637 … … 1659 1659 1660 1660 if (edges[BSTop].shouldRender() && includesEdge(edgeSet, BSTop)) { 1661 LayoutRect sideRect = outerBorder.rect();1661 IntRect sideRect = outerBorder.rect(); 1662 1662 sideRect.setHeight(edges[BSTop].width); 1663 1663 … … 1667 1667 1668 1668 if (edges[BSBottom].shouldRender() && includesEdge(edgeSet, BSBottom)) { 1669 LayoutRect sideRect = outerBorder.rect();1669 IntRect sideRect = outerBorder.rect(); 1670 1670 sideRect.shiftYEdgeTo(sideRect.maxY() - edges[BSBottom].width); 1671 1671 … … 1675 1675 1676 1676 if (edges[BSLeft].shouldRender() && includesEdge(edgeSet, BSLeft)) { 1677 LayoutRect sideRect = outerBorder.rect();1677 IntRect sideRect = outerBorder.rect(); 1678 1678 sideRect.setWidth(edges[BSLeft].width); 1679 1679 … … 1683 1683 1684 1684 if (edges[BSRight].shouldRender() && includesEdge(edgeSet, BSRight)) { 1685 LayoutRect sideRect = outerBorder.rect();1685 IntRect sideRect = outerBorder.rect(); 1686 1686 sideRect.shiftXEdgeTo(sideRect.maxX() - edges[BSRight].width); 1687 1687 … … 1812 1812 const BorderEdge& currEdge = edges[i]; 1813 1813 if (currEdge.shouldRender()) { 1814 LayoutRect sideRect = calculateSideRect(outerBorder, edges, i);1814 IntRect sideRect = calculateSideRect(outerBorder, edges, i); 1815 1815 path.addRect(sideRect); 1816 1816 } … … 2434 2434 } 2435 2435 2436 static LayoutRect calculateSideRectIncludingInner(const RoundedRect& outerBorder, const BorderEdge edges[], BoxSide side)2437 { 2438 LayoutRect sideRect = outerBorder.rect();2436 static IntRect calculateSideRectIncludingInner(const RoundedRect& outerBorder, const BorderEdge edges[], BoxSide side) 2437 { 2438 IntRect sideRect = outerBorder.rect(); 2439 2439 int width; 2440 2440 -
trunk/Source/WebCore/rendering/RenderBoxModelObject.h
r107874 r108719 221 221 void clipBorderSideForComplexInnerPath(GraphicsContext*, const RoundedRect&, const RoundedRect&, BoxSide, const class BorderEdge[]); 222 222 void paintOneBorderSide(GraphicsContext*, const RenderStyle*, const RoundedRect& outerBorder, const RoundedRect& innerBorder, 223 const LayoutRect& sideRect, BoxSide, BoxSide adjacentSide1, BoxSide adjacentSide2, const class BorderEdge[],223 const IntRect& sideRect, BoxSide, BoxSide adjacentSide1, BoxSide adjacentSide2, const class BorderEdge[], 224 224 const Path*, BackgroundBleedAvoidance, bool includeLogicalLeftEdge, bool includeLogicalRightEdge, bool antialias, const Color* overrideColor = 0); 225 225 void paintTranslucentBorderSides(GraphicsContext*, const RenderStyle*, const RoundedRect& outerBorder, const RoundedRect& innerBorder, -
trunk/Source/WebCore/rendering/RenderInline.cpp
r108382 r108719 1447 1447 { 1448 1448 RenderStyle* styleToUse = style(); 1449 LayoutUnit outlineWidth = styleToUse->outlineWidth();1449 int outlineWidth = styleToUse->outlineWidth(); 1450 1450 EBorderStyle outlineStyle = styleToUse->outlineStyle(); 1451 1451 1452 1452 bool antialias = shouldAntialiasLines(graphicsContext); 1453 1453 1454 LayoutUnit offset = style()->outlineOffset();1455 1456 Layout Unit top = paintOffset.y() + thisline.y() - offset;1457 LayoutUnit left = paintOffset.x() + thisline.x() - offset;1458 LayoutUnit bottom = paintOffset.y() + thisline.maxY() + offset; 1459 LayoutUnit right = paintOffset.x() + thisline.maxX() + offset;1454 int offset = style()->outlineOffset(); 1455 1456 LayoutRect box(LayoutPoint(paintOffset.x() + thisline.x() - offset, paintOffset.y() + thisline.y() - offset), 1457 LayoutSize(thisline.width() + offset, thisline.height() + offset)); 1458 1459 IntRect pixelSnappedBox = pixelSnappedIntRect(box); 1460 1460 1461 1461 // left edge 1462 1462 drawLineForBoxSide(graphicsContext, 1463 left- outlineWidth,1464 top - (lastline.isEmpty() || thisline.x() < lastline.x() || (lastline.maxX() - 1) <= thisline.x() ? outlineWidth : zeroLayoutUnit),1465 left,1466 bottom + (nextline.isEmpty() || thisline.x() <= nextline.x() || (nextline.maxX() - 1) <= thisline.x() ? outlineWidth : zeroLayoutUnit),1463 pixelSnappedBox.x() - outlineWidth, 1464 pixelSnappedBox.y() - (lastline.isEmpty() || thisline.x() < lastline.x() || (lastline.maxX() - 1) <= thisline.x() ? outlineWidth : 0), 1465 pixelSnappedBox.x(), 1466 pixelSnappedBox.maxY() + (nextline.isEmpty() || thisline.x() <= nextline.x() || (nextline.maxX() - 1) <= thisline.x() ? outlineWidth : 0), 1467 1467 BSLeft, 1468 1468 outlineColor, outlineStyle, … … 1473 1473 // right edge 1474 1474 drawLineForBoxSide(graphicsContext, 1475 right,1476 top - (lastline.isEmpty() || lastline.maxX() < thisline.maxX() || (thisline.maxX() - 1) <= lastline.x() ? outlineWidth : zeroLayoutUnit),1477 right+ outlineWidth,1478 bottom + (nextline.isEmpty() || nextline.maxX() <= thisline.maxX() || (thisline.maxX() - 1) <= nextline.x() ? outlineWidth : zeroLayoutUnit),1475 pixelSnappedBox.maxX(), 1476 pixelSnappedBox.y() - (lastline.isEmpty() || lastline.maxX() < thisline.maxX() || (thisline.maxX() - 1) <= lastline.x() ? outlineWidth : 0), 1477 pixelSnappedBox.maxX() + outlineWidth, 1478 pixelSnappedBox.maxY() + (nextline.isEmpty() || nextline.maxX() <= thisline.maxX() || (thisline.maxX() - 1) <= nextline.x() ? outlineWidth : 0), 1479 1479 BSRight, 1480 1480 outlineColor, outlineStyle, … … 1485 1485 if (thisline.x() < lastline.x()) 1486 1486 drawLineForBoxSide(graphicsContext, 1487 left- outlineWidth,1488 top- outlineWidth,1489 min( right+ outlineWidth, (lastline.isEmpty() ? 1000000 : paintOffset.x() + lastline.x())),1490 top,1487 pixelSnappedBox.x() - outlineWidth, 1488 pixelSnappedBox.y() - outlineWidth, 1489 min(pixelSnappedBox.maxX() + outlineWidth, (lastline.isEmpty() ? 1000000 : paintOffset.x() + lastline.x())), 1490 pixelSnappedBox.y(), 1491 1491 BSTop, outlineColor, outlineStyle, 1492 1492 outlineWidth, 1493 (!lastline.isEmpty() && paintOffset.x() + lastline.x() + 1 < right+ outlineWidth) ? -outlineWidth : outlineWidth,1493 (!lastline.isEmpty() && paintOffset.x() + lastline.x() + 1 < pixelSnappedBox.maxX() + outlineWidth) ? -outlineWidth : outlineWidth, 1494 1494 antialias); 1495 1495 1496 1496 if (lastline.maxX() < thisline.maxX()) 1497 1497 drawLineForBoxSide(graphicsContext, 1498 max(lastline.isEmpty() ? -1000000 : paintOffset.x() + lastline.maxX(), left- outlineWidth),1499 top- outlineWidth,1500 right+ outlineWidth,1501 top,1498 max(lastline.isEmpty() ? -1000000 : paintOffset.x() + lastline.maxX(), pixelSnappedBox.x() - outlineWidth), 1499 pixelSnappedBox.y() - outlineWidth, 1500 pixelSnappedBox.maxX() + outlineWidth, 1501 pixelSnappedBox.y(), 1502 1502 BSTop, outlineColor, outlineStyle, 1503 (!lastline.isEmpty() && left- outlineWidth < paintOffset.x() + lastline.maxX()) ? -outlineWidth : outlineWidth,1503 (!lastline.isEmpty() && pixelSnappedBox.x() - outlineWidth < paintOffset.x() + lastline.maxX()) ? -outlineWidth : outlineWidth, 1504 1504 outlineWidth, antialias); 1505 1505 1506 1506 if (thisline.x() == thisline.maxX()) 1507 1507 drawLineForBoxSide(graphicsContext, 1508 left- outlineWidth,1509 top- outlineWidth,1510 right+ outlineWidth,1511 top,1508 pixelSnappedBox.x() - outlineWidth, 1509 pixelSnappedBox.y() - outlineWidth, 1510 pixelSnappedBox.maxX() + outlineWidth, 1511 pixelSnappedBox.y(), 1512 1512 BSTop, outlineColor, outlineStyle, 1513 1513 outlineWidth, … … 1518 1518 if (thisline.x() < nextline.x()) 1519 1519 drawLineForBoxSide(graphicsContext, 1520 left- outlineWidth,1521 bottom,1522 min( right+ outlineWidth, !nextline.isEmpty() ? paintOffset.x() + nextline.x() + 1 : 1000000),1523 bottom+ outlineWidth,1520 pixelSnappedBox.x() - outlineWidth, 1521 pixelSnappedBox.maxY(), 1522 min(pixelSnappedBox.maxX() + outlineWidth, !nextline.isEmpty() ? paintOffset.x() + nextline.x() + 1 : 1000000), 1523 pixelSnappedBox.maxY() + outlineWidth, 1524 1524 BSBottom, outlineColor, outlineStyle, 1525 1525 outlineWidth, 1526 (!nextline.isEmpty() && paintOffset.x() + nextline.x() + 1 < right+ outlineWidth) ? -outlineWidth : outlineWidth,1526 (!nextline.isEmpty() && paintOffset.x() + nextline.x() + 1 < pixelSnappedBox.maxX() + outlineWidth) ? -outlineWidth : outlineWidth, 1527 1527 antialias); 1528 1528 1529 1529 if (nextline.maxX() < thisline.maxX()) 1530 1530 drawLineForBoxSide(graphicsContext, 1531 max(!nextline.isEmpty() ? paintOffset.x() + nextline.maxX() : -1000000, left- outlineWidth),1532 bottom,1533 right+ outlineWidth,1534 bottom+ outlineWidth,1531 max(!nextline.isEmpty() ? paintOffset.x() + nextline.maxX() : -1000000, pixelSnappedBox.x() - outlineWidth), 1532 pixelSnappedBox.maxY(), 1533 pixelSnappedBox.maxX() + outlineWidth, 1534 pixelSnappedBox.maxY() + outlineWidth, 1535 1535 BSBottom, outlineColor, outlineStyle, 1536 (!nextline.isEmpty() && left- outlineWidth < paintOffset.x() + nextline.maxX()) ? -outlineWidth : outlineWidth,1536 (!nextline.isEmpty() && pixelSnappedBox.x() - outlineWidth < paintOffset.x() + nextline.maxX()) ? -outlineWidth : outlineWidth, 1537 1537 outlineWidth, antialias); 1538 1538 1539 1539 if (thisline.x() == thisline.maxX()) 1540 1540 drawLineForBoxSide(graphicsContext, 1541 left- outlineWidth,1542 bottom,1543 right+ outlineWidth,1544 bottom+ outlineWidth,1541 pixelSnappedBox.x() - outlineWidth, 1542 pixelSnappedBox.maxY(), 1543 pixelSnappedBox.maxX() + outlineWidth, 1544 pixelSnappedBox.maxY() + outlineWidth, 1545 1545 BSBottom, outlineColor, outlineStyle, 1546 1546 outlineWidth, -
trunk/Source/WebCore/rendering/RenderObject.cpp
r108690 r108719 808 808 } 809 809 810 void RenderObject::drawLineForBoxSide(GraphicsContext* graphicsContext, LayoutUnit x1, LayoutUnit y1, LayoutUnit x2, LayoutUnit y2,810 void RenderObject::drawLineForBoxSide(GraphicsContext* graphicsContext, int x1, int y1, int x2, int y2, 811 811 BoxSide side, Color color, EBorderStyle style, 812 812 int adjacentWidth1, int adjacentWidth2, bool antialias) … … 983 983 bool wasAntialiased = graphicsContext->shouldAntialias(); 984 984 graphicsContext->setShouldAntialias(antialias); 985 graphicsContext->drawRect( pixelSnappedIntRect(LayoutRect(x1, y1, x2 - x1, y2 - y1)));985 graphicsContext->drawRect(IntRect(x1, y1, x2 - x1, y2 - y1)); 986 986 graphicsContext->setShouldAntialias(wasAntialiased); 987 987 graphicsContext->setStrokeStyle(oldStrokeStyle); … … 1142 1142 Color outlineColor = styleToUse->visitedDependentColor(CSSPropertyOutlineColor); 1143 1143 1144 LayoutUnit outlineOffset = styleToUse->outlineOffset();1144 int outlineOffset = styleToUse->outlineOffset(); 1145 1145 1146 1146 if (styleToUse->outlineStyleIsAuto() || hasOutlineAnnotation()) { … … 1154 1154 return; 1155 1155 1156 LayoutRect inner = paintRect;1156 IntRect inner = pixelSnappedIntRect(paintRect); 1157 1157 inner.inflate(outlineOffset); 1158 1158 1159 LayoutRect outer = inner;1159 IntRect outer = pixelSnappedIntRect(inner); 1160 1160 outer.inflate(outlineWidth); 1161 1161 … … 1179 1179 } 1180 1180 1181 LayoutUnit leftOuter = outer.x();1182 LayoutUnit leftInner = inner.x();1183 LayoutUnit rightOuter = outer.maxX();1184 LayoutUnit rightInner = inner.maxX();1185 LayoutUnit topOuter = outer.y();1186 LayoutUnit topInner = inner.y();1187 LayoutUnit bottomOuter = outer.maxY();1188 LayoutUnit bottomInner = inner.maxY();1181 int leftOuter = outer.x(); 1182 int leftInner = inner.x(); 1183 int rightOuter = outer.maxX(); 1184 int rightInner = inner.maxX(); 1185 int topOuter = outer.y(); 1186 int topInner = inner.y(); 1187 int bottomOuter = outer.maxY(); 1188 int bottomInner = inner.maxY(); 1189 1189 1190 1190 drawLineForBoxSide(graphicsContext, leftOuter, topOuter, leftInner, bottomOuter, BSLeft, outlineColor, outlineStyle, outlineWidth, outlineWidth); -
trunk/Source/WebCore/rendering/RenderObject.h
r108699 r108719 862 862 void propagateStyleToAnonymousChildren(bool blockChildrenOnly = false); 863 863 864 void drawLineForBoxSide(GraphicsContext*, LayoutUnit x1, LayoutUnit y1, LayoutUnit x2, LayoutUnit y2, BoxSide,864 void drawLineForBoxSide(GraphicsContext*, int x1, int y1, int x2, int y2, BoxSide, 865 865 Color, EBorderStyle, int adjbw1, int adjbw2, bool antialias = false); 866 866
Note: See TracChangeset
for help on using the changeset viewer.