Title: [168820] branches/safari-538.34-branch/Source

Diff

Modified: branches/safari-538.34-branch/Source/WebCore/ChangeLog (168819 => 168820)


--- branches/safari-538.34-branch/Source/WebCore/ChangeLog	2014-05-14 08:44:09 UTC (rev 168819)
+++ branches/safari-538.34-branch/Source/WebCore/ChangeLog	2014-05-14 08:53:28 UTC (rev 168820)
@@ -1,5 +1,24 @@
 2014-05-14  Lucas Forschler  <[email protected]>
 
+        Merge r168744
+
+    2014-05-13  Enrica Casucci  <[email protected]>
+
+            REGRESSION (WebKit2): Zooming to text field leaves it partially hidden by the form assistant.
+            https://bugs.webkit.org/show_bug.cgi?id=132879
+            <rdar://problem/16318049>
+
+            Reviewed by Benjamin Poulain.
+
+            Adding some exports. The fix to setScrollPosition is to avoid clamping the scroll
+            position when using delegate scrolling.
+
+            * WebCore.exp.in:
+            * platform/ScrollView.cpp:
+            (WebCore::ScrollView::setScrollPosition):
+
+2014-05-14  Lucas Forschler  <[email protected]>
+
         Merge r168670
 
     2014-05-12  Simon Fraser  <[email protected]>

Modified: branches/safari-538.34-branch/Source/WebCore/WebCore.exp.in (168819 => 168820)


--- branches/safari-538.34-branch/Source/WebCore/WebCore.exp.in	2014-05-14 08:44:09 UTC (rev 168819)
+++ branches/safari-538.34-branch/Source/WebCore/WebCore.exp.in	2014-05-14 08:53:28 UTC (rev 168820)
@@ -1545,6 +1545,7 @@
 __ZNK7WebCore11RenderLayer19absoluteBoundingBoxEv
 __ZNK7WebCore11RenderLayer24needsCompositedScrollingEv
 __ZNK7WebCore11RenderStyle11fontMetricsEv
+__ZNK7WebCore11RenderStyle15fontDescriptionEv
 __ZNK7WebCore11RenderStyle21visitedDependentColorEi
 __ZNK7WebCore11RenderStyle4fontEv
 __ZNK7WebCore12RenderObject14enclosingLayerEv

Modified: branches/safari-538.34-branch/Source/WebCore/platform/ScrollView.cpp (168819 => 168820)


--- branches/safari-538.34-branch/Source/WebCore/platform/ScrollView.cpp	2014-05-14 08:44:09 UTC (rev 168819)
+++ branches/safari-538.34-branch/Source/WebCore/platform/ScrollView.cpp	2014-05-14 08:53:28 UTC (rev 168820)
@@ -504,7 +504,7 @@
     }
 #endif
 
-    IntPoint newScrollPosition = adjustScrollPositionWithinRange(scrollPoint);
+    IntPoint newScrollPosition = !delegatesScrolling() ? adjustScrollPositionWithinRange(scrollPoint) : scrollPoint;
 
     if ((!delegatesScrolling() || !inProgrammaticScroll()) && newScrollPosition == scrollPosition())
         return;

Modified: branches/safari-538.34-branch/Source/WebKit2/ChangeLog (168819 => 168820)


--- branches/safari-538.34-branch/Source/WebKit2/ChangeLog	2014-05-14 08:44:09 UTC (rev 168819)
+++ branches/safari-538.34-branch/Source/WebKit2/ChangeLog	2014-05-14 08:53:28 UTC (rev 168820)
@@ -1,5 +1,38 @@
 2014-05-14  Lucas Forschler  <[email protected]>
 
