WebCore:
authorandersca <andersca@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 9 Nov 2006 00:51:35 +0000 (00:51 +0000)
committerandersca <andersca@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 9 Nov 2006 00:51:35 +0000 (00:51 +0000)
        Reviewed by Adam.

        Move more code into editor.

        * WebCore.exp:
        * bridge/EditorClient.h:
        * bridge/mac/FrameMac.h:
        * bridge/mac/FrameMac.mm:
        * bridge/mac/WebCoreFrameBridge.h:
        * dom/Document.cpp:
        (WebCore::Document::relinquishesEditingFocus):
        (WebCore::Document::acceptsEditingFocus):
        (WebCore::Document::didBeginEditing):
        (WebCore::Document::didEndEditing):
        * editing/Editor.cpp:
        (WebCore::Editor::indent):
        (WebCore::Editor::outdent):
        * editing/Editor.h:
        * page/Frame.cpp:
        * page/Frame.h:

WebKit:

        Reviewed by Adam.

        Move more code into editor.

        * WebCoreSupport/WebEditorClient.h:
        * WebCoreSupport/WebEditorClient.mm:
        (WebEditorClient::shouldBeginEditing):
        (WebEditorClient::shouldEndEditing):
        (WebEditorClient::didBeginEditing):
        (WebEditorClient::didEndEditing):
        * WebCoreSupport/WebFrameBridge.mm:
        * WebView/WebHTMLView.m:
        (-[NSArray indent:]):
        (-[NSArray outdent:]):
        * WebView/WebView.mm:
        * WebView/WebViewInternal.h:

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

19 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/dom/Document.cpp
WebCore/editing/Editor.cpp
WebCore/editing/Editor.h
WebCore/page/Frame.cpp
WebCore/page/Frame.h
WebKit/ChangeLog
WebKit/WebCoreSupport/WebEditorClient.h
WebKit/WebCoreSupport/WebEditorClient.mm
WebKit/WebCoreSupport/WebFrameBridge.mm
WebKit/WebView/WebHTMLView.m
WebKit/WebView/WebView.mm
WebKit/WebView/WebViewInternal.h

index 26a546e1679ade31d6be344dd65f233952e3b175..4caec97289c8875ccadfffe3750d5e7b2c5e25e9 100644 (file)
@@ -1,3 +1,26 @@
+2006-11-08  Anders Carlsson  <acarlsson@apple.com>
+
+        Reviewed by Adam.
+
+        Move more code into editor.
+        
+        * WebCore.exp:
+        * bridge/EditorClient.h:
+        * bridge/mac/FrameMac.h:
+        * bridge/mac/FrameMac.mm:
+        * bridge/mac/WebCoreFrameBridge.h:
+        * dom/Document.cpp:
+        (WebCore::Document::relinquishesEditingFocus):
+        (WebCore::Document::acceptsEditingFocus):
+        (WebCore::Document::didBeginEditing):
+        (WebCore::Document::didEndEditing):
+        * editing/Editor.cpp:
+        (WebCore::Editor::indent):
+        (WebCore::Editor::outdent):
+        * editing/Editor.h:
+        * page/Frame.cpp:
+        * page/Frame.h:
+
 2006-11-08  Beth Dakin  <bdakin@apple.com>
 
         Reviewed by Adam.
index 878e3151b7413b42bccdfb556889e6f20f651576..6342186db7f2b3e3adcc42bf86ff5ac532ee104f 100644 (file)
@@ -215,8 +215,6 @@ __ZN7WebCore5Frame17setWindowHasFocusEb
 __ZN7WebCore5Frame20hitTestResultAtPointERKNS_8IntPointEb
 __ZN7WebCore5Frame20setSelectionFromNoneEv
 __ZN7WebCore5Frame21setProhibitsScrollingEb
-__ZN7WebCore5Frame6indentEv
-__ZN7WebCore5Frame7outdentEv
 __ZN7WebCore5Image10getNSImageEv
 __ZN7WebCore5Image21getTIFFRepresentationEv
 __ZN7WebCore5RangeC1EPNS_8DocumentEPNS_4NodeEiS4_i
