Move the code for determining the need for touch bar quirks to Quirks class
authorrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 13 Mar 2019 02:31:40 +0000 (02:31 +0000)
committerrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 13 Mar 2019 02:31:40 +0000 (02:31 +0000)
https://bugs.webkit.org/show_bug.cgi?id=195654

Reviewed by Brent Fulgham.

Source/WebCore:

Moved the code to determine whether the touch bar quirks are needed or not from WebKit2.

* WebCore.xcodeproj/project.pbxproj:
* page/Quirks.cpp:
(WebCore::Quirks::isTouchBarUpdateSupressedForHiddenContentEditable const):
(WebCore::Quirks::isNeverRichlyEditableForTouchBar const):
* page/Quirks.h:

Source/WebKit:

Moved the code to determine whether touch bar quirks are needed or not to WebCore.

Also renamed HiddenContentEditableQuirk to IsTouchBarUpdateSupressedForHiddenContentEditable
and PlainTextQuirk to NeverRichlyEditableForTouchBar.

* UIProcess/Cocoa/WebViewImpl.h:
(WebKit::WebViewImpl::isRichlyEditableForTouchBar): Renamed.
* UIProcess/Cocoa/WebViewImpl.mm:
(WebKit::WebViewImpl::updateTouchBar):
(WebKit::WebViewImpl::candidateListTouchBarItem const):
(WebKit::WebViewImpl::isRichlyEditableForTouchBar const): Renamed from isRichlyEditable.
(WebKit::WebViewImpl::textTouchBar const):
(WebKit::WebViewImpl::updateTextTouchBar):
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::setIsTouchBarUpdateSupressedForHiddenContentEditable): Renamed from
setNeedsHiddenContentEditableQuirk.
(WebKit::WebPageProxy::setIsNeverRichlyEditableForTouchBar): Renamed from setNeedsPlainTextQuirk.
* UIProcess/WebPageProxy.h:
(WebKit::WebPageProxy::isTouchBarUpdateSupressedForHiddenContentEditable const): Renamed from
needsHiddenContentEditableQuirk.
(WebKit::WebPageProxy::isNeverRichlyEditableForTouchBar const): Renamed from needsPlainTextQuirk.
* UIProcess/WebPageProxy.messages.in: Renamed the IPC messages.
* WebProcess/WebPage/WebPage.cpp:
(WebKit::needsHiddenContentEditableQuirk): Deleted. Moved to WebCore.
(WebKit::needsPlainTextQuirk): Deleted. Moved to WebCore.
(WebKit::WebPage::didStartPageTransition):
(WebKit::WebPage::didChangeSelection):
* WebProcess/WebPage/WebPage.h:
(WebKit::WebPage):

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

12 files changed:
Source/WebCore/ChangeLog
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/page/Quirks.cpp
Source/WebCore/page/Quirks.h
Source/WebKit/ChangeLog
Source/WebKit/UIProcess/Cocoa/WebViewImpl.h
Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm
Source/WebKit/UIProcess/WebPageProxy.cpp
Source/WebKit/UIProcess/WebPageProxy.h
Source/WebKit/UIProcess/WebPageProxy.messages.in
Source/WebKit/WebProcess/WebPage/WebPage.cpp
Source/WebKit/WebProcess/WebPage/WebPage.h

index 25ac755..c759de4 100644 (file)
@@ -1,3 +1,18 @@
+2019-03-12  Ryosuke Niwa  <rniwa@webkit.org>
+
+        Move the code for determining the need for touch bar quirks to Quirks class
+        https://bugs.webkit.org/show_bug.cgi?id=195654
+
+        Reviewed by Brent Fulgham.
+
+        Moved the code to determine whether the touch bar quirks are needed or not from WebKit2.
+
+        * WebCore.xcodeproj/project.pbxproj:
+        * page/Quirks.cpp:
+        (WebCore::Quirks::isTouchBarUpdateSupressedForHiddenContentEditable const):
+        (WebCore::Quirks::isNeverRichlyEditableForTouchBar const):
+        * page/Quirks.h:
+
 2019-03-12  Justin Fan  <justin_fan@apple.com>
 
         [Web GPU] Update GPURenderPipelineDescriptor and add GPUColorStateDescriptor.format
