Title: [276976] branches/safari-612.1.12-branch/Source
Revision
276976
Author
repst...@apple.com
Date
2021-05-04 12:11:25 -0700 (Tue, 04 May 2021)

Log Message

Cherry-pick r276947. rdar://problem/77510833

    Allow AppHighlight visibility to be toggled
    https://bugs.webkit.org/show_bug.cgi?id=225276

    Reviewed by Wenson Hsieh.

    Source/WebCore:

    Add supporting infrastructure to allow highlights to be turned on and off.
    This is done with a simple state and a forced repaint on the areas that have highlights.

    * Modules/highlight/Highlight.cpp:
    (WebCore::Highlight::forceRepaint):
    * Modules/highlight/Highlight.h:
    * Modules/highlight/HighlightRegister.cpp:
    (WebCore::HighlightRegister::setActive):
    * Modules/highlight/HighlightRegister.h:
    (WebCore::HighlightRegister::isActive):
    * rendering/InlineTextBox.cpp:
    (WebCore::InlineTextBox::collectMarkedTextsForHighlights const):
    * rendering/RenderReplaced.cpp:
    (WebCore::RenderReplaced::calculateHighlightColor const):

    Source/WebKit:

    Add supporting infrastructure to allow highlights to be turned on and off.

    * Scripts/webkit/messages.py:
    (headers_for_type):
    * UIProcess/Cocoa/WebPageProxyCocoa.mm:
    (WebKit::WebPageProxy::restoreAppHighlightsAndScrollToIndex):
    (WebKit::WebPageProxy::setAppHighlightsActive):
    * UIProcess/WebPageProxy.h:
    * UIProcess/ios/WKContentViewInteraction.mm:
    (-[WKContentView canPerformAction:withSender:]):
    (-[WKContentView targetForAction:withSender:]):
    * WebProcess/WebPage/WebPage.cpp:
    (WebKit::WebPage::setAppHighlightsActive):
    * WebProcess/WebPage/WebPage.h:
    * WebProcess/WebPage/WebPage.messages.in:

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

Modified Paths

Added Paths

Diff

Modified: branches/safari-612.1.12-branch/Source/WebCore/ChangeLog (276975 => 276976)


