Title: [104821] trunk
- Revision
- 104821
- Author
- [email protected]
- Date
- 2012-01-12 06:39:36 -0800 (Thu, 12 Jan 2012)
Log Message
Speech input: Send text to correct element even if focus has changed
https://bugs.webkit.org/show_bug.cgi?id=76071
Reviewed by Steve Block.
Source/WebCore:
Make sure that the text from speech input ends up in the correct
element even if focus has changed since the user clicked on it.
Test: fast/speech/change-focus.html
* html/shadow/TextControlInnerElements.cpp:
(WebCore::InputFieldSpeechButtonElement::setRecognitionResult):
LayoutTests:
Add test to make sure that the text from speech input ends up in the
correct element even if focus has moved away after the user clicked on it.
* fast/speech/change-focus-expected.txt: Added.
* fast/speech/change-focus.html: Added.
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (104820 => 104821)
--- trunk/LayoutTests/ChangeLog 2012-01-12 14:27:46 UTC (rev 104820)
+++ trunk/LayoutTests/ChangeLog 2012-01-12 14:39:36 UTC (rev 104821)
@@ -1,3 +1,16 @@
+2012-01-12 Hans Wennborg <[email protected]>
+
+ Speech input: Send text to correct element even if focus has changed
+ https://bugs.webkit.org/show_bug.cgi?id=76071
+
+ Reviewed by Steve Block.
+
+ Add test to make sure that the text from speech input ends up in the
+ correct element even if focus has moved away after the user clicked on it.
+
+ * fast/speech/change-focus-expected.txt: Added.
+ * fast/speech/change-focus.html: Added.
+
2012-01-12 Mario Sanchez Prada <[email protected]>
[GTK] platform/gtk/accessibility/unknown-roles-not-exposed.html is flaky
Added: trunk/LayoutTests/fast/speech/change-focus-expected.txt (0 => 104821)
--- trunk/LayoutTests/fast/speech/change-focus-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/speech/change-focus-expected.txt 2012-01-12 14:39:36 UTC (rev 104821)
@@ -0,0 +1,12 @@
+Tests for speech button click with <input type="text" speech>.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Clicking on speech button.
+PASS document.getElementById("input1").value is "Pictures of the moon"
+PASS document.getElementById("input2").value is ""
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/fast/speech/change-focus.html (0 => 104821)
--- trunk/LayoutTests/fast/speech/change-focus.html (rev 0)
+++ trunk/LayoutTests/fast/speech/change-focus.html 2012-01-12 14:39:36 UTC (rev 104821)
@@ -0,0 +1,54 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src=""
+</head>
+<body>
+<script type="text/_javascript_">
+description('Tests for speech button click with <input type="text" speech>.');
+
+function startSpeechInput(id) {
+ // Clicking the speech button should fill in mock speech-recognized text.
+ debug('Clicking on speech button.');
+ var input = document.getElementById(id);
+ var isRTL = input.dir == 'rtl';
+ var x = 0;
+ if (isRTL)
+ x = input.offsetLeft + 4;
+ else
+ x = input.offsetLeft + input.offsetWidth - 4;
+ var y = input.offsetTop + input.offsetHeight / 2;
+ if (!isRTL && input.style.paddingRight.length)
+ x -= parseInt(input.style.paddingRight.substr(0, input.style.paddingRight.length - 2));
+ else if (isRTL && input.style.paddingLeft.length)
+ x += parseInt(input.style.paddingLeft.substr(0, input.style.paddingLeft.length - 2));
+ eventSender.mouseMoveTo(x, y);
+ eventSender.mouseDown();
+ eventSender.mouseUp();
+}
+
+function run() {
+ if (window.layoutTestController && window.eventSender) {
+ layoutTestController.addMockSpeechInputResult('Pictures of the moon', 1.0, '');
+ startSpeechInput('input1');
+ }
+}
+
+function onFocus() {
+ document.getElementById('input2').focus();
+}
+
+function onSpeechChange() {
+ shouldBeEqualToString('document.getElementById("input1").value', 'Pictures of the moon');
+ shouldBeEqualToString('document.getElementById("input2").value', '');
+ finishJSTest();
+}
+
+window._onload_ = run;
+window.jsTestIsAsync = true;
+</script>
+<script src=""
+<input id='input1' x-webkit-speech _onfocus_="onFocus()" _onwebkitspeechchange_="onSpeechChange()">
+<input id='input2'>
+</body>
+</html>
Modified: trunk/Source/WebCore/ChangeLog (104820 => 104821)
--- trunk/Source/WebCore/ChangeLog 2012-01-12 14:27:46 UTC (rev 104820)
+++ trunk/Source/WebCore/ChangeLog 2012-01-12 14:39:36 UTC (rev 104821)
@@ -1,3 +1,18 @@
+2012-01-12 Hans Wennborg <[email protected]>
+
+ Speech input: Send text to correct element even if focus has changed
+ https://bugs.webkit.org/show_bug.cgi?id=76071
+
+ Reviewed by Steve Block.
+
+ Make sure that the text from speech input ends up in the correct
+ element even if focus has changed since the user clicked on it.
+
+ Test: fast/speech/change-focus.html
+
+ * html/shadow/TextControlInnerElements.cpp:
+ (WebCore::InputFieldSpeechButtonElement::setRecognitionResult):
+
2012-01-10 Pavel Podivilov <[email protected]>
Web Inspector: make source urls relative to source map url.
Modified: trunk/Source/WebCore/html/shadow/TextControlInnerElements.cpp (104820 => 104821)
--- trunk/Source/WebCore/html/shadow/TextControlInnerElements.cpp 2012-01-12 14:27:46 UTC (rev 104820)
+++ trunk/Source/WebCore/html/shadow/TextControlInnerElements.cpp 2012-01-12 14:39:36 UTC (rev 104821)
@@ -498,8 +498,13 @@
return;
RefPtr<InputFieldSpeechButtonElement> holdRefButton(this);
- if (document() && document()->domWindow())
+ if (document() && document()->domWindow()) {
+ // Call selectionChanged, causing the element to cache the selection,
+ // so that the text event inserts the text in this element even if
+ // focus has moved away from it.
+ input->selectionChanged(false);
input->dispatchEvent(TextEvent::create(document()->domWindow(), results.isEmpty() ? "" : results[0]->utterance(), TextEventInputOther));
+ }
// This event is sent after the text event so the website can perform actions using the input field content immediately.
// It provides alternative recognition hypotheses and notifies that the results come from speech input.
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes