WebCore:
authormitz@apple.com <mitz@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 1 Jul 2008 22:34:44 +0000 (22:34 +0000)
committermitz@apple.com <mitz@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 1 Jul 2008 22:34:44 +0000 (22:34 +0000)
        Reviewed by Darin Adler.

        - move the method to set the base writing direction from Frame to Editor

        * WebCore.base.exp: Updated.
        * editing/Editor.cpp:
        (WebCore::Editor::setBaseWritingDirection): Changed the parameter to a
        WritingDirection enum value and added the special behavior when the
        focused node is a text field or a text area.
        * editing/Editor.h:
        * page/ContextMenuController.cpp:
        (WebCore::ContextMenuController::contextMenuItemSelected): Changed back
        to call the Editor method.
        * page/Frame.cpp: Removed setSelectionBaseWritingDirection().
        * page/Frame.h:

WebKit/mac:

        Reviewed by Darin Adler.

        - WebKit part of moving the method to set the base writing direction from Frame to Editor

        * WebView/WebHTMLView.mm:
        (-[WebHTMLView toggleBaseWritingDirection:]): Changed back to call the
        Editor method.
        (-[WebHTMLView changeBaseWritingDirection:]): Ditto.
        (-[WebHTMLView _changeBaseWritingDirectionTo:]): Ditto.

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

WebCore/ChangeLog
WebCore/WebCore.base.exp
WebCore/editing/Editor.cpp
WebCore/editing/Editor.h
WebCore/page/ContextMenuController.cpp
WebCore/page/Frame.cpp
WebCore/page/Frame.h
WebKit/mac/ChangeLog
WebKit/mac/WebView/WebHTMLView.mm

index d36ab30..f1e6371 100644 (file)
@@ -1,3 +1,21 @@
+2008-07-01  Dan Bernstein  <mitz@apple.com>
+
+        Reviewed by Darin Adler.
+
+        - move the method to set the base writing direction from Frame to Editor
+
+        * WebCore.base.exp: Updated.
+        * editing/Editor.cpp:
+        (WebCore::Editor::setBaseWritingDirection): Changed the parameter to a
+        WritingDirection enum value and added the special behavior when the
+        focused node is a text field or a text area.
+        * editing/Editor.h:
+        * page/ContextMenuController.cpp:
+        (WebCore::ContextMenuController::contextMenuItemSelected): Changed back
+        to call the Editor method.
+        * page/Frame.cpp: Removed setSelectionBaseWritingDirection().
+        * page/Frame.h:
+
 2008-07-01  Darin Adler  <darin@apple.com>
 
         Reviewed by Oliver.
index bd9b190..f9bae2e 100644 (file)
@@ -466,7 +466,6 @@ __ZN7WebCore5Frame25matchLabelsAgainstElementEP7NSArrayPNS_7ElementE
 __ZN7WebCore5Frame28searchForLabelsBeforeElementEP7NSArrayPNS_7ElementE
 __ZN7WebCore5Frame29cleanupScriptObjectsForPluginEPv
 __ZN7WebCore5Frame29forceLayoutWithPageWidthRangeEffb
-__ZN7WebCore5Frame32setSelectionBaseWritingDirectionENS_16WritingDirectionE
 __ZN7WebCore5Frame34setMarkedTextMatchesAreHighlightedEb
 __ZN7WebCore5Frame4initEv
 __ZN7WebCore5Frame5paintEPNS_15GraphicsContextERKNS_7IntRectE
@@ -498,6 +497,7 @@ __ZN7WebCore6Editor19deleteWithDirectionENS_19SelectionController10EDirectionENS
 __ZN7WebCore6Editor19insertUnorderedListEv
 __ZN7WebCore6Editor21applyStyleToSelectionEPNS_19CSSStyleDeclarationENS_10EditActionE
 __ZN7WebCore6Editor21isSelectionMisspelledEv
+__ZN7WebCore6Editor23setBaseWritingDirectionENS_16WritingDirectionE
 __ZN7WebCore6Editor24advanceToNextMisspellingEb
 __ZN7WebCore6Editor24isSelectionUngrammaticalEv
 __ZN7WebCore6Editor26decreaseSelectionListLevelEv