--- branches/safari-612.1.12-branch/Source/WebCore/ChangeLog	2021-05-04 19:03:50 UTC (rev 276975)
+++ branches/safari-612.1.12-branch/Source/WebCore/ChangeLog	2021-05-04 19:11:25 UTC (rev 276976)
@@ -1,3 +1,71 @@
+2021-05-04  Russell Epstein  <repst...@apple.com>
+
+        Cherry-pick r276947. rdar://problem/77510833
+
+    Allow AppHighlight visibility to be toggled
+    https://bugs.webkit.org/show_bug.cgi?id=225276
+    
+    Reviewed by Wenson Hsieh.
+    
+    Source/WebCore:
+    
+    Add supporting infrastructure to allow highlights to be turned on and off.
+    This is done with a simple state and a forced repaint on the areas that have highlights.
+    
+    * Modules/highlight/Highlight.cpp:
+    (WebCore::Highlight::forceRepaint):
+    * Modules/highlight/Highlight.h:
+    * Modules/highlight/HighlightRegister.cpp:
+    (WebCore::HighlightRegister::setActive):
+    * Modules/highlight/HighlightRegister.h:
+    (WebCore::HighlightRegister::isActive):
+    * rendering/InlineTextBox.cpp:
+    (WebCore::InlineTextBox::collectMarkedTextsForHighlights const):
+    * rendering/RenderReplaced.cpp:
+    (WebCore::RenderReplaced::calculateHighlightColor const):
+    
+    Source/WebKit:
+    
+    Add supporting infrastructure to allow highlights to be turned on and off.
+    
+    * Scripts/webkit/messages.py:
+    (headers_for_type):
+    * UIProcess/Cocoa/WebPageProxyCocoa.mm:
+    (WebKit::WebPageProxy::restoreAppHighlightsAndScrollToIndex):
+    (WebKit::WebPageProxy::setAppHighlightsActive):
+    * UIProcess/WebPageProxy.h:
+    * UIProcess/ios/WKContentViewInteraction.mm:
+    (-[WKContentView canPerformAction:withSender:]):
+    (-[WKContentView targetForAction:withSender:]):
+    * WebProcess/WebPage/WebPage.cpp:
+    (WebKit::WebPage::setAppHighlightsActive):
+    * WebProcess/WebPage/WebPage.h:
+    * WebProcess/WebPage/WebPage.messages.in:
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@276947 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2021-05-03  Megan Gardner  <megan_gard...@apple.com>
+
+            Allow AppHighlight visibility to be toggled
+            https://bugs.webkit.org/show_bug.cgi?id=225276
+
+            Reviewed by Wenson Hsieh.
+
+            Add supporting infrastructure to allow highlights to be turned on and off.
+            This is done with a simple state and a forced repaint on the areas that have highlights.
+
+            * Modules/highlight/Highlight.cpp:
+            (WebCore::Highlight::forceRepaint):
+            * Modules/highlight/Highlight.h:
+            * Modules/highlight/HighlightRegister.cpp:
+            (WebCore::HighlightRegister::setActive):
+            * Modules/highlight/HighlightRegister.h:
+            (WebCore::HighlightRegister::isActive):
+            * rendering/InlineTextBox.cpp:
+            (WebCore::InlineTextBox::collectMarkedTextsForHighlights const):
+            * rendering/RenderReplaced.cpp:
+            (WebCore::RenderReplaced::calculateHighlightColor const):
+
 2021-05-03  Russell Epstein  <repst...@apple.com>
 
         Cherry-pick r276853. rdar://problem/77458363

Modified: branches/safari-612.1.12-branch/Source/WebCore/Modules/highlight/Highlight.cpp (276975 => 276976)


--- branches/safari-612.1.12-branch/Source/WebCore/Modules/highlight/Highlight.cpp	2021-05-04 19:03:50 UTC (rev 276975)
+++ branches/safari-612.1.12-branch/Source/WebCore/Modules/highlight/Highlight.cpp	2021-05-04 19:11:25 UTC (rev 276976)
@@ -101,5 +101,11 @@
     return true;
 }
 
+void Highlight::repaint()
+{
+    for (auto& data : m_rangesData)
+        repaintRange(data->range);
 }
 
+}
+

Modified: branches/safari-612.1.12-branch/Source/WebCore/Modules/highlight/Highlight.h (276975 => 276976)


--- branches/safari-612.1.12-branch/Source/WebCore/Modules/highlight/Highlight.h	2021-05-04 19:03:50 UTC (rev 276975)
+++ branches/safari-612.1.12-branch/Source/WebCore/Modules/highlight/Highlight.h	2021-05-04 19:11:25 UTC (rev 276976)
@@ -59,6 +59,8 @@
     bool addToSetLike(StaticRange&);
     bool removeFromSetLike(const StaticRange&);
     void initializeSetLike(DOMSetAdapter&);
+    
+    void repaint();
     const Vector<Ref<HighlightRangeData>>& rangesData() const { return m_rangesData; }
 
     // FIXME: Add WEBCORE_EXPORT CSSStyleDeclaration& style();

Modified: branches/safari-612.1.12-branch/Source/WebCore/Modules/highlight/HighlightRegister.cpp (276975 => 276976)


--- branches/safari-612.1.12-branch/Source/WebCore/Modules/highlight/HighlightRegister.cpp	2021-05-04 19:03:50 UTC (rev 276975)
+++ branches/safari-612.1.12-branch/Source/WebCore/Modules/highlight/HighlightRegister.cpp	2021-05-04 19:11:25 UTC (rev 276976)
@@ -65,5 +65,17 @@
     else
         setFromMapLike(appHighlightKey(), Highlight::create(WTFMove(value)));
 }
