[SCM] WebKit Debian packaging branch, webkit-1.1, updated. upstream/1.1.21-584-g1e41756

timothy at apple.com timothy at apple.com
Fri Feb 26 22:23:14 UTC 2010


The following commit has been merged in the webkit-1.1 branch:
commit 80605d065c3291626d8587531a95581da56b942d
Author: timothy at apple.com <timothy at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Wed Feb 17 21:45:14 2010 +0000

    Add a way for WebView and its dependancies to be selectively included
    in WebKitStatistics leak tracking. By default WebView is not included and
    you need to subclass WebView and implement +isIncludedInWebKitStatistics
    to be included.
    
    rdar://problem/7567677&7572900
    https://webkit.org/b/35045
    
    Reviewed by Adam Roben.
    
    * WebView/WebDataSource.mm:
    (-[WebDataSource _initWithDocumentLoader:]): Increment WebDataSourceCount if the WebFrame is included in statistics.
    (-[WebDataSource dealloc]): Only --WebDataSourceCount if _private->includedInWebKitStatistics is YES.
    (-[WebDataSource finalize]): Ditto.
    * WebView/WebFrame.mm:
    (-[WebFrame _isIncludedInWebKitStatistics]): Return _private->includedInWebKitStatistics.
    (-[WebFrame _initWithWebFrameView:webView:]): Increment WebFrameCount if the WebView's class is included in statistics.
    (-[WebFrame dealloc]): Only --WebFrameCount if _private->includedInWebKitStatistics is YES.
    (-[WebFrame finalize]): Ditto.
    * WebView/WebFrameInternal.h:
    * WebView/WebFrameView.mm:
    (-[WebFrameView _setWebFrame:]): Increment WebFrameViewCount if the WebFrame is included in statistics.
    (-[WebFrameView initWithFrame:]): Move ++WebFrameViewCount from here since we don't
    know what WebFrame we belong to yet.
    (-[WebFrameView dealloc]): Only --WebFrameViewCount if _private->includedInWebKitStatistics is YES.
    (-[WebFrameView finalize]): Ditto.
    * WebView/WebHTMLRepresentation.mm:
    (-[WebHTMLRepresentation init]): Move ++WebHTMLRepresentationCount from here since we don't
    know what WebFrame we belong to yet.
    (-[WebHTMLRepresentation dealloc]): Only --WebHTMLRepresentationCount if _private->includedInWebKitStatistics is YES.
    (-[WebHTMLRepresentation finalize]): Ditto.
    (-[WebHTMLRepresentation setDataSource:]): Increment WebHTMLRepresentationCount if the WebFrame of the dataSource is
    included in statistics.
    * WebView/WebView.mm:
    (-[WebView _commonInitializationWithFrameName:groupName:usesDocumentViews:]):
    (-[WebView dealloc]):
    (+[WebView shouldIncludeInWebKitStatistics]): Return NO, so any WebView wont be included.
    Subclasses that care can return YES to be included.
    * WebView/WebViewInternal.h:
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@54908 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebKit/mac/ChangeLog b/WebKit/mac/ChangeLog
index 990b801..e77f5c2 100644
--- a/WebKit/mac/ChangeLog
+++ b/WebKit/mac/ChangeLog
@@ -1,3 +1,45 @@
+2010-02-17  Timothy Hatcher  <timothy at apple.com>
+
+        Add a way for WebView and its dependancies to be selectively included
+        in WebKitStatistics leak tracking. By default WebView is not included and
+        you need to subclass WebView and implement +isIncludedInWebKitStatistics
+        to be included.
+
+        rdar://problem/7567677&7572900
+        https://webkit.org/b/35045
+
+        Reviewed by Adam Roben.
+
+        * WebView/WebDataSource.mm:
+        (-[WebDataSource _initWithDocumentLoader:]): Increment WebDataSourceCount if the WebFrame is included in statistics.
+        (-[WebDataSource dealloc]): Only --WebDataSourceCount if _private->includedInWebKitStatistics is YES.
+        (-[WebDataSource finalize]): Ditto.
+        * WebView/WebFrame.mm:
+        (-[WebFrame _isIncludedInWebKitStatistics]): Return _private->includedInWebKitStatistics.
+        (-[WebFrame _initWithWebFrameView:webView:]): Increment WebFrameCount if the WebView's class is included in statistics.
+        (-[WebFrame dealloc]): Only --WebFrameCount if _private->includedInWebKitStatistics is YES.
+        (-[WebFrame finalize]): Ditto.
+        * WebView/WebFrameInternal.h:
+        * WebView/WebFrameView.mm:
+        (-[WebFrameView _setWebFrame:]): Increment WebFrameViewCount if the WebFrame is included in statistics.
+        (-[WebFrameView initWithFrame:]): Move ++WebFrameViewCount from here since we don't
+        know what WebFrame we belong to yet.
+        (-[WebFrameView dealloc]): Only --WebFrameViewCount if _private->includedInWebKitStatistics is YES.
+        (-[WebFrameView finalize]): Ditto.
+        * WebView/WebHTMLRepresentation.mm:
+        (-[WebHTMLRepresentation init]): Move ++WebHTMLRepresentationCount from here since we don't
+        know what WebFrame we belong to yet.
+        (-[WebHTMLRepresentation dealloc]): Only --WebHTMLRepresentationCount if _private->includedInWebKitStatistics is YES.
+        (-[WebHTMLRepresentation finalize]): Ditto.
+        (-[WebHTMLRepresentation setDataSource:]): Increment WebHTMLRepresentationCount if the WebFrame of the dataSource is
+        included in statistics.
+        * WebView/WebView.mm:
+        (-[WebView _commonInitializationWithFrameName:groupName:usesDocumentViews:]):
+        (-[WebView dealloc]):
+        (+[WebView shouldIncludeInWebKitStatistics]): Return NO, so any WebView wont be included.
+        Subclasses that care can return YES to be included.
+        * WebView/WebViewInternal.h:
+
 2010-02-16  Darin Adler  <darin at apple.com>
 
         Reviewed by Sam Weinig.
