Reviewed by Adam Roben.
authorhbono@chromium.org <hbono@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 12 Jul 2011 02:51:39 +0000 (02:51 +0000)
committerhbono@chromium.org <hbono@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 12 Jul 2011 02:51:39 +0000 (02:51 +0000)
Implement layoutTestController.setTextDirection for WebKit2 and Windows.
https://bugs.webkit.org/show_bug.cgi?id=61931

This change implements layoutTextController.setTextDirection for WebKit2
and Windows so we can run a layout test added by r87770 on them. Each
implementation adds a wrapper function for Editor::setBaseWritingDirection()
so LayoutTestController can call it.

Source/WebKit/win:

* Interfaces/IWebFramePrivate.idl: Added setTextDirection to allow
LayoutTestController to change the text direction.
* WebFrame.cpp: ditto.
(WebFrame::setTextDirection):
* WebFrame.h: ditto.

Source/WebKit2:

* WebProcess/InjectedBundle/API/c/WKBundleFrame.cpp: Added
WKBundleFrameSetTextDirection to allow LayoutTestController to change the
text direction.
(WKBundleFrameSetTextDirection):
* WebProcess/InjectedBundle/API/c/WKBundleFramePrivate.h: ditto.
* WebProcess/WebPage/WebFrame.cpp: Added setTextDirection to allow
WKBundleFrame to change the text direction.
(WebKit::WebFrame::setTextDirection):
* WebProcess/WebPage/WebFrame.h: ditto.

Tools:

* DumpRenderTree/win/LayoutTestControllerWin.cpp:
(LayoutTestController::setTextDirection): Implemented the binding function
for layoutTestController.setTextDirection (Windows).
* WebKitTestRunner/InjectedBundle/Bindings/LayoutTestController.idl:
Added a binding function for layoutTestController.setTextDirection (WebKit2).
* WebKitTestRunner/InjectedBundle/LayoutTestController.cpp: ditto.
(WTR::LayoutTestController::setTextDirection):
* WebKitTestRunner/InjectedBundle/LayoutTestController.h: ditto.

LayoutTests:

* platform/mac-wk2/Skipped: Removed set-text-direction.html.
* platform/win/Skipped: ditto.

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

17 files changed:
LayoutTests/ChangeLog
LayoutTests/platform/win/Skipped
LayoutTests/platform/wk2/Skipped
Source/WebKit/win/ChangeLog
Source/WebKit/win/Interfaces/IWebFramePrivate.idl
Source/WebKit/win/WebFrame.cpp
Source/WebKit/win/WebFrame.h
Source/WebKit2/ChangeLog
Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleFrame.cpp
Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleFramePrivate.h
Source/WebKit2/WebProcess/WebPage/WebFrame.cpp
Source/WebKit2/WebProcess/WebPage/WebFrame.h
Tools/ChangeLog
Tools/DumpRenderTree/win/LayoutTestControllerWin.cpp
Tools/WebKitTestRunner/InjectedBundle/Bindings/LayoutTestController.idl
Tools/WebKitTestRunner/InjectedBundle/LayoutTestController.cpp
Tools/WebKitTestRunner/InjectedBundle/LayoutTestController.h

index 0c08043..ee95c2a 100644 (file)
@@ -1,3 +1,18 @@
+2011-07-11  Hironori Bono  <hbono@chromium.org>
+
+        Reviewed by Adam Roben.
+
+        Implement layoutTestController.setTextDirection for WebKit2 and Windows.
+        https://bugs.webkit.org/show_bug.cgi?id=61931
+
+        This change implements layoutTextController.setTextDirection for WebKit2
+        and Windows so we can run a layout test added by r87770 on them. Each
+        implementation adds a wrapper function for Editor::setBaseWritingDirection()
+        so LayoutTestController can call it.
+
+        * platform/mac-wk2/Skipped: Removed set-text-direction.html.
+        * platform/win/Skipped: ditto.
+
 2011-07-11  Ryosuke Niwa  <rniwa@webkit.org>
 
         Skip hittest-on-relative-positioned-children.html in WebKit2.
index a848066..428dd4c 100644 (file)
@@ -1007,9 +1007,6 @@ editing/spelling/grammar.html
 # EditorClient::requestCheckingOfString() is not implemented
 editing/spelling/spellcheck-paste.html
 
-# layoutTestController::setTextDirection() is not implemented
-fast/html/set-text-direction.html
-
 # IndexedDB is not yet enabled.
 storage/indexeddb
 
index c268be9..ccb6f1a 100644 (file)
@@ -411,10 +411,6 @@ scrollbars/scrollbar-iframe-click-does-not-blur-content.html
 scrollbars/scrollbar-miss-mousemove-disabled.html
 scrollbars/scrollevent-iframe-no-scrolling-wheel.html
 
