WebCore:
authorandersca <andersca@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 10 Nov 2006 19:45:25 +0000 (19:45 +0000)
committerandersca <andersca@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 10 Nov 2006 19:45:25 +0000 (19:45 +0000)
        Reviewed by Maciej, Geoff.

        Added an execCommand method to Editor. The idea is that this should replace the CommandByName object. Get rid of
        the alterCurrentSelection method in the bridge. WebKit can just call execCommand directly.

        * WebCore.exp:
        * bridge/mac/WebCoreFrameBridge.h:
        * bridge/mac/WebCoreFrameBridge.mm:
        * editing/Editor.cpp:
        (WebCore::execMoveBackward):
        (WebCore::execMoveBackwardAndModifySelection):
        (WebCore::execMoveDown):
        (WebCore::execMoveDownAndModifySelection):
        (WebCore::execMoveForward):
        (WebCore::execMoveForwardAndModifySelection):
        (WebCore::execMoveLeft):
        (WebCore::execMoveLeftAndModifySelection):
        (WebCore::execMoveRight):
        (WebCore::execMoveRightAndModifySelection):
        (WebCore::execMoveToBeginningOfDocument):
        (WebCore::execMoveToBeginningOfDocumentAndModifySelection):
        (WebCore::execMoveToBeginningOfSentence):
        (WebCore::execMoveToBeginningOfSentenceAndModifySelection):
        (WebCore::execMoveToBeginningOfLine):
        (WebCore::execMoveToBeginningOfLineAndModifySelection):
        (WebCore::execMoveToBeginningOfParagraph):
        (WebCore::execMoveToBeginningOfParagraphAndModifySelection):
        (WebCore::execMoveToEndOfDocument):
        (WebCore::execMoveToEndOfDocumentAndModifySelection):
        (WebCore::execMoveToEndOfSentence):
        (WebCore::execMoveToEndOfSentenceAndModifySelection):
        (WebCore::execMoveToEndOfLine):
        (WebCore::execMoveToEndOfLineAndModifySelection):
        (WebCore::execMoveToEndOfParagraph):
        (WebCore::execMoveToEndOfParagraphAndModifySelection):
        (WebCore::execMoveParagraphBackwardAndModifySelection):
        (WebCore::execMoveParagraphForwardAndModifySelection):
        (WebCore::execMoveUp):
        (WebCore::execMoveUpAndModifySelection):
        (WebCore::execMoveWordBackward):
        (WebCore::execMoveWordBackwardAndModifySelection):
        (WebCore::execMoveWordForward):
        (WebCore::execMoveWordForwardAndModifySelection):
        (WebCore::execMoveWordLeft):
        (WebCore::execMoveWordLeftAndModifySelection):
        (WebCore::execMoveWordRight):
        (WebCore::execMoveWordRightAndModifySelection):
        (WebCore::enabledAnySelection):
        (WebCore::createCommandMap):
        (WebCore::CommandEntry::):
        (WebCore::Editor::execCommand):
        * editing/Editor.h:

WebKit:

        Reviewed by Maciej, Geoff.

        Call execCommand directly here instead of going through the bridge.

        * WebView/WebHTMLView.m:
        (-[NSArray moveBackward:]):
        (-[NSArray moveBackwardAndModifySelection:]):
        (-[NSArray moveDown:]):
        (-[NSArray moveDownAndModifySelection:]):
        (-[NSArray moveForward:]):
        (-[NSArray moveForwardAndModifySelection:]):
        (-[NSArray moveLeft:]):
        (-[NSArray moveLeftAndModifySelection:]):
        (-[NSArray moveRight:]):
        (-[NSArray moveRightAndModifySelection:]):
        (-[NSArray moveToBeginningOfDocument:]):
        (-[NSArray moveToBeginningOfDocumentAndModifySelection:]):
        (-[NSArray moveToBeginningOfSentence:]):
        (-[NSArray moveToBeginningOfSentenceAndModifySelection:]):
        (-[NSArray moveToBeginningOfLine:]):
        (-[NSArray moveToBeginningOfLineAndModifySelection:]):
        (-[NSArray moveToBeginningOfParagraph:]):
        (-[NSArray moveToBeginningOfParagraphAndModifySelection:]):
        (-[NSArray moveToEndOfDocument:]):
        (-[NSArray moveToEndOfDocumentAndModifySelection:]):
        (-[NSArray moveToEndOfSentence:]):
        (-[NSArray moveToEndOfSentenceAndModifySelection:]):
        (-[NSArray moveToEndOfLine:]):
        (-[NSArray moveToEndOfLineAndModifySelection:]):
        (-[NSArray moveToEndOfParagraph:]):
        (-[NSArray moveToEndOfParagraphAndModifySelection:]):
        (-[NSArray moveParagraphBackwardAndModifySelection:]):
        (-[NSArray moveParagraphForwardAndModifySelection:]):
        (-[NSArray moveUp:]):
        (-[NSArray moveUpAndModifySelection:]):
        (-[NSArray moveWordBackward:]):
        (-[NSArray moveWordBackwardAndModifySelection:]):
        (-[NSArray moveWordForward:]):
        (-[NSArray moveWordForwardAndModifySelection:]):
        (-[NSArray moveWordLeft:]):
        (-[NSArray moveWordLeftAndModifySelection:]):
        (-[NSArray moveWordRight:]):
        (-[NSArray moveWordRightAndModifySelection:]):

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

WebCore/ChangeLog
WebCore/WebCore.exp
WebCore/WebCore.xcodeproj/project.pbxproj
WebCore/bridge/mac/WebCoreFrameBridge.h
WebCore/bridge/mac/WebCoreFrameBridge.mm
WebCore/editing/Editor.cpp
WebCore/editing/Editor.h
WebCore/editing/TypingCommand.h
WebKit/ChangeLog
WebKit/WebKit.xcodeproj/project.pbxproj
WebKit/WebView/WebHTMLView.m

index 2d0fc76d312bf18f2d316c8fd02bf4e3294881c6..4958c88c1eca773d874c09842ffe260191316a58 100644 (file)
@@ -1,3 +1,58 @@
+2006-11-10  Anders Carlsson  <acarlsson@apple.com>
+
+        Reviewed by Maciej, Geoff.
+
+        Added an execCommand method to Editor. The idea is that this should replace the CommandByName object. Get rid of
+        the alterCurrentSelection method in the bridge. WebKit can just call execCommand directly.
+
+        * WebCore.exp:
+        * bridge/mac/WebCoreFrameBridge.h:
+        * bridge/mac/WebCoreFrameBridge.mm:
+        * editing/Editor.cpp:
+        (WebCore::execMoveBackward):
+        (WebCore::execMoveBackwardAndModifySelection):
+        (WebCore::execMoveDown):
+        (WebCore::execMoveDownAndModifySelection):
+        (WebCore::execMoveForward):
+        (WebCore::execMoveForwardAndModifySelection):
+        (WebCore::execMoveLeft):
+        (WebCore::execMoveLeftAndModifySelection):
+        (WebCore::execMoveRight):
+        (WebCore::execMoveRightAndModifySelection):
+        (WebCore::execMoveToBeginningOfDocument):
+        (WebCore::execMoveToBeginningOfDocumentAndModifySelection):
+        (WebCore::execMoveToBeginningOfSentence):
+        (WebCore::execMoveToBeginningOfSentenceAndModifySelection):
+        (WebCore::execMoveToBeginningOfLine):
+        (WebCore::execMoveToBeginningOfLineAndModifySelection):
+        (WebCore::execMoveToBeginningOfParagraph):
+        (WebCore::execMoveToBeginningOfParagraphAndModifySelection):
+        (WebCore::execMoveToEndOfDocument):
+        (WebCore::execMoveToEndOfDocumentAndModifySelection):
+        (WebCore::execMoveToEndOfSentence):
+        (WebCore::execMoveToEndOfSentenceAndModifySelection):
+        (WebCore::execMoveToEndOfLine):
+        (WebCore::execMoveToEndOfLineAndModifySelection):
+        (WebCore::execMoveToEndOfParagraph):
+        (WebCore::execMoveToEndOfParagraphAndModifySelection):
+        (WebCore::execMoveParagraphBackwardAndModifySelection):
+        (WebCore::execMoveParagraphForwardAndModifySelection):
+        (WebCore::execMoveUp):
+        (WebCore::execMoveUpAndModifySelection):
+        (WebCore::execMoveWordBackward):
+        (WebCore::execMoveWordBackwardAndModifySelection):
+        (WebCore::execMoveWordForward):
+        (WebCore::execMoveWordForwardAndModifySelection):
+        (WebCore::execMoveWordLeft):
+        (WebCore::execMoveWordLeftAndModifySelection):
+        (WebCore::execMoveWordRight):
+        (WebCore::execMoveWordRightAndModifySelection):
+        (WebCore::enabledAnySelection):
+        (WebCore::createCommandMap):
+        (WebCore::CommandEntry::):
+        (WebCore::Editor::execCommand):
+        * editing/Editor.h:
+
 2006-11-10  Brady Eidson  <beidson@apple.com>
 
         Reviewed by Darin
         (WebCore::RenderObject::calcVerticalMargins):
         (WebCore::RenderObject::font):
 
->>>>>>> .r17689
 2006-11-08  Darin Adler  <darin@apple.com>
 
         Reviewed by Anders.
index a5df6eb9472049f2ac9bdb2b9eb162aca9866862..8874ef75cc215888d2fdee6236635d359d2c3fad 100644 (file)
@@ -241,6 +241,7 @@ __ZN7WebCore5RangeC1EPNS_8DocumentEPNS_4NodeEiS4_i
 __ZN7WebCore5RangeD1Ev
 __ZN7WebCore6Editor10applyStyleEPNS_19CSSStyleDeclarationENS_10EditActionE
 __ZN7WebCore6Editor10toggleBoldEv
+__ZN7WebCore6Editor11execCommandERKNS_6StringE
 __ZN7WebCore6Editor12toggleItalicEv
 __ZN7WebCore6Editor19applyParagraphStyleEPNS_19CSSStyleDeclarationENS_10EditActionE
 __ZN7WebCore6Editor21applyStyleToSelectionEPNS_19CSSStyleDeclarationENS_10EditActionE