diff --git a/WebKit/mac/Misc/WebKitStatistics.h b/WebKit/mac/Misc/WebKitStatistics.h
index 32241b5..040a40b 100644
--- a/WebKit/mac/Misc/WebKitStatistics.h
+++ b/WebKit/mac/Misc/WebKitStatistics.h
@@ -28,6 +28,9 @@
 
 #import <Foundation/Foundation.h>
 
+// These values are only incremented and decremented if the WebView is subclassed and
+// +[WebView shouldIncludeInWebKitStatistics] returns YES. By default WebView returns NO.
+
 @interface WebKitStatistics : NSObject
 
 + (int)webViewCount;
diff --git a/WebKit/mac/WebView/WebDataSource.mm b/WebKit/mac/WebView/WebDataSource.mm
index 8a3842e..d9622b3 100644
--- a/WebKit/mac/WebView/WebDataSource.mm
+++ b/WebKit/mac/WebView/WebDataSource.mm
@@ -70,6 +70,7 @@ using namespace WebCore;
     id <WebDocumentRepresentation> representation;
     
     BOOL representationFinishedLoading;
+    BOOL includedInWebKitStatistics;
 }
 @end
 
@@ -372,10 +373,11 @@ static inline void addTypesFromClass(NSMutableDictionary *allTypes, Class objCCl
     _private->loader = loader.releaseRef();
         
     LOG(Loading, "creating datasource for %@", static_cast<NSURL *>(_private->loader->request().url()));
-    
-    ++WebDataSourceCount;
-    
-    return self;    
+
+    if ((_private->includedInWebKitStatistics = [[self webFrame] _isIncludedInWebKitStatistics]))
+        ++WebDataSourceCount;
+
+    return self;
 }
 
 @end
@@ -389,16 +391,18 @@ static inline void addTypesFromClass(NSMutableDictionary *allTypes, Class objCCl
 
 - (void)dealloc
 {
-    --WebDataSourceCount;
-    
+    if (_private && _private->includedInWebKitStatistics)
+        --WebDataSourceCount;
+
     [_private release];
-    
+
     [super dealloc];
 }
 
 - (void)finalize
 {
-    --WebDataSourceCount;
+    if (_private && _private->includedInWebKitStatistics)
+        --WebDataSourceCount;
 
     [super finalize];
 }
diff --git a/WebKit/mac/WebView/WebFrame.mm b/WebKit/mac/WebView/WebFrame.mm
index 41d7e01..b0e4d83 100644
--- a/WebKit/mac/WebView/WebFrame.mm
+++ b/WebKit/mac/WebView/WebFrame.mm
@@ -269,6 +269,11 @@ WebView *getWebView(WebFrame *webFrame)
     return [self _createFrameWithPage:ownerElement->document()->frame()->page() frameName:name frameView:frameView ownerElement:ownerElement];
 }
 