+
+void HighlightRegister::setHighlightVisibility(HighlightVisibility highlightVisibility)
+{
+    if (m_highlightVisibility == highlightVisibility)
+        return;
+    
+    m_highlightVisibility = highlightVisibility;
+    
+    for (auto& highlight : m_map)
+        highlight.value->repaint();
+}
+
 #endif
 }

Modified: branches/safari-612.1.12-branch/Source/WebCore/Modules/highlight/HighlightRegister.h (276975 => 276976)


--- branches/safari-612.1.12-branch/Source/WebCore/Modules/highlight/HighlightRegister.h	2021-05-04 19:03:50 UTC (rev 276975)
+++ branches/safari-612.1.12-branch/Source/WebCore/Modules/highlight/HighlightRegister.h	2021-05-04 19:11:25 UTC (rev 276976)
@@ -26,6 +26,7 @@
 #pragma once
 
 #include "Highlight.h"
+#include "HighlightVisibility.h"
 #include <wtf/HashMap.h>
 #include <wtf/RefCounted.h>
 
@@ -44,6 +45,10 @@
     void setFromMapLike(String&&, Ref<Highlight>&&);
     void clear();
     bool remove(const String&);
+    
+    HighlightVisibility highlightsVisibility() const { return m_highlightVisibility; }
+    WEBCORE_EXPORT void setHighlightVisibility(HighlightVisibility);
+    
 #if ENABLE(APP_HIGHLIGHTS)
     WEBCORE_EXPORT void addAppHighlight(Ref<StaticRange>&&);
     static ASCIILiteral appHighlightKey();
@@ -53,6 +58,8 @@
 private:
     HighlightRegister() = default;
     HashMap<String, Ref<Highlight>> m_map;
+
+    HighlightVisibility m_highlightVisibility { HighlightVisibility::Hidden };
 };
 
 }

Copied: branches/safari-612.1.12-branch/Source/WebCore/Modules/highlight/HighlightVisibility.h (from rev 276968, branches/safari-612.1.12-branch/Source/WebCore/Modules/highlight/HighlightRegister.h) (0 => 276976)


--- branches/safari-612.1.12-branch/Source/WebCore/Modules/highlight/HighlightVisibility.h	                        (rev 0)
+++ branches/safari-612.1.12-branch/Source/WebCore/Modules/highlight/HighlightVisibility.h	2021-05-04 19:11:25 UTC (rev 276976)
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2019-2020 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+namespace WebCore {
+
+enum class HighlightVisibility : bool { Hidden, Visible };
+
+}

Modified: branches/safari-612.1.12-branch/Source/WebCore/WebCore.xcodeproj/project.pbxproj (276975 => 276976)


--- branches/safari-612.1.12-branch/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2021-05-04 19:03:50 UTC (rev 276975)
+++ branches/safari-612.1.12-branch/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2021-05-04 19:11:25 UTC (rev 276976)
@@ -1262,6 +1262,7 @@
 		448B1B7A0F3A2F9B0047A9E2 /* TextSizeAdjustment.h in Headers */ = {isa = PBXBuildFile; fileRef = 448B1B780F3A2F9B0047A9E2 /* TextSizeAdjustment.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		4496E39E1398136C003EE32A /* JSSVGAnimateMotionElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 4496E39C1398136C003EE32A /* JSSVGAnimateMotionElement.h */; };
 		4496E3A0139813A5003EE32A /* JSSVGMPathElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 4496E39F139813A5003EE32A /* JSSVGMPathElement.h */; };
