WebCore:
authoraliceli1 <aliceli1@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 20 Oct 2006 23:57:05 +0000 (23:57 +0000)
committeraliceli1 <aliceli1@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 20 Oct 2006 23:57:05 +0000 (23:57 +0000)
        Reviewed by Maciej.

        This is the initial foundation for the EditingController class and
        everything else it needs to work.  The idea is that the Frame has an
        EditingController object that it calls to handle editing commands, the
        most simple examples being copy/paste.  This controller will handle
        these editing commands in WebCore, and only hand off to WebKit to call
        editing delegates (to the let the app intercept editing actions if it
        wants to).  Thus we need a platform-specific client to which the
        EditingController hands off the delegate calls,
        WebCoreEditingControllerClient.  On the WebCore side this is an
        abstract base class, and on the WebKit(Mac) side this is an ObjC++
        subclass, WebEditingControllerClient.  How does the EditingController
        get a handle to its platform-specific client?  In WebKit, the creator
        of a platform-specific Frame creates the client (which is ref-counted)
        and passes it down the chain of constructors until it gets back to the
        EditingController, which then refs it in its constructor and derefs in
        its destructor.

        No Layout tests needed.

        * WebCore.xcodeproj/project.pbxproj:
        Added files and made DomRangeInternal.h and EditingClient.h private headers, necessary for WebKit to compile

        * bridge/EditorClient.h: Added.
        (WebCore::EditorClient::~EditorClient):

        * bridge/mac/FrameMac.h:
        Added an EditingClient to the constructor, to pass down to Frame constructor

        * bridge/mac/FrameMac.mm:
        (WebCore::FrameMac::FrameMac):
        Passed client down to Frame constructor

        * bridge/mac/WebCoreFrameBridge.h:
        Added an EditingClient to the constructor, to pass down to FrameMac constructor

        * bridge/mac/WebCoreFrameBridge.mm:
        (-[WebCoreFrameBridge initMainFrameWithPage:withEditorClient:]):
        (-[WebCoreFrameBridge initSubframeWithOwnerElement:withEditorClient:]):
        Passed client down to FrameMac constructor

        * editing/Editor.cpp: Added.
        Mostly stuf implementations of the following functions, except for a couple.  These are all needed by cut, copy, paste, delete.
        (WebCore::generalPasteboard):
        (WebCore::Editor::canCopy):
        (WebCore::Editor::canCut):
        (WebCore::Editor::canDelete):
        (WebCore::Editor::canDeleteRange):
        (WebCore::Editor::canPaste):
        (WebCore::Editor::canSmartCopyOrDelete):
        (WebCore::Editor::deleteSelection):
        (WebCore::Editor::deleteSelectionWithSmartDelete):
        (WebCore::Editor::isSelectionRichlyEditable):
        (WebCore::Editor::pasteAsPlainTextWithPasteboard):
        (WebCore::Editor::pasteWithPasteboard):
        (WebCore::Editor::selectedRange):
        (WebCore::Editor::shouldDeleteRange):
        (WebCore::Editor::tryDHTMLCopy):
        (WebCore::Editor::tryDHTMLCut):
        (WebCore::Editor::tryDHTMLPaste):
        (WebCore::Editor::writeSelectionToPasteboard):
        (WebCore::Editor::Editor):
        (WebCore::Editor::~Editor):
        (WebCore::Editor::cut):
        (WebCore::Editor::copy):
        (WebCore::Editor::paste):
        (WebCore::Editor::performDelete):

        * editing/Editor.h: Added.

        * page/Frame.h:
        Added an EditingClient to the constructor, to pass down to Editor constructor

        * page/Frame.cpp:
        (WebCore::Frame::Frame):
        Passed down to Editor constructor
        (WebCore::Frame::editor):
        Accessfor for Editor stored in FramePrivate

        * page/FramePrivate.h:
        (WebCore::FramePrivate::FramePrivate):
        Added an Editor object to the FramePrivate data

        * platform/Sound.h: Added.
        Made a platform-independent accessor to a beep function

        * platform/mac/SoundMac.mm: Added.
        (WebCore::systemBeep):
        calls mac system beep

WebKit:

        Reviewed by Maciej.

        Adding knowledge of EditorClient to WebKit

        * WebCoreSupport/WebEditorClient.h: Added.

        * WebCoreSupport/WebEditorClient.mm: Added.
        (WebEditorClient::WebEditorClient):
        (WebEditorClient::~WebEditorClient):
        (WebEditorClient::shouldDeleteRange):
        Implementation of mac EditorClient

        * WebCoreSupport/WebFrameBridge.m:
        (-[WebFrameBridge initMainFrameWithPage:frameName:view:]):
        (-[WebFrameBridge initSubframeWithOwnerElement:frameName:view:]):
        create an editor client to pass down the chain of constructors

        * WebKit.xcodeproj/project.pbxproj:
        Added related EditorClient files

        * WebKitPrefix.h:
        Added tiger build flag in order to make certain private headers from webcore compile successfully

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

20 files changed:
WebCore/ChangeLog
WebCore/WebCore.xcodeproj/project.pbxproj
WebCore/bridge/EditorClient.h [new file with mode: 0644]
WebCore/bridge/mac/FrameMac.h
WebCore/bridge/mac/FrameMac.mm
WebCore/bridge/mac/WebCoreFrameBridge.h
WebCore/bridge/mac/WebCoreFrameBridge.mm
WebCore/editing/Editor.cpp [new file with mode: 0644]
WebCore/editing/Editor.h [new file with mode: 0644]
WebCore/page/Frame.cpp
WebCore/page/Frame.h
WebCore/page/FramePrivate.h
WebCore/platform/Sound.h [new file with mode: 0644]
WebCore/platform/mac/SoundMac.mm [new file with mode: 0644]
WebKit/ChangeLog
WebKit/WebCoreSupport/WebEditorClient.h [new file with mode: 0644]
WebKit/WebCoreSupport/WebEditorClient.mm [new file with mode: 0644]
WebKit/WebCoreSupport/WebFrameBridge.m
WebKit/WebKit.xcodeproj/project.pbxproj
WebKit/WebKitPrefix.h

