[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc
commit-queue at webkit.org
commit-queue at webkit.org
Wed Dec 22 11:10:38 UTC 2010
The following commit has been merged in the debian/experimental branch:
commit d1b4e1d0ddea08b4271d5fa908067a1678188108
Author: commit-queue at webkit.org <commit-queue at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Wed Jul 14 13:57:48 2010 +0000
2010-07-14 Satish Sampath <satish at chromium.org>
Reviewed by Kent Tamura.
Invoke speech recognition when user clicks on the speech button of input elements.
http://bugs.webkit.org/show_bug.cgi?id=42047
No new tests, the relevant LayoutTestController bindings will be added in a subsequent patch.
* rendering/TextControlInnerElements.cpp:
(WebCore::InputFieldSpeechButtonElement::InputFieldSpeechButtonElement):
(WebCore::InputFieldSpeechButtonElement::defaultEventHandler): Added click handling.
(WebCore::InputFieldSpeechButtonElement::speechInput):
(WebCore::InputFieldSpeechButtonElement::recordingComplete): Callback to indicate recording progress.
(WebCore::InputFieldSpeechButtonElement::setRecognitionResult): Callback to receive recognized text.
(WebCore::InputFieldSpeechButtonElement::detach):
* rendering/TextControlInnerElements.h:
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@63315 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 6428f90..1acfacd 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,21 @@
+2010-07-14 Satish Sampath <satish at chromium.org>
+
+ Reviewed by Kent Tamura.
+
+ Invoke speech recognition when user clicks on the speech button of input elements.
+ http://bugs.webkit.org/show_bug.cgi?id=42047
+
+ No new tests, the relevant LayoutTestController bindings will be added in a subsequent patch.
+
+ * rendering/TextControlInnerElements.cpp:
+ (WebCore::InputFieldSpeechButtonElement::InputFieldSpeechButtonElement):
+ (WebCore::InputFieldSpeechButtonElement::defaultEventHandler): Added click handling.
+ (WebCore::InputFieldSpeechButtonElement::speechInput):
+ (WebCore::InputFieldSpeechButtonElement::recordingComplete): Callback to indicate recording progress.
+ (WebCore::InputFieldSpeechButtonElement::setRecognitionResult): Callback to receive recognized text.
+ (WebCore::InputFieldSpeechButtonElement::detach):
+ * rendering/TextControlInnerElements.h:
+
2010-07-14 Sheriff Bot <webkit.review.bot at gmail.com>
Unreviewed, rolling out r63305.
diff --git a/WebCore/rendering/TextControlInnerElements.cpp b/WebCore/rendering/TextControlInnerElements.cpp
index 1e86e4d..9bbf491 100644
--- a/WebCore/rendering/TextControlInnerElements.cpp
+++ b/WebCore/rendering/TextControlInnerElements.cpp
@@ -36,8 +36,10 @@
#include "HTMLNames.h"
#include "HTMLTextAreaElement.h"
#include "MouseEvent.h"
+#include "Page.h"
#include "RenderLayer.h"
#include "RenderTextControlSingleLine.h"
+#include "SpeechInput.h"
namespace WebCore {
@@ -328,6 +330,7 @@ void SpinButtonElement::defaultEventHandler(Event* event)
inline InputFieldSpeechButtonElement::InputFieldSpeechButtonElement(Document* document)
: TextControlInnerElement(document)
+ , m_capturing(false)
{
}
@@ -338,8 +341,73 @@ PassRefPtr<InputFieldSpeechButtonElement> InputFieldSpeechButtonElement::create(
void InputFieldSpeechButtonElement::defaultEventHandler(Event* event)
{
- // FIXME: Start speech recognition here.
- HTMLDivElement::defaultEventHandler(event);
+ // On mouse down, select the text and set focus.
+ HTMLInputElement* input = static_cast<HTMLInputElement*>(shadowAncestorNode());
+ if (event->type() == eventNames().mousedownEvent && event->isMouseEvent() && static_cast<MouseEvent*>(event)->button() == LeftButton) {
+ if (renderer() && renderer()->visibleToHitTesting()) {
+ if (Frame* frame = document()->frame()) {
+ frame->eventHandler()->setCapturingMouseEventsNode(this);
+ m_capturing = true;
+ }
+ }
+ // The call to focus() below dispatches a focus event, and an event handler in the page might
+ // remove the input element from DOM. To make sure it remains valid until we finish our work
+ // here, we take a temporary reference.
+ RefPtr<HTMLInputElement> holdRef(input);
+ input->focus();
+ input->select();
+ event->setDefaultHandled();
+ }
+ // On mouse up, start speech recognition.
+ if (event->type() == eventNames().mouseupEvent && event->isMouseEvent() && static_cast<MouseEvent*>(event)->button() == LeftButton) {
+ if (m_capturing && renderer() && renderer()->visibleToHitTesting()) {
+ if (Frame* frame = document()->frame()) {
+ frame->eventHandler()->setCapturingMouseEventsNode(0);
+ m_capturing = false;
+ }
+ if (hovered()) {
+ speechInput()->startRecognition();
+ event->setDefaultHandled();
+ }
+ }
+ }
+
+ if (!event->defaultHandled())
+ HTMLDivElement::defaultEventHandler(event);
+}
+
+SpeechInput* InputFieldSpeechButtonElement::speechInput()
+{
+ if (!m_speechInput)
+ m_speechInput.set(new SpeechInput(document()->page()->speechInputClient(), this));
+ return m_speechInput.get();
+}
+
+void InputFieldSpeechButtonElement::recordingComplete()
+{
+ // FIXME: Add UI feedback here to indicate that audio recording stopped and recognition is
+ // in progress.
+}
+
+void InputFieldSpeechButtonElement::setRecognitionResult(const String& result)
+{
+ HTMLInputElement* input = static_cast<HTMLInputElement*>(shadowAncestorNode());
+ // The call to setValue() below dispatches an event, and an event handler in the page might
+ // remove the input element from DOM. To make sure it remains valid until we finish our work
+ // here, we take a temporary reference.
+ RefPtr<HTMLInputElement> holdRef(input);
+ input->setValue(result);
+ input->dispatchFormControlChangeEvent();
+ renderer()->repaint();
+}
+
+void InputFieldSpeechButtonElement::detach()
+{
+ if (m_capturing) {
+ if (Frame* frame = document()->frame())
+ frame->eventHandler()->setCapturingMouseEventsNode(0);
+ }
+ TextControlInnerElement::detach();
}
#endif // ENABLE(INPUT_SPEECH)
diff --git a/WebCore/rendering/TextControlInnerElements.h b/WebCore/rendering/TextControlInnerElements.h
index fc609e5..b8380bd 100644
--- a/WebCore/rendering/TextControlInnerElements.h
+++ b/WebCore/rendering/TextControlInnerElements.h
@@ -28,9 +28,11 @@
#define TextControlInnerElements_h
#include "HTMLDivElement.h"
+#include "SpeechInputListener.h"
namespace WebCore {
+class SpeechInput;
class String;
class TextControlInnerElement : public HTMLDivElement {
@@ -109,14 +111,25 @@ private:
#if ENABLE(INPUT_SPEECH)
-class InputFieldSpeechButtonElement : public TextControlInnerElement {
+class InputFieldSpeechButtonElement
+ : public TextControlInnerElement,
+ public SpeechInputListener {
public:
static PassRefPtr<InputFieldSpeechButtonElement> create(Document*);
virtual void defaultEventHandler(Event*);
+ // SpeechInputListener methods.
+ void recordingComplete();
+ void setRecognitionResult(const String& result);
+
private:
InputFieldSpeechButtonElement(Document*);
+ virtual void detach();
+ SpeechInput* speechInput();
+
+ bool m_capturing;
+ OwnPtr<SpeechInput> m_speechInput;
};
#endif // ENABLE(INPUT_SPEECH)
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list