[SCM] WebKit Debian packaging branch, debian/unstable, updated. debian/1.1.15-1-40151-g37bb677

darin darin at 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Sat Sep 26 07:14:16 UTC 2009


The following commit has been merged in the debian/unstable branch:
commit 8636c6f1b7e1a7cf17db000eb48f25ce465f69ce
Author: darin <darin at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Thu Dec 12 10:56:27 2002 +0000

    WebFoundation:
    
            Reviewed by Maciej.
    
    	- fixed most likely cause of 3125565 -- 2% regression running the PLT for uncached loads
    
            * Misc.subproj/WebNSUserDefaultsExtras.m:
            (+[NSUserDefaults _web_defaultsDidChange]): Added. Clears out cache when defaults change.
            (+[NSUserDefaults _web_addDefaultsChangeObserver]): Added. Sets up the above to run at the right time.
            (+[NSUserDefaults _web_acceptLanguageHeaderForPreferredLanguages]): Changed to cache the result in a
    	global and regenerate it when the global is cleared.
            (+[NSUserDefaults _web_preferredLanguageCode]): Ditto.
    
    WebKit:
    
            Reviewed by Maciej.
    
            - fixed most likely cause of 3125565 -- 2% regression running the PLT for uncached loads
    
            Don't recompute the user agent when it doesn't change. It almost never changes.
    
            * WebView.subproj/WebController.m:
            (-[WebController initWithView:controllerSetName:]): Add observer so we know when defaults change.
            (-[WebController dealloc]): Remove observer.
            (-[WebController setApplicationNameForUserAgent:]): Clear out computed user agent to force it
    	to be recomputed later.
            (-[WebController applicationNameForUserAgent]): Just retain since we copied when we stored it
    	so we know it's not mutable.
            (-[WebController customUserAgent]): Ditto.
            (-[WebController userAgentForURL:]): Use the cached user agent if it's good. Otherwise compute
    	and cache the user agent string. This means that we will almost never recompute it.
    
            * WebView.subproj/WebControllerPrivate.h: Add userAgent field to cache in.
            * WebView.subproj/WebControllerPrivate.m:
            (-[WebControllerPrivate dealloc]): Release userAgent.
            (-[WebController _defaultsDidChange]): Release and nil userAgent.
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@3019 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebKit/ChangeLog b/WebKit/ChangeLog
index 4542d65..207d1b2 100644
--- a/WebKit/ChangeLog
+++ b/WebKit/ChangeLog
@@ -2,6 +2,30 @@
 
         Reviewed by Maciej.
 
+        - fixed most likely cause of 3125565 -- 2% regression running the PLT for uncached loads
+        
+        Don't recompute the user agent when it doesn't change. It almost never changes.
+
+        * WebView.subproj/WebController.m:
+        (-[WebController initWithView:controllerSetName:]): Add observer so we know when defaults change.
+        (-[WebController dealloc]): Remove observer.
+        (-[WebController setApplicationNameForUserAgent:]): Clear out computed user agent to force it
+	to be recomputed later.
+        (-[WebController applicationNameForUserAgent]): Just retain since we copied when we stored it
+	so we know it's not mutable.
+        (-[WebController customUserAgent]): Ditto.
+        (-[WebController userAgentForURL:]): Use the cached user agent if it's good. Otherwise compute
+	and cache the user agent string. This means that we will almost never recompute it.
+
+        * WebView.subproj/WebControllerPrivate.h: Add userAgent field to cache in.
+        * WebView.subproj/WebControllerPrivate.m:
+        (-[WebControllerPrivate dealloc]): Release userAgent.
+        (-[WebController _defaultsDidChange]): Release and nil userAgent.
+
+2002-12-12  Darin Adler  <darin at apple.com>
+
+        Reviewed by Maciej.
+
 	- fixed 3125504 -- REGRESSION: Selection not working correctly for text area on http://glish.com/css/7.asp
 
 	The problem is that the text area lost its first responder status because WebHTMLView took the click,
diff --git a/WebKit/WebView.subproj/WebController.m b/WebKit/WebView.subproj/WebController.m
index 2d54c6d..fc275e0 100644
--- a/WebKit/WebView.subproj/WebController.m
+++ b/WebKit/WebView.subproj/WebController.m
@@ -62,6 +62,11 @@ NSString *WebElementStringKey = 		@"WebElementString";
 
     [self setUsesBackForwardList: YES];
     
+    [[NSNotificationCenter defaultCenter] addObserver:self
+                                             selector:@selector(_defaultsDidChange)
+                                                 name:NSUserDefaultsDidChangeNotification
+                                               object:[NSUserDefaults standardUserDefaults]];
+    
     ++WebControllerCount;
 
     return self;
