Title: [168117] trunk/Source/WebKit2
Revision
168117
Author
benja...@webkit.org
Date
2014-05-01 13:32:57 -0700 (Thu, 01 May 2014)

Log Message

[iOS][WK2] The highlight view needs to be in WKWebView coordinates
https://bugs.webkit.org/show_bug.cgi?id=132435
<rdar://problem/16708861>

Patch by Benjamin Poulain <bpoul...@apple.com> on 2014-05-01
Reviewed by Tim Horton.

_UIHighlightView needs to be in WKWebView coordinates so that it render unscaled for any page scale factor.
The view needs to be a child of WKContentView so that it moves/scales with the page.

To fix the issue, add an inverse transform root layer for the hightlight, and scale the coordinates to their
inverse scaled counterpart.

The scale is not updated live with the scaling of WKContentView but that should be fine since the view disappear
on any scaling operation (and I would prefer not add live painting during scaling animation).

* UIProcess/ios/WKContentViewInteraction.h:
* UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView cleanupInteraction]):
(-[WKContentView _didGetTapHighlightForRequest:color:WebCore::quads:WebCore::topLeftRadius:WebCore::topRightRadius:WebCore::bottomLeftRadius:WebCore::bottomRightRadius:WebCore::]):
(-[WKContentView _cancelInteraction]):

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (168116 => 168117)


--- trunk/Source/WebKit2/ChangeLog	2014-05-01 20:03:27 UTC (rev 168116)
+++ trunk/Source/WebKit2/ChangeLog	2014-05-01 20:32:57 UTC (rev 168117)
@@ -1,3 +1,26 @@
+2014-05-01  Benjamin Poulain  <bpoul...@apple.com>
+
+        [iOS][WK2] The highlight view needs to be in WKWebView coordinates
+        https://bugs.webkit.org/show_bug.cgi?id=132435
+        <rdar://problem/16708861>
+
+        Reviewed by Tim Horton.
+
+        _UIHighlightView needs to be in WKWebView coordinates so that it render unscaled for any page scale factor.
+        The view needs to be a child of WKContentView so that it moves/scales with the page.
+
+        To fix the issue, add an inverse transform root layer for the hightlight, and scale the coordinates to their
+        inverse scaled counterpart.
+
+        The scale is not updated live with the scaling of WKContentView but that should be fine since the view disappear
+        on any scaling operation (and I would prefer not add live painting during scaling animation).
+
+        * UIProcess/ios/WKContentViewInteraction.h:
+        * UIProcess/ios/WKContentViewInteraction.mm:
+        (-[WKContentView cleanupInteraction]):
+        (-[WKContentView _didGetTapHighlightForRequest:color:WebCore::quads:WebCore::topLeftRadius:WebCore::topRightRadius:WebCore::bottomLeftRadius:WebCore::bottomRightRadius:WebCore::]):
+        (-[WKContentView _cancelInteraction]):
+
 2014-05-01  Ryuan Choi  <ryuan.c...@samsung.com>
 
         [EFL] There are many warnings with software backend

Modified: trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.h (168116 => 168117)


--- trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.h	2014-05-01 20:03:27 UTC (rev 168116)
+++ trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.h	2014-05-01 20:32:57 UTC (rev 168117)
@@ -92,6 +92,7 @@
 
     RetainPtr<UITextInputTraits> _traits;
     RetainPtr<UIWebFormAccessory> _formAccessoryView;
+    RetainPtr<UIView> _highlightRootView;
     RetainPtr<_UIHighlightView> _highlightView;
     RetainPtr<NSString> _markedText;
     RetainPtr<WKActionSheetAssistant> _actionSheetAssistant;

Modified: trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm (168116 => 168117)


--- trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm	2014-05-01 20:03:27 UTC (rev 168116)
+++ trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm	2014-05-01 20:32:57 UTC (rev 168117)
@@ -230,6 +230,8 @@
     _actionSheetAssistant = nil;
     [_formInputSession invalidate];
     _formInputSession = nil;