-# WebKitTestRunner needs an implementation of setTextDirection.
-# <https://bugs.webkit.org/show_bug.cgi?id=61931>
-fast/html/set-text-direction.html
-
 # CONSOLE MESSAGE: line 0: SVG animation pause API missing!
 # [WK2] SVG animation pause API missing
 # https://bugs.webkit.org/show_bug.cgi?id=63396
index b57a36a..20ff91c 100644 (file)
@@ -1,3 +1,21 @@
+2011-07-11  Hironori Bono  <hbono@chromium.org>
+
+        Reviewed by Adam Roben.
+
+        Implement layoutTestController.setTextDirection for WebKit2 and Windows.
+        https://bugs.webkit.org/show_bug.cgi?id=61931
+
+        This change implements layoutTextController.setTextDirection for WebKit2
+        and Windows so we can run a layout test added by r87770 on them. Each
+        implementation adds a wrapper function for Editor::setBaseWritingDirection()
+        so LayoutTestController can call it.
+
+        * Interfaces/IWebFramePrivate.idl: Added setTextDirection to allow
+        LayoutTestController to change the text direction.
+        * WebFrame.cpp: ditto.
+        (WebFrame::setTextDirection):
+        * WebFrame.h: ditto.
+
 2011-07-08  Chang Shu  <cshu@webkit.org>
 
         Update calling sites after function renamed.
index 8457780..31287ba 100644 (file)
@@ -120,4 +120,6 @@ interface IWebFramePrivate : IUnknown
     HRESULT hasSpellingMarker([in] UINT from, [in] UINT length, [out, retval] BOOL* result);
     
     HRESULT clearOpener();
+
+    HRESULT setTextDirection([in] BSTR direction);
 }
index f9c12f6..b8bb249 100644 (file)
@@ -1061,6 +1061,22 @@ HRESULT STDMETHODCALLTYPE WebFrame::clearOpener()
     return hr;
 }
 
+HRESULT WebFrame::setTextDirection(BSTR direction)
+{
+    Frame* coreFrame = core(this);
+    if (!coreFrame || !coreFrame->editor())
+        return E_FAIL;
+
+    String directionString(direction, SysStringLen(direction));
+    if (directionString == "auto")
+        coreFrame->editor()->setBaseWritingDirection(NaturalWritingDirection);
+    else if (directionString == "ltr")
+        coreFrame->editor()->setBaseWritingDirection(LeftToRightWritingDirection);
+    else if (directionString == "rtl")
+        coreFrame->editor()->setBaseWritingDirection(RightToLeftWritingDirection);
+    return S_OK;
+}
+
 // IWebDocumentText -----------------------------------------------------------
 
 HRESULT STDMETHODCALLTYPE WebFrame::supportsTextEncoding( 
index 6552960..8046d85 100644 (file)
@@ -283,6 +283,8 @@ public:
 
     virtual HRESULT STDMETHODCALLTYPE clearOpener();
 
+    virtual HRESULT STDMETHODCALLTYPE setTextDirection(BSTR);
+
     // IWebDocumentText
     virtual HRESULT STDMETHODCALLTYPE supportsTextEncoding( 
         /* [retval][out] */ BOOL* result);
index ba2edc6..b76f260 100644 (file)
@@ -1,3 +1,25 @@
+2011-07-11  Hironori Bono  <hbono@chromium.org>
+
+        Reviewed by Adam Roben.
+
+        Implement layoutTestController.setTextDirection for WebKit2 and Windows.
+        https://bugs.webkit.org/show_bug.cgi?id=61931
+
+        This change implements layoutTextController.setTextDirection for WebKit2
+        and Windows so we can run a layout test added by r87770 on them. Each
+        implementation adds a wrapper function for Editor::setBaseWritingDirection()
+        so LayoutTestController can call it.
+
+        * WebProcess/InjectedBundle/API/c/WKBundleFrame.cpp: Added
+        WKBundleFrameSetTextDirection to allow LayoutTestController to change the
+        text direction.
+        (WKBundleFrameSetTextDirection):
+        * WebProcess/InjectedBundle/API/c/WKBundleFramePrivate.h: ditto.
+        * WebProcess/WebPage/WebFrame.cpp: Added setTextDirection to allow
+        WKBundleFrame to change the text direction.
+        (WebKit::WebFrame::setTextDirection):
+        * WebProcess/WebPage/WebFrame.h: ditto.
+
 2011-07-11  Benjamin Poulain  <benjamin@webkit.org>
 
         [Qt][WK2] Get rid of focusNextPrevChild()
index 814b7ed..5455e60 100644 (file)
@@ -235,3 +235,8 @@ bool WKBundleFrameContainsAnyFormElements(WKBundleFrameRef frameRef)
 {
     return toImpl(frameRef)->containsAnyFormElements();
 }
+
+void WKBundleFrameSetTextDirection(WKBundleFrameRef frameRef, WKStringRef directionRef)
+{
+    toImpl(frameRef)->setTextDirection(toImpl(directionRef)->string());
+}
index 9eb7156..a786b25 100644 (file)
@@ -51,6 +51,7 @@ WK_EXPORT WKStringRef WKBundleFrameCopyLayerTreeAsText(WKBundleFrameRef frame);
 WK_EXPORT void WKBundleFrameClearOpener(WKBundleFrameRef frame);
 
 WK_EXPORT bool WKBundleFrameContainsAnyFormElements(WKBundleFrameRef frame);
+WK_EXPORT void WKBundleFrameSetTextDirection(WKBundleFrameRef frame, WKStringRef);
 
 #ifdef __cplusplus
 }
