Title: [169567] trunk/Source
Revision
169567
Author
benja...@webkit.org
Date
2014-06-03 13:59:04 -0700 (Tue, 03 Jun 2014)

Log Message

[iOS][WK2] Align the highlight rects with device pixels
https://bugs.webkit.org/show_bug.cgi?id=133464

Source/WebCore: 

Patch by Benjamin Poulain <bpoul...@apple.com> on 2014-06-03
Reviewed by Enrica Casucci.

Add utility functions to pixel align points and rects.

* WebCore.exp.in:
* platform/graphics/FloatPoint.h:
(WebCore::flooredToDevicePixels):
(WebCore::ceiledToDevicePixels):
* platform/graphics/FloatRect.cpp:
(WebCore::enclosingRectExtendedToDevicePixels):
* platform/graphics/FloatRect.h:

Source/WebKit2: 
<rdar://problem/16708861>

Patch by Benjamin Poulain <bpoul...@apple.com> on 2014-06-03
Reviewed by Enrica Casucci.

* UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView _showTapHighlightWithColor:WebCore::quads:WebCore::topLeftRadius:WebCore::topRightRadius:WebCore::bottomLeftRadius:WebCore::bottomRightRadius:WebCore::]):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (169566 => 169567)


--- trunk/Source/WebCore/ChangeLog	2014-06-03 20:13:32 UTC (rev 169566)
+++ trunk/Source/WebCore/ChangeLog	2014-06-03 20:59:04 UTC (rev 169567)
@@ -1,3 +1,20 @@
+2014-06-03  Benjamin Poulain  <bpoul...@apple.com>
+
+        [iOS][WK2] Align the highlight rects with device pixels
+        https://bugs.webkit.org/show_bug.cgi?id=133464
+
+        Reviewed by Enrica Casucci.
+
+        Add utility functions to pixel align points and rects.
+
+        * WebCore.exp.in:
+        * platform/graphics/FloatPoint.h:
+        (WebCore::flooredToDevicePixels):
+        (WebCore::ceiledToDevicePixels):
+        * platform/graphics/FloatRect.cpp:
+        (WebCore::enclosingRectExtendedToDevicePixels):
+        * platform/graphics/FloatRect.h:
+
 2014-06-03  Timothy Horton  <timothy_hor...@apple.com>
 
         Prepopulated tiles may never be unparented from TileGrids with aggressive tile retention on

Modified: trunk/Source/WebCore/WebCore.exp.in (169566 => 169567)


--- trunk/Source/WebCore/WebCore.exp.in	2014-06-03 20:13:32 UTC (rev 169566)
+++ trunk/Source/WebCore/WebCore.exp.in	2014-06-03 20:59:04 UTC (rev 169567)
@@ -2638,6 +2638,7 @@
 __ZN7WebCore31applicationIsMicrosoftMessengerEv
 __ZN7WebCore31enableURLSchemeCanonicalizationEb
 __ZN7WebCore33applicationIsTheEconomistOnIPhoneEv
+__ZN7WebCore35enclosingRectExtendedToDevicePixelsERKNS_9FloatRectEf
 __ZN7WebCore35positionOfNextBoundaryOfGranularityERKNS_15VisiblePositionENS_15TextGranularityENS_18SelectionDirectionE
 __ZN7WebCore41initializeHTTPConnectionSettingsOnStartupEv
 __ZN7WebCore4FontC1ERKNS_16FontPlatformDataEN3WTF10PassRefPtrINS_12FontSelectorEEE

Modified: trunk/Source/WebCore/platform/graphics/FloatPoint.h (169566 => 169567)


--- trunk/Source/WebCore/platform/graphics/FloatPoint.h	2014-06-03 20:13:32 UTC (rev 169566)
+++ trunk/Source/WebCore/platform/graphics/FloatPoint.h	2014-06-03 20:59:04 UTC (rev 169567)
@@ -220,11 +220,21 @@
     return IntPoint(clampToInteger(floorf(p.x())), clampToInteger(floorf(p.y())));
 }
 
+inline FloatPoint flooredToDevicePixels(const FloatPoint& p, float deviceScaleFactor)
+{
+    return FloatPoint(floorf(p.x() * deviceScaleFactor)  / deviceScaleFactor, floorf(p.y() * deviceScaleFactor)  / deviceScaleFactor);
+}
+
 inline IntPoint ceiledIntPoint(const FloatPoint& p)
 {
     return IntPoint(clampToInteger(ceilf(p.x())), clampToInteger(ceilf(p.y())));
 }
 