index 205804f..c4fef86 100644 (file)
                9BA273F4172206BB0097CE47 /* LogicalSelectionOffsetCaches.h in Headers */ = {isa = PBXBuildFile; fileRef = 9BA273F3172206BB0097CE47 /* LogicalSelectionOffsetCaches.h */; };
                9BAAC45C21520128003D4A98 /* GCReachableRef.h in Headers */ = {isa = PBXBuildFile; fileRef = 9BAAC4562151E39E003D4A98 /* GCReachableRef.h */; settings = {ATTRIBUTES = (Private, ); }; };
                9BAB6C6C12550631001626D4 /* EditingStyle.h in Headers */ = {isa = PBXBuildFile; fileRef = 9BAB6C6A12550631001626D4 /* EditingStyle.h */; settings = {ATTRIBUTES = (Private, ); }; };
+               9BAEE92C22388A7D004157A9 /* Quirks.h in Headers */ = {isa = PBXBuildFile; fileRef = CD9A87FB215D6CF3006F17B5 /* Quirks.h */; settings = {ATTRIBUTES = (Private, ); }; };
                9BAF3B2412C1A39800014BF1 /* WritingDirection.h in Headers */ = {isa = PBXBuildFile; fileRef = 9BAF3B2312C1A39800014BF1 /* WritingDirection.h */; settings = {ATTRIBUTES = (Private, ); }; };
                9BBA2CAB1F679E0C00FD1C1E /* WebContentReader.h in Headers */ = {isa = PBXBuildFile; fileRef = 9BF433761F67619B00E1FD71 /* WebContentReader.h */; settings = {ATTRIBUTES = (Private, ); }; };
                9BC6C21B13CCC97B008E0337 /* HTMLTextFormControlElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 9BC6C21913CCC97B008E0337 /* HTMLTextFormControlElement.h */; settings = {ATTRIBUTES = (Private, ); }; };
                                83C1F5941EDF69D300410D27 /* QualifiedNameCache.h in Headers */,
                                A15E31F41E0CB0B5004B371C /* QuickLook.h in Headers */,
                                072AE1E8183C0741000A5988 /* QuickTimePluginReplacement.h in Headers */,
+                               9BAEE92C22388A7D004157A9 /* Quirks.h in Headers */,
                                379E371713736A6600B9E919 /* QuotedPrintable.h in Headers */,
                                5A574F29131DB96D00471B88 /* QuotesData.h in Headers */,
                                B22279720D00BF220071B782 /* RadialGradientAttributes.h in Headers */,
index a2b2843..5b15db2 100644 (file)
@@ -154,4 +154,45 @@ bool Quirks::hasWebSQLSupportQuirk() const
     return m_hasWebSQLSupportQuirk.value();
 }
 
+bool Quirks::isTouchBarUpdateSupressedForHiddenContentEditable() const
+{
+#if PLATFORM(MAC)
+    if (!needsQuirks())
+        return false;
+
+    auto host = m_document->topDocument().url().host();
+    return equalLettersIgnoringASCIICase(host, "docs.google.com");
+#else
+    return false;
+#endif
+}
+
+bool Quirks::isNeverRichlyEditableForTouchBar() const
+{
+#if PLATFORM(MAC)
+    if (!needsQuirks())
+        return false;
+
+    auto& url = m_document->topDocument().url();
+    auto host = url.host();
+
+    if (equalLettersIgnoringASCIICase(host, "twitter.com"))
+        return true;
+
+    if (equalLettersIgnoringASCIICase(host, "onedrive.live.com"))
+        return true;
+
+    if (equalLettersIgnoringASCIICase(host, "trix-editor.org"))
+        return true;
+
+    if (equalLettersIgnoringASCIICase(host, "www.icloud.com")) {
+        auto path = url.path();
+        if (path.contains("notes") || url.fragmentIdentifier().contains("notes"))
+            return true;
+    }
+#endif
+
+    return false;
+}
+
 }
