Disable ContentChangeObserver TouchEvent adjustment on youtube.com on iOS in mobile...
authorachristensen@apple.com <achristensen@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 10 Aug 2019 22:45:43 +0000 (22:45 +0000)
committerachristensen@apple.com <achristensen@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 10 Aug 2019 22:45:43 +0000 (22:45 +0000)
https://bugs.webkit.org/show_bug.cgi?id=200609
<rdar://problem/54015403>

Reviewed by Maciej Stachowiak.

Source/WebCore:

When watching a youtube video on iOS with "Autoplay" switched to off,
upon finishing the video all clicks anywhere on the page are effectively ignored.
Disabling ContentChangeObserver's TouchEvent adjustment fixes this bug.  I verified this manually.
This switch was introduced in r242621, and it disables part of a new feature, so there is low risk of fallout.

* loader/DocumentLoader.h:
(WebCore::DocumentLoader::setAllowContentChangeObserverQuirk):
(WebCore::DocumentLoader::allowContentChangeObserverQuirk const):
* page/Quirks.cpp:
(WebCore::Quirks::shouldDisableContentChangeObserverTouchEventAdjustment const):
* page/Quirks.h:
* page/ios/ContentChangeObserver.cpp:
(WebCore::ContentChangeObserver::touchEventDidStart):

Source/WebKit:

* Shared/WebsitePoliciesData.cpp:
(WebKit::WebsitePoliciesData::encode const):
(WebKit::WebsitePoliciesData::decode):
(WebKit::WebsitePoliciesData::applyToDocumentLoader):
* Shared/WebsitePoliciesData.h:
* UIProcess/API/APIWebsitePolicies.cpp:
(API::WebsitePolicies::copy const):
(API::WebsitePolicies::data):
* UIProcess/API/APIWebsitePolicies.h:
* UIProcess/ios/WebPageProxyIOS.mm:
(WebKit::WebPageProxy::effectiveContentModeAfterAdjustingPolicies):

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

Source/WebCore/ChangeLog
Source/WebCore/loader/DocumentLoader.h
Source/WebCore/page/Quirks.cpp
Source/WebCore/page/Quirks.h
Source/WebCore/page/ios/ContentChangeObserver.cpp
Source/WebKit/ChangeLog
Source/WebKit/Shared/WebsitePoliciesData.cpp
Source/WebKit/Shared/WebsitePoliciesData.h
Source/WebKit/UIProcess/API/APIWebsitePolicies.cpp
Source/WebKit/UIProcess/API/APIWebsitePolicies.h
Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm

index 9f282bc..20f16ae 100644 (file)
@@ -1,3 +1,25 @@
+2019-08-10  Alex Christensen  <achristensen@webkit.org>
+
+        Disable ContentChangeObserver TouchEvent adjustment on youtube.com on iOS in mobile browsing mode
+        https://bugs.webkit.org/show_bug.cgi?id=200609
+        <rdar://problem/54015403>
+
+        Reviewed by Maciej Stachowiak.
+
+        When watching a youtube video on iOS with "Autoplay" switched to off,
+        upon finishing the video all clicks anywhere on the page are effectively ignored.
+        Disabling ContentChangeObserver's TouchEvent adjustment fixes this bug.  I verified this manually.
+        This switch was introduced in r242621, and it disables part of a new feature, so there is low risk of fallout.
+
+        * loader/DocumentLoader.h:
+        (WebCore::DocumentLoader::setAllowContentChangeObserverQuirk):
+        (WebCore::DocumentLoader::allowContentChangeObserverQuirk const):
+        * page/Quirks.cpp:
+        (WebCore::Quirks::shouldDisableContentChangeObserverTouchEventAdjustment const):
+        * page/Quirks.h:
+        * page/ios/ContentChangeObserver.cpp:
+        (WebCore::ContentChangeObserver::touchEventDidStart):
+
 2019-08-10  Said Abou-Hallawa  <sabouhallawa@apple.com>
 
         [iOS] Add a quirk for gmail.com messages on iPhone iOS13
index 7f2697b..cd89271 100644 (file)
@@ -391,6 +391,9 @@ public:
 
     WEBCORE_EXPORT void applyPoliciesToSettings();
 
+    void setAllowContentChangeObserverQuirk(bool allow) { m_allowContentChangeObserverQuirk = allow; }
+    bool allowContentChangeObserverQuirk() const { return m_allowContentChangeObserverQuirk; }
+
 protected:
     WEBCORE_EXPORT DocumentLoader(const ResourceRequest&, const SubstituteData&);
 
@@ -594,6 +597,7 @@ private:
 #endif
     String m_customUserAgent;
     String m_customJavaScriptUserAgentAsSiteSpecificQuirks;
+    bool m_allowContentChangeObserverQuirk { false };
     String m_customNavigatorPlatform;
     bool m_userContentExtensionsEnabled { true };
 #if ENABLE(DEVICE_ORIENTATION)
index 75abcb8..0beed94 100644 (file)
@@ -139,6 +139,20 @@ bool Quirks::hasBrokenEncryptedMediaAPISupportQuirk() const
     return m_hasBrokenEncryptedMediaAPISupportQuirk.value();
 }
 
+bool Quirks::shouldDisableContentChangeObserverTouchEventAdjustment() const
+{
+    if (!needsQuirks())
+        return false;
+
+    auto& topDocument = m_document->topDocument();
+    auto* topDocumentLoader = topDocument.loader();
+    if (!topDocumentLoader || !topDocumentLoader->allowContentChangeObserverQuirk())
+        return false;
+
+    auto host = m_document->topDocument().url().host();
+    return host.endsWith(".youtube.com") || host == "youtube.com";
+}
+
 bool Quirks::shouldStripQuotationMarkInFontFaceSetFamily() const
 {
     if (!needsQuirks())
index 19ff29d..bfd8f6d 100644 (file)
@@ -61,6 +61,7 @@ public:
     bool needsInputModeNoneImplicitly(const HTMLElement&) const;
     bool needsDeferKeyDownAndKeyPressTimersUntilNextEditingCommand() const;
     bool shouldLightenJapaneseBoldSansSerif() const;
+    bool shouldDisableContentChangeObserverTouchEventAdjustment() const;
 
     WEBCORE_EXPORT bool shouldDispatchSyntheticMouseEventsWhenModifyingSelection() const;
     WEBCORE_EXPORT bool shouldSuppressAutocorrectionAndAutocaptializationInHiddenEditableAreas() const;
index 0be5ee8..0c65568 100644 (file)
@@ -423,7 +423,7 @@ void ContentChangeObserver::contentVisibilityDidChange()
 void ContentChangeObserver::touchEventDidStart(PlatformEvent::Type eventType)
 {
 #if ENABLE(TOUCH_EVENTS)
-    if (!m_document.settings().contentChangeObserverEnabled())
+    if (!m_document.settings().contentChangeObserverEnabled() || m_document.quirks().shouldDisableContentChangeObserverTouchEventAdjustment())
         return;
     if (eventType != PlatformEvent::Type::TouchStart)
         return;
index 6a51815..bfea25e 100644 (file)
@@ -1,3 +1,23 @@
+2019-08-10  Alex Christensen  <achristensen@webkit.org>
+
+        Disable ContentChangeObserver TouchEvent adjustment on youtube.com on iOS in mobile browsing mode
+        https://bugs.webkit.org/show_bug.cgi?id=200609
+        <rdar://problem/54015403>
+
+        Reviewed by Maciej Stachowiak.
+
+        * Shared/WebsitePoliciesData.cpp:
+        (WebKit::WebsitePoliciesData::encode const):
+        (WebKit::WebsitePoliciesData::decode):
+        (WebKit::WebsitePoliciesData::applyToDocumentLoader):
+        * Shared/WebsitePoliciesData.h:
+        * UIProcess/API/APIWebsitePolicies.cpp:
+        (API::WebsitePolicies::copy const):
+        (API::WebsitePolicies::data):
+        * UIProcess/API/APIWebsitePolicies.h:
+        * UIProcess/ios/WebPageProxyIOS.mm:
+        (WebKit::WebPageProxy::effectiveContentModeAfterAdjustingPolicies):
+
 2019-08-10  Said Abou-Hallawa  <sabouhallawa@apple.com>
 
         [iOS] Add a quirk for gmail.com messages on iPhone iOS13
index 3d81c87..3a06056 100644 (file)
@@ -53,6 +53,7 @@ void WebsitePoliciesData::encode(IPC::Encoder& encoder) const
     encoder << mediaSourcePolicy;
     encoder << simulatedMouseEventsDispatchPolicy;
     encoder << legacyOverflowScrollingTouchPolicy;
+    encoder << allowContentChangeObserverQuirk;
 }
 
 Optional<WebsitePoliciesData> WebsitePoliciesData::decode(IPC::Decoder& decoder)
@@ -129,6 +130,11 @@ Optional<WebsitePoliciesData> WebsitePoliciesData::decode(IPC::Decoder& decoder)
     if (!legacyOverflowScrollingTouchPolicy)
         return WTF::nullopt;
 
+    Optional<bool> allowContentChangeObserverQuirk;
+    decoder >> allowContentChangeObserverQuirk;
+    if (!allowContentChangeObserverQuirk)
+        return WTF::nullopt;
+    
     return { {
         WTFMove(*contentBlockersEnabled),
         WTFMove(*allowedAutoplayQuirks),
@@ -146,6 +152,7 @@ Optional<WebsitePoliciesData> WebsitePoliciesData::decode(IPC::Decoder& decoder)
         WTFMove(*mediaSourcePolicy),
         WTFMove(*simulatedMouseEventsDispatchPolicy),
         WTFMove(*legacyOverflowScrollingTouchPolicy),
+        WTFMove(*allowContentChangeObserverQuirk),
     } };
 }
 
