Changeset 196334 in webkit
- Timestamp:
- Feb 9, 2016 2:01:24 PM (8 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r196314 r196334 1 2016-02-09 Zalan Bujtas <zalan@apple.com> 2 3 Outline corners do not align properly for multiline inlines. 4 https://bugs.webkit.org/show_bug.cgi?id=154025 5 6 Reviewed by David Hyatt. 7 8 Adjust border position when outline-offset > 0. This patch also 9 removes integral pixelsnapping (drawLineForBoxSide takes care of 10 device pixelsnapping). 11 12 * fast/inline/outline-corners-with-offset-expected.html: Added. 13 * fast/inline/outline-corners-with-offset.html: Added. 14 1 15 2016-02-09 Zalan Bujtas <zalan@apple.com> 2 16 -
trunk/Source/WebCore/ChangeLog
r196332 r196334 1 2016-02-09 Zalan Bujtas <zalan@apple.com> 2 3 Outline corners do not align properly for multiline inlines. 4 https://bugs.webkit.org/show_bug.cgi?id=154025 5 6 Reviewed by David Hyatt. 7 8 Adjust border position when outline-offset > 0. This patch also 9 removes integral pixelsnapping (drawLineForBoxSide takes care of 10 device pixelsnapping). 11 12 Test: fast/inline/outline-corners-with-offset.html 13 14 * rendering/RenderInline.cpp: 15 (WebCore::RenderInline::paintOutlineForLine): 16 1 17 2016-02-09 Jer Noble <jer.noble@apple.com> 2 18 -
trunk/Source/WebCore/rendering/RenderInline.cpp
r196222 r196334 1638 1638 1639 1639 void RenderInline::paintOutlineForLine(GraphicsContext& graphicsContext, const LayoutPoint& paintOffset, 1640 const LayoutRect& lastline, const LayoutRect& thisline, const LayoutRect& nextline, 1641 const Color outlineColor) 1642 { 1643 const RenderStyle& styleToUse = style(); 1640 const LayoutRect& previousLine, const LayoutRect& thisLine, const LayoutRect& nextLine, const Color outlineColor) 1641 { 1642 const auto& styleToUse = style(); 1643 float outlineOffset = styleToUse.outlineOffset(); 1644 LayoutRect outlineBoxRect = thisLine; 1645 outlineBoxRect.inflate(outlineOffset); 1646 outlineBoxRect.moveBy(paintOffset); 1647 if (outlineBoxRect.isEmpty()) 1648 return; 1649 1644 1650 float outlineWidth = styleToUse.outlineWidth(); 1645 float outlineOffset = style().outlineOffset();1646 1651 EBorderStyle outlineStyle = styleToUse.outlineStyle(); 1647 1652 bool antialias = shouldAntialiasLines(graphicsContext); 1648 1653 1649 LayoutRect box(LayoutPoint(paintOffset.x() + thisline.x() - outlineOffset, paintOffset.y() + thisline.y() - outlineOffset), 1650 LayoutSize(thisline.width() + 2 * outlineOffset, thisline.height() + 2 * outlineOffset)); 1651 1652 IntRect pixelSnappedBox = snappedIntRect(box); 1653 if (pixelSnappedBox.isEmpty()) 1654 return; 1655 IntRect pixelSnappedLastLine = snappedIntRect(paintOffset.x() + lastline.x(), 0, lastline.width(), 0); 1656 IntRect pixelSnappedNextLine = snappedIntRect(paintOffset.x() + nextline.x(), 0, nextline.width(), 0); 1657 1654 auto adjustedPreviousLine = previousLine; 1655 adjustedPreviousLine.moveBy(paintOffset); 1656 auto adjustedNextLine = nextLine; 1657 adjustedNextLine.moveBy(paintOffset); 1658 1659 float adjacentWidth1 = 0; 1660 float adjacentWidth2 = 0; 1658 1661 // left edge 1659 drawLineForBoxSide(graphicsContext, 1660 FloatRect(FloatPoint(pixelSnappedBox.x() - outlineWidth, 1661 pixelSnappedBox.y() - (lastline.isEmpty() || thisline.x() < lastline.x() || (lastline.maxX() - 1) <= thisline.x() ? outlineWidth : 0)), 1662 FloatPoint(pixelSnappedBox.x(), 1663 pixelSnappedBox.maxY() + (nextline.isEmpty() || thisline.x() <= nextline.x() || (nextline.maxX() - 1) <= thisline.x() ? outlineWidth : 0))), 1664 BSLeft, 1665 outlineColor, outlineStyle, 1666 (lastline.isEmpty() || thisline.x() < lastline.x() || (lastline.maxX() - 1) <= thisline.x() ? outlineWidth : -outlineWidth), 1667 (nextline.isEmpty() || thisline.x() <= nextline.x() || (nextline.maxX() - 1) <= thisline.x() ? outlineWidth : -outlineWidth), 1668 antialias); 1662 auto topLeft = outlineBoxRect.minXMinYCorner(); 1663 if (previousLine.isEmpty() || thisLine.x() < previousLine.x() || (previousLine.maxX()) <= thisLine.x()) { 1664 topLeft.move(-outlineWidth, -outlineWidth); 1665 adjacentWidth1 = outlineWidth; 1666 } else { 1667 topLeft.move(-outlineWidth, 2 * outlineOffset); 1668 adjacentWidth1 = -outlineWidth; 1669 } 1670 auto bottomRight = outlineBoxRect.minXMaxYCorner(); 1671 if (nextLine.isEmpty() || thisLine.x() <= nextLine.x() || (nextLine.maxX()) <= thisLine.x()) { 1672 bottomRight.move(0, outlineWidth); 1673 adjacentWidth2 = outlineWidth; 1674 } else { 1675 bottomRight.move(0, -2 * outlineOffset); 1676 adjacentWidth2 = -outlineWidth; 1677 } 1678 drawLineForBoxSide(graphicsContext, FloatRect(topLeft, bottomRight), BSLeft, outlineColor, outlineStyle, adjacentWidth1, adjacentWidth2, antialias); 1669 1679 1670 1680 // right edge 1671 drawLineForBoxSide(graphicsContext, 1672 FloatRect(FloatPoint(pixelSnappedBox.maxX(), 1673 pixelSnappedBox.y() - (lastline.isEmpty() || lastline.maxX() < thisline.maxX() || (thisline.maxX() - 1) <= lastline.x() ? outlineWidth : 0)), 1674 FloatPoint(pixelSnappedBox.maxX() + outlineWidth, 1675 pixelSnappedBox.maxY() + (nextline.isEmpty() || nextline.maxX() <= thisline.maxX() || (thisline.maxX() - 1) <= nextline.x() ? outlineWidth : 0))), 1676 BSRight, 1677 outlineColor, outlineStyle, 1678 (lastline.isEmpty() || lastline.maxX() < thisline.maxX() || (thisline.maxX() - 1) <= lastline.x() ? outlineWidth : -outlineWidth), 1679 (nextline.isEmpty() || nextline.maxX() <= thisline.maxX() || (thisline.maxX() - 1) <= nextline.x() ? outlineWidth : -outlineWidth), 1680 antialias); 1681 topLeft = outlineBoxRect.maxXMinYCorner(); 1682 if (previousLine.isEmpty() || previousLine.maxX() < thisLine.maxX() || thisLine.maxX() <= previousLine.x()) { 1683 topLeft.move(0, -outlineWidth); 1684 adjacentWidth1 = outlineWidth; 1685 } else { 1686 topLeft.move(0, 2 * outlineOffset); 1687 adjacentWidth1 = -outlineWidth; 1688 } 1689 bottomRight = outlineBoxRect.maxXMaxYCorner(); 1690 if (nextLine.isEmpty() || nextLine.maxX() <= thisLine.maxX() || thisLine.maxX() <= nextLine.x()) { 1691 bottomRight.move(outlineWidth, outlineWidth); 1692 adjacentWidth2 = outlineWidth; 1693 } else { 1694 bottomRight.move(outlineWidth, -2 * outlineOffset); 1695 adjacentWidth2 = -outlineWidth; 1696 } 1697 drawLineForBoxSide(graphicsContext, FloatRect(topLeft, bottomRight), BSRight, outlineColor, outlineStyle, adjacentWidth1, adjacentWidth2, antialias); 1698 1681 1699 // upper edge 1682 if (thisline.x() < lastline.x()) 1683 drawLineForBoxSide(graphicsContext, 1684 FloatRect(FloatPoint(pixelSnappedBox.x() - outlineWidth, 1685 pixelSnappedBox.y() - outlineWidth), 1686 FloatPoint(std::min<float>(pixelSnappedBox.maxX() + outlineWidth, (lastline.isEmpty() ? 1000000 : pixelSnappedLastLine.x())), 1687 pixelSnappedBox.y())), 1688 BSTop, outlineColor, outlineStyle, 1689 outlineWidth, 1690 (!lastline.isEmpty() && paintOffset.x() + lastline.x() + 1 < pixelSnappedBox.maxX() + outlineWidth) ? -outlineWidth : outlineWidth, 1691 antialias); 1692 1693 if (lastline.maxX() < thisline.maxX()) 1694 drawLineForBoxSide(graphicsContext, 1695 FloatRect(FloatPoint(std::max<float>(lastline.isEmpty() ? -1000000 : pixelSnappedLastLine.maxX(), pixelSnappedBox.x() - outlineWidth), 1696 pixelSnappedBox.y() - outlineWidth), 1697 FloatPoint(pixelSnappedBox.maxX() + outlineWidth, 1698 pixelSnappedBox.y())), 1699 BSTop, outlineColor, outlineStyle, 1700 (!lastline.isEmpty() && pixelSnappedBox.x() - outlineWidth < paintOffset.x() + lastline.maxX()) ? -outlineWidth : outlineWidth, 1701 outlineWidth, antialias); 1702 1703 if (thisline.x() == thisline.maxX()) 1704 drawLineForBoxSide(graphicsContext, 1705 FloatRect(FloatPoint(pixelSnappedBox.x() - outlineWidth, 1706 pixelSnappedBox.y() - outlineWidth), 1707 FloatPoint(pixelSnappedBox.maxX() + outlineWidth, 1708 pixelSnappedBox.y())), 1709 BSTop, outlineColor, outlineStyle, 1710 outlineWidth, 1711 outlineWidth, 1712 antialias); 1700 if (thisLine.x() < previousLine.x()) { 1701 topLeft = outlineBoxRect.minXMinYCorner(); 1702 topLeft.move(-outlineWidth, -outlineWidth); 1703 adjacentWidth1 = outlineWidth; 1704 bottomRight = outlineBoxRect.maxXMinYCorner(); 1705 bottomRight.move(outlineWidth, 0); 1706 if (!previousLine.isEmpty() && adjustedPreviousLine.x() < bottomRight.x()) { 1707 bottomRight.setX(adjustedPreviousLine.x() - outlineOffset); 1708 adjacentWidth2 = -outlineWidth; 1709 } else 1710 adjacentWidth2 = outlineWidth; 1711 drawLineForBoxSide(graphicsContext, FloatRect(topLeft, bottomRight), BSTop, outlineColor, outlineStyle, adjacentWidth1, adjacentWidth2, antialias); 1712 } 1713 1714 if (previousLine.maxX() < thisLine.maxX()) { 1715 topLeft = outlineBoxRect.minXMinYCorner(); 1716 topLeft.move(-outlineWidth, -outlineWidth); 1717 if (!previousLine.isEmpty() && adjustedPreviousLine.maxX() > topLeft.x()) { 1718 topLeft.setX(adjustedPreviousLine.maxX() + outlineOffset); 1719 adjacentWidth1 = -outlineWidth; 1720 } else 1721 adjacentWidth1 = outlineWidth; 1722 bottomRight = outlineBoxRect.maxXMinYCorner(); 1723 bottomRight.move(outlineWidth, 0); 1724 adjacentWidth2 = outlineWidth; 1725 drawLineForBoxSide(graphicsContext, FloatRect(topLeft, bottomRight), BSTop, outlineColor, outlineStyle, adjacentWidth1, adjacentWidth2, antialias); 1726 } 1727 1728 if (thisLine.x() == thisLine.maxX()) { 1729 topLeft = outlineBoxRect.minXMinYCorner(); 1730 topLeft.move(-outlineWidth, -outlineWidth); 1731 adjacentWidth1 = outlineWidth; 1732 bottomRight = outlineBoxRect.maxXMinYCorner(); 1733 bottomRight.move(outlineWidth, 0); 1734 adjacentWidth2 = outlineWidth; 1735 drawLineForBoxSide(graphicsContext, FloatRect(topLeft, bottomRight), BSTop, outlineColor, outlineStyle, adjacentWidth1, adjacentWidth2, antialias); 1736 } 1713 1737 1714 1738 // lower edge 1715 if (thisline.x() < nextline.x()) 1716 drawLineForBoxSide(graphicsContext, 1717 FloatRect(FloatPoint(pixelSnappedBox.x() - outlineWidth, 1718 pixelSnappedBox.maxY()), 1719 FloatPoint(std::min<float>(pixelSnappedBox.maxX() + outlineWidth, !nextline.isEmpty() ? pixelSnappedNextLine.x() + 1 : 1000000), 1720 pixelSnappedBox.maxY() + outlineWidth)), 1721 BSBottom, outlineColor, outlineStyle, 1722 outlineWidth, 1723 (!nextline.isEmpty() && paintOffset.x() + nextline.x() + 1 < pixelSnappedBox.maxX() + outlineWidth) ? -outlineWidth : outlineWidth, 1724 antialias); 1725 1726 if (nextline.maxX() < thisline.maxX()) 1727 drawLineForBoxSide(graphicsContext, 1728 FloatRect(FloatPoint(std::max<float>(!nextline.isEmpty() ? pixelSnappedNextLine.maxX() : -1000000, pixelSnappedBox.x() - outlineWidth), 1729 pixelSnappedBox.maxY()), 1730 FloatPoint(pixelSnappedBox.maxX() + outlineWidth, 1731 pixelSnappedBox.maxY() + outlineWidth)), 1732 BSBottom, outlineColor, outlineStyle, 1733 (!nextline.isEmpty() && pixelSnappedBox.x() - outlineWidth < paintOffset.x() + nextline.maxX()) ? -outlineWidth : outlineWidth, 1734 outlineWidth, antialias); 1735 1736 if (thisline.x() == thisline.maxX()) 1737 drawLineForBoxSide(graphicsContext, 1738 FloatRect(FloatPoint(pixelSnappedBox.x() - outlineWidth, 1739 pixelSnappedBox.maxY()), 1740 FloatPoint(pixelSnappedBox.maxX() + outlineWidth, 1741 pixelSnappedBox.maxY() + outlineWidth)), 1742 BSBottom, outlineColor, outlineStyle, 1743 outlineWidth, 1744 outlineWidth, 1745 antialias); 1739 if (thisLine.x() < nextLine.x()) { 1740 topLeft = outlineBoxRect.minXMaxYCorner(); 1741 topLeft.move(-outlineWidth, 0); 1742 adjacentWidth1 = outlineWidth; 1743 bottomRight = outlineBoxRect.maxXMaxYCorner(); 1744 bottomRight.move(outlineWidth, outlineWidth); 1745 if (!nextLine.isEmpty() && (adjustedNextLine.x() < bottomRight.x())) { 1746 bottomRight.setX(adjustedNextLine.x() - outlineOffset); 1747 adjacentWidth2 = -outlineWidth; 1748 } else 1749 adjacentWidth2 = outlineWidth; 1750 drawLineForBoxSide(graphicsContext, FloatRect(topLeft, bottomRight), BSBottom, outlineColor, outlineStyle, adjacentWidth1, adjacentWidth2, antialias); 1751 } 1752 1753 if (nextLine.maxX() < thisLine.maxX()) { 1754 topLeft = outlineBoxRect.minXMaxYCorner(); 1755 topLeft.move(-outlineWidth, 0); 1756 if (!nextLine.isEmpty() && adjustedNextLine.maxX() > topLeft.x()) { 1757 topLeft.setX(adjustedNextLine.maxX() + outlineOffset); 1758 adjacentWidth1 = -outlineWidth; 1759 } else 1760 adjacentWidth1 = outlineWidth; 1761 bottomRight = outlineBoxRect.maxXMaxYCorner(); 1762 bottomRight.move(outlineWidth, outlineWidth); 1763 adjacentWidth2 = outlineWidth; 1764 drawLineForBoxSide(graphicsContext, FloatRect(topLeft, bottomRight), BSBottom, outlineColor, outlineStyle, adjacentWidth1, adjacentWidth2, antialias); 1765 } 1766 1767 if (thisLine.x() == thisLine.maxX()) { 1768 topLeft = outlineBoxRect.minXMaxYCorner(); 1769 topLeft.move(-outlineWidth, 0); 1770 adjacentWidth1 = outlineWidth; 1771 bottomRight = outlineBoxRect.maxXMaxYCorner(); 1772 bottomRight.move(outlineWidth, outlineWidth); 1773 adjacentWidth2 = outlineWidth; 1774 drawLineForBoxSide(graphicsContext, FloatRect(topLeft, bottomRight), BSBottom, outlineColor, outlineStyle, adjacentWidth1, adjacentWidth2, antialias); 1775 } 1746 1776 } 1747 1777
Note: See TracChangeset
for help on using the changeset viewer.