2010-10-22 Leandro Gracia Gil <leandrogracia@google.com>
authorjorlow@chromium.org <jorlow@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 22 Oct 2010 12:09:08 +0000 (12:09 +0000)
committerjorlow@chromium.org <jorlow@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 22 Oct 2010 12:09:08 +0000 (12:09 +0000)
        Reviewed by Jeremy Orlow.

        Added a layout test for the language tag in speech input. Updated
        the speech button tests to include the new language parameter in the
        mock result.
        https://bugs.webkit.org/show_bug.cgi?id=47089

        * fast/speech/input-text-language-tag-expected.txt: Added.
        * fast/speech/input-text-language-tag.html: Added.
        * fast/speech/input-text-speechbutton.html: Added an empty language
          parameter.
        * fast/speech/speech-button-ignore-generated-events.html: Added an
          empty language parameter.
        * platform/chromium/test_expectations.txt: language tag test is expected
          to fail until the chromium-side patch has been applied.
2010-10-22  Leandro Gracia Gil  <leandrogracia@google.com>

        Reviewed by Jeremy Orlow.

        Patch the current speech input implementation to use and validate the
        nearest language tag. The language is now passed to the startRecognition
        methods so that language-specific recognition could be used. Also added
        a second parameter to setMockSpeechInputResult for the language used in
        speech recognition.
        https://bugs.webkit.org/show_bug.cgi?id=47089

        This is the 2nd of a 4-sided patch in Chromium and WebKit. For more
        details see http://codereview.chromium.org/3615005/show and
        http://codereview.chromium.org/3595018/show.

        Test: fast/speech/input-text-language-tag.html

        * dom/Element.cpp:
        (WebCore::Element::computeInheritedLanguage): includes a brief character
          validation for the BCP 47 language tag.
        * page/SpeechInput.cpp:
        (WebCore::SpeechInput::startRecognition):
        * page/SpeechInput.h:
        * page/SpeechInputClient.h:
        * platform/mock/SpeechInputClientMock.cpp:
        (WebCore::SpeechInputClientMock::startRecognition):
        (WebCore::SpeechInputClientMock::setRecognitionResult): results are now
          stored by language using a hash map.
        (WebCore::SpeechInputClientMock::timerFired):
        * platform/mock/SpeechInputClientMock.h:
        * rendering/TextControlInnerElements.cpp:
        (WebCore::TextControlInnerElement::attachInnerElement):
        (WebCore::SearchFieldCancelButtonElement::detach):
        (WebCore::SpinButtonElement::defaultEventHandler):
        (WebCore::InputFieldSpeechButtonElement::defaultEventHandler):
        (WebCore::InputFieldSpeechButtonElement::detach):
2010-10-22  Leandro Gracia Gil  <leandrogracia@google.com>

        Reviewed by Jeremy Orlow.

        Patch the current speech input implementation to use and validate the
        nearest language tag. The language is now passed to the startRecognition
        methods so that language-specific recognition could be used. Also added
        a second parameter to setMockSpeechInputResult for the language used in
        speech recognition.
        https://bugs.webkit.org/show_bug.cgi?id=47089

        This is the 2nd of a 4-sided patch in Chromium and WebKit. For more
        details see http://codereview.chromium.org/3615005/show and
        http://codereview.chromium.org/3595018/show.

        * public/WebSpeechInputController.h:
        (WebKit::WebSpeechInputController::startRecognition):
        * public/WebSpeechInputControllerMock.h:
        * src/SpeechInputClientImpl.cpp:
        (WebKit::SpeechInputClientImpl::create):
        (WebKit::SpeechInputClientImpl::startRecognition):
        * src/SpeechInputClientImpl.h:
        * src/WebSpeechInputControllerMockImpl.cpp:
        (WebKit::WebSpeechInputControllerMockImpl::setMockRecognitionResult):
        (WebKit::WebSpeechInputControllerMockImpl::startRecognition):
        * src/WebSpeechInputControllerMockImpl.h:
        * src/WebViewImpl.cpp:
        (WebKit::WebViewImpl::WebViewImpl):
        * src/WebViewImpl.h:
2010-10-22  Leandro Gracia Gil  <leandrogracia@google.com>

        Reviewed by Jeremy Orlow.

        Added a second parameter to setMockSpeechInputResult for
        the language used in speech input.
        https://bugs.webkit.org/show_bug.cgi?id=47089

        * DumpRenderTree/LayoutTestController.cpp:
        (setMockSpeechInputResultCallback):
        * DumpRenderTree/LayoutTestController.h:
        * DumpRenderTree/chromium/LayoutTestController.cpp:
        (LayoutTestController::setMockSpeechInputResult):
        * DumpRenderTree/gtk/LayoutTestControllerGtk.cpp:
        (LayoutTestController::setMockSpeechInputResult):
        * DumpRenderTree/mac/LayoutTestControllerMac.mm:
        (LayoutTestController::setMockSpeechInputResult):
        * DumpRenderTree/qt/LayoutTestControllerQt.h:
        * DumpRenderTree/qt/LayoutTestControllerQt.cpp:
        (LayoutTestController::setMockSpeechInputResult):
        * DumpRenderTree/win/LayoutTestControllerWin.cpp:
        (LayoutTestController::setMockSpeechInputResult):
        * DumpRenderTree/wx/LayoutTestControllerWx.cpp:
        (LayoutTestController::setMockSpeechInputResult):

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