+        Merge r168744
+
+    2014-05-13  Enrica Casucci  <[email protected]>
+
+            REGRESSION (WebKit2): Zooming to text field leaves it partially hidden by the form assistant.
+            https://bugs.webkit.org/show_bug.cgi?id=132879
+            <rdar://problem/16318049>
+
+            Reviewed by Benjamin Poulain.
+
+            Adds the heuristics to zoom and scroll to ensure the element being focused
+            is fully visible and its text readable.
+
+            * Shared/AssistedNodeInformation.cpp:
+            (WebKit::AssistedNodeInformation::encode):
+            (WebKit::AssistedNodeInformation::decode):
+            * Shared/AssistedNodeInformation.h:
+            (WebKit::AssistedNodeInformation::AssistedNodeInformation):
+            * UIProcess/API/Cocoa/WKWebView.mm:
+            (-[WKWebView _zoomToFocusRect:WebCore::selectionRect:WebCore::fontSize:minimumScale:maximumScale:allowUserScaling:forceScroll:]):
+            (-[WKWebView _keyboardChangedWithInfo:adjustScrollView:]):
+            * UIProcess/API/Cocoa/WKWebViewInternal.h:
+            * UIProcess/ios/WKContentView.h:
+            * UIProcess/ios/WKContentView.mm:
+            (-[WKContentView _zoomToFocusRect:selectionRect:fontSize:minimumScale:maximumScale:allowUserScaling:forceScroll:]):
+            * UIProcess/ios/WKContentViewInteraction.mm:
+            (-[WKContentView _displayFormNodeInputView]):
+            (-[WKContentView _startAssistingNode:userIsInteracting:userObject:]):
+            * WebProcess/WebPage/ios/WebPageIOS.mm:
+            (WebKit::WebPage::getAssistedNodeInformation):
+
+2014-05-14  Lucas Forschler  <[email protected]>
+
         Merge r168768
 
     2014-05-13  Anders Carlsson  <[email protected]>

Modified: branches/safari-538.34-branch/Source/WebKit2/Shared/AssistedNodeInformation.cpp (168819 => 168820)


--- branches/safari-538.34-branch/Source/WebKit2/Shared/AssistedNodeInformation.cpp	2014-05-14 08:44:09 UTC (rev 168819)
+++ branches/safari-538.34-branch/Source/WebKit2/Shared/AssistedNodeInformation.cpp	2014-05-14 08:53:28 UTC (rev 168820)
@@ -64,8 +64,10 @@
 void AssistedNodeInformation::encode(IPC::ArgumentEncoder& encoder) const
 {
     encoder << elementRect;
+    encoder << selectionRect;
     encoder << minimumScaleFactor;
     encoder << maximumScaleFactor;
+    encoder << nodeFontSize;
     encoder << hasNextNode;
     encoder << hasPreviousNode;
     encoder << isAutocorrect;
@@ -76,6 +78,7 @@
     encoder << selectedIndex;
     encoder << isMultiSelect;
     encoder << isReadOnly;
+    encoder << allowsUserScaling;
     encoder << value;
     encoder << valueAsNumber;
     encoder << title;
@@ -86,12 +89,18 @@
     if (!decoder.decode(result.elementRect))
         return false;
 
+    if (!decoder.decode(result.selectionRect))
+        return false;
+
     if (!decoder.decode(result.minimumScaleFactor))
         return false;
 
     if (!decoder.decode(result.maximumScaleFactor))
         return false;
 
+    if (!decoder.decode(result.nodeFontSize))
+        return false;
+
     if (!decoder.decode(result.hasNextNode))
         return false;
 
@@ -122,6 +131,9 @@
     if (!decoder.decode(result.isReadOnly))
         return false;
 
+    if (!decoder.decode(result.allowsUserScaling))
+        return false;
+
     if (!decoder.decode(result.value))
         return false;
 

Modified: branches/safari-538.34-branch/Source/WebKit2/Shared/AssistedNodeInformation.h (168819 => 168820)


--- branches/safari-538.34-branch/Source/WebKit2/Shared/AssistedNodeInformation.h	2014-05-14 08:44:09 UTC (rev 168819)
+++ branches/safari-538.34-branch/Source/WebKit2/Shared/AssistedNodeInformation.h	2014-05-14 08:53:28 UTC (rev 168820)
@@ -95,11 +95,13 @@
     AssistedNodeInformation()
         : minimumScaleFactor(-INFINITY)
         , maximumScaleFactor(INFINITY)
+        , nodeFontSize(0)
         , hasNextNode(false)
         , hasPreviousNode(false)
         , isAutocorrect(false)
         , isMultiSelect(false)
         , isReadOnly(false)
+        , allowsUserScaling(false)
         , autocapitalizeType(WebAutocapitalizeTypeDefault)
         , elementType(WKTypeNone)
         , selectedIndex(-1)
@@ -108,13 +110,16 @@
     }
 
     WebCore::IntRect elementRect;
