WebCore:
authorggaren <ggaren@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 12 Nov 2006 04:53:17 +0000 (04:53 +0000)
committerggaren <ggaren@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 12 Nov 2006 04:53:17 +0000 (04:53 +0000)
        Reviewed by Maciej Stachowiak.

        - Fixed loader crash by clarifying ownership of WebKit client objects.
        WebCore objects own their WebKit clients, and ref and deref through
        virtual methods, leaving WebKit free to use whatever client / reference-counting
        implementation it likes.

        * WebCore.exp:
        * WebCore.xcodeproj/project.pbxproj:
        * bridge/EditorClient.h: Fixed up function prototypes for style.
        * loader/FrameLoader.cpp: Removed detachFrameLoader, since its real purpose
        was to implement an alternative ownership model.
        (WebCore::FrameLoader::~FrameLoader): Removed empty destructor.
        (WebCore::FrameLoader::setClient): This function now takes ownership
        (WebCore::FrameLoader::client):
        * loader/FrameLoader.h:
        * loader/FrameLoaderClient.h:
        * page/ChromeClient.h:
        * platform/AbstractShared.h: Added. This is the virtual function-based refcounting
        complement to Shared.
        (WebCore::AbstractShared::~AbstractShared):

WebKit:

        Reviewed by Maciej Stachowiak.

        - Fixed loader crash by clarifying ownership of WebKit client objects.
        WebCore objects own their WebKit clients, and ref and deref through
        virtual methods, leaving WebKit free to use whatever client / reference-counting
        implementation it likes.

        WebKit on Mac just uses the same refcounting class that WebCore uses (Shared),
        but other platforms may choose to do other things.

        * WebCoreSupport/WebChromeClient.h:
        (WebChromeClient::ref):
        (WebChromeClient::deref):
        (WebChromeClient::refCount):
        * WebCoreSupport/WebEditorClient.h: Nixed commented-out function prototypes.
        The ones in WebCore make clear what remains to be implemented. Replaced constructor
        with factory function to avoid leaks.
        * WebCoreSupport/WebEditorClient.mm:
        (WebEditorClient::create):
        (WebEditorClient::WebEditorClient):
        (WebEditorClient::setWebFrame):
        * WebCoreSupport/WebFrameBridge.mm:
        (-[WebFrameBridge initMainFrameWithPage:WebCore::frameName:view:webView:]):
        (-[WebFrameBridge initSubframeWithOwnerElement:frameName:view:]):
        * WebCoreSupport/WebFrameLoaderClient.h: Replaced constructor with factory
        function to avoid leaks.
        (WebFrameLoaderClient::ref):
        (WebFrameLoaderClient::deref):
        (WebFrameLoaderClient::refCount):
        * WebCoreSupport/WebFrameLoaderClient.mm:
        (WebFrameLoaderClient::create):
        * WebView/WebFrame.mm:
        (-[WebFrame _initWithWebFrameView:webView:coreFrame:]):

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

18 files changed:
WebCore/ChangeLog
WebCore/WebCore.exp
WebCore/WebCore.xcodeproj/project.pbxproj
WebCore/bridge/EditorClient.h
WebCore/loader/FrameLoader.cpp
WebCore/loader/FrameLoader.h
WebCore/loader/FrameLoaderClient.h
WebCore/page/ChromeClient.h
WebCore/platform/AbstractShared.h [new file with mode: 0644]
WebKit/ChangeLog
WebKit/WebCoreSupport/WebChromeClient.h
WebKit/WebCoreSupport/WebChromeClient.mm
WebKit/WebCoreSupport/WebEditorClient.h
WebKit/WebCoreSupport/WebEditorClient.mm
WebKit/WebCoreSupport/WebFrameBridge.mm
WebKit/WebCoreSupport/WebFrameLoaderClient.h
WebKit/WebCoreSupport/WebFrameLoaderClient.mm
WebKit/WebView/WebFrame.mm

index 755861b..05165fb 100644 (file)
@@ -1,3 +1,27 @@
+2006-11-11  Geoffrey Garen  <ggaren@apple.com>
+
+        Reviewed by Maciej Stachowiak.
+        
+        - Fixed loader crash by clarifying ownership of WebKit client objects. 
+        WebCore objects own their WebKit clients, and ref and deref through 
+        virtual methods, leaving WebKit free to use whatever client / reference-counting 
+        implementation it likes.
+        
+        * WebCore.exp:
+        * WebCore.xcodeproj/project.pbxproj:
+        * bridge/EditorClient.h: Fixed up function prototypes for style.
+        * loader/FrameLoader.cpp: Removed detachFrameLoader, since its real purpose
+        was to implement an alternative ownership model.
+        (WebCore::FrameLoader::~FrameLoader): Removed empty destructor.
+        (WebCore::FrameLoader::setClient): This function now takes ownership
+        (WebCore::FrameLoader::client):
+        * loader/FrameLoader.h:
+        * loader/FrameLoaderClient.h:
+        * page/ChromeClient.h:
+        * platform/AbstractShared.h: Added. This is the virtual function-based refcounting
+        complement to Shared.
+        (WebCore::AbstractShared::~AbstractShared):
+
 2006-11-11  George Staikos  <staikos@kde.org>
 
         Reviewed by Maciej.
index 1533169..ba5b6f1 100644 (file)
 .objc_class_name_WebCoreSettings
 .objc_class_name_WebCoreStringTruncator
 .objc_class_name_WebCoreViewFactory
-.objc_class_name_WebMimeTypeRegistryBridge
 .objc_class_name_WebDashboardRegion
+.objc_class_name_WebMimeTypeRegistryBridge
 .objc_class_name_WebScriptObject
 .objc_class_name_WebScriptObjectPrivate
 .objc_class_name_WebUndefined
@@ -159,7 +159,7 @@ __ZN7WebCore11FrameLoader4loadERKNS_4KURLERKNS_6StringENS_13FrameLoadTypeES6_PNS
 __ZN7WebCore11FrameLoader5clearEb
 __ZN7WebCore11FrameLoader6reloadEv
 __ZN7WebCore11FrameLoader7canLoadEP5NSURLRKNS_6StringERb
-__ZN7WebCore11FrameLoader9setClientEPNS_17FrameLoaderClientE
+__ZN7WebCore11FrameLoader9setClientEN3WTF10PassRefPtrINS_17FrameLoaderClientEEE
 __ZN7WebCore11RenderLayer18gAlignCenterAlwaysE
 __ZN7WebCore11selectRangeEPNS_19SelectionControllerEPNS_5RangeENS_9EAffinityEb
 __ZN7WebCore11toUserSpaceERK7_NSRectP8NSWindow
@@ -211,10 +211,12 @@ __ZN7WebCore16DeprecatedStringC1ERKS0_
 __ZN7WebCore16DeprecatedStringC1Ev
 __ZN7WebCore16DeprecatedStringD1Ev
 __ZN7WebCore16DeprecatedStringaSERKS0_
+__ZN7WebCore16MimeTypeRegistry24isSupportedImageMIMETypeERKNS_6StringE
+__ZN7WebCore16MimeTypeRegistry27isSupportedNonImageMIMETypeERKNS_6StringE
+__ZN7WebCore16MimeTypeRegistry32isSupportedImageResourceMIMETypeERKNS_6StringE
 __ZN7WebCore16NavigationActionC1ERKNS_4KURLENS_13FrameLoadTypeEb
 __ZN7WebCore16NavigationActionC1ERKNS_4KURLENS_14NavigationTypeE
 __ZN7WebCore16NavigationActionC1Ev
-__ZN7WebCore17FrameLoaderClientD2Ev
 __ZN7WebCore19SelectionController5clearEv
 __ZN7WebCore19SelectionController9selectAllEv
 __ZN7WebCore21PlatformKeyboardEventC1EP7NSEventb
@@ -413,14 +415,10 @@ __ZNK7WebCore9FrameTree20traverseNextWithWrapEb
 __ZNK7WebCore9FrameTree24traversePreviousWithWrapEb
 __ZNK7WebCore9FrameTree4findERKNS_12AtomicStringE
 __ZNK7WebCore9FrameTree5childERKNS_12AtomicStringE
-__ZN7WebCore16MimeTypeRegistry24isSupportedImageMIMETypeERKNS_6StringE
-__ZN7WebCore16MimeTypeRegistry32isSupportedImageResourceMIMETypeERKNS_6StringE
-__ZN7WebCore16MimeTypeRegistry27isSupportedNonImageMIMETypeERKNS_6StringE
 __ZNK7WebCore9Selection17isContentEditableEv
 __ZNK7WebCore9Selection23isContentRichlyEditableEv
 __ZNK7WebCore9Selection7toRangeEv
 __ZNK7WebCore9TimerBase8isActiveEv
-__ZTVN7WebCore17FrameLoaderClientE
 _canonicalURL
 _stringIsFileURL
 _urlByRemovingComponent
index f9a6fc7..a9819c4 100644 (file)
@@ -58,6 +58,7 @@
                14E8378E09F85D4F00B85AE4 /* JSEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = 14E8378D09F85D4F00B85AE4 /* JSEvent.h */; };
                14EC267F09CA07E000E1EEEC /* EventTargetNode.h in Headers */ = {isa = PBXBuildFile; fileRef = 14EC267D09CA07E000E1EEEC /* EventTargetNode.h */; settings = {ATTRIBUTES = (Private, ); }; };
                14EC268009CA07E000E1EEEC /* EventTargetNode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 14EC267E09CA07E000E1EEEC /* EventTargetNode.cpp */; };
+               14F861890B0651D300CE995A /* AbstractShared.h in Headers */ = {isa = PBXBuildFile; fileRef = 14F861880B0651D300CE995A /* AbstractShared.h */; settings = {ATTRIBUTES = (Private, ); }; };
                14FD6DFD0AE5EA1B00AD67AD /* WindowFeatures.h in Headers */ = {isa = PBXBuildFile; fileRef = 14FD6DFC0AE5EA1B00AD67AD /* WindowFeatures.h */; };
                14FFE31D0AE1963300136BF5 /* HTMLFrameElementBase.h in Headers */ = {isa = PBXBuildFile; fileRef = 14FFE31B0AE1963300136BF5 /* HTMLFrameElementBase.h */; };
                14FFE31E0AE1963300136BF5 /* HTMLFrameElementBase.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 14FFE31C0AE1963300136BF5 /* HTMLFrameElementBase.cpp */; };
                14E8378D09F85D4F00B85AE4 /* JSEvent.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = JSEvent.h; sourceTree = "<group>"; };
                14EC267D09CA07E000E1EEEC /* EventTargetNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EventTargetNode.h; sourceTree = "<group>"; };
                14EC267E09CA07E000E1EEEC /* EventTargetNode.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = EventTargetNode.cpp; sourceTree = "<group>"; };
+               14F861880B0651D300CE995A /* AbstractShared.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = AbstractShared.h; sourceTree = "<group>"; };
                14FD6DFC0AE5EA1B00AD67AD /* WindowFeatures.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = WindowFeatures.h; sourceTree = "<group>"; };
                14FFE31B0AE1963300136BF5 /* HTMLFrameElementBase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HTMLFrameElementBase.h; sourceTree = "<group>"; };
                14FFE31C0AE1963300136BF5 /* HTMLFrameElementBase.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HTMLFrameElementBase.cpp; sourceTree = "<group>"; };
                                6582A14809999D6C00BEEB6D /* mac */,
                                656B84D70AEA1CE900A095B4 /* network */,
                                65F5382109B2B55700F3DC4A /* make-charset-table.pl */,
+                               14F861880B0651D300CE995A /* AbstractShared.h */,
                                BCFB2F74097A2E1A00BA703D /* Arena.cpp */,
                                BCFB2F75097A2E1A00BA703D /* Arena.h */,
                                BCB16B890979B01400467741 /* ArrayImpl.cpp */,
                                65DADA180AFD878000CE53ED /* FormData.h in Headers */,
                                651888890AFF3BF700164720 /* ResourceError.h in Headers */,
                                148CF65E0B00561400A997FC /* Screen.h in Headers */,
+                               14F861890B0651D300CE995A /* AbstractShared.h in Headers */,
                                B27535570B053814002CE64F /* AffineTransform.h in Headers */,
                                B275355D0B053814002CE64F /* GraphicsContextPlatformPrivate.h in Headers */,
                                B27535650B053814002CE64F /* PDFDocumentImage.h in Headers */,
index 5110ff3..652b749 100644 (file)
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
  */
 
-#ifndef Editor_Client_h__
-#define Editor_Client_h__
+#ifndef Editor_Client_h
+#define Editor_Client_h
 