33 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/speech/input-text-language-tag-expected.txt [new file with mode: 0644]
LayoutTests/fast/speech/input-text-language-tag.html [new file with mode: 0644]
LayoutTests/fast/speech/input-text-speechbutton.html
LayoutTests/fast/speech/speech-button-ignore-generated-events.html
LayoutTests/platform/chromium/test_expectations.txt
WebCore/ChangeLog
WebCore/dom/Element.cpp
WebCore/page/SpeechInput.cpp
WebCore/page/SpeechInput.h
WebCore/page/SpeechInputClient.h
WebCore/platform/mock/SpeechInputClientMock.cpp
WebCore/platform/mock/SpeechInputClientMock.h
WebCore/rendering/TextControlInnerElements.cpp
WebKit/chromium/ChangeLog
WebKit/chromium/public/WebSpeechInputController.h
WebKit/chromium/public/WebSpeechInputControllerMock.h
WebKit/chromium/src/SpeechInputClientImpl.cpp
WebKit/chromium/src/SpeechInputClientImpl.h
WebKit/chromium/src/WebSpeechInputControllerMockImpl.cpp
WebKit/chromium/src/WebSpeechInputControllerMockImpl.h
WebKit/chromium/src/WebViewImpl.cpp
WebKit/chromium/src/WebViewImpl.h
WebKitTools/ChangeLog
WebKitTools/DumpRenderTree/LayoutTestController.cpp
WebKitTools/DumpRenderTree/LayoutTestController.h
WebKitTools/DumpRenderTree/chromium/LayoutTestController.cpp
WebKitTools/DumpRenderTree/gtk/LayoutTestControllerGtk.cpp
WebKitTools/DumpRenderTree/mac/LayoutTestControllerMac.mm
WebKitTools/DumpRenderTree/qt/LayoutTestControllerQt.cpp
WebKitTools/DumpRenderTree/qt/LayoutTestControllerQt.h
WebKitTools/DumpRenderTree/win/LayoutTestControllerWin.cpp
WebKitTools/DumpRenderTree/wx/LayoutTestControllerWx.cpp

index cd43dbd..7a96940 100644 (file)
@@ -1,3 +1,21 @@
+2010-10-22  Leandro Gracia Gil  <leandrogracia@google.com>
+
+        Reviewed by Jeremy Orlow.
+
+        Added a layout test for the language tag in speech input. Updated
+        the speech button tests to include the new language parameter in the
+        mock result.
+        https://bugs.webkit.org/show_bug.cgi?id=47089
+
+        * fast/speech/input-text-language-tag-expected.txt: Added.
+        * fast/speech/input-text-language-tag.html: Added.
+        * fast/speech/input-text-speechbutton.html: Added an empty language
+          parameter.
+        * fast/speech/speech-button-ignore-generated-events.html: Added an
+          empty language parameter.
+        * platform/chromium/test_expectations.txt: language tag test is expected
+          to fail until the chromium-side patch has been applied.
+
 2010-10-22  MORITA Hajime  <morrita@google.com>
 
         Reviewed by Kent Tamura.
 
         * platform/gtk/Skipped: Unskip passing tests.
 
-2010-10-19  Leandro Gracia Gil  <leandrogracia@google.com>
-
-        Reviewed by Jeremy Orlow.
-
-        Added a layout test for the language tag in speech input. Updated
-        the speech button tests to include the new language parameter in the
-        mock result.
-        https://bugs.webkit.org/show_bug.cgi?id=47089
-
-        * fast/speech/input-text-language-tag-expected.txt: Added.
-        * fast/speech/input-text-language-tag.html: Added.
-        * fast/speech/input-text-speechbutton.html: Added an empty language
-          parameter.
-        * fast/speech/speech-button-ignore-generated-events.html: Added an
-          empty language parameter.
-        * platform/chromium/test_expectations.txt: language tag test is expected
-          to fail until the chromium-side patch has been applied.
-
 2010-10-19  Antonio Gomes  <agomes@rim.com>
 
         Reviewed by Kenneth Rohde Christiansen.