index 5a88491690bff2bcbde77723ad0fe26345681489..19f03914bc04755346207b7f7a8876a1c3910f31 100644 (file)
@@ -1,3 +1,96 @@
+2006-10-20  Alice Liu  <alice.liu@apple.com>
+
+        Reviewed by Maciej.
+
+        This is the initial foundation for the EditingController class and
+        everything else it needs to work.  The idea is that the Frame has an
+        EditingController object that it calls to handle editing commands, the
+        most simple examples being copy/paste.  This controller will handle
+        these editing commands in WebCore, and only hand off to WebKit to call
+        editing delegates (to the let the app intercept editing actions if it
+        wants to).  Thus we need a platform-specific client to which the
+        EditingController hands off the delegate calls, 
+        WebCoreEditingControllerClient.  On the WebCore side this is an 
+        abstract base class, and on the WebKit(Mac) side this is an ObjC++
+        subclass, WebEditingControllerClient.  How does the EditingController
+        get a handle to its platform-specific client?  In WebKit, the creator
+        of a platform-specific Frame creates the client (which is ref-counted)
+        and passes it down the chain of constructors until it gets back to the
+        EditingController, which then refs it in its constructor and derefs in
+        its destructor.
+        
+        No Layout tests needed.
+        
+        * WebCore.xcodeproj/project.pbxproj:
+        Added files and made DomRangeInternal.h and EditingClient.h private headers, necessary for WebKit to compile
+
+        * bridge/EditorClient.h: Added.
+        (WebCore::EditorClient::~EditorClient):
+
+        * bridge/mac/FrameMac.h:
+        Added an EditingClient to the constructor, to pass down to Frame constructor
+
+        * bridge/mac/FrameMac.mm:
+        (WebCore::FrameMac::FrameMac):
+        Passed client down to Frame constructor
+        
+        * bridge/mac/WebCoreFrameBridge.h:
+        Added an EditingClient to the constructor, to pass down to FrameMac constructor
+        
+        * bridge/mac/WebCoreFrameBridge.mm:
+        (-[WebCoreFrameBridge initMainFrameWithPage:withEditorClient:]):
+        (-[WebCoreFrameBridge initSubframeWithOwnerElement:withEditorClient:]):
+        Passed client down to FrameMac constructor
+        
+        * editing/Editor.cpp: Added.
+        Mostly stuf implementations of the following functions, except for a couple.  These are all needed by cut, copy, paste, delete.
+        (WebCore::generalPasteboard):
+        (WebCore::Editor::canCopy):
+        (WebCore::Editor::canCut):
+        (WebCore::Editor::canDelete):
+        (WebCore::Editor::canDeleteRange):
+        (WebCore::Editor::canPaste):
+        (WebCore::Editor::canSmartCopyOrDelete):
+        (WebCore::Editor::deleteSelection):
+        (WebCore::Editor::deleteSelectionWithSmartDelete):
+        (WebCore::Editor::isSelectionRichlyEditable):
+        (WebCore::Editor::pasteAsPlainTextWithPasteboard):
+        (WebCore::Editor::pasteWithPasteboard):
+        (WebCore::Editor::selectedRange):
+        (WebCore::Editor::shouldDeleteRange):
+        (WebCore::Editor::tryDHTMLCopy):
+        (WebCore::Editor::tryDHTMLCut):
+        (WebCore::Editor::tryDHTMLPaste):
+        (WebCore::Editor::writeSelectionToPasteboard):
+        (WebCore::Editor::Editor):
+        (WebCore::Editor::~Editor):
+        (WebCore::Editor::cut):
+        (WebCore::Editor::copy):
+        (WebCore::Editor::paste):
+        (WebCore::Editor::performDelete):
+        
+        * editing/Editor.h: Added.
+        
+        * page/Frame.h:
+        Added an EditingClient to the constructor, to pass down to Editor constructor
+
+        * page/Frame.cpp:
+        (WebCore::Frame::Frame):
+        Passed down to Editor constructor
+        (WebCore::Frame::editor):
+        Accessfor for Editor stored in FramePrivate
+        
+        * page/FramePrivate.h:
+        (WebCore::FramePrivate::FramePrivate):
+        Added an Editor object to the FramePrivate data
+        
+        * platform/Sound.h: Added.
+        Made a platform-independent accessor to a beep function
+        
+        * platform/mac/SoundMac.mm: Added.
+        (WebCore::systemBeep):
+        calls mac system beep
+        
 2006-10-20  David Hyatt  <hyatt@apple.com>
 
         Make sure to support the "encoding" property on form elements for
index ffcb161abda47278cbcb97dc2e7a97e27003faf2..12ae72a574233633a52f5c52db817b404f872248 100644 (file)
                448A29BF0A46D9CB0030759F /* JSHTMLOptionsCollection.h in Headers */ = {isa = PBXBuildFile; fileRef = 448A29BD0A46D9CB0030759F /* JSHTMLOptionsCollection.h */; };
                448A29C00A46D9CB0030759F /* JSHTMLOptionsCollection.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 448A29BE0A46D9CB0030759F /* JSHTMLOptionsCollection.cpp */; };
                448AD27C0A48137A0023D179 /* JSHTMLOptionsCollectionCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 448AD27A0A4813790023D179 /* JSHTMLOptionsCollectionCustom.cpp */; };