+inline FloatPoint ceiledToDevicePixels(const FloatPoint& p, float deviceScaleFactor)
+{
+    return FloatPoint(ceilf(p.x() * deviceScaleFactor)  / deviceScaleFactor, ceilf(p.y() * deviceScaleFactor)  / deviceScaleFactor);
+}
+
 inline IntSize flooredIntSize(const FloatPoint& p)
 {
     return IntSize(clampToInteger(floorf(p.x())), clampToInteger(floorf(p.y())));

Modified: trunk/Source/WebCore/platform/graphics/FloatRect.cpp (169566 => 169567)


--- trunk/Source/WebCore/platform/graphics/FloatRect.cpp	2014-06-03 20:13:32 UTC (rev 169566)
+++ trunk/Source/WebCore/platform/graphics/FloatRect.cpp	2014-06-03 20:59:04 UTC (rev 169567)
@@ -206,6 +206,13 @@
     setLocationAndSizeFromEdges(left, top, right, bottom);
 }
 
+FloatRect enclosingRectExtendedToDevicePixels(const FloatRect& rect, float deviceScaleFactor)
+{
+    FloatPoint location = flooredToDevicePixels(rect.minXMinYCorner(), deviceScaleFactor);
+    FloatPoint maxPoint = ceiledToDevicePixels(rect.maxXMaxYCorner(), deviceScaleFactor);
+    return FloatRect(location, maxPoint - location);
+}
+
 IntRect enclosingIntRect(const FloatRect& rect)
 {
     IntPoint location = flooredIntPoint(rect.minXMinYCorner());

Modified: trunk/Source/WebCore/platform/graphics/FloatRect.h (169566 => 169567)


--- trunk/Source/WebCore/platform/graphics/FloatRect.h	2014-06-03 20:13:32 UTC (rev 169566)
+++ trunk/Source/WebCore/platform/graphics/FloatRect.h	2014-06-03 20:59:04 UTC (rev 169567)
@@ -246,6 +246,7 @@
     return *this == infiniteRect();
 }
 
+FloatRect enclosingRectExtendedToDevicePixels(const FloatRect&, float deviceScaleFactor);
 IntRect enclosingIntRect(const FloatRect&);
 
 // Returns a valid IntRect contained within the given FloatRect.

Modified: trunk/Source/WebKit2/ChangeLog (169566 => 169567)


--- trunk/Source/WebKit2/ChangeLog	2014-06-03 20:13:32 UTC (rev 169566)
+++ trunk/Source/WebKit2/ChangeLog	2014-06-03 20:59:04 UTC (rev 169567)
@@ -1,3 +1,14 @@
+2014-06-03  Benjamin Poulain  <bpoul...@apple.com>
+
+        [iOS][WK2] Align the highlight rects with device pixels
+        https://bugs.webkit.org/show_bug.cgi?id=133464
+        <rdar://problem/16708861>
+
+        Reviewed by Enrica Casucci.
+
+        * UIProcess/ios/WKContentViewInteraction.mm:
+        (-[WKContentView _showTapHighlightWithColor:WebCore::quads:WebCore::topLeftRadius:WebCore::topRightRadius:WebCore::bottomLeftRadius:WebCore::bottomRightRadius:WebCore::]):
+
 2014-06-02  Enrica Casucci  <enr...@apple.com>
 
         REGRESSION (iOS WebKit2): Single tap in pages with focus on load will clear the selection after the keyboard appears.

Modified: trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm (169566 => 169567)


--- trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm	2014-06-03 20:13:32 UTC (rev 169566)
+++ trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm	2014-06-03 20:59:04 UTC (rev 169567)
@@ -401,6 +401,7 @@
     }
 
     bool allHighlightRectsAreRectilinear = true;
+    float deviceScaleFactor = _page->deviceScaleFactor();
     const size_t quadCount = highlightedQuads.size();
     RetainPtr<NSMutableArray> rects = adoptNS([[NSMutableArray alloc] initWithCapacity:static_cast<const NSUInteger>(quadCount)]);
     for (size_t i = 0; i < quadCount; ++i) {
@@ -408,8 +409,9 @@
         if (quad.isRectilinear()) {
             FloatRect boundingBox = quad.boundingBox();
             boundingBox.scale(selfScale);
-            CGRect rect = CGRectInset(boundingBox, -UIWebViewMinimumHighlightRadius, -UIWebViewMinimumHighlightRadius);
-            [rects addObject:[NSValue valueWithCGRect:rect]];
+            boundingBox.inflate(UIWebViewMinimumHighlightRadius);
+            CGRect pixelAlignedRect = static_cast<CGRect>(enclosingRectExtendedToDevicePixels(boundingBox, deviceScaleFactor));
+            [rects addObject:[NSValue valueWithCGRect:pixelAlignedRect]];
         } else {
             allHighlightRectsAreRectilinear = false;
             rects.clear();
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to