+    WebCore::IntRect selectionRect;
     double minimumScaleFactor;
     double maximumScaleFactor;
+    double nodeFontSize;
     bool hasNextNode;
     bool hasPreviousNode;
     bool isAutocorrect;
     bool isMultiSelect;
     bool isReadOnly;
+    bool allowsUserScaling;
     WebAutocapitalizeType autocapitalizeType;
     WKInputType elementType;
     String formAction;

Modified: branches/safari-538.34-branch/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm (168819 => 168820)


--- branches/safari-538.34-branch/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm	2014-05-14 08:44:09 UTC (rev 168819)
+++ branches/safari-538.34-branch/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm	2014-05-14 08:53:28 UTC (rev 168820)
@@ -83,6 +83,19 @@
 @interface UIPeripheralHost(UIKitInternal)
 - (CGFloat)getVerticalOverlapForView:(UIView *)view usingKeyboardInfo:(NSDictionary *)info;
 @end
+
+@interface UIView (UIViewInternal)
+- (UIViewController *)_viewControllerForAncestor;
+@end
+
+@interface UIWindow (UIWindowInternal)
+- (BOOL)_isHostedInAnotherProcess;
+@end
+
+@interface UIViewController (UIViewControllerInternal)
+- (UIViewController *)_rootAncestorViewController;
+- (UIViewController *)_viewControllerForSupportedInterfaceOrientations;
+@end
 #endif
 
 #if PLATFORM(MAC)
@@ -105,6 +118,7 @@
     BOOL _hasStaticMinimumLayoutSize;
     CGSize _minimumLayoutSizeOverride;
     CGSize _minimumLayoutSizeOverrideForMinimalUI;
+    CGRect _inputViewBounds;
 
     UIEdgeInsets _obscuredInsets;
     bool _isChangingObscuredInsetsInteractively;
@@ -119,7 +133,6 @@
     CATransform3D _resizeAnimationTransformAdjustments;
     RetainPtr<UIView> _resizeAnimationView;
     CGFloat _lastAdjustmentForScroller;
-    CGFloat _keyboardVerticalOverlap;
 
     std::unique_ptr<WebKit::ViewGestureController> _gestureController;
     BOOL _allowsBackForwardNavigationGestures;
@@ -610,6 +623,122 @@
     [self _zoomToPoint:origin atScale:[_scrollView minimumZoomScale]];
 }
 
