From: hans@chromium.org Date: Mon, 30 Jan 2012 10:10:33 +0000 (+0000) Subject: Unreviewed, rolling out r106219. X-Git-Tag: 070512121124~14262 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=aeed3672020fa73a7b615daa4fe87db1ef98f590;p=profile%2Fivi%2Fwebkit-efl.git Unreviewed, rolling out r106219. http://trac.webkit.org/changeset/106219 https://bugs.webkit.org/show_bug.cgi?id=77083 This broke Chromium's test_shell. Source/WebCore: * GNUmakefile.list.am: * Target.pri: * WebCore.gypi: * WebCore.vcproj/WebCore.vcproj: * WebCore.xcodeproj/project.pbxproj: * platform/mock/SpeechInputClientMock.cpp: Added. (WebCore): (WebCore::SpeechInputClientMock::SpeechInputClientMock): (WebCore::SpeechInputClientMock::setListener): (WebCore::SpeechInputClientMock::startRecognition): (WebCore::SpeechInputClientMock::stopRecording): (WebCore::SpeechInputClientMock::cancelRecognition): (WebCore::SpeechInputClientMock::addRecognitionResult): (WebCore::SpeechInputClientMock::clearResults): (WebCore::SpeechInputClientMock::timerFired): * platform/mock/SpeechInputClientMock.h: Added. (WebCore): (SpeechInputClientMock): Source/WebKit/chromium: * WebKit.gyp: * public/WebSpeechInputControllerMock.h: Added. (WebKit): (WebSpeechInputControllerMock): (WebKit::WebSpeechInputControllerMock::~WebSpeechInputControllerMock): * public/WebSpeechInputResult.h: (WebSpeechInputResult): * src/WebSpeechInputControllerMockImpl.cpp: Added. (WebKit): (WebKit::WebSpeechInputControllerMock::create): (WebKit::WebSpeechInputControllerMockImpl::WebSpeechInputControllerMockImpl): (WebKit::WebSpeechInputControllerMockImpl::~WebSpeechInputControllerMockImpl): (WebKit::WebSpeechInputControllerMockImpl::addMockRecognitionResult): (WebKit::WebSpeechInputControllerMockImpl::clearResults): (WebKit::WebSpeechInputControllerMockImpl::didCompleteRecording): (WebKit::WebSpeechInputControllerMockImpl::didCompleteRecognition): (WebKit::WebSpeechInputControllerMockImpl::setRecognitionResult): (WebKit::WebSpeechInputControllerMockImpl::startRecognition): (WebKit::WebSpeechInputControllerMockImpl::cancelRecognition): (WebKit::WebSpeechInputControllerMockImpl::stopRecording): * src/WebSpeechInputControllerMockImpl.h: Added. (WebCore): (WebKit): (WebSpeechInputControllerMockImpl): * src/WebSpeechInputResult.cpp: Tools: * DumpRenderTree/DumpRenderTree.gypi: * DumpRenderTree/chromium/LayoutTestController.cpp: (LayoutTestController::addMockSpeechInputResult): * DumpRenderTree/chromium/LayoutTestController.h: (WebKit): (LayoutTestController): (): * DumpRenderTree/chromium/MockWebSpeechInputController.cpp: Removed. * DumpRenderTree/chromium/MockWebSpeechInputController.h: Removed. * DumpRenderTree/chromium/TestShell.cpp: * DumpRenderTree/chromium/WebViewHost.cpp: (WebViewHost::speechInputController): * DumpRenderTree/chromium/WebViewHost.h: (WebKit): (WebViewHost::speechInputControllerMock): (WebViewHost): (): git-svn-id: http://svn.webkit.org/repository/webkit/trunk@106223 268f45cc-cd09-0410-ab3c-d52691b4dbfc --- diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog index 73fc871..c02af10 100644 --- a/Source/WebCore/ChangeLog +++ b/Source/WebCore/ChangeLog @@ -1,3 +1,30 @@ +2012-01-30 Hans Wennborg + + Unreviewed, rolling out r106219. + http://trac.webkit.org/changeset/106219 + https://bugs.webkit.org/show_bug.cgi?id=77083 + + This broke Chromium's test_shell. + + * GNUmakefile.list.am: + * Target.pri: + * WebCore.gypi: + * WebCore.vcproj/WebCore.vcproj: + * WebCore.xcodeproj/project.pbxproj: + * platform/mock/SpeechInputClientMock.cpp: Added. + (WebCore): + (WebCore::SpeechInputClientMock::SpeechInputClientMock): + (WebCore::SpeechInputClientMock::setListener): + (WebCore::SpeechInputClientMock::startRecognition): + (WebCore::SpeechInputClientMock::stopRecording): + (WebCore::SpeechInputClientMock::cancelRecognition): + (WebCore::SpeechInputClientMock::addRecognitionResult): + (WebCore::SpeechInputClientMock::clearResults): + (WebCore::SpeechInputClientMock::timerFired): + * platform/mock/SpeechInputClientMock.h: Added. + (WebCore): + (SpeechInputClientMock): + 2012-01-30 Yury Semikhatsky Unreviewed. Clang build fix after r106218 diff --git a/Source/WebCore/GNUmakefile.list.am b/Source/WebCore/GNUmakefile.list.am index 2cc3816..d485ee5 100644 --- a/Source/WebCore/GNUmakefile.list.am +++ b/Source/WebCore/GNUmakefile.list.am @@ -3141,6 +3141,8 @@ webcore_sources += \ Source/WebCore/platform/mock/GeolocationServiceMock.h \ Source/WebCore/platform/mock/ScrollbarThemeMock.cpp \ Source/WebCore/platform/mock/ScrollbarThemeMock.h \ + Source/WebCore/platform/mock/SpeechInputClientMock.cpp \ + Source/WebCore/platform/mock/SpeechInputClientMock.h \ Source/WebCore/platform/network/AuthenticationChallengeBase.cpp \ Source/WebCore/platform/network/AuthenticationChallengeBase.h \ Source/WebCore/platform/network/AuthenticationClient.h \ diff --git a/Source/WebCore/Target.pri b/Source/WebCore/Target.pri index 626bb8a..b34c542 100644 --- a/Source/WebCore/Target.pri +++ b/Source/WebCore/Target.pri @@ -1106,6 +1106,7 @@ SOURCES += \ platform/mock/DeviceOrientationClientMock.cpp \ platform/mock/GeolocationClientMock.cpp \ platform/mock/GeolocationServiceMock.cpp \ + platform/mock/SpeechInputClientMock.cpp \ platform/mock/ScrollbarThemeMock.cpp \ platform/network/AuthenticationChallengeBase.cpp \ platform/network/BlobData.cpp \ @@ -2099,6 +2100,7 @@ HEADERS += \ platform/mock/DeviceOrientationClientMock.h \ platform/mock/GeolocationClientMock.cpp \ platform/mock/GeolocationServiceMock.h \ + platform/mock/SpeechInputClientMock.h \ platform/mock/ScrollbarThemeMock.h \ platform/graphics/BitmapImage.h \ platform/graphics/Color.h \ diff --git a/Source/WebCore/WebCore.gypi b/Source/WebCore/WebCore.gypi index 50ade73..0330f10 100644 --- a/Source/WebCore/WebCore.gypi +++ b/Source/WebCore/WebCore.gypi @@ -3852,6 +3852,8 @@ 'platform/mock/GeolocationServiceMock.h', 'platform/mock/ScrollbarThemeMock.cpp', 'platform/mock/ScrollbarThemeMock.h', + 'platform/mock/SpeechInputClientMock.cpp', + 'platform/mock/SpeechInputClientMock.h', 'platform/network/AuthenticationChallengeBase.cpp', 'platform/network/BlobData.cpp', 'platform/network/BlobData.h', diff --git a/Source/WebCore/WebCore.vcproj/WebCore.vcproj b/Source/WebCore/WebCore.vcproj/WebCore.vcproj index 4d6027b..f18f470 100755 --- a/Source/WebCore/WebCore.vcproj/WebCore.vcproj +++ b/Source/WebCore/WebCore.vcproj/WebCore.vcproj @@ -32624,6 +32624,14 @@ RelativePath="..\platform\mock\ScrollbarThemeMock.h" > + + + + didCompleteRecognition(m_requestId); + m_requestId = 0; + } +} + +void SpeechInputClientMock::addRecognitionResult(const String& result, double confidence, const AtomicString& language) +{ + if (language.isEmpty()) + m_resultsForEmptyLanguage.append(SpeechInputResult::create(result, confidence)); + else { + if (!m_recognitionResults.contains(language)) + m_recognitionResults.set(language, SpeechInputResultArray()); + m_recognitionResults.find(language)->second.append(SpeechInputResult::create(result, confidence)); + } +} + +void SpeechInputClientMock::clearResults() +{ + m_resultsForEmptyLanguage.clear(); + m_recognitionResults.clear(); +} + +void SpeechInputClientMock::timerFired(WebCore::Timer*) +{ + if (m_recording) { + m_recording = false; + m_listener->didCompleteRecording(m_requestId); + m_timer.startOneShot(0); + } else { + bool noResultsFound = false; + + // We take a copy of the requestId here so that if scripts destroyed the input element + // inside one of the callbacks below, we'll still know what this session's requestId was. + int requestId = m_requestId; + m_requestId = 0; + + // Empty language case must be handled separately to avoid problems with HashMap and empty keys. + if (m_language.isEmpty()) { + if (!m_resultsForEmptyLanguage.isEmpty()) + m_listener->setRecognitionResult(requestId, m_resultsForEmptyLanguage); + else + noResultsFound = true; + } else { + if (m_recognitionResults.contains(m_language)) + m_listener->setRecognitionResult(requestId, m_recognitionResults.get(m_language)); + else + noResultsFound = true; + } + + if (noResultsFound) { + // Can't avoid setting a result even if no result was set for the given language. + // 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("'"); + SpeechInputResultArray results; + results.append(SpeechInputResult::create(error, 1.0)); + m_listener->setRecognitionResult(requestId, results); + } + + m_listener->didCompleteRecognition(requestId); + } +} + +} // namespace WebCore + +#endif // ENABLE(INPUT_SPEECH) diff --git a/Source/WebCore/platform/mock/SpeechInputClientMock.h b/Source/WebCore/platform/mock/SpeechInputClientMock.h new file mode 100644 index 0000000..4e13242 --- /dev/null +++ b/Source/WebCore/platform/mock/SpeechInputClientMock.h @@ -0,0 +1,78 @@ +/* + * Copyright (C) 2010 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR 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. + */ + +#ifndef SpeechInputClientMock_h +#define SpeechInputClientMock_h + +#include "PlatformString.h" +#include "SpeechInputClient.h" +#include "SpeechInputResult.h" +#include "Timer.h" +#include +#include + +#if ENABLE(INPUT_SPEECH) + +namespace WebCore { + +class SpeechInputListener; + +// Provides a mock object for the speech input embedder API called by WebCore. +class SpeechInputClientMock : public SpeechInputClient { +public: + SpeechInputClientMock(); + + void addRecognitionResult(const String& result, double confidence, const AtomicString& language); + void clearResults(); + + // SpeechInputClient methods. + void setListener(SpeechInputListener*); + bool startRecognition(int requestId, const IntRect& elementRect, const AtomicString& language, const String& grammar, SecurityOrigin*); + void stopRecording(int); + void cancelRecognition(int); + +private: + void timerFired(Timer*); + + bool m_recording; + Timer m_timer; + SpeechInputListener* m_listener; + int m_requestId; + + HashMap m_recognitionResults; + AtomicString m_language; + SpeechInputResultArray m_resultsForEmptyLanguage; +}; + +} // namespace WebCore + +#endif // ENABLE(INPUT_SPEECH) + +#endif // SpeechInputClientMock_h diff --git a/Source/WebKit/chromium/ChangeLog b/Source/WebKit/chromium/ChangeLog index 2b7a558..b829f67 100644 --- a/Source/WebKit/chromium/ChangeLog +++ b/Source/WebKit/chromium/ChangeLog @@ -1,3 +1,37 @@ +2012-01-30 Hans Wennborg + + Unreviewed, rolling out r106219. + http://trac.webkit.org/changeset/106219 + https://bugs.webkit.org/show_bug.cgi?id=77083 + + This broke Chromium's test_shell. + + * WebKit.gyp: + * public/WebSpeechInputControllerMock.h: Added. + (WebKit): + (WebSpeechInputControllerMock): + (WebKit::WebSpeechInputControllerMock::~WebSpeechInputControllerMock): + * public/WebSpeechInputResult.h: + (WebSpeechInputResult): + * src/WebSpeechInputControllerMockImpl.cpp: Added. + (WebKit): + (WebKit::WebSpeechInputControllerMock::create): + (WebKit::WebSpeechInputControllerMockImpl::WebSpeechInputControllerMockImpl): + (WebKit::WebSpeechInputControllerMockImpl::~WebSpeechInputControllerMockImpl): + (WebKit::WebSpeechInputControllerMockImpl::addMockRecognitionResult): + (WebKit::WebSpeechInputControllerMockImpl::clearResults): + (WebKit::WebSpeechInputControllerMockImpl::didCompleteRecording): + (WebKit::WebSpeechInputControllerMockImpl::didCompleteRecognition): + (WebKit::WebSpeechInputControllerMockImpl::setRecognitionResult): + (WebKit::WebSpeechInputControllerMockImpl::startRecognition): + (WebKit::WebSpeechInputControllerMockImpl::cancelRecognition): + (WebKit::WebSpeechInputControllerMockImpl::stopRecording): + * src/WebSpeechInputControllerMockImpl.h: Added. + (WebCore): + (WebKit): + (WebSpeechInputControllerMockImpl): + * src/WebSpeechInputResult.cpp: + 2012-01-26 Hans Wennborg Speech Input: move MockSpeechInputClient into Chromium DumpRenderTree implementation diff --git a/Source/WebKit/chromium/WebKit.gyp b/Source/WebKit/chromium/WebKit.gyp index 71e57e3..2d92ba5 100644 --- a/Source/WebKit/chromium/WebKit.gyp +++ b/Source/WebKit/chromium/WebKit.gyp @@ -245,6 +245,7 @@ 'public/WebSocket.h', 'public/WebSocketClient.h', 'public/WebSpeechInputController.h', + 'public/WebSpeechInputControllerMock.h', 'public/WebSpeechInputListener.h', 'public/WebSpeechInputResult.h', 'public/WebSpellCheckClient.h', @@ -641,6 +642,8 @@ 'src/WebSocketImpl.h', 'src/WebSolidColorLayer.cpp', 'src/WebSolidColorLayerImpl.cpp', + 'src/WebSpeechInputControllerMockImpl.cpp', + 'src/WebSpeechInputControllerMockImpl.h', 'src/WebSpeechInputResult.cpp', 'src/WebStorageAreaImpl.cpp', 'src/WebStorageAreaImpl.h', diff --git a/Source/WebKit/chromium/public/WebSpeechInputControllerMock.h b/Source/WebKit/chromium/public/WebSpeechInputControllerMock.h new file mode 100644 index 0000000..d4e543f --- /dev/null +++ b/Source/WebKit/chromium/public/WebSpeechInputControllerMock.h @@ -0,0 +1,54 @@ +/* + * Copyright (C) 2010 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR 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. + */ + +#ifndef WebSpeechInputControllerMock_h +#define WebSpeechInputControllerMock_h + +#include "WebSpeechInputController.h" + +namespace WebKit { + +class WebString; +class WebSpeechInputListener; + +class WebSpeechInputControllerMock : public WebSpeechInputController { +public: + WEBKIT_EXPORT static WebSpeechInputControllerMock* create( + WebSpeechInputListener* listener); + virtual ~WebSpeechInputControllerMock() { } + + virtual void addMockRecognitionResult(const WebString& result, double confidence, const WebString& language) = 0; + + virtual void clearResults() = 0; +}; + +} // namespace WebKit + +#endif diff --git a/Source/WebKit/chromium/public/WebSpeechInputResult.h b/Source/WebKit/chromium/public/WebSpeechInputResult.h index 8d02a49..a316fd2 100644 --- a/Source/WebKit/chromium/public/WebSpeechInputResult.h +++ b/Source/WebKit/chromium/public/WebSpeechInputResult.h @@ -42,11 +42,9 @@ namespace WebKit { class WebSpeechInputResult { public: WebSpeechInputResult() { } - WebSpeechInputResult(const WebSpeechInputResult& other) { assign(other); } ~WebSpeechInputResult() { reset(); } WEBKIT_EXPORT void set(const WebString& utterance, double confidence); - WEBKIT_EXPORT void assign(const WebSpeechInputResult& other); WEBKIT_EXPORT void reset(); #if WEBKIT_IMPLEMENTATION diff --git a/Source/WebKit/chromium/src/WebSpeechInputControllerMockImpl.cpp b/Source/WebKit/chromium/src/WebSpeechInputControllerMockImpl.cpp new file mode 100644 index 0000000..4f1f074 --- /dev/null +++ b/Source/WebKit/chromium/src/WebSpeechInputControllerMockImpl.cpp @@ -0,0 +1,117 @@ +/* + * Copyright (C) 2010 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR 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. + */ + +#include "config.h" +#include "WebSpeechInputControllerMockImpl.h" + +#if ENABLE(INPUT_SPEECH) + +#include "PlatformString.h" +#include "SecurityOrigin.h" +#include "SpeechInputClientMock.h" +#include "platform/WebRect.h" +#include "WebSecurityOrigin.h" +#include + +namespace WebKit { + +WebSpeechInputControllerMock* WebSpeechInputControllerMock::create(WebSpeechInputListener* listener) +{ + return new WebSpeechInputControllerMockImpl(listener); +} + +WebSpeechInputControllerMockImpl::WebSpeechInputControllerMockImpl( + WebSpeechInputListener* listener) + : m_webcoreMock(adoptPtr(new WebCore::SpeechInputClientMock())) + , m_listener(listener) +{ + m_webcoreMock->setListener(this); +} + +WebSpeechInputControllerMockImpl::~WebSpeechInputControllerMockImpl() +{ + m_webcoreMock->setListener(0); +} + +void WebSpeechInputControllerMockImpl::addMockRecognitionResult(const WebString& result, double confidence, const WebString &language) +{ + m_webcoreMock->addRecognitionResult(result, confidence, language); +} + +void WebSpeechInputControllerMockImpl::clearResults() +{ + m_webcoreMock->clearResults(); +} + +void WebSpeechInputControllerMockImpl::didCompleteRecording(int requestId) +{ + m_listener->didCompleteRecording(requestId); +} + +void WebSpeechInputControllerMockImpl::didCompleteRecognition(int requestId) +{ + m_listener->didCompleteRecognition(requestId); +} + +void WebSpeechInputControllerMockImpl::setRecognitionResult(int requestId, const WebCore::SpeechInputResultArray& result) +{ + m_listener->setRecognitionResult(requestId, result); +} + +bool WebSpeechInputControllerMockImpl::startRecognition(int requestId, const WebRect& elementRect, const WebString& language, const WebString& grammar, const WebSecurityOrigin& origin) +{ + return m_webcoreMock->startRecognition(requestId, elementRect, language, grammar, origin.get()); +} + +void WebSpeechInputControllerMockImpl::cancelRecognition(int requestId) +{ + m_webcoreMock->cancelRecognition(requestId); +} + +void WebSpeechInputControllerMockImpl::stopRecording(int requestId) +{ + m_webcoreMock->stopRecording(requestId); +} + +} // namespace WebKit + +#else + +namespace WebKit { + +WebSpeechInputControllerMock* WebSpeechInputControllerMock::create(WebSpeechInputListener* listener) +{ + return 0; +} + +} // namespace WebKit + +#endif // ENABLE(INPUT_SPEECH) + diff --git a/Source/WebKit/chromium/src/WebSpeechInputControllerMockImpl.h b/Source/WebKit/chromium/src/WebSpeechInputControllerMockImpl.h new file mode 100644 index 0000000..05bfd52 --- /dev/null +++ b/Source/WebKit/chromium/src/WebSpeechInputControllerMockImpl.h @@ -0,0 +1,79 @@ +/* + * Copyright (C) 2010 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR 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. + */ + +#ifndef WebSpeechInputControllerMockImpl_h +#define WebSpeechInputControllerMockImpl_h + +#include "SpeechInputListener.h" +#include "WebSpeechInputControllerMock.h" +#include "WebSpeechInputListener.h" +#include "platform/WebString.h" +#include + +#if ENABLE(INPUT_SPEECH) + +namespace WebCore { +class SpeechInputClientMock; +} + +namespace WebKit { + +struct WebRect; + +class WebSpeechInputControllerMockImpl : public WebCore::SpeechInputListener + , public WebSpeechInputControllerMock { +public: + WebSpeechInputControllerMockImpl(WebSpeechInputListener*); + virtual ~WebSpeechInputControllerMockImpl(); + + // WebCore::SpeechInputListener methods. + void didCompleteRecording(int requestId); + void didCompleteRecognition(int requestId); + void setRecognitionResult(int requestId, const WebCore::SpeechInputResultArray& result); + + // WebSpeechInputController methods. + bool startRecognition(int requestId, const WebRect& elementRect, const WebString& language, const WebString& grammar, const WebSecurityOrigin&); + void cancelRecognition(int requestId); + void stopRecording(int requestId); + + // WebSpeechInputControllerMock methods. + void addMockRecognitionResult(const WebString& result, double confidence, const WebString& language); + void clearResults(); + +private: + OwnPtr m_webcoreMock; + WebSpeechInputListener* m_listener; +}; + +} // namespace WebKit + +#endif // ENABLE(INPUT_SPEECH) + +#endif // WebSpeechInputControllerMockImpl_h diff --git a/Source/WebKit/chromium/src/WebSpeechInputResult.cpp b/Source/WebKit/chromium/src/WebSpeechInputResult.cpp index 693538f..9b13144 100644 --- a/Source/WebKit/chromium/src/WebSpeechInputResult.cpp +++ b/Source/WebKit/chromium/src/WebSpeechInputResult.cpp @@ -48,11 +48,6 @@ void WebSpeechInputResult::set(const WebString& utterance, double confidence) m_private = WebCore::SpeechInputResult::create(utterance, confidence); } -void WebSpeechInputResult::assign(const WebSpeechInputResult& other) -{ - m_private = WebCore::SpeechInputResult::create(*other.m_private.get()); -} - WebSpeechInputResult::operator PassRefPtr() const { return m_private.get(); diff --git a/Tools/ChangeLog b/Tools/ChangeLog index 2f8415c..f3c9308 100644 --- a/Tools/ChangeLog +++ b/Tools/ChangeLog @@ -1,3 +1,29 @@ +2012-01-30 Hans Wennborg + + Unreviewed, rolling out r106219. + http://trac.webkit.org/changeset/106219 + https://bugs.webkit.org/show_bug.cgi?id=77083 + + This broke Chromium's test_shell. + + * DumpRenderTree/DumpRenderTree.gypi: + * DumpRenderTree/chromium/LayoutTestController.cpp: + (LayoutTestController::addMockSpeechInputResult): + * DumpRenderTree/chromium/LayoutTestController.h: + (WebKit): + (LayoutTestController): + (): + * DumpRenderTree/chromium/MockWebSpeechInputController.cpp: Removed. + * DumpRenderTree/chromium/MockWebSpeechInputController.h: Removed. + * DumpRenderTree/chromium/TestShell.cpp: + * DumpRenderTree/chromium/WebViewHost.cpp: + (WebViewHost::speechInputController): + * DumpRenderTree/chromium/WebViewHost.h: + (WebKit): + (WebViewHost::speechInputControllerMock): + (WebViewHost): + (): + 2012-01-26 Hans Wennborg Speech Input: move MockSpeechInputClient into Chromium DumpRenderTree implementation diff --git a/Tools/DumpRenderTree/DumpRenderTree.gypi b/Tools/DumpRenderTree/DumpRenderTree.gypi index 0736c03..b707464 100644 --- a/Tools/DumpRenderTree/DumpRenderTree.gypi +++ b/Tools/DumpRenderTree/DumpRenderTree.gypi @@ -22,8 +22,6 @@ 'chromium/LayoutTestController.h', 'chromium/MockSpellCheck.cpp', 'chromium/MockSpellCheck.h', - 'chromium/MockWebSpeechInputController.cpp', - 'chromium/MockWebSpeechInputController.h', 'chromium/NotificationPresenter.h', 'chromium/NotificationPresenter.cpp', 'chromium/PlainTextController.cpp', diff --git a/Tools/DumpRenderTree/chromium/LayoutTestController.cpp b/Tools/DumpRenderTree/chromium/LayoutTestController.cpp index 37480b0..de394a9 100644 --- a/Tools/DumpRenderTree/chromium/LayoutTestController.cpp +++ b/Tools/DumpRenderTree/chromium/LayoutTestController.cpp @@ -33,7 +33,6 @@ #include "LayoutTestController.h" #include "DRTDevToolsAgent.h" -#include "MockWebSpeechInputController.h" #include "TestShell.h" #include "WebAnimationController.h" #include "WebBindings.h" @@ -56,6 +55,7 @@ #include "WebSecurityPolicy.h" #include "WebSettings.h" #include "platform/WebSize.h" +#include "WebSpeechInputControllerMock.h" #include "platform/WebURL.h" #include "WebView.h" #include "WebViewHost.h" @@ -1934,7 +1934,7 @@ void LayoutTestController::addMockSpeechInputResult(const CppArgumentList& argum if (arguments.size() < 3 || !arguments[0].isString() || !arguments[1].isNumber() || !arguments[2].isString()) return; - if (MockWebSpeechInputController* controller = m_shell->webViewHost()->speechInputControllerMock()) + if (WebSpeechInputControllerMock* controller = m_shell->webViewHost()->speechInputControllerMock()) controller->addMockRecognitionResult(cppVariantToWebString(arguments[0]), arguments[1].toDouble(), cppVariantToWebString(arguments[2])); } diff --git a/Tools/DumpRenderTree/chromium/LayoutTestController.h b/Tools/DumpRenderTree/chromium/LayoutTestController.h index e37ff7d..2c7df80 100644 --- a/Tools/DumpRenderTree/chromium/LayoutTestController.h +++ b/Tools/DumpRenderTree/chromium/LayoutTestController.h @@ -52,6 +52,9 @@ namespace WebKit { class WebGeolocationClientMock; +class WebSpeechInputController; +class WebSpeechInputControllerMock; +class WebSpeechInputListener; } namespace webkit_support { @@ -439,6 +442,7 @@ public: // The following methods are not exposed to JavaScript. void setWorkQueueFrozen(bool frozen) { m_workQueue.setFrozen(frozen); } + WebKit::WebSpeechInputController* speechInputController(WebKit::WebSpeechInputListener*); bool shouldDumpAsAudio() const { return m_dumpAsAudio; } void setShouldDumpAsAudio(bool dumpAsAudio) { m_dumpAsAudio = dumpAsAudio; } bool shouldDumpAsText() { return m_dumpAsText; } @@ -695,6 +699,8 @@ private: WebKit::WebURL m_userStyleSheetLocation; + OwnPtr m_speechInputControllerMock; + // WAV audio data is stored here. WebKit::WebArrayBufferView m_audioData; diff --git a/Tools/DumpRenderTree/chromium/MockWebSpeechInputController.cpp b/Tools/DumpRenderTree/chromium/MockWebSpeechInputController.cpp deleted file mode 100644 index cb0b066..0000000 --- a/Tools/DumpRenderTree/chromium/MockWebSpeechInputController.cpp +++ /dev/null @@ -1,167 +0,0 @@ -/* - * Copyright (C) 2012 Google Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR 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. - */ - -#include "config.h" -#include "MockWebSpeechInputController.h" - -#include "WebSpeechInputListener.h" -#include "platform/WebCString.h" -#include - -using namespace WebKit; - -PassOwnPtr MockWebSpeechInputController::create(WebSpeechInputListener* listener) -{ - return adoptPtr(new MockWebSpeechInputController(listener)); -} - -void MockWebSpeechInputController::addMockRecognitionResult(const WebString& result, double confidence, const WebString& language) -{ - WebSpeechInputResult res; - res.set(result, confidence); - - if (language.isEmpty()) - m_resultsForEmptyLanguage.append(res); - else { - String langString = String::fromUTF8(language.utf8().data()); - if (!m_recognitionResults.contains(langString)) - m_recognitionResults.set(langString, Vector()); - m_recognitionResults.find(langString)->second.append(res); - } -} - -void MockWebSpeechInputController::clearResults() -{ - m_resultsForEmptyLanguage.clear(); - m_recognitionResults.clear(); -} - -bool MockWebSpeechInputController::startRecognition(int requestId, const WebRect& elementRect, const WebString& language, const WebString& grammar, const WebSecurityOrigin& origin) -{ - if (m_speechTask) - return false; - - m_requestId = requestId; - m_recording = true; - m_language = String::fromUTF8(language.utf8().data()); - - m_speechTask = new SpeechTask(this); - postTask(m_speechTask); - - return true; -} - -void MockWebSpeechInputController::cancelRecognition(int requestId) -{ - if (m_speechTask) { - ASSERT(requestId == m_requestId); - - m_speechTask->stop(); - m_recording = false; - m_listener->didCompleteRecognition(m_requestId); - m_requestId = 0; - } -} - -void MockWebSpeechInputController::stopRecording(int requestId) -{ - ASSERT(requestId == m_requestId); - if (m_speechTask && m_recording) { - m_speechTask->stop(); - speechTaskFired(); - } -} - -MockWebSpeechInputController::MockWebSpeechInputController(WebSpeechInputListener* listener) - : m_listener(listener) - , m_speechTask(0) - , m_recording(false) - , m_requestId(-1) -{ -} - -void MockWebSpeechInputController::speechTaskFired() -{ - if (m_recording) { - m_recording = false; - m_listener->didCompleteRecording(m_requestId); - - m_speechTask = new SpeechTask(this); - postTask(m_speechTask); - } else { - bool noResultsFound = false; - // We take a copy of the requestId here so that if scripts destroyed the input element - // inside one of the callbacks below, we'll still know what this session's requestId was. - int requestId = m_requestId; - m_requestId = 0; - - // Empty language case must be handled separately to avoid problems with HashMap and empty keys. - if (m_language.isEmpty()) { - if (!m_resultsForEmptyLanguage.isEmpty()) - m_listener->setRecognitionResult(requestId, m_resultsForEmptyLanguage); - else - noResultsFound = true; - } else { - if (m_recognitionResults.contains(m_language)) - m_listener->setRecognitionResult(requestId, m_recognitionResults.get(m_language)); - else - noResultsFound = true; - } - - if (noResultsFound) { - // Can't avoid setting a result even if no result was set for the given language. - // 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("'"); - - WebSpeechInputResult res; - res.set(WebString::fromUTF8(error.utf8().data()), 1.0); - - Vector results; - results.append(res); - - m_listener->setRecognitionResult(requestId, results); - } - } -} - -MockWebSpeechInputController::SpeechTask::SpeechTask(MockWebSpeechInputController* mock) - : MethodTask::MethodTask(mock) -{ -} - -void MockWebSpeechInputController::SpeechTask::stop() -{ - m_object->m_speechTask = 0; - cancel(); - delete(this); -} - -void MockWebSpeechInputController::SpeechTask::runIfValid() -{ - m_object->m_speechTask = 0; - m_object->speechTaskFired(); -} diff --git a/Tools/DumpRenderTree/chromium/MockWebSpeechInputController.h b/Tools/DumpRenderTree/chromium/MockWebSpeechInputController.h deleted file mode 100644 index 96aadff..0000000 --- a/Tools/DumpRenderTree/chromium/MockWebSpeechInputController.h +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Copyright (C) 2012 Google Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR 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. - */ - -#ifndef MockWebSpeechInputController_h -#define MockWebSpeechInputController_h - -#if ENABLE(INPUT_SPEECH) - -#include "Task.h" -#include "WebSpeechInputController.h" -#include "WebSpeechInputResult.h" -#include -#include -#include -#include -#include -#include - -namespace WebKit { -struct WebRect; -class WebSecurityOrigin; -class WebSpeechInputListener; -class WebString; -} - -class MockWebSpeechInputController : public WebKit::WebSpeechInputController { -public: - static PassOwnPtr create(WebKit::WebSpeechInputListener*); - - void addMockRecognitionResult(const WebKit::WebString& result, double confidence, const WebKit::WebString& language); - void clearResults(); - - // WebSpeechInputController implementation: - virtual bool startRecognition(int requestId, const WebKit::WebRect& elementRect, const WebKit::WebString& language, const WebKit::WebString& grammar, const WebKit::WebSecurityOrigin&) OVERRIDE; - virtual void cancelRecognition(int requestId) OVERRIDE; - virtual void stopRecording(int requestId) OVERRIDE; - - TaskList* taskList() { return &m_taskList; } - -private: - MockWebSpeechInputController(WebKit::WebSpeechInputListener*); - void speechTaskFired(); - - class SpeechTask : public MethodTask { - public: - SpeechTask(MockWebSpeechInputController*); - void stop(); - - private: - virtual void runIfValid() OVERRIDE; - }; - - WebKit::WebSpeechInputListener* m_listener; - - TaskList m_taskList; - SpeechTask* m_speechTask; - - bool m_recording; - int m_requestId; - String m_language; - - HashMap > m_recognitionResults; - Vector m_resultsForEmptyLanguage; -}; - -#endif // ENABLE(INPUT_SPEECH) - -#endif // MockWebSpeechInputController_h diff --git a/Tools/DumpRenderTree/chromium/TestShell.cpp b/Tools/DumpRenderTree/chromium/TestShell.cpp index 501e78b..45cbc1e 100644 --- a/Tools/DumpRenderTree/chromium/TestShell.cpp +++ b/Tools/DumpRenderTree/chromium/TestShell.cpp @@ -52,6 +52,7 @@ #include "WebScriptController.h" #include "WebSettings.h" #include "platform/WebSize.h" +#include "WebSpeechInputControllerMock.h" #include "platform/WebString.h" #include "platform/WebURLRequest.h" #include "platform/WebURLResponse.h" diff --git a/Tools/DumpRenderTree/chromium/WebViewHost.cpp b/Tools/DumpRenderTree/chromium/WebViewHost.cpp index 2e68030..f8ee472 100644 --- a/Tools/DumpRenderTree/chromium/WebViewHost.cpp +++ b/Tools/DumpRenderTree/chromium/WebViewHost.cpp @@ -32,7 +32,6 @@ #include "WebViewHost.h" #include "LayoutTestController.h" -#include "MockWebSpeechInputController.h" #include "TestNavigationController.h" #include "TestShell.h" #include "TestWebPlugin.h" @@ -56,6 +55,7 @@ #include "platform/WebRect.h" #include "WebScreenInfo.h" #include "platform/WebSize.h" +#include "WebSpeechInputControllerMock.h" #include "WebStorageNamespace.h" #include "WebTextCheckingCompletion.h" #include "WebTextCheckingResult.h" @@ -678,7 +678,7 @@ WebKit::WebGeolocationClientMock* WebViewHost::geolocationClientMock() WebSpeechInputController* WebViewHost::speechInputController(WebKit::WebSpeechInputListener* listener) { if (!m_speechInputControllerMock) - m_speechInputControllerMock = MockWebSpeechInputController::create(listener); + m_speechInputControllerMock = adoptPtr(WebSpeechInputControllerMock::create(listener)); return m_speechInputControllerMock.get(); } diff --git a/Tools/DumpRenderTree/chromium/WebViewHost.h b/Tools/DumpRenderTree/chromium/WebViewHost.h index eb21369..1d0954a 100644 --- a/Tools/DumpRenderTree/chromium/WebViewHost.h +++ b/Tools/DumpRenderTree/chromium/WebViewHost.h @@ -45,7 +45,6 @@ #include class LayoutTestController; -class MockWebSpeechInputController; class SkCanvas; class TestShell; @@ -58,6 +57,7 @@ class WebGeolocationClientMock; class WebGeolocationServiceMock; class WebSharedWorkerClient; class WebSpeechInputController; +class WebSpeechInputControllerMock; class WebSpeechInputListener; class WebURL; class WebUserMediaClientMock; @@ -108,7 +108,7 @@ class WebViewHost : public WebKit::WebSpellCheckClient, public WebKit::WebViewCl WebKit::WebContextMenuData* lastContextMenuData() const; void clearContextMenuData(); - MockWebSpeechInputController* speechInputControllerMock() { return m_speechInputControllerMock.get(); } + WebKit::WebSpeechInputControllerMock* speechInputControllerMock() { return m_speechInputControllerMock.get(); } #if ENABLE(POINTER_LOCK) void didLosePointerLock(); @@ -382,7 +382,7 @@ private: OwnPtr m_geolocationClientMock; OwnPtr m_deviceOrientationClientMock; - OwnPtr m_speechInputControllerMock; + OwnPtr m_speechInputControllerMock; OwnPtr m_userMediaClientMock; OwnPtr m_testMediaStreamClient;