+		449D864F2640C9C5000122DE /* HighlightVisibility.h in Headers */ = {isa = PBXBuildFile; fileRef = 449D864D2640C9B9000122DE /* HighlightVisibility.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		44A20DB90F84166C00B3E1FE /* WebCoreURLResponseIOS.h in Headers */ = {isa = PBXBuildFile; fileRef = 44A20DB80F84166C00B3E1FE /* WebCoreURLResponseIOS.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		44A28AAC12DFB8AC00AE923B /* MathMLElementFactory.h in Headers */ = {isa = PBXBuildFile; fileRef = 44A28AAB12DFB8AC00AE923B /* MathMLElementFactory.h */; };
 		44A28AAF12DFB8BF00AE923B /* MathMLNames.h in Headers */ = {isa = PBXBuildFile; fileRef = 44A28AAE12DFB8BF00AE923B /* MathMLNames.h */; };
@@ -8234,6 +8235,7 @@
 		4496E39C1398136C003EE32A /* JSSVGAnimateMotionElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSSVGAnimateMotionElement.h; sourceTree = "<group>"; };
 		4496E39F139813A5003EE32A /* JSSVGMPathElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSSVGMPathElement.h; sourceTree = "<group>"; };
 		4496E3A1139813CB003EE32A /* JSSVGMPathElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSSVGMPathElement.cpp; sourceTree = "<group>"; };
+		449D864D2640C9B9000122DE /* HighlightVisibility.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = HighlightVisibility.h; sourceTree = "<group>"; };
 		44A20DB80F84166C00B3E1FE /* WebCoreURLResponseIOS.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebCoreURLResponseIOS.h; sourceTree = "<group>"; };
 		44A28AAB12DFB8AC00AE923B /* MathMLElementFactory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MathMLElementFactory.h; path = DerivedSources/WebCore/MathMLElementFactory.h; sourceTree = BUILT_PRODUCTS_DIR; };
 		44A28AAE12DFB8BF00AE923B /* MathMLNames.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MathMLNames.h; path = DerivedSources/WebCore/MathMLNames.h; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -20047,6 +20049,7 @@
 				44E88E52236A667F009B4847 /* HighlightRegister.cpp */,
 				44E88E50236A56AC009B4847 /* HighlightRegister.h */,
 				44E88E4C2369128A009B4847 /* HighlightRegister.idl */,
+				449D864D2640C9B9000122DE /* HighlightVisibility.h */,
 			);
 			path = highlight;
 			sourceTree = "<group>";
@@ -31419,6 +31422,7 @@
 				31A795C71888BCB200382F90 /* ANGLEInstancedArrays.h in Headers */,
 				49E912AB0EFAC906009D0CAF /* Animation.h in Headers */,
 				71EFCEDC202B38A900D7C411 /* AnimationEffect.h in Headers */,
+				449D864F2640C9C5000122DE /* HighlightVisibility.h in Headers */,
 				71E2C42621C935280024F8C8 /* AnimationEffectPhase.h in Headers */,
 				319848011A1D817B00A13318 /* AnimationEvent.h in Headers */,
 				711AD126236D86E5006FF37C /* AnimationEventBase.h in Headers */,

Modified: branches/safari-612.1.12-branch/Source/WebCore/rendering/InlineTextBox.cpp (276975 => 276976)


--- branches/safari-612.1.12-branch/Source/WebCore/rendering/InlineTextBox.cpp	2021-05-04 19:03:50 UTC (rev 276975)
+++ branches/safari-612.1.12-branch/Source/WebCore/rendering/InlineTextBox.cpp	2021-05-04 19:11:25 UTC (rev 276976)
@@ -911,14 +911,16 @@
     }
 #if ENABLE(APP_HIGHLIGHTS)
     if (auto appHighlightRegister = renderer().document().appHighlightRegisterIfExists()) {
-        for (auto& highlight : appHighlightRegister->map()) {
-            for (auto& rangeData : highlight.value->rangesData()) {
-                if (!highlightData.setRenderRange(rangeData))
-                    continue;
+        if (appHighlightRegister->highlightsVisibility() == HighlightVisibility::Visible) {
+            for (auto& highlight : appHighlightRegister->map()) {
+                for (auto& rangeData : highlight.value->rangesData()) {
+                    if (!highlightData.setRenderRange(rangeData))
+                        continue;
 
-                auto [highlightStart, highlightEnd] = highlightStartEnd(highlightData);
-                if (highlightStart < highlightEnd)
-                    markedTexts.append({ highlightStart, highlightEnd, MarkedText::AppHighlight });
+                    auto [highlightStart, highlightEnd] = highlightStartEnd(highlightData);
+                    if (highlightStart < highlightEnd)
+                        markedTexts.append({ highlightStart, highlightEnd, MarkedText::AppHighlight });
+                }
             }
         }
     }

Modified: branches/safari-612.1.12-branch/Source/WebCore/rendering/RenderReplaced.cpp (276975 => 276976)


--- branches/safari-612.1.12-branch/Source/WebCore/rendering/RenderReplaced.cpp	2021-05-04 19:03:50 UTC (rev 276975)
+++ branches/safari-612.1.12-branch/Source/WebCore/rendering/RenderReplaced.cpp	2021-05-04 19:11:25 UTC (rev 276976)
@@ -145,17 +145,19 @@
     HighlightData highlightData;
 #if ENABLE(APP_HIGHLIGHTS)
     if (auto appHighlightRegister = document().appHighlightRegisterIfExists()) {
-        for (auto& highlight : appHighlightRegister->map()) {
-            for (auto& rangeData : highlight.value->rangesData()) {
-                if (!highlightData.setRenderRange(rangeData))
-                    continue;
+        if (appHighlightRegister->highlightsVisibility() == HighlightVisibility::Visible) {
+            for (auto& highlight : appHighlightRegister->map()) {
+                for (auto& rangeData : highlight.value->rangesData()) {
+                    if (!highlightData.setRenderRange(rangeData))
+                        continue;
 
-                auto state = highlightData.highlightStateForRenderer(*this);
-                if (!isHighlighted(state, highlightData))
-                    continue;
+                    auto state = highlightData.highlightStateForRenderer(*this);
+                    if (!isHighlighted(state, highlightData))
+                        continue;
 
-                OptionSet<StyleColor::Options> styleColorOptions = { StyleColor::Options::UseSystemAppearance };
-                return theme().appHighlightColor(styleColorOptions);
+                    OptionSet<StyleColor::Options> styleColorOptions = { StyleColor::Options::UseSystemAppearance };
+                    return theme().appHighlightColor(styleColorOptions);
+                }
             }
         }
     }

Modified: branches/safari-612.1.12-branch/Source/WebKit/ChangeLog (276975 => 276976)


--- branches/safari-612.1.12-branch/Source/WebKit/ChangeLog	2021-05-04 19:03:50 UTC (rev 276975)
+++ branches/safari-612.1.12-branch/Source/WebKit/ChangeLog	2021-05-04 19:11:25 UTC (rev 276976)
@@ -1,3 +1,72 @@
+2021-05-04  Russell Epstein  <repst...@apple.com>
+
+        Cherry-pick r276947. rdar://problem/77510833
+
+    Allow AppHighlight visibility to be toggled
+    https://bugs.webkit.org/show_bug.cgi?id=225276
+    
+    Reviewed by Wenson Hsieh.
+    
+    Source/WebCore:
+    
+    Add supporting infrastructure to allow highlights to be turned on and off.
+    This is done with a simple state and a forced repaint on the areas that have highlights.
+    
+    * Modules/highlight/Highlight.cpp:
+    (WebCore::Highlight::forceRepaint):
+    * Modules/highlight/Highlight.h:
+    * Modules/highlight/HighlightRegister.cpp:
+    (WebCore::HighlightRegister::setActive):
+    * Modules/highlight/HighlightRegister.h:
+    (WebCore::HighlightRegister::isActive):
+    * rendering/InlineTextBox.cpp:
+    (WebCore::InlineTextBox::collectMarkedTextsForHighlights const):
+    * rendering/RenderReplaced.cpp:
+    (WebCore::RenderReplaced::calculateHighlightColor const):
+    
+    Source/WebKit:
+    
+    Add supporting infrastructure to allow highlights to be turned on and off.
+    
+    * Scripts/webkit/messages.py:
+    (headers_for_type):
+    * UIProcess/Cocoa/WebPageProxyCocoa.mm:
+    (WebKit::WebPageProxy::restoreAppHighlightsAndScrollToIndex):
+    (WebKit::WebPageProxy::setAppHighlightsActive):
+    * UIProcess/WebPageProxy.h:
+    * UIProcess/ios/WKContentViewInteraction.mm:
+    (-[WKContentView canPerformAction:withSender:]):
+    (-[WKContentView targetForAction:withSender:]):
+    * WebProcess/WebPage/WebPage.cpp:
+    (WebKit::WebPage::setAppHighlightsActive):
+    * WebProcess/WebPage/WebPage.h:
+    * WebProcess/WebPage/WebPage.messages.in:
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@276947 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2021-05-03  Megan Gardner  <megan_gard...@apple.com>
+
+            Allow AppHighlight visibility to be toggled
+            https://bugs.webkit.org/show_bug.cgi?id=225276
+
+            Reviewed by Wenson Hsieh.
+
+            Add supporting infrastructure to allow highlights to be turned on and off.
+
+            * Scripts/webkit/messages.py:
+            (headers_for_type):
+            * UIProcess/Cocoa/WebPageProxyCocoa.mm:
+            (WebKit::WebPageProxy::restoreAppHighlightsAndScrollToIndex):
+            (WebKit::WebPageProxy::setAppHighlightsActive):
+            * UIProcess/WebPageProxy.h:
+            * UIProcess/ios/WKContentViewInteraction.mm:
+            (-[WKContentView canPerformAction:withSender:]):
+            (-[WKContentView targetForAction:withSender:]):
+            * WebProcess/WebPage/WebPage.cpp:
+            (WebKit::WebPage::setAppHighlightsActive):
+            * WebProcess/WebPage/WebPage.h:
+            * WebProcess/WebPage/WebPage.messages.in:
+
 2021-05-03  Ruben Turcios  <rubent...@apple.com>
 
         Cherry-pick r276826. rdar://problem/77463493

Modified: branches/safari-612.1.12-branch/Source/WebKit/Scripts/webkit/messages.py (276975 => 276976)


--- branches/safari-612.1.12-branch/Source/WebKit/Scripts/webkit/messages.py	2021-05-04 19:03:50 UTC (rev 276975)
+++ branches/safari-612.1.12-branch/Source/WebKit/Scripts/webkit/messages.py	2021-05-04 19:11:25 UTC (rev 276976)
@@ -694,6 +694,7 @@
         'WebCore::GrammarDetail': ['<WebCore/TextCheckerClient.h>'],
         'WebCore::HasInsecureContent': ['<WebCore/FrameLoaderTypes.h>'],
         'WebCore::HighlightRequestOriginatedInApp': ['<WebCore/AppHighlight.h>'],
+        'WebCore::HighlightVisibility': ['<WebCore/HighlightVisibility.h>'],
         'WebCore::IncludeSecureCookies': ['<WebCore/CookieJar.h>'],
         'WebCore::IndexedDB::ObjectStoreOverwriteMode': ['<WebCore/IndexedDB.h>'],
         'WebCore::InputMode': ['<WebCore/InputMode.h>'],

Modified: branches/safari-612.1.12-branch/Source/WebKit/UIProcess/Cocoa/WebPageProxyCocoa.mm (276975 => 276976)


--- branches/safari-612.1.12-branch/Source/WebKit/UIProcess/Cocoa/WebPageProxyCocoa.mm	2021-05-04 19:03:50 UTC (rev 276975)
+++ branches/safari-612.1.12-branch/Source/WebKit/UIProcess/Cocoa/WebPageProxyCocoa.mm	2021-05-04 19:11:25 UTC (rev 276976)
@@ -572,9 +572,20 @@
 
         memoryHandles.append(SharedMemory::IPCHandle { WTFMove(handle), highlight->size() });
     }
+    
+    setUpHighlightsObserver();
 
     send(Messages::WebPage::RestoreAppHighlightsAndScrollToIndex(WTFMove(memoryHandles), index));
 }
+
+void WebPageProxy::setAppHighlightsVisibility(WebCore::HighlightVisibility appHighlightsVisibility)
+{
+    if (!hasRunningProcess())
+        return;
+
+    send(Messages::WebPage::SetAppHighlightsVisibility(appHighlightsVisibility));
+}
+
 #endif
 
 SandboxExtension::HandleArray WebPageProxy::createNetworkExtensionsSandboxExtensions(WebProcessProxy& process)

Modified: branches/safari-612.1.12-branch/Source/WebKit/UIProcess/WebPageProxy.h (276975 => 276976)


--- branches/safari-612.1.12-branch/Source/WebKit/UIProcess/WebPageProxy.h	2021-05-04 19:03:50 UTC (rev 276975)
+++ branches/safari-612.1.12-branch/Source/WebKit/UIProcess/WebPageProxy.h	2021-05-04 19:11:25 UTC (rev 276976)
@@ -260,6 +260,7 @@
 enum class LockBackForwardList : bool;
 enum class HasInsecureContent : bool;
 enum class HighlightRequestOriginatedInApp : bool;
+enum class HighlightVisibility : bool;
 enum class MouseEventPolicy : uint8_t;
 enum class NotificationDirection : uint8_t;
 enum class RouteSharingPolicy : uint8_t;
@@ -1890,6 +1891,7 @@
     void createAppHighlightInSelectedRange(WebCore::CreateNewGroupForHighlight, WebCore::HighlightRequestOriginatedInApp);
     void storeAppHighlight(const WebCore::AppHighlight&);
     void restoreAppHighlightsAndScrollToIndex(const Vector<Ref<WebKit::SharedMemory>>& highlights, const Optional<unsigned> index);
+    void setAppHighlightsVisibility(const WebCore::HighlightVisibility);
 #endif
 
 #if ENABLE(MEDIA_STREAM)

Modified: branches/safari-612.1.12-branch/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm (276975 => 276976)


--- branches/safari-612.1.12-branch/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm	2021-05-04 19:03:50 UTC (rev 276975)
+++ branches/safari-612.1.12-branch/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm	2021-05-04 19:11:25 UTC (rev 276976)
@@ -3565,11 +3565,6 @@
         || action == @selector(_transpose))
         return editorState.isContentEditable;
 
-#if ENABLE(APP_HIGHLIGHTS)
-    if (action == @selector(createHighlightInCurrentGroupWithRange:) || action == @selector(createHighlightInNewGroupWithRange:))
-        return editorState.selectionIsRange && !editorState.isContentEditable;
-#endif
-
     return [_webView canPerformAction:action withSender:sender];
 }
 
