WK2 leaks when a page is closed
authorcfleizach@apple.com <cfleizach@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 26 Jan 2011 01:54:10 +0000 (01:54 +0000)
committercfleizach@apple.com <cfleizach@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 26 Jan 2011 01:54:10 +0000 (01:54 +0000)
https://bugs.webkit.org/show_bug.cgi?id=53100

Reviewed by Darin Adler.

Allow the WKView a chance to clean up on a page close. In this case,
cleaning up means removing the references the accessibility token has
to the window.

* UIProcess/API/mac/PageClientImpl.h:
* UIProcess/API/mac/PageClientImpl.mm:
(WebKit::PageClientImpl::pageClosed):
* UIProcess/API/mac/WKView.mm:
(-[WKView _setRemoteAccessibilityWindow:]):
(-[WKView _setAccessibilityChildToken:]):
(-[WKView _processDidCrash]):
(-[WKView _pageClosed]):
* UIProcess/API/mac/WKViewInternal.h:
* UIProcess/API/qt/qwkpage_p.h:
(QWKPagePrivate::pageClosed):
* UIProcess/PageClient.h:
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::close):
* UIProcess/win/WebView.cpp:
(WebKit::WebView::pageClosed):
* UIProcess/win/WebView.h:

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

Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/API/mac/PageClientImpl.h
Source/WebKit2/UIProcess/API/mac/PageClientImpl.mm
Source/WebKit2/UIProcess/API/mac/WKView.mm
Source/WebKit2/UIProcess/API/mac/WKViewInternal.h
Source/WebKit2/UIProcess/API/qt/qwkpage_p.h
Source/WebKit2/UIProcess/PageClient.h
Source/WebKit2/UIProcess/WebPageProxy.cpp
Source/WebKit2/UIProcess/win/WebView.cpp
Source/WebKit2/UIProcess/win/WebView.h

index f48a152..c7323bb 100644 (file)
@@ -1,3 +1,32 @@
+2011-01-25  Chris Fleizach  <cfleizach@apple.com>
+
+        Reviewed by Darin Adler.
+
+        WK2 leaks when a page is closed
+        https://bugs.webkit.org/show_bug.cgi?id=53100
+
+        Allow the WKView a chance to clean up on a page close. In this case,
+        cleaning up means removing the references the accessibility token has
+        to the window.
+
+        * UIProcess/API/mac/PageClientImpl.h:
+        * UIProcess/API/mac/PageClientImpl.mm:
+        (WebKit::PageClientImpl::pageClosed):
+        * UIProcess/API/mac/WKView.mm:
+        (-[WKView _setRemoteAccessibilityWindow:]):
+        (-[WKView _setAccessibilityChildToken:]):
+        (-[WKView _processDidCrash]):
+        (-[WKView _pageClosed]):
+        * UIProcess/API/mac/WKViewInternal.h:
+        * UIProcess/API/qt/qwkpage_p.h:
+        (QWKPagePrivate::pageClosed):
+        * UIProcess/PageClient.h:
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::close):
+        * UIProcess/win/WebView.cpp:
+        (WebKit::WebView::pageClosed):
+        * UIProcess/win/WebView.h:
+
 2011-01-25  Chris Marrin  <cmarrin@apple.com>
 
         Reviewed by Adam Roben.
index 625b8f6..7e087cf 100644 (file)
@@ -60,6 +60,7 @@ private:
     virtual bool isViewInWindow();
     
     virtual void processDidCrash();
+    virtual void pageClosed();
     virtual void didRelaunchProcess();
     virtual void takeFocus(bool direction);
     virtual void toolTipChanged(const String& oldToolTip, const String& newToolTip);
index 6eab7f6..c23d518 100644 (file)
@@ -181,6 +181,11 @@ void PageClientImpl::processDidCrash()
 {
     [m_wkView _processDidCrash];
 }
+    
+void PageClientImpl::pageClosed()
+{
+    [m_wkView _pageClosed];
+}
 
 void PageClientImpl::didRelaunchProcess()
 {
index 4277a90..a14be39 100644 (file)
@@ -277,6 +277,13 @@ static bool useNewDrawingArea()
     return YES;
 }
 
