[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

andreip at google.com andreip at google.com
Wed Dec 22 14:47:39 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit 7238cfb624e3882e7813704cfbb90ce11c04a267
Author: andreip at google.com <andreip at google.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Wed Oct 20 15:56:03 2010 +0000

    2010-10-19  Leandro Gracia Gil  <leandrogracia at 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  Leandro Gracia Gil  <leandrogracia at 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-19  Leandro Gracia Gil  <leandrogracia at 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-19  Leandro Gracia Gil  <leandrogracia at 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):
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@70149 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index b11ebd1..62b4849 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,21 @@
+2010-10-19  Leandro Gracia Gil  <leandrogracia at 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 at rim.com>
 
         Reviewed by Kenneth Rohde Christiansen.
diff --git a/LayoutTests/fast/speech/input-text-speechbutton.html b/LayoutTests/fast/speech/input-text-speechbutton.html
index 6f5bc4b..cef7705 100644
--- a/LayoutTests/fast/speech/input-text-speechbutton.html
+++ b/LayoutTests/fast/speech/input-text-speechbutton.html
@@ -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');
diff --git a/LayoutTests/fast/speech/speech-button-ignore-generated-events.html b/LayoutTests/fast/speech/speech-button-ignore-generated-events.html
index b9b8ec3..c684863 100644
--- a/LayoutTests/fast/speech/speech-button-ignore-generated-events.html
+++ b/LayoutTests/fast/speech/speech-button-ignore-generated-events.html
@@ -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');
 
diff --git a/LayoutTests/platform/chromium/test_expectations.txt b/LayoutTests/platform/chromium/test_expectations.txt
index d32845a..2cbe37d 100644
--- a/LayoutTests/platform/chromium/test_expectations.txt
+++ b/LayoutTests/platform/chromium/test_expectations.txt
@@ -3242,3 +3242,6 @@ BUGJAPHET : fast/dom/HTMLAnchorElement/set-href-attribute-prevents-rebase.html =
 
 // r69833, JSC/V8 Date parsing differences
 BUGJAPHET : fast/js/date-parse-test.html = TEXT
+
+// Temporarily disabled for a 4-sided patch. Will be enabled again by BUGWK47420.
+BUGWK47089 : fast/speech/input-text-language-tag.html = FAIL
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index ecbb1e9..6fc2f94 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,40 @@
+2010-10-19  Leandro Gracia Gil  <leandrogracia at 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 at webkit.org>
 
         Reviewed by Nikolas Zimmermann.
diff --git a/WebCore/dom/Element.cpp b/WebCore/dom/Element.cpp
index 83e129e..c7d442a 100644
--- a/WebCore/dom/Element.cpp
+++ b/WebCore/dom/Element.cpp
@@ -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;
 }
 
diff --git a/WebCore/page/SpeechInput.cpp b/WebCore/page/SpeechInput.cpp
index 234791b..cc5e0f9 100644
--- a/WebCore/page/SpeechInput.cpp
+++ b/WebCore/page/SpeechInput.cpp
@@ -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)
diff --git a/WebCore/page/SpeechInput.h b/WebCore/page/SpeechInput.h
index d10b789..8b426f5 100644
--- a/WebCore/page/SpeechInput.h
+++ b/WebCore/page/SpeechInput.h
@@ -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);
 
diff --git a/WebCore/page/SpeechInputClient.h b/WebCore/page/SpeechInputClient.h
index d5fda17..f5aab02 100644
--- a/WebCore/page/SpeechInputClient.h
+++ b/WebCore/page/SpeechInputClient.h
@@ -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).
diff --git a/WebCore/platform/mock/SpeechInputClientMock.cpp b/WebCore/platform/mock/SpeechInputClientMock.cpp
index 6b64942..c04971e 100644
--- a/WebCore/platform/mock/SpeechInputClientMock.cpp
+++ b/WebCore/platform/mock/SpeechInputClientMock.cpp
@@ -35,6 +35,11 @@
 
 #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;
     }
diff --git a/WebCore/platform/mock/SpeechInputClientMock.h b/WebCore/platform/mock/SpeechInputClientMock.h
index ce83d3b..3ce987b 100644
--- a/WebCore/platform/mock/SpeechInputClientMock.h
+++ b/WebCore/platform/mock/SpeechInputClientMock.h
@@ -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
diff --git a/WebCore/rendering/TextControlInnerElements.cpp b/WebCore/rendering/TextControlInnerElements.cpp
index 5d5b8b3..65d0a64 100644
--- a/WebCore/rendering/TextControlInnerElements.cpp
+++ b/WebCore/rendering/TextControlInnerElements.cpp
@@ -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)
diff --git a/WebKit/chromium/ChangeLog b/WebKit/chromium/ChangeLog
index 22e6792..37b22e0 100644
--- a/WebKit/chromium/ChangeLog
+++ b/WebKit/chromium/ChangeLog
@@ -1,3 +1,33 @@
+2010-10-19  Leandro Gracia Gil  <leandrogracia at 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 at webkit.org>
 
         Unreviewed Chromium win build fix.