+               4B3043B60AE0363200A82647 /* EditorClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B3043B50AE0363200A82647 /* EditorClient.h */; settings = {ATTRIBUTES = (Private, ); }; };
+               4B3043C70AE0370300A82647 /* Sound.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B3043C60AE0370300A82647 /* Sound.h */; };
+               4B3043C90AE0371D00A82647 /* SoundMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4B3043C80AE0371D00A82647 /* SoundMac.mm */; };
+               4B3043CC0AE0373B00A82647 /* Editor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B3043CA0AE0373B00A82647 /* Editor.cpp */; };
+               4B3043CD0AE0373B00A82647 /* Editor.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B3043CB0AE0373B00A82647 /* Editor.h */; };
                4BBDBF7D0ACC9290005F6E97 /* CommandByName.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4BBDBF7B0ACC9290005F6E97 /* CommandByName.cpp */; };
                4BBDBF7E0ACC9290005F6E97 /* CommandByName.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BBDBF7C0ACC9290005F6E97 /* CommandByName.h */; };
                4E1959210A39DABA00220FE5 /* MediaFeatureNames.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4E19591F0A39DABA00220FE5 /* MediaFeatureNames.cpp */; };
                8538F0300AD71CDB006A81D1 /* DOMAbstractView.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 8538F0160AD718D8006A81D1 /* DOMAbstractView.h */; };
                8538F05B0AD722F1006A81D1 /* DOMRange.h in Headers */ = {isa = PBXBuildFile; fileRef = 8538F0580AD722F1006A81D1 /* DOMRange.h */; };
                8538F05C0AD722F1006A81D1 /* DOMRange.mm in Sources */ = {isa = PBXBuildFile; fileRef = 8538F0590AD722F1006A81D1 /* DOMRange.mm */; };
-               8538F05D0AD722F1006A81D1 /* DOMRangeInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 8538F05A0AD722F1006A81D1 /* DOMRangeInternal.h */; };
+               8538F05D0AD722F1006A81D1 /* DOMRangeInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 8538F05A0AD722F1006A81D1 /* DOMRangeInternal.h */; settings = {ATTRIBUTES = (Private, ); }; };
                8538F0850AD72CB6006A81D1 /* DOMRanges.h in Headers */ = {isa = PBXBuildFile; fileRef = 8538F0840AD72CB6006A81D1 /* DOMRanges.h */; settings = {ATTRIBUTES = (Private, ); }; };
                8538F08C0AD72E0A006A81D1 /* DOMRange.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 8538F0580AD722F1006A81D1 /* DOMRange.h */; };
                853BF4DB0ABB6B55008647BB /* DOMNode.h in Headers */ = {isa = PBXBuildFile; fileRef = 853BF4D90ABB6B55008647BB /* DOMNode.h */; };
                448A29BD0A46D9CB0030759F /* JSHTMLOptionsCollection.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = JSHTMLOptionsCollection.h; sourceTree = "<group>"; };
                448A29BE0A46D9CB0030759F /* JSHTMLOptionsCollection.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = JSHTMLOptionsCollection.cpp; sourceTree = "<group>"; };
                448AD27A0A4813790023D179 /* JSHTMLOptionsCollectionCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSHTMLOptionsCollectionCustom.cpp; sourceTree = "<group>"; };
+               4B3043B50AE0363200A82647 /* EditorClient.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = EditorClient.h; sourceTree = "<group>"; };
+               4B3043C60AE0370300A82647 /* Sound.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = Sound.h; sourceTree = "<group>"; };
+               4B3043C80AE0371D00A82647 /* SoundMac.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = SoundMac.mm; sourceTree = "<group>"; };
+               4B3043CA0AE0373B00A82647 /* Editor.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = Editor.cpp; sourceTree = "<group>"; };
+               4B3043CB0AE0373B00A82647 /* Editor.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = Editor.h; sourceTree = "<group>"; };
                4BBDBF7B0ACC9290005F6E97 /* CommandByName.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CommandByName.cpp; sourceTree = "<group>"; };
                4BBDBF7C0ACC9290005F6E97 /* CommandByName.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CommandByName.h; sourceTree = "<group>"; };
                4E19591F0A39DABA00220FE5 /* MediaFeatureNames.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = MediaFeatureNames.cpp; sourceTree = "<group>"; };
                                9353676A09AED88B00D35CD6 /* ScrollViewMac.mm */,
                                93309E9F099EB78C0056E581 /* SharedTimerMac.cpp */,
                                BC86FB8E061F5C23006BB822 /* SliderMac.mm */,
+                               4B3043C80AE0371D00A82647 /* SoundMac.mm */,
                                84B2B24F056BF15F00D2B771 /* SSLKeyGeneratorMac.mm */,
                                93B0FD880A759BED0080AD44 /* StringImplMac.mm */,
                                93B0FD890A759BED0080AD44 /* StringMac.mm */,
                                65BF02350974819000C43196 /* mac */,
                                55998A5C052B59CC0017A6C1 /* AXObjectCache.h */,
                                BCEA4943097F0F5C0094C9E4 /* BrowserExtension.h */,
+                               4B3043B50AE0363200A82647 /* EditorClient.h */,
                                935C475C09AC4CA000A6AAB4 /* History.h */,
                                14FD6DFC0AE5EA1B00AD67AD /* WindowFeatures.h */,
                        );
                                93309D93099E64910056E581 /* EditAction.h */,
                                93309D94099E64910056E581 /* EditCommand.cpp */,
                                93309D95099E64910056E581 /* EditCommand.h */,
+                               4B3043CA0AE0373B00A82647 /* Editor.cpp */,
+                               4B3043CB0AE0373B00A82647 /* Editor.h */,
                                93309D98099E64910056E581 /* htmlediting.cpp */,
                                93309D99099E64910056E581 /* htmlediting.h */,
                                93309D96099E64910056E581 /* HTMLInterchange.cpp */,
                                BCFB2E830979FD4F00BA703D /* Shared.h */,
                                93309EA0099EB78C0056E581 /* SharedTimer.h */,
                                BC86FB8D061F5C23006BB822 /* Slider.h */,
+                               4B3043C60AE0370300A82647 /* Sound.h */,
                                F587866202DE3B1101EA4122 /* SSLKeyGenerator.h */,
                                9352071709BD3BA500F2038D /* StaticConstructors.h */,
                                657BD74909AFDC54005A2056 /* StreamingTextDecoder.cpp */,
                                93B77B1D0ADDA10700EA4B81 /* UChar.h in Headers */,
                                0668E18B0ADD9624004128E0 /* PopupMenu.h in Headers */,
                                6563A9A70ADF4094000ED2CD /* LoaderNSURLRequestExtras.h in Headers */,