+- (BOOL)_isIncludedInWebKitStatistics
+{
+    return _private && _private->includedInWebKitStatistics;
+}
+
 - (void)_attachScriptDebugger
 {
     ScriptController* scriptController = _private->coreFrame->script();
@@ -308,6 +313,11 @@ WebView *getWebView(WebFrame *webFrame)
 
     _private = [[WebFramePrivate alloc] init];
 
+    // Set includedInWebKitStatistics before calling WebFrameView _setWebFrame, since
+    // it calls WebFrame _isIncludedInWebKitStatistics.
+    if ((_private->includedInWebKitStatistics = [[v class] shouldIncludeInWebKitStatistics]))
+        ++WebFrameCount;
+
     if (fv) {
         [_private setWebFrameView:fv];
         [fv _setWebFrame:self];
@@ -315,8 +325,6 @@ WebView *getWebView(WebFrame *webFrame)
 
     _private->shouldCreateRenderers = YES;
 
-    ++WebFrameCount;
-
     return self;
 }
 
@@ -1276,14 +1284,19 @@ static inline WebDataSource *dataSource(DocumentLoader* loader)
 
 - (void)dealloc
 {
+    if (_private && _private->includedInWebKitStatistics)
+        --WebFrameCount;
+
     [_private release];
-    --WebFrameCount;
+
     [super dealloc];
 }
 
 - (void)finalize
 {
-    --WebFrameCount;
+    if (_private && _private->includedInWebKitStatistics)
+        --WebFrameCount;
+
     [super finalize];
 }
 
diff --git a/WebKit/mac/WebView/WebFrameInternal.h b/WebKit/mac/WebView/WebFrameInternal.h
index 0dcf19b..4c1ee40 100644
--- a/WebKit/mac/WebView/WebFrameInternal.h
+++ b/WebKit/mac/WebView/WebFrameInternal.h
@@ -81,6 +81,7 @@ WebView *getWebView(WebFrame *webFrame);
     WebScriptDebugger* scriptDebugger;
     id internalLoadDelegate;
     BOOL shouldCreateRenderers;
+    BOOL includedInWebKitStatistics;
 }
 @end
 
@@ -96,6 +97,8 @@ WebView *getWebView(WebFrame *webFrame);
 
 - (void)_clearCoreFrame;
 
+- (BOOL)_isIncludedInWebKitStatistics;
+
 - (void)_updateBackgroundAndUpdatesWhileOffscreen;
 - (void)_setInternalLoadDelegate:(id)internalLoadDelegate;
 - (id)_internalLoadDelegate;
diff --git a/WebKit/mac/WebView/WebFrameView.mm b/WebKit/mac/WebView/WebFrameView.mm
index b6b1941..422b605 100644
--- a/WebKit/mac/WebView/WebFrameView.mm
+++ b/WebKit/mac/WebView/WebFrameView.mm
@@ -92,6 +92,7 @@ enum {
 @public
     WebFrame *webFrame;
     WebDynamicScrollBarsView *frameScrollView;
+    BOOL includedInWebKitStatistics;
 }
 @end
 
@@ -187,6 +188,11 @@ enum {
 
     // Not retained because the WebView owns the WebFrame, which owns the WebFrameView.
     _private->webFrame = webFrame;    
+
+    if (!_private->includedInWebKitStatistics && [webFrame _isIncludedInWebKitStatistics]) {
+        _private->includedInWebKitStatistics = YES;
+        ++WebFrameViewCount;
+    }
 }
 
 - (WebDynamicScrollBarsView *)_scrollView