@@ -75,6 +80,8 @@ NSString *WebElementStringKey = 		@"WebElementString";
 
     --WebControllerCount;
     
+    [[NSNotificationCenter defaultCenter] removeObserver:self];
+    
     [_private release];
     [super dealloc];
 }
@@ -307,11 +314,13 @@ NSString *WebElementStringKey = 		@"WebElementString";
     NSString *name = [applicationName copy];
     [_private->applicationNameForUserAgent release];
     _private->applicationNameForUserAgent = name;
+    [_private->userAgent release];
+    _private->userAgent = nil;
 }
 
 - (NSString *)applicationNameForUserAgent
 {
-    return [[_private->applicationNameForUserAgent copy] autorelease];
+    return [[_private->applicationNameForUserAgent retain] autorelease];
 }
 
 - (void)setCustomUserAgent:(NSString *)userAgentString
@@ -340,15 +349,17 @@ NSString *WebElementStringKey = 		@"WebElementString";
         ERROR("must not ask for customUserAgent is hasCustomUserAgent is NO");
     }
 
-    return [[_private->userAgentOverride copy] autorelease];
+    return [[_private->userAgentOverride retain] autorelease];
 }
 
 // Get the appropriate user-agent string for a particular URL.
 - (NSString *)userAgentForURL:(NSURL *)URL
 {
-    NSString *result = [[_private->userAgentOverride copy] autorelease];
-    if (result) {
-        return result;
+    if (_private->userAgentOverride) {
+        return [[_private->userAgentOverride retain] autorelease];
+    }
+    if (_private->userAgent) {
+        return [[_private->userAgent retain] autorelease];
     }
 
     // Note that we currently don't look at the URL.
@@ -362,12 +373,17 @@ NSString *WebElementStringKey = 		@"WebElementString";
         objectForInfoDictionaryKey:(id)kCFBundleVersionKey];
     NSString *applicationName = _private->applicationNameForUserAgent;
 
+    NSString *userAgent;
     if ([applicationName length]) {
-        return [NSString stringWithFormat:@"Mozilla/5.0 (Macintosh; U; PPC; %@) WebKit/%@ %@",
+        userAgent = [NSString stringWithFormat:@"Mozilla/5.0 (Macintosh; U; PPC; %@) WebKit/%@ %@",
             language, sourceVersion, applicationName];
+    } else {
+        userAgent = [NSString stringWithFormat:@"Mozilla/5.0 (Macintosh; U; PPC; %@) WebKit/%@",
+            language, sourceVersion];
     }
-    return [NSString stringWithFormat:@"Mozilla/5.0 (Macintosh; U; PPC; %@) WebKit/%@",
-        language, sourceVersion];
+    
+    _private->userAgent = [userAgent retain];
+    return userAgent;
 }
 
 - (BOOL)supportsTextEncoding
@@ -464,5 +480,4 @@ NSString *WebElementStringKey = 		@"WebElementString";
 {
 }
 
-
 @end
diff --git a/WebKit/WebView.subproj/WebControllerPrivate.h b/WebKit/WebView.subproj/WebControllerPrivate.h
index 633a8fe..d91d09b 100644
--- a/WebKit/WebView.subproj/WebControllerPrivate.h
+++ b/WebKit/WebView.subproj/WebControllerPrivate.h
@@ -30,6 +30,7 @@
 
     NSString *applicationNameForUserAgent;
     NSString *userAgentOverride;
+    NSString *userAgent;
     
     BOOL defersCallbacks;
 
diff --git a/WebKit/WebView.subproj/WebControllerPrivate.m b/WebKit/WebView.subproj/WebControllerPrivate.m
index f9c5c14..c71ba95 100644
--- a/WebKit/WebView.subproj/WebControllerPrivate.m
+++ b/WebKit/WebView.subproj/WebControllerPrivate.m
@@ -64,6 +64,7 @@
     [backForwardList release];
     [applicationNameForUserAgent release];
     [userAgentOverride release];
+    [userAgent release];
     
     [controllerSetName release];
     [topLevelFrameName release];
@@ -330,4 +331,10 @@
     _private->lastElementWasNonNil = dictionary != nil;
 }
 
+- (void)_defaultsDidChange
+{
+    [_private->userAgent release];
+    _private->userAgent = nil;
+}
+
 @end
diff --git a/WebKit/WebView.subproj/WebView.m b/WebKit/WebView.subproj/WebView.m
index 2d54c6d..fc275e0 100644
--- a/WebKit/WebView.subproj/WebView.m
+++ b/WebKit/WebView.subproj/WebView.m
@@ -62,6 +62,11 @@ NSString *WebElementStringKey = 		@"WebElementString";
 
     [self setUsesBackForwardList: YES];
     