@@ -3761,8 +3756,11 @@
 - (id)targetForAction:(SEL)action withSender:(id)sender
 {
 #if ENABLE(APP_HIGHLIGHTS)
-    if (action == @selector(createHighlightInCurrentGroupWithRange:) || action == @selector(createHighlightInNewGroupWithRange:))
-        return self;
+    if (action == @selector(createHighlightInCurrentGroupWithRange:))
+        return self.shouldAllowAppHighlightCreation && _page->appHighlightsVisibility() ? self : nil;
+    if (action == @selector(createHighlightInNewGroupWithRange:))
+        return self.shouldAllowAppHighlightCreation && !_page->appHighlightsVisibility() ? self : nil;
+    
 #endif
     return [_webView targetForAction:action withSender:sender];
 }

Modified: branches/safari-612.1.12-branch/Source/WebKit/WebProcess/WebPage/WebPage.cpp (276975 => 276976)


--- branches/safari-612.1.12-branch/Source/WebKit/WebProcess/WebPage/WebPage.cpp	2021-05-04 19:03:50 UTC (rev 276975)
+++ branches/safari-612.1.12-branch/Source/WebKit/WebProcess/WebPage/WebPage.cpp	2021-05-04 19:11:25 UTC (rev 276976)
@@ -7517,6 +7517,15 @@
         i++;
     }
 }
