Diff
Modified: trunk/LayoutTests/ChangeLog (87769 => 87770)
--- trunk/LayoutTests/ChangeLog 2011-06-01 02:22:52 UTC (rev 87769)
+++ trunk/LayoutTests/ChangeLog 2011-06-01 02:25:47 UTC (rev 87770)
@@ -1,3 +1,22 @@
+2011-05-31 Hironori Bono <hb...@chromium.org>
+
+ Reviewed by Eric Seidel.
+
+ Send an input event when we change the text direction.
+ https://bugs.webkit.org/show_bug.cgi?id=50952
+
+ This adds a new layout test to verify that we can receive input events
+ when we change the text direction of a <textarea> element and an <input>
+ element.
+
+ * fast/html/set-text-direction-expected.txt: Added.
+ * fast/html/set-text-direction.html: Added.
+ * platform/gtk/Skipped:
+ * platform/mac-leopard/Skipped:
+ * platform/mac-tiger/Skipped:
+ * platform/qt/Skipped:
+ * platform/win/Skipped:
+
2011-05-27 Adrienne Walker <e...@google.com>
Reviewed by James Robinson.
Added: trunk/LayoutTests/fast/html/set-text-direction-expected.txt (0 => 87770)
--- trunk/LayoutTests/fast/html/set-text-direction-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/html/set-text-direction-expected.txt 2011-06-01 02:25:47 UTC (rev 87770)
@@ -0,0 +1,17 @@
+Test that WebKit changes the dir attribute and sends an input event when we change the text direction.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS expected is textarea.dir
+PASS sentInputEvent is true
+PASS expected is textarea.dir
+PASS sentInputEvent is true
+PASS expected is input.dir
+PASS sentInputEvent is true
+PASS expected is input.dir
+PASS sentInputEvent is true
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Property changes on: trunk/LayoutTests/fast/html/set-text-direction-expected.txt
___________________________________________________________________
Added: svn:eol-style
Added: trunk/LayoutTests/fast/html/set-text-direction.html (0 => 87770)
--- trunk/LayoutTests/fast/html/set-text-direction.html (rev 0)
+++ trunk/LayoutTests/fast/html/set-text-direction.html 2011-06-01 02:25:47 UTC (rev 87770)
@@ -0,0 +1,85 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<link rel="stylesheet" href=""
+<script src=""
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+<script language="_javascript_" type="text/_javascript_">
+description('Test that WebKit changes the dir attribute and sends an input event when we change the text direction.');
+
+// The string used for storing the expected text direction when we receive an input event.
+var expected = '';
+var sentInputEvent = false;
+
+function removeChildAndForceGC(child) {
+ document.body.removeChild(child);
+ gc();
+}
+
+// Create a textarea element and an input element. These elements are used for
+// changing their text direction with Editor::setBaseWritingDirection() calls.
+var textarea = document.createElement('textarea');
+textarea.rows = 10;
+textarea.cols = 10;
+textarea._oninput_ = function() {
+ shouldBe('expected', 'textarea.dir');
+ sentInputEvent = true;
+
+ // When we change the direction to ltr, we remove this element to verify WebKit
+ // continue running without crashes.
+ if (expected == 'ltr')
+ removeChildAndForceGC(textarea);
+}
+document.body.appendChild(textarea);
+
+var input = document.createElement('input');
+input.type = 'text';
+input._oninput_ = function() {
+ shouldBe('expected', 'input.dir');
+ sentInputEvent = true;
+
+ // When we change the direction to ltr, we remove this element to verify WebKit
+ // continue running without crashes.
+ if (expected == 'ltr')
+ removeChildAndForceGC(input);
+}
+document.body.appendChild(input);
+
+// Change the text direction of the textarea element to RTL.
+expected = 'rtl';
+sentInputEvent = false;
+textarea.focus();
+layoutTestController.setTextDirection('rtl');
+shouldBeTrue('sentInputEvent');
+
+// Change the text direction of the textarea element to LTR.
+// This also removes the element to verify WebKit works without crashes.
+expected = 'ltr';
+sentInputEvent = false;
+textarea.focus();
+layoutTestController.setTextDirection('ltr');
+shouldBeTrue('sentInputEvent');
+
+// Change the text direction of the input element to RTL.
+expected = 'rtl';
+sentInputEvent = false;
+input.focus();
+layoutTestController.setTextDirection('rtl');
+shouldBeTrue('sentInputEvent');
+
+// Change the text direction of the input element to LTR.
+// This also removes the element to verify WebKit works without crashes.
+expected = 'ltr';
+sentInputEvent = false;
+input.focus();
+layoutTestController.setTextDirection('ltr');
+shouldBeTrue('sentInputEvent');
+
+var successfullyParsed = true;
+</script>
+<script src=""
+</body>
+</html>
Property changes on: trunk/LayoutTests/fast/html/set-text-direction.html
___________________________________________________________________
Added: svn:eol-style
Modified: trunk/LayoutTests/platform/gtk/Skipped (87769 => 87770)
--- trunk/LayoutTests/platform/gtk/Skipped 2011-06-01 02:22:52 UTC (rev 87769)
+++ trunk/LayoutTests/platform/gtk/Skipped 2011-06-01 02:25:47 UTC (rev 87770)
@@ -1409,6 +1409,9 @@
# textInputController.hasGrammarMarker() is not implemented.
editing/spelling/grammar.html
+# layoutTestController::setTextDirection() is not implemented.
+fast/html/set-text-direction.html
+
# https://bugs.webkit.org/show_bug.cgi?id=57160
# [GTK] layoutTestController.overridePreference("WebKitDefaultFontSize"...) does not take into account screen DPI
fast/harness/override-preferences-2.html
Modified: trunk/LayoutTests/platform/mac-leopard/Skipped (87769 => 87770)
--- trunk/LayoutTests/platform/mac-leopard/Skipped 2011-06-01 02:22:52 UTC (rev 87769)
+++ trunk/LayoutTests/platform/mac-leopard/Skipped 2011-06-01 02:25:47 UTC (rev 87770)
@@ -94,6 +94,7 @@
# Available 10.6 or later
editing/spelling/spellcheck-paste.html
+fast/html/set-text-direction.html
# Disable tests which started failing after r66961
# Failures look like an underlying platform issue
Modified: trunk/LayoutTests/platform/qt/Skipped (87769 => 87770)
--- trunk/LayoutTests/platform/qt/Skipped 2011-06-01 02:22:52 UTC (rev 87769)
+++ trunk/LayoutTests/platform/qt/Skipped 2011-06-01 02:25:47 UTC (rev 87770)
@@ -2518,5 +2518,8 @@
fast/events/selectstart-by-double-triple-clicks.html
fast/events/selectstart-by-drag.html
+# LayoutTestController::setTextDirection is not implemented.
+fast/html/set-text-direction.html
+
# JSC does not support setIsolatedWorldSecurityOrigin (http://webkit.org/b/61540)
http/tests/security/isolatedWorld/cross-origin-xhr.html
Modified: trunk/LayoutTests/platform/win/Skipped (87769 => 87770)
--- trunk/LayoutTests/platform/win/Skipped 2011-06-01 02:22:52 UTC (rev 87769)
+++ trunk/LayoutTests/platform/win/Skipped 2011-06-01 02:25:47 UTC (rev 87770)
@@ -990,6 +990,9 @@
# 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
Modified: trunk/Source/WebCore/ChangeLog (87769 => 87770)
--- trunk/Source/WebCore/ChangeLog 2011-06-01 02:22:52 UTC (rev 87769)
+++ trunk/Source/WebCore/ChangeLog 2011-06-01 02:25:47 UTC (rev 87770)
@@ -1,3 +1,21 @@
+2011-05-31 Hironori Bono <hb...@chromium.org>
+
+ Reviewed by Eric Seidel.
+
+ Send an input event when we change the text direction.
+ https://bugs.webkit.org/show_bug.cgi?id=50952
+
+ Both Safari and Chrome call Editor::setBaseWritingDirection() to change
+ the text direction of an editable element with their UIs. This change
+ calls dispatchInputEvent() to send an input event when the function
+ actually changes the "dir" attribute so we can send an input event as
+ written in the HTML5 spec.
+
+ Test: fast/html/set-text-direction.html
+
+ * editing/Editor.cpp:
+ (WebCore::Editor::setBaseWritingDirection):
+
2011-05-31 Jer Noble <jer.no...@apple.com>
Reviewed by Darin Adler.
Modified: trunk/Source/WebCore/editing/Editor.cpp (87769 => 87770)
--- trunk/Source/WebCore/editing/Editor.cpp 2011-06-01 02:22:52 UTC (rev 87769)
+++ trunk/Source/WebCore/editing/Editor.cpp 2011-06-01 02:25:47 UTC (rev 87770)
@@ -1447,6 +1447,7 @@
if (direction == NaturalWritingDirection)
return;
toHTMLElement(focusedNode)->setAttribute(dirAttr, direction == LeftToRightWritingDirection ? "ltr" : "rtl");
+ focusedNode->dispatchInputEvent();
frame()->document()->updateStyleIfNeeded();
return;
}
Modified: trunk/Tools/ChangeLog (87769 => 87770)
--- trunk/Tools/ChangeLog 2011-06-01 02:22:52 UTC (rev 87769)
+++ trunk/Tools/ChangeLog 2011-06-01 02:25:47 UTC (rev 87770)
@@ -1,3 +1,29 @@
+2011-05-31 Hironori Bono <hb...@chromium.org>
+
+ Reviewed by Eric Seidel.
+
+ Add a _javascript_ function layoutTestController.setTextDirection().
+ https://bugs.webkit.org/show_bug.cgi?id=50952
+
+ This change adds a new _javascript_ function setTextDirection() to the
+ LayoutTestController class of Safari and Chrome to write layout tests
+ that changes the text direction of an editable element.
+
+ * DumpRenderTree/LayoutTestController.cpp:
+ (setTextDirectionCallback):
+ (LayoutTestController::staticFunctions):
+ * DumpRenderTree/LayoutTestController.h:
+ * DumpRenderTree/chromium/LayoutTestController.cpp:
+ (LayoutTestController::LayoutTestController):
+ (LayoutTestController::setTextDirection):
+ * DumpRenderTree/chromium/LayoutTestController.h:
+ * DumpRenderTree/gtk/LayoutTestControllerGtk.cpp:
+ (LayoutTestController::setTextDirection):
+ * DumpRenderTree/mac/LayoutTestControllerMac.mm:
+ (LayoutTestController::setTextDirection):
+ * DumpRenderTree/win/LayoutTestControllerWin.cpp:
+ (LayoutTestController::setTextDirection):
+
2011-05-31 Ademar de Souza Reis Jr <ademar.r...@openbossa.org>
Reviewed by Simon Hausmann.
Modified: trunk/Tools/DumpRenderTree/LayoutTestController.cpp (87769 => 87770)
--- trunk/Tools/DumpRenderTree/LayoutTestController.cpp 2011-06-01 02:22:52 UTC (rev 87769)
+++ trunk/Tools/DumpRenderTree/LayoutTestController.cpp 2011-06-01 02:25:47 UTC (rev 87770)
@@ -2213,6 +2213,17 @@
return JSValueMakeUndefined(context);
}
+static JSValueRef setTextDirectionCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
+{
+ if (argumentCount == 1) {
+ JSRetainPtr<JSStringRef> direction(Adopt, JSValueToStringCopy(context, arguments[0], exception));
+ LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
+ controller->setTextDirection(direction.get());
+ }
+
+ return JSValueMakeUndefined(context);
+}
+
static void layoutTestControllerObjectFinalize(JSObjectRef object)
{
LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(object));
@@ -2422,6 +2433,7 @@
{ "localStorageDiskUsageForOrigin", localStorageDiskUsageForOriginCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
{ "originsWithLocalStorage", originsWithLocalStorageCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
{ "setShouldPaintBrokenImage", setShouldPaintBrokenImageCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
+ { "setTextDirection", setTextDirectionCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
{ "shadowPseudoId", shadowPseudoIdCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
{ 0, 0, 0 }
};
Modified: trunk/Tools/DumpRenderTree/LayoutTestController.h (87769 => 87770)
--- trunk/Tools/DumpRenderTree/LayoutTestController.h 2011-06-01 02:22:52 UTC (rev 87769)
+++ trunk/Tools/DumpRenderTree/LayoutTestController.h 2011-06-01 02:25:47 UTC (rev 87770)
@@ -345,6 +345,8 @@
void setMinimumTimerInterval(double);
+ void setTextDirection(JSStringRef);
+
private:
LayoutTestController(const std::string& testPathOrURL, const std::string& expectedPixelHash);
Modified: trunk/Tools/DumpRenderTree/chromium/LayoutTestController.cpp (87769 => 87770)
--- trunk/Tools/DumpRenderTree/chromium/LayoutTestController.cpp 2011-06-01 02:22:52 UTC (rev 87769)
+++ trunk/Tools/DumpRenderTree/chromium/LayoutTestController.cpp 2011-06-01 02:25:47 UTC (rev 87770)
@@ -190,6 +190,7 @@
bindMethod("waitForPolicyDelegate", &LayoutTestController::waitForPolicyDelegate);
bindMethod("waitUntilDone", &LayoutTestController::waitUntilDone);
bindMethod("windowCount", &LayoutTestController::windowCount);
+ bindMethod("setTextDirection", &LayoutTestController::setTextDirection);
// The following are stubs.
bindMethod("abortModal", &LayoutTestController::abortModal);
@@ -1853,3 +1854,24 @@
m_shell->webView()->setVisibilityState(WebPageVisibilityStateHidden, false);
}
}
+
+void LayoutTestController::setTextDirection(const CppArgumentList& arguments, CppVariant* result)
+{
+ result->setNull();
+ if (arguments.size() != 1 || !arguments[0].isString())
+ return;
+
+ // Map a direction name to a WebTextDirection value.
+ std::string directionName = arguments[0].toString();
+ WebKit::WebTextDirection direction;
+ if (directionName == "auto")
+ direction = WebKit::WebTextDirectionDefault;
+ else if (directionName == "rtl")
+ direction = WebKit::WebTextDirectionRightToLeft;
+ else if (directionName == "ltr")
+ direction = WebKit::WebTextDirectionLeftToRight;
+ else
+ return;
+
+ m_shell->webView()->setTextDirection(direction);
+}
Modified: trunk/Tools/DumpRenderTree/chromium/LayoutTestController.h (87769 => 87770)
--- trunk/Tools/DumpRenderTree/chromium/LayoutTestController.h 2011-06-01 02:22:52 UTC (rev 87769)
+++ trunk/Tools/DumpRenderTree/chromium/LayoutTestController.h 2011-06-01 02:25:47 UTC (rev 87770)
@@ -378,6 +378,9 @@
void setPageVisibility(const CppArgumentList&, CppVariant*);
void resetPageVisibility(const CppArgumentList&, CppVariant*);
+ // Changes the direction of the focused element.
+ void setTextDirection(const CppArgumentList&, CppVariant*);
+
public:
// The following methods are not exposed to _javascript_.
void setWorkQueueFrozen(bool frozen) { m_workQueue.setFrozen(frozen); }
Modified: trunk/Tools/DumpRenderTree/gtk/LayoutTestControllerGtk.cpp (87769 => 87770)
--- trunk/Tools/DumpRenderTree/gtk/LayoutTestControllerGtk.cpp 2011-06-01 02:22:52 UTC (rev 87769)
+++ trunk/Tools/DumpRenderTree/gtk/LayoutTestControllerGtk.cpp 2011-06-01 02:25:47 UTC (rev 87770)
@@ -1000,3 +1000,8 @@
WebKitWebView* webView = webkit_web_frame_get_web_view(mainFrame);
DumpRenderTreeSupportGtk::setMinimumTimerInterval(webView, minimumTimerInterval);
}
+
+void LayoutTestController::setTextDirection(JSStringRef direction)
+{
+ // FIXME: Implement.
+}
Modified: trunk/Tools/DumpRenderTree/mac/LayoutTestControllerMac.mm (87769 => 87770)
--- trunk/Tools/DumpRenderTree/mac/LayoutTestControllerMac.mm 2011-06-01 02:22:52 UTC (rev 87769)
+++ trunk/Tools/DumpRenderTree/mac/LayoutTestControllerMac.mm 2011-06-01 02:25:47 UTC (rev 87770)
@@ -1153,3 +1153,15 @@
{
[[mainFrame webView] _setMinimumTimerInterval:minimumTimerInterval];
}
+
+void LayoutTestController::setTextDirection(JSStringRef directionName)
+{
+#if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD)
+ if (JSStringIsEqualToUTF8CString(directionName, "ltr"))
+ [[mainFrame webView] makeBaseWritingDirectionLeftToRight:0];
+ else if (JSStringIsEqualToUTF8CString(directionName, "rtl"))
+ [[mainFrame webView] makeBaseWritingDirectionRightToLeft:0];
+ else
+ ASSERT_NOT_REACHED();
+#endif
+}
Modified: trunk/Tools/DumpRenderTree/win/LayoutTestControllerWin.cpp (87769 => 87770)
--- trunk/Tools/DumpRenderTree/win/LayoutTestControllerWin.cpp 2011-06-01 02:22:52 UTC (rev 87769)
+++ trunk/Tools/DumpRenderTree/win/LayoutTestControllerWin.cpp 2011-06-01 02:25:47 UTC (rev 87770)
@@ -1577,4 +1577,7 @@
viewPrivate->setMinimumTimerInterval(minimumTimerInterval);
}
-
+void LayoutTestController::setTextDirection(JSStringRef direction)
+{
+ // FIXME: Implement.
+}