index 2624476..46f99e3 100644 (file)
@@ -705,4 +705,17 @@ String WebFrame::mimeTypeForResourceWithURL(const KURL& url) const
     return page()->cachedResponseMIMETypeForURL(url);
 }
 
+void WebFrame::setTextDirection(const String& direction)
+{
+    if (!m_coreFrame || !m_coreFrame->editor())
+        return;
+
+    if (direction == "auto")
+        m_coreFrame->editor()->setBaseWritingDirection(NaturalWritingDirection);
+    else if (direction == "ltr")
+        m_coreFrame->editor()->setBaseWritingDirection(LeftToRightWritingDirection);
+    else if (direction == "rtl")
+        m_coreFrame->editor()->setBaseWritingDirection(RightToLeftWritingDirection);
+}
+
 } // namespace WebKit
index 44e16ba..975712d 100644 (file)
@@ -121,6 +121,8 @@ public:
     String suggestedFilenameForResourceWithURL(const WebCore::KURL&) const;
     String mimeTypeForResourceWithURL(const WebCore::KURL&) const;
 
+    void setTextDirection(const String&);
+
     // Simple listener class used by plug-ins to know when frames finish or fail loading.
     class LoadListener {
     public:
index b977bdc..b39f487 100644 (file)
@@ -1,3 +1,24 @@
+2011-07-11  Hironori Bono  <hbono@chromium.org>
+
+        Reviewed by Adam Roben.
+
+        Implement layoutTestController.setTextDirection for WebKit2 and Windows.
+        https://bugs.webkit.org/show_bug.cgi?id=61931
+
+        This change implements layoutTextController.setTextDirection for WebKit2
+        and Windows so we can run a layout test added by r87770 on them. Each
+        implementation adds a wrapper function for Editor::setBaseWritingDirection()
+        so LayoutTestController can call it.
+
+        * DumpRenderTree/win/LayoutTestControllerWin.cpp:
+        (LayoutTestController::setTextDirection): Implemented the binding function
+        for layoutTestController.setTextDirection (Windows).
+        * WebKitTestRunner/InjectedBundle/Bindings/LayoutTestController.idl:
+        Added a binding function for layoutTestController.setTextDirection (WebKit2).
+        * WebKitTestRunner/InjectedBundle/LayoutTestController.cpp: ditto.
+        (WTR::LayoutTestController::setTextDirection):
+        * WebKitTestRunner/InjectedBundle/LayoutTestController.h: ditto.
+
 2011-07-11  Raphael Kubo da Costa  <kubo@profusion.mobi>
 
         [EFL] ImageDiff: Make sure gEcoreEvas is destroyed at the right time.
index d8de2b9..0097583 100644 (file)
@@ -1524,7 +1524,11 @@ void LayoutTestController::setMinimumTimerInterval(double minimumTimerInterval)
 
 void LayoutTestController::setTextDirection(JSStringRef direction)
 {
-    // FIXME: Implement.
+    COMPtr<IWebFramePrivate> framePrivate(Query, frame);
+    if (!framePrivate)
+        return;
+
+    framePrivate->setTextDirection(bstrT(direction).GetBSTR());
 }
 
 void LayoutTestController::allowRoundingHacks()
index d72b0a2..5278b39 100644 (file)
@@ -108,6 +108,8 @@ module WTR {
 
         void setPOSIXLocale(in DOMString locale);
 
+        void setTextDirection(in DOMString direction);
+
         void setWillSendRequestReturnsNull(in boolean flag);
     };
 
index 014f9ca..fad79d3 100644 (file)
@@ -473,4 +473,10 @@ void LayoutTestController::setPOSIXLocale(JSStringRef locale)
     setlocale(LC_ALL, localeBuf);
 }
 
+void LayoutTestController::setTextDirection(JSStringRef direction)
+{
+    WKBundleFrameRef mainFrame = WKBundlePageGetMainFrame(InjectedBundle::shared().page()->page());
+    return WKBundleFrameSetTextDirection(mainFrame, toWK(direction).get());
+}
+
 } // namespace WTR
index 68d8a94..69c3588 100644 (file)
@@ -162,6 +162,8 @@ public:
     bool willSendRequestReturnsNull() { return m_willSendRequestReturnsNull; }
     void setWillSendRequestReturnsNull(bool f) { m_willSendRequestReturnsNull = f; }
 
+    void setTextDirection(JSStringRef);
+
 private:
     static const double waitToDumpWatchdogTimerInterval;