diff --git a/LayoutTests/fast/speech/input-text-language-tag-expected.txt b/LayoutTests/fast/speech/input-text-language-tag-expected.txt
new file mode 100644 (file)
index 0000000..91f30d6
--- /dev/null
@@ -0,0 +1,13 @@
+Tests for language tag inheritance and validation in speech buttons.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS document.getElementById("speechInputNone").value is "error: no result found for language ''"
+PASS document.getElementById("speechInputElement").value is "Pictures of the moon"
+PASS document.getElementById("speechInputInherited").value is "月の写真"
+PASS document.getElementById("speechInputInvalid").value is "error: no result found for language ''"
+PASS successfullyParsed is true
+
+TEST COMPLETE
diff --git a/LayoutTests/fast/speech/input-text-language-tag.html b/LayoutTests/fast/speech/input-text-language-tag.html
new file mode 100644 (file)
index 0000000..9bfc822
--- /dev/null
@@ -0,0 +1,62 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<meta charset="utf-8">
+<head>
+<link rel="stylesheet" href="../js/resources/js-test-style.css">
+<script src="../js/resources/js-test-pre.js"></script>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+<script type="text/javascript">
+description('Tests for language tag inheritance and validation in speech buttons.');
+
+// Note: test cases are sequential to ensure that no new recognition starts when another recognition recording is active.
+function onChangeNone() {
+    shouldBeEqualToString('document.getElementById("speechInputNone").value', 'error: no result found for language \'\'');
+    setTimeout(function() { speechButtonClick('speechInputElement'); }, 50);
+}
+
+function onChangeElement() {
+    shouldBeEqualToString('document.getElementById("speechInputElement").value', 'Pictures of the moon');
+    setTimeout(function() { speechButtonClick('speechInputInherited'); }, 50);
+}
+
+function onChangeInherited() {
+    shouldBeEqualToString('document.getElementById("speechInputInherited").value', '月の写真');
+    setTimeout(function() { speechButtonClick('speechInputInvalid'); }, 50);
+}
+
+function onChangeInvalid() {
+    shouldBeEqualToString('document.getElementById("speechInputInvalid").value', 'error: no result found for language \'\'');
+    finishJSTest();
+}
+
+function speechButtonClick(elementId) {
+    var element = document.getElementById(elementId);
+    var x = element.offsetLeft + element.offsetWidth - 4;
+    var y = element.offsetTop + element.offsetHeight / 2;
+    eventSender.mouseMoveTo(x, y);
+    eventSender.mouseDown();
+    eventSender.mouseUp();
+}
+
+function run() {
+    if (window.layoutTestController && window.eventSender) {
+        layoutTestController.setMockSpeechInputResult('Pictures of the moon', 'en-GB');
+        layoutTestController.setMockSpeechInputResult('月の写真', 'ja');
+        speechButtonClick('speechInputNone');
+    }
+}
+
+window.onload = run;
+window.jsTestIsAsync = true;
+window.successfullyParsed = true;
+</script>
+<script src="../js/resources/js-test-post.js"></script>
+<input id="speechInputNone" x-webkit-speech onwebkitspeechchange="onChangeNone()">
+<input id="speechInputElement" x-webkit-speech onwebkitspeechchange="onChangeElement()" lang="en-GB">
+<div lang="ja"> <input id="speechInputInherited" x-webkit-speech onwebkitspeechchange="onChangeInherited()"> </div>
+<input id="speechInputInvalid" x-webkit-speech onwebkitspeechchange="onChangeInvalid()" lang="1337$þ3λk">
+</body>
+</html>
index 6f5bc4b..cef7705 100644 (file)
@@ -32,7 +32,7 @@ function onWebkitSpeechChange() {
 
 function run() {
     if (window.layoutTestController && window.eventSender) {
-        layoutTestController.setMockSpeechInputResult('Pictures of the moon');
+        layoutTestController.setMockSpeechInputResult('Pictures of the moon', '');
 
         // Clicking the speech button should fill in mock speech-recognized text.
         var input = document.getElementById('speechInput');
index b9b8ec3..c684863 100644 (file)
@@ -49,7 +49,7 @@ function setupDispatchEventTest() {
 function run() {
     if (window.layoutTestController && window.eventSender) {
         // Running in DRT, test the eventSender case.
-        layoutTestController.setMockSpeechInputResult('Pictures of the moon');
+        layoutTestController.setMockSpeechInputResult('Pictures of the moon', '');
         document.getElementById('speechInput').onwebkitspeechchange = function() {
             shouldBeEqualToString('document.getElementById("speechInput").value', 'Pictures of the moon');
 
index 36ff025..35dbb3e 100644 (file)
@@ -3248,5 +3248,9 @@ BUGJAPHET : fast/js/date-parse-test.html = TEXT
 
 // Added in WebKit r70190
 BUGWK48034 : plugins/pass-different-npp-struct.html = TEXT
+
 // Added in WebKit r70265
 BUGWK48034 : platform/win/plugins/npn-invalidate-rect-invalidates-window.html = TEXT
+
+// Temporarily disabled for a 4-sided patch. Will be enabled again by BUGWK47420.
+BUGWK47089 : fast/speech/input-text-language-tag.html = FAIL
index c9a45b3..8c29bb7 100644 (file)
@@ -1,3 +1,40 @@
+2010-10-22  Leandro Gracia Gil  <leandrogracia@google.com>
+
+        Reviewed by Jeremy Orlow.
+
+        Patch the current speech input implementation to use and validate the
+        nearest language tag. The language is now passed to the startRecognition
+        methods so that language-specific recognition could be used. Also added
+        a second parameter to setMockSpeechInputResult for the language used in
+        speech recognition.
+        https://bugs.webkit.org/show_bug.cgi?id=47089
+
+        This is the 2nd of a 4-sided patch in Chromium and WebKit. For more
+        details see http://codereview.chromium.org/3615005/show and
+        http://codereview.chromium.org/3595018/show.
+
+        Test: fast/speech/input-text-language-tag.html
+
+        * dom/Element.cpp:
+        (WebCore::Element::computeInheritedLanguage): includes a brief character
+          validation for the BCP 47 language tag.
+        * page/SpeechInput.cpp:
+        (WebCore::SpeechInput::startRecognition):
+        * page/SpeechInput.h:
+        * page/SpeechInputClient.h:
+        * platform/mock/SpeechInputClientMock.cpp:
+        (WebCore::SpeechInputClientMock::startRecognition):
+        (WebCore::SpeechInputClientMock::setRecognitionResult): results are now
+          stored by language using a hash map.
+        (WebCore::SpeechInputClientMock::timerFired):
+        * platform/mock/SpeechInputClientMock.h:
+        * rendering/TextControlInnerElements.cpp:
+        (WebCore::TextControlInnerElement::attachInnerElement):
+        (WebCore::SearchFieldCancelButtonElement::detach):
+        (WebCore::SpinButtonElement::defaultEventHandler):
+        (WebCore::InputFieldSpeechButtonElement::defaultEventHandler):
+        (WebCore::InputFieldSpeechButtonElement::detach):
+
 2010-10-21  Yury Semikhatsky  <yurys@chromium.org>
 
         Unreviewed, rolling out r70298.WebKit win compilation failure.
         (WebCore::InputFieldSpeechButtonElement::defaultEventHandler):
         (WebCore::InputFieldSpeechButtonElement::detach):
 
-2010-10-19  Leandro Gracia Gil  <leandrogracia@google.com>
-
-        Reviewed by Jeremy Orlow.
-
-        Patch the current speech input implementation to use and validate the
-        nearest language tag. The language is now passed to the startRecognition
-        methods so that language-specific recognition could be used. Also added
-        a second parameter to setMockSpeechInputResult for the language used in
-        speech recognition.
-        https://bugs.webkit.org/show_bug.cgi?id=47089
-
-        This is the 2nd of a 4-sided patch in Chromium and WebKit. For more
-        details see http://codereview.chromium.org/3615005/show and
-        http://codereview.chromium.org/3595018/show.
-
-        Test: fast/speech/input-text-language-tag.html
-
-        * dom/Element.cpp:
-        (WebCore::Element::computeInheritedLanguage): includes a brief character
-          validation for the BCP 47 language tag.
-        * page/SpeechInput.cpp:
-        (WebCore::SpeechInput::startRecognition):
-        * page/SpeechInput.h:
-        * page/SpeechInputClient.h:
-        * platform/mock/SpeechInputClientMock.cpp:
-        (WebCore::SpeechInputClientMock::startRecognition):
-        (WebCore::SpeechInputClientMock::setRecognitionResult): results are now
-          stored by language using a hash map.
-        (WebCore::SpeechInputClientMock::timerFired):
-        * platform/mock/SpeechInputClientMock.h:
-        * rendering/TextControlInnerElements.cpp:
-        (WebCore::TextControlInnerElement::attachInnerElement):
-        (WebCore::SearchFieldCancelButtonElement::detach):
-        (WebCore::SpinButtonElement::defaultEventHandler):
-        (WebCore::InputFieldSpeechButtonElement::defaultEventHandler):
-        (WebCore::InputFieldSpeechButtonElement::detach):
-
 2010-10-20  Dirk Schulze  <krit@webkit.org>
 
         Reviewed by Nikolas Zimmermann.
index 83e129e..c7d442a 100644 (file)
@@ -56,6 +56,7 @@
 #include "Settings.h"
 #include "TextIterator.h"
 #include "XMLNames.h"
+#include <wtf/ASCIICType.h>
 #include <wtf/text/CString.h>
 
 #if ENABLE(SVG)
@@ -1474,6 +1475,15 @@ AtomicString Element::computeInheritedLanguage() const
         n = n->parent();
     }
 
+    if (!value.isNull() && !value.isEmpty()) {
+        // Only A-Za-z0-9 and '-' are allowed in the language tag (see BCP 47)
+        const char *p = value.string().ascii().data();
+        for (; *p != '\0'; ++p) {
+            if (!isASCIIAlphanumeric(*p) && *p != '-')
+                return AtomicString();
+        }
+    }
+
     return value;
 }
 
index 234791b..cc5e0f9 100644 (file)
@@ -93,10 +93,10 @@ void SpeechInput::setRecognitionResult(int listenerId, const String& result)
         m_listeners.get(listenerId)->setRecognitionResult(listenerId, result);
 }
 
-bool SpeechInput::startRecognition(int listenerId, const IntRect& elementRect)
+bool SpeechInput::startRecognition(int listenerId, const String& language, const IntRect& elementRect)
 {
     ASSERT(m_listeners.contains(listenerId));
-    return m_client->startRecognition(listenerId, elementRect);
+    return m_client->startRecognition(listenerId, language, elementRect);
 }
 
 void SpeechInput::stopRecording(int listenerId)
index d10b789..8b426f5 100644 (file)
@@ -61,7 +61,7 @@ public:
     void unregisterListener(int);
 
     // Methods invoked by the input elements.
-    bool startRecognition(int, const IntRect&);
+    bool startRecognition(int, const String&, const IntRect&);
     void stopRecording(int);
     void cancelRecognition(int);
 
index d5fda17..f5aab02 100644 (file)
@@ -31,6 +31,8 @@
 #ifndef SpeechInputClient_h
 #define SpeechInputClient_h
 
+#include <wtf/Forward.h>
+
 #if ENABLE(INPUT_SPEECH)
 
 namespace WebCore {
@@ -48,7 +50,7 @@ public:
     virtual void setListener(SpeechInputListener*) = 0;
 
     // Starts speech recognition and audio recording.
-    virtual bool startRecognition(int requestId, const IntRect& elementRect) = 0;
+    virtual bool startRecognition(int requestId, const String& language, const IntRect& elementRect) = 0;
 
     // Stops audio recording and performs recognition with the audio recorded until now
     // (does not discard audio).
index 6b64942..c04971e 100644 (file)
 
 #include "SpeechInputListener.h"
 
+namespace {
+    // HashMap doesn't support empty strings as keys, so this value (an invalid BCP47 tag) is used for those cases.
+    const String emptyLanguage = "_";
+}
+
 namespace WebCore {
 
 SpeechInputClientMock::SpeechInputClientMock()
@@ -50,12 +55,13 @@ void SpeechInputClientMock::setListener(SpeechInputListener* listener)
     m_listener = listener;
 }
 
-bool SpeechInputClientMock::startRecognition(int requestId, const IntRect&)
+bool SpeechInputClientMock::startRecognition(int requestId, const String& language, const IntRect&)
 {
     if (m_timer.isActive())
         return false;
     m_requestId = requestId;
     m_recording = true;
+    m_language = language;
     m_timer.startOneShot(0);
     return true;
 }
@@ -80,9 +86,12 @@ void SpeechInputClientMock::cancelRecognition(int requestId)
     }
 }
 
-void SpeechInputClientMock::setRecognitionResult(const String& result)
+void SpeechInputClientMock::setRecognitionResult(const String& result, const String& language)
 {
-    m_recognitionResult = result;
+    if (language.isEmpty())
+        m_recognitionResult.set(emptyLanguage, result);
+    else
+        m_recognitionResult.set(language, result);
 }
 
 void SpeechInputClientMock::timerFired(WebCore::Timer<SpeechInputClientMock>*)
@@ -92,7 +101,17 @@ void SpeechInputClientMock::timerFired(WebCore::Timer<SpeechInputClientMock>*)
         m_listener->didCompleteRecording(m_requestId);
         m_timer.startOneShot(0);
     } else {
-        m_listener->setRecognitionResult(m_requestId, m_recognitionResult);
+        String language = m_language.isEmpty() ? String(emptyLanguage) : m_language;
+        if (!m_recognitionResult.contains(language)) {
+            // Can't avoid setting a result on empty or invalid language strings.
+            // This would avoid generating the events used to check the results and the test would timeout.
+            String error("error: no result found for language '");
+            error.append(m_language);
+            error.append("'");
+            m_listener->setRecognitionResult(m_requestId, error);
+        } else
+            m_listener->setRecognitionResult(m_requestId, m_recognitionResult.get(language));
+
         m_listener->didCompleteRecognition(m_requestId);
         m_requestId = 0;
     }
index ce83d3b..3ce987b 100644 (file)
@@ -34,6 +34,8 @@
 #include "PlatformString.h"
 #include "SpeechInputClient.h"
 #include "Timer.h"
+#include <wtf/HashMap.h>
+#include <wtf/text/StringHash.h>
 
 #if ENABLE(INPUT_SPEECH)
 
@@ -46,11 +48,11 @@ class SpeechInputClientMock : public SpeechInputClient {
 public:
     SpeechInputClientMock();
 
-    void setRecognitionResult(const String& result);
+    void setRecognitionResult(const String& result, const String& language);
 
     // SpeechInputClient methods.
     void setListener(SpeechInputListener*);
-    bool startRecognition(int, const IntRect&);
+    bool startRecognition(int, const String&, const IntRect&);
     void stopRecording(int);
     void cancelRecognition(int);
 
@@ -61,7 +63,9 @@ private:
     Timer<SpeechInputClientMock> m_timer;
     SpeechInputListener* m_listener;
     int m_requestId;
-    String m_recognitionResult;
+
+    HashMap<String, String> m_recognitionResult;
+    String m_language;
 };
 
 } // namespace WebCore
index 5d5b8b3..65d0a64 100644 (file)
@@ -21,9 +21,9 @@
  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
+
 #include "config.h"
 #include "TextControlInnerElements.h"
 
@@ -107,18 +107,18 @@ void TextControlInnerElement::attachInnerElement(Node* parent, PassRefPtr<Render
         setRenderer(renderer);
         renderer->setStyle(style);
     }
-    
+
     // Set these explicitly since this normally happens during an attach()
     setAttached();
     setInDocument();
-    
+
     // For elements without a shadow parent, add the node to the DOM normally.
     if (!m_shadowParent) {
         // FIXME: This code seems very wrong.  Why are we magically adding |this| to the DOM here?
         //        We shouldn't be calling parser API methods outside of the parser!
         parent->deprecatedParserAddChild(this);
     }
+
     // Add the renderer to the render tree
     if (renderer)
         parent->renderer()->addChild(renderer);
@@ -208,7 +208,7 @@ void SearchFieldCancelButtonElement::detach()
 {
     if (m_capturing) {
         if (Frame* frame = document()->frame())
-            frame->eventHandler()->setCapturingMouseEventsNode(0);      
+            frame->eventHandler()->setCapturingMouseEventsNode(0);
     }
     TextControlInnerElement::detach();
 }
@@ -281,9 +281,9 @@ void SpinButtonElement::defaultEventHandler(Event* event)
     if (!box) {
         if (!event->defaultHandled())
             HTMLDivElement::defaultEventHandler(event);
-        return;        
+        return;
     }
-    
+
     HTMLInputElement* input = static_cast<HTMLInputElement*>(shadowAncestorNode());
     if (input->disabled() || input->isReadOnlyFormControl()) {
         if (!event->defaultHandled())
@@ -431,7 +431,7 @@ void InputFieldSpeechButtonElement::defaultEventHandler(Event* event)
     if (event->type() == eventNames().clickEvent) {
         switch (m_state) {
         case Idle:
-            if (speechInput()->startRecognition(m_listenerId, input->renderer()->absoluteBoundingBoxRect()))
+            if (speechInput()->startRecognition(m_listenerId, input->computeInheritedLanguage(), input->renderer()->absoluteBoundingBoxRect()))
                 setState(Recording);
             break;
         case Recording:
@@ -487,7 +487,7 @@ void InputFieldSpeechButtonElement::detach()
 {
     if (m_capturing) {
         if (Frame* frame = document()->frame())
-            frame->eventHandler()->setCapturingMouseEventsNode(0);      
+            frame->eventHandler()->setCapturingMouseEventsNode(0);
     }
 
     if (m_state != Idle)
index 7c1f491..f67a374 100644 (file)
@@ -1,3 +1,33 @@
+2010-10-22  Leandro Gracia Gil  <leandrogracia@google.com>
+
+        Reviewed by Jeremy Orlow.
+        Patch the current speech input implementation to use and validate the
+        nearest language tag. The language is now passed to the startRecognition
+        methods so that language-specific recognition could be used. Also added
+        a second parameter to setMockSpeechInputResult for the language used in
+        speech recognition.
+        https://bugs.webkit.org/show_bug.cgi?id=47089
+
+        This is the 2nd of a 4-sided patch in Chromium and WebKit. For more
+        details see http://codereview.chromium.org/3615005/show and
+        http://codereview.chromium.org/3595018/show.
+
+        * public/WebSpeechInputController.h:
+        (WebKit::WebSpeechInputController::startRecognition):
+        * public/WebSpeechInputControllerMock.h:
+        * src/SpeechInputClientImpl.cpp:
+        (WebKit::SpeechInputClientImpl::create):
+        (WebKit::SpeechInputClientImpl::startRecognition):
+        * src/SpeechInputClientImpl.h:
+        * src/WebSpeechInputControllerMockImpl.cpp:
+        (WebKit::WebSpeechInputControllerMockImpl::setMockRecognitionResult):
+        (WebKit::WebSpeechInputControllerMockImpl::startRecognition):
+        * src/WebSpeechInputControllerMockImpl.h:
+        * src/WebViewImpl.cpp:
+        (WebKit::WebViewImpl::WebViewImpl):
+        * src/WebViewImpl.h:
+
 2010-10-21  Yuzo Fujishima  <yuzo@google.com>
 
         Unreviewed build fix attempt for Chromium Linux Debug Clang
         (WebKit::WebViewImpl::WebViewImpl):
         * src/WebViewImpl.h:
 
-2010-10-19  Leandro Gracia Gil  <leandrogracia@google.com>
-
-        Reviewed by Jeremy Orlow.
-        Patch the current speech input implementation to use and validate the
-        nearest language tag. The language is now passed to the startRecognition
-        methods so that language-specific recognition could be used. Also added
-        a second parameter to setMockSpeechInputResult for the language used in
-        speech recognition.
-        https://bugs.webkit.org/show_bug.cgi?id=47089
-
-        This is the 2nd of a 4-sided patch in Chromium and WebKit. For more
-        details see http://codereview.chromium.org/3615005/show and
-        http://codereview.chromium.org/3595018/show.
-
-        * public/WebSpeechInputController.h:
-        (WebKit::WebSpeechInputController::startRecognition):
-        * public/WebSpeechInputControllerMock.h:
-        * src/SpeechInputClientImpl.cpp:
-        (WebKit::SpeechInputClientImpl::create):
-        (WebKit::SpeechInputClientImpl::startRecognition):
-        * src/SpeechInputClientImpl.h:
-        * src/WebSpeechInputControllerMockImpl.cpp:
-        (WebKit::WebSpeechInputControllerMockImpl::setMockRecognitionResult):
-        (WebKit::WebSpeechInputControllerMockImpl::startRecognition):
-        * src/WebSpeechInputControllerMockImpl.h:
-        * src/WebViewImpl.cpp:
-        (WebKit::WebViewImpl::WebViewImpl):
-        * src/WebViewImpl.h:
-
 2010-10-20  Dirk Schulze  <krit@webkit.org>
 
         Unreviewed Chromium win build fix.
index 5408741..1fde2a8 100644 (file)
@@ -35,6 +35,7 @@
 
 namespace WebKit {
 
+class WebString;
 struct WebRect;
 
 // Provides an embedder API called by WebKit.
@@ -43,7 +44,7 @@ public:
     // Starts speech recognition. Speech will get recorded until the endpointer detects silence,
     // runs to the limit or stopRecording is called. Progress indications and the recognized
     // text are returned via the listener interface.
-    virtual bool startRecognition(int requestId, const WebRect&)
+    virtual bool startRecognition(int requestId, const WebString& language, const WebRect& elementRect)
     {
         WEBKIT_ASSERT_NOT_REACHED();
         return false;
index 9a26235..b4c50a0 100644 (file)
@@ -44,6 +44,10 @@ public:
         WebSpeechInputListener* listener);
     virtual ~WebSpeechInputControllerMock() { }
 
+    virtual void setMockRecognitionResult(const WebString& result, const WebString& language) = 0;
+
+    // FIXME: this is a fix for a two-sided patch. Delete as soon as the chromium side is patched.
+    // Chromium patch not uploaded yet, but will depend on http://codereview.chromium.org/3615005/show patch.
     virtual void setMockRecognitionResult(const WebString& result) = 0;
 };
 
index 963d440..1381929 100644 (file)
 #include "SpeechInputClientImpl.h"
 
 #include "PlatformString.h"
+#include "SpeechInputListener.h"
 #include "WebSpeechInputController.h"
 #include "WebString.h"
 #include "WebViewClient.h"
-#include "page/SpeechInputListener.h"
+#include <wtf/PassOwnPtr.h>
 
 #if ENABLE(INPUT_SPEECH)
 
 namespace WebKit {
 
+PassOwnPtr<SpeechInputClientImpl> SpeechInputClientImpl::create(WebViewClient* client)
+{
+    return adoptPtr(new SpeechInputClientImpl(client));
+}
+
 SpeechInputClientImpl::SpeechInputClientImpl(WebViewClient* web_view_client)
     : m_controller(web_view_client ? web_view_client->speechInputController(this) : 0)
     , m_listener(0)
@@ -56,10 +62,10 @@ void SpeechInputClientImpl::setListener(WebCore::SpeechInputListener* listener)
     m_listener = listener;
 }
 
-bool SpeechInputClientImpl::startRecognition(int requestId, const WebCore::IntRect& elementRect)
+bool SpeechInputClientImpl::startRecognition(int requestId, const String& language, const WebCore::IntRect& elementRect)
 {
     ASSERT(m_listener);
-    return m_controller->startRecognition(requestId, elementRect);
+    return m_controller->startRecognition(requestId, language, elementRect);
 }
 
 void SpeechInputClientImpl::stopRecording(int requestId)
index 817b32b..c7d1fa3 100644 (file)
 
 #if ENABLE(INPUT_SPEECH)
 
+#include "SpeechInputClient.h"
 #include "WebSpeechInputListener.h"
-#include "page/SpeechInputClient.h"
+#include <wtf/Forward.h>
+#include <wtf/OwnPtr.h>
+#include <wtf/PassOwnPtr.h>
+
+namespace WTF {
+class String;
+}
 
 namespace WebCore {
 class SpeechInputListener;
@@ -49,12 +56,12 @@ class SpeechInputClientImpl
     : public WebCore::SpeechInputClient,
       public WebSpeechInputListener {
 public:
-    SpeechInputClientImpl(WebViewClient*);
+    static PassOwnPtr<SpeechInputClientImpl> create(WebViewClient*);
     virtual ~SpeechInputClientImpl();
 
     // SpeechInputClient methods.
     void setListener(WebCore::SpeechInputListener*);
-    bool startRecognition(int, const WebCore::IntRect&);
+    bool startRecognition(int, const String&, const WebCore::IntRect&);
     void stopRecording(int);
     void cancelRecognition(int);
 
@@ -64,6 +71,8 @@ public:
     void didCompleteRecognition(int);
 
 private:
+    SpeechInputClientImpl(WebViewClient*);
+
     WebSpeechInputController* m_controller; // To call into the embedder.
     WebCore::SpeechInputListener* m_listener;
 };
index 60c4fed..45c6ff0 100644 (file)
@@ -57,7 +57,12 @@ WebSpeechInputControllerMockImpl::~WebSpeechInputControllerMockImpl()
 
 void WebSpeechInputControllerMockImpl::setMockRecognitionResult(const WebString& result)
 {
-    m_webcoreMock->setRecognitionResult(result);
+    m_webcoreMock->setRecognitionResult(result, WebString::fromUTF8(""));
+}
+
+void WebSpeechInputControllerMockImpl::setMockRecognitionResult(const WebString& result, const WebString &language)
+{
+    m_webcoreMock->setRecognitionResult(result, language);
 }
 
 void WebSpeechInputControllerMockImpl::didCompleteRecording(int requestId)
@@ -75,9 +80,9 @@ void WebSpeechInputControllerMockImpl::setRecognitionResult(int requestId, const
     m_listener->setRecognitionResult(requestId, result);
 }
 
-bool WebSpeechInputControllerMockImpl::startRecognition(int requestId, const WebRect& elementRect)
+bool WebSpeechInputControllerMockImpl::startRecognition(int requestId, const WebString& language, const WebRect& elementRect)
 {
-    return m_webcoreMock->startRecognition(requestId, elementRect);
+    return m_webcoreMock->startRecognition(requestId, language, elementRect);
 }
 
 void WebSpeechInputControllerMockImpl::cancelRecognition(int requestId)
index edbfca3..1b3053b 100644 (file)
 #include "WebString.h"
 #include <wtf/OwnPtr.h>
 
+namespace WTF {
+class String;
+}
+
 namespace WebCore {
 class SpeechInputClientMock;
 }
@@ -57,11 +61,15 @@ public:
     void setRecognitionResult(int requestId, const WTF::String& result);
 
     // WebSpeechInputController methods.
-    bool startRecognition(int requestId, const WebRect& elementRect);
+    bool startRecognition(int requestId, const WebString& language, const WebRect& elementRect);
     void cancelRecognition(int requestId);
     void stopRecording(int requestId);
 
     // WebSpeechInputControllerMock methods.
+    void setMockRecognitionResult(const WebString& result, const WebString& language);
+
+    // FIXME: this is a fix for a two-sided patch. Delete as soon as the chromium side is patched.
+    // Chromium patch not uploaded yet, but will depend on http://codereview.chromium.org/3615005/show patch.
     void setMockRecognitionResult(const WebString& result);
 
 private:
@@ -72,4 +80,3 @@ private:
 } // namespace WebKit
 
 #endif // WebSpeechInputControllerMockImpl_h
-
index 929f91a..7fc9ef7 100644 (file)
@@ -88,6 +88,7 @@
 #include "SecurityOrigin.h"
 #include "SelectionController.h"
 #include "Settings.h"
+#include "SpeechInputClientImpl.h"
 #include "Timer.h"
 #include "TypingCommand.h"
 #include "UserGestureIndicator.h"
@@ -282,7 +283,7 @@ WebViewImpl::WebViewImpl(WebViewClient* client, WebDevToolsAgentClient* devTools
     , m_compositorCreationFailed(false)
 #endif
 #if ENABLE(INPUT_SPEECH)
-    , m_speechInputClient(client)
+    , m_speechInputClient(SpeechInputClientImpl::create(client))
 #endif
     , m_deviceOrientationClientProxy(new DeviceOrientationClientProxy(client ? client->deviceOrientationClient() : 0))
 {
@@ -305,7 +306,7 @@ WebViewImpl::WebViewImpl(WebViewClient* client, WebDevToolsAgentClient* devTools
     pageClients.dragClient = &m_dragClientImpl;
     pageClients.inspectorClient = &m_inspectorClientImpl;
 #if ENABLE(INPUT_SPEECH)
-    pageClients.speechInputClient = &m_speechInputClient;
+    pageClients.speechInputClient = m_speechInputClient.get();
 #endif
     pageClients.deviceOrientationClient = m_deviceOrientationClientProxy.get();
 
index 8410ebd..0509d05 100644 (file)
@@ -49,7 +49,6 @@
 #include "IntRect.h"
 #include "LayerRendererChromium.h"
 #include "NotificationPresenterImpl.h"
-#include "SpeechInputClientImpl.h"
 #include <wtf/OwnPtr.h>
 #include <wtf/RefCounted.h>
 
@@ -74,6 +73,7 @@ class AutoFillPopupMenuClient;
 class ContextMenuClientImpl;
 class DeviceOrientationClientProxy;
 class DragScrollTimer;
+class SpeechInputClientImpl;
 class WebAccessibilityObject;
 class WebDevToolsAgentClient;
 class WebDevToolsAgentPrivate;
@@ -547,7 +547,7 @@ private:
     static const WebInputEvent* m_currentInputEvent;
 
 #if ENABLE(INPUT_SPEECH)
-    SpeechInputClientImpl m_speechInputClient;
+    OwnPtr<SpeechInputClientImpl> m_speechInputClient;
 #endif
     // If we attempt to fetch the on-screen GraphicsContext3D before
     // the compositor has been turned on, we need to instantiate it
index 86ba72f..deae82d 100644 (file)
@@ -1,3 +1,28 @@
+2010-10-22  Leandro Gracia Gil  <leandrogracia@google.com>
+
+        Reviewed by Jeremy Orlow.
+
+        Added a second parameter to setMockSpeechInputResult for
+        the language used in speech input.
+        https://bugs.webkit.org/show_bug.cgi?id=47089
+
+        * DumpRenderTree/LayoutTestController.cpp:
+        (setMockSpeechInputResultCallback):
+        * DumpRenderTree/LayoutTestController.h:
+        * DumpRenderTree/chromium/LayoutTestController.cpp:
+        (LayoutTestController::setMockSpeechInputResult):
+        * DumpRenderTree/gtk/LayoutTestControllerGtk.cpp:
+        (LayoutTestController::setMockSpeechInputResult):
+        * DumpRenderTree/mac/LayoutTestControllerMac.mm:
+        (LayoutTestController::setMockSpeechInputResult):
+        * DumpRenderTree/qt/LayoutTestControllerQt.h:
+        * DumpRenderTree/qt/LayoutTestControllerQt.cpp:
+        (LayoutTestController::setMockSpeechInputResult):
+        * DumpRenderTree/win/LayoutTestControllerWin.cpp:
+        (LayoutTestController::setMockSpeechInputResult):
+        * DumpRenderTree/wx/LayoutTestControllerWx.cpp:
+        (LayoutTestController::setMockSpeechInputResult):
+
 2010-10-21  MORITA Hajime  <morrita@google.com>
 
         Reviewed by Kent Tamura.
         * DumpRenderTree/gtk/LayoutTestControllerGtk.cpp:
         (LayoutTestController::setMockSpeechInputResult):
 
-2010-10-19  Leandro Gracia Gil  <leandrogracia@google.com>
-
-        Reviewed by Jeremy Orlow.
-
-        Added a second parameter to setMockSpeechInputResult for
-        the language used in speech input.
-        https://bugs.webkit.org/show_bug.cgi?id=47089
-
-        * DumpRenderTree/LayoutTestController.cpp:
-        (setMockSpeechInputResultCallback):
-        * DumpRenderTree/LayoutTestController.h:
-        * DumpRenderTree/chromium/LayoutTestController.cpp:
-        (LayoutTestController::setMockSpeechInputResult):
-        * DumpRenderTree/gtk/LayoutTestControllerGtk.cpp:
-        (LayoutTestController::setMockSpeechInputResult):
-
 2010-10-19  Adam Roben  <aroben@apple.com>
 
         Teach update-webkit-support-libs about the new versioning of
index b5cc874..db470c8 100644 (file)
@@ -1070,14 +1070,17 @@ static JSValueRef setMockGeolocationErrorCallback(JSContextRef context, JSObject
 
 static JSValueRef setMockSpeechInputResultCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
 {
-    if (argumentCount < 1)
+    if (argumentCount < 2)
         return JSValueMakeUndefined(context);
 
     JSRetainPtr<JSStringRef> result(Adopt, JSValueToStringCopy(context, arguments[0], exception));
     ASSERT(!*exception);
 
+    JSRetainPtr<JSStringRef> language(Adopt, JSValueToStringCopy(context, arguments[1], exception));
+    ASSERT(!*exception);
+
     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
-    controller->setMockSpeechInputResult(result.get());
+    controller->setMockSpeechInputResult(result.get(), language.get());
 
     return JSValueMakeUndefined(context);
 }
index 689e114..4410bfd 100644 (file)
@@ -94,7 +94,7 @@ public:
     void setMockDeviceOrientation(bool canProvideAlpha, double alpha, bool canProvideBeta, double beta, bool canProvideGamma, double gamma);
     void setMockGeolocationError(int code, JSStringRef message);
     void setMockGeolocationPosition(double latitude, double longitude, double accuracy);
-    void setMockSpeechInputResult(JSStringRef result);
+    void setMockSpeechInputResult(JSStringRef result, JSStringRef language);
     void setPersistentUserStyleSheetLocation(JSStringRef path);
     void setPluginsEnabled(bool flag);
     void setPopupBlockingEnabled(bool flag);
index 82fd085..d9d8183 100644 (file)
@@ -1526,10 +1526,10 @@ void LayoutTestController::abortModal(const CppArgumentList& arguments, CppVaria
 void LayoutTestController::setMockSpeechInputResult(const CppArgumentList& arguments, CppVariant* result)
 {
     result->setNull();
-    if (arguments.size() < 1 || !arguments[0].isString())
+    if (arguments.size() < 2 || !arguments[0].isString() || !arguments[1].isString())
         return;
 
-    m_speechInputControllerMock->setMockRecognitionResult(cppVariantToWebString(arguments[0]));
+    m_speechInputControllerMock->setMockRecognitionResult(cppVariantToWebString(arguments[0]), cppVariantToWebString(arguments[1]));
 }
 
 WebKit::WebSpeechInputController* LayoutTestController::speechInputController(WebKit::WebSpeechInputListener* listener)
index 181ef9f..f3db622 100644 (file)
@@ -500,7 +500,7 @@ void LayoutTestController::setGeolocationPermission(bool allow)
     setGeolocationPermissionCommon(allow);
 }
 
-void LayoutTestController::setMockSpeechInputResult(JSStringRef result)
+void LayoutTestController::setMockSpeechInputResult(JSStringRef result, JSStringRef language)
 {
     // FIXME: Implement for speech input layout tests.
     // See https://bugs.webkit.org/show_bug.cgi?id=39485.
index c5d5a90..150b6f9 100644 (file)
@@ -371,7 +371,7 @@ void LayoutTestController::setGeolocationPermission(bool allow)
     [[[mainFrame webView] UIDelegate] didSetMockGeolocationPermission];
 }
 
-void LayoutTestController::setMockSpeechInputResult(JSStringRef result)
+void LayoutTestController::setMockSpeechInputResult(JSStringRef result, JSStringRef language)
 {
     // FIXME: Implement for speech input layout tests.
     // See https://bugs.webkit.org/show_bug.cgi?id=39485.
index d36a074..2056b40 100644 (file)
@@ -759,7 +759,7 @@ void LayoutTestController::setMockGeolocationPosition(double latitude, double lo
     DumpRenderTreeSupportQt::setMockGeolocationPosition(latitude, longitude, accuracy);
 }
 
-void LayoutTestController::setMockSpeechInputResult(const QString& result)
+void LayoutTestController::setMockSpeechInputResult(const QString& result, const QString& language)
 {
     // FIXME: Implement for speech input layout tests.
     // See https://bugs.webkit.org/show_bug.cgi?id=39485.
index 3684946..106c73b 100644 (file)
@@ -215,7 +215,7 @@ public slots:
     bool isGeolocationPermissionSet() const { return m_isGeolocationPermissionSet; }
     bool geolocationPermission() const { return m_geolocationPermission; }
 
-    void setMockSpeechInputResult(const QString& result);
+    void setMockSpeechInputResult(const QString& result, const QString& language);
 
     // Empty stub method to keep parity with object model exposed by global LayoutTestController.
     void abortModal() {}
index 9e8ed1e..d7c41e0 100644 (file)
@@ -405,7 +405,7 @@ void LayoutTestController::setGeolocationPermission(bool allow)
     setGeolocationPermissionCommon(allow);
 }
 
-void LayoutTestController::setMockSpeechInputResult(JSStringRef result)
+void LayoutTestController::setMockSpeechInputResult(JSStringRef result, JSStringRef language)
 {
     // FIXME: Implement for speech input layout tests.
     // See https://bugs.webkit.org/show_bug.cgi?id=39485.
index eefc587..32614c1 100644 (file)
@@ -320,7 +320,7 @@ void LayoutTestController::setGeolocationPermission(bool allow)
     setGeolocationPermissionCommon(allow);
 }
 
-void LayoutTestController::setMockSpeechInputResult(JSStringRef result)
+void LayoutTestController::setMockSpeechInputResult(JSStringRef result, JSStringRef language)
 {
     // FIXME: Implement for speech input layout tests.
     // See https://bugs.webkit.org/show_bug.cgi?id=39485.
@@ -528,4 +528,3 @@ JSRetainPtr<JSStringRef> LayoutTestController::pageSizeAndMarginsInPixels(int pa
     // FIXME: Implement
     return 0;
 }
-