@@ -226,9 +224,10 @@ __ZN7WebCore6Editor10toggleBoldEv
 __ZN7WebCore6Editor12toggleItalicEv
 __ZN7WebCore6Editor19applyParagraphStyleEPNS_19CSSStyleDeclarationENS_10EditActionE
 __ZN7WebCore6Editor21applyStyleToSelectionEPNS_19CSSStyleDeclarationENS_10EditActionE
-__ZNK7WebCore6Editor22selectionStartHasStyleEPNS_19CSSStyleDeclarationE
 __ZN7WebCore6Editor30applyParagraphStyleToSelectionEPNS_19CSSStyleDeclarationENS_10EditActionE
 __ZN7WebCore6Editor30deleteSelectionWithSmartDeleteEb
+__ZN7WebCore6Editor6indentEv
+__ZN7WebCore6Editor7outdentEv
 __ZN7WebCore6StringC1EP8NSString
 __ZN7WebCore6StringC1EPKc
 __ZN7WebCore6StringC1ERKNS_16DeprecatedStringE
@@ -370,6 +369,7 @@ __ZNK7WebCore5Range9endOffsetERi
 __ZNK7WebCore5Range9startNodeEv
 __ZNK7WebCore6Editor13canEditRichlyEv
 __ZNK7WebCore6Editor17shouldDeleteRangeEPNS_5RangeE
+__ZNK7WebCore6Editor22selectionStartHasStyleEPNS_19CSSStyleDeclarationE
 __ZNK7WebCore6Editor6canCutEv
 __ZNK7WebCore6Editor7canCopyEv
 __ZNK7WebCore6Editor7canEditEv
