Title: [247746] trunk/Source
Revision
247746
Author
[email protected]
Date
2019-07-23 14:49:00 -0700 (Tue, 23 Jul 2019)

Log Message

[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.

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):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (247745 => 247746)


--- trunk/Source/WebCore/ChangeLog	2019-07-23 21:05:00 UTC (rev 247745)
+++ trunk/Source/WebCore/ChangeLog	2019-07-23 21:49:00 UTC (rev 247746)
@@ -1,3 +1,22 @@
+2019-07-23  Zalan Bujtas  <[email protected]>
+
+        [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  <[email protected]>
 
         CanvasRenderingContext2D.setTransfrom() reads only the aliases attributes of DOMMatrix2DInit

Modified: trunk/Source/WebCore/page/Quirks.cpp (247745 => 247746)


--- trunk/Source/WebCore/page/Quirks.cpp	2019-07-23 21:05:00 UTC (rev 247745)
+++ trunk/Source/WebCore/page/Quirks.cpp	2019-07-23 21:49:00 UTC (rev 247746)
@@ -437,4 +437,12 @@
 #endif
 }
 
+bool Quirks::shouldAvoidScrollingWhenFocusedContentIsVisible() const
+{
+    if (!needsQuirks())
+        return false;
+
+    return equalLettersIgnoringASCIICase(m_document->url().host(), "www.zillow.com");
 }
+
+}

Modified: trunk/Source/WebCore/page/Quirks.h (247745 => 247746)


--- trunk/Source/WebCore/page/Quirks.h	2019-07-23 21:05:00 UTC (rev 247745)
+++ trunk/Source/WebCore/page/Quirks.h	2019-07-23 21:49:00 UTC (rev 247746)
@@ -62,6 +62,7 @@
     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;
 

Modified: trunk/Source/WebKit/ChangeLog (247745 => 247746)


--- trunk/Source/WebKit/ChangeLog	2019-07-23 21:05:00 UTC (rev 247745)
+++ trunk/Source/WebKit/ChangeLog	2019-07-23 21:49:00 UTC (rev 247746)
@@ -1,3 +1,24 @@
+2019-07-23  Zalan Bujtas  <[email protected]>
+
+        [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  <[email protected]>
 
         Move _javascript_ConfigurationDirectory SPI from _WKProcessPoolConfiguration to WKProcessPoolPrivate to make it runtime switchable

Modified: trunk/Source/WebKit/Shared/FocusedElementInformation.cpp (247745 => 247746)


--- trunk/Source/WebKit/Shared/FocusedElementInformation.cpp	2019-07-23 21:05:00 UTC (rev 247745)
+++ trunk/Source/WebKit/Shared/FocusedElementInformation.cpp	2019-07-23 21:49:00 UTC (rev 247746)
@@ -107,6 +107,7 @@
     encoder << shouldSynthesizeKeyEventsForEditing;
     encoder << isSpellCheckingEnabled;
     encoder << shouldAvoidResizingWhenInputViewBoundsChange;
+    encoder << shouldAvoidScrollingWhenFocusedContentIsVisible;
 }
 
 bool FocusedElementInformation::decode(IPC::Decoder& decoder, FocusedElementInformation& result)
@@ -234,6 +235,9 @@
     if (!decoder.decode(result.shouldAvoidResizingWhenInputViewBoundsChange))
         return false;
 
+    if (!decoder.decode(result.shouldAvoidScrollingWhenFocusedContentIsVisible))
+        return false;
+
     return true;
 }
 #endif

Modified: trunk/Source/WebKit/Shared/FocusedElementInformation.h (247745 => 247746)


--- trunk/Source/WebKit/Shared/FocusedElementInformation.h	2019-07-23 21:05:00 UTC (rev 247745)
+++ trunk/Source/WebKit/Shared/FocusedElementInformation.h	2019-07-23 21:49:00 UTC (rev 247746)
@@ -139,6 +139,7 @@
     bool shouldSynthesizeKeyEventsForEditing { false };
     bool isSpellCheckingEnabled { true };
     bool shouldAvoidResizingWhenInputViewBoundsChange { false };
+    bool shouldAvoidScrollingWhenFocusedContentIsVisible { false };
 
     FocusedElementIdentifier focusedElementIdentifier { 0 };
 

Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm (247745 => 247746)


--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm	2019-07-23 21:05:00 UTC (rev 247745)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm	2019-07-23 21:49:00 UTC (rev 247746)
@@ -2422,7 +2422,8 @@
     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;

Modified: trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h (247745 => 247746)


--- trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h	2019-07-23 21:05:00 UTC (rev 247745)
+++ trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h	2019-07-23 21:49:00 UTC (rev 247746)
@@ -538,6 +538,7 @@
 
 @property (nonatomic, readonly) BOOL _shouldUseContextMenus;
 @property (nonatomic, readonly) BOOL _shouldAvoidResizingWhenInputViewBoundsChange;
+@property (nonatomic, readonly) BOOL _shouldAvoidScrollingWhenFocusedContentIsVisible;
 
 @end
 

Modified: trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm (247745 => 247746)


--- trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm	2019-07-23 21:05:00 UTC (rev 247745)
+++ trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm	2019-07-23 21:49:00 UTC (rev 247746)
@@ -5400,6 +5400,7 @@
     _focusedElementInformation.elementType = WebKit::InputType::None;
     _focusedElementInformation.shouldSynthesizeKeyEventsForEditing = false;
     _focusedElementInformation.shouldAvoidResizingWhenInputViewBoundsChange = false;
+    _focusedElementInformation.shouldAvoidScrollingWhenFocusedContentIsVisible = false;
     _inputPeripheral = nil;
     _focusRequiresStrongPasswordAssistance = NO;
 
@@ -6351,6 +6352,11 @@
     return _focusedElementInformation.shouldAvoidResizingWhenInputViewBoundsChange;
 }
 
+- (BOOL)_shouldAvoidScrollingWhenFocusedContentIsVisible
+{
+    return _focusedElementInformation.shouldAvoidScrollingWhenFocusedContentIsVisible;
+}
+
 - (UIView *)containerViewForTargetedPreviews
 {
     return self.unscaledView ?: self;

Modified: trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm (247745 => 247746)


--- trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm	2019-07-23 21:05:00 UTC (rev 247745)
+++ trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm	2019-07-23 21:49:00 UTC (rev 247746)
@@ -3053,7 +3053,9 @@
         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)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to