+    [_highlightView removeFromSuperview];
+    [_highlightRootView removeFromSuperview];
     [_touchEventGestureRecognizer setDelegate:nil];
     [_singleTapGestureRecognizer setDelegate:nil];
     [_doubleTapGestureRecognizer setDelegate:nil];
@@ -353,15 +355,26 @@
         return;
 
     const CGFloat UIWebViewMinimumHighlightRadius = 2.0;
-    if (!_highlightView) {
+
+    if (!_highlightRootView) {
+        _highlightRootView = adoptNS([[UIView alloc] init]);
+        [_highlightRootView setOpaque:NO];
+        [_highlightRootView layer].anchorPoint = CGPointMake(0, 0);
+
         _highlightView = adoptNS([[_UIHighlightView alloc] initWithFrame:CGRectZero]);
         [_highlightView setOpaque:NO];
         [_highlightView setCornerRadius:UIWebViewMinimumHighlightRadius];
+        [_highlightRootView addSubview:_highlightView.get()];
     }
-    [self addSubview:_highlightView.get()];
+    [self addSubview:_highlightRootView.get()];
+    CGFloat selfScale = [[self layer] transform].m11;
+    CGFloat highlightViewScale = 1 / selfScale;
+    [_highlightRootView setTransform:CGAffineTransformMakeScale(highlightViewScale, highlightViewScale)];
 
-    RetainPtr<UIColor> highlightUIKitColor = adoptNS([[UIColor alloc] initWithRed:(color.red() / 255.0) green:(color.green() / 255.0) blue:(color.blue() / 255.0) alpha:(color.alpha() / 255.0)]);
-    [_highlightView setColor:highlightUIKitColor.get()];
+    {
+        RetainPtr<UIColor> highlightUIKitColor = adoptNS([[UIColor alloc] initWithRed:(color.red() / 255.0) green:(color.green() / 255.0) blue:(color.blue() / 255.0) alpha:(color.alpha() / 255.0)]);
+        [_highlightView setColor:highlightUIKitColor.get()];
+    }
 
     bool allHighlightRectsAreRectilinear = true;
     const size_t quadCount = highlightedQuads.size();
@@ -369,7 +382,9 @@
     for (size_t i = 0; i < quadCount; ++i) {
         const FloatQuad& quad = highlightedQuads[i];
         if (quad.isRectilinear()) {
-            CGRect rect = CGRectInset(quad.boundingBox(), -UIWebViewMinimumHighlightRadius, -UIWebViewMinimumHighlightRadius);
+            FloatRect boundingBox = quad.boundingBox();
+            boundingBox.scale(selfScale);
+            CGRect rect = CGRectInset(boundingBox, -UIWebViewMinimumHighlightRadius, -UIWebViewMinimumHighlightRadius);
             [rects addObject:[NSValue valueWithCGRect:rect]];
         } else {
             allHighlightRectsAreRectilinear = false;
@@ -383,7 +398,8 @@
     else {
         RetainPtr<NSMutableArray> quads = adoptNS([[NSMutableArray alloc] initWithCapacity:static_cast<const NSUInteger>(quadCount)]);
         for (size_t i = 0; i < quadCount; ++i) {
-            const FloatQuad& quad = highlightedQuads[i];
+            FloatQuad quad = highlightedQuads[i];
+            quad.scale(selfScale, selfScale);
             FloatQuad extendedQuad = inflateQuad(quad, UIWebViewMinimumHighlightRadius);
             [quads addObject:[NSValue valueWithCGPoint:extendedQuad.p1()]];
             [quads addObject:[NSValue valueWithCGPoint:extendedQuad.p2()]];
@@ -600,7 +616,7 @@
 - (void)_cancelInteraction
 {
     _isTapHighlightIDValid = NO;
-    [_highlightView removeFromSuperview];
+    [_highlightRootView removeFromSuperview];
 }
 
 - (BOOL)hasSelectablePositionAtPoint:(CGPoint)point
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to