index 40a8431..526ed11 100644 (file)
@@ -1084,12 +1084,21 @@ void Editor::toggleUnderline()
     command("ToggleUnderline").execute();
 }
 
-void Editor::setBaseWritingDirection(const String& direction)
+void Editor::setBaseWritingDirection(WritingDirection direction)
 {
+    Node* focusedNode = frame()->document()->focusedNode();
+    if (focusedNode && (focusedNode->hasTagName(textareaTag)
+                        || focusedNode->hasTagName(inputTag) && (static_cast<HTMLInputElement*>(focusedNode)->inputType() == HTMLInputElement::TEXT
+                                                                || static_cast<HTMLInputElement*>(focusedNode)->inputType() == HTMLInputElement::SEARCH))) {
+        if (direction == NaturalWritingDirection)
+            return;
+        static_cast<HTMLElement*>(focusedNode)->setAttribute(dirAttr, direction == LeftToRightWritingDirection ? "ltr" : "rtl");
+        frame()->document()->updateRendering();
+        return;
+    }
 
     RefPtr<CSSMutableStyleDeclaration> style = CSSMutableStyleDeclaration::create();
-    ExceptionCode ec;
-    style->setProperty(CSSPropertyDirection, direction, false, ec);
+    style->setProperty(CSSPropertyDirection, direction == LeftToRightWritingDirection ? "ltr" : direction == RightToLeftWritingDirection ? "rtl" : "inherit", false);
     applyParagraphStyleToSelection(style.get(), EditActionSetWritingDirection);
 }
 