index 7573bea98b60699c5aafccbe0fabe84f7243d95b..b28ae5f841b6396bd7ebe0753df747d069c82802 100644 (file)
                0867D690FE84028FC02AAC07 /* Project object */ = {
                        isa = PBXProject;
                        buildConfigurationList = 149C284308902B11008A9EFC /* Build configuration list for PBXProject "WebCore" */;
-                       compatibilityVersion = "Xcode 2.4";
                        hasScannedForEncodings = 1;
                        knownRegions = (
                                English,
                        productRefGroup = 034768DFFF38A50411DB9C8B /* Products */;
                        projectDirPath = "";
                        projectRoot = "";
-                       shouldCheckCompatibility = 1;
                        targets = (
                                93F198A508245E59001E9ABC /* WebCore */,
                                DD041FBE09D9DDBE0010AF2A /* Derived Sources */,
index da2cab594ba8f7bc73300c1cb55aa5d8a4293a38..6fc692ced9676d3b7aa06b1e6b43b9251e39fcdb 100644 (file)
@@ -45,8 +45,8 @@ public:
     virtual bool isGrammarCheckingEnabled() = 0;
     virtual int spellCheckerDocumentTag() = 0;
 
-//    virtual bool shouldBeginEditingInRange(Range *range) = 0;
-//    virtual bool shouldEndEditingInRange(Range *range) = 0;
+    virtual bool shouldBeginEditing(Range*) = 0;
+    virtual bool shouldEndEditing(Range*) = 0;
 //    virtual bool shouldInsertNode(Node *node, Range* replacingRange, WebViewInsertAction givenAction) = 0;
 //    virtual bool shouldInsertText(NSString *text, Range *replacingRange, WebViewInsertAction givenAction) = 0;
 //    virtual bool shouldChangeSelectedRange(Range *currentRange, Range *toProposedRange, NSSelectionAffinity selectionAffinity, bool stillSelecting) = 0;
@@ -54,9 +54,9 @@ public:
 //    virtual bool shouldChangeTypingStyle(CSSStyleDeclaration *currentStyle, CSSStyleDeclaration *toProposedStyle) = 0;
 //    virtual bool doCommandBySelector(SEL selector) = 0;
 //
-//    virtual void webViewDidBeginEditing:(NSNotification *)notification = 0;
+    virtual void didBeginEditing() = 0;
 //    virtual void webViewDidChange:(NSNotification *)notification = 0;
-//    virtual void webViewDidEndEditing:(NSNotification *)notification = 0;
+    virtual void didEndEditing() = 0;
 //    virtual void webViewDidChangeTypingStyle:(NSNotification *)notification = 0;
 //    virtual void webViewDidChangeSelection:(NSNotification *)notification = 0;
 //    virtual NSUndoManager* undoManagerForWebView:(WebView *)webView = 0;
index 19830b7f8903091d06bf75e39691ed493b0ce5d8..a32c70d69eab5f4c5c99522fa6686cee6d0862b3 100644 (file)
@@ -193,10 +193,6 @@ public:
     virtual bool isContentEditable() const;
     virtual bool shouldChangeSelection(const Selection& oldSelection, const Selection& newSelection, EAffinity affinity, bool stillSelecting) const;
     virtual bool shouldDeleteSelection(const Selection&) const;
-    virtual bool shouldBeginEditing(const Range*) const;
-    virtual bool shouldEndEditing(const Range*) const;
-    virtual void didBeginEditing() const;
-    virtual void didEndEditing() const;
     
     virtual void setSecureKeyboardEntry(bool);
     virtual bool isSecureKeyboardEntry();
index 19bb2f620eb15ed9113e0c185bbb02e29c0a114b..3a8434fd09cc910ed47509f06c291a1dad72cf0c 100644 (file)
@@ -2424,28 +2424,6 @@ bool FrameMac::isContentEditable() const
     return Frame::isContentEditable() || [_bridge isEditable];
 }
 
-bool FrameMac::shouldBeginEditing(const Range *range) const
-{
-    ASSERT(range);
-    return [_bridge shouldBeginEditing:[DOMRange _rangeWith:const_cast<Range*>(range)]];
-}
-
-bool FrameMac::shouldEndEditing(const Range *range) const
-{
-    ASSERT(range);
-    return [_bridge shouldEndEditing:[DOMRange _rangeWith:const_cast<Range*>(range)]];
-}
-
-void FrameMac::didBeginEditing() const
-{
-    [_bridge didBeginEditing];
-}
-
-void FrameMac::didEndEditing() const
-{
-    [_bridge didEndEditing];
-}
-
 void FrameMac::textFieldDidBeginEditing(Element* input)
 {
     BEGIN_BLOCK_OBJC_EXCEPTIONS;
index b41dec464e9392f3a95316ff5c23e75c9ebc09c9..ff0f9a0a838cd390e24c5c08be5724e0300ea38d 100644 (file)
@@ -402,10 +402,6 @@ typedef enum {
 - (BOOL)isEditable;
 - (BOOL)shouldChangeSelectedDOMRange:(DOMRange *)currentRange toDOMRange:(DOMRange *)proposedRange affinity:(WebCore::EAffinity)selectionAffinity stillSelecting:(BOOL)flag;
 - (BOOL)shouldDeleteSelectedDOMRange:(DOMRange *)currentRange;
-- (BOOL)shouldBeginEditing:(DOMRange *)range;
-- (BOOL)shouldEndEditing:(DOMRange *)range;
-- (void)didBeginEditing;
-- (void)didEndEditing;
 
 - (NSString *)overrideMediaType;
 
index 5c7f89e3c8d0eb57be08718959e6dc76c2781c1a..d2f0b7178ae42706318a93f9a5809fb62921b335 100644 (file)
@@ -36,6 +36,8 @@
 #include "DocumentLoader.h"
 #include "DocumentType.h"
 #include "EditingText.h"
+#include "Editor.h"
+#include "EditorClient.h"
 #include "EntityReference.h"
 #include "Event.h"
 #include "EventListener.h"
@@ -1969,7 +1971,7 @@ bool Document::relinquishesEditingFocus(Node *node)
     if (!frame() || !root)
         return false;
 
-    return frame()->shouldEndEditing(rangeOfContents(root).get());
+    return frame()->editor()->client()->shouldEndEditing(rangeOfContents(root).get());
 }
 
 bool Document::acceptsEditingFocus(Node *node)
@@ -1981,7 +1983,7 @@ bool Document::acceptsEditingFocus(Node *node)
     if (!frame() || !root)
         return false;
 
-    return frame()->shouldBeginEditing(rangeOfContents(root).get());
+    return frame()->editor()->client()->shouldBeginEditing(rangeOfContents(root).get());
 }
 
 void Document::didBeginEditing()
@@ -1989,7 +1991,7 @@ void Document::didBeginEditing()
     if (!frame())
         return;
     
-    frame()->didBeginEditing();
+    frame()->editor()->client()->didBeginEditing();
 }
 
 void Document::didEndEditing()
@@ -1997,7 +1999,7 @@ void Document::didEndEditing()
     if (!frame())
         return;
     
-    frame()->didEndEditing();
+    frame()->editor()->client()->didEndEditing();
 }
 
 #if PLATFORM(MAC)
