[iOS] Add quirks to disable autocorrection and autocapitalization in hidden editable...
authorwenson_hsieh@apple.com <wenson_hsieh@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 19 Apr 2019 18:17:15 +0000 (18:17 +0000)
committerwenson_hsieh@apple.com <wenson_hsieh@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 19 Apr 2019 18:17:15 +0000 (18:17 +0000)
https://bugs.webkit.org/show_bug.cgi?id=197102
<rdar://problem/49864669>

Reviewed by Ryosuke Niwa.

Source/WebCore:

Add a quirk to disable autocorrection and autocapitalization in hidden editable areas.

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

Source/WebKit:

If the quirk for disabling autocorrection and autocapitalization in hidden editable areas is active, then check
whether the focused element is hidden, and turn off autocorrection and autocapitalization if needed.

* WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::WebPage::getFocusedElementInformation):

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

Source/WebCore/ChangeLog
Source/WebCore/page/Quirks.cpp
Source/WebCore/page/Quirks.h
Source/WebKit/ChangeLog
Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm

index 70bec1c..df6fc73 100644 (file)
@@ -1,3 +1,18 @@
+2019-04-19  Wenson Hsieh  <wenson_hsieh@apple.com>
+
+        [iOS] Add quirks to disable autocorrection and autocapitalization in hidden editable areas on some websites
+        https://bugs.webkit.org/show_bug.cgi?id=197102
+        <rdar://problem/49864669>
+
+        Reviewed by Ryosuke Niwa.
+
+        Add a quirk to disable autocorrection and autocapitalization in hidden editable areas.
+
+        * page/Quirks.cpp:
+        (WebCore::shouldSuppressAutocorrectionAndAutocaptializationInHiddenEditableAreasForHost):
+        (WebCore::Quirks::shouldSuppressAutocorrectionAndAutocaptializationInHiddenEditableAreas const):
+        * page/Quirks.h:
+
 2019-04-18  Fujii Hironori  <Hironori.Fujii@sony.com>
 
         Implement KeyedDecoderGeneric and KeyedEncoderGeneric
index 2562568..57c0546 100644 (file)
@@ -195,6 +195,25 @@ bool Quirks::isNeverRichlyEditableForTouchBar() const
     return false;
 }
 
+#if USE(APPLE_INTERNAL_SDK)
+#import <WebKitAdditions/QuirksAdditions.cpp>
+#else
+
+static bool shouldSuppressAutocorrectionAndAutocaptializationInHiddenEditableAreasForHost(const StringView&)
+{
+    return false;
+}
+
+#endif
+
+bool Quirks::shouldSuppressAutocorrectionAndAutocaptializationInHiddenEditableAreas() const
+{
+    if (!needsQuirks())
+        return false;
+
+    return shouldSuppressAutocorrectionAndAutocaptializationInHiddenEditableAreasForHost(m_document->topDocument().url().host());
+}
+
 bool Quirks::shouldDispatchSimulatedMouseEvents() const
 {
 #if PLATFORM(IOS_FAMILY)
index 87f99f9..6fb60a0 100644 (file)
@@ -48,6 +48,7 @@ public:
     bool shouldDispatchSimulatedMouseEvents() const;
     bool shouldDisablePointerEventsQuirk() const;
 
+    WEBCORE_EXPORT bool shouldSuppressAutocorrectionAndAutocaptializationInHiddenEditableAreas() const;
     WEBCORE_EXPORT bool isTouchBarUpdateSupressedForHiddenContentEditable() const;
     WEBCORE_EXPORT bool isNeverRichlyEditableForTouchBar() const;
 
index 2ee2704..2dbdab4 100644 (file)
@@ -1,3 +1,17 @@
+2019-04-19  Wenson Hsieh  <wenson_hsieh@apple.com>
+
+        [iOS] Add quirks to disable autocorrection and autocapitalization in hidden editable areas on some websites
+        https://bugs.webkit.org/show_bug.cgi?id=197102
+        <rdar://problem/49864669>
+
+        Reviewed by Ryosuke Niwa.
+
+        If the quirk for disabling autocorrection and autocapitalization in hidden editable areas is active, then check
+        whether the focused element is hidden, and turn off autocorrection and autocapitalization if needed.
+
+        * WebProcess/WebPage/ios/WebPageIOS.mm:
+        (WebKit::WebPage::getFocusedElementInformation):
+
 2019-04-19  Commit Queue  <commit-queue@webkit.org>
 
         Unreviewed, rolling out r244447.
index 86ae4ca..ab3e68d 100644 (file)
 #import <WebCore/Pasteboard.h>
 #import <WebCore/PlatformKeyboardEvent.h>
 #import <WebCore/PlatformMouseEvent.h>
+#import <WebCore/Quirks.h>
 #import <WebCore/RenderBlock.h>
 #import <WebCore/RenderImage.h>
 #import <WebCore/RenderThemeIOS.h>
@@ -2732,6 +2733,11 @@ void WebPage::getFocusedElementInformation(FocusedElementInformation& informatio
         }
         information.isReadOnly = false;
     }
+
+    if (m_focusedElement->document().quirks().shouldSuppressAutocorrectionAndAutocaptializationInHiddenEditableAreas() && m_focusedElement->renderer() && enclosingLayerIsTransparentOrFullyClipped(*m_focusedElement->renderer())) {
+        information.autocapitalizeType = AutocapitalizeTypeNone;
+        information.isAutocorrect = false;
+    }
 }
 
 void WebPage::autofillLoginCredentials(const String& username, const String& password)