Commit 5a36ed98 authored by aliceli1's avatar aliceli1

WebCore:

        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: http://svn.webkit.org/repository/webkit/trunk@17179 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 5b82484e
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
......@@ -237,6 +237,11 @@
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 */; };
......@@ -639,7 +644,7 @@
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 */; };
......@@ -3107,6 +3112,11 @@
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>"; };
......@@ -6358,6 +6368,7 @@
9353676A09AED88B00D35CD6 /* ScrollViewMac.mm */,
93309E9F099EB78C0056E581 /* SharedTimerMac.cpp */,
BC86FB8E061F5C23006BB822 /* SliderMac.mm */,
4B3043C80AE0371D00A82647 /* SoundMac.mm */,
84B2B24F056BF15F00D2B771 /* SSLKeyGeneratorMac.mm */,
93B0FD880A759BED0080AD44 /* StringImplMac.mm */,
93B0FD890A759BED0080AD44 /* StringMac.mm */,
......@@ -6418,6 +6429,7 @@
65BF02350974819000C43196 /* mac */,
55998A5C052B59CC0017A6C1 /* AXObjectCache.h */,
BCEA4943097F0F5C0094C9E4 /* BrowserExtension.h */,
4B3043B50AE0363200A82647 /* EditorClient.h */,
935C475C09AC4CA000A6AAB4 /* History.h */,
14FD6DFC0AE5EA1B00AD67AD /* WindowFeatures.h */,
);
......@@ -7367,6 +7379,8 @@
93309D93099E64910056E581 /* EditAction.h */,
93309D94099E64910056E581 /* EditCommand.cpp */,
93309D95099E64910056E581 /* EditCommand.h */,
4B3043CA0AE0373B00A82647 /* Editor.cpp */,
4B3043CB0AE0373B00A82647 /* Editor.h */,
93309D98099E64910056E581 /* htmlediting.cpp */,
93309D99099E64910056E581 /* htmlediting.h */,
93309D96099E64910056E581 /* HTMLInterchange.cpp */,
......@@ -8509,6 +8523,7 @@
BCFB2E830979FD4F00BA703D /* Shared.h */,
93309EA0099EB78C0056E581 /* SharedTimer.h */,
BC86FB8D061F5C23006BB822 /* Slider.h */,
4B3043C60AE0370300A82647 /* Sound.h */,
F587866202DE3B1101EA4122 /* SSLKeyGenerator.h */,
9352071709BD3BA500F2038D /* StaticConstructors.h */,
657BD74909AFDC54005A2056 /* StreamingTextDecoder.cpp */,
......@@ -10398,6 +10413,9 @@
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 */,
......@@ -11630,6 +11648,8 @@
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 */,
/*
* 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__
......@@ -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();
......
......@@ -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)
......
......@@ -33,16 +33,19 @@
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;
......
......@@ -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;
......
/*
* 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
/*
* 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__
......@@ -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);
......
......@@ -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;
......
......@@ -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;