Title: [170218] trunk/Source/WebKit2
- Revision
- 170218
- Author
- [email protected]
- Date
- 2014-06-20 15:42:06 -0700 (Fri, 20 Jun 2014)
Log Message
iOS WebKit2: selection handles become too large when zooming a page.
https://bugs.webkit.org/show_bug.cgi?id=134084
<rdar://problem/16799164>
Reviewed by Benjamin Poulain.
Since the document view is zoomed, we add a subview that has the inverse transform
of the document view. This new view becomes the root for the selection hierarchy.
The new view has zero size, not to interfere with the existing gestures on the WKContenView
therefore we implement hitTest to detect interaction with the selection elements.
* UIProcess/ios/WKContentView.mm:
(-[WKContentView didUpdateVisibleRect:unobscuredRect:unobscuredRectInScrollViewCoordinates:scale:minimumScale:inStableState:isChangingObscuredInsetsInteractively:]):
* UIProcess/ios/WKContentViewInteraction.h:
* UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView setupInteraction]):
(-[WKContentView cleanupInteraction]):
(-[WKContentView unscaledView]):
(-[WKContentView inverseScale]):
(-[WKContentView _updateUnscaledView]):
(-[WKContentView hitTest:withEvent:::]):
(-[WKContentView selectedTextRange]):
Modified Paths
Diff
Modified: trunk/Source/WebKit2/ChangeLog (170217 => 170218)
--- trunk/Source/WebKit2/ChangeLog 2014-06-20 22:40:30 UTC (rev 170217)
+++ trunk/Source/WebKit2/ChangeLog 2014-06-20 22:42:06 UTC (rev 170218)
@@ -1,3 +1,28 @@
+2014-06-19 Enrica Casucci <[email protected]>
+
+ iOS WebKit2: selection handles become too large when zooming a page.
+ https://bugs.webkit.org/show_bug.cgi?id=134084
+ <rdar://problem/16799164>
+
+ Reviewed by Benjamin Poulain.
+
+ Since the document view is zoomed, we add a subview that has the inverse transform
+ of the document view. This new view becomes the root for the selection hierarchy.
+ The new view has zero size, not to interfere with the existing gestures on the WKContenView
+ therefore we implement hitTest to detect interaction with the selection elements.
+
+ * UIProcess/ios/WKContentView.mm:
+ (-[WKContentView didUpdateVisibleRect:unobscuredRect:unobscuredRectInScrollViewCoordinates:scale:minimumScale:inStableState:isChangingObscuredInsetsInteractively:]):
+ * UIProcess/ios/WKContentViewInteraction.h:
+ * UIProcess/ios/WKContentViewInteraction.mm:
+ (-[WKContentView setupInteraction]):
+ (-[WKContentView cleanupInteraction]):
+ (-[WKContentView unscaledView]):
+ (-[WKContentView inverseScale]):
+ (-[WKContentView _updateUnscaledView]):
+ (-[WKContentView hitTest:withEvent:::]):
+ (-[WKContentView selectedTextRange]):
+
2014-06-20 Timothy Horton <[email protected]>
Snapshotting WKThumbnailViews should not tell Web processes backing unparented WKViews that they're in window
Modified: trunk/Source/WebKit2/UIProcess/ios/WKContentView.mm (170217 => 170218)
--- trunk/Source/WebKit2/UIProcess/ios/WKContentView.mm 2014-06-20 22:40:30 UTC (rev 170217)
+++ trunk/Source/WebKit2/UIProcess/ios/WKContentView.mm 2014-06-20 22:42:06 UTC (rev 170218)
@@ -310,6 +310,7 @@
if (auto drawingArea = _page->drawingArea())
drawingArea->updateDebugIndicator();
+ [self _updateUnscaledView];
}
- (void)setMinimumSize:(CGSize)size
Modified: trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.h (170217 => 170218)
--- trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.h 2014-06-20 22:40:30 UTC (rev 170217)
+++ trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.h 2014-06-20 22:42:06 UTC (rev 170218)
@@ -100,6 +100,7 @@
RetainPtr<UIWebFormAccessory> _formAccessoryView;
RetainPtr<UIView> _highlightRootView;
RetainPtr<_UIHighlightView> _highlightView;
+ RetainPtr<UIView> _inverseScaleRootView;
RetainPtr<NSString> _markedText;
RetainPtr<WKActionSheetAssistant> _actionSheetAssistant;
RetainPtr<WKAirPlayRoutePicker> _airPlayRoutePicker;
@@ -174,6 +175,7 @@
- (void)accessoryDone;
- (void)_didHandleKeyEvent:(WebIOSEvent *)event;
- (Vector<WebKit::WKOptionItem>&) assistedNodeSelectOptions;
+- (void)_updateUnscaledView;
@end
#endif // PLATFORM(IOS)
Modified: trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm (170217 => 170218)
--- trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm 2014-06-20 22:40:30 UTC (rev 170217)
+++ trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm 2014-06-20 22:42:06 UTC (rev 170218)
@@ -191,6 +191,15 @@
- (void)setupInteraction
{
+ if (!_inverseScaleRootView) {
+ _inverseScaleRootView = adoptNS([[UIView alloc] init]);
+ [_inverseScaleRootView setOpaque:NO];
+ [_inverseScaleRootView layer].anchorPoint = CGPointMake(0, 0);
+ }
+ [self addSubview:_inverseScaleRootView.get()];
+ CGFloat inverseScale = 1 / [[self layer] transform].m11;
+ [_inverseScaleRootView setTransform:CGAffineTransformMakeScale(inverseScale, inverseScale)];
+
_touchEventGestureRecognizer = adoptNS([[UIWebTouchEventsGestureRecognizer alloc] initWithTarget:self action:@selector(_webTouchEventsRecognized:) touchDelegate:self]);
[_touchEventGestureRecognizer setDelegate:self];
[self addGestureRecognizer:_touchEventGestureRecognizer.get()];
@@ -243,7 +252,7 @@
_formInputSession = nil;
[_highlightView removeFromSuperview];
[_highlightRootView removeFromSuperview];
-
+ [_inverseScaleRootView removeFromSuperview];
[_touchEventGestureRecognizer setDelegate:nil];
[self removeGestureRecognizer:_touchEventGestureRecognizer.get()];
@@ -271,6 +280,34 @@
}
}
+- (UIView*)unscaledView
+{
+ return _inverseScaleRootView.get();
+}
+
+- (CGFloat)inverseScale
+{
+ return [[_inverseScaleRootView layer] transform].m11;
+}
+
+- (void)_updateUnscaledView
+{
+ CGFloat inverseScale = 1 / [[self layer] transform].m11;
+ [_inverseScaleRootView setTransform:CGAffineTransformMakeScale(inverseScale, inverseScale)];
+ _selectionNeedsUpdate = YES;
+ [self _updateChangedSelection];
+}
+
+- (UIView *)hitTest:(CGPoint)point withEvent:(::UIEvent *)event
+{
+ for (UIView *subView in [_inverseScaleRootView.get() subviews]) {
+ UIView *hitView = [subView hitTest:[subView convertPoint:point fromView:self] withEvent:event];
+ if (hitView)
+ return hitView;
+ }
+ return [super hitTest:point withEvent:event];
+}
+
- (const InteractionInformationAtPosition&)positionInformation
{
return _positionInformation;
@@ -1670,11 +1707,34 @@
- (UITextRange *)selectedTextRange
{
+ FloatRect startRect = _page->editorState().caretRectAtStart;
+ FloatRect endRect = _page->editorState().caretRectAtEnd;
+ double inverseScale = [self inverseScale];
+ // We want to keep the original caret width, while the height scales with
+ // the content taking orientation into account.
+ // We achieve this by scaling the width with the inverse
+ // scale factor. This way, when it is converted from the content view
+ // the width remains unchanged.
+ if (startRect.width() < startRect.height())
+ startRect.setWidth(startRect.width() * inverseScale);
+ else
+ startRect.setHeight(startRect.height() * inverseScale);
+ if (endRect.width() < endRect.height()) {
+ double delta = endRect.width();
+ endRect.setWidth(endRect.width() * inverseScale);
+ delta = endRect.width() - delta;
+ endRect.move(delta, 0);
+ } else {
+ double delta = endRect.height();
+ endRect.setHeight(endRect.height() * inverseScale);
+ delta = endRect.height() - delta;
+ endRect.move(0, delta);
+ }
return [WKTextRange textRangeWithState:_page->editorState().selectionIsNone
isRange:_page->editorState().selectionIsRange
isEditable:_page->editorState().isContentEditable
- startRect:_page->editorState().caretRectAtStart
- endRect:_page->editorState().caretRectAtEnd
+ startRect:startRect
+ endRect:endRect
selectionRects:[self webSelectionRects]
selectedTextLength:_page->editorState().selectedTextLength];
}
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes