WebCore:
authorggaren <ggaren@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 28 Nov 2006 18:54:03 +0000 (18:54 +0000)
committerggaren <ggaren@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 28 Nov 2006 18:54:03 +0000 (18:54 +0000)
        Reviewed by Adam.

        Fixed <rdar://problem/4844848> REGRESSION: extra cross-library ref/deref
        calls cause .5% PLT regression.

        Changed ref/deref calls to a single 'xxxDestroyed' call. Moved EditorClient
        from the Frame to the Page, since it's only responsible for
        Webview-level delegate calls.

        I don't really love this design, but it fixes the regression and allows
        a single WebKit object to implement multiple client interfaces.

        Layout tests pass.

WebKit:

        Reviewed by Adam.

        Fixed <rdar://problem/4844848> REGRESSION: extra cross-library ref/deref
        calls cause .5% PLT regression.

        Changed ref/deref calls to a single 'xxxDestroyed' call. Moved EditorClient
        from the Frame to the Page, since it's only responsible for
        Webview-level delegate calls.

        I don't really love this design, but it fixes the regression and allows
        a single WebKit object to implement multiple client interfaces.

        Layout tests pass.

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

37 files changed:
WebCore/ChangeLog
WebCore/WebCore.exp
WebCore/WebCore.xcodeproj/project.pbxproj
WebCore/bridge/EditorClient.h
WebCore/bridge/mac/FrameMac.h
WebCore/bridge/mac/FrameMac.mm
WebCore/bridge/mac/WebCoreFrameBridge.h
WebCore/bridge/mac/WebCoreFrameBridge.mm
WebCore/editing/Editor.cpp
WebCore/editing/Editor.h
WebCore/loader/FrameLoader.cpp
WebCore/loader/FrameLoader.h
WebCore/loader/FrameLoaderClient.h
WebCore/page/Chrome.cpp
WebCore/page/Chrome.h
WebCore/page/ChromeClient.h
WebCore/page/ContextMenuClient.h
WebCore/page/ContextMenuController.cpp
WebCore/page/ContextMenuController.h
WebCore/page/Frame.cpp
WebCore/page/Frame.h
WebCore/page/FramePrivate.h
WebCore/page/Page.cpp
WebCore/page/Page.h
WebCore/platform/AbstractShared.h [deleted file]
WebKit/ChangeLog
WebKit/WebCoreSupport/WebChromeClient.h
WebKit/WebCoreSupport/WebChromeClient.mm
WebKit/WebCoreSupport/WebContextMenuClient.h
WebKit/WebCoreSupport/WebContextMenuClient.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
WebKit/WebView/WebView.mm

index 7504bdc..5f27a24 100644 (file)
@@ -1,3 +1,19 @@
+2006-11-28  Geoffrey Garen  <ggaren@apple.com>
+
+        Reviewed by Adam.
+
+        Fixed <rdar://problem/4844848> REGRESSION: extra cross-library ref/deref 
+        calls cause .5% PLT regression.
+        
+        Changed ref/deref calls to a single 'xxxDestroyed' call. Moved EditorClient
+        from the Frame to the Page, since it's only responsible for
+        Webview-level delegate calls.
+        
+        I don't really love this design, but it fixes the regression and allows
+        a single WebKit object to implement multiple client interfaces.
+        
+        Layout tests pass.
+
 2006-11-27  Anders Carlsson  <acarlsson@apple.com>
 
         Try fixing the build.
index 46b1c6b..0fa7b05 100644 (file)
@@ -159,7 +159,7 @@ __ZN7WebCore11FrameLoader4loadERKNS_4KURLERKNS_6StringENS_13FrameLoadTypeES6_PNS
 __ZN7WebCore11FrameLoader5clearEb
 __ZN7WebCore11FrameLoader6reloadEv
 __ZN7WebCore11FrameLoader7canLoadEP5NSURLRKNS_6StringERb
-__ZN7WebCore11FrameLoader9setClientEN3WTF10PassRefPtrINS_17FrameLoaderClientEEE
+__ZN7WebCore11FrameLoader9setClientEPNS_17FrameLoaderClientE
 __ZN7WebCore11RenderLayer18gAlignCenterAlwaysE
 __ZN7WebCore11selectRangeEPNS_19SelectionControllerEPNS_5RangeENS_9EAffinityEb
 __ZN7WebCore11toUserSpaceERK7_NSRectP8NSWindow
@@ -230,11 +230,10 @@ __ZN7WebCore4KURLC1EP5NSURL
 __ZN7WebCore4KURLC1ERKNS_16DeprecatedStringE
 __ZN7WebCore4Page12setGroupNameERKNS_6StringE
 __ZN7WebCore4Page16setDefersLoadingEb
-__ZN7WebCore4PageC1EN3WTF10PassRefPtrINS_12ChromeClientEEENS2_INS_17ContextMenuClientEEE
+__ZN7WebCore4PageC1EPNS_12ChromeClientEPNS_17ContextMenuClientEPNS_12EditorClientE
 __ZN7WebCore4PageD1Ev
 __ZN7WebCore5Cache11setDisabledEb
 __ZN7WebCore5Cache13getStatisticsEv
-__ZN7WebCore5cacheEv
 __ZN7WebCore5Frame11setSettingsEPNS_8SettingsE
 __ZN7WebCore5Frame12ownerElementEv
 __ZN7WebCore5Frame17setWindowHasFocusEb
@@ -244,6 +243,7 @@ __ZN7WebCore5Image10getNSImageEv
 __ZN7WebCore5Image21getTIFFRepresentationEv
 __ZN7WebCore5RangeC1EPNS_8DocumentEPNS_4NodeEiS4_i
 __ZN7WebCore5RangeD1Ev
+__ZN7WebCore5cacheEv
 __ZN7WebCore6Editor10applyStyleEPNS_19CSSStyleDeclarationENS_10EditActionE
 __ZN7WebCore6Editor11execCommandERKNS_6StringE
 __ZN7WebCore6Editor21applyStyleToSelectionEPNS_19CSSStyleDeclarationENS_10EditActionE
index dfb9a4f..27a21b6 100644 (file)
@@ -61,7 +61,6 @@
                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 5616e6c..3523c9b 100644 (file)
 #ifndef Editor_Client_h
 #define Editor_Client_h
 
-#include <wtf/Forward.h>
-#include "AbstractShared.h"
-
 #include "EditorInsertAction.h"
+#include <wtf/Forward.h>
 
 namespace WebCore {
 
@@ -39,8 +37,11 @@ class HTMLElement;
 class String;
 class Range;
 
-class EditorClient : public AbstractShared {
+class EditorClient {
 public:
+    virtual ~EditorClient() {  }
+    virtual void pageDestroyed() = 0;
+    
     virtual bool shouldDeleteRange(Range*) = 0;
     virtual bool shouldShowDeleteInterface(HTMLElement*) = 0;
     
index 44b6f95..6e9c105 100644 (file)
@@ -76,6 +76,7 @@ typedef int NSWritingDirection;
 namespace WebCore {
 
 class ClipboardMac;
+class EditorClient;
 class HTMLTableCellElement;
 class RenderWidget;
 
@@ -83,7 +84,7 @@ class FrameMac : public Frame {
     friend class Frame;
 
 public:
-    FrameMac(Page*, Element*, PassRefPtr<EditorClient>);
+    FrameMac(Page*, Element*);
     ~FrameMac();
 
     void setBridge(WebCoreFrameBridge*);
index 07dcd33..a960e3a 100644 (file)
@@ -141,8 +141,8 @@ static SEL selectorForKeyEvent(KeyboardEvent* event)
     return 0;
 }
 
-FrameMac::FrameMac(Page* page, Element* ownerElement, PassRefPtr<EditorClient> client)
-    : Frame(page, ownerElement, client)
+FrameMac::FrameMac(Page* page, Element* ownerElement)
+    : Frame(page, ownerElement)
     , _bridge(nil)
     , _bindingRoot(0)
     , _windowScriptObject(0)
index 459c3b5..ef7a211 100644 (file)
@@ -127,8 +127,8 @@ typedef enum {
 
 + (WebCoreFrameBridge *)bridgeForDOMDocument:(DOMDocument *)document;
 
-- (id)initMainFrameWithPage:(WebCore::Page*)page withEditorClient:(WebCoreEditorClient *)client;
-- (id)initSubframeWithOwnerElement:(WebCoreElement *)ownerElement withEditorClient:(WebCoreEditorClient *)client;
+- (id)initMainFrameWithPage:(WebCore::Page*)page;
+- (id)initSubframeWithOwnerElement:(WebCoreElement *)ownerElement;
 
 - (void)close;
 
index 28aff2b..9984500 100644 (file)
@@ -252,7 +252,7 @@ static inline WebCoreFrameBridge *bridge(Frame *frame)
     return bridge([document _document]->frame());
 }
 
-- (id)initMainFrameWithPage:(WebCore::Page*)page withEditorClient:(WebCoreEditorClient *)client
+- (id)initMainFrameWithPage:(WebCore::Page*)page
 {
     if (!initializedKJS) {
         mainThread = pthread_self();
@@ -264,7 +264,7 @@ static inline WebCoreFrameBridge *bridge(Frame *frame)
     if (!(self = [super init]))
         return nil;
 
-    m_frame = new FrameMac(page, 0, client);
+    m_frame = new FrameMac(page, 0);
     m_frame->setBridge(self);
     _shouldCreateRenderers = YES;
 
@@ -278,12 +278,12 @@ static inline WebCoreFrameBridge *bridge(Frame *frame)
     return self;
 }
 
-- (id)initSubframeWithOwnerElement:(Element *)ownerElement withEditorClient:(WebCoreEditorClient *)client
+- (id)initSubframeWithOwnerElement:(Element *)ownerElement
 {
     if (!(self = [super init]))
         return nil;
     
-    m_frame = new FrameMac(ownerElement->document()->frame()->page(), ownerElement, client);
+    m_frame = new FrameMac(ownerElement->document()->frame()->page(), ownerElement);
     m_frame->setBridge(self);
     _shouldCreateRenderers = YES;
 
index d07026b..22a49f7 100644 (file)
@@ -44,6 +44,7 @@
 #include "HTMLNames.h"
 #include "HitTestResult.h"
 #include "IndentOutdentCommand.h"
+#include "Page.h"
 #include "Range.h"
 #include "ReplaceSelectionCommand.h"
 #include "SelectionController.h"
@@ -65,7 +66,9 @@ static Pasteboard generalPasteboard()
 
 EditorClient* Editor::client() const
 {
-    return m_client.get();
+    if (Page* page = m_frame->page())
+        return page->editorClient();
+    return 0;
 }
 
 bool Editor::canEdit() const
@@ -163,7 +166,9 @@ bool Editor::shouldDeleteRange(Range* range) const
     if (!canDeleteRange(range))
         return false;
 
-    return m_client->shouldDeleteRange(range);
+    if (client())
+        return client()->shouldDeleteRange(range);
+    return false;
  }
 
 bool Editor::tryDHTMLCopy()
@@ -190,12 +195,16 @@ void Editor::writeSelectionToPasteboard(Pasteboard pasteboard)
 
 bool Editor::shouldInsertText(String text, Range* range, EditorInsertAction action) const
 {
-    return m_client->shouldInsertText(text, range, action);
+    if (client())
+        return client()->shouldInsertText(text, range, action);
+    return false;
 }
 
 bool Editor::shouldShowDeleteInterface(HTMLElement* element) const
 {
-    return m_client->shouldShowDeleteInterface(element);
+    if (client())
+        return client()->shouldShowDeleteInterface(element);
+    return false;
 }
 
 void Editor::respondToChangedSelection(const Selection& oldSelection)
@@ -211,7 +220,8 @@ void Editor::respondToChangedContents(const Selection& endingSelection)
             m_frame->renderer()->document()->axObjectCache()->postNotification(node->renderer(), "AXValueChanged");
     }
     
-    m_client->respondToChangedContents();  
+    if (client())
+        client()->respondToChangedContents();  
     m_deleteButtonController->respondToChangedContents();
 }
 
@@ -315,7 +325,7 @@ void Editor::applyStyleToSelection(CSSStyleDeclaration* style, EditAction editin
     if (!style || style->length() == 0 || !canEditRichly())
         return;
 
-    if (m_client->shouldApplyStyle(style, m_frame->selectionController()->toRange().get()))
+    if (client() && client()->shouldApplyStyle(style, m_frame->selectionController()->toRange().get()))
         applyStyle(style, editingAction);
 }
 
@@ -324,18 +334,22 @@ void Editor::applyParagraphStyleToSelection(CSSStyleDeclaration* style, EditActi
     if (!style || style->length() == 0 || !canEditRichly())
         return;
     
-    if (m_client->shouldApplyStyle(style, m_frame->selectionController()->toRange().get()))
+    if (client() && client()->shouldApplyStyle(style, m_frame->selectionController()->toRange().get()))
         applyParagraphStyle(style, editingAction);
 }
 
 bool Editor::selectWordBeforeMenuEvent() const
 {
-    return m_client->selectWordBeforeMenuEvent();
+    if (client())
+        return client()->selectWordBeforeMenuEvent();
+    return false;
 }
 
 bool Editor::clientIsEditable() const
 {
-    return m_client->isEditable();
+    if (client())
+        return client()->isEditable();
+    return false;
 }
 
 bool Editor::selectionStartHasStyle(CSSStyleDeclaration* style) const
@@ -420,7 +434,8 @@ void Editor::appliedEditing(PassRefPtr<EditCommand> cmd)
         // Only register a new undo command if the command passed in is
         // different from the last command
         m_lastEditCommand = cmd;
-        m_client->registerCommandForUndo(m_lastEditCommand);
+        if (client())
+            client()->registerCommandForUndo(m_lastEditCommand);
     }
     respondToChangedContents(newSelection);    
 }
@@ -434,7 +449,8 @@ void Editor::unappliedEditing(PassRefPtr<EditCommand> cmd)
         m_frame->selectionController()->setSelection(newSelection, true);
     
     m_lastEditCommand = 0;
-    m_client->registerCommandForRedo(cmd);
+    if (client())
+        client()->registerCommandForRedo(cmd);
     respondToChangedContents(newSelection);    
 }
 
@@ -447,7 +463,8 @@ void Editor::reappliedEditing(PassRefPtr<EditCommand> cmd)
         m_frame->selectionController()->setSelection(newSelection, true);
     
     m_lastEditCommand = 0;
-    m_client->registerCommandForUndo(cmd);
+    if (client())
+        client()->registerCommandForUndo(cmd);
     respondToChangedContents(newSelection);    
 }
 
@@ -871,9 +888,8 @@ static CommandMap* createCommandMap()
 //
 // =============================================================================
 
-Editor::Editor(Frame* frame, PassRefPtr<EditorClient> client)
+Editor::Editor(Frame* frame)
     : m_frame(frame)
-    , m_client(client)
     , m_deleteButtonController(new DeleteButtonController(frame))
 { 
 }
index 9cc2a6f..03b8b04 100644 (file)
@@ -47,7 +47,7 @@ typedef int Pasteboard;
 
 class Editor {
 public:
-    Editor(Frame*, PassRefPtr<EditorClient>);
+    Editor(Frame*);
     ~Editor();
 
     EditorClient* client() const;
@@ -109,7 +109,6 @@ public:
     bool execCommand(const String&);
 private:
     Frame* m_frame;
-    RefPtr<EditorClient> m_client;
     OwnPtr<DeleteButtonController> m_deleteButtonController;
     RefPtr<EditCommand> m_lastEditCommand;
     RefPtr<Node> m_removedAnchor;
index 8e113e4..23fcaa2 100644 (file)
@@ -235,6 +235,8 @@ FrameLoader::~FrameLoader()
     HashSet<Frame*>::iterator end = m_openedFrames.end();
     for (HashSet<Frame*>::iterator it = m_openedFrames.begin(); it != end; ++it)
         (*it)->loader()->m_opener = 0;
+        
+    m_client->frameLoaderDestroyed();
 }
 
 static void setAllDefersLoading(const ResourceLoaderSet& loaders, bool defers)
@@ -2160,7 +2162,7 @@ int FrameLoader::numPendingOrLoadingRequests(bool recurse) const
     return count;
 }
 
