https://bugs.webkit.org/show_bug.cgi?id=76443
Reviewed by Darin Fisher.
Source/WebCore:
When requesting speech input, report the speech element rect relative
to the window rather than the frame. The embedder will typically use
this position to show a bubble indicating that speech recognition is
in progress.
Test: fast/speech/bubble-position.html
* html/shadow/TextControlInnerElements.cpp:
(WebCore::InputFieldSpeechButtonElement::startSpeechInput):
Tools:
Update LayoutTestController to allow for retrieving the speech
element's position used in a request.
In Chromium this is handled by the MockWebSpeechInputController;
adding stubs for the other implementations.
* DumpRenderTree/LayoutTestController.cpp:
(setMockSpeechInputDumpRectCallback):
(LayoutTestController::staticFunctions):
* DumpRenderTree/LayoutTestController.h:
(LayoutTestController):
* DumpRenderTree/chromium/LayoutTestController.cpp:
(LayoutTestController::LayoutTestController):
(LayoutTestController::setMockSpeechInputDumpRect):
* DumpRenderTree/chromium/LayoutTestController.h:
(LayoutTestController):
* DumpRenderTree/chromium/MockWebSpeechInputController.cpp:
(MockWebSpeechInputController::setDumpRect):
(MockWebSpeechInputController::clearResults):
(MockWebSpeechInputController::startRecognition):
(MockWebSpeechInputController::MockWebSpeechInputController):
(makeRectResult):
(MockWebSpeechInputController::speechTaskFired):
* DumpRenderTree/chromium/MockWebSpeechInputController.h:
(MockWebSpeechInputController):
* DumpRenderTree/efl/LayoutTestControllerEfl.cpp:
(LayoutTestController::setMockSpeechInputDumpRect):
* DumpRenderTree/gtk/LayoutTestControllerGtk.cpp:
(LayoutTestController::setMockSpeechInputDumpRect):
* DumpRenderTree/mac/LayoutTestControllerMac.mm:
(LayoutTestController::setMockSpeechInputDumpRect):
* DumpRenderTree/qt/LayoutTestControllerQt.cpp:
(LayoutTestController::setMockSpeechInputDumpRect):
* DumpRenderTree/qt/LayoutTestControllerQt.h:
(LayoutTestController):
* DumpRenderTree/win/LayoutTestControllerWin.cpp:
(LayoutTestController::setMockSpeechInputDumpRect):
* DumpRenderTree/wx/LayoutTestControllerWx.cpp:
(LayoutTestController::setMockSpeechInputDumpRect):
LayoutTests:
Add layout test to check that the element position used when
requesting speech input is relative to the window, not the frame.
* fast/speech/bubble-position-expected.txt: Added.
* fast/speech/bubble-position.html: Added.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@106438
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2012-01-31 Hans Wennborg <hans@chromium.org>
+
+ Speech Input: Report speech element rect relative to window rather than frame
+ https://bugs.webkit.org/show_bug.cgi?id=76443
+
+ Reviewed by Darin Fisher.
+
+ Add layout test to check that the element position used when
+ requesting speech input is relative to the window, not the frame.
+
+ * fast/speech/bubble-position-expected.txt: Added.
+ * fast/speech/bubble-position.html: Added.
+
2012-02-01 Philippe Normand <pnormand@igalia.com>
Unreviewed, GTK rebaseline after r106373 and r106361.
--- /dev/null
+Tests for speech button click with <input type="text" speech>.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Clicking the speech button.
+onSpeechChange()
+PASS input.value === expectedString is true
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
--- /dev/null
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src="../js/resources/js-test-pre.js"></script>
+</head>
+<body>
+<script type="text/javascript">
+description('Tests for speech button click with <input type="text" speech>.');
+
+function onSpeechChange() {
+ debug("onSpeechChange()");
+
+ // Since we requested dumpRect, the rect comes back as the speech result.
+ window.expectedString = expectedX + "," + expectedY + "," + expectedWidth + "," + expectedHeight;
+ shouldBeTrue("input.value === expectedString");
+ finishJSTest();
+}
+
+function run() {
+ window.iframe = document.getElementById('iframe');
+ window.input = iframe.contentDocument.createElement('input');
+ input.setAttribute('x-webkit-speech');
+ input.onwebkitspeechchange = onSpeechChange;
+ iframe.contentDocument.getElementsByTagName('body')[0].appendChild(input);
+
+ window.expectedWidth = input.scrollHeight;
+ window.expectedHeight = input.scrollHeight;
+ window.expectedX = iframe.offsetLeft + input.offsetLeft + input.offsetWidth - expectedWidth;
+ window.expectedY = iframe.offsetTop + input.offsetTop + input.offsetHeight - 1;
+
+ if (window.layoutTestController && window.eventSender) {
+ layoutTestController.setMockSpeechInputDumpRect(true);
+
+ debug('Clicking the speech button.');
+ var x = input.offsetLeft + input.offsetWidth - 4;
+ var y = input.offsetTop + input.offsetHeight / 2;
+ x += iframe.offsetLeft;
+ y += iframe.offsetTop;
+
+ eventSender.mouseMoveTo(x, y);
+ eventSender.mouseDown();
+ eventSender.mouseUp();
+ }
+}
+
+window.onload = run;
+window.jsTestIsAsync = true;
+</script>
+<script src="../js/resources/js-test-post.js"></script>
+<iframe id="iframe">
+</body>
+</html>
+
+2012-01-31 Hans Wennborg <hans@chromium.org>
+
+ Speech Input: Report speech element rect relative to window rather than frame
+ https://bugs.webkit.org/show_bug.cgi?id=76443
+
+ Reviewed by Darin Fisher.
+
+ When requesting speech input, report the speech element rect relative
+ to the window rather than the frame. The embedder will typically use
+ this position to show a bubble indicating that speech recognition is
+ in progress.
+
+ Test: fast/speech/bubble-position.html
+
+ * html/shadow/TextControlInnerElements.cpp:
+ (WebCore::InputFieldSpeechButtonElement::startSpeechInput):
+
2012-01-31 Andreas Kling <awesomekling@apple.com>
Make elements that don't have attributes smaller.
#include "Page.h"
#include "RenderLayer.h"
#include "RenderTextControlSingleLine.h"
+#include "RenderView.h"
#include "ScriptController.h"
#include "ScrollbarTheme.h"
#include "SpeechInput.h"
AtomicString language = input->computeInheritedLanguage();
String grammar = input->getAttribute(webkitgrammarAttr);
// FIXME: this should probably respect transforms
- IntRect rect = renderer()->absoluteBoundingBoxRectIgnoringTransforms();
+ IntRect rect = renderer()->view()->frameView()->contentsToWindow(renderer()->absoluteBoundingBoxRectIgnoringTransforms());
if (speechInput()->startRecognition(m_listenerId, rect, language, grammar, document()->securityOrigin()))
setState(Recording);
}
+2012-01-31 Hans Wennborg <hans@chromium.org>
+
+ Speech Input: Report speech element rect relative to window rather than frame
+ https://bugs.webkit.org/show_bug.cgi?id=76443
+
+ Reviewed by Darin Fisher.
+
+ Update LayoutTestController to allow for retrieving the speech
+ element's position used in a request.
+
+ In Chromium this is handled by the MockWebSpeechInputController;
+ adding stubs for the other implementations.
+
+ * DumpRenderTree/LayoutTestController.cpp:
+ (setMockSpeechInputDumpRectCallback):
+ (LayoutTestController::staticFunctions):
+ * DumpRenderTree/LayoutTestController.h:
+ (LayoutTestController):
+ * DumpRenderTree/chromium/LayoutTestController.cpp:
+ (LayoutTestController::LayoutTestController):
+ (LayoutTestController::setMockSpeechInputDumpRect):
+ * DumpRenderTree/chromium/LayoutTestController.h:
+ (LayoutTestController):
+ * DumpRenderTree/chromium/MockWebSpeechInputController.cpp:
+ (MockWebSpeechInputController::setDumpRect):
+ (MockWebSpeechInputController::clearResults):
+ (MockWebSpeechInputController::startRecognition):
+ (MockWebSpeechInputController::MockWebSpeechInputController):
+ (makeRectResult):
+ (MockWebSpeechInputController::speechTaskFired):
+ * DumpRenderTree/chromium/MockWebSpeechInputController.h:
+ (MockWebSpeechInputController):
+ * DumpRenderTree/efl/LayoutTestControllerEfl.cpp:
+ (LayoutTestController::setMockSpeechInputDumpRect):
+ * DumpRenderTree/gtk/LayoutTestControllerGtk.cpp:
+ (LayoutTestController::setMockSpeechInputDumpRect):
+ * DumpRenderTree/mac/LayoutTestControllerMac.mm:
+ (LayoutTestController::setMockSpeechInputDumpRect):
+ * DumpRenderTree/qt/LayoutTestControllerQt.cpp:
+ (LayoutTestController::setMockSpeechInputDumpRect):
+ * DumpRenderTree/qt/LayoutTestControllerQt.h:
+ (LayoutTestController):
+ * DumpRenderTree/win/LayoutTestControllerWin.cpp:
+ (LayoutTestController::setMockSpeechInputDumpRect):
+ * DumpRenderTree/wx/LayoutTestControllerWx.cpp:
+ (LayoutTestController::setMockSpeechInputDumpRect):
+
2012-01-31 Ryuan Choi <ryuan.choi@samsung.com>
[EFL] Add basic DRT/Efl implementation to support viewport test.
return JSValueMakeUndefined(context);
}
+static JSValueRef setMockSpeechInputDumpRectCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
+{
+ if (argumentCount < 1)
+ return JSValueMakeUndefined(context);
+
+ bool dumpRect = JSValueToBoolean(context, arguments[0]);
+
+ LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
+ controller->setMockSpeechInputDumpRect(dumpRect);
+
+ return JSValueMakeUndefined(context);
+}
+
static JSValueRef setNewWindowsCopyBackForwardListCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
{
// Has mac implementation
{ "setMockGeolocationError", setMockGeolocationErrorCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
{ "setMockGeolocationPosition", setMockGeolocationPositionCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
{ "addMockSpeechInputResult", addMockSpeechInputResultCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
+ { "setMockSpeechInputDumpRect", setMockSpeechInputDumpRectCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
{ "setNewWindowsCopyBackForwardList", setNewWindowsCopyBackForwardListCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
{ "setPageVisibility", setPageVisibilityCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
{ "setPOSIXLocale", setPOSIXLocaleCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
void setMockGeolocationError(int code, JSStringRef message);
void setMockGeolocationPosition(double latitude, double longitude, double accuracy);
void addMockSpeechInputResult(JSStringRef result, double confidence, JSStringRef language);
+ void setMockSpeechInputDumpRect(bool flag);
void setPersistentUserStyleSheetLocation(JSStringRef path);
void setPluginsEnabled(bool flag);
void setPopupBlockingEnabled(bool flag);
// by CppBoundClass, the parent to LayoutTestController).
bindMethod("addFileToPasteboardOnDrag", &LayoutTestController::addFileToPasteboardOnDrag);
bindMethod("addMockSpeechInputResult", &LayoutTestController::addMockSpeechInputResult);
+ bindMethod("setMockSpeechInputDumpRect", &LayoutTestController::setMockSpeechInputDumpRect);
bindMethod("addOriginAccessWhitelistEntry", &LayoutTestController::addOriginAccessWhitelistEntry);
bindMethod("addUserScript", &LayoutTestController::addUserScript);
bindMethod("addUserStyleSheet", &LayoutTestController::addUserStyleSheet);
controller->addMockRecognitionResult(cppVariantToWebString(arguments[0]), arguments[1].toDouble(), cppVariantToWebString(arguments[2]));
}
+void LayoutTestController::setMockSpeechInputDumpRect(const CppArgumentList& arguments, CppVariant* result)
+{
+ result->setNull();
+ if (arguments.size() < 1 || !arguments[0].isBool())
+ return;
+
+ if (MockWebSpeechInputController* controller = m_shell->webViewHost()->speechInputControllerMock())
+ controller->setDumpRect(arguments[0].value.boolValue);
+}
+
void LayoutTestController::startSpeechInput(const CppArgumentList& arguments, CppVariant* result)
{
result->setNull();
// Speech input related functions.
void addMockSpeechInputResult(const CppArgumentList&, CppVariant*);
+ void setMockSpeechInputDumpRect(const CppArgumentList&, CppVariant*);
void startSpeechInput(const CppArgumentList&, CppVariant*);
void layerTreeAsText(const CppArgumentList& args, CppVariant* result);
#include "WebSpeechInputListener.h"
#include "platform/WebCString.h"
+#include "platform/WebVector.h"
#include <wtf/text/CString.h>
+#include <wtf/text/StringBuilder.h>
using namespace WebKit;
}
}
+void MockWebSpeechInputController::setDumpRect(bool dumpRect)
+{
+ m_dumpRect = dumpRect;
+}
+
void MockWebSpeechInputController::clearResults()
{
m_resultsForEmptyLanguage.clear();
m_recognitionResults.clear();
+ m_dumpRect = false;
}
bool MockWebSpeechInputController::startRecognition(int requestId, const WebRect& elementRect, const WebString& language, const WebString& grammar, const WebSecurityOrigin& origin)
return false;
m_requestId = requestId;
+ m_requestRect = elementRect;
m_recording = true;
m_language = String::fromUTF8(language.utf8().data());
, m_speechTask(0)
, m_recording(false)
, m_requestId(-1)
+ , m_dumpRect(false)
{
}
+static WebSpeechInputResultArray makeRectResult(const WebRect& rect)
+{
+ StringBuilder sb;
+ sb.append(String::number(rect.x));
+ sb.append(",");
+ sb.append(String::number(rect.y));
+ sb.append(",");
+ sb.append(String::number(rect.width));
+ sb.append(",");
+ sb.append(String::number(rect.height));
+
+ WebSpeechInputResult res;
+ res.set(WebString(sb.characters(), sb.length()), 1.0);
+
+ WebSpeechInputResultArray results;
+ results.assign(&res, 1);
+ return results;
+}
+
void MockWebSpeechInputController::speechTaskFired()
{
if (m_recording) {
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_dumpRect) {
+ m_listener->setRecognitionResult(requestId, makeRectResult(m_requestRect));
+ } else if (m_language.isEmpty()) {
+ // Empty language case must be handled separately to avoid problems with HashMap and empty keys.
if (!m_resultsForEmptyLanguage.isEmpty())
m_listener->setRecognitionResult(requestId, m_resultsForEmptyLanguage);
else
#if ENABLE(INPUT_SPEECH)
#include "Task.h"
+#include "platform/WebRect.h"
#include "WebSpeechInputController.h"
#include "WebSpeechInputResult.h"
#include <wtf/Compiler.h>
#include <wtf/text/StringHash.h>
namespace WebKit {
-struct WebRect;
class WebSecurityOrigin;
class WebSpeechInputListener;
class WebString;
static PassOwnPtr<MockWebSpeechInputController> create(WebKit::WebSpeechInputListener*);
void addMockRecognitionResult(const WebKit::WebString& result, double confidence, const WebKit::WebString& language);
+ void setDumpRect(bool);
void clearResults();
// WebSpeechInputController implementation:
bool m_recording;
int m_requestId;
+ WebKit::WebRect m_requestRect;
String m_language;
HashMap<String, Vector<WebKit::WebSpeechInputResult> > m_recognitionResults;
Vector<WebKit::WebSpeechInputResult> m_resultsForEmptyLanguage;
+ bool m_dumpRect;
};
#endif // ENABLE(INPUT_SPEECH)
notImplemented();
}
+void LayoutTestController::setMockSpeechInputDumpRect(bool)
+{
+ // FIXME: Implement for speech input layout tests.
+ // See https://bugs.webkit.org/show_bug.cgi?id=39485.
+ notImplemented();
+}
+
void LayoutTestController::startSpeechInput(JSContextRef inputElement)
{
// FIXME: Implement for speech input layout tests.
// See https://bugs.webkit.org/show_bug.cgi?id=39485.
}
+void LayoutTestController::setMockSpeechInputDumpRect(bool flag)
+{
+ // FIXME: Implement for speech input layout tests.
+ // See https://bugs.webkit.org/show_bug.cgi?id=39485.
+}
+
void LayoutTestController::startSpeechInput(JSContextRef inputElement)
{
// FIXME: Implement for speech input layout tests.
// See https://bugs.webkit.org/show_bug.cgi?id=39485.
}
+void LayoutTestController::setMockSpeechInputDumpRect(bool flag)
+{
+ // FIXME: Implement for speech input layout tests.
+ // See https://bugs.webkit.org/show_bug.cgi?id=39485.
+}
+
void LayoutTestController::startSpeechInput(JSContextRef inputElement)
{
// FIXME: Implement for speech input layout tests.
// See https://bugs.webkit.org/show_bug.cgi?id=39485.
}
+void LayoutTestController::setMockSpeechInputDumpRect(bool flag)
+{
+ // FIXME: Implement for speech input layout tests.
+ // See https://bugs.webkit.org/show_bug.cgi?id=39485.
+}
+
void LayoutTestController::startSpeechInput(const QString& inputElement)
{
// FIXME: Implement for speech input layout tests.
bool geolocationPermission() const { return m_geolocationPermission; }
void addMockSpeechInputResult(const QString& result, double confidence, const QString& language);
+ void setMockSpeechInputDumpRect(bool flag);
void startSpeechInput(const QString& inputElement);
// Empty stub method to keep parity with object model exposed by global LayoutTestController.
// See https://bugs.webkit.org/show_bug.cgi?id=39485.
}
+void LayoutTestController::setMockSpeechInputDumpRect(bool flag)
+{
+ // FIXME: Implement for speech input layout tests.
+ // See https://bugs.webkit.org/show_bug.cgi?id=39485.
+}
+
void LayoutTestController::startSpeechInput(JSContextRef inputElement)
{
// FIXME: Implement for speech input layout tests.
// See https://bugs.webkit.org/show_bug.cgi?id=39485.
}
+void LayoutTestController::setMockSpeechInputDumpRect(bool flag)
+{
+ // FIXME: Implement for speech input layout tests.
+ // See https://bugs.webkit.org/show_bug.cgi?id=39485.
+}
+
void LayoutTestController::startSpeechInput(JSContextRef inputElement)
{
// FIXME: Implement for speech input layout tests.