Stop unnecessarily copying WKWebViewConfiguration in a few places
authortimothy_horton@apple.com <timothy_horton@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 28 Nov 2015 21:30:06 +0000 (21:30 +0000)
committertimothy_horton@apple.com <timothy_horton@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 28 Nov 2015 21:30:06 +0000 (21:30 +0000)
https://bugs.webkit.org/show_bug.cgi?id=151639

Reviewed by Dan Bernstein.

* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView initWithFrame:configuration:]):
(-[WKWebView dealloc]):
(-[WKWebView _contentProviderRegistry]):
(-[WKWebView _selectionGranularity]):
(-[WKWebView _setHasCustomContentView:loadedMIMEType:]):
* UIProcess/API/Cocoa/WKWebViewInternal.h:
* UIProcess/ios/PageClientImplIOS.mm:
(WebKit::PageClientImpl::mimeTypesWithCustomContentProviders):
* UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView setupInteraction]):
(-[WKContentView _stopAssistingKeyboard]):
Looking at allocation traces I noticed that we were making way more
WKWebViewConfigurations than made sense; looking at backtraces I found
a few internal callers of -[WKWebView configuration], which copies the
configuration. There's no reason for these internal callers to make
such a copy, though.

I'm not exactly sure what the usual approach is here, but I added
getters so WKContentViewInteraction and PageClientImplIOS can get to
the values they're looking for without using the configuration property.

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

Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm
Source/WebKit2/UIProcess/API/Cocoa/WKWebViewInternal.h
Source/WebKit2/UIProcess/ios/PageClientImplIOS.mm
Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm

index cf71445..28e773d 100644 (file)
@@ -1,3 +1,32 @@
+2015-11-28  Tim Horton  <timothy_horton@apple.com>
+
+        Stop unnecessarily copying WKWebViewConfiguration in a few places
+        https://bugs.webkit.org/show_bug.cgi?id=151639
+
+        Reviewed by Dan Bernstein.
+
+        * UIProcess/API/Cocoa/WKWebView.mm:
+        (-[WKWebView initWithFrame:configuration:]):
+        (-[WKWebView dealloc]):
+        (-[WKWebView _contentProviderRegistry]):
+        (-[WKWebView _selectionGranularity]):
+        (-[WKWebView _setHasCustomContentView:loadedMIMEType:]):
+        * UIProcess/API/Cocoa/WKWebViewInternal.h:
+        * UIProcess/ios/PageClientImplIOS.mm:
+        (WebKit::PageClientImpl::mimeTypesWithCustomContentProviders):
+        * UIProcess/ios/WKContentViewInteraction.mm:
+        (-[WKContentView setupInteraction]):
+        (-[WKContentView _stopAssistingKeyboard]):
+        Looking at allocation traces I noticed that we were making way more
+        WKWebViewConfigurations than made sense; looking at backtraces I found
+        a few internal callers of -[WKWebView configuration], which copies the
+        configuration. There's no reason for these internal callers to make 
+        such a copy, though.
+
+        I'm not exactly sure what the usual approach is here, but I added
+        getters so WKContentViewInteraction and PageClientImplIOS can get to
+        the values they're looking for without using the configuration property.
+
 2015-11-27  Brady Eidson  <beidson@apple.com>
 
         Modern IDB: Class-ify IDBGetResult making it impossible to get the data members wrong.
index c0bd1c0..dffc5c9 100644 (file)
@@ -805,6 +805,16 @@ static CGSize roundScrollViewContentSize(const WebKit::WebPageProxy& page, CGSiz
     return _customContentView ? _customContentView.get() : _contentView.get();
 }
 
+- (WKWebViewContentProviderRegistry *)_contentProviderRegistry
+{
+    return [_configuration _contentProviderRegistry];
+}
+
+- (WKSelectionGranularity)_selectionGranularity
+{
+    return [_configuration selectionGranularity];
+}
+
 - (void)_setHasCustomContentView:(BOOL)pageHasCustomContentView loadedMIMEType:(const WTF::String&)mimeType
 {
     if (pageHasCustomContentView) {
index 9507dc9..afa398c 100644 (file)
@@ -28,6 +28,7 @@
 #if WK_API_ENABLED
 
 #import "SameDocumentNavigationType.h"
+#import "WKWebViewConfiguration.h"
 #import <wtf/RefPtr.h>
 #import <wtf/RetainPtr.h>
 
@@ -54,6 +55,7 @@ class WebPageProxy;
 struct PrintInfo;
 }
 
+@class WKWebViewContentProviderRegistry;
 @class _WKFrameHandle;
 
 @interface WKWebView () WK_WEB_VIEW_PROTOCOLS {
@@ -109,6 +111,10 @@ struct PrintInfo;
 - (void)_navigationGestureDidBegin;
 - (void)_navigationGestureDidEnd;
 
+@property (nonatomic, readonly) WKWebViewContentProviderRegistry *_contentProviderRegistry;
+
+@property (nonatomic, readonly) WKSelectionGranularity _selectionGranularity;
+
 @property (nonatomic, readonly) BOOL _allowsDoubleTapGestures;
 @property (nonatomic, readonly) UIEdgeInsets _computedContentInset;
 #endif
index 53ff5f3..7fbf527 100644 (file)
@@ -681,7 +681,7 @@ void PageClientImpl::didFinishDrawingPagesToPDF(const IPC::DataReference& pdfDat
 
 Vector<String> PageClientImpl::mimeTypesWithCustomContentProviders()
 {
-    return m_webView.configuration._contentProviderRegistry._mimeTypesWithCustomContentProviders;
+    return m_webView._contentProviderRegistry._mimeTypesWithCustomContentProviders;
 }
 
 void PageClientImpl::navigationGestureDidBegin()
index 9ad0917..b1d9840 100644 (file)
@@ -484,7 +484,7 @@ static UIWebSelectionMode toUIWebSelectionMode(WKSelectionGranularity granularit
     _showingTextStyleOptions = NO;
 
     // FIXME: This should be called when we get notified that loading has completed.
-    [self useSelectionAssistantWithMode:toUIWebSelectionMode([[_webView configuration] selectionGranularity])];
+    [self useSelectionAssistantWithMode:toUIWebSelectionMode([_webView _selectionGranularity])];
     
     _actionSheetAssistant = adoptNS([[WKActionSheetAssistant alloc] initWithView:self]);
     [_actionSheetAssistant setDelegate:self];
@@ -3179,7 +3179,7 @@ static UITextAutocapitalizationType toUITextAutocapitalize(WebAutocapitalizeType
 
 - (void)_stopAssistingKeyboard
 {
-    [self useSelectionAssistantWithMode:toUIWebSelectionMode([[_webView configuration] selectionGranularity])];
+    [self useSelectionAssistantWithMode:toUIWebSelectionMode([_webView _selectionGranularity])];
 }
 
 - (const AssistedNodeInformation&)assistedNodeInformation