@@ -286,15 +292,7 @@ static inline void addTypesFromClass(NSMutableDictionary *allTypes, Class objCCl
 
 @implementation WebFrameView
 
-- initWithCoder:(NSCoder *)decoder
-{
-    // Older nibs containing WebViews will also contain WebFrameViews. We need to keep track of
-    // their count also to match the decrement in -dealloc.
-    ++WebFrameViewCount;
-    return [super initWithCoder:decoder];
-}
-
-- initWithFrame:(NSRect)frame
+- (id)initWithFrame:(NSRect)frame
 {
     self = [super initWithFrame:frame];
     if (!self)
@@ -350,14 +348,13 @@ static inline void addTypesFromClass(NSMutableDictionary *allTypes, Class objCCl
     // This works together with our becomeFirstResponder and setNextKeyView overrides.
     [super setNextKeyView:scrollView];
     
-    ++WebFrameViewCount;
-    
     return self;
 }
 
 - (void)dealloc 
 {
-    --WebFrameViewCount;
+    if (_private && _private->includedInWebKitStatistics)
+        --WebFrameViewCount;
     
     [_private release];
     _private = nil;
@@ -367,7 +364,8 @@ static inline void addTypesFromClass(NSMutableDictionary *allTypes, Class objCCl
 
 - (void)finalize 
 {
-    --WebFrameViewCount;
+    if (_private && _private->includedInWebKitStatistics)
+        --WebFrameViewCount;
 
     [super finalize];
 }
diff --git a/WebKit/mac/WebView/WebHTMLRepresentation.mm b/WebKit/mac/WebView/WebHTMLRepresentation.mm
index 41ce9f9..3aaa914 100644
--- a/WebKit/mac/WebView/WebHTMLRepresentation.mm
+++ b/WebKit/mac/WebView/WebHTMLRepresentation.mm
@@ -66,6 +66,8 @@ using namespace HTMLNames;
     WebDataSource *dataSource;
     
     BOOL hasSentResponseToPlugin;
+    BOOL includedInWebKitStatistics;
+
     id <WebPluginManualLoader> manualLoader;
     NSView *pluginView;
 }
@@ -117,16 +119,15 @@ static NSArray *concatenateArrays(NSArray *first, NSArray *second)
         return nil;
     
     _private = [[WebHTMLRepresentationPrivate alloc] init];
-    
-    ++WebHTMLRepresentationCount;
-    
+
     return self;
 }
 
 - (void)dealloc
 {
-    --WebHTMLRepresentationCount;
-    
+    if (_private && _private->includedInWebKitStatistics)
+        --WebHTMLRepresentationCount;
+
     [_private release];
 
     [super dealloc];
@@ -134,7 +135,8 @@ static NSArray *concatenateArrays(NSArray *first, NSArray *second)
 
 - (void)finalize
 {
-    --WebHTMLRepresentationCount;
+    if (_private && _private->includedInWebKitStatistics)
+        --WebHTMLRepresentationCount;
 
     [super finalize];
 }
@@ -148,6 +150,11 @@ static NSArray *concatenateArrays(NSArray *first, NSArray *second)
 - (void)setDataSource:(WebDataSource *)dataSource
 {
     _private->dataSource = dataSource;
+
+    if (!_private->includedInWebKitStatistics && [[dataSource webFrame] _isIncludedInWebKitStatistics]) {
+        _private->includedInWebKitStatistics = YES;
+        ++WebHTMLRepresentationCount;
+    }
 }
 
 - (BOOL)_isDisplayingWebArchive
diff --git a/WebKit/mac/WebView/WebView.mm b/WebKit/mac/WebView/WebView.mm
index 0509b01..b2b33b9 100644
--- a/WebKit/mac/WebView/WebView.mm
+++ b/WebKit/mac/WebView/WebView.mm
@@ -658,7 +658,8 @@ static bool shouldEnableLoadDeferring()
         [frameView setNextKeyView:nextKeyView];
     [super setNextKeyView:frameView];
 
-    ++WebViewCount;
+    if ([[self class] shouldIncludeInWebKitStatistics])
+        ++WebViewCount;
 
     [self _registerDraggedTypes];
 
@@ -2745,8 +2746,9 @@ static bool needsWebViewInitThreadWorkaround()
     // this maintains our old behavior for existing applications
     [self close];
 
-    --WebViewCount;
-    
+    if ([[self class] shouldIncludeInWebKitStatistics])
+        --WebViewCount;
+
     if ([self _needsFrameLoadDelegateRetainQuirk])
         [_private->frameLoadDelegate release];
         
@@ -5341,6 +5343,11 @@ static WebFrameView *containingFrameView(NSView *view)
 
 @implementation WebView (WebViewInternal)
 
++ (BOOL)shouldIncludeInWebKitStatistics
+{
+    return NO;
+}
+
 - (BOOL)_becomingFirstResponderFromOutside
 {
     return _private->becomingFirstResponderFromOutside;
diff --git a/WebKit/mac/WebView/WebViewInternal.h b/WebKit/mac/WebView/WebViewInternal.h
index 6c2ae50..3f38d58 100644
--- a/WebKit/mac/WebView/WebViewInternal.h
+++ b/WebKit/mac/WebView/WebViewInternal.h
@@ -64,6 +64,8 @@ namespace WebCore {
 
 @interface WebView (WebViewInternal)
 
++ (BOOL)shouldIncludeInWebKitStatistics;
+
 - (WebCore::Frame*)_mainCoreFrame;
 - (WebFrame *)_selectedOrMainFrame;
 

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list