[iOS] Tapping the search field on a search results page on zillow.com shows and immed...
authorzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 23 Jul 2019 21:49:00 +0000 (21:49 +0000)
committerzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 23 Jul 2019 21:49:00 +0000 (21:49 +0000)
https://bugs.webkit.org/show_bug.cgi?id=200044
<rdar://problem/53103732>

Reviewed by Wenson Hsieh.

Source/WebCore:

1. The keyboard gets dismissed as the result of scroll event.
2. The (horizontal)scroll event is initiated by WebKit as we try to re-center the content.
3. The content gets off-centered as the result of the newly constructed drop-down menu which slightly sticks out of the document to the right (layout overflows).

It works with shipping version of iOS because _zoomToFocusRect operates on stale viewport information (see r244494 for the progression).
This patch applies a site specific quirk to restore shipping behavior.

* page/Quirks.cpp:
(WebCore::Quirks::shouldAvoidScrollingWhenFocusedContentIsVisible const):
* page/Quirks.h:

Source/WebKit:

* Shared/FocusedElementInformation.cpp:
(WebKit::FocusedElementInformation::encode const):
(WebKit::FocusedElementInformation::decode):
* Shared/FocusedElementInformation.h:
* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView _zoomToFocusRect:selectionRect:insideFixed:fontSize:minimumScale:maximumScale:allowScaling:forceScroll:]):
* UIProcess/ios/WKContentViewInteraction.h:
* UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView _elementDidBlur]):
(-[WKContentView _shouldAvoidScrollingWhenFocusedContentIsVisible]):
* WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::WebPage::getFocusedElementInformation):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@247746 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/page/Quirks.cpp
Source/WebCore/page/Quirks.h
Source/WebKit/ChangeLog
Source/WebKit/Shared/FocusedElementInformation.cpp
Source/WebKit/Shared/FocusedElementInformation.h
Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm
Source/WebKit/UIProcess/ios/WKContentViewInteraction.h
Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm
Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm

index 88ba0ec..74022ef 100644 (file)
@@ -1,3 +1,22 @@
+2019-07-23  Zalan Bujtas  <zalan@apple.com>
+
+        [iOS] Tapping the search field on a search results page on zillow.com shows and immediately dismisses the keyboard
+        https://bugs.webkit.org/show_bug.cgi?id=200044
+        <rdar://problem/53103732>
+
+        Reviewed by Wenson Hsieh.
+
+        1. The keyboard gets dismissed as the result of scroll event.
+        2. The (horizontal)scroll event is initiated by WebKit as we try to re-center the content.
+        3. The content gets off-centered as the result of the newly constructed drop-down menu which slightly sticks out of the document to the right (layout overflows).
+
+        It works with shipping version of iOS because _zoomToFocusRect operates on stale viewport information (see r244494 for the progression).
+        This patch applies a site specific quirk to restore shipping behavior.
+
+        * page/Quirks.cpp:
+        (WebCore::Quirks::shouldAvoidScrollingWhenFocusedContentIsVisible const):
+        * page/Quirks.h:
+
 2019-07-23  Said Abou-Hallawa  <sabouhallawa@apple.com>
 
         CanvasRenderingContext2D.setTransfrom() reads only the aliases attributes of DOMMatrix2DInit
index 7fdd633..16f9421 100644 (file)
@@ -437,4 +437,12 @@ bool Quirks::needsYouTubeOverflowScrollQuirk() const
 #endif
 }
 
+bool Quirks::shouldAvoidScrollingWhenFocusedContentIsVisible() const
+{
+    if (!needsQuirks())
+        return false;
+
+    return equalLettersIgnoringASCIICase(m_document->url().host(), "www.zillow.com");
+}
+
 }
index 2d50a18..a9face1 100644 (file)
@@ -62,6 +62,7 @@ public:
     WEBCORE_EXPORT bool isTouchBarUpdateSupressedForHiddenContentEditable() const;
     WEBCORE_EXPORT bool isNeverRichlyEditableForTouchBar() const;
     WEBCORE_EXPORT bool shouldAvoidResizingWhenInputViewBoundsChange() const;
+    WEBCORE_EXPORT bool shouldAvoidScrollingWhenFocusedContentIsVisible() const;
 
     WEBCORE_EXPORT bool needsYouTubeMouseOutQuirk() const;
 
index e7ba2c4..035af05 100644 (file)
@@ -1,3 +1,24 @@
+2019-07-23  Zalan Bujtas  <zalan@apple.com>
+
+        [iOS] Tapping the search field on a search results page on zillow.com shows and immediately dismisses the keyboard
+        https://bugs.webkit.org/show_bug.cgi?id=200044
+        <rdar://problem/53103732>
+
+        Reviewed by Wenson Hsieh.
+
+        * Shared/FocusedElementInformation.cpp:
+        (WebKit::FocusedElementInformation::encode const):
+        (WebKit::FocusedElementInformation::decode):
+        * Shared/FocusedElementInformation.h:
+        * UIProcess/API/Cocoa/WKWebView.mm:
+        (-[WKWebView _zoomToFocusRect:selectionRect:insideFixed:fontSize:minimumScale:maximumScale:allowScaling:forceScroll:]):
+        * UIProcess/ios/WKContentViewInteraction.h:
+        * UIProcess/ios/WKContentViewInteraction.mm:
+        (-[WKContentView _elementDidBlur]):
+        (-[WKContentView _shouldAvoidScrollingWhenFocusedContentIsVisible]):
+        * WebProcess/WebPage/ios/WebPageIOS.mm:
+        (WebKit::WebPage::getFocusedElementInformation):
+
 2019-07-23  Alex Christensen  <achristensen@webkit.org>
 
         Move javaScriptConfigurationDirectory SPI from _WKProcessPoolConfiguration to WKProcessPoolPrivate to make it runtime switchable