+// focusedElementRect and selectionRect are both in document coordinates.
+- (void)_zoomToFocusRect:(WebCore::FloatRect)focusedElementRectInDocumentCoordinates selectionRect:(WebCore::FloatRect)selectionRectInDocumentCoordinates fontSize:(float)fontSize minimumScale:(double)minimumScale maximumScale:(double)maximumScale allowScaling:(BOOL)allowScaling forceScroll:(BOOL)forceScroll
+{
+    const double WKWebViewStandardFontSize = 16;
+    const double kMinimumHeightToShowContentAboveKeyboard = 106;
+    const CFTimeInterval UIWebFormAnimationDuration = 0.25;
+    const double CaretOffsetFromWindowEdge = 20;
+
+    // Zoom around the element's bounding frame. We use a "standard" size to determine the proper frame.
+    double scale = allowScaling ? std::min(std::max(WKWebViewStandardFontSize / fontSize, minimumScale), maximumScale) : contentZoomScale(self);
+    CGFloat documentWidth = [_contentView bounds].size.width;
+    scale = CGRound(documentWidth * scale) / documentWidth;
+
+    UIWindow *window = [_scrollView window];
+
+    WebCore::FloatRect focusedElementRectInNewScale = focusedElementRectInDocumentCoordinates;
+    focusedElementRectInNewScale.scale(scale);
+    focusedElementRectInNewScale.moveBy([_contentView frame].origin);
+
+    // Find the portion of the view that is visible on the screen.
+    UIViewController *topViewController = [[[_scrollView _viewControllerForAncestor] _rootAncestorViewController] _viewControllerForSupportedInterfaceOrientations];
+    UIView *fullScreenView = topViewController.view;
+    if (!fullScreenView)
+        fullScreenView = window;
+
+    CGRect unobscuredScrollViewRectInWebViewCoordinates = UIEdgeInsetsInsetRect([self bounds], _obscuredInsets);
+    CGRect visibleScrollViewBoundsInWebViewCoordinates = CGRectIntersection(unobscuredScrollViewRectInWebViewCoordinates, [fullScreenView convertRect:[fullScreenView bounds] toView:self]);
+    CGRect formAssistantFrameInWebViewCoordinates = [window convertRect:_inputViewBounds toView:self];
+    CGRect intersectionBetweenScrollViewAndFormAssistant = CGRectIntersection(visibleScrollViewBoundsInWebViewCoordinates, formAssistantFrameInWebViewCoordinates);
+    CGSize visibleSize = visibleScrollViewBoundsInWebViewCoordinates.size;
+
+    CGFloat visibleOffsetFromTop = 0;
+    if (!CGRectIsEmpty(intersectionBetweenScrollViewAndFormAssistant)) {
+        CGFloat heightVisibleAboveFormAssistant = CGRectGetMinY(intersectionBetweenScrollViewAndFormAssistant) - CGRectGetMinY(visibleScrollViewBoundsInWebViewCoordinates);
+        CGFloat heightVisibleBelowFormAssistant = CGRectGetMaxY(visibleScrollViewBoundsInWebViewCoordinates) - CGRectGetMaxY(intersectionBetweenScrollViewAndFormAssistant);
+
+        if (heightVisibleAboveFormAssistant >= kMinimumHeightToShowContentAboveKeyboard || heightVisibleBelowFormAssistant < heightVisibleAboveFormAssistant)
+            visibleSize.height = heightVisibleAboveFormAssistant;
+        else {
+            visibleSize.height = heightVisibleBelowFormAssistant;
+            visibleOffsetFromTop = CGRectGetMaxY(intersectionBetweenScrollViewAndFormAssistant) - CGRectGetMinY(visibleScrollViewBoundsInWebViewCoordinates);
+        }
+    }
+
+    BOOL selectionRectIsNotNull = !selectionRectInDocumentCoordinates.isZero();
+    if (!forceScroll) {
+        CGRect currentlyVisibleRegionInWebViewCoordinates;
+        currentlyVisibleRegionInWebViewCoordinates.origin = unobscuredScrollViewRectInWebViewCoordinates.origin;
+        currentlyVisibleRegionInWebViewCoordinates.origin.y += visibleOffsetFromTop;
+        currentlyVisibleRegionInWebViewCoordinates.size = visibleSize;
+
+        // Don't bother scrolling if the entire node is already visible, whether or not we got a selectionRect.
+        if (CGRectContainsRect(currentlyVisibleRegionInWebViewCoordinates, [self convertRect:focusedElementRectInDocumentCoordinates fromView:_contentView.get()]))
+            return;
+
+        // Don't bother scrolling if we have a valid selectionRect and it is already visible.
+        if (selectionRectIsNotNull && CGRectContainsRect(currentlyVisibleRegionInWebViewCoordinates, [self convertRect:selectionRectInDocumentCoordinates fromView:_contentView.get()]))
+            return;
+    }
+
+    // We want to zoom to the left/top corner of the DOM node, with as much spacing on all sides as we
+    // can get based on the visible area after zooming (workingFrame).  The spacing in either dimension is half the
+    // difference between the size of the DOM node and the size of the visible frame.
+    CGFloat horizontalSpaceInWebViewCoordinates = std::max((visibleSize.width - focusedElementRectInNewScale.width()) / 2.0, 0.0);
+    CGFloat verticalSpaceInWebViewCoordinates = std::max((visibleSize.height - focusedElementRectInNewScale.height()) / 2.0, 0.0);
+
+    CGPoint topLeft;
+    topLeft.x = focusedElementRectInNewScale.x() - horizontalSpaceInWebViewCoordinates;
+    topLeft.y = focusedElementRectInNewScale.y() - verticalSpaceInWebViewCoordinates - visibleOffsetFromTop;
+
+    CGFloat minimumAllowableHorizontalOffsetInWebViewCoordinates = -INFINITY;
+    CGFloat minimumAllowableVerticalOffsetInWebViewCoordinates = -INFINITY;
+    if (selectionRectIsNotNull) {
+        WebCore::FloatRect selectionRectInNewScale = selectionRectInDocumentCoordinates;
+        selectionRectInNewScale.scale(scale);
+        selectionRectInNewScale.moveBy([_contentView frame].origin);
+        minimumAllowableHorizontalOffsetInWebViewCoordinates = CGRectGetMaxX(selectionRectInNewScale) + CaretOffsetFromWindowEdge - visibleSize.width;
+        minimumAllowableVerticalOffsetInWebViewCoordinates = CGRectGetMaxY(selectionRectInNewScale) + CaretOffsetFromWindowEdge - visibleSize.height - visibleOffsetFromTop;
+    }
+
+    WebCore::FloatRect documentBoundsInNewScale = [_contentView bounds];
+    documentBoundsInNewScale.scale(scale);
+    documentBoundsInNewScale.moveBy([_contentView frame].origin);
+
+    // Constrain the left edge in document coordinates so that:
+    //  - it isn't so small that the scrollVisibleRect isn't visible on the screen
+    //  - it isn't so great that the document's right edge is less than the right edge of the screen
+    if (selectionRectIsNotNull && topLeft.x < minimumAllowableHorizontalOffsetInWebViewCoordinates)
+        topLeft.x = minimumAllowableHorizontalOffsetInWebViewCoordinates;
+    else {
+        CGFloat maximumAllowableHorizontalOffset = CGRectGetMaxX(documentBoundsInNewScale) - visibleSize.width;
+        if (topLeft.x > maximumAllowableHorizontalOffset)
+            topLeft.x = maximumAllowableHorizontalOffset;
+    }
+
+    // Constrain the top edge in document coordinates so that:
+    //  - it isn't so small that the scrollVisibleRect isn't visible on the screen
+    //  - it isn't so great that the document's bottom edge is higher than the top of the form assistant
+    if (selectionRectIsNotNull && topLeft.y < minimumAllowableVerticalOffsetInWebViewCoordinates)
+        topLeft.y = minimumAllowableVerticalOffsetInWebViewCoordinates;
+    else {
+        CGFloat maximumAllowableVerticalOffset = CGRectGetMaxY(documentBoundsInNewScale) - visibleSize.height;
+        if (topLeft.y > maximumAllowableVerticalOffset)
+            topLeft.y = maximumAllowableVerticalOffset;
+    }
+
+    WebCore::FloatPoint newCenter = CGPointMake(topLeft.x + unobscuredScrollViewRectInWebViewCoordinates.size.width / 2.0, topLeft.y + unobscuredScrollViewRectInWebViewCoordinates.size.height / 2.0);
+
+    // The newCenter has been computed in the new scale, but _zoomToCenter expected the center to be in the original scale.
+    newCenter.scale(1 / scale, 1 / scale);
+    [_scrollView _zoomToCenter:newCenter
+                        scale:scale
+                     duration:UIWebFormAnimationDuration
+                        force:YES];
+}
+
 - (BOOL)_zoomToRect:(WebCore::FloatRect)targetRect withOrigin:(WebCore::FloatPoint)origin fitEntireRect:(BOOL)fitEntireRect minimumScale:(double)minimumScale maximumScale:(double)maximumScale minimumScrollDistance:(float)minimumScrollDistance
 {
     const float maximumScaleFactorDeltaForPanScroll = 0.02;
@@ -753,7 +882,7 @@
 {
     // FIXME: handle split keyboard.
     UIEdgeInsets obscuredInsets = _obscuredInsets;
-    obscuredInsets.bottom = std::max(_obscuredInsets.bottom, _keyboardVerticalOverlap);
+    obscuredInsets.bottom = std::max(_obscuredInsets.bottom, _inputViewBounds.size.height);
     CGRect unobscuredRect = UIEdgeInsetsInsetRect(self.bounds, obscuredInsets);
     return [self convertRect:unobscuredRect toView:_contentView.get()];
 }
@@ -780,7 +909,18 @@
 
 - (void)_keyboardChangedWithInfo:(NSDictionary *)keyboardInfo adjustScrollView:(BOOL)adjustScrollView
 {
-    _keyboardVerticalOverlap = [[UIPeripheralHost sharedInstance] getVerticalOverlapForView:self usingKeyboardInfo:keyboardInfo];
+    NSValue *endFrameValue = [keyboardInfo objectForKey:UIKeyboardFrameEndUserInfoKey];
+    if (!endFrameValue)
+        return;
+
+    // The keyboard rect is always in screen coordinates. In the view services case the window does not
+    // have the interface orientation rotation transformation; its host does. So, it makes no sense to
+    // clip the keyboard rect against its screen.
+    if ([[self window] _isHostedInAnotherProcess])
+        _inputViewBounds = [self.window convertRect:[endFrameValue CGRectValue] fromWindow:nil];
+    else
+        _inputViewBounds = [self.window convertRect:CGRectIntersection([endFrameValue CGRectValue], self.window.screen.bounds) fromWindow:nil];
+
     [self _updateVisibleContentRects];
 
     if (adjustScrollView)

Modified: branches/safari-538.34-branch/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewInternal.h (168819 => 168820)


--- branches/safari-538.34-branch/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewInternal.h	2014-05-14 08:44:09 UTC (rev 168819)
+++ branches/safari-538.34-branch/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewInternal.h	2014-05-14 08:53:28 UTC (rev 168820)
@@ -67,6 +67,7 @@
 
 - (void)_scrollToContentOffset:(WebCore::FloatPoint)contentOffset;
 - (BOOL)_scrollToRect:(WebCore::FloatRect)targetRect origin:(WebCore::FloatPoint)origin minimumScrollDistance:(float)minimumScrollDistance;
+- (void)_zoomToFocusRect:(WebCore::FloatRect)focusedElementRect selectionRect:(WebCore::FloatRect)selectionRectInDocumentCoordinates fontSize:(float)fontSize minimumScale:(double)minimumScale maximumScale:(double)maximumScale allowScaling:(BOOL)allowScaling forceScroll:(BOOL)forceScroll;
 - (BOOL)_zoomToRect:(WebCore::FloatRect)targetRect withOrigin:(WebCore::FloatPoint)origin fitEntireRect:(BOOL)fitEntireRect minimumScale:(double)minimumScale maximumScale:(double)maximumScale minimumScrollDistance:(float)minimumScrollDistance;
 - (void)_zoomOutWithOrigin:(WebCore::FloatPoint)origin;
 

Modified: branches/safari-538.34-branch/Source/WebKit2/UIProcess/ios/WKContentView.h (168819 => 168820)


--- branches/safari-538.34-branch/Source/WebKit2/UIProcess/ios/WKContentView.h	2014-05-14 08:44:09 UTC (rev 168819)
+++ branches/safari-538.34-branch/Source/WebKit2/UIProcess/ios/WKContentView.h	2014-05-14 08:53:28 UTC (rev 168820)
@@ -81,6 +81,7 @@
 - (void)_setAccessibilityWebProcessToken:(NSData *)data;
 
 - (BOOL)_scrollToRect:(CGRect)targetRect withOrigin:(CGPoint)origin minimumScrollDistance:(CGFloat)minimumScrollDistance;
+- (void)_zoomToFocusRect:(CGRect)rectToFocus selectionRect:(CGRect)selectionRect fontSize:(float)fontSize minimumScale:(double)minimumScale maximumScale:(double)maximumScale allowScaling:(BOOL)allowScaling forceScroll:(BOOL)forceScroll;
 - (BOOL)_zoomToRect:(CGRect)targetRect withOrigin:(CGPoint)origin fitEntireRect:(BOOL)fitEntireRect minimumScale:(double)minimumScale maximumScale:(double)maximumScale minimumScrollDistance:(CGFloat)minimumScrollDistance;
 - (void)_zoomOutWithOrigin:(CGPoint)origin;
 

Modified: branches/safari-538.34-branch/Source/WebKit2/UIProcess/ios/WKContentView.mm (168819 => 168820)


--- branches/safari-538.34-branch/Source/WebKit2/UIProcess/ios/WKContentView.mm	2014-05-14 08:44:09 UTC (rev 168819)
+++ branches/safari-538.34-branch/Source/WebKit2/UIProcess/ios/WKContentView.mm	2014-05-14 08:53:28 UTC (rev 168820)
@@ -446,6 +446,17 @@
     return [_webView _scrollToRect:targetRect origin:origin minimumScrollDistance:minimumScrollDistance];
 }
 
+- (void)_zoomToFocusRect:(CGRect)rectToFocus selectionRect:(CGRect)selectionRect fontSize:(float)fontSize minimumScale:(double)minimumScale maximumScale:(double)maximumScale allowScaling:(BOOL)allowScaling forceScroll:(BOOL)forceScroll
+{
+    [_webView _zoomToFocusRect:rectToFocus
+                 selectionRect:selectionRect
+                      fontSize:fontSize
+                  minimumScale:minimumScale
+                  maximumScale:maximumScale
+              allowScaling:allowScaling
+                   forceScroll:forceScroll];
+}
+
 - (BOOL)_zoomToRect:(CGRect)targetRect withOrigin:(CGPoint)origin fitEntireRect:(BOOL)fitEntireRect minimumScale:(double)minimumScale maximumScale:(double)maximumScale minimumScrollDistance:(CGFloat)minimumScrollDistance
 {
     return [_webView _zoomToRect:targetRect withOrigin:origin fitEntireRect:fitEntireRect minimumScale:minimumScale maximumScale:maximumScale minimumScrollDistance:minimumScrollDistance];

Modified: branches/safari-538.34-branch/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm (168819 => 168820)


--- branches/safari-538.34-branch/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm	2014-05-14 08:44:09 UTC (rev 168819)
+++ branches/safari-538.34-branch/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm	2014-05-14 08:53:28 UTC (rev 168820)
@@ -495,15 +495,13 @@
 
 - (void)_displayFormNodeInputView
 {
-    if (UICurrentUserInterfaceIdiomIsPad())
-        [self _scrollToRect:_assistedNodeInformation.elementRect withOrigin:_page->editorState().caretRectAtStart.location() minimumScrollDistance:0];
-    else
-        [self _zoomToRect:_assistedNodeInformation.elementRect
-               withOrigin:_page->editorState().caretRectAtStart.location()
-            fitEntireRect:YES minimumScale:_assistedNodeInformation.minimumScaleFactor
-             maximumScale:_assistedNodeInformation.maximumScaleFactor
-    minimumScrollDistance:0];
-
+    [self _zoomToFocusRect:_assistedNodeInformation.elementRect
+             selectionRect:_assistedNodeInformation.selectionRect
+                  fontSize:_assistedNodeInformation.nodeFontSize
+              minimumScale:_assistedNodeInformation.minimumScaleFactor
+              maximumScale:_assistedNodeInformation.maximumScaleFactor
+              allowScaling:(_assistedNodeInformation.allowsUserScaling && !UICurrentUserInterfaceIdiomIsPad())
+               forceScroll:[self requiresAccessoryView]];
     [self _updateAccessory];
 }
 
@@ -2126,6 +2124,11 @@
     if (!userIsInteracting && !_textSelectionAssistant)
         return;
 
+    // FIXME: We should remove this check when we manage to send StartAssistingNode from the WebProcess
+    // only when it is truly time to show the keyboard.
+    if (_assistedNodeInformation.elementType == information.elementType && _assistedNodeInformation.elementRect == information.elementRect)
+        return;
+
     _isEditable = YES;
     _assistedNodeInformation = information;
     _inputPeripheral = nil;

Modified: branches/safari-538.34-branch/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm (168819 => 168820)


--- branches/safari-538.34-branch/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm	2014-05-14 08:44:09 UTC (rev 168819)
+++ branches/safari-538.34-branch/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm	2014-05-14 08:53:28 UTC (rev 168820)
@@ -1776,12 +1776,17 @@
 {
     layoutIfNeeded();
 
-    if (RenderObject* renderer = m_assistedNode->renderer())
+    if (RenderObject* renderer = m_assistedNode->renderer()) {
         information.elementRect = m_page->focusController().focusedOrMainFrame().view()->contentsToRootView(renderer->absoluteBoundingBoxRect());
-    else
+        information.nodeFontSize = renderer->style().fontDescription().computedSize();
+    } else
         information.elementRect = IntRect();
+    // FIXME: This should return the selection rect, but when this is called at focus time
+    // we don't have a selection yet. Using the last interaction location is a reasonable approximation for now.
+    information.selectionRect = IntRect(m_lastInteractionLocation, IntSize(1, 1));
     information.minimumScaleFactor = m_viewportConfiguration.minimumScale();
     information.maximumScaleFactor = m_viewportConfiguration.maximumScale();
+    information.allowsUserScaling = m_viewportConfiguration.allowsUserScaling();
     information.hasNextNode = hasFocusableElement(m_assistedNode.get(), m_page.get(), true);
     information.hasPreviousNode = hasFocusableElement(m_assistedNode.get(), m_page.get(), false);
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to