+
+void WebPage::setAppHighlightsVisibility(WebCore::HighlightVisibility appHighlightVisibility)
+{
+    for (RefPtr<Frame> frame = m_mainFrame->coreFrame(); frame; frame = frame->tree().traverseNextRendered()) {
+        if (auto document = makeRefPtr(frame->document()))
+            document->appHighlightRegister().setHighlightVisibility(appHighlightVisibility);
+    }
+}
+
 #endif
 
 #if ENABLE(MEDIA_SESSION_COORDINATOR)

Modified: branches/safari-612.1.12-branch/Source/WebKit/WebProcess/WebPage/WebPage.h (276975 => 276976)


--- branches/safari-612.1.12-branch/Source/WebKit/WebProcess/WebPage/WebPage.h	2021-05-04 19:03:50 UTC (rev 276975)
+++ branches/safari-612.1.12-branch/Source/WebKit/WebProcess/WebPage/WebPage.h	2021-05-04 19:11:25 UTC (rev 276976)
@@ -216,6 +216,7 @@
 enum class DragHandlingMethod : uint8_t;
 enum class EventMakesGamepadsVisible : bool;
 enum class HighlightRequestOriginatedInApp : bool;
+enum class HighlightVisibility : bool;
 enum class SelectionDirection : uint8_t;
 enum class ShouldTreatAsContinuingLoad : bool;
 enum class TextIndicatorPresentationTransition : uint8_t;