+                               4B3043B60AE0363200A82647 /* EditorClient.h in Headers */,
+                               4B3043C70AE0370300A82647 /* Sound.h in Headers */,
+                               4B3043CD0AE0373B00A82647 /* Editor.h in Headers */,
                                14FFE31D0AE1963300136BF5 /* HTMLFrameElementBase.h in Headers */,
                                658436860AE01B7400E53753 /* FrameLoadRequest.h in Headers */,
                                14FD6DFD0AE5EA1B00AD67AD /* WindowFeatures.h in Headers */,
                                656D37490ADBA5DE00A4554D /* WebSubresourceLoader.mm in Sources */,
                                0668E1900ADD9640004128E0 /* PopupMenuMac.mm in Sources */,
                                6563A9A80ADF4094000ED2CD /* LoaderNSURLRequestExtras.m in Sources */,
+                               4B3043C90AE0371D00A82647 /* SoundMac.mm in Sources */,
+                               4B3043CC0AE0373B00A82647 /* Editor.cpp in Sources */,
                                14FFE31E0AE1963300136BF5 /* HTMLFrameElementBase.cpp in Sources */,
                                8542A7940AE5C94000DF58DF /* JSSVGRect.cpp in Sources */,
                                8542A7960AE5C94200DF58DF /* JSSVGPoint.cpp in Sources */,