index 9aac165eb002fbac0037b95046b3f9f6eeca4877..d87d03b484cb5d79b1eb6bae8ad24e67e50027a9 100644 (file)
@@ -40,6 +40,7 @@
 #include "HTMLElement.h"
 #include "HTMLNames.h"
 #include "HitTestResult.h"
+#include "IndentOutdentCommand.h"
 #include "Range.h"
 #include "ReplaceSelectionCommand.h"
 #include "SelectionController.h"
@@ -360,6 +361,17 @@ bool Editor::selectionStartHasStyle(CSSStyleDeclaration* style) const
     return match;
 }
 
+void Editor::indent()
+{
+    applyCommand(new IndentOutdentCommand(m_frame->document(), IndentOutdentCommand::Indent));
+}
+
+void Editor::outdent()
+{
+    applyCommand(new IndentOutdentCommand(m_frame->document(), IndentOutdentCommand::Outdent));
+}
+
+
 // =============================================================================
 //
 // public editing commands
index 6cf26e07ec50efce49cd1e727f4217df4a0726c7..6c96a68ea60e7551b83b9b7852b432bbdc6ceaf7 100644 (file)
@@ -67,6 +67,9 @@ public:
     void paste();
     void performDelete();
 
+    void indent();
+    void outdent();
+
     bool shouldShowDeleteInterface(HTMLElement*) const;
     bool shouldDeleteRange(Range*) const;
 
index e329e88d72e35d59f549b32014667c8799538bb0..833a0860af8091ae5de2d813197c70429ba6acac 100644 (file)
@@ -818,16 +818,6 @@ bool Frame::shouldDeleteSelection(const Selection& newSelection) const
     return true;
 }
 