index 14821ec..e9195e8 100644 (file)
@@ -107,6 +107,7 @@ void FocusedElementInformation::encode(IPC::Encoder& encoder) const
     encoder << shouldSynthesizeKeyEventsForEditing;
     encoder << isSpellCheckingEnabled;
     encoder << shouldAvoidResizingWhenInputViewBoundsChange;
+    encoder << shouldAvoidScrollingWhenFocusedContentIsVisible;
 }
 
 bool FocusedElementInformation::decode(IPC::Decoder& decoder, FocusedElementInformation& result)
@@ -234,6 +235,9 @@ bool FocusedElementInformation::decode(IPC::Decoder& decoder, FocusedElementInfo
     if (!decoder.decode(result.shouldAvoidResizingWhenInputViewBoundsChange))
         return false;
 
+    if (!decoder.decode(result.shouldAvoidScrollingWhenFocusedContentIsVisible))
+        return false;
+
     return true;
 }
 #endif
index 46bf753..89ed11c 100644 (file)
@@ -139,6 +139,7 @@ struct FocusedElementInformation {
     bool shouldSynthesizeKeyEventsForEditing { false };
     bool isSpellCheckingEnabled { true };
     bool shouldAvoidResizingWhenInputViewBoundsChange { false };
+    bool shouldAvoidScrollingWhenFocusedContentIsVisible { false };
 
     FocusedElementIdentifier focusedElementIdentifier { 0 };
 
index 3cc86a9..d419e89 100644 (file)
@@ -2422,7 +2422,8 @@ static WebCore::FloatPoint constrainContentOffset(WebCore::FloatPoint contentOff
     focusedElementRectInNewScale.moveBy([_contentView frame].origin);
 
     BOOL selectionRectIsNotNull = !selectionRectInDocumentCoordinates.isZero();
-    if (!forceScroll) {
+    BOOL doNotScrollWhenContentIsAlreadyVisible = !forceScroll || [_contentView _shouldAvoidScrollingWhenFocusedContentIsVisible];
+    if (doNotScrollWhenContentIsAlreadyVisible) {
         CGRect currentlyVisibleRegionInWebViewCoordinates;
         currentlyVisibleRegionInWebViewCoordinates.origin = unobscuredScrollViewRectInWebViewCoordinates.origin;
         currentlyVisibleRegionInWebViewCoordinates.origin.y += visibleOffsetFromTop;
index 0a62bbe..fd8ae9e 100644 (file)
@@ -538,6 +538,7 @@ FOR_EACH_PRIVATE_WKCONTENTVIEW_ACTION(DECLARE_WKCONTENTVIEW_ACTION_FOR_WEB_VIEW)
 
 @property (nonatomic, readonly) BOOL _shouldUseContextMenus;
 @property (nonatomic, readonly) BOOL _shouldAvoidResizingWhenInputViewBoundsChange;
+@property (nonatomic, readonly) BOOL _shouldAvoidScrollingWhenFocusedContentIsVisible;
 
 @end
 
index 4710953..9f55128 100644 (file)
@@ -5400,6 +5400,7 @@ static RetainPtr<NSObject <WKFormPeripheral>> createInputPeripheralWithView(WebK
     _focusedElementInformation.elementType = WebKit::InputType::None;
     _focusedElementInformation.shouldSynthesizeKeyEventsForEditing = false;
     _focusedElementInformation.shouldAvoidResizingWhenInputViewBoundsChange = false;
+    _focusedElementInformation.shouldAvoidScrollingWhenFocusedContentIsVisible = false;
     _inputPeripheral = nil;
     _focusRequiresStrongPasswordAssistance = NO;
 
@@ -6351,6 +6352,11 @@ static BOOL allPasteboardItemOriginsMatchOrigin(UIPasteboard *pasteboard, const
     return _focusedElementInformation.shouldAvoidResizingWhenInputViewBoundsChange;
 }
 
+- (BOOL)_shouldAvoidScrollingWhenFocusedContentIsVisible
+{
+    return _focusedElementInformation.shouldAvoidScrollingWhenFocusedContentIsVisible;
+}
+
 - (UIView *)containerViewForTargetedPreviews
 {
     return self.unscaledView ?: self;
index efe5afc..db02001 100644 (file)
@@ -3053,7 +3053,9 @@ void WebPage::getFocusedElementInformation(FocusedElementInformation& informatio
         information.isAutocorrect = false;
     }
 
-    information.shouldAvoidResizingWhenInputViewBoundsChange = m_focusedElement->document().quirks().shouldAvoidResizingWhenInputViewBoundsChange();
+    auto& quirks = m_focusedElement->document().quirks();
+    information.shouldAvoidResizingWhenInputViewBoundsChange = quirks.shouldAvoidResizingWhenInputViewBoundsChange();
+    information.shouldAvoidScrollingWhenFocusedContentIsVisible = quirks.shouldAvoidScrollingWhenFocusedContentIsVisible();
 }
 
 void WebPage::autofillLoginCredentials(const String& username, const String& password)