diff --git a/WebCore/bridge/EditorClient.h b/WebCore/bridge/EditorClient.h
new file mode 100644 (file)
index 0000000..3c8aa72
--- /dev/null
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2006 Apple Computer, Inc.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#ifndef Editor_Client_h__
+#define Editor_Client_h__
+
+#include "Shared.h"
+
+namespace WebCore {
+
+class Range;
+
+class EditorClient : public Shared<EditorClient>{
+public:
+    virtual ~EditorClient() { }
+
+    virtual bool shouldDeleteRange(Range *range) = 0;
+//    virtual bool shouldBeginEditingInRange(Range *range) = 0;
+//    virtual bool shouldEndEditingInRange(Range *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 shouldApplyStyle(CSSStyleDeclaration *style, Range *toElementsInDOMRange) = 0;
+//    virtual bool shouldChangeTypingStyle(CSSStyleDeclaration *currentStyle, CSSStyleDeclaration *toProposedStyle) = 0;
+//    virtual bool doCommandBySelector(SEL selector) = 0;
+//
+//    virtual void webViewDidBeginEditing:(NSNotification *)notification = 0;
+//    virtual void webViewDidChange:(NSNotification *)notification = 0;
+//    virtual void webViewDidEndEditing:(NSNotification *)notification = 0;
+//    virtual void webViewDidChangeTypingStyle:(NSNotification *)notification = 0;
+//    virtual void webViewDidChangeSelection:(NSNotification *)notification = 0;
+//    virtual NSUndoManager* undoManagerForWebView:(WebView *)webView = 0;
+
+};
+
+}
+
+#endif // Editor_Client_h__
index 093194cc024c47c6cec3877998c2a607c3658145..7deed7040c51d1caa52795ef37f92773ec5d9ea8 100644 (file)
@@ -98,6 +98,7 @@ typedef int NSWritingDirection;
 namespace WebCore {
 
 class DocumentFragment;
+class EditorClient;
 class FramePrivate;
 class HTMLTableCellElement;
 class RenderObject;
@@ -114,7 +115,7 @@ enum SelectionDirection {
 class FrameMac : public Frame
 {
 public:
-    FrameMac(Page*, Element*);
+    FrameMac(Page*, Element*, EditorClient*);
     ~FrameMac();
     
     void clear();
index a03a685f113f4e2f3975affc6a122434fbdbd4b2..e18437dd442559234eafd085a6774c32b9b82ab6 100644 (file)
@@ -148,8 +148,8 @@ static SEL selectorForKeyEvent(const PlatformKeyboardEvent* event)
     return selector;
 }
 
-FrameMac::FrameMac(Page* page, Element* ownerElement)
-    : Frame(page, ownerElement)
+FrameMac::FrameMac(Page* page, Element* ownerElement, EditorClient* client)
+    : Frame(page, ownerElement, client)
     , _bridge(nil)
     , _mouseDownView(nil)
     , _sendingEventToSubview(false)
index 5a26add8ef09fdd4741903dd78ca23cf83ce4630..4c82ac808629b69322a88d29022c5739c6606d7b 100644 (file)
 namespace WebCore {
     class FrameMac;
     class Element;
+    class EditorClient;
 }
 
 typedef WebCore::FrameMac WebCoreMacFrame;
 typedef WebCore::Element WebCoreElement;
+typedef WebCore::EditorClient WebCoreEditorClient;
 
 #else
 
 @class NSMenu;
 @class WebCoreMacFrame;
 @class WebCoreElement;
+@class WebCoreEditorClient;
 
 #endif
 
@@ -192,8 +195,8 @@ typedef enum {
 
 + (WebCoreFrameBridge *)bridgeForDOMDocument:(DOMDocument *)document;
 
-- (id)initMainFrameWithPage:(WebCorePageBridge *)page;
-- (id)initSubframeWithOwnerElement:(WebCoreElement *)ownerElement;
+- (id)initMainFrameWithPage:(WebCorePageBridge *)page withEditorClient:(WebCoreEditorClient *)client;
+- (id)initSubframeWithOwnerElement:(WebCoreElement *)ownerElement withEditorClient:(WebCoreEditorClient *)client;
 
 - (void)close;
 
index 0238748d44625b1faf94b36c6a185c1e6802683b..2482102c302180741623c5076d43496c722b797f 100644 (file)
@@ -37,6 +37,7 @@
 #import "DocLoader.h"
 #import "DocumentFragment.h"
 #import "DocumentType.h"
+#import "EditorClient.h"
 #import "FloatRect.h"
 #import "FoundationExtras.h"
 #import "FrameMac.h"
@@ -470,7 +471,7 @@ static inline WebCoreFrameBridge *bridge(Frame *frame)
     return bridge([document _document]->frame());
 }
 
-- (id)initMainFrameWithPage:(WebCorePageBridge *)page
+- (id)initMainFrameWithPage:(WebCorePageBridge *)page withEditorClient:(WebCoreEditorClient *)client
 {
     if (!initializedKJS) {
         mainThread = pthread_self();
@@ -482,7 +483,7 @@ static inline WebCoreFrameBridge *bridge(Frame *frame)
     if (!(self = [super init]))
         return nil;
 
-    m_frame = new FrameMac([page impl], 0);
+    m_frame = new FrameMac([page impl], 0, client);
     m_frame->setBridge(self);
     _shouldCreateRenderers = YES;
 
@@ -498,12 +499,12 @@ static inline WebCoreFrameBridge *bridge(Frame *frame)
     return self;
 }
 
-- (id)initSubframeWithOwnerElement:(Element *)ownerElement
+- (id)initSubframeWithOwnerElement:(Element *)ownerElement withEditorClient:(WebCoreEditorClient *)client
 {
     if (!(self = [super init]))
         return nil;
     
-    m_frame = new FrameMac(ownerElement->document()->frame()->page(), ownerElement);
+    m_frame = new FrameMac(ownerElement->document()->frame()->page(), ownerElement, client);
     m_frame->setBridge(self);
     _shouldCreateRenderers = YES;
 
diff --git a/WebCore/editing/Editor.cpp b/WebCore/editing/Editor.cpp
new file mode 100644 (file)
index 0000000..c6da534
--- /dev/null
@@ -0,0 +1,195 @@
+/*
+ * Copyright (C) 2006 Apple Computer, Inc.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#include "config.h"
+#include "Editor.h"
+
+#include "Frame.h"
+#include "Range.h"
+#include "Sound.h"
+#include "EditorClient.h"
+
+namespace WebCore {
+
+// implement as platform-specific
+Pasteboard generalPasteboard()
+{
+    return 0;
+}
+
+bool Editor::canCopy()
+{ return false; }
+
+bool Editor::canCut()
+{ return false; }
+
+bool Editor::canDelete()
+{ return false; }
+
+bool Editor::canDeleteRange(Range* range)
+{
+    ExceptionCode ec = 0;
+    Node *startContainer = range->startContainer(ec);
+    Node *endContainer = range->endContainer(ec);
+    if (!startContainer || !endContainer)
+        return false;
+    
+    if (!startContainer->isContentEditable() || !endContainer->isContentEditable())
+        return false;
+    
+    if (range->collapsed(ec)) {
+        VisiblePosition start(startContainer, range->startOffset(ec), DOWNSTREAM);
+        VisiblePosition previous = start.previous();
+        // FIXME: We sometimes allow deletions at the start of editable roots, like when the caret is in an empty list item.
+        if (previous.isNull() || previous.deepEquivalent().node()->rootEditableElement() != startContainer->rootEditableElement())
+            return false;
+    }
+    return true;
+}
+
+bool Editor::canPaste()
+{ return false; }
+
+bool Editor::canSmartCopyOrDelete()
+{ return false; }
+
+void Editor::deleteSelection()
+{}
+
+void Editor::deleteSelectionWithSmartDelete(bool enabled)
+{}
+
+bool Editor::isSelectionRichlyEditable()
+{ return false; }
+
+void Editor::pasteAsPlainTextWithPasteboard(Pasteboard pasteboard)
+{}
+
+void Editor::pasteWithPasteboard(Pasteboard pasteboard, bool allowPlainText)
+{}
+
+Range* Editor::selectedRange()
+{ return NULL; }
+
+bool Editor::shouldDeleteRange(Range* range)
+{
+    ExceptionCode ec;
+    if (!range || range->collapsed(ec))
+        return false;
+    
+    if (!canDeleteRange(range))
+        return false;
+
+    return m_client->shouldDeleteRange(range);
+ }
+
+bool Editor::tryDHTMLCopy()
+{
+    bool handled = false;
+    return handled;
+}
+
+bool Editor::tryDHTMLCut()
+{
+    bool handled = false;
+    return handled;
+}
+
+bool Editor::tryDHTMLPaste()
+{
+    bool handled = false;
+    return handled;
+}
+
+void Editor::writeSelectionToPasteboard(Pasteboard pasteboard)
+{}
+
+// =============================================================================
+//
+// public editing commands
+//
+// =============================================================================
+
+Editor::Editor(Frame* frame, EditorClient* client)
+    : m_frame(frame)
+    , m_client(client)
+{ 
+    m_client->ref();
+}
+
+Editor::~Editor()
+{
+    m_client->deref();
+}
+
+void Editor::cut()
+{
+    if (tryDHTMLCut())
+        return; // DHTML did the whole operation
+    if (!canCut()) {
+        systemBeep();
+        return;
+    }
+    
+    if (shouldDeleteRange(selectedRange())) {
+        writeSelectionToPasteboard(generalPasteboard());
+        deleteSelectionWithSmartDelete(canSmartCopyOrDelete());
+    }
+}
+
+void Editor::copy()
+{
+
+    if (tryDHTMLCopy())
+        return; // DHTML did the whole operation
+    if (!canCopy()) {
+        systemBeep();
+        return;
+    }
+    writeSelectionToPasteboard(generalPasteboard());
+}
+
+void Editor::paste()
+{
+    if (tryDHTMLPaste())
+        return;     // DHTML did the whole operation
+    if (!canPaste())
+        return;
+    if (isSelectionRichlyEditable())
+        pasteWithPasteboard(generalPasteboard(), true);
+    else
+        pasteAsPlainTextWithPasteboard(generalPasteboard());
+}
+
+void Editor::performDelete()
+{
+    if (!canDelete()) {
+        systemBeep();
+        return;
+    }
+    deleteSelection();
+}
+
+} // namespace WebCore
diff --git a/WebCore/editing/Editor.h b/WebCore/editing/Editor.h
new file mode 100644 (file)
index 0000000..469b666
--- /dev/null
@@ -0,0 +1,74 @@
+/*
+ * Copyright (C) 2006 Apple Computer, Inc.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#ifndef editor_h__
+#define editor_h__
+
+namespace WebCore {
+
+class Frame;
+class Range;
+class EditorClient;
+
+// make platform-specific and implement - this is temporary placeholder
+typedef int Pasteboard;
+
+class Editor {
+public:
+    Editor(Frame* frame, EditorClient* client);
+    ~Editor();
+
+    void cut();
+    void copy();
+    void paste();
+    void performDelete();
+
+private:
+    Frame* m_frame;
+    EditorClient* m_client;
+    
+    bool canCopy();
+    bool canCut();
+    bool canDelete();
+    bool canDeleteRange(Range* range);
+    bool canPaste();
+    bool canSmartCopyOrDelete();
+    bool isSelectionRichlyEditable();
+    Range* selectedRange();
+    bool shouldDeleteRange(Range* range);
+    bool tryDHTMLCopy();
+    bool tryDHTMLCut();
+    bool tryDHTMLPaste();
+    void deleteSelection();
+    void deleteSelectionWithSmartDelete(bool enabled);
+    void pasteAsPlainTextWithPasteboard(Pasteboard pasteboard);
+    void pasteWithPasteboard(Pasteboard pasteboard, bool allowPlainText);
+    void writeSelectionToPasteboard(Pasteboard pasteboard);
+
+};
+
+} // namespace WebCore
+
+#endif // editor_h__
index 9012c743209484eb77cd31227ea22f0ed1cd8dc7..9703e877d3754387caaf455089167c1ed8379146 100644 (file)
@@ -158,8 +158,8 @@ static inline Frame* parentFromOwnerElement(Element* ownerElement)
     return ownerElement->document()->frame();
 }
 
-Frame::Frame(Page* page, Element* ownerElement) 
-    : d(new FramePrivate(page, parentFromOwnerElement(ownerElement), this, ownerElement))
+Frame::Frame(Page* page, Element* ownerElement, EditorClient* client
+    : d(new FramePrivate(page, parentFromOwnerElement(ownerElement), this, ownerElement, client))
 {
     AtomicString::init();
     EventNames::init();
@@ -1238,6 +1238,11 @@ SelectionController* Frame::selectionController() const
     return &(d->m_selectionController);
 }
 
+Editor* Frame::editor() const
+{
+    return &(d->m_editor);
+}
+
 CommandByName* Frame::command() const
 {
     return &(d->m_command);
index c18c95109444c6b2bfc3ce4c83c3c6b137621fff..09d0ec4ee7061430f64d25b4940d6b883871b2fd 100644 (file)
@@ -62,6 +62,8 @@ class CSSStyleDeclaration;
 class DrawContentsEvent;
 class DOMWindow;
 class EditCommand;
+class Editor;
+class EditorClient;
 class FormData;
 class FramePrivate;
 class FrameLoadRequest;
@@ -102,7 +104,7 @@ class Frame : public Shared<Frame> {
 public:
   enum { NoXPosForVerticalArrowNavigation = INT_MIN };
 
-  Frame(Page*, Element*);
+  Frame(Page*, Element*, EditorClient*);
   virtual ~Frame();
 
   virtual bool openURL(const KURL&);
@@ -833,7 +835,7 @@ public:
   SelectionController* selectionController() const;
   SelectionController* dragCaretController() const;
   DOMWindow* domWindow() const;
-
+  Editor* editor() const;
   CommandByName* command() const;
  private:
   friend class FramePrivate;
index 214bb924add45afcbdc411acd228a27be134c496..7d01268af851b1ddc5efeae30118a844b2346aa5 100644 (file)
@@ -34,6 +34,7 @@
 #include "DOMWindow.h"
 #include "Decoder.h"
 #include "EditCommand.h"
+#include "Editor.h"
 #include "FormData.h"
 #include "Frame.h"
 #include "FrameTree.h"
@@ -60,7 +61,7 @@ namespace WebCore {
     
     class FramePrivate {
     public:
-        FramePrivate(Page* page, Frame* parent, Frame* thisFrame, Element* ownerElement)
+        FramePrivate(Page* page, Frame* parent, Frame* thisFrame, Element* ownerElement, EditorClient* client)
             : m_page(page)
             , m_treeNode(thisFrame, parent)
             , m_ownerElement(ownerElement)
@@ -88,6 +89,7 @@ namespace WebCore {
             , m_bMousePressed(false)
             , m_selectionController(thisFrame)
             , m_caretBlinkTimer(thisFrame, &Frame::caretBlinkTimerFired)
+            , m_editor(thisFrame, client)
             , m_command(thisFrame)
             , m_caretVisible(false)
             , m_caretPaint(true)
@@ -198,7 +200,7 @@ namespace WebCore {
         SelectionController m_selectionController;
         Selection m_mark;
         Timer<Frame> m_caretBlinkTimer;
-
+        Editor m_editor;
         CommandByName m_command;
 
         bool m_caretVisible : 1;
diff --git a/WebCore/platform/Sound.h b/WebCore/platform/Sound.h
new file mode 100644 (file)
index 0000000..d982526
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 2006 Apple Computer, Inc.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#ifndef WebCoreSound_h
+#define WebCoreSound_h
+
+namespace WebCore {
+
+    void systemBeep();
+
+} // namespace WebCore
+
+#endif // WebCoreSound_h
diff --git a/WebCore/platform/mac/SoundMac.mm b/WebCore/platform/mac/SoundMac.mm
new file mode 100644 (file)
index 0000000..ced14b8
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2006 Apple Computer, Inc.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "config.h"
+#import "Sound.h"
+
+namespace WebCore {
+
+void systemBeep() { NSBeep(); }
+
+} // namespace WebCore
index 1ed68ae5b7d3c5d75be360d9032cf7bb1df79a12..9b9ef67b6bf5d39231685e5cfeb0a176e6907f96 100644 (file)
@@ -1,3 +1,28 @@
+2006-10-20  Alice Liu  <alice.liu@apple.com>
+
+        Reviewed by Maciej.
+
+        Adding knowledge of EditorClient to WebKit
+
+        * WebCoreSupport/WebEditorClient.h: Added.
+
+        * WebCoreSupport/WebEditorClient.mm: Added.
+        (WebEditorClient::WebEditorClient):
+        (WebEditorClient::~WebEditorClient):
+        (WebEditorClient::shouldDeleteRange):
+        Implementation of mac EditorClient
+
+        * WebCoreSupport/WebFrameBridge.m:
+        (-[WebFrameBridge initMainFrameWithPage:frameName:view:]):
+        (-[WebFrameBridge initSubframeWithOwnerElement:frameName:view:]):
+        create an editor client to pass down the chain of constructors
+
+        * WebKit.xcodeproj/project.pbxproj:
+        Added related EditorClient files
+
+        * WebKitPrefix.h:
+        Added tiger build flag in order to make certain private headers from webcore compile successfully
+
 2006-10-20  Darin Adler  <darin@apple.com>
 
         - rolled out my loader change; caused world leak and possibly a plug-in crash
diff --git a/WebKit/WebCoreSupport/WebEditorClient.h b/WebKit/WebCoreSupport/WebEditorClient.h
new file mode 100644 (file)
index 0000000..f171e81
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2006 Apple Computer, Inc.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1.  Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer. 
+ * 2.  Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution. 
+ * 3.  Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+ *     its contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import <WebCore/EditorClient.h>
+
+@class WebView;
+
+class WebEditorClient : public WebCore::EditorClient
+{
+public:
+    WebEditorClient(WebView* webView);
+    ~WebEditorClient();
+
+    bool shouldDeleteRange(WebCore::Range *range);    
+//    bool shouldBeginEditingInRange(Range *range);
+//    bool shouldEndEditingInRange(Range *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(CSSStyleDeclaration *style, Range *toElementsInDOMRange);
+//    bool shouldChangeTypingStyle(CSSStyleDeclaration *currentStyle, CSSStyleDeclaration *toProposedStyle);
+//    bool doCommandBySelector(SEL selector);
+
+//    void webViewDidBeginEditing:(NSNotification *)notification;
+//    void webViewDidChange:(NSNotification *)notification;
+//    void webViewDidEndEditing:(NSNotification *)notification;
+//    void webViewDidChangeTypingStyle:(NSNotification *)notification;
+//    void webViewDidChangeSelection:(NSNotification *)notification;
+//    NSUndoManager* undoManagerForWebView:(WebView *)webView;
+
+private:
+    WebView *m_webView;
+};
diff --git a/WebKit/WebCoreSupport/WebEditorClient.mm b/WebKit/WebCoreSupport/WebEditorClient.mm
new file mode 100644 (file)
index 0000000..de403a0
--- /dev/null
@@ -0,0 +1,70 @@
+/*
+ * Copyright (C) 2006 Apple Computer, Inc.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1.  Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer. 
+ * 2.  Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution. 
+ * 3.  Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+ *     its contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "WebEditorClient.h"
+
+#import "WebView.h"
+#import "WebViewInternal.h"
+#import <WebCore/DOMRangeInternal.h>
+#import "WebEditingDelegate.h"
+
+using namespace WebCore;
+
+WebEditorClient::WebEditorClient(WebView* webView)
+    : m_webView(webView) 
+{
+    [m_webView retain];
+}
+
+WebEditorClient::~WebEditorClient()
+{
+    [m_webView release];
+}
+
+bool WebEditorClient::shouldDeleteRange(Range *range)
+{
+    return [[m_webView _editingDelegateForwarder] webView:m_webView shouldDeleteDOMRange:[DOMRange _rangeWith:range]];
+}
+
+/*
+bool WebEditorClient::shouldBeginEditingInRange(Range *range) { return false; }
+bool WebEditorClient::shouldEndEditingInRange(Range *range) { return false; }
+bool WebEditorClient::shouldInsertNode(Node *node, Range* replacingRange, WebViewInsertAction givenAction) { return false; }
+bool WebEditorClient::shouldInsertText(NSString *text, Range *replacingRange, WebViewInsertActiongivenAction) { return false; }
+bool WebEditorClient::shouldChangeSelectedRange(Range *currentRange, Range *toProposedRange, NSSelectionAffinity selectionAffinity, bool stillSelecting) { return false; }
+bool WebEditorClient::shouldApplyStyle(CSSStyleDeclaration *style, Range *toElementsInDOMRange) { return false; }
+bool WebEditorClient::shouldChangeTypingStyle(CSSStyleDeclaration *currentStyle, CSSStyleDeclaration *toProposedStyle) { return false; }
+bool WebEditorClient::doCommandBySelector(SEL selector) { return false; }
+
+void WebEditorClient::webViewDidBeginEditing:(NSNotification *)notification { }
+void WebEditorClient::webViewDidChange:(NSNotification *)notification { }
+void WebEditorClient::webViewDidEndEditing:(NSNotification *)notification { }
+void WebEditorClient::webViewDidChangeTypingStyle:(NSNotification *)notification { }
+void WebEditorClient::webViewDidChangeSelection:(NSNotification *)notification { }
+NSUndoManager* WebEditorClient::undoManagerForWebView:(WebView *)webView { return NULL; }
+*/
index 17387e8f00503871ed37289cf10a1d200a38c6b8..482298c1d53c01ef529a0c8a3dad0d4ad04aae7e 100644 (file)
@@ -34,6 +34,7 @@
 #import "WebDataSourceInternal.h"
 #import "WebDefaultUIDelegate.h"
 #import "WebEditingDelegate.h"
+#import "WebEditorClient.h"
 #import "WebFormDelegate.h"
 #import "WebFrameInternal.h"
 #import "WebFrameLoadDelegate.h"
@@ -118,7 +119,7 @@ NSString *WebPluginContainerKey =   @"WebPluginContainer";
 
 - (id)initMainFrameWithPage:(WebPageBridge *)page frameName:(NSString *)name view:(WebFrameView *)view
 {
-    self = [super initMainFrameWithPage:page];
+    self = [super initMainFrameWithPage:page withEditorClient:new WebEditorClient([view _webView])];
     _frame = [[WebFrame alloc] _initWithWebFrameView:view webView:[self webView] bridge:self];
 
     ++WebBridgeCount;
@@ -132,7 +133,7 @@ NSString *WebPluginContainerKey =   @"WebPluginContainer";
 
 - (id)initSubframeWithOwnerElement:(WebCoreElement *)ownerElement frameName:(NSString *)name view:(WebFrameView *)view
 {
-    self = [super initSubframeWithOwnerElement:ownerElement];
+    self = [super initSubframeWithOwnerElement:ownerElement withEditorClient:new WebEditorClient([view _webView])];
     _frame = [[WebFrame alloc] _initWithWebFrameView:view webView:[self webView] bridge:self];
 
     ++WebBridgeCount;
index 510d2bed68710cb75c25639387b0bae0fd3c602c..1bfe5ed57e8867f2eb4003c6da8f7cb3b98a1911 100644 (file)
@@ -34,6 +34,8 @@
                22E42A4F0A5B9F620003275B /* OpenGL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 22E42A4E0A5B9F620003275B /* OpenGL.framework */; };
                22E42A9A0A5BA4D00003275B /* AGL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 22E42A990A5BA4D00003275B /* AGL.framework */; };
                22F219CC08D236730030E078 /* WebBackForwardListPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = 22F219CB08D236730030E078 /* WebBackForwardListPrivate.h */; settings = {ATTRIBUTES = (Private, ); }; };
+               4BF99F900AE050BC00815C2B /* WebEditorClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BF99F8E0AE050BC00815C2B /* WebEditorClient.h */; };
+               4BF99F910AE050BC00815C2B /* WebEditorClient.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4BF99F8F0AE050BC00815C2B /* WebEditorClient.mm */; };
                51B2A1000ADB15D0002A9BEE /* WebIconDatabaseDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = 51B2A0FF0ADB15D0002A9BEE /* WebIconDatabaseDelegate.h */; };
                51E4D3990A886B5E00ECEE2C /* WebIconDatabaseBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 51E4D3970A886B5E00ECEE2C /* WebIconDatabaseBridge.h */; };
                51E4D39A0A886B5E00ECEE2C /* WebIconDatabaseBridge.m in Sources */ = {isa = PBXBuildFile; fileRef = 51E4D3980A886B5E00ECEE2C /* WebIconDatabaseBridge.m */; };
                3944607E020F50ED0ECA1767 /* WebBackForwardList.m */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.objc; path = WebBackForwardList.m; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
                3944607F020F50ED0ECA1767 /* WebHistoryItem.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = WebHistoryItem.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
                39446080020F50ED0ECA1767 /* WebHistoryItem.m */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.objc; path = WebHistoryItem.m; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