index 84e8838..46ad6d6 100644 (file)
@@ -46,6 +46,9 @@ public:
     bool hasBrokenEncryptedMediaAPISupportQuirk() const;
     bool hasWebSQLSupportQuirk() const;
 
+    WEBCORE_EXPORT bool isTouchBarUpdateSupressedForHiddenContentEditable() const;
+    WEBCORE_EXPORT bool isNeverRichlyEditableForTouchBar() const;
+
 private:
     bool needsQuirks() const;
 
index f4661ed..d1b6832 100644 (file)
@@ -1,3 +1,40 @@
+2019-03-12  Ryosuke Niwa  <rniwa@webkit.org>
+
+        Move the code for determining the need for touch bar quirks to Quirks class
+        https://bugs.webkit.org/show_bug.cgi?id=195654
+
+        Reviewed by Brent Fulgham.
+
+        Moved the code to determine whether touch bar quirks are needed or not to WebCore.
+
+        Also renamed HiddenContentEditableQuirk to IsTouchBarUpdateSupressedForHiddenContentEditable
+        and PlainTextQuirk to NeverRichlyEditableForTouchBar.
+
+        * UIProcess/Cocoa/WebViewImpl.h:
+        (WebKit::WebViewImpl::isRichlyEditableForTouchBar): Renamed.
+        * UIProcess/Cocoa/WebViewImpl.mm:
+        (WebKit::WebViewImpl::updateTouchBar):
+        (WebKit::WebViewImpl::candidateListTouchBarItem const):
+        (WebKit::WebViewImpl::isRichlyEditableForTouchBar const): Renamed from isRichlyEditable.
+        (WebKit::WebViewImpl::textTouchBar const):
+        (WebKit::WebViewImpl::updateTextTouchBar):
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::setIsTouchBarUpdateSupressedForHiddenContentEditable): Renamed from
+        setNeedsHiddenContentEditableQuirk.
+        (WebKit::WebPageProxy::setIsNeverRichlyEditableForTouchBar): Renamed from setNeedsPlainTextQuirk.
+        * UIProcess/WebPageProxy.h:
+        (WebKit::WebPageProxy::isTouchBarUpdateSupressedForHiddenContentEditable const): Renamed from
+        needsHiddenContentEditableQuirk.
+        (WebKit::WebPageProxy::isNeverRichlyEditableForTouchBar const): Renamed from needsPlainTextQuirk.
+        * UIProcess/WebPageProxy.messages.in: Renamed the IPC messages.
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::needsHiddenContentEditableQuirk): Deleted. Moved to WebCore.
+        (WebKit::needsPlainTextQuirk): Deleted. Moved to WebCore.
+        (WebKit::WebPage::didStartPageTransition):
+        (WebKit::WebPage::didChangeSelection):
+        * WebProcess/WebPage/WebPage.h:
+        (WebKit::WebPage):
+
 2019-03-12  Jiewen Tan  <jiewen_tan@apple.com>
 
         Add WebFrameProxy::loadData
index 4a3e0ae..44d9c9d 100644 (file)
@@ -608,7 +608,7 @@ private:
     void updateMediaTouchBar();
 
     bool useMediaPlaybackControlsView() const;
-    bool isRichlyEditable() const;
+    bool isRichlyEditableForTouchBar() const;
 
     bool m_clientWantsMediaPlaybackControlsView { false };
     bool m_canCreateTouchBars { false };
index 20a72e2..1bd83b7 100644 (file)
@@ -902,7 +902,7 @@ void WebViewImpl::updateTouchBar()
 
     NSTouchBar *touchBar = nil;
     bool userActionRequirementsHaveBeenMet = m_requiresUserActionForEditingControlsManager ? m_page->hasHadSelectionChangesFromUserInteraction() : true;