+    [[NSNotificationCenter defaultCenter] addObserver:self
+                                             selector:@selector(_defaultsDidChange)
+                                                 name:NSUserDefaultsDidChangeNotification
+                                               object:[NSUserDefaults standardUserDefaults]];
+    
     ++WebControllerCount;
 
     return self;
@@ -75,6 +80,8 @@ NSString *WebElementStringKey = 		@"WebElementString";
 
     --WebControllerCount;
     
+    [[NSNotificationCenter defaultCenter] removeObserver:self];
+    
     [_private release];
     [super dealloc];
 }
@@ -307,11 +314,13 @@ NSString *WebElementStringKey = 		@"WebElementString";
     NSString *name = [applicationName copy];
     [_private->applicationNameForUserAgent release];
     _private->applicationNameForUserAgent = name;
+    [_private->userAgent release];
+    _private->userAgent = nil;
 }
 
 - (NSString *)applicationNameForUserAgent
 {
-    return [[_private->applicationNameForUserAgent copy] autorelease];
+    return [[_private->applicationNameForUserAgent retain] autorelease];
 }
 
 - (void)setCustomUserAgent:(NSString *)userAgentString
@@ -340,15 +349,17 @@ NSString *WebElementStringKey = 		@"WebElementString";
         ERROR("must not ask for customUserAgent is hasCustomUserAgent is NO");
     }
 
-    return [[_private->userAgentOverride copy] autorelease];
+    return [[_private->userAgentOverride retain] autorelease];
 }
 
 // Get the appropriate user-agent string for a particular URL.
 - (NSString *)userAgentForURL:(NSURL *)URL
 {
-    NSString *result = [[_private->userAgentOverride copy] autorelease];
-    if (result) {
-        return result;
+    if (_private->userAgentOverride) {
+        return [[_private->userAgentOverride retain] autorelease];
+    }
+    if (_private->userAgent) {
+        return [[_private->userAgent retain] autorelease];
     }
 
     // Note that we currently don't look at the URL.
@@ -362,12 +373,17 @@ NSString *WebElementStringKey = 		@"WebElementString";
         objectForInfoDictionaryKey:(id)kCFBundleVersionKey];
     NSString *applicationName = _private->applicationNameForUserAgent;
 
+    NSString *userAgent;
     if ([applicationName length]) {
-        return [NSString stringWithFormat:@"Mozilla/5.0 (Macintosh; U; PPC; %@) WebKit/%@ %@",
+        userAgent = [NSString stringWithFormat:@"Mozilla/5.0 (Macintosh; U; PPC; %@) WebKit/%@ %@",
             language, sourceVersion, applicationName];
+    } else {
+        userAgent = [NSString stringWithFormat:@"Mozilla/5.0 (Macintosh; U; PPC; %@) WebKit/%@",
+            language, sourceVersion];
     }
-    return [NSString stringWithFormat:@"Mozilla/5.0 (Macintosh; U; PPC; %@) WebKit/%@",
-        language, sourceVersion];
+    
+    _private->userAgent = [userAgent retain];
+    return userAgent;
 }
 
 - (BOOL)supportsTextEncoding
@@ -464,5 +480,4 @@ NSString *WebElementStringKey = 		@"WebElementString";
 {
 }
 
-
 @end
diff --git a/WebKit/WebView.subproj/WebViewPrivate.h b/WebKit/WebView.subproj/WebViewPrivate.h
index 633a8fe..d91d09b 100644
--- a/WebKit/WebView.subproj/WebViewPrivate.h
+++ b/WebKit/WebView.subproj/WebViewPrivate.h
@@ -30,6 +30,7 @@
 
     NSString *applicationNameForUserAgent;
     NSString *userAgentOverride;
+    NSString *userAgent;
     
     BOOL defersCallbacks;
 
diff --git a/WebKit/WebView.subproj/WebViewPrivate.m b/WebKit/WebView.subproj/WebViewPrivate.m
index f9c5c14..c71ba95 100644
--- a/WebKit/WebView.subproj/WebViewPrivate.m
+++ b/WebKit/WebView.subproj/WebViewPrivate.m
@@ -64,6 +64,7 @@
     [backForwardList release];
     [applicationNameForUserAgent release];
     [userAgentOverride release];
+    [userAgent release];
     
     [controllerSetName release];
     [topLevelFrameName release];
@@ -330,4 +331,10 @@
     _private->lastElementWasNonNil = dictionary != nil;
 }
 
+- (void)_defaultsDidChange
+{
+    [_private->userAgent release];
+    _private->userAgent = nil;
+}
+
 @end

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list