+               4BF99F8E0AE050BC00815C2B /* WebEditorClient.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = WebEditorClient.h; sourceTree = "<group>"; };
+               4BF99F8F0AE050BC00815C2B /* WebEditorClient.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = WebEditorClient.mm; sourceTree = "<group>"; };
                513D422E034CF55A00CA2ACD /* WebResourceLoadDelegate.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = WebResourceLoadDelegate.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
                51443F9A0429392B00CA2D3A /* WebPolicyDelegate.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = WebPolicyDelegate.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
                51443F9B0429392B00CA2D3A /* WebPolicyDelegate.m */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.objcpp; fileEncoding = 30; indentWidth = 4; path = WebPolicyDelegate.m; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
                F5B36B400281DE87018635CB /* WebCoreSupport */ = {
                        isa = PBXGroup;
                        children = (
+                               4BF99F8E0AE050BC00815C2B /* WebEditorClient.h */,
+                               4BF99F8F0AE050BC00815C2B /* WebEditorClient.mm */,
                                51E4D3970A886B5E00ECEE2C /* WebIconDatabaseBridge.h */,
                                51E4D3980A886B5E00ECEE2C /* WebIconDatabaseBridge.m */,
                                65C7F42A0979DE640022E453 /* WebPageBridge.h */,
                                65FFB7FC0AD0B7D30048CD05 /* WebDocumentLoaderMac.h in Headers */,
                                658BA6FC0ADB39DE00AEB387 /* WebPolicyDeciderMac.h in Headers */,
                                51B2A1000ADB15D0002A9BEE /* WebIconDatabaseDelegate.h in Headers */,
+                               4BF99F900AE050BC00815C2B /* WebEditorClient.h in Headers */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
                                1C0D40880AC1C8F40009C113 /* WebKitVersionChecks.m in Sources */,
                                65FFB7FD0AD0B7D30048CD05 /* WebDocumentLoaderMac.m in Sources */,
                                658BA6FD0ADB39DE00AEB387 /* WebPolicyDeciderMac.m in Sources */,
+                               4BF99F910AE050BC00815C2B /* WebEditorClient.mm in Sources */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
index faebb3a2dc5e2471643a9aead7936df69b643419..d05164715a21cb46ff9a43fe05169044305a8e9d 100644 (file)
@@ -58,6 +58,9 @@
 
 #ifdef __OBJC__
 #import <Cocoa/Cocoa.h>
+#if MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_4
+#define BUILDING_ON_TIGER 1
+#endif
 #endif
 
 #include <JavaScriptCore/Platform.h>