index fe731c1..14de1e3 100644 (file)
@@ -60,6 +60,7 @@ struct CompositionUnderline {
 
 enum TriState { FalseTriState, TrueTriState, MixedTriState };
 enum EditorCommandSource { CommandFromMenuOrKeyBinding, CommandFromDOM, CommandFromDOMWithUserInterface };
+enum WritingDirection { NaturalWritingDirection, LeftToRightWritingDirection, RightToLeftWritingDirection };
 
 class Editor {
 public:
@@ -215,7 +216,7 @@ public:
     void showColorPanel();
     void toggleBold();
     void toggleUnderline();
-    void setBaseWritingDirection(const String&);
+    void setBaseWritingDirection(WritingDirection);
 
     bool smartInsertDeleteEnabled();
     
index ed56de6..c7f0235 100644 (file)
@@ -249,13 +249,13 @@ void ContextMenuController::contextMenuItemSelected(ContextMenuItem* item)
             m_client->stopSpeaking();
             break;
         case ContextMenuItemTagDefaultDirection:
-            frame->setSelectionBaseWritingDirection(NaturalWritingDirection);
+            frame->editor()->setBaseWritingDirection(NaturalWritingDirection);
             break;
         case ContextMenuItemTagLeftToRight:
-            frame->setSelectionBaseWritingDirection(LeftToRightWritingDirection);
+            frame->editor()->setBaseWritingDirection(LeftToRightWritingDirection);
             break;
         case ContextMenuItemTagRightToLeft:
-            frame->setSelectionBaseWritingDirection(RightToLeftWritingDirection);
+            frame->editor()->setBaseWritingDirection(RightToLeftWritingDirection);
             break;
 #if PLATFORM(MAC)
         case ContextMenuItemTagSearchInSpotlight:
index 5bc8ea5..ef4ed78 100644 (file)
@@ -49,7 +49,6 @@
 #include "HTMLFormElement.h"
 #include "HTMLFrameElementBase.h"
 #include "HTMLFormControlElement.h"
-#include "HTMLInputElement.h"
 #include "HTMLNames.h"
 #include "HTMLTableCellElement.h"
 #include "HitTestResult.h"
@@ -838,20 +837,6 @@ void Frame::updateSecureKeyboardEntryIfActive()
         setUseSecureKeyboardEntry(d->m_doc->useSecureKeyboardEntryWhenActive());
 }
 
-void Frame::setSelectionBaseWritingDirection(WritingDirection direction)
-{
-    Node* focusedNode = document()->focusedNode();
-    if (focusedNode && (focusedNode->hasTagName(textareaTag)
-                        || focusedNode->hasTagName(inputTag) && (static_cast<HTMLInputElement*>(focusedNode)->inputType() == HTMLInputElement::TEXT
-                                                                || static_cast<HTMLInputElement*>(focusedNode)->inputType() == HTMLInputElement::SEARCH))) {
-        if (direction == NaturalWritingDirection)
-            return;
-        static_cast<HTMLElement*>(focusedNode)->setAttribute(dirAttr, direction == LeftToRightWritingDirection ? "ltr" : "rtl");
-        document()->updateRendering();
-    } else
-        editor()->setBaseWritingDirection(direction == LeftToRightWritingDirection ? "ltr" : direction == RightToLeftWritingDirection ? "rtl" : "inherit");
-}
-
 CSSMutableStyleDeclaration *Frame::typingStyle() const
 {
     return d->m_typingStyle.get();
index 6596298..7de7812 100644 (file)
@@ -78,12 +78,6 @@ class Widget;
 
 template <typename T> class Timer;
 
-enum WritingDirection {
-    NaturalWritingDirection,
-    LeftToRightWritingDirection,
-    RightToLeftWritingDirection
-};
-
 class Frame : public RefCounted<Frame> {
 public:
     static PassRefPtr<Frame> create(Page* page, HTMLFrameOwnerElement* ownerElement, FrameLoaderClient* client)
@@ -319,8 +313,6 @@ public:
 
     void setUseSecureKeyboardEntry(bool);
 
-    void setSelectionBaseWritingDirection(WritingDirection);
-
 private:
     void caretBlinkTimerFired(Timer<Frame>*);
 
index 598eafe..f73281c 100644 (file)
@@ -1,3 +1,15 @@
+2008-07-01  Dan Bernstein  <mitz@apple.com>
+
+        Reviewed by Darin Adler.
+
+        - WebKit part of moving the method to set the base writing direction from Frame to Editor
+
+        * WebView/WebHTMLView.mm:
+        (-[WebHTMLView toggleBaseWritingDirection:]): Changed back to call the
+        Editor method.
+        (-[WebHTMLView changeBaseWritingDirection:]): Ditto.
+        (-[WebHTMLView _changeBaseWritingDirectionTo:]): Ditto.
+
 2008-07-01  Geoffrey Garen  <ggaren@apple.com>
 
         Build fix: forgot to check in this file.
index cd0586c..408e593 100644 (file)
@@ -4372,7 +4372,7 @@ NSStrokeColorAttributeName        /* NSColor, default nil: same as foreground co
     }
 
     if (Frame* coreFrame = core([self _frame]))
-        coreFrame->setSelectionBaseWritingDirection(direction);
+        coreFrame->editor()->setBaseWritingDirection(direction);
 }
 
 - (void)changeBaseWritingDirection:(id)sender
@@ -4389,7 +4389,7 @@ NSStrokeColorAttributeName        /* NSColor, default nil: same as foreground co
     ASSERT(writingDirection != NSWritingDirectionNatural);
 
     if (Frame* coreFrame = core([self _frame]))
-        coreFrame->setSelectionBaseWritingDirection(writingDirection == NSWritingDirectionLeftToRight ? LeftToRightWritingDirection : RightToLeftWritingDirection);
+        coreFrame->editor()->setBaseWritingDirection(writingDirection == NSWritingDirectionLeftToRight ? LeftToRightWritingDirection : RightToLeftWritingDirection);
 }
 
 static BOOL writingDirectionKeyBindingsEnabled()
@@ -4411,7 +4411,7 @@ static BOOL writingDirectionKeyBindingsEnabled()
     }
 
     if (Frame* coreFrame = core([self _frame]))
-        coreFrame->setSelectionBaseWritingDirection(direction == NSWritingDirectionLeftToRight ? LeftToRightWritingDirection : RightToLeftWritingDirection);
+        coreFrame->editor()->setBaseWritingDirection(direction == NSWritingDirectionLeftToRight ? LeftToRightWritingDirection : RightToLeftWritingDirection);
 }
 
 - (void)changeBaseWritingDirectionToLTR:(id)sender