Title: [270007] trunk/Source/WebKit
Revision
270007
Author
megan_gard...@apple.com
Date
2020-11-18 19:16:53 -0800 (Wed, 18 Nov 2020)

Log Message

Menu Bar support for app highlights in book.
https://bugs.webkit.org/show_bug.cgi?id=219117

Reviewed by Wenson Hsieh.

Add menu stubs in iOS to support highlights for books in modern webkit.

* UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView setUpInteraction]):
(-[WKContentView canPerformAction:withSender:]):
(-[WKContentView setupAppHighlightMenus]):
(-[WKContentView createHighlightInCurrentGroupWithRange:]):
(-[WKContentView createHighlightInNewGroupWithRange:]):

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (270006 => 270007)


--- trunk/Source/WebKit/ChangeLog	2020-11-19 02:53:43 UTC (rev 270006)
+++ trunk/Source/WebKit/ChangeLog	2020-11-19 03:16:53 UTC (rev 270007)
@@ -1,3 +1,19 @@
+2020-11-18  Megan Gardner  <megan_gard...@apple.com>
+
+        Menu Bar support for app highlights in book.
+        https://bugs.webkit.org/show_bug.cgi?id=219117
+
+        Reviewed by Wenson Hsieh.
+
+        Add menu stubs in iOS to support highlights for books in modern webkit. 
+
+        * UIProcess/ios/WKContentViewInteraction.mm:
+        (-[WKContentView setUpInteraction]):
+        (-[WKContentView canPerformAction:withSender:]):
+        (-[WKContentView setupAppHighlightMenus]):
+        (-[WKContentView createHighlightInCurrentGroupWithRange:]):
+        (-[WKContentView createHighlightInNewGroupWithRange:]):
+
 2020-11-18  Wenson Hsieh  <wenson_hs...@apple.com>
 
         Rename MetaCommandSwitchTo to MetaCommandSwitchToItemBuffer

Modified: trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm (270006 => 270007)


--- trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm	2020-11-19 02:53:43 UTC (rev 270006)
+++ trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm	2020-11-19 03:16:53 UTC (rev 270007)
@@ -837,6 +837,10 @@
     [self setUpScribbleInteraction];
 #endif
 
+#if ENABLE(APP_HIGHLIGHTS)
+    [self setupAppHighlightMenus];
+#endif
+
     _twoFingerSingleTapGestureRecognizer = adoptNS([[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(_twoFingerSingleTapGestureRecognized:)]);
     [_twoFingerSingleTapGestureRecognizer setAllowableMovement:60];
     [_twoFingerSingleTapGestureRecognizer _setAllowableSeparation:150];
@@ -3326,6 +3330,11 @@
         || 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];
 }
 
@@ -8594,6 +8603,28 @@
 }
 #endif
 
+#if ENABLE(APP_HIGHLIGHTS)
+- (void)setupAppHighlightMenus
+{
+    if (_page->preferences().appHighlightsEnabled()) {
+        auto addHighlightCurrentGroupItem = adoptNS([[UIMenuItem alloc] initWithTitle:WebCore::contextMenuItemTagAddHighlightToCurrentGroup() action:@selector(createHighlightInCurrentGroupWithRange:)]);
+        auto addHighlightNewGroupItem = adoptNS([[UIMenuItem alloc] initWithTitle:WebCore::contextMenuItemTagAddHighlightToNewGroup() action:@selector(createHighlightInNewGroupWithRange:)]);
+        [[UIMenuController sharedMenuController] setMenuItems:@[ addHighlightCurrentGroupItem.get(), addHighlightNewGroupItem.get() ]];
+    }
+}
+
+- (void)createHighlightInCurrentGroupWithRange:(id)sender
+{
+    // FIXME: Add Highlight logic.
+}
+
+- (void)createHighlightInNewGroupWithRange:(id)sender
+{
+    // FIXME: Add Highlight logic.
+}
+
+#endif
+
 - (void)setContinuousSpellCheckingEnabled:(BOOL)enabled
 {
     if (WebKit::TextChecker::setContinuousSpellCheckingEnabled(enabled))
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to