-bool Frame::shouldBeginEditing(const Range *range) const
-{
-    return true;
-}
-
-bool Frame::shouldEndEditing(const Range *range) const
-{
-    return true;
-}
-
 bool Frame::isContentEditable() const 
 {
     if (!d->m_doc)
@@ -1020,16 +1010,6 @@ void Frame::computeAndSetTypingStyle(CSSStyleDeclaration *style, EditAction edit
     d->m_typingStyle = mutableStyle.release();
 }
 
-void Frame::indent()
-{
-    applyCommand(new IndentOutdentCommand(document(), IndentOutdentCommand::Indent));
-}
-
-void Frame::outdent()
-{
-    applyCommand(new IndentOutdentCommand(document(), IndentOutdentCommand::Outdent));
-}
-
 static void updateState(CSSMutableStyleDeclaration *desiredStyle, CSSComputedStyleDeclaration *computedStyle, bool& atStart, Frame::TriState& state)
 {
     DeprecatedValueListConstIterator<CSSProperty> end;
index a795db6435f1ae6bd46ee25d0043b965dd9e6ff9..50f9063da542954f9a151f80ad71488fb55fd284 100644 (file)
@@ -250,12 +250,6 @@ public:
 
     void transpose();
 
-    virtual bool shouldBeginEditing(const Range*) const;
-    virtual bool shouldEndEditing(const Range*) const;
-
-    virtual void didBeginEditing() const {}
-    virtual void didEndEditing() const {}
-
     void copyToPasteboard();
     void cutToPasteboard();
     void pasteFromPasteboard();
@@ -265,8 +259,6 @@ public:
     virtual bool canRedo() const = 0;
     virtual bool canUndo() const = 0;
     void computeAndSetTypingStyle(CSSStyleDeclaration* , EditAction = EditActionUnspecified);
-    void indent();
-    void outdent();
     enum TriState { falseTriState, trueTriState, mixedTriState };
     TriState selectionHasStyle(CSSStyleDeclaration*) const;
     String selectionStartStylePropertyValue(int stylePropertyID) const;
index 721f8d8c251e6f81b7fb477261af65a6b939608a..8e8a2e37745fe9d2ed080995f03314029168fe38 100644 (file)
@@ -1,3 +1,22 @@
+2006-11-08  Anders Carlsson  <acarlsson@apple.com>
+
+        Reviewed by Adam.
+
+        Move more code into editor.
+
+        * WebCoreSupport/WebEditorClient.h:
+        * WebCoreSupport/WebEditorClient.mm:
+        (WebEditorClient::shouldBeginEditing):
+        (WebEditorClient::shouldEndEditing):
+        (WebEditorClient::didBeginEditing):
+        (WebEditorClient::didEndEditing):
+        * WebCoreSupport/WebFrameBridge.mm:
+        * WebView/WebHTMLView.m:
+        (-[NSArray indent:]):
+        (-[NSArray outdent:]):
+        * WebView/WebView.mm:
+        * WebView/WebViewInternal.h:
+
 2006-11-08  Beth Dakin  <bdakin@apple.com>
 
         Reviewed by Adam.
index 322f26b5da01325a1a164b62bca61ddabfea6856..cf33406b59c3621710d816e0aa76a7a6e83844c1 100644 (file)
@@ -45,8 +45,8 @@ public:
     bool shouldDeleteRange(WebCore::Range*);    
     bool shouldShowDeleteInterface(WebCore::HTMLElement*);
 
-//    bool shouldBeginEditingInRange(Range *range);
-//    bool shouldEndEditingInRange(Range *range);
+    bool shouldBeginEditing(WebCore::Range*);
+    bool shouldEndEditing(WebCore::Range*);
 //    bool shouldInsertNode(Node *node, Range* replacingRange, WebViewInsertAction givenAction);
 //    bool shouldInsertText(NSString *text, Range *replacingRange, WebViewInsertActiongivenAction);
 //    bool shouldChangeSelectedRange(Range *currentRange, Range *toProposedRange, NSSelectionAffinity selectionAffinity, bool stillSelecting);
@@ -54,9 +54,9 @@ public:
 //    bool shouldChangeTypingStyle(CSSStyleDeclaration *currentStyle, CSSStyleDeclaration *toProposedStyle);
 //    bool doCommandBySelector(SEL selector);
 
-//    void webViewDidBeginEditing:(NSNotification *)notification;
+    void didBeginEditing();
 //    void webViewDidChange:(NSNotification *)notification;
-//    void webViewDidEndEditing:(NSNotification *)notification;
+    void didEndEditing();
 //    void webViewDidChangeTypingStyle:(NSNotification *)notification;
 //    void webViewDidChangeSelection:(NSNotification *)notification;
 //    NSUndoManager* undoManagerForWebView:(WebView *)webView;
index 145e4ec297b14aa2e20bf203da6962db0ddeeec1..8e11ba1c517d5c6ffe6005a3a9f21097d62b6bd3 100644 (file)
@@ -90,9 +90,31 @@ bool WebEditorClient::shouldApplyStyle(CSSStyleDeclaration* style, Range* range)
         shouldApplyStyle:kit(style) toElementsInDOMRange:kit(range)];
 }
 
