Title: [271445] trunk/Source/WebKit
Revision
271445
Author
[email protected]
Date
2021-01-13 11:05:44 -0800 (Wed, 13 Jan 2021)

Log Message

Defer setting up app highlight menus until needed to not delay launch time.
https://bugs.webkit.org/show_bug.cgi?id=220577
rdar://72940219

Delay adding the app highlight menus to the callout bar until a selection happens,
as the creation of these menus is expensive, and they are only needed if a selection is
made on the page, which is not guaranteed to happen.

Reviewed by Tim Horton.

* UIProcess/ios/WKContentView.mm:
(-[WKContentView _processDidExit]):
* UIProcess/ios/WKContentViewInteraction.h:
* UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView setUpInteraction]):
(-[WKContentView _selectionChanged]):
(-[WKContentView setupAppHighlightMenus]):

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (271444 => 271445)


--- trunk/Source/WebKit/ChangeLog	2021-01-13 18:56:35 UTC (rev 271444)
+++ trunk/Source/WebKit/ChangeLog	2021-01-13 19:05:44 UTC (rev 271445)
@@ -1,3 +1,23 @@
+2021-01-13  Megan Gardner  <[email protected]>
+
+        Defer setting up app highlight menus until needed to not delay launch time.
+        https://bugs.webkit.org/show_bug.cgi?id=220577
+        rdar://72940219
+
+        Delay adding the app highlight menus to the callout bar until a selection happens,
+        as the creation of these menus is expensive, and they are only needed if a selection is
+        made on the page, which is not guaranteed to happen.
+
+        Reviewed by Tim Horton.
+
+        * UIProcess/ios/WKContentView.mm:
+        (-[WKContentView _processDidExit]):
+        * UIProcess/ios/WKContentViewInteraction.h:
+        * UIProcess/ios/WKContentViewInteraction.mm:
+        (-[WKContentView setUpInteraction]):
+        (-[WKContentView _selectionChanged]):
+        (-[WKContentView setupAppHighlightMenus]):
+
 2021-01-13  Commit Queue  <[email protected]>
 
         Unreviewed, reverting r271401.

Modified: trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h (271444 => 271445)


--- trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h	2021-01-13 18:56:35 UTC (rev 271444)
+++ trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h	2021-01-13 19:05:44 UTC (rev 271445)
@@ -440,6 +440,10 @@
     BlockPtr<void()> _actionToPerformAfterReceivingEditDragSnapshot;
 #endif
 
+#if ENABLE(APP_HIGHLIGHTS)
+    BOOL _hasSetUpAppHighlightMenus;
+#endif
+
 #if PLATFORM(WATCHOS)
     RetainPtr<WKFocusedFormControlView> _focusedFormControlView;
     RetainPtr<UIViewController> _presentedFullScreenInputViewController;

Modified: trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm (271444 => 271445)


--- trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm	2021-01-13 18:56:35 UTC (rev 271444)
+++ trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm	2021-01-13 19:05:44 UTC (rev 271445)
@@ -842,10 +842,6 @@
     [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];
@@ -6658,6 +6654,10 @@
 
 - (void)_selectionChanged
 {
+#if ENABLE(APP_HIGHLIGHTS)
+    [self setUpAppHighlightMenus];
+#endif
+
     [self _updateSelectionAssistantSuppressionState];
 
     _cachedSelectedTextRange = nil;
@@ -8684,12 +8684,16 @@
 #endif
 
 #if ENABLE(APP_HIGHLIGHTS)
-- (void)setupAppHighlightMenus
+- (void)setUpAppHighlightMenus
 {
+    if (_hasSetUpAppHighlightMenus)
+        return;
+
     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() ]];
+        _hasSetUpAppHighlightMenus = YES;
     }
 }
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to