diff --git a/WebKit/chromium/public/WebSpeechInputController.h b/WebKit/chromium/public/WebSpeechInputController.h
index 5408741..1fde2a8 100644
--- a/WebKit/chromium/public/WebSpeechInputController.h
+++ b/WebKit/chromium/public/WebSpeechInputController.h
@@ -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;
diff --git a/WebKit/chromium/public/WebSpeechInputControllerMock.h b/WebKit/chromium/public/WebSpeechInputControllerMock.h
index 9a26235..b4c50a0 100644
--- a/WebKit/chromium/public/WebSpeechInputControllerMock.h
+++ b/WebKit/chromium/public/WebSpeechInputControllerMock.h
@@ -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;
 };
 
diff --git a/WebKit/chromium/src/SpeechInputClientImpl.cpp b/WebKit/chromium/src/SpeechInputClientImpl.cpp
index 963d440..1381929 100644
--- a/WebKit/chromium/src/SpeechInputClientImpl.cpp
+++ b/WebKit/chromium/src/SpeechInputClientImpl.cpp
@@ -32,15 +32,21 @@
 #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)
diff --git a/WebKit/chromium/src/SpeechInputClientImpl.h b/WebKit/chromium/src/SpeechInputClientImpl.h
index 817b32b..c7d1fa3 100644
--- a/WebKit/chromium/src/SpeechInputClientImpl.h
+++ b/WebKit/chromium/src/SpeechInputClientImpl.h
@@ -33,8 +33,15 @@
 
 #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;
 };
diff --git a/WebKit/chromium/src/WebSpeechInputControllerMockImpl.cpp b/WebKit/chromium/src/WebSpeechInputControllerMockImpl.cpp
index 60c4fed..45c6ff0 100644
--- a/WebKit/chromium/src/WebSpeechInputControllerMockImpl.cpp
+++ b/WebKit/chromium/src/WebSpeechInputControllerMockImpl.cpp
@@ -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)
diff --git a/WebKit/chromium/src/WebSpeechInputControllerMockImpl.h b/WebKit/chromium/src/WebSpeechInputControllerMockImpl.h
index edbfca3..1b3053b 100644
--- a/WebKit/chromium/src/WebSpeechInputControllerMockImpl.h
+++ b/WebKit/chromium/src/WebSpeechInputControllerMockImpl.h
@@ -37,6 +37,10 @@
 #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
-
diff --git a/WebKit/chromium/src/WebViewImpl.cpp b/WebKit/chromium/src/WebViewImpl.cpp
index aeab400..0c1ee36 100644
--- a/WebKit/chromium/src/WebViewImpl.cpp
+++ b/WebKit/chromium/src/WebViewImpl.cpp
@@ -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"
@@ -275,7 +276,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))
 {
@@ -298,7 +299,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();
 
diff --git a/WebKit/chromium/src/WebViewImpl.h b/WebKit/chromium/src/WebViewImpl.h
index 050b5e1..712eb7a 100644
--- a/WebKit/chromium/src/WebViewImpl.h
+++ b/WebKit/chromium/src/WebViewImpl.h
@@ -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;
@@ -543,7 +543,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
diff --git a/WebKitTools/ChangeLog b/WebKitTools/ChangeLog
index b128dfb..a870d51 100644
--- a/WebKitTools/ChangeLog
+++ b/WebKitTools/ChangeLog
@@ -1,3 +1,19 @@
+2010-10-19  Leandro Gracia Gil  <leandrogracia at 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 at apple.com>
 
         Teach update-webkit-support-libs about the new versioning of
diff --git a/WebKitTools/DumpRenderTree/LayoutTestController.cpp b/WebKitTools/DumpRenderTree/LayoutTestController.cpp
index b5cc874..db470c8 100644
--- a/WebKitTools/DumpRenderTree/LayoutTestController.cpp
+++ b/WebKitTools/DumpRenderTree/LayoutTestController.cpp
@@ -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);
 }
diff --git a/WebKitTools/DumpRenderTree/LayoutTestController.h b/WebKitTools/DumpRenderTree/LayoutTestController.h
index 689e114..9a945e9 100644
--- a/WebKitTools/DumpRenderTree/LayoutTestController.h
+++ b/WebKitTools/DumpRenderTree/LayoutTestController.h
@@ -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 languageTag);
     void setPersistentUserStyleSheetLocation(JSStringRef path);
     void setPluginsEnabled(bool flag);
     void setPopupBlockingEnabled(bool flag);
diff --git a/WebKitTools/DumpRenderTree/chromium/LayoutTestController.cpp b/WebKitTools/DumpRenderTree/chromium/LayoutTestController.cpp
index 82fd085..d9d8183 100644
--- a/WebKitTools/DumpRenderTree/chromium/LayoutTestController.cpp
+++ b/WebKitTools/DumpRenderTree/chromium/LayoutTestController.cpp
@@ -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)
diff --git a/WebKitTools/DumpRenderTree/gtk/LayoutTestControllerGtk.cpp b/WebKitTools/DumpRenderTree/gtk/LayoutTestControllerGtk.cpp
index 181ef9f..f3db622 100644
--- a/WebKitTools/DumpRenderTree/gtk/LayoutTestControllerGtk.cpp
+++ b/WebKitTools/DumpRenderTree/gtk/LayoutTestControllerGtk.cpp
@@ -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.

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list