@@ -1420,6 +1421,7 @@
 
     bool createAppHighlightInSelectedRange(WebCore::CreateNewGroupForHighlight, WebCore::HighlightRequestOriginatedInApp);
     void restoreAppHighlightsAndScrollToIndex(const Vector<SharedMemory::IPCHandle>&&, const Optional<unsigned> index);
+    void setAppHighlightsVisibility(const WebCore::HighlightVisibility);
 #endif
 
     void dispatchWheelEventWithoutScrolling(const WebWheelEvent&, CompletionHandler<void(bool)>&&);

Modified: branches/safari-612.1.12-branch/Source/WebKit/WebProcess/WebPage/WebPage.messages.in (276975 => 276976)


--- branches/safari-612.1.12-branch/Source/WebKit/WebProcess/WebPage/WebPage.messages.in	2021-05-04 19:03:50 UTC (rev 276975)
+++ branches/safari-612.1.12-branch/Source/WebKit/WebProcess/WebPage/WebPage.messages.in	2021-05-04 19:11:25 UTC (rev 276976)
@@ -629,6 +629,7 @@
 #if ENABLE(APP_HIGHLIGHTS)
     CreateAppHighlightInSelectedRange(enum:bool WebCore::CreateNewGroupForHighlight createNewGroup, enum:bool WebCore::HighlightRequestOriginatedInApp requestOrigin)
     RestoreAppHighlightsAndScrollToIndex(Vector<WebKit::SharedMemory::IPCHandle> memoryHandles, Optional<unsigned> index)
+    SetAppHighlightsVisibility(enum:bool WebCore::HighlightVisibility highlightVisibility)
 #endif
 
     DispatchWheelEventWithoutScrolling(WebKit::WebWheelEvent event) -> (bool handled) Async
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to