Title: [182037] trunk/Source/WebKit2
- Revision
- 182037
- Author
- [email protected]
- Date
- 2015-03-26 16:24:02 -0700 (Thu, 26 Mar 2015)
Log Message
REGRESSION(r1807689): Slower startup time for WKWebView.
https://bugs.webkit.org/show_bug.cgi?id=143115
rdar://problem/20233711
Reviewed by Anders Carlsson.
In http://trac.webkit.org/changeset/180768 we added an observer to
track visibility of the NSFontPanel to ensure we could fetch the font
information for the current selection when the panel first becomes visible.
It turns out that adding the observer requires the shared font panel
object to be created.
That is apparently a very expensive operation that is regressing
the initialization time for the WKWebView.
We should initialize the NSFontPanel lazily, only when we make the entire
view editable.
* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView _setEditable:]):
* UIProcess/API/mac/WKView.mm:
(-[WKView addWindowObserversForWindow:]):
(-[WKView _addFontPanelObserver]):
(-[WKView removeWindowObservers]):
(-[WKView observeValueForKeyPath:ofObject:change:context:]):
* UIProcess/API/mac/WKViewInternal.h:
Modified Paths
Diff
Modified: trunk/Source/WebKit2/ChangeLog (182036 => 182037)
--- trunk/Source/WebKit2/ChangeLog 2015-03-26 23:23:57 UTC (rev 182036)
+++ trunk/Source/WebKit2/ChangeLog 2015-03-26 23:24:02 UTC (rev 182037)
@@ -1,3 +1,30 @@
+2015-03-26 Enrica Casucci <[email protected]>
+
+ REGRESSION(r1807689): Slower startup time for WKWebView.
+ https://bugs.webkit.org/show_bug.cgi?id=143115
+ rdar://problem/20233711
+
+ Reviewed by Anders Carlsson.
+
+ In http://trac.webkit.org/changeset/180768 we added an observer to
+ track visibility of the NSFontPanel to ensure we could fetch the font
+ information for the current selection when the panel first becomes visible.
+ It turns out that adding the observer requires the shared font panel
+ object to be created.
+ That is apparently a very expensive operation that is regressing
+ the initialization time for the WKWebView.
+ We should initialize the NSFontPanel lazily, only when we make the entire
+ view editable.
+
+ * UIProcess/API/Cocoa/WKWebView.mm:
+ (-[WKWebView _setEditable:]):
+ * UIProcess/API/mac/WKView.mm:
+ (-[WKView addWindowObserversForWindow:]):
+ (-[WKView _addFontPanelObserver]):
+ (-[WKView removeWindowObservers]):
+ (-[WKView observeValueForKeyPath:ofObject:change:context:]):
+ * UIProcess/API/mac/WKViewInternal.h:
+
2015-03-26 Alex Christensen <[email protected]>
Progress towards CMake on Mac.
Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm (182036 => 182037)
--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm 2015-03-26 23:23:57 UTC (rev 182036)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm 2015-03-26 23:24:02 UTC (rev 182037)
@@ -1659,6 +1659,7 @@
- (void)_setEditable:(BOOL)editable
{
_page->setEditable(editable);
+ [_wkView _addFontPanelObserver];
}
- (_WKRemoteObjectRegistry *)_remoteObjectRegistry
Modified: trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm (182036 => 182037)
--- trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm 2015-03-26 23:23:57 UTC (rev 182036)
+++ trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm 2015-03-26 23:24:02 UTC (rev 182037)
@@ -2609,10 +2609,6 @@
name:@"_NSWindowDidChangeContentsHostedInLayerSurfaceNotification" object:window];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_windowDidChangeOcclusionState:)
name:NSWindowDidChangeOcclusionStateNotification object:window];
- [[NSFontPanel sharedFontPanel] addObserver:self
- forKeyPath:@"visible"
- options:NSKeyValueObservingOptionNew
- context:nil];
#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101000
[window addObserver:self forKeyPath:@"contentLayoutRect" options:NSKeyValueObservingOptionInitial context:keyValueObservingContext];
[window addObserver:self forKeyPath:@"titlebarAppearsTransparent" options:NSKeyValueObservingOptionInitial context:keyValueObservingContext];
@@ -2621,6 +2617,11 @@
}
}
+- (void)_addFontPanelObserver
+{
+ [[NSFontPanel sharedFontPanel] addObserver:self forKeyPath:@"visible" options:0 context:keyValueObservingContext];
+}
+
- (void)removeWindowObservers
{
NSWindow *window = _data->_targetWindowForMovePreparation ? _data->_targetWindowForMovePreparation : [self window];
@@ -2637,7 +2638,8 @@
[[NSNotificationCenter defaultCenter] removeObserver:self name:NSWindowDidChangeScreenNotification object:window];
[[NSNotificationCenter defaultCenter] removeObserver:self name:@"_NSWindowDidChangeContentsHostedInLayerSurfaceNotification" object:window];
[[NSNotificationCenter defaultCenter] removeObserver:self name:NSWindowDidChangeOcclusionStateNotification object:window];
- [[NSFontPanel sharedFontPanel] removeObserver:self forKeyPath:@"visible" context:nil];
+ if (_data->_page->isEditable())
+ [[NSFontPanel sharedFontPanel] removeObserver:self forKeyPath:@"visible" context:keyValueObservingContext];
#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101000
[window removeObserver:self forKeyPath:@"contentLayoutRect" context:keyValueObservingContext];
[window removeObserver:self forKeyPath:@"titlebarAppearsTransparent" context:keyValueObservingContext];
@@ -3848,18 +3850,18 @@
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
{
- if ([NSFontPanel sharedFontPanelExists] && object == [NSFontPanel sharedFontPanel]) {
+ if (context != keyValueObservingContext) {
+ [super observeValueForKeyPath:keyPath ofObject:object change:change context:context];
+ return;
+ }
+
+ if ([keyPath isEqualToString:@"visible"] && [NSFontPanel sharedFontPanelExists] && object == [NSFontPanel sharedFontPanel]) {
[self updateFontPanelIfNeeded];
return;
}
#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101000
- if (context == keyValueObservingContext) {
- if ([keyPath isEqualToString:@"contentLayoutRect"] || [keyPath isEqualToString:@"titlebarAppearsTransparent"])
- [self _updateContentInsetsIfAutomatic];
- return;
- }
-
- [super observeValueForKeyPath:keyPath ofObject:object change:change context:context];
+ if ([keyPath isEqualToString:@"contentLayoutRect"] || [keyPath isEqualToString:@"titlebarAppearsTransparent"])
+ [self _updateContentInsetsIfAutomatic];
#endif
}
Modified: trunk/Source/WebKit2/UIProcess/API/mac/WKViewInternal.h (182036 => 182037)
--- trunk/Source/WebKit2/UIProcess/API/mac/WKViewInternal.h 2015-03-26 23:23:57 UTC (rev 182036)
+++ trunk/Source/WebKit2/UIProcess/API/mac/WKViewInternal.h 2015-03-26 23:24:02 UTC (rev 182037)
@@ -132,6 +132,7 @@
- (void)_windowDidOrderOnScreen:(NSNotification *)notification;
- (void)_windowDidOrderOffScreen:(NSNotification *)notification;
+- (void)_addFontPanelObserver;
// FullScreen
@property (readonly) BOOL _hasFullScreenWindowController;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes