Title: [237331] trunk/Source/WebKit
Revision
237331
Author
[email protected]
Date
2018-10-22 14:22:36 -0700 (Mon, 22 Oct 2018)

Log Message

Don't waste time under -setupInteraction under -initWithFrame for unparented WKWebViews
https://bugs.webkit.org/show_bug.cgi?id=190801
<rdar://problem/43674361>

Reviewed by Megan Gardner.

* UIProcess/ios/WKContentView.mm:
(-[WKContentView _commonInitializationWithProcessPool:configuration:]):
(-[WKContentView didMoveToWindow]):
Defer the first call to WKContentViewInteraction's -setupInteraction
until the view is parented. This avoids a few milliseconds of unnecessary
work for views that are never parented.

* UIProcess/ios/WKContentViewInteraction.h:
* UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView setupInteraction]):
(-[WKContentView cleanupInteraction]):
Keep track of the current state of WKContentViewInteraction's gestures.
Use this to make it OK to call -setupInteraction multiple times.

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (237330 => 237331)


--- trunk/Source/WebKit/ChangeLog	2018-10-22 21:05:20 UTC (rev 237330)
+++ trunk/Source/WebKit/ChangeLog	2018-10-22 21:22:36 UTC (rev 237331)
@@ -1,3 +1,25 @@
+2018-10-22  Tim Horton  <[email protected]>
+
+        Don't waste time under -setupInteraction under -initWithFrame for unparented WKWebViews
+        https://bugs.webkit.org/show_bug.cgi?id=190801
+        <rdar://problem/43674361>
+
+        Reviewed by Megan Gardner.
+
+        * UIProcess/ios/WKContentView.mm:
+        (-[WKContentView _commonInitializationWithProcessPool:configuration:]):
+        (-[WKContentView didMoveToWindow]):
+        Defer the first call to WKContentViewInteraction's -setupInteraction
+        until the view is parented. This avoids a few milliseconds of unnecessary
+        work for views that are never parented.
+
+        * UIProcess/ios/WKContentViewInteraction.h:
+        * UIProcess/ios/WKContentViewInteraction.mm:
+        (-[WKContentView setupInteraction]):
+        (-[WKContentView cleanupInteraction]):
+        Keep track of the current state of WKContentViewInteraction's gestures.
+        Use this to make it OK to call -setupInteraction multiple times.
+
 2018-10-22  Chris Dumez  <[email protected]>
 
         Deque's contains() and findIf() should be const

Modified: trunk/Source/WebKit/UIProcess/ios/WKContentView.mm (237330 => 237331)


--- trunk/Source/WebKit/UIProcess/ios/WKContentView.mm	2018-10-22 21:05:20 UTC (rev 237330)
+++ trunk/Source/WebKit/UIProcess/ios/WKContentView.mm	2018-10-22 21:22:36 UTC (rev 237331)
@@ -218,7 +218,6 @@
     [self addSubview:_fixedClippingView.get()];
     [_fixedClippingView addSubview:_rootContentView.get()];
 
-    [self setupInteraction];
     [self setUserInteractionEnabled:YES];
 
     self.layer.hitTestsAsOpaque = YES;
@@ -277,6 +276,14 @@
     }
 }
 
+- (void)didMoveToWindow
+{
+    [super didMoveToWindow];
+
+    if (self.window)
+        [self setupInteraction];
+}
+
 ALLOW_DEPRECATED_DECLARATIONS_BEGIN
 - (WKBrowsingContextController *)browsingContextController
 {

Modified: trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h (237330 => 237331)


--- trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h	2018-10-22 21:05:20 UTC (rev 237330)
+++ trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h	2018-10-22 21:22:36 UTC (rev 237331)
@@ -277,6 +277,8 @@
 
     BOOL _focusRequiresStrongPasswordAssistance;
 
+    BOOL _hasSetUpInteractions;
+
 #if ENABLE(DATA_INTERACTION)
     WebKit::DragDropInteractionState _dragDropInteractionState;
     RetainPtr<UIDragInteraction> _dragInteraction;

Modified: trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm (237330 => 237331)


--- trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm	2018-10-22 21:05:20 UTC (rev 237330)
+++ trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm	2018-10-22 21:22:36 UTC (rev 237331)
@@ -625,6 +625,9 @@
 
 - (void)setupInteraction
 {
+    if (_hasSetUpInteractions)
+        return;
+
     if (!_interactionViewsContainerView) {
         _interactionViewsContainerView = adoptNS([[UIView alloc] init]);
         [_interactionViewsContainerView layer].name = @"InteractionViewsContainer";
@@ -713,10 +716,15 @@
     _dataListTextSuggestionsInputView = nil;
     _dataListTextSuggestions = nil;
 #endif
+
+    _hasSetUpInteractions = YES;
 }
 
 - (void)cleanupInteraction
 {
+    if (!_hasSetUpInteractions)
+        return;
+
     _webSelectionAssistant = nil;
     _textSelectionAssistant = nil;
     
@@ -813,6 +821,8 @@
     _dataListTextSuggestionsInputView = nil;
     _dataListTextSuggestions = nil;
 #endif
+
+    _hasSetUpInteractions = NO;
 }
 
 - (void)_removeDefaultGestureRecognizers
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to