index 193849113d51f5a5cb819f650a31b248fe77fd89..3b9a30975c887bf692d5f64661e0dd862e84c5d2 100644 (file)
                149C284408902B11008A9EFC /* Debug */ = {
                        isa = XCBuildConfiguration;
                        buildSettings = {
-                               DEBUG_INFORMATION_FORMAT = stabs;
+                               DEBUG_INFORMATION_FORMAT = dwarf;
                                FEATURE_DEFINES = "SVG_SUPPORT XPATH_SUPPORT";
                                GCC_ENABLE_CPP_EXCEPTIONS = NO;
                                GCC_ENABLE_CPP_RTTI = NO;
                        isa = XCBuildConfiguration;
                        buildSettings = {
                                DEAD_CODE_STRIPPING = YES;
-                               DEBUG_INFORMATION_FORMAT = stabs;
+                               DEBUG_INFORMATION_FORMAT = dwarf;
                                FEATURE_DEFINES = "SVG_SUPPORT XPATH_SUPPORT";
                                GCC_DEBUGGING_SYMBOLS = full;
                                GCC_ENABLE_CPP_EXCEPTIONS = NO;
index 38cfa55199bd2e116182b15d82c0182d3594ecfc..d9ba31138f3bcfc3e5a7a24eb30011a652dc5880 100644 (file)
@@ -233,7 +233,6 @@ typedef enum {
 
 - (DOMRange *)rangeOfCharactersAroundCaret;
 - (DOMRange *)rangeByAlteringCurrentSelection:(WebCore::SelectionController::EAlteration)alteration direction:(WebCore::SelectionController::EDirection)direction granularity:(WebCore::TextGranularity)granularity;
-- (void)alterCurrentSelection:(WebCore::SelectionController::EAlteration)alteration direction:(WebCore::SelectionController::EDirection)direction granularity:(WebCore::TextGranularity)granularity;
 - (void)alterCurrentSelection:(WebCore::SelectionController::EAlteration)alteration verticalDistance:(float)distance;
 - (WebCore::TextGranularity)selectionGranularity;
 - (DOMRange *)smartDeleteRangeForProposedRange:(DOMRange *)proposedCharRange;
index e6094c9185e0ec79e5fe88bd93ccc8d36a506db8..919742ce2657d8ed20cdf4ab4dac9401461ff85b 100644 (file)
@@ -984,16 +984,6 @@ static HTMLFormElement *formElementFromDOMElement(DOMElement *element)
     return [DOMRange _rangeWith:selectionController.toRange().get()];
 }
 
-- (void)alterCurrentSelection:(SelectionController::EAlteration)alteration direction:(SelectionController::EDirection)direction granularity:(TextGranularity)granularity
-{
-    if (m_frame->selectionController()->isNone())
-        return;
-
-    // NOTE: The enums *must* match the very similar ones declared in SelectionController.h
-    SelectionController* selectionController = m_frame->selectionController();
-    selectionController->modify(alteration, direction, granularity, true);
-}
-
 - (void)alterCurrentSelection:(SelectionController::EAlteration)alteration verticalDistance:(float)verticalDistance
 {
     if (m_frame->selectionController()->isNone())
index 9504b5eff6b036d0e40c08a594aef79d9f549d40..4b973438598d4526e13cfc353e017a6440f4879f 100644 (file)
@@ -450,6 +450,303 @@ void Editor::reappliedEditing(PassRefPtr<EditCommand> cmd)
     respondToChangedContents(newSelection);    
 }
 
+// Execute command functions
+
+static bool execMoveBackward(Frame* frame)
+{
+    frame->selectionController()->modify(SelectionController::MOVE, SelectionController::BACKWARD, CharacterGranularity, true);
+    return true;
+}
+
+static bool execMoveBackwardAndModifySelection(Frame* frame)
+{
+    frame->selectionController()->modify(SelectionController::EXTEND, SelectionController::BACKWARD, CharacterGranularity, true);
+    return true;
+}
+
+static bool execMoveDown(Frame* frame)
+{
+    frame->selectionController()->modify(SelectionController::MOVE, SelectionController::FORWARD, LineGranularity, true);
+    return true;
+}
+
+static bool execMoveDownAndModifySelection(Frame* frame)
+{
+    frame->selectionController()->modify(SelectionController::EXTEND, SelectionController::FORWARD, LineGranularity, true);
+    return true;
+}
+
+static bool execMoveForward(Frame* frame)
+{
+    frame->selectionController()->modify(SelectionController::MOVE, SelectionController::FORWARD, CharacterGranularity, true);
+    return true;
+}
+
+static bool execMoveForwardAndModifySelection(Frame* frame)
+{
+    frame->selectionController()->modify(SelectionController::EXTEND, SelectionController::FORWARD, CharacterGranularity, true);
+    return true;
+}
+
+static bool execMoveLeft(Frame* frame)
+{
+    frame->selectionController()->modify(SelectionController::MOVE, SelectionController::LEFT, CharacterGranularity, true);
+    return true;
+}
+
+static bool execMoveLeftAndModifySelection(Frame* frame)
+{
+    frame->selectionController()->modify(SelectionController::EXTEND, SelectionController::LEFT, CharacterGranularity, true);
+    return true;
+}
+
+static bool execMoveRight(Frame* frame)
+{
+    frame->selectionController()->modify(SelectionController::MOVE, SelectionController::RIGHT, CharacterGranularity, true);
+    return true;
+}
+
+static bool execMoveRightAndModifySelection(Frame* frame)
+{
+    frame->selectionController()->modify(SelectionController::EXTEND, SelectionController::RIGHT, CharacterGranularity, true);
+    return true;
+}
+
+static bool execMoveToBeginningOfDocument(Frame* frame)
+{
+    frame->selectionController()->modify(SelectionController::MOVE, SelectionController::BACKWARD, DocumentBoundary, true);
+    return true;
+}
+
+static bool execMoveToBeginningOfDocumentAndModifySelection(Frame* frame)
+{
+    frame->selectionController()->modify(SelectionController::EXTEND, SelectionController::BACKWARD, DocumentBoundary, true);
+    return true;
+}
+
+static bool execMoveToBeginningOfSentence(Frame* frame)
+{
+    frame->selectionController()->modify(SelectionController::MOVE, SelectionController::BACKWARD, SentenceBoundary, true);
+    return true;
+}
+
+static bool execMoveToBeginningOfSentenceAndModifySelection(Frame* frame)
+{
+    frame->selectionController()->modify(SelectionController::EXTEND, SelectionController::BACKWARD, SentenceBoundary, true);
+    return true;
+}
+
+static bool execMoveToBeginningOfLine(Frame* frame)
+{
+    frame->selectionController()->modify(SelectionController::MOVE, SelectionController::BACKWARD, LineBoundary, true);
+    return true;
+}
+
+static bool execMoveToBeginningOfLineAndModifySelection(Frame* frame)
+{
+    frame->selectionController()->modify(SelectionController::EXTEND, SelectionController::BACKWARD, LineBoundary, true);
+    return true;
+}
+
+static bool execMoveToBeginningOfParagraph(Frame* frame)
+{
+    frame->selectionController()->modify(SelectionController::MOVE, SelectionController::BACKWARD, ParagraphBoundary, true);
+    return true;
+}
+
+static bool execMoveToBeginningOfParagraphAndModifySelection(Frame* frame)
+{
+    frame->selectionController()->modify(SelectionController::EXTEND, SelectionController::BACKWARD, ParagraphBoundary, true);
+    return true;
+}
+
+static bool execMoveToEndOfDocument(Frame* frame)
+{
+    frame->selectionController()->modify(SelectionController::MOVE, SelectionController::FORWARD, DocumentBoundary, true);
+    return true;
+}
+
+static bool execMoveToEndOfDocumentAndModifySelection(Frame* frame)
+{
+    frame->selectionController()->modify(SelectionController::EXTEND, SelectionController::FORWARD, DocumentBoundary, true);
+    return true;
+}
+
+static bool execMoveToEndOfSentence(Frame* frame)
+{
+    frame->selectionController()->modify(SelectionController::MOVE, SelectionController::FORWARD, SentenceBoundary, true);
+    return true;
+}
+
+static bool execMoveToEndOfSentenceAndModifySelection(Frame* frame)
+{
+    frame->selectionController()->modify(SelectionController::EXTEND, SelectionController::FORWARD, SentenceBoundary, true);
+    return true;
+}
+
+static bool execMoveToEndOfLine(Frame* frame)
+{
+    frame->selectionController()->modify(SelectionController::MOVE, SelectionController::FORWARD, LineBoundary, true);
+    return true;
+}
+
+static bool execMoveToEndOfLineAndModifySelection(Frame* frame)
+{
+    frame->selectionController()->modify(SelectionController::EXTEND, SelectionController::FORWARD, LineBoundary, true);
+    return true;
+}
+
+static bool execMoveToEndOfParagraph(Frame* frame)
+{
+    frame->selectionController()->modify(SelectionController::MOVE, SelectionController::FORWARD, ParagraphBoundary, true);
+    return true;
+}
+
+static bool execMoveToEndOfParagraphAndModifySelection(Frame* frame)
+{
+    frame->selectionController()->modify(SelectionController::EXTEND, SelectionController::FORWARD, ParagraphBoundary, true);
+    return true;
+}
+
+static bool execMoveParagraphBackwardAndModifySelection(Frame* frame)
+{
+    frame->selectionController()->modify(SelectionController::EXTEND, SelectionController::BACKWARD, ParagraphGranularity, true);
+    return true;
+}
+
+static bool execMoveParagraphForwardAndModifySelection(Frame* frame)
+{
+    frame->selectionController()->modify(SelectionController::EXTEND, SelectionController::FORWARD, ParagraphGranularity, true);
+    return true;
+}
+
+static bool execMoveUp(Frame* frame)
+{
+    frame->selectionController()->modify(SelectionController::MOVE, SelectionController::BACKWARD, LineGranularity, true);
+    return true;
+}
+
+static bool execMoveUpAndModifySelection(Frame* frame)
+{
+    frame->selectionController()->modify(SelectionController::EXTEND, SelectionController::BACKWARD, LineGranularity, true);
+    return true;
+}
+
+static bool execMoveWordBackward(Frame* frame)
+{
+    frame->selectionController()->modify(SelectionController::MOVE, SelectionController::BACKWARD, WordGranularity, true);
+    return true;
+}
+
+static bool execMoveWordBackwardAndModifySelection(Frame* frame)
+{
+    frame->selectionController()->modify(SelectionController::EXTEND, SelectionController::BACKWARD, WordGranularity, true);
+    return true;
+}
+
+static bool execMoveWordForward(Frame* frame)
+{
+    frame->selectionController()->modify(SelectionController::MOVE, SelectionController::FORWARD, WordGranularity, true);
+    return true;
+}
+
+static bool execMoveWordForwardAndModifySelection(Frame* frame)
+{
+    frame->selectionController()->modify(SelectionController::EXTEND, SelectionController::FORWARD, WordGranularity, true);
+    return true;
+}
+
+static bool execMoveWordLeft(Frame* frame)
+{
+    frame->selectionController()->modify(SelectionController::MOVE, SelectionController::LEFT, WordGranularity, true);
+    return true;
+}
+
+static bool execMoveWordLeftAndModifySelection(Frame* frame)
+{
+    frame->selectionController()->modify(SelectionController::EXTEND, SelectionController::LEFT, WordGranularity, true);
+    return true;
+}
+
+static bool execMoveWordRight(Frame* frame)
+{
+    frame->selectionController()->modify(SelectionController::MOVE, SelectionController::RIGHT, WordGranularity, true);
+    return true;
+}
+
+static bool execMoveWordRightAndModifySelection(Frame* frame)
+{
+    frame->selectionController()->modify(SelectionController::EXTEND, SelectionController::RIGHT, WordGranularity, true);
+    return true;
+}
+
+// Enabled functions
+
+bool canAlterCurrentSelection(Frame* frame)
+{
+    return frame->selectionController()->isCaretOrRange() && frame->selectionController()->isContentEditable();
+}
+
+struct Command {
+    bool (*enabled)(Frame* frame);
+    bool (*exec)(Frame* frame);
+};
+
+typedef HashMap<String, const Command*> CommandMap;
+
+static CommandMap* createCommandMap()
+{
+    struct CommandEntry { const char* name; Command command; };
+    
+    static const CommandEntry commands[] = {
+        { "MoveBackward", { canAlterCurrentSelection, execMoveBackward } },
+        { "MoveBackwardAndModifySelection", { canAlterCurrentSelection, execMoveBackwardAndModifySelection } },
+        { "MoveDown", { canAlterCurrentSelection, execMoveDown } },
+        { "MoveDownAndModifySelection", { canAlterCurrentSelection, execMoveDownAndModifySelection } },
+        { "MoveForward", { canAlterCurrentSelection, execMoveForward } },
+        { "MoveForwardAndModifySelection", { canAlterCurrentSelection, execMoveForwardAndModifySelection } },
+        { "MoveLeft", { canAlterCurrentSelection, execMoveLeft } },
+        { "MoveLeftAndModifySelection", { canAlterCurrentSelection, execMoveLeftAndModifySelection } },
+        { "MoveRight", { canAlterCurrentSelection, execMoveRight } },
+        { "MoveRightAndModifySelection", { canAlterCurrentSelection, execMoveRightAndModifySelection } },
+        { "MoveToBeginningOfDocument", { canAlterCurrentSelection, execMoveToBeginningOfDocument } },
+        { "MoveToBeginningOfDocumentAndModifySelection", { canAlterCurrentSelection, execMoveToBeginningOfDocumentAndModifySelection } },
+        { "MoveToBeginningOfSentence", { canAlterCurrentSelection, execMoveToBeginningOfSentence } },
+        { "MoveToBeginningOfSentenceAndModifySelection", { canAlterCurrentSelection, execMoveToBeginningOfSentenceAndModifySelection } },
+        { "MoveToBeginningOfLine", { canAlterCurrentSelection, execMoveToBeginningOfLine } },
+        { "MoveToBeginningOfLineAndModifySelection", { canAlterCurrentSelection, execMoveToBeginningOfLineAndModifySelection } },
+        { "MoveToBeginningOfParagraph", { canAlterCurrentSelection, execMoveToBeginningOfParagraph } },
+        { "MoveToBeginningOfLineAndModifySelection", { canAlterCurrentSelection, execMoveToBeginningOfParagraphAndModifySelection } },
+        { "MoveToEndOfDocument", { canAlterCurrentSelection, execMoveToEndOfDocument } },
+        { "MoveToEndOfDocumentAndModifySelection", { canAlterCurrentSelection, execMoveToEndOfDocumentAndModifySelection } },
+        { "MoveToEndOfSentence", { canAlterCurrentSelection, execMoveToEndOfSentence } },
+        { "MoveToEndOfSentenceAndModifySelection", { canAlterCurrentSelection, execMoveToEndOfSentenceAndModifySelection } },
+        { "MoveToEndOfLine", { canAlterCurrentSelection, execMoveToEndOfLine } },
+        { "MoveToEndOfLineAndModifySelection", { canAlterCurrentSelection, execMoveToEndOfLineAndModifySelection } },
+        { "MoveToEndOfParagraph", { canAlterCurrentSelection, execMoveToEndOfParagraph } },
+        { "MoveToEndOfLineAndModifySelection", { canAlterCurrentSelection, execMoveToEndOfParagraphAndModifySelection } },
+        { "MoveParagraphBackwardAndModifySelection", { canAlterCurrentSelection, execMoveParagraphBackwardAndModifySelection } },
+        { "MoveParagraphForwardAndModifySelection", { canAlterCurrentSelection, execMoveParagraphForwardAndModifySelection } },
+        { "MoveUp", { canAlterCurrentSelection, execMoveUp } },
+        { "MoveUpAndModifySelection", { canAlterCurrentSelection, execMoveUpAndModifySelection } },
+        { "MoveWordBackward", { canAlterCurrentSelection, execMoveWordBackward } },
+        { "MoveWordBackwardAndModifySelection", { canAlterCurrentSelection, execMoveWordBackwardAndModifySelection } },
+        { "MoveWordForward", { canAlterCurrentSelection, execMoveWordForward } },
+        { "MoveWordForwardAndModifySelection", { canAlterCurrentSelection, execMoveWordForwardAndModifySelection } },
+        { "MoveWordLeft", { canAlterCurrentSelection, execMoveWordLeft } },
+        { "MoveWordLeftAndModifySelection", { canAlterCurrentSelection, execMoveWordLeftAndModifySelection } },
+        { "MoveWordRight", { canAlterCurrentSelection, execMoveWordRight } },
+        { "MoveWordRightAndModifySelection", { canAlterCurrentSelection, execMoveWordRightAndModifySelection } },
+    };
+    
+    CommandMap* commandMap = new CommandMap;
+    
+    const unsigned numCommands = sizeof(commands) / sizeof(commands[0]);
+    for (unsigned i = 0; i < numCommands; i++)
+        commandMap->set(commands[i].name, &commands[i].command);
+    return commandMap;
+}
+
 // =============================================================================
 //
 // public editing commands
@@ -467,6 +764,25 @@ Editor::~Editor()
 {
 }
 
+bool Editor::execCommand(const String& command)
+{
+    static CommandMap* commandMap;
+    if (!commandMap)
+        commandMap = createCommandMap();
+    
+    const Command* c = commandMap->get(command);
+    ASSERT(c);
+    
+    bool handled = false;
+    
+    if (c->enabled(m_frame)) {
+        m_frame->document()->updateLayoutIgnorePendingStylesheets();
+        handled = c->exec(m_frame);
+    }
+    
+    return handled;
+}
+
 void Editor::cut()
 {
     if (tryDHTMLCut())
index f28fb0580096a49f7f61095ce29b96150b3e5517..2e3fcf03e75d022c51bce901eee346a11a605bcb 100644 (file)
@@ -100,6 +100,8 @@ public:
     void toggleItalic();
     
     bool selectionStartHasStyle(CSSStyleDeclaration*) const;
+    
+    bool execCommand(const String&);
 private:
     Frame* m_frame;
     RefPtr<EditorClient> m_client;
index 37c8ad0f72fc29e23c92054f9f03d636e1241be7..ce78f408de97e38c540acbd3d04e2f8b5bb5b052 100644 (file)
@@ -66,10 +66,10 @@ public:
     void deleteKeyPressed(TextGranularity);
     void forwardDeleteKeyPressed(TextGranularity);
 
+private:
     bool smartDelete() { return m_smartDelete; }
     void setSmartDelete(bool smartDelete) { m_smartDelete = smartDelete; }
-
-private:
+    
     virtual bool isTypingCommand() const;
     virtual bool preservesTypingStyle() const;
 
index 7702a797814560a52482b1b6858985426d8161f3..8465efc7656ec8a862ad24795a0dd1e53864cad6 100644 (file)
@@ -1,3 +1,49 @@
+2006-11-09  Anders Carlsson  <acarlsson@apple.com>
+
+        Reviewed by Maciej, Geoff.
+
+        Call execCommand directly here instead of going through the bridge.
+        
+        * WebView/WebHTMLView.m:
+        (-[NSArray moveBackward:]):
+        (-[NSArray moveBackwardAndModifySelection:]):
+        (-[NSArray moveDown:]):
+        (-[NSArray moveDownAndModifySelection:]):
+        (-[NSArray moveForward:]):
+        (-[NSArray moveForwardAndModifySelection:]):
+        (-[NSArray moveLeft:]):
+        (-[NSArray moveLeftAndModifySelection:]):
+        (-[NSArray moveRight:]):
+        (-[NSArray moveRightAndModifySelection:]):
+        (-[NSArray moveToBeginningOfDocument:]):
+        (-[NSArray moveToBeginningOfDocumentAndModifySelection:]):
+        (-[NSArray moveToBeginningOfSentence:]):
+        (-[NSArray moveToBeginningOfSentenceAndModifySelection:]):
+        (-[NSArray moveToBeginningOfLine:]):
+        (-[NSArray moveToBeginningOfLineAndModifySelection:]):
+        (-[NSArray moveToBeginningOfParagraph:]):
+        (-[NSArray moveToBeginningOfParagraphAndModifySelection:]):
+        (-[NSArray moveToEndOfDocument:]):
+        (-[NSArray moveToEndOfDocumentAndModifySelection:]):
+        (-[NSArray moveToEndOfSentence:]):
+        (-[NSArray moveToEndOfSentenceAndModifySelection:]):
+        (-[NSArray moveToEndOfLine:]):
+        (-[NSArray moveToEndOfLineAndModifySelection:]):
+        (-[NSArray moveToEndOfParagraph:]):
+        (-[NSArray moveToEndOfParagraphAndModifySelection:]):
+        (-[NSArray moveParagraphBackwardAndModifySelection:]):
+        (-[NSArray moveParagraphForwardAndModifySelection:]):
+        (-[NSArray moveUp:]):
+        (-[NSArray moveUpAndModifySelection:]):
+        (-[NSArray moveWordBackward:]):
+        (-[NSArray moveWordBackwardAndModifySelection:]):
+        (-[NSArray moveWordForward:]):
+        (-[NSArray moveWordForwardAndModifySelection:]):
+        (-[NSArray moveWordLeft:]):
+        (-[NSArray moveWordLeftAndModifySelection:]):
+        (-[NSArray moveWordRight:]):
+        (-[NSArray moveWordRightAndModifySelection:]):
+
 2006-11-10  Brady Eidson  <beidson@apple.com>
 
         Reviewed by Darin
index 173c6cc806f9152f595d8c376eb0fa91f394411a..912b9ccfd45c0d2064e53422554d3bc2c2fcc4d9 100644 (file)
                149C283308902B0F008A9EFC /* Debug */ = {
                        isa = XCBuildConfiguration;
                        buildSettings = {
-                               DEBUG_INFORMATION_FORMAT = stabs;
+                               DEBUG_INFORMATION_FORMAT = dwarf;
                                GCC_C_LANGUAGE_STANDARD = gnu99;
                                GCC_ENABLE_CPP_EXCEPTIONS = NO;
                                GCC_ENABLE_CPP_RTTI = NO;
                        isa = XCBuildConfiguration;
                        buildSettings = {
                                DEAD_CODE_STRIPPING = YES;
-                               DEBUG_INFORMATION_FORMAT = stabs;
+                               DEBUG_INFORMATION_FORMAT = dwarf;
                                GCC_C_LANGUAGE_STANDARD = gnu99;
                                GCC_DEBUGGING_SYMBOLS = full;
                                GCC_ENABLE_CPP_EXCEPTIONS = NO;
index 1b4b535895f852160ad250053d1d237ad81d543b..d41d6ee221d9fcf3fe9bc3bdabc51ff667b899e7 100644 (file)
@@ -3532,236 +3532,236 @@ done:
 
 - (void)centerSelectionInVisibleArea:(id)sender
 {
-    if (FrameMac* coreFrame = core([self _frame]))
+    if (Frame* coreFrame = core([self _frame]))
         coreFrame->revealSelection(RenderLayer::gAlignCenterAlways);
 }
 
 - (void)moveBackward:(id)sender
 {
-    if ([self _canAlterCurrentSelection])
-        [[self _bridge] alterCurrentSelection:SelectionController::MOVE direction:SelectionController::BACKWARD granularity:CharacterGranularity];
+    if (Frame* coreFrame = core([self _frame]))
+        coreFrame->editor()->execCommand("MoveBackward");
 }
 
 - (void)moveBackwardAndModifySelection:(id)sender
 {
-    if ([self _canAlterCurrentSelection])
-        [[self _bridge] alterCurrentSelection:SelectionController::EXTEND direction:SelectionController::BACKWARD granularity:CharacterGranularity];
+    if (Frame* coreFrame = core([self _frame]))
+        coreFrame->editor()->execCommand("MoveBackwardAndModifySelection");
 }
 
 - (void)moveDown:(id)sender
 {
-    if ([self _canAlterCurrentSelection])
-        [[self _bridge] alterCurrentSelection:SelectionController::MOVE direction:SelectionController::FORWARD granularity:LineGranularity];
+    if (Frame* coreFrame = core([self _frame]))
+        coreFrame->editor()->execCommand("MoveDown");
 }
 
 - (void)moveDownAndModifySelection:(id)sender
 {
-    if ([self _canAlterCurrentSelection])
-        [[self _bridge] alterCurrentSelection:SelectionController::EXTEND direction:SelectionController::FORWARD granularity:LineGranularity];
+    if (Frame* coreFrame = core([self _frame]))
+        coreFrame->editor()->execCommand("MoveDownAndModifySelection");
 }
 
 - (void)moveForward:(id)sender
 {
-    if ([self _canAlterCurrentSelection])
-        [[self _bridge] alterCurrentSelection:SelectionController::MOVE direction:SelectionController::FORWARD granularity:CharacterGranularity];
+    if (Frame* coreFrame = core([self _frame]))
+        coreFrame->editor()->execCommand("MoveForward");
 }
 
 - (void)moveForwardAndModifySelection:(id)sender
 {
-    if ([self _canAlterCurrentSelection])
-        [[self _bridge] alterCurrentSelection:SelectionController::EXTEND direction:SelectionController::FORWARD granularity:CharacterGranularity];
+    if (Frame* coreFrame = core([self _frame]))
+        coreFrame->editor()->execCommand("MoveForwardAndModifySelection");
 }
 
 - (void)moveLeft:(id)sender
 {
-    if ([self _canAlterCurrentSelection])
-        [[self _bridge] alterCurrentSelection:SelectionController::MOVE direction:SelectionController::LEFT granularity:CharacterGranularity];
+    if (Frame* coreFrame = core([self _frame]))
+        coreFrame->editor()->execCommand("MoveLeft");
 }
 
 - (void)moveLeftAndModifySelection:(id)sender
 {
-    if ([self _canAlterCurrentSelection])
-        [[self _bridge] alterCurrentSelection:SelectionController::EXTEND direction:SelectionController::LEFT granularity:CharacterGranularity];
+    if (Frame* coreFrame = core([self _frame]))
+        coreFrame->editor()->execCommand("MoveLeftAndModifySelection");
 }
 
 - (void)moveRight:(id)sender
 {
-    if ([self _canAlterCurrentSelection])
-        [[self _bridge] alterCurrentSelection:SelectionController::MOVE direction:SelectionController::RIGHT granularity:CharacterGranularity];
+    if (Frame* coreFrame = core([self _frame]))
+        coreFrame->editor()->execCommand("MoveRight");
 }
 
 - (void)moveRightAndModifySelection:(id)sender
 {
-    if ([self _canAlterCurrentSelection])
-        [[self _bridge] alterCurrentSelection:SelectionController::EXTEND direction:SelectionController::RIGHT granularity:CharacterGranularity];
+    if (Frame* coreFrame = core([self _frame]))
+        coreFrame->editor()->execCommand("MoveRightAndModifySelection");
 }
 
 - (void)moveToBeginningOfDocument:(id)sender
 {
-    if ([self _canAlterCurrentSelection])
-        [[self _bridge] alterCurrentSelection:SelectionController::MOVE direction:SelectionController::BACKWARD granularity:DocumentBoundary];
+    if (Frame* coreFrame = core([self _frame]))
+        coreFrame->editor()->execCommand("MoveToBeginningOfDocument");
 }
 
 - (void)moveToBeginningOfDocumentAndModifySelection:(id)sender
 {
-    if ([self _canAlterCurrentSelection])
-        [[self _bridge] alterCurrentSelection:SelectionController::EXTEND direction:SelectionController::BACKWARD granularity:DocumentBoundary];
+    if (Frame* coreFrame = core([self _frame]))
+        coreFrame->editor()->execCommand("MoveToBeginningOfDocumentAndModifySelection");
 }
 
 - (void)moveToBeginningOfSentence:(id)sender
 {
-    if ([self _canAlterCurrentSelection])
-        [[self _bridge] alterCurrentSelection:SelectionController::MOVE direction:SelectionController::BACKWARD granularity:SentenceBoundary];
+    if (Frame* coreFrame = core([self _frame]))
+        coreFrame->editor()->execCommand("MoveToBeginningOfSentence");
 }
 
 - (void)moveToBeginningOfSentenceAndModifySelection:(id)sender
 {
-    if ([self _canAlterCurrentSelection])
-        [[self _bridge] alterCurrentSelection:SelectionController::EXTEND direction:SelectionController::BACKWARD granularity:SentenceBoundary];
+    if (Frame* coreFrame = core([self _frame]))
+        coreFrame->editor()->execCommand("MoveToBeginningOfSentenceAndModifySelection");
 }
 
 - (void)moveToBeginningOfLine:(id)sender
 {
-    if ([self _canAlterCurrentSelection])
-        [[self _bridge] alterCurrentSelection:SelectionController::MOVE direction:SelectionController::BACKWARD granularity:LineBoundary];
+    if (Frame* coreFrame = core([self _frame]))
+        coreFrame->editor()->execCommand("MoveToBeginningOfLine");
 }
 
 - (void)moveToBeginningOfLineAndModifySelection:(id)sender
 {
-    if ([self _canAlterCurrentSelection])
-        [[self _bridge] alterCurrentSelection:SelectionController::EXTEND direction:SelectionController::BACKWARD granularity:LineBoundary];
+    if (Frame* coreFrame = core([self _frame]))
+        coreFrame->editor()->execCommand("MoveToBeginningOfLineAndModifySelection");
 }
 
 - (void)moveToBeginningOfParagraph:(id)sender
 {
-    if ([self _canAlterCurrentSelection])
-        [[self _bridge] alterCurrentSelection:SelectionController::MOVE direction:SelectionController::BACKWARD granularity:ParagraphBoundary];
+    if (Frame* coreFrame = core([self _frame]))
+        coreFrame->editor()->execCommand("MoveToBeginningOfParagraph");
 }
 
 - (void)moveToBeginningOfParagraphAndModifySelection:(id)sender
 {
-    if ([self _canAlterCurrentSelection])
-        [[self _bridge] alterCurrentSelection:SelectionController::EXTEND direction:SelectionController::BACKWARD granularity:ParagraphBoundary];
+    if (Frame* coreFrame = core([self _frame]))
+        coreFrame->editor()->execCommand("MoveToBeginningOfParagraphAndModifySelection");
 }
 
 - (void)moveToEndOfDocument:(id)sender
 {
-    if ([self _canAlterCurrentSelection])
-        [[self _bridge] alterCurrentSelection:SelectionController::MOVE direction:SelectionController::FORWARD granularity:DocumentBoundary];
+    if (Frame* coreFrame = core([self _frame]))
+        coreFrame->editor()->execCommand("MoveToEndOfDocument");
 }
 
 - (void)moveToEndOfDocumentAndModifySelection:(id)sender
 {
-    if ([self _canAlterCurrentSelection])
-        [[self _bridge] alterCurrentSelection:SelectionController::EXTEND direction:SelectionController::FORWARD granularity:DocumentBoundary];
+    if (Frame* coreFrame = core([self _frame]))
+        coreFrame->editor()->execCommand("MoveToEndOfDocumentAndModifySelection");
 }
 
 - (void)moveToEndOfSentence:(id)sender
 {
-    if ([self _canAlterCurrentSelection])
-        [[self _bridge] alterCurrentSelection:SelectionController::MOVE direction:SelectionController::FORWARD granularity:SentenceBoundary];
+    if (Frame* coreFrame = core([self _frame]))
+        coreFrame->editor()->execCommand("MoveToEndOfSentence");
 }
 
 - (void)moveToEndOfSentenceAndModifySelection:(id)sender
 {
-    if ([self _canAlterCurrentSelection])
-        [[self _bridge] alterCurrentSelection:SelectionController::EXTEND direction:SelectionController::FORWARD granularity:SentenceBoundary];
+    if (Frame* coreFrame = core([self _frame]))
+        coreFrame->editor()->execCommand("MoveToEndOfSentenceAndModifySelection");
 }
 
 - (void)moveToEndOfLine:(id)sender
 {
-    if ([self _canAlterCurrentSelection])
-        [[self _bridge] alterCurrentSelection:SelectionController::MOVE direction:SelectionController::FORWARD granularity:LineBoundary];
+    if (Frame* coreFrame = core([self _frame]))
+        coreFrame->editor()->execCommand("MoveToEndOfLine");
 }
 
 - (void)moveToEndOfLineAndModifySelection:(id)sender
 {
-    if ([self _canAlterCurrentSelection])
-        [[self _bridge] alterCurrentSelection:SelectionController::EXTEND direction:SelectionController::FORWARD granularity:LineBoundary];
+    if (Frame* coreFrame = core([self _frame]))
+        coreFrame->editor()->execCommand("MoveToEndOfLineAndModifySelection");
 }
 
 - (void)moveToEndOfParagraph:(id)sender
 {
-    if ([self _canAlterCurrentSelection])
-        [[self _bridge] alterCurrentSelection:SelectionController::MOVE direction:SelectionController::FORWARD granularity:ParagraphBoundary];
+    if (Frame* coreFrame = core([self _frame]))
+        coreFrame->editor()->execCommand("MoveToEndOfParagraph");
 }
 
 - (void)moveToEndOfParagraphAndModifySelection:(id)sender
 {
-    if ([self _canAlterCurrentSelection])
-        [[self _bridge] alterCurrentSelection:SelectionController::EXTEND direction:SelectionController::FORWARD granularity:ParagraphBoundary];
+    if (Frame* coreFrame = core([self _frame]))
+        coreFrame->editor()->execCommand("MoveToEndOfParagraphAndModifySelection");
 }
 
 - (void)moveParagraphBackwardAndModifySelection:(id)sender
 {
-    if ([self _canAlterCurrentSelection])
-        [[self _bridge] alterCurrentSelection:SelectionController::EXTEND direction:SelectionController::BACKWARD granularity:ParagraphGranularity];
+    if (Frame* coreFrame = core([self _frame]))
+        coreFrame->editor()->execCommand("MoveParagraphBackwardAndModifySelection");
 }
 
 - (void)moveParagraphForwardAndModifySelection:(id)sender
 {
-    if ([self _canAlterCurrentSelection])
-        [[self _bridge] alterCurrentSelection:SelectionController::EXTEND direction:SelectionController::FORWARD granularity:ParagraphGranularity];
+    if (Frame* coreFrame = core([self _frame]))
+        coreFrame->editor()->execCommand("MoveParagraphForwardAndModifySelection");
 }
 
 - (void)moveUp:(id)sender
 {
-    if ([self _canAlterCurrentSelection])
-        [[self _bridge] alterCurrentSelection:SelectionController::MOVE direction:SelectionController::BACKWARD granularity:LineGranularity];
+    if (Frame* coreFrame = core([self _frame]))
+        coreFrame->editor()->execCommand("MoveUp");
 }
 
 - (void)moveUpAndModifySelection:(id)sender
 {
-    if ([self _canAlterCurrentSelection])
-        [[self _bridge] alterCurrentSelection:SelectionController::EXTEND direction:SelectionController::BACKWARD granularity:LineGranularity];
+    if (Frame* coreFrame = core([self _frame]))
+        coreFrame->editor()->execCommand("MoveUpAndModifySelection");
 }
 
 - (void)moveWordBackward:(id)sender
 {
-    if ([self _canAlterCurrentSelection])
-        [[self _bridge] alterCurrentSelection:SelectionController::MOVE direction:SelectionController::BACKWARD granularity:WordGranularity];
+    if (Frame* coreFrame = core([self _frame]))
+        coreFrame->editor()->execCommand("MoveWordBackward");
 }
 
 - (void)moveWordBackwardAndModifySelection:(id)sender
 {
-    if ([self _canAlterCurrentSelection])
-        [[self _bridge] alterCurrentSelection:SelectionController::EXTEND direction:SelectionController::BACKWARD granularity:WordGranularity];
+    if (Frame* coreFrame = core([self _frame]))
+        coreFrame->editor()->execCommand("MoveWordBackwardAndModifySelection");
 }
 
 - (void)moveWordForward:(id)sender
 {
-    if ([self _canAlterCurrentSelection])
-        [[self _bridge] alterCurrentSelection:SelectionController::MOVE direction:SelectionController::FORWARD granularity:WordGranularity];
+    if (Frame* coreFrame = core([self _frame]))
+        coreFrame->editor()->execCommand("MoveWordForward");
 }
 
 - (void)moveWordForwardAndModifySelection:(id)sender
 {
-    if ([self _canAlterCurrentSelection])
-        [[self _bridge] alterCurrentSelection:SelectionController::EXTEND direction:SelectionController::FORWARD granularity:WordGranularity];
+    if (Frame* coreFrame = core([self _frame]))
+        coreFrame->editor()->execCommand("MoveWordForwardAndModifySelection");
 }
 
 - (void)moveWordLeft:(id)sender
 {
-    if ([self _canAlterCurrentSelection])
-        [[self _bridge] alterCurrentSelection:SelectionController::MOVE direction:SelectionController::LEFT granularity:WordGranularity];
+    if (Frame* coreFrame = core([self _frame]))
+        coreFrame->editor()->execCommand("MoveWordLeft");
 }
 
 - (void)moveWordLeftAndModifySelection:(id)sender
 {
-    if ([self _canAlterCurrentSelection])
-        [[self _bridge] alterCurrentSelection:SelectionController::EXTEND direction:SelectionController::LEFT granularity:WordGranularity];
+    if (Frame* coreFrame = core([self _frame]))
+        coreFrame->editor()->execCommand("MoveWordLeftAndModifySelection");
 }
 
 - (void)moveWordRight:(id)sender
 {
-    if ([self _canAlterCurrentSelection])
-        [[self _bridge] alterCurrentSelection:SelectionController::MOVE direction:SelectionController::RIGHT granularity:WordGranularity];
+    if (Frame* coreFrame = core([self _frame]))
+        coreFrame->editor()->execCommand("MoveWordRight");
 }
 
 - (void)moveWordRightAndModifySelection:(id)sender
 {
-    if ([self _canAlterCurrentSelection])
-        [[self _bridge] alterCurrentSelection:SelectionController::EXTEND direction:SelectionController::RIGHT granularity:WordGranularity];
+    if (Frame* coreFrame = core([self _frame]))
+        coreFrame->editor()->execCommand("MoveWordRightAndModifySelection");
 }
 
 - (void)pageUp:(id)sender