[Forms: focus] focus rings around text fields do not follow contour (border-radius)
authorzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 12 Mar 2016 17:24:21 +0000 (17:24 +0000)
committerzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 12 Mar 2016 17:24:21 +0000 (17:24 +0000)
commit1ca9e0bcad092c9a6c3971b485d26cd98aaf1a54
tree0452988baec48d7ea54bb6ae7eefab075b8661f0
parent3684be23bd3901966ba2f70a4b904416077e93a2
[Forms: focus] focus rings around text fields do not follow contour (border-radius)
https://bugs.webkit.org/show_bug.cgi?id=154099
rdar://problem/9988429

Reviewed by Tim Horton.

Source/WebCore:

This patch enables outline-style: auto to follow the curve of border-radius.
When both border-radius and outline-style: auto are set, the native focusring painting will take the border-radius values
into account. This is only for outline-style: auto, other non-auto outline styles paint as if there
was no border-radius set.
It supports both single and multiline content with joint rectangles.
However in case of disjoint rectangles, we fallback to the non-radius drawing.

Tests: fast/inline/hidpi-outline-auto-with-border-radius-horizontal-ltr.html
       fast/inline/hidpi-outline-auto-with-border-radius-horizontal-rtl.html
       fast/inline/hidpi-outline-auto-with-border-radius-vertical-ltr.html
       fast/inline/hidpi-outline-auto-with-border-radius-vertical-rtl.html

* platform/graphics/GraphicsContext.h:
* platform/graphics/Path.cpp:
(WebCore::Path::addBeziersForRoundedRect):
* platform/graphics/Path.h:
(WebCore::Path::circleControlPoint):
* platform/graphics/PathUtilities.cpp:
(WebCore::polygonsForRect):
(WebCore::PathUtilities::pathsWithShrinkWrappedRects):
(WebCore::startAndEndPointsForCorner):
(WebCore::cornerType):
(WebCore::controlPointsForBezierCurve):
(WebCore::adjustedtRadiiForHuggingCurve):
(WebCore::PathUtilities::pathWithShrinkWrappedRectsForOutline):
* platform/graphics/PathUtilities.h:
* platform/graphics/mac/GraphicsContextMac.mm:
(WebCore::GraphicsContext::drawFocusRing):
* rendering/RenderElement.cpp:
(WebCore::RenderElement::paintFocusRing):

LayoutTests:

Unfortunately there's no proper way to test native focusring drawing.
These tests attempt to verify that we don't end up painting sharp corners.

* fast/inline/hidpi-outline-auto-with-border-radius-horizontal-ltr-expected.html: Added.
* fast/inline/hidpi-outline-auto-with-border-radius-horizontal-ltr.html: Added.
* fast/inline/hidpi-outline-auto-with-border-radius-horizontal-rtl-expected.html: Added.
* fast/inline/hidpi-outline-auto-with-border-radius-horizontal-rtl.html: Added.
* fast/inline/hidpi-outline-auto-with-border-radius-vertical-ltr-expected.html: Added.
* fast/inline/hidpi-outline-auto-with-border-radius-vertical-ltr.html: Added.
* fast/inline/hidpi-outline-auto-with-border-radius-vertical-rtl-expected.html: Added.
* fast/inline/hidpi-outline-auto-with-border-radius-vertical-rtl.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@198062 268f45cc-cd09-0410-ab3c-d52691b4dbfc
17 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/inline/hidpi-outline-auto-with-border-radius-horizontal-ltr-expected.html [new file with mode: 0644]
LayoutTests/fast/inline/hidpi-outline-auto-with-border-radius-horizontal-ltr.html [new file with mode: 0644]
LayoutTests/fast/inline/hidpi-outline-auto-with-border-radius-horizontal-rtl-expected.html [new file with mode: 0644]
LayoutTests/fast/inline/hidpi-outline-auto-with-border-radius-horizontal-rtl.html [new file with mode: 0644]
LayoutTests/fast/inline/hidpi-outline-auto-with-border-radius-vertical-ltr-expected.html [new file with mode: 0644]
LayoutTests/fast/inline/hidpi-outline-auto-with-border-radius-vertical-ltr.html [new file with mode: 0644]
LayoutTests/fast/inline/hidpi-outline-auto-with-border-radius-vertical-rtl-expected.html [new file with mode: 0644]
LayoutTests/fast/inline/hidpi-outline-auto-with-border-radius-vertical-rtl.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/GraphicsContext.h
Source/WebCore/platform/graphics/Path.cpp
Source/WebCore/platform/graphics/Path.h
Source/WebCore/platform/graphics/PathUtilities.cpp
Source/WebCore/platform/graphics/PathUtilities.h
Source/WebCore/platform/graphics/mac/GraphicsContextMac.mm
Source/WebCore/rendering/RenderElement.cpp