-    if (m_page->editorState().isContentEditable && !m_page->needsHiddenContentEditableQuirk()) {
+    if (m_page->editorState().isContentEditable && !m_page->isTouchBarUpdateSupressedForHiddenContentEditable()) {
         updateTextTouchBar();
         if (userActionRequirementsHaveBeenMet)
             touchBar = textTouchBar();
@@ -943,7 +943,7 @@ NSCandidateListTouchBarItem *WebViewImpl::candidateListTouchBarItem() const
 {
     if (m_page->editorState().isInPasswordField)
         return m_passwordTextCandidateListTouchBarItem.get();
-    return isRichlyEditable() ? m_richTextCandidateListTouchBarItem.get() : m_plainTextCandidateListTouchBarItem.get();
+    return isRichlyEditableForTouchBar() ? m_richTextCandidateListTouchBarItem.get() : m_plainTextCandidateListTouchBarItem.get();
 }
 
 #if ENABLE(WEB_PLAYBACK_CONTROLS_MANAGER)
@@ -1054,16 +1054,16 @@ void WebViewImpl::setUpTextTouchBar(NSTouchBar *touchBar)
         textFormatItem.groupTouchBar.customizationIdentifier = @"WKTextFormatTouchBar";
 }
 
-bool WebViewImpl::isRichlyEditable() const
+bool WebViewImpl::isRichlyEditableForTouchBar() const
 {
-    return m_page->editorState().isContentRichlyEditable && !m_page->needsPlainTextQuirk();
+    return m_page->editorState().isContentRichlyEditable && !m_page->isNeverRichlyEditableForTouchBar();
 }
 
 NSTouchBar *WebViewImpl::textTouchBar() const
 {
     if (m_page->editorState().isInPasswordField)
         return m_passwordTextTouchBar.get();
-    return isRichlyEditable() ? m_richTextTouchBar.get() : m_plainTextTouchBar.get();
+    return isRichlyEditableForTouchBar() ? m_richTextTouchBar.get() : m_plainTextTouchBar.get();
 }
 
 static NSTextAlignment nsTextAlignmentFromTextAlignment(TextAlignment textAlignment)
@@ -1155,7 +1155,7 @@ void WebViewImpl::updateTextTouchBar()
 
     // Set current typing attributes for rich text. This will ensure that the buttons reflect the state of
     // the text when changing selection throughout the document.
-    if (isRichlyEditable()) {
+    if (isRichlyEditableForTouchBar()) {
         const EditorState& editorState = m_page->editorState();
         if (!editorState.isMissingPostLayoutData) {
             [m_textTouchBarItemController setTextIsBold:(bool)(m_page->editorState().postLayoutData().typingAttributes & AttributeBold)];
index 78565b6..5ae7434 100644 (file)
@@ -5560,14 +5560,14 @@ void WebPageProxy::setHasHadSelectionChangesFromUserInteraction(bool hasHadUserS
     m_hasHadSelectionChangesFromUserInteraction = hasHadUserSelectionChanges;
 }
 
-void WebPageProxy::setNeedsHiddenContentEditableQuirk(bool needsHiddenContentEditableQuirk)
+void WebPageProxy::setIsTouchBarUpdateSupressedForHiddenContentEditable(bool ignoreTouchBarUpdate)
 {
-    m_needsHiddenContentEditableQuirk = needsHiddenContentEditableQuirk;
+    m_isTouchBarUpdateSupressedForHiddenContentEditable = ignoreTouchBarUpdate;
 }
 
-void WebPageProxy::setNeedsPlainTextQuirk(bool needsPlainTextQuirk)
+void WebPageProxy::setIsNeverRichlyEditableForTouchBar(bool isNeverRichlyEditable)
 {
-    m_needsPlainTextQuirk = needsPlainTextQuirk;
+    m_isNeverRichlyEditableForTouchBar = isNeverRichlyEditable;
 }
 
 void WebPageProxy::requestDOMPasteAccess(const WebCore::IntRect& elementRect, const String& originIdentifier, CompletionHandler<void(WebCore::DOMPasteAccessResponse)>&& completionHandler)
index c697651..da68be7 100644 (file)
@@ -1378,8 +1378,8 @@ public:
     void setUserInterfaceLayoutDirection(WebCore::UserInterfaceLayoutDirection);
 
     bool hasHadSelectionChangesFromUserInteraction() const { return m_hasHadSelectionChangesFromUserInteraction; }
-    bool needsHiddenContentEditableQuirk() const { return m_needsHiddenContentEditableQuirk; }
-    bool needsPlainTextQuirk() const { return m_needsPlainTextQuirk; }
+    bool isTouchBarUpdateSupressedForHiddenContentEditable() const { return m_isTouchBarUpdateSupressedForHiddenContentEditable; }
+    bool isNeverRichlyEditableForTouchBar() const { return m_isNeverRichlyEditableForTouchBar; }
 
     bool isAlwaysOnLoggingAllowed() const;
 
@@ -1690,8 +1690,8 @@ private:
 
     void compositionWasCanceled();
     void setHasHadSelectionChangesFromUserInteraction(bool);
-    void setNeedsHiddenContentEditableQuirk(bool);
-    void setNeedsPlainTextQuirk(bool);
+    void setIsTouchBarUpdateSupressedForHiddenContentEditable(bool);
+    void setIsNeverRichlyEditableForTouchBar(bool);
 
     void requestDOMPasteAccess(const WebCore::IntRect&, const String&, CompletionHandler<void(WebCore::DOMPasteAccessResponse)>&&);
 
@@ -2369,8 +2369,8 @@ WEBPAGEPROXY_LOADOPTIMIZER_ADDITIONS_2
     bool m_isResourceCachingDisabled { false };
 
     bool m_hasHadSelectionChangesFromUserInteraction { false };
-    bool m_needsHiddenContentEditableQuirk { false };
-    bool m_needsPlainTextQuirk { false };
+    bool m_isTouchBarUpdateSupressedForHiddenContentEditable { false };
+    bool m_isNeverRichlyEditableForTouchBar { false };
 
 #if ENABLE(MEDIA_SESSION)
     bool m_hasMediaSessionWithActiveMediaElements { false };
index 3465e76..c076e9e 100644 (file)
@@ -250,8 +250,8 @@ messages -> WebPageProxy {
     EditorStateChanged(struct WebKit::EditorState editorState)
     CompositionWasCanceled()
     SetHasHadSelectionChangesFromUserInteraction(bool hasHadUserSelectionChanges)
-    SetNeedsHiddenContentEditableQuirk(bool needsHiddenContentEditableQuirk)
-    SetNeedsPlainTextQuirk(bool needsPlainTextQuirk)
+    SetIsTouchBarUpdateSupressedForHiddenContentEditable(bool isTouchBarUpdateSupressed)
+    SetIsNeverRichlyEditableForTouchBar(bool isNeverRichlyEditable)
     RequestDOMPasteAccess(WebCore::IntRect elementRect, String originIdentifier) -> (enum:uint8_t WebCore::DOMPasteAccessResponse response) Delayed
 
     # Find messages
index ca50975..d07fdc3 100644 (file)
 #include <WebCore/PointerCaptureController.h>
 #include <WebCore/PrintContext.h>
 #include <WebCore/PromisedAttachmentInfo.h>
+#include <WebCore/Quirks.h>
 #include <WebCore/Range.h>
 #include <WebCore/RegistrableDomain.h>
 #include <WebCore/RemoteDOMWindow.h>
@@ -3140,13 +3141,13 @@ void WebPage::didStartPageTransition()
 #if PLATFORM(MAC)
     if (hasPreviouslyFocusedDueToUserInteraction)
         send(Messages::WebPageProxy::SetHasHadSelectionChangesFromUserInteraction(m_hasEverFocusedElementDueToUserInteractionSincePageTransition));
-    if (m_needsHiddenContentEditableQuirk) {
-        m_needsHiddenContentEditableQuirk = false;
-        send(Messages::WebPageProxy::SetNeedsHiddenContentEditableQuirk(m_needsHiddenContentEditableQuirk));
+    if (m_isTouchBarUpdateSupressedForHiddenContentEditable) {
+        m_isTouchBarUpdateSupressedForHiddenContentEditable = false;
+        send(Messages::WebPageProxy::SetIsTouchBarUpdateSupressedForHiddenContentEditable(m_isTouchBarUpdateSupressedForHiddenContentEditable));
     }
-    if (m_needsPlainTextQuirk) {
-        m_needsPlainTextQuirk = false;
-        send(Messages::WebPageProxy::SetNeedsPlainTextQuirk(m_needsPlainTextQuirk));
+    if (m_isNeverRichlyEditableForTouchBar) {
+        m_isNeverRichlyEditableForTouchBar = false;
+        send(Messages::WebPageProxy::SetIsNeverRichlyEditableForTouchBar(m_isNeverRichlyEditableForTouchBar));
     }
 #endif
 #if PLATFORM(IOS_FAMILY)
@@ -5209,39 +5210,6 @@ void WebPage::cancelComposition()
 }
 #endif
 
-#if PLATFORM(MAC)
-static bool needsHiddenContentEditableQuirk(bool needsQuirks, const URL& url)
-{
-    if (!needsQuirks)
-        return false;
-
-    return equalLettersIgnoringASCIICase(url.host(), "docs.google.com");
-}
-
-static bool needsPlainTextQuirk(bool needsQuirks, const URL& url)
-{
-    if (!needsQuirks)
-        return false;
-
-    auto host = url.host();
-
-    if (equalLettersIgnoringASCIICase(host, "twitter.com"))
-        return true;
-
-    if (equalLettersIgnoringASCIICase(host, "onedrive.live.com"))
-        return true;
-
-    String path = url.path();
-    if (equalLettersIgnoringASCIICase(host, "www.icloud.com") && (path.contains("notes") || url.fragmentIdentifier().contains("notes")))
-        return true;
-
-    if (equalLettersIgnoringASCIICase(host, "trix-editor.org"))
-        return true;
-
-    return false;
-}
-#endif
-
 void WebPage::didApplyStyle()
 {
     sendEditorStateUpdate();
@@ -5271,14 +5239,14 @@ void WebPage::didChangeSelection()
     m_hasEverFocusedElementDueToUserInteractionSincePageTransition |= m_userIsInteracting;
 
     if (!hasPreviouslyFocusedDueToUserInteraction && m_hasEverFocusedElementDueToUserInteractionSincePageTransition) {
-        if (needsHiddenContentEditableQuirk(m_page->settings().needsSiteSpecificQuirks(), m_page->mainFrame().document()->url())) {
-            m_needsHiddenContentEditableQuirk = true;
-            send(Messages::WebPageProxy::SetNeedsHiddenContentEditableQuirk(m_needsHiddenContentEditableQuirk));
+        if (frame.document()->quirks().isTouchBarUpdateSupressedForHiddenContentEditable()) {
+            m_isTouchBarUpdateSupressedForHiddenContentEditable = true;
+            send(Messages::WebPageProxy::SetIsTouchBarUpdateSupressedForHiddenContentEditable(m_isTouchBarUpdateSupressedForHiddenContentEditable));
         }
 
-        if (needsPlainTextQuirk(m_page->settings().needsSiteSpecificQuirks(), m_page->mainFrame().document()->url())) {
-            m_needsPlainTextQuirk = true;
-            send(Messages::WebPageProxy::SetNeedsPlainTextQuirk(m_needsPlainTextQuirk));
+        if (frame.document()->quirks().isNeverRichlyEditableForTouchBar()) {
+            m_isNeverRichlyEditableForTouchBar = true;
+            send(Messages::WebPageProxy::SetIsNeverRichlyEditableForTouchBar(m_isNeverRichlyEditableForTouchBar));
         }
 
         send(Messages::WebPageProxy::SetHasHadSelectionChangesFromUserInteraction(m_hasEverFocusedElementDueToUserInteractionSincePageTransition));
index 49ba935..5101c40 100644 (file)
@@ -1729,8 +1729,8 @@ private:
 
     bool m_userIsInteracting { false };
     bool m_hasEverFocusedElementDueToUserInteractionSincePageTransition { false };
-    bool m_needsHiddenContentEditableQuirk { false };
-    bool m_needsPlainTextQuirk { false };
+    bool m_isTouchBarUpdateSupressedForHiddenContentEditable { false };
+    bool m_isNeverRichlyEditableForTouchBar { false };
     bool m_changingActivityState { false };
 
 #if ENABLE(CONTEXT_MENUS)