@@ -256,6 +263,8 @@ void WebsitePoliciesData::applyToDocumentLoader(WebsitePoliciesData&& websitePol
         break;
     }
 
+    documentLoader.setAllowContentChangeObserverQuirk(websitePolicies.allowContentChangeObserverQuirk);
+
     auto* frame = documentLoader.frame();
     if (!frame)
         return;
index 98fc991..a9e52f5 100644 (file)
@@ -67,6 +67,7 @@ struct WebsitePoliciesData {
     WebsiteMediaSourcePolicy mediaSourcePolicy { WebsiteMediaSourcePolicy::Default };
     WebsiteSimulatedMouseEventsDispatchPolicy simulatedMouseEventsDispatchPolicy { WebsiteSimulatedMouseEventsDispatchPolicy::Default };
     WebsiteLegacyOverflowScrollingTouchPolicy legacyOverflowScrollingTouchPolicy { WebsiteLegacyOverflowScrollingTouchPolicy::Default };
+    bool allowContentChangeObserverQuirk { false };
 
     void encode(IPC::Encoder&) const;
     static Optional<WebsitePoliciesData> decode(IPC::Decoder&);
index b0a900c..fc0c2de 100644 (file)
@@ -62,6 +62,7 @@ Ref<WebsitePolicies> WebsitePolicies::copy() const
     policies->setMediaSourcePolicy(m_mediaSourcePolicy);
     policies->setSimulatedMouseEventsDispatchPolicy(m_simulatedMouseEventsDispatchPolicy);
     policies->setLegacyOverflowScrollingTouchPolicy(m_legacyOverflowScrollingTouchPolicy);
+    policies->setAllowContentChangeObserverQuirk(m_allowContentChangeObserverQuirk);
     
     Vector<WebCore::HTTPHeaderField> legacyCustomHeaderFields;
     legacyCustomHeaderFields.reserveInitialCapacity(m_legacyCustomHeaderFields.size());
@@ -115,6 +116,7 @@ WebKit::WebsitePoliciesData WebsitePolicies::data()
         m_mediaSourcePolicy,
         m_simulatedMouseEventsDispatchPolicy,
         m_legacyOverflowScrollingTouchPolicy,
+        m_allowContentChangeObserverQuirk,
     };
 }
 
index 1d78d20..8d2a71b 100644 (file)
@@ -114,6 +114,9 @@ public:
     WTF::String applicationNameForDesktopUserAgent() const { return m_applicationNameForDesktopUserAgent; }
     void setApplicationNameForDesktopUserAgent(const WTF::String& applicationName) { m_applicationNameForDesktopUserAgent = applicationName; }
 
+    bool allowContentChangeObserverQuirk() const { return m_allowContentChangeObserverQuirk; }
+    void setAllowContentChangeObserverQuirk(bool allow) { m_allowContentChangeObserverQuirk = allow; }
+
 private:
     WebsitePolicies(bool contentBlockersEnabled, OptionSet<WebKit::WebsiteAutoplayQuirk>, WebKit::WebsiteAutoplayPolicy, Vector<WebCore::HTTPHeaderField>&&, Vector<WebCore::CustomHeaderFields>&&, WebKit::WebsitePopUpPolicy, RefPtr<WebsiteDataStore>&&);
 
@@ -137,6 +140,7 @@ private:
     WebKit::WebsiteLegacyOverflowScrollingTouchPolicy m_legacyOverflowScrollingTouchPolicy { WebKit::WebsiteLegacyOverflowScrollingTouchPolicy::Default };
     bool m_allowSiteSpecificQuirksToOverrideContentMode { false };
     WTF::String m_applicationNameForDesktopUserAgent;
+    bool m_allowContentChangeObserverQuirk { false };
 };
 
 } // namespace API
index 6d47176..b7a6b39 100644 (file)
@@ -1420,8 +1420,10 @@ WebContentMode WebPageProxy::effectiveContentModeAfterAdjustingPolicies(API::Web
 
     m_allowsFastClicksEverywhere = false;
 
-    if (!useDesktopBrowsingMode)
+    if (!useDesktopBrowsingMode) {
+        policies.setAllowContentChangeObserverQuirk(true);
         return WebContentMode::Mobile;
+    }
 
     if (policies.customUserAgent().isEmpty() && customUserAgent().isEmpty()) {
         auto applicationName = policies.applicationNameForDesktopUserAgent();