-#include "Shared.h"
+#include "AbstractShared.h"
 
 namespace WebCore {
 
@@ -34,10 +34,8 @@ class CSSStyleDeclaration;
 class Range;
 class HTMLElement;
 
-class EditorClient : public Shared<EditorClient>{
+class EditorClient : public AbstractShared {
 public:
-    virtual ~EditorClient() { }
-
     virtual bool shouldDeleteRange(Range*) = 0;
     virtual bool shouldShowDeleteInterface(HTMLElement*) = 0;
     
@@ -47,22 +45,21 @@ public:
 
     virtual bool shouldBeginEditing(Range*) = 0;
     virtual bool shouldEndEditing(Range*) = 0;
-//    virtual bool shouldInsertNode(Node *node, Range* replacingRange, WebViewInsertAction givenAction) = 0;
-//    virtual bool shouldInsertText(NSString *text, Range *replacingRange, WebViewInsertAction givenAction) = 0;
-//    virtual bool shouldChangeSelectedRange(Range *currentRange, Range *toProposedRange, NSSelectionAffinity selectionAffinity, bool stillSelecting) = 0;
+//  virtual bool shouldInsertNode(Node*, Range* replacingRange, WebViewInsertAction) = 0;
+//  virtual bool shouldInsertText(NSString*, Range *replacingRange, WebViewInsertAction) = 0;
+//  virtual bool shouldChangeSelectedRange(Range* fromRange, Range* toRange, NSSelectionAffinity, bool stillSelecting) = 0;
     virtual bool shouldApplyStyle(CSSStyleDeclaration*, Range*) = 0;
-//    virtual bool shouldChangeTypingStyle(CSSStyleDeclaration *currentStyle, CSSStyleDeclaration *toProposedStyle) = 0;
-//    virtual bool doCommandBySelector(SEL selector) = 0;
+//  virtual bool shouldChangeTypingStyle(CSSStyleDeclaration* fromStyle, CSSStyleDeclaration* toStyle) = 0;
+//  virtual bool doCommandBySelector(SEL selector) = 0;
 //
     virtual void didBeginEditing() = 0;
     virtual void respondToChangedContents() = 0;
     virtual void didEndEditing() = 0;
-//    virtual void webViewDidChangeTypingStyle:(NSNotification *)notification = 0;
-//    virtual void webViewDidChangeSelection:(NSNotification *)notification = 0;
-//    virtual NSUndoManager* undoManagerForWebView:(WebView *)webView = 0;
-
+//  virtual void webViewDidChangeTypingStyle:(NSNotification *)notification = 0;
+//  virtual void webViewDidChangeSelection:(NSNotification *)notification = 0;
+//  virtual NSUndoManager* undoManagerForWebView:(WebView *)webView = 0;
 };
 
 }
 
-#endif // Editor_Client_h__
+#endif // Editor_Client_h
index 0559546..2626b40 100644 (file)
@@ -229,9 +229,6 @@ FrameLoader::FrameLoader(Frame* frame)
 
 FrameLoader::~FrameLoader()
 {
-    if (m_client)
-        m_client->detachFrameLoader();
-
     setOpener(0);
 
     HashSet<Frame*>::iterator end = m_openedFrames.end();
@@ -2148,7 +2145,7 @@ int FrameLoader::numPendingOrLoadingRequests(bool recurse) const
     return count;
 }
 
-void FrameLoader::setClient(FrameLoaderClient* client)
+void FrameLoader::setClient(PassRefPtr<FrameLoaderClient> client)
 {
     ASSERT(client);
     ASSERT(!m_client);
@@ -2157,7 +2154,7 @@ void FrameLoader::setClient(FrameLoaderClient* client)
 
 FrameLoaderClient* FrameLoader::client() const
 {
-    return m_client;
+    return m_client.get();
 }
 
 #if PLATFORM(MAC)
@@ -2257,8 +2254,4 @@ void FrameLoader::setTitle(const String& title)
 }
 #endif
 
-FrameLoaderClient::~FrameLoaderClient()
-{
-}
-
-}
+} // namespace WebCore
index 61b94b5..97a35df 100644 (file)
@@ -330,7 +330,7 @@ namespace WebCore {
         void addExtraFieldsToRequest(NSMutableURLRequest *, bool isMainResource, bool alwaysFromRequest);
 #endif
 
-        void setClient(FrameLoaderClient*);
+        void setClient(PassRefPtr<FrameLoaderClient>);
         FrameLoaderClient* client() const;
 
         void setDefersLoading(bool);
@@ -569,7 +569,7 @@ namespace WebCore {
         void startIconLoader();
 
         Frame* m_frame;
-        FrameLoaderClient* m_client;
+        RefPtr<FrameLoaderClient> m_client;
 
         FrameState m_state;
         FrameLoadType m_loadType;
index 10992f8..4ac1e55 100644 (file)
@@ -28,9 +28,9 @@
 #ifndef FrameLoaderClient_h
 #define FrameLoaderClient_h
 
+#include "AbstractShared.h"
 #include "FrameLoaderTypes.h"
 #include <wtf/Forward.h>
-#include <wtf/Noncopyable.h>
 
 #if PLATFORM(MAC)
 #ifdef __OBJC__
@@ -57,10 +57,8 @@ namespace WebCore {
 
     typedef void (FrameLoader::*FramePolicyFunction)(PolicyAction);
 
-    class FrameLoaderClient : Noncopyable {
+    class FrameLoaderClient : public AbstractShared {
     public:
-        virtual void detachFrameLoader() = 0;
-
         virtual bool hasWebView() const = 0; // mainly for assertions
         virtual bool hasFrameView() const = 0; // ditto
 
@@ -227,11 +225,8 @@ namespace WebCore {
         virtual void setTitle(const String& title, const KURL&) = 0;
 
         virtual String userAgent() = 0;
-
-    protected:
-        virtual ~FrameLoaderClient();
     };
 
-}
+} // namespace WebCore
 
-#endif
+#endif // FrameLoaderClient_h
index f2fe553..387a4ae 100644 (file)
@@ -21,7 +21,7 @@
 #ifndef ChromeClient_h
 #define ChromeClient_h
 
-#include "Shared.h"
+#include "AbstractShared.h"
 
 namespace WebCore {
 
@@ -29,10 +29,8 @@ namespace WebCore {
     class Page;
     struct FrameLoadRequest;
     
-    class ChromeClient : public Shared<ChromeClient> {
+    class ChromeClient : public AbstractShared {
     public:
-        virtual ~ChromeClient() { }
-
         virtual void setWindowRect(const FloatRect&) = 0;
         virtual FloatRect windowRect() = 0;
         
diff --git a/WebCore/platform/AbstractShared.h b/WebCore/platform/AbstractShared.h
new file mode 100644 (file)
index 0000000..71c8b08
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2006 Apple Computer, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ */
+
+#ifndef AbstractShared_h
+#define AbstractShared_h
+
+#include <wtf/Noncopyable.h>
+
+namespace WebCore {
+
+class AbstractShared : Noncopyable {
+protected:
+    virtual ~AbstractShared() { }
+    
+public:
+    virtual void ref() = 0;
+    virtual void deref() = 0;
+};
+
+} // namespace WebCore
+
+#endif // AbstractShared_h
index bf4493e..fedcce1 100644 (file)
@@ -1,3 +1,39 @@
+2006-11-11  Geoffrey Garen  <ggaren@apple.com>
+
+        Reviewed by Maciej Stachowiak.
+        
+        - Fixed loader crash by clarifying ownership of WebKit client objects. 
+        WebCore objects own their WebKit clients, and ref and deref through 
+        virtual methods, leaving WebKit free to use whatever client / reference-counting 
+        implementation it likes.
+        
+        WebKit on Mac just uses the same refcounting class that WebCore uses (Shared),
+        but other platforms may choose to do other things.
+
+        * WebCoreSupport/WebChromeClient.h:
+        (WebChromeClient::ref):
+        (WebChromeClient::deref):
+        (WebChromeClient::refCount):
+        * WebCoreSupport/WebEditorClient.h: Nixed commented-out function prototypes.
+        The ones in WebCore make clear what remains to be implemented. Replaced constructor
+        with factory function to avoid leaks.
+        * WebCoreSupport/WebEditorClient.mm:
+        (WebEditorClient::create):
+        (WebEditorClient::WebEditorClient):
+        (WebEditorClient::setWebFrame):
+        * WebCoreSupport/WebFrameBridge.mm:
+        (-[WebFrameBridge initMainFrameWithPage:WebCore::frameName:view:webView:]):
+        (-[WebFrameBridge initSubframeWithOwnerElement:frameName:view:]):
+        * WebCoreSupport/WebFrameLoaderClient.h: Replaced constructor with factory
+        function to avoid leaks.
+        (WebFrameLoaderClient::ref):
+        (WebFrameLoaderClient::deref):
+        (WebFrameLoaderClient::refCount):
+        * WebCoreSupport/WebFrameLoaderClient.mm:
+        (WebFrameLoaderClient::create):
+        * WebView/WebFrame.mm:
+        (-[WebFrame _initWithWebFrameView:webView:coreFrame:]):
+
 === Safari-521.30 ===
 
 2006-11-10  Maciej Stachowiak  <mjs@apple.com>
index 3879848..2e1572f 100644 (file)
  */
 
 #import <WebCore/ChromeClient.h>
-
+#import <WebCore/Shared.h>
 #import <wtf/Forward.h>
 
 @class WebView;
 
-class WebChromeClient : public WebCore::ChromeClient {
+class WebChromeClient : public WebCore::ChromeClient, public WebCore::Shared<WebChromeClient> {
 public:
     static PassRefPtr<WebChromeClient> create(WebView *webView);
     
+    virtual void ref();
+    virtual void deref();
+
     WebView *webView() { return m_webView; }
     
     virtual void setWindowRect(const WebCore::FloatRect&);
index 4915199..9e9bd57 100644 (file)
@@ -53,6 +53,16 @@ WebChromeClient::WebChromeClient(WebView *webView)
 {
 }
 
+void WebChromeClient::ref() 
+{
+    Shared<WebChromeClient>::ref();
+}
+
+void WebChromeClient::deref()
+{
+    Shared<WebChromeClient>::deref();
+}
+
 // These functions scale between window and WebView coordinates because JavaScript/DOM operations 
 // assume that the WebView and the window share the same coordinate system.
 
index ee4a895..929394e 100644 (file)
  */
 
 #import <WebCore/EditorClient.h>
+#import <WebCore/Shared.h>
+#import <wtf/Forward.h>
 
 @class WebFrame;
 
-class WebEditorClient : public WebCore::EditorClient {
+class WebEditorClient : public WebCore::EditorClient, public WebCore::Shared<WebEditorClient> {
 public:
-    WebEditorClient();
-    WebEditorClient(WebFrame *webFrame);
-    ~WebEditorClient();
+    static PassRefPtr<WebEditorClient> create();
+    
+    virtual void ref();
+    virtual void deref();
 
     void setWebFrame(WebFrame *webFrame);
     
@@ -47,20 +50,16 @@ public:
 
     bool shouldBeginEditing(WebCore::Range*);
     bool shouldEndEditing(WebCore::Range*);
-//    bool shouldInsertNode(Node *node, Range* replacingRange, WebViewInsertAction givenAction);
-//    bool shouldInsertText(NSString *text, Range *replacingRange, WebViewInsertActiongivenAction);
-//    bool shouldChangeSelectedRange(Range *currentRange, Range *toProposedRange, NSSelectionAffinity selectionAffinity, bool stillSelecting);
+
     bool shouldApplyStyle(WebCore::CSSStyleDeclaration*, WebCore::Range*);
-//    bool shouldChangeTypingStyle(CSSStyleDeclaration *currentStyle, CSSStyleDeclaration *toProposedStyle);
-//    bool doCommandBySelector(SEL selector);
 
     void didBeginEditing();
-    void respondToChangedContents();
     void didEndEditing();
-//    void webViewDidChangeTypingStyle:(NSNotification *)notification;
-//    void webViewDidChangeSelection:(NSNotification *)notification;
-//    NSUndoManager* undoManagerForWebView:(WebView *)webView;
+
+    void respondToChangedContents();
 
 private:
+    WebEditorClient();
+    
     WebFrame *m_webFrame;
 };
index bd8933e..50d6292 100644 (file)
 #import "WebHTMLViewInternal.h"
 #import "WebViewInternal.h"
 #import "WebEditingDelegatePrivate.h"
+#import <wtf/PassRefPtr.h>
 
 using namespace WebCore;
 
+PassRefPtr<WebEditorClient> WebEditorClient::create()
+{
+    return new WebEditorClient;
+}
+
 WebEditorClient::WebEditorClient()
     : m_webFrame(nil) 
 {
 }
 
-WebEditorClient::WebEditorClient(WebFrame *webFrame)
-    : m_webFrame(webFrame) 
+void WebEditorClient::ref()
 {
+    Shared<WebEditorClient>::ref();
 }
 
-WebEditorClient::~WebEditorClient()
+void WebEditorClient::deref()
 {
+    Shared<WebEditorClient>::deref();
 }
 
 void WebEditorClient::setWebFrame(WebFrame *webFrame)
-{ 
+{
+    ASSERT(!m_webFrame); // Should only be called during initialization
+    ASSERT(webFrame);
     m_webFrame = webFrame;
 }
 
index d73209d..170cbed 100644 (file)
@@ -131,7 +131,7 @@ NSString *WebPluginContainerKey =   @"WebPluginContainer";
 
 - (id)initMainFrameWithPage:(WebCore::Page*)page frameName:(NSString *)name view:(WebFrameView *)view webView:(WebView *)webView
 {
-    RefPtr<WebEditorClient> editorClient = new WebEditorClient;
+    RefPtr<WebEditorClient> editorClient = WebEditorClient::create();
     self = [super initMainFrameWithPage:page withEditorClient:editorClient.get()];
     [self finishInitializingWithFrameName:name view:view];
     
@@ -143,7 +143,7 @@ NSString *WebPluginContainerKey =   @"WebPluginContainer";
 
 - (id)initSubframeWithOwnerElement:(WebCoreElement *)ownerElement frameName:(NSString *)name view:(WebFrameView *)view
 {
-    RefPtr<WebEditorClient> editorClient = new WebEditorClient;
+    RefPtr<WebEditorClient> editorClient = WebEditorClient::create();
     self = [super initSubframeWithOwnerElement:ownerElement withEditorClient:editorClient.get()];
     [self finishInitializingWithFrameName:name view:view];
 
index a0fbd0e..67f4013 100644 (file)
@@ -28,7 +28,9 @@
 
 #import <WebCore/FrameLoaderClient.h>
 #import <WebCore/RetainPtr.h>
+#import <WebCore/Shared.h>
 #import <WebCore/Timer.h>
+#import <wtf/Forward.h>
 #import <wtf/HashMap.h>
 
 @class WebFrame;
@@ -43,15 +45,19 @@ namespace WebCore {
 
 typedef HashMap<RefPtr<WebCore::ResourceLoader>, WebCore::RetainPtr<WebResource> > ResourceMap;
 
-class WebFrameLoaderClient : public WebCore::FrameLoaderClient {
+class WebFrameLoaderClient : public WebCore::FrameLoaderClient, public WebCore::Shared<WebFrameLoaderClient> {
 public:
-    WebFrameLoaderClient(WebFrame*);
+    static PassRefPtr<WebFrameLoaderClient> create(WebFrame*);
+
+    virtual void ref();
+    virtual void deref();
+
     WebFrame* webFrame() const { return m_webFrame.get(); }
 
     void receivedPolicyDecison(WebCore::PolicyAction);
 
 private:
-    virtual void detachFrameLoader();
+    WebFrameLoaderClient(WebFrame*);
 
     virtual bool hasWebView() const; // mainly for assertions
     virtual bool hasFrameView() const; // ditto
index 3b027ec..100b5e2 100644 (file)
@@ -103,6 +103,11 @@ static inline WebDataSource *dataSource(DocumentLoader* loader)
     return loader ? static_cast<WebDocumentLoaderMac*>(loader)->dataSource() : nil;
 }
 
+PassRefPtr<WebFrameLoaderClient> WebFrameLoaderClient::create(WebFrame* webFrame)
+{
+    return new WebFrameLoaderClient(webFrame);
+}
+
 WebFrameLoaderClient::WebFrameLoaderClient(WebFrame *webFrame)
     : m_webFrame(webFrame)
     , m_policyFunction(0)
@@ -110,9 +115,14 @@ WebFrameLoaderClient::WebFrameLoaderClient(WebFrame *webFrame)
 {
 }
 
-void WebFrameLoaderClient::detachFrameLoader()
+void WebFrameLoaderClient::ref()
+{
+    Shared<WebFrameLoaderClient>::ref();
+}
+
+void WebFrameLoaderClient::deref()
 {
-    delete this;
+    Shared<WebFrameLoaderClient>::deref();
 }
 
 bool WebFrameLoaderClient::hasWebView() const
index dcb3989..bef0b0c 100644 (file)
@@ -845,7 +845,7 @@ WebView *getWebView(WebFrame *webFrame)
 
     ++WebFrameCount;
 
-    [self _frameLoader]->setClient(new WebFrameLoaderClient(self));
+    [self _frameLoader]->setClient(WebFrameLoaderClient::create(self));
 
     return self;
 }