Title: [97971] trunk/Source/WebCore
Revision
97971
Author
carycl...@google.com
Date
2011-10-20 06:18:51 -0700 (Thu, 20 Oct 2011)

Log Message

[Chromium Skia on Mac] Improve focus ring
https://bugs.webkit.org/show_bug.cgi?id=70124

Reviewed by Adam Barth.

The focus ring code formerly outset the bounds of
the component rectangles by fractional amounts. Because
the rectangles are SkIRect (integer based), the fractional
outset had no effect.

The equivalent code in GraphicsContextMac.mm computes
the curve radius and rectangle outset with integers, so
the use of floats in Skia's case, besides not working,
is unnecessary.

The Skia code also failed to take the offset into account.
In LayoutTests, the focus rings either have an offset of
0 or 2. The CoreGraphics code increases the ring's rectangles
by the offset, then passes the result to wkDrawFocusRing.

I did not find any documentation about how wkDrawFocusRing
further inflates the focus ring, but empirically I determined
that adding 2 to the offset generated rings with identical
outer diameters.

With these adjustments, the layout tests generate focus rings
in the Skia on Mac case that match the coverage of the
Chromium CG-based platform, in particular, matching:

editing/inserting/editable-inline-element.html
editing/selection/3690703-2.html

* platform/graphics/skia/GraphicsContextSkia.cpp:
(WebCore::getFocusRingOutset):
(WebCore::GraphicsContext::drawFocusRing):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (97970 => 97971)


--- trunk/Source/WebCore/ChangeLog	2011-10-20 13:05:21 UTC (rev 97970)
+++ trunk/Source/WebCore/ChangeLog	2011-10-20 13:18:51 UTC (rev 97971)
@@ -1,3 +1,41 @@
+2011-10-20  Cary Clark  <carycl...@google.com>
+
+        [Chromium Skia on Mac] Improve focus ring
+        https://bugs.webkit.org/show_bug.cgi?id=70124
+
+        Reviewed by Adam Barth.
+        
+        The focus ring code formerly outset the bounds of
+        the component rectangles by fractional amounts. Because
+        the rectangles are SkIRect (integer based), the fractional
+        outset had no effect.
+
+        The equivalent code in GraphicsContextMac.mm computes
+        the curve radius and rectangle outset with integers, so
+        the use of floats in Skia's case, besides not working,
+        is unnecessary.
+
+        The Skia code also failed to take the offset into account.
+        In LayoutTests, the focus rings either have an offset of
+        0 or 2. The CoreGraphics code increases the ring's rectangles
+        by the offset, then passes the result to wkDrawFocusRing.
+
+        I did not find any documentation about how wkDrawFocusRing
+        further inflates the focus ring, but empirically I determined
+        that adding 2 to the offset generated rings with identical
+        outer diameters.
+ 
+        With these adjustments, the layout tests generate focus rings
+        in the Skia on Mac case that match the coverage of the
+        Chromium CG-based platform, in particular, matching:
+        
+        editing/inserting/editable-inline-element.html
+        editing/selection/3690703-2.html
+
+        * platform/graphics/skia/GraphicsContextSkia.cpp:
+        (WebCore::getFocusRingOutset):
+        (WebCore::GraphicsContext::drawFocusRing):
+
 2011-10-20  Zoltan Herczeg  <zherc...@webkit.org>
 
         Improve NEON based GaussianBlur

Modified: trunk/Source/WebCore/platform/graphics/skia/GraphicsContextSkia.cpp (97970 => 97971)


--- trunk/Source/WebCore/platform/graphics/skia/GraphicsContextSkia.cpp	2011-10-20 13:05:21 UTC (rev 97970)
+++ trunk/Source/WebCore/platform/graphics/skia/GraphicsContextSkia.cpp	2011-10-20 13:18:51 UTC (rev 97971)
@@ -538,16 +538,16 @@
 #endif
 }
 
-static inline SkScalar getFocusRingOutset()
+static inline int getFocusRingOutset(int offset)
 {
 #if PLATFORM(CHROMIUM) && OS(DARWIN)
-    return 0.75f;
+    return offset + 2;
 #else
-    return 0.5f;
+    return 0;
 #endif
 }
 
-void GraphicsContext::drawFocusRing(const Vector<IntRect>& rects, int width, int /* offset */, const Color& color)
+void GraphicsContext::drawFocusRing(const Vector<IntRect>& rects, int width, int offset, const Color& color)
 {
     if (paintingDisabled())
         return;
@@ -557,7 +557,7 @@
         return;
 
     SkRegion focusRingRegion;
-    const SkScalar focusRingOutset = getFocusRingOutset();
+    const int focusRingOutset = getFocusRingOutset(offset);
     for (unsigned i = 0; i < rectCount; i++) {
         SkIRect r = rects[i];
         r.inset(-focusRingOutset, -focusRingOutset);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to