-void FrameLoader::setClient(PassRefPtr<FrameLoaderClient> client)
+void FrameLoader::setClient(FrameLoaderClient* client)
 {
     ASSERT(client);
     ASSERT(!m_client);
@@ -2169,7 +2171,7 @@ void FrameLoader::setClient(PassRefPtr<FrameLoaderClient> client)
 
 FrameLoaderClient* FrameLoader::client() const
 {
-    return m_client.get();
+    return m_client;
 }
 
 #if PLATFORM(MAC)
index c0fc7f3..2892934 100644 (file)
@@ -332,7 +332,7 @@ namespace WebCore {
         void addExtraFieldsToRequest(NSMutableURLRequest *, bool isMainResource, bool alwaysFromRequest);
 #endif
 
-        void setClient(PassRefPtr<FrameLoaderClient>);
+        void setClient(FrameLoaderClient*);
         FrameLoaderClient* client() const;
 
         void setDefersLoading(bool);
@@ -571,7 +571,7 @@ namespace WebCore {
         void startIconLoader();
 
         Frame* m_frame;
-        RefPtr<FrameLoaderClient> m_client;
+        FrameLoaderClient* m_client;
 
         FrameState m_state;
         FrameLoadType m_loadType;
index d9e9007..82b096c 100644 (file)
@@ -28,7 +28,6 @@
 #ifndef FrameLoaderClient_h
 #define FrameLoaderClient_h
 
-#include "AbstractShared.h"
 #include "FrameLoaderTypes.h"
 #include <wtf/Forward.h>
 
@@ -58,8 +57,11 @@ namespace WebCore {
 
     typedef void (FrameLoader::*FramePolicyFunction)(PolicyAction);
 
-    class FrameLoaderClient : public AbstractShared {
+    class FrameLoaderClient {
     public:
+        virtual ~FrameLoaderClient() {  }
+        virtual void frameLoaderDestroyed() = 0;
+        
         virtual bool hasWebView() const = 0; // mainly for assertions
         virtual bool hasFrameView() const = 0; // ditto
 
index da3bc77..eacfda6 100644 (file)
 
 namespace WebCore {
 
-Chrome::Chrome(Page* page, PassRefPtr<ChromeClient> client)
+Chrome::Chrome(Page* page, ChromeClient* client)
     : m_page(page)
     , m_client(client)
 {
     ASSERT(m_client);
 }
 
+Chrome::~Chrome()
+{
+    m_client->chromeDestroyed();
+}
+
 void Chrome::setWindowRect(const FloatRect& rect) const
 {
     m_client->setWindowRect(rect);
index 6562370..0827b41 100644 (file)
@@ -35,9 +35,10 @@ namespace WebCore {
     
     class Chrome {
     public:
-        Chrome(Page*, PassRefPtr<ChromeClient>);
+        Chrome(Page*, ChromeClient*);
+        ~Chrome();
 
-        ChromeClient* client() { return m_client.get(); }
+        ChromeClient* client() { return m_client; }
 
         void setWindowRect(const FloatRect&) const;
         FloatRect windowRect() const;
@@ -75,7 +76,7 @@ namespace WebCore {
         
     private:
         Page* m_page;
-        RefPtr<ChromeClient> m_client;
+        ChromeClient* m_client;
     };
 }
 
index 4f3d2f2..b72c51e 100644 (file)
@@ -21,8 +21,6 @@
 #ifndef ChromeClient_h
 #define ChromeClient_h
 
-#include "AbstractShared.h"
-
 namespace WebCore {
 
     class FloatRect;
@@ -31,8 +29,11 @@ namespace WebCore {
     
     struct FrameLoadRequest;
     
-    class ChromeClient : public AbstractShared {
+    class ChromeClient {
     public:
+        virtual ~ChromeClient() {  }
+        virtual void chromeDestroyed() = 0;
+        
         virtual void setWindowRect(const FloatRect&) = 0;
         virtual FloatRect windowRect() = 0;
         
index 7fddf98..f0b4695 100644 (file)
 #ifndef ContextMenuClient_h
 #define ContextMenuClient_h
 
-#include "AbstractShared.h"
-
 namespace WebCore {
     class ContextMenu;
     class Frame;
     class HitTestResult;
     class KURL;
 
-    class ContextMenuClient : public AbstractShared {
+    class ContextMenuClient {
     public:
+        virtual ~ContextMenuClient() {  }
+        virtual void contextMenuDestroyed() = 0;
+        
         virtual void addCustomContextMenuItems(ContextMenu*) = 0;
 
         virtual void copyLinkToClipboard(HitTestResult) = 0;
index fb81187..03648c1 100644 (file)
@@ -54,7 +54,7 @@ namespace WebCore {
 
 using namespace EventNames;
 
-ContextMenuController::ContextMenuController(Page* page, PassRefPtr<ContextMenuClient> client)
+ContextMenuController::ContextMenuController(Page* page, ContextMenuClient* client)
     : m_page(page)
     , m_client(client)
     , m_contextMenu(0)
@@ -63,6 +63,7 @@ ContextMenuController::ContextMenuController(Page* page, PassRefPtr<ContextMenuC
 
 ContextMenuController::~ContextMenuController()
 {
+    m_client->contextMenuDestroyed();
 }
 
 void ContextMenuController::handleContextMenuEvent(Event* event)
index 9448bdc..261daaa 100644 (file)
@@ -42,18 +42,17 @@ namespace WebCore {
     class ContextMenuController : Noncopyable
     {
     public:
-        ContextMenuController(Page*, PassRefPtr<ContextMenuClient>);
+        ContextMenuController(Page*, ContextMenuClient*);
         ~ContextMenuController();
 
-        ContextMenuClient* client() { return m_client.get(); }
+        ContextMenuClient* client() { return m_client; }
 
         void handleContextMenuEvent(Event*);
         void contextMenuActionSelected(ContextMenuAction, String);
 
     private:
         Page* m_page;
-        RefPtr<ContextMenuClient> m_client;
-
+        ContextMenuClient* m_client;
         OwnPtr<ContextMenu> m_contextMenu;
     };
 
index a0e572d..baf6a2b 100644 (file)
@@ -39,7 +39,6 @@
 #include "DocLoader.h"
 #include "DocumentType.h"
 #include "EditingText.h"
-#include "EditorClient.h"
 #include "Event.h"
 #include "EventNames.h"
 #include "FloatRect.h"
@@ -158,8 +157,8 @@ static inline Frame* parentFromOwnerElement(Element* ownerElement)
     return ownerElement->document()->frame();
 }
 
-Frame::Frame(Page* page, Element* ownerElement, PassRefPtr<EditorClient> client
-    : d(new FramePrivate(page, parentFromOwnerElement(ownerElement), this, ownerElement, client))
+Frame::Frame(Page* page, Element* ownerElement) 
+    : d(new FramePrivate(page, parentFromOwnerElement(ownerElement), this, ownerElement))
 {
     AtomicString::init();
     EventNames::init();
@@ -1494,7 +1493,7 @@ void Frame::setProhibitsScrolling(bool prohibit)
     d->m_prohibitsScrolling = prohibit;
 }
 
-FramePrivate::FramePrivate(Page* page, Frame* parent, Frame* thisFrame, Element* ownerElement, PassRefPtr<EditorClient> client)
+FramePrivate::FramePrivate(Page* page, Frame* parent, Frame* thisFrame, Element* ownerElement)
     : m_page(page)
     , m_treeNode(thisFrame, parent)
     , m_ownerElement(ownerElement)
@@ -1506,7 +1505,7 @@ FramePrivate::FramePrivate(Page* page, Frame* parent, Frame* thisFrame, Element*
     , m_zoomFactor(parent ? parent->d->m_zoomFactor : 100)
     , m_selectionController(thisFrame)
     , m_caretBlinkTimer(thisFrame, &Frame::caretBlinkTimerFired)
-    , m_editor(thisFrame, client)
+    , m_editor(thisFrame)
     , m_command(thisFrame)
     , m_eventHandler(thisFrame)
     , m_caretVisible(false)
index 54009fd..13745c8 100644 (file)
@@ -59,7 +59,6 @@ class DOMWindow;
 class Document;
 class EditCommand;
 class Editor;
-class EditorClient;
 class Element;
 class EventHandler;
 class FloatRect;
@@ -103,7 +102,7 @@ struct MarkedTextUnderline {
 
 class Frame : public Shared<Frame> {
 public:
-    Frame(Page*, Element*, PassRefPtr<EditorClient>);
+    Frame(Page*, Element*);
     virtual void setView(FrameView*);
     virtual ~Frame();
 
index 8ec300f..8a8d314 100644 (file)
@@ -40,7 +40,7 @@ namespace WebCore {
 
     class FramePrivate {
     public:
-        FramePrivate(Page*, Frame* parent, Frame* thisFrame, Element* ownerElement, PassRefPtr<EditorClient>);
+        FramePrivate(Page*, Frame* parent, Frame* thisFrame, Element* ownerElement);
         ~FramePrivate();
 
         Page* m_page;
index 5db3e54..f3ac5fb 100644 (file)
@@ -23,6 +23,7 @@
 
 #include "ChromeClient.h"
 #include "ContextMenuClient.h"
+#include "EditorClient.h"
 #include "Frame.h"
 #include "FrameLoader.h"
 #include "FrameTree.h"
@@ -39,10 +40,11 @@ namespace WebCore {
 static HashSet<Page*>* allPages;
 static HashMap<String, HashSet<Page*>*>* frameNamespaces;
 
-Page::Page(PassRefPtr<ChromeClient> chromeClient, PassRefPtr<ContextMenuClient> contextMenuClient)
+Page::Page(ChromeClient* chromeClient, ContextMenuClient* contextMenuClient, EditorClient* editorClient)
     : m_dragCaretController(0, true)
     , m_chrome(this, chromeClient)
     , m_contextMenuController(this, contextMenuClient)
+    , m_editorClient(editorClient)
     , m_frameCount(0)
     , m_defersLoading(false)
 {
@@ -72,6 +74,8 @@ Page::~Page()
         Collector::collect();
 #endif
     }
+    
+    m_editorClient->pageDestroyed();
 }
 
 void Page::setMainFrame(PassRefPtr<Frame> mainFrame)
index eaf7383..c798b32 100644 (file)
@@ -36,6 +36,7 @@ namespace WebCore {
 
     class ChromeClient;
     class ContextMenuClient;
+    class EditorClient;
     class Frame;
     class FrameNamespace;
     class FloatRect;
@@ -44,8 +45,10 @@ namespace WebCore {
 
     class Page : Noncopyable {
     public:
-        Page(PassRefPtr<ChromeClient>, PassRefPtr<ContextMenuClient>);
+        Page(ChromeClient*, ContextMenuClient*, EditorClient*);
         ~Page();
+        
+        EditorClient* editorClient() const { return m_editorClient; }
 
         void setMainFrame(PassRefPtr<Frame>);
         Frame* mainFrame() const { return m_mainFrame.get(); }
@@ -81,6 +84,7 @@ namespace WebCore {
         Chrome m_chrome;
         ContextMenuController m_contextMenuController;
 
+        EditorClient* m_editorClient;
         RefPtr<Frame> m_mainFrame;
         int m_frameCount;
         String m_groupName;
diff --git a/WebCore/platform/AbstractShared.h b/WebCore/platform/AbstractShared.h
deleted file mode 100644 (file)
index 71c8b08..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * 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 1bcfd49..6578aec 100644 (file)
@@ -1,3 +1,19 @@
+2006-11-28  Geoffrey Garen  <ggaren@apple.com>
+
+        Reviewed by Adam.
+
+        Fixed <rdar://problem/4844848> REGRESSION: extra cross-library ref/deref 
+        calls cause .5% PLT regression.
+        
+        Changed ref/deref calls to a single 'xxxDestroyed' call. Moved EditorClient
+        from the Frame to the Page, since it's only responsible for
+        Webview-level delegate calls.
+        
+        I don't really love this design, but it fixes the regression and allows
+        a single WebKit object to implement multiple client interfaces.
+        
+        Layout tests pass.
+
 2006-11-27  Beth Dakin  <bdakin@apple.com>
 
         Reviewed by Adam.
index bf00703..ccfdcd1 100644 (file)
  */
 
 #import <WebCore/ChromeClient.h>
-#import <WebCore/Shared.h>
 #import <wtf/Forward.h>
 
 @class WebView;
 
-class WebChromeClient : public WebCore::ChromeClient, public WebCore::Shared<WebChromeClient> {
+class WebChromeClient : public WebCore::ChromeClient {
 public:
-    static PassRefPtr<WebChromeClient> create(WebView *webView);
-    
-    virtual void ref();
-    virtual void deref();
-
+    WebChromeClient(WebView *webView);
     WebView *webView() { return m_webView; }
     
+    virtual void chromeDestroyed();
+    
     virtual void setWindowRect(const WebCore::FloatRect&);
     virtual WebCore::FloatRect windowRect();
 
@@ -75,7 +72,5 @@ public:
     virtual void addMessageToConsole(const WebCore::String& message, unsigned int lineNumber, const WebCore::String& sourceID);
 
 private:
-    WebChromeClient(WebView *webView);
-    
     WebView *m_webView;
 };
index 9924912..dc331f0 100644 (file)
 
 using namespace WebCore;
 
-PassRefPtr<WebChromeClient> WebChromeClient::create(WebView *webView)
-{
-    return new WebChromeClient(webView);
-}
-
 WebChromeClient::WebChromeClient(WebView *webView) 
     : m_webView(webView)
 {
 }
 
-void WebChromeClient::ref() 
-{
-    Shared<WebChromeClient>::ref();
-}
-
-void WebChromeClient::deref()
+void WebChromeClient::chromeDestroyed()
 {
-    Shared<WebChromeClient>::deref();
+    delete this;
 }
 
 // These functions scale between window and WebView coordinates because JavaScript/DOM operations 
index 84b885d..572db95 100644 (file)
 
 @class WebView;
 
-class WebContextMenuClient : public WebCore::ContextMenuClient, public WebCore::Shared<WebContextMenuClient> {
+class WebContextMenuClient : public WebCore::ContextMenuClient {
 public:
-    static PassRefPtr<WebContextMenuClient> create(WebView *webView);
+    WebContextMenuClient(WebView *webView);
     
-    virtual void ref();
-    virtual void deref();
+    virtual void contextMenuDestroyed();
     
     virtual void addCustomContextMenuItems(WebCore::ContextMenu* menu);
     
@@ -50,7 +49,5 @@ public:
     WebView *webView() { return m_webView; }
         
 private:
-    WebContextMenuClient(WebView *webView);
-    
     WebView *m_webView;
 };
index 4781ac0..e39db96 100644 (file)
 
 using namespace WebCore;
 
-PassRefPtr<WebContextMenuClient> WebContextMenuClient::create(WebView *webView)
-{
-    return new WebContextMenuClient(webView);
-}
-
 WebContextMenuClient::WebContextMenuClient(WebView *webView) 
     : m_webView(webView)
 {
 }
 
-void WebContextMenuClient::ref() 
-{
-    Shared<WebContextMenuClient>::ref();
-}
-
-void WebContextMenuClient::deref()
+void WebContextMenuClient::contextMenuDestroyed()
 {
-    Shared<WebContextMenuClient>::deref();
+    delete this;
 }
 
 void WebContextMenuClient::addCustomContextMenuItems(ContextMenu* menu)
index a4c6839..5953252 100644 (file)
 
 #import <WebCore/EditorClient.h>
 #import <WebCore/RetainPtr.h>
-#import <WebCore/Shared.h>
 #import <wtf/Forward.h>
 
+@class WebView;
 @class WebEditorUndoTarget;
-@class WebFrame;
 
-class WebEditorClient : public WebCore::EditorClient, public WebCore::Shared<WebEditorClient> {
+class WebEditorClient : public WebCore::EditorClient {
 public:
-    static PassRefPtr<WebEditorClient> create();
-    ~WebEditorClient();
+    WebEditorClient(WebView *);
     
-    virtual void ref();
-    virtual void deref();
+    virtual void pageDestroyed();
 
-    void setWebFrame(WebFrame *webFrame);
-    
-    bool isGrammarCheckingEnabled();
-    bool isContinuousSpellCheckingEnabled();
-    int spellCheckerDocumentTag();
+    virtual bool isGrammarCheckingEnabled();
+    virtual bool isContinuousSpellCheckingEnabled();
+    virtual int spellCheckerDocumentTag();
 
-    bool selectWordBeforeMenuEvent();
-    bool isEditable();
+    virtual bool selectWordBeforeMenuEvent();
+    virtual bool isEditable();
 
-    bool shouldDeleteRange(WebCore::Range*);    
-    bool shouldShowDeleteInterface(WebCore::HTMLElement*);
+    virtual bool shouldDeleteRange(WebCore::Range*);    
+    virtual bool shouldShowDeleteInterface(WebCore::HTMLElement*);
 
-    bool shouldBeginEditing(WebCore::Range*);
-    bool shouldEndEditing(WebCore::Range*);
-    bool shouldInsertText(WebCore::String, WebCore::Range*, WebCore::EditorInsertAction);
+    virtual bool shouldBeginEditing(WebCore::Range*);
+    virtual bool shouldEndEditing(WebCore::Range*);
+    virtual bool shouldInsertText(WebCore::String, WebCore::Range*, WebCore::EditorInsertAction);
 
-    bool shouldApplyStyle(WebCore::CSSStyleDeclaration*, WebCore::Range*);
+    virtual bool shouldApplyStyle(WebCore::CSSStyleDeclaration*, WebCore::Range*);
 
-    void didBeginEditing();
-    void didEndEditing();
+    virtual void didBeginEditing();
+    virtual void didEndEditing();
 
-    void respondToChangedContents();
+    virtual void respondToChangedContents();
 
     virtual void registerCommandForUndo(PassRefPtr<WebCore::EditCommand>);
     virtual void registerCommandForRedo(PassRefPtr<WebCore::EditCommand>);
@@ -78,7 +73,7 @@ private:
     void registerCommandForUndoOrRedo(PassRefPtr<WebCore::EditCommand>, bool isRedo);
     WebEditorClient();
     
-    WebFrame *m_webFrame;
+    WebView *m_webView;
     WebCore::RetainPtr<WebEditorUndoTarget> m_undoTarget;
     
     bool m_haveUndoRedoOperations;
index d250e33..5fab93b 100644 (file)
@@ -123,42 +123,21 @@ WebViewInsertAction kit(EditorInsertAction coreAction)
 
 @end
 
-PassRefPtr<WebEditorClient> WebEditorClient::create()
+void WebEditorClient::pageDestroyed()
 {
-    return new WebEditorClient;
+    delete this;
 }
 
-WebEditorClient::WebEditorClient()
-    : m_webFrame(nil)
+WebEditorClient::WebEditorClient(WebView *webView)
+    : m_webView(webView)
     , m_undoTarget([[[WebEditorUndoTarget alloc] init] autorelease])
     , m_haveUndoRedoOperations(false)
 {
 }
 
-WebEditorClient::~WebEditorClient()
-{
-}
-
-void WebEditorClient::ref()
-{
-    Shared<WebEditorClient>::ref();
-}
-
-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;
-}
-
 bool WebEditorClient::isContinuousSpellCheckingEnabled()
 {
-    return [[m_webFrame webView] isContinuousSpellCheckingEnabled];
+    return [m_webView isContinuousSpellCheckingEnabled];
 }
 
 bool WebEditorClient::isGrammarCheckingEnabled()
@@ -166,46 +145,46 @@ bool WebEditorClient::isGrammarCheckingEnabled()
 #ifdef BUILDING_ON_TIGER
     return false;
 #else
-    return [[m_webFrame webView] isGrammarCheckingEnabled];
+    return [m_webView isGrammarCheckingEnabled];
 #endif
 }
 
 int WebEditorClient::spellCheckerDocumentTag()
 {
-    return [[m_webFrame webView] spellCheckerDocumentTag];
+    return [m_webView spellCheckerDocumentTag];
 }
 
 bool WebEditorClient::selectWordBeforeMenuEvent()
 {
-    return [[m_webFrame webView] _selectWordBeforeMenuEvent];
+    return [m_webView _selectWordBeforeMenuEvent];
 }
 
 bool WebEditorClient::isEditable()
 {
-    return [[m_webFrame webView] isEditable];
+    return [m_webView isEditable];
 }
 
 bool WebEditorClient::shouldDeleteRange(Range* range)
 {
-    return [[[m_webFrame webView] _editingDelegateForwarder] webView:[m_webFrame webView]
+    return [[m_webView _editingDelegateForwarder] webView:m_webView
         shouldDeleteDOMRange:kit(range)];
 }
 
 bool WebEditorClient::shouldShowDeleteInterface(HTMLElement* element)
 {
-    return [[[m_webFrame webView] _editingDelegateForwarder] webView:[m_webFrame webView]
+    return [[m_webView _editingDelegateForwarder] webView:m_webView
         shouldShowDeleteInterfaceForElement:kit(element)];
 }
 
 bool WebEditorClient::shouldApplyStyle(CSSStyleDeclaration* style, Range* range)
 {
-    return [[[m_webFrame webView] _editingDelegateForwarder] webView:[m_webFrame webView]
+    return [[m_webView _editingDelegateForwarder] webView:m_webView
         shouldApplyStyle:kit(style) toElementsInDOMRange:kit(range)];
 }
 
 bool WebEditorClient::shouldBeginEditing(Range* range)
 {
-    return [[[m_webFrame webView] _editingDelegateForwarder] webView:[m_webFrame webView]
+    return [[m_webView _editingDelegateForwarder] webView:m_webView
         shouldBeginEditingInDOMRange:kit(range)];
 
     return false;
@@ -213,32 +192,32 @@ bool WebEditorClient::shouldBeginEditing(Range* range)
 
 bool WebEditorClient::shouldEndEditing(Range* range)
 {
-    return [[[m_webFrame webView] _editingDelegateForwarder] webView:[m_webFrame webView]
+    return [[m_webView _editingDelegateForwarder] webView:m_webView
                              shouldEndEditingInDOMRange:kit(range)];
 }
 
 bool WebEditorClient::shouldInsertText(String text, Range* range, EditorInsertAction action)
 {
-    WebView* webView = [m_webFrame webView];
+    WebView* webView = m_webView;
     return [[webView _editingDelegateForwarder] webView:webView shouldInsertText:text replacingDOMRange:kit(range) givenAction:kit(action)];
 }
 
 void WebEditorClient::didBeginEditing()
 {
-    [[NSNotificationCenter defaultCenter] postNotificationName:WebViewDidBeginEditingNotification object:[m_webFrame webView]];
+    [[NSNotificationCenter defaultCenter] postNotificationName:WebViewDidBeginEditingNotification object:m_webView];
 }
 
 void WebEditorClient::respondToChangedContents()
 {
-    NSView <WebDocumentView> *view = [[m_webFrame frameView] documentView];
+    NSView <WebDocumentView> *view = [[[m_webView selectedFrame] frameView] documentView];
     if ([view isKindOfClass:[WebHTMLView class]])
         [(WebHTMLView *)view _updateFontPanel];
-    [[NSNotificationCenter defaultCenter] postNotificationName:WebViewDidChangeNotification object:[m_webFrame webView]];    
+    [[NSNotificationCenter defaultCenter] postNotificationName:WebViewDidChangeNotification object:m_webView];    
 }
 
 void WebEditorClient::didEndEditing()
 {
-    [[NSNotificationCenter defaultCenter] postNotificationName:WebViewDidEndEditingNotification object:[m_webFrame webView]];
+    [[NSNotificationCenter defaultCenter] postNotificationName:WebViewDidEndEditingNotification object:m_webView];
 }
 
 static NSString* undoNameForEditAction(EditAction editAction)
@@ -289,7 +268,7 @@ void WebEditorClient::registerCommandForUndoOrRedo(PassRefPtr<EditCommand> cmd,
 {
     ASSERT(cmd);
     
-    NSUndoManager *undoManager = [[m_webFrame webView] undoManager];
+    NSUndoManager *undoManager = [m_webView undoManager];
     NSString *actionName = undoNameForEditAction(cmd->editingAction());
     WebEditCommand *command = [WebEditCommand commandWithEditCommand:cmd];
     [undoManager registerUndoWithTarget:m_undoTarget.get() selector:(isRedo ? @selector(redoEditing:) : @selector(undoEditing:)) object:command];
@@ -314,7 +293,7 @@ void WebEditorClient::clearUndoRedoOperations()
         // workaround for <rdar://problem/4645507> NSUndoManager dies
         // with uncaught exception when undo items cleared while
         // groups are open
-        NSUndoManager *undoManager = [[m_webFrame webView] undoManager];
+        NSUndoManager *undoManager = [m_webView undoManager];
         int groupingLevel = [undoManager groupingLevel];
         for (int i = 0; i < groupingLevel; ++i)
             [undoManager endUndoGrouping];
@@ -330,24 +309,24 @@ void WebEditorClient::clearUndoRedoOperations()
 
 bool WebEditorClient::canUndo() const
 {
-    return [[[m_webFrame webView] undoManager] canUndo];
+    return [[m_webView undoManager] canUndo];
 }
 
 bool WebEditorClient::canRedo() const
 {
-    return [[[m_webFrame webView] undoManager] canRedo];
+    return [[m_webView undoManager] canRedo];
 }
 
 void WebEditorClient::undo()
 {
     if (canUndo())
-        [[[m_webFrame webView] undoManager] undo];
+        [[m_webView undoManager] undo];
 }
 
 void WebEditorClient::redo()
 {
     if (canRedo())
-        [[[m_webFrame webView] undoManager] redo];    
+        [[m_webView undoManager] redo];    
 }
 
 /*
index 0941fb6..c7702b7 100644 (file)
@@ -34,7 +34,6 @@
 #import "WebDataSourceInternal.h"
 #import "WebDefaultUIDelegate.h"
 #import "WebEditingDelegate.h"
-#import "WebEditorClient.h"
 #import "WebFormDelegate.h"
 #import "WebFrameInternal.h"
 #import "WebFrameLoadDelegate.h"
@@ -132,25 +131,15 @@ NSString *WebPluginContainerKey =   @"WebPluginContainer";
 
 - (id)initMainFrameWithPage:(WebCore::Page*)page frameName:(NSString *)name view:(WebFrameView *)view webView:(WebView *)webView
 {
-    RefPtr<WebEditorClient> editorClient = WebEditorClient::create();
-    self = [super initMainFrameWithPage:page withEditorClient:editorClient.get()];
+    self = [super initMainFrameWithPage:page];
     [self finishInitializingWithFrameName:name view:view];
-    
-    // FIXME: Need to clear the WebFrame pointer in WebEditorClient when the WebView is deallocated.
-    editorClient->setWebFrame([view webFrame]);
-
     return self;
 }
 
 - (id)initSubframeWithOwnerElement:(WebCoreElement *)ownerElement frameName:(NSString *)name view:(WebFrameView *)view
 {
-    RefPtr<WebEditorClient> editorClient = WebEditorClient::create();
-    self = [super initSubframeWithOwnerElement:ownerElement withEditorClient:editorClient.get()];
+    self = [super initSubframeWithOwnerElement:ownerElement];
     [self finishInitializingWithFrameName:name view:view];
-
-    // FIXME: Need to clear the WebFrame pointer in WebEditorClient when the WebView is deallocated.
-    editorClient->setWebFrame([view webFrame]);
-
     return self;
 }
 
index a2b2297..b03c7fd 100644 (file)
@@ -28,7 +28,6 @@
 
 #import <WebCore/FrameLoaderClient.h>
 #import <WebCore/RetainPtr.h>
-#import <WebCore/Shared.h>
 #import <WebCore/Timer.h>
 #import <wtf/Forward.h>
 #import <wtf/HashMap.h>
@@ -46,20 +45,16 @@ namespace WebCore {
 
 typedef HashMap<RefPtr<WebCore::ResourceLoader>, WebCore::RetainPtr<WebResource> > ResourceMap;
 
-class WebFrameLoaderClient : public WebCore::FrameLoaderClient, public WebCore::Shared<WebFrameLoaderClient> {
+class WebFrameLoaderClient : public WebCore::FrameLoaderClient {
 public:
-    static PassRefPtr<WebFrameLoaderClient> create(WebFrame*);
-
-    virtual void ref();
-    virtual void deref();
+    WebFrameLoaderClient(WebFrame*);
 
     WebFrame* webFrame() const { return m_webFrame.get(); }
 
+    virtual void frameLoaderDestroyed();
     void receivedPolicyDecison(WebCore::PolicyAction);
 
 private:
-    WebFrameLoaderClient(WebFrame*);
-
     virtual bool hasWebView() const; // mainly for assertions
     virtual bool hasFrameView() const; // ditto
 
index 982ac3c..9b9a258 100644 (file)
@@ -106,11 +106,6 @@ 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)
@@ -118,14 +113,9 @@ WebFrameLoaderClient::WebFrameLoaderClient(WebFrame *webFrame)
 {
 }
 
-void WebFrameLoaderClient::ref()
-{
-    Shared<WebFrameLoaderClient>::ref();
-}
-
-void WebFrameLoaderClient::deref()
+void WebFrameLoaderClient::frameLoaderDestroyed()
 {
-    Shared<WebFrameLoaderClient>::deref();
+    delete this;
 }
 
 bool WebFrameLoaderClient::hasWebView() const
index 263933d..0f7f84a 100644 (file)
@@ -836,7 +836,7 @@ WebView *getWebView(WebFrame *webFrame)
 
     ++WebFrameCount;
 
-    [self _frameLoader]->setClient(WebFrameLoaderClient::create(self));
+    [self _frameLoader]->setClient(new WebFrameLoaderClient(self));
 
     return self;
 }
index bf57ed8..825fdcb 100644 (file)
@@ -49,6 +49,7 @@
 #import "WebDownloadInternal.h"
 #import "WebDynamicScrollBarsView.h"
 #import "WebEditingDelegate.h"
+#import "WebEditorClient.h"
 #import "WebFormDelegatePrivate.h"
 #import "WebFrameBridge.h"
 #import "WebFrameInternal.h"
@@ -1821,7 +1822,7 @@ NSMutableDictionary *countInvocations;
     WebKitInitializeLoggingChannelsIfNecessary();
     WebCore::InitializeLoggingChannelsIfNecessary();
 
-    _private->page = new Page(WebChromeClient::create(self), WebContextMenuClient::create(self));
+    _private->page = new Page(new WebChromeClient(self), new WebContextMenuClient(self), new WebEditorClient(self));
     [[[WebFrameBridge alloc] initMainFrameWithPage:_private->page frameName:frameName view:frameView webView:self] release];
 
     [self _addToAllWebViewsSet];