+- (void)_setRemoteAccessibilityWindow:(id)window
+{
+#if !defined(BUILDING_ON_SNOW_LEOPARD)
+    WKAXInitializeRemoteElementWithWindow(_data->_remoteAccessibilityChild.get(), window);    
+#endif
+}
+
 - (void)setFrameSize:(NSSize)size
 {
     [super setFrameSize:size];
@@ -1193,6 +1200,7 @@ static void extractUnderlines(NSAttributedString *string, Vector<CompositionUnde
         _data->_page->viewStateDidChange(WebPageProxy::ViewWindowIsActive | WebPageProxy::ViewIsInWindow);
     }
 
+    [self _setRemoteAccessibilityWindow:[self window]];
 }
 
 - (void)_windowDidBecomeKey:(NSNotification *)notification
@@ -1300,7 +1308,7 @@ static void drawPageBackground(CGContextRef context, WebPageProxy* page, const I
 {
 #if !defined(BUILDING_ON_SNOW_LEOPARD)
     _data->_remoteAccessibilityChild = WKAXRemoteElementForToken((CFDataRef)data);
-    WKAXInitializeRemoteElementWithWindow(_data->_remoteAccessibilityChild.get(), [self window]);
+    [self _setRemoteAccessibilityWindow:[self window]];
 #endif
 }
 
@@ -1395,6 +1403,14 @@ static void drawPageBackground(CGContextRef context, WebPageProxy* page, const I
 - (void)_processDidCrash
 {
     [self setNeedsDisplay:YES];
+    [self _setRemoteAccessibilityWindow:nil];
+}
+
+- (void)_pageClosed
+{
+    // When the page closes, the references the accessibility child has to the window 
+    // need to be removed, otherwise it can leak.
+    [self _setRemoteAccessibilityWindow:nil];
 }
 
 - (void)_didRelaunchProcess
index cba241d..655100d 100644 (file)
@@ -36,6 +36,7 @@ namespace WebKit {
 - (PassOwnPtr<WebKit::DrawingAreaProxy>)_createDrawingAreaProxy;
 - (BOOL)_isFocused;
 - (void)_processDidCrash;
+- (void)_pageClosed;
 - (void)_didRelaunchProcess;
 - (void)_takeFocus:(BOOL)direction;
 - (void)_toolTipChangedFrom:(NSString *)oldToolTip to:(NSString *)newToolTip;
index ec1a6a2..a9243c7 100644 (file)
@@ -62,6 +62,7 @@ public:
 #endif // USE(ACCELERATED_COMPOSITING)
     virtual void pageDidRequestScroll(const WebCore::IntSize&);
     virtual void processDidCrash();
+    virtual void pageClosed() { }
     virtual void didRelaunchProcess();
     virtual void didChangeContentsSize(const WebCore::IntSize&);
     virtual void didFindZoomableArea(const WebCore::IntRect&);
index e483aef..fcc5fb2 100644 (file)
@@ -79,6 +79,7 @@ public:
     
     virtual void processDidCrash() = 0;
     virtual void didRelaunchProcess() = 0;
+    virtual void pageClosed() = 0;
 
     virtual void takeFocus(bool direction) = 0;
     virtual void toolTipChanged(const String&, const String&) = 0;
index ab1ea33..2fd8f1a 100644 (file)
@@ -254,6 +254,7 @@ void WebPageProxy::close()
     m_isClosed = true;
 
     m_backForwardList->pageClosed();
+    m_pageClient->pageClosed();
 
     process()->disconnectFramesFromPage(this);
     m_mainFrame = 0;
index 4516f54..e94c8e4 100644 (file)
@@ -626,6 +626,10 @@ bool WebView::isViewInWindow()
     return m_isInWindow;
 }
 
+void WebView::pageClosed()
+{
+}
+
 void WebView::processDidCrash()
 {
     updateNativeCursor();
index dfb5ed1..31f6c45 100644 (file)
@@ -116,6 +116,7 @@ private:
     virtual bool isViewInWindow();
     virtual void processDidCrash();
     virtual void didRelaunchProcess();
+    virtual void pageClosed();
     virtual void takeFocus(bool direction);
     virtual void toolTipChanged(const WTF::String&, const WTF::String&);
     virtual void setCursor(const WebCore::Cursor&);