+bool WebEditorClient::shouldBeginEditing(Range* range)
+{
+    return [[m_webView _editingDelegateForwarder] webView:m_webView
+        shouldBeginEditingInDOMRange:kit(range)];
+
+    return false;
+}
+
+bool WebEditorClient::shouldEndEditing(Range* range)
+{
+    return [[m_webView _editingDelegateForwarder] webView:m_webView
+                             shouldEndEditingInDOMRange:kit(range)];
+}
+
+void WebEditorClient::didBeginEditing()
+{
+    [[NSNotificationCenter defaultCenter] postNotificationName:WebViewDidBeginEditingNotification object:m_webView];
+}
+
+void WebEditorClient::didEndEditing()
+{
+    [[NSNotificationCenter defaultCenter] postNotificationName:WebViewDidEndEditingNotification object:m_webView];
+}
+
 /*
-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; }
index 7a822065a62b904a1fde9df40c441fa3346c8f44..2f8e2e0bd5f740beb12b957a39e8c484b05244da 100644 (file)
@@ -1070,26 +1070,6 @@ static id <WebFormDelegate> formDelegate(WebFrameBridge *self)
     return [[webView _editingDelegateForwarder] webView:webView shouldDeleteDOMRange:range];
 }
 
-- (BOOL)shouldBeginEditing:(DOMRange *)range
-{
-    return [[self webView] _shouldBeginEditingInDOMRange:range];
-}
-
-- (BOOL)shouldEndEditing:(DOMRange *)range
-{
-    return [[self webView] _shouldEndEditingInDOMRange:range];
-}
-
-- (void)didBeginEditing
-{
-    [[NSNotificationCenter defaultCenter] postNotificationName:WebViewDidBeginEditingNotification object:[_frame webView]];
-}
-
-- (void)didEndEditing
-{
-    [[NSNotificationCenter defaultCenter] postNotificationName:WebViewDidEndEditingNotification object:[_frame webView]];
-}
-
 - (void)windowObjectCleared
 {
     WebView *wv = [self webView];
index 1232b05add27a7cffcd0b3194c09548d591f9e98..081db1ab1350d6ca22d1cedff082dba8725bed26 100644 (file)
@@ -4858,12 +4858,12 @@ static DOMRange *unionDOMRanges(DOMRange *a, DOMRange *b)
 
 - (void)indent:(id)sender
 {
-    core([self _frame])->indent();
+    core([self _frame])->editor()->indent();
 }
 
 - (void)outdent:(id)sender
 {
-    core([self _frame])->outdent();
+    core([self _frame])->editor()->outdent();
 }
 
 #if 0
index e9def163c844cb15d5e0a3033817f843055bbd06..ba2ba5b55ba35d63acbd9d353ad42c7730fb4e0e 100644 (file)
@@ -3148,16 +3148,6 @@ static WebFrame *incrementFrame(WebFrame *curr, BOOL forward, BOOL wrapFlag)
     return [[self _editingDelegateForwarder] webView:self shouldChangeSelectedDOMRange:currentRange toDOMRange:proposedRange affinity:selectionAffinity stillSelecting:flag];
 }
 
-- (BOOL)_shouldBeginEditingInDOMRange:(DOMRange *)range
-{
-    return [[self _editingDelegateForwarder] webView:self shouldBeginEditingInDOMRange:range];
-}
-
-- (BOOL)_shouldEndEditingInDOMRange:(DOMRange *)range
-{
-    return [[self _editingDelegateForwarder] webView:self shouldEndEditingInDOMRange:range];
-}
-
 - (BOOL)maintainsInactiveSelection
 {
     return NO;
index 9a87bc011e9b62b5684a971a04da8ca1dbafb932..77eb23ac79e677a1659b9b05ed3733d7f6f1dc71 100644 (file)
@@ -51,8 +51,6 @@ namespace WebCore {
 @interface WebView (WebViewEditingExtras)
 - (BOOL)_interceptEditingKeyEvent:(NSEvent *)event;
 - (BOOL)_shouldChangeSelectedDOMRange:(DOMRange *)currentRange toDOMRange:(DOMRange *)proposedRange affinity:(NSSelectionAffinity)selectionAffinity stillSelecting:(BOOL)flag;
-- (BOOL)_shouldBeginEditingInDOMRange:(DOMRange *)range;
-- (BOOL)_shouldEndEditingInDOMRange:(DOMRange *)range;
 @end
 
 @interface WebView (AllWebViews)