Changeset 83324 in webkit
- Timestamp:
- Apr 8, 2011 12:33:04 PM (13 years ago)
- Location:
- trunk/Source/WebKit/mac
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/mac/ChangeLog
r83223 r83324 1 2011-04-08 Maciej Stachowiak <mjs@apple.com> 2 3 Reviewed by Darin Adler. 4 5 -[WebView setPreferences:] can take a lot of time if loading lots of webviews at once 6 https://bugs.webkit.org/show_bug.cgi?id=58128 7 <rdar://problem/9244553> 8 9 The root of the problem here was an O(N^2) issue - each WebView, 10 upon having its preferences initialized, would broadcast a 11 notification that was listened to by all other WebViews sharing 12 its preferences. 13 14 To maintain the API contract, I split the notification into two, 15 one that is for public API consumption, and the other which is for 16 internal use only. Changes that don't need to be picked up by 17 other WebViews broadcast the public notification only. And we 18 avoid WebView broadcasting a notification just to get itself to 19 update. 20 21 * Misc/WebIconDatabase.mm: 22 (-[WebIconDatabase _startUpIconDatabase]): 23 (-[WebIconDatabase _shutDownIconDatabase]): 24 * Plugins/WebBaseNetscapePluginView.mm: 25 (-[WebBaseNetscapePluginView viewWillMoveToWindow:]): 26 (-[WebBaseNetscapePluginView viewWillMoveToSuperview:]): 27 (-[WebBaseNetscapePluginView viewDidMoveToWindow]): 28 (-[WebBaseNetscapePluginView viewWillMoveToHostWindow:]): 29 * WebView/WebPreferences.mm: 30 (-[WebPreferences initWithIdentifier:]): 31 (-[WebPreferences _setStringValue:forKey:]): 32 (-[WebPreferences _setIntegerValue:forKey:]): 33 (-[WebPreferences _setFloatValue:forKey:]): 34 (-[WebPreferences _setBoolValue:forKey:]): 35 (-[WebPreferences _setLongLongValue:forKey:]): 36 (-[WebPreferences _setUnsignedLongLongValue:forKey:]): 37 (-[WebPreferences _postPreferencesChangedNotification]): 38 (-[WebPreferences _postPreferencesChangedAPINotification]): 39 * WebView/WebPreferencesPrivate.h: 40 * WebView/WebView.mm: 41 (-[WebView _commonInitializationWithFrameName:groupName:usesDocumentViews:]): 42 (-[WebView _preferencesChangedNotification:]): 43 (-[WebView _preferencesChanged:]): 44 (-[WebView setUsesPageCache:]): 45 (+[WebView initialize]): 46 (-[WebView setPreferences:]): 47 (-[WebView _keyboardUIMode]): 48 * WebView/WebViewInternal.h: 49 1 50 2011-04-07 Andrew Scherkus <scherkus@chromium.org> 2 51 -
trunk/Source/WebKit/mac/Misc/WebIconDatabase.mm
r81824 r83324 36 36 #import "WebNSNotificationCenterExtras.h" 37 37 #import "WebNSURLExtras.h" 38 #import "WebPreferences .h"38 #import "WebPreferencesPrivate.h" 39 39 #import "WebTypesInternal.h" 40 40 #import <WebCore/IconDatabase.h> … … 314 314 [[NSNotificationCenter defaultCenter] addObserver:self 315 315 selector:@selector(_resetCachedWebPreferences:) 316 name:WebPreferencesChanged Notification316 name:WebPreferencesChangedInternalNotification 317 317 object:nil]; 318 318 } … … 325 325 object:NSApp]; 326 326 [[NSNotificationCenter defaultCenter] removeObserver:self 327 name:WebPreferencesChanged Notification327 name:WebPreferencesChangedInternalNotification 328 328 object:nil]; 329 329 } -
trunk/Source/WebKit/mac/Plugins/WebBaseNetscapePluginView.mm
r82723 r83324 620 620 [self stop]; 621 621 622 // Stop observing WebPreferencesChanged Notification -- we only need to observe this when installed in the view hierarchy.622 // Stop observing WebPreferencesChangedInternalNotification -- we only need to observe this when installed in the view hierarchy. 623 623 // When not in the view hierarchy, -viewWillMoveToWindow: and -viewDidMoveToWindow will start/stop the plugin as needed. 624 [[NSNotificationCenter defaultCenter] removeObserver:self name:WebPreferencesChanged Notification object:nil];624 [[NSNotificationCenter defaultCenter] removeObserver:self name:WebPreferencesChangedInternalNotification object:nil]; 625 625 } 626 626 } … … 635 635 [self stop]; 636 636 637 // Stop observing WebPreferencesChanged Notification -- we only need to observe this when installed in the view hierarchy.637 // Stop observing WebPreferencesChangedInternalNotification -- we only need to observe this when installed in the view hierarchy. 638 638 // When not in the view hierarchy, -viewWillMoveToWindow: and -viewDidMoveToWindow will start/stop the plugin as needed. 639 [[NSNotificationCenter defaultCenter] removeObserver:self name:WebPreferencesChanged Notification object:nil];639 [[NSNotificationCenter defaultCenter] removeObserver:self name:WebPreferencesChangedInternalNotification object:nil]; 640 640 } 641 641 } … … 646 646 647 647 if ([self window]) { 648 // While in the view hierarchy, observe WebPreferencesChanged Notification so that we can start/stop depending648 // While in the view hierarchy, observe WebPreferencesChangedInternalNotification so that we can start/stop depending 649 649 // on whether plugins are enabled. 650 650 [[NSNotificationCenter defaultCenter] addObserver:self 651 651 selector:@selector(preferencesHaveChanged:) 652 name:WebPreferencesChanged Notification652 name:WebPreferencesChangedInternalNotification 653 653 object:nil]; 654 654 … … 678 678 [self stop]; 679 679 680 // Remove WebPreferencesChanged Notification observer -- we will observe once again when we move back into the window681 [[NSNotificationCenter defaultCenter] removeObserver:self name:WebPreferencesChanged Notification object:nil];680 // Remove WebPreferencesChangedInternalNotification observer -- we will observe once again when we move back into the window 681 [[NSNotificationCenter defaultCenter] removeObserver:self name:WebPreferencesChangedInternalNotification object:nil]; 682 682 } 683 683 } -
trunk/Source/WebKit/mac/WebView/WebPreferences.mm
r82052 r83324 43 43 NSString *WebPreferencesChangedNotification = @"WebPreferencesChangedNotification"; 44 44 NSString *WebPreferencesRemovedNotification = @"WebPreferencesRemovedNotification"; 45 NSString *WebPreferencesChangedInternalNotification = @"WebPreferencesChangedInternalNotification"; 45 46 46 47 #define KEY(x) (_private->identifier ? [_private->identifier stringByAppendingString:(x)] : (x)) … … 233 234 [[self class] _setInstance:self forIdentifier:_private->identifier]; 234 235 235 [self _postPreferencesChange sNotification];236 [self _postPreferencesChangedNotification]; 236 237 237 238 return self; … … 437 438 if (_private->autosaves) 438 439 [[NSUserDefaults standardUserDefaults] setObject:value forKey:_key]; 439 [self _postPreferencesChange sNotification];440 [self _postPreferencesChangedNotification]; 440 441 } 441 442 … … 454 455 if (_private->autosaves) 455 456 [[NSUserDefaults standardUserDefaults] setInteger:value forKey:_key]; 456 [self _postPreferencesChange sNotification];457 [self _postPreferencesChangedNotification]; 457 458 } 458 459 … … 471 472 if (_private->autosaves) 472 473 [[NSUserDefaults standardUserDefaults] setFloat:value forKey:_key]; 473 [self _postPreferencesChange sNotification];474 [self _postPreferencesChangedNotification]; 474 475 } 475 476 … … 487 488 if (_private->autosaves) 488 489 [[NSUserDefaults standardUserDefaults] setBool:value forKey:_key]; 489 [self _postPreferencesChange sNotification];490 [self _postPreferencesChangedNotification]; 490 491 } 491 492 … … 504 505 if (_private->autosaves) 505 506 [[NSUserDefaults standardUserDefaults] setObject:[NSNumber numberWithLongLong:value] forKey:_key]; 506 [self _postPreferencesChange sNotification];507 [self _postPreferencesChangedNotification]; 507 508 } 508 509 … … 521 522 if (_private->autosaves) 522 523 [[NSUserDefaults standardUserDefaults] setObject:[NSNumber numberWithUnsignedLongLong:value] forKey:_key]; 523 [self _postPreferencesChange sNotification];524 [self _postPreferencesChangedNotification]; 524 525 } 525 526 … … 1174 1175 } 1175 1176 1176 - (void)_postPreferencesChange sNotification1177 - (void)_postPreferencesChangedNotification 1177 1178 { 1178 1179 if (!pthread_main_np()) { … … 1181 1182 } 1182 1183 1183 [[NSNotificationCenter defaultCenter] 1184 postNotificationName:WebPreferencesChangedNotification object:self 1185 userInfo:nil]; 1184 [[NSNotificationCenter defaultCenter] postNotificationName:WebPreferencesChangedInternalNotification object:self userInfo:nil]; 1185 [[NSNotificationCenter defaultCenter] postNotificationName:WebPreferencesChangedNotification object:self userInfo:nil]; 1186 } 1187 1188 - (void)_postPreferencesChangedAPINotification 1189 { 1190 if (!pthread_main_np()) { 1191 [self performSelectorOnMainThread:_cmd withObject:nil waitUntilDone:NO]; 1192 return; 1193 } 1194 1195 [[NSNotificationCenter defaultCenter] postNotificationName:WebPreferencesChangedNotification object:self userInfo:nil]; 1186 1196 } 1187 1197 -
trunk/Source/WebKit/mac/WebView/WebPreferencesPrivate.h
r81635 r83324 52 52 extern NSString *WebPreferencesChangedNotification; 53 53 extern NSString *WebPreferencesRemovedNotification; 54 extern NSString *WebPreferencesChangedInternalNotification; 54 55 55 56 @interface WebPreferences (WebPrivate) … … 211 212 212 213 // Other private methods 213 - (void)_postPreferencesChangesNotification; 214 - (void)_postPreferencesChangedNotification; 215 - (void)_postPreferencesChangedAPINotification; 214 216 + (WebPreferences *)_getInstanceForIdentifier:(NSString *)identifier; 215 217 + (void)_setInstance:(WebPreferences *)instance forIdentifier:(NSString *)identifier; -
trunk/Source/WebKit/mac/WebView/WebView.mm
r83201 r83324 778 778 WebPreferences *prefs = [self preferences]; 779 779 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_preferencesChangedNotification:) 780 name:WebPreferencesChanged Notification object:prefs];781 782 // Post a notification so the WebCore settings update.783 [[self preferences] _postPreferencesChange sNotification];780 name:WebPreferencesChangedInternalNotification object:prefs]; 781 782 [self _preferencesChanged:[self preferences]]; 783 [[self preferences] _postPreferencesChangedAPINotification]; 784 784 785 785 if (!WebKitLinkedOnOrAfter(WEBKIT_FIRST_VERSION_WITH_LOCAL_RESOURCE_SECURITY_RESTRICTION)) { … … 1442 1442 { 1443 1443 WebPreferences *preferences = (WebPreferences *)[notification object]; 1444 [self _preferencesChanged:preferences]; 1445 } 1446 1447 - (void)_preferencesChanged:(WebPreferences *)preferences 1448 { 1444 1449 ASSERT(preferences == [self preferences]); 1445 1446 1450 if (!_private->userAgentOverridden) 1447 1451 _private->userAgent = String(); … … 2288 2292 _private->usesPageCache = usesPageCache; 2289 2293 2290 // Post a notification so the WebCore settings update. 2291 [[self preferences] _postPreferencesChangesNotification]; 2294 // Update our own settings and post the public notification only 2295 [self _preferencesChanged:[self preferences]]; 2296 [[self preferences] _postPreferencesChangedAPINotification]; 2292 2297 } 2293 2298 … … 2874 2879 2875 2880 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_applicationWillTerminate) name:NSApplicationWillTerminateNotification object:NSApp]; 2876 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_preferencesChangedNotification:) name:WebPreferencesChanged Notification object:nil];2881 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_preferencesChangedNotification:) name:WebPreferencesChangedInternalNotification object:nil]; 2877 2882 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_preferencesRemovedNotification:) name:WebPreferencesRemovedNotification object:nil]; 2878 2883 … … 3379 3384 WebPreferences *oldPrefs = _private->preferences; 3380 3385 3381 [[NSNotificationCenter defaultCenter] removeObserver:self name:WebPreferencesChanged Notification object:[self preferences]];3386 [[NSNotificationCenter defaultCenter] removeObserver:self name:WebPreferencesChangedInternalNotification object:[self preferences]]; 3382 3387 [WebPreferences _removeReferenceForIdentifier:[oldPrefs identifier]]; 3383 3388 … … 3386 3391 // After registering for the notification, post it so the WebCore settings update. 3387 3392 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_preferencesChangedNotification:) 3388 name:WebPreferencesChangedNotification object:[self preferences]]; 3389 [[self preferences] _postPreferencesChangesNotification]; 3393 name:WebPreferencesChangedInternalNotification object:[self preferences]]; 3394 [self _preferencesChanged:[self preferences]]; 3395 [[self preferences] _postPreferencesChangedAPINotification]; 3390 3396 3391 3397 [oldPrefs didRemoveFromWebView]; … … 5990 5996 [[NSNotificationCenter defaultCenter] 5991 5997 addObserver:self selector:@selector(_retrieveKeyboardUIModeFromPreferences:) 5992 name:WebPreferencesChanged Notification object:nil];5998 name:WebPreferencesChangedInternalNotification object:nil]; 5993 5999 } 5994 6000 return _private->_keyboardUIMode; -
trunk/Source/WebKit/mac/WebView/WebViewInternal.h
r82148 r83324 184 184 - (void)_setInsertionPasteboard:(NSPasteboard *)pasteboard; 185 185 186 - (void)_preferencesChanged:(WebPreferences *)preferences; 187 186 188 #if ENABLE(VIDEO) && defined(__cplusplus) 187 189 - (void)_enterFullscreenForNode:(WebCore::Node*)node;
Note: See TracChangeset
for help on using the changeset viewer.