Source/WebCore: Add API functions to enable starting and stopping speech input,
[WebKit-https.git] / Source / WebKit / chromium / src / WebInputElement.cpp
index 8a21ed9..49fe19e 100644 (file)
@@ -33,6 +33,9 @@
 
 #include "HTMLInputElement.h"
 #include "HTMLNames.h"
+#include "RenderObject.h"
+#include "RenderTextControlSingleLine.h"
+#include "TextControlInnerElements.h"
 #include "WebString.h"
 #include <wtf/PassRefPtr.h>
 
@@ -62,7 +65,7 @@ bool WebInputElement::isImageButton() const
 
 bool WebInputElement::autoComplete() const
 {
-    return constUnwrap<HTMLInputElement>()->autoComplete();
+    return constUnwrap<HTMLInputElement>()->shouldAutocomplete();
 }
 
 int WebInputElement::maxLength() const
@@ -120,9 +123,9 @@ bool WebInputElement::isAutofilled() const
     return constUnwrap<HTMLInputElement>()->isAutofilled();
 }
 
-void WebInputElement::setAutofilled(bool autoFilled)
+void WebInputElement::setAutofilled(bool autofilled)
 {
-    unwrap<HTMLInputElement>()->setAutofilled(autoFilled);
+    unwrap<HTMLInputElement>()->setAutofilled(autofilled);
 }
 
 void WebInputElement::setSelectionRange(int start, int end)
@@ -150,6 +153,59 @@ bool WebInputElement::isChecked() const
     return constUnwrap<HTMLInputElement>()->checked();
 }
 
+bool WebInputElement::isSpeechInputEnabled() const
+{
+#if ENABLE(INPUT_SPEECH)
+    return constUnwrap<HTMLInputElement>()->isSpeechEnabled();
+#else
+    return false;
+#endif
+}
+
+WebInputElement::SpeechInputState WebInputElement::getSpeechInputState() const
+{
+#if ENABLE(INPUT_SPEECH)
+    RenderObject* renderer = constUnwrap<HTMLInputElement>()->renderer();
+    if (!renderer)
+        return Idle;
+
+    RenderTextControlSingleLine* control = toRenderTextControlSingleLine(renderer);
+    InputFieldSpeechButtonElement* speechButton = toInputFieldSpeechButtonElement(control->speechButtonElement());
+    if (speechButton)
+        return static_cast<WebInputElement::SpeechInputState>(speechButton->state());
+#endif
+
+    return Idle;
+}
+
+void WebInputElement::startSpeechInput()
+{
+#if ENABLE(INPUT_SPEECH)
+    RenderObject* renderer = constUnwrap<HTMLInputElement>()->renderer();
+    if (!renderer)
+        return;
+
+    RenderTextControlSingleLine* control = toRenderTextControlSingleLine(renderer);
+    InputFieldSpeechButtonElement* speechButton = toInputFieldSpeechButtonElement(control->speechButtonElement());
+    if (speechButton)
+        speechButton->startSpeechInput();
+#endif
+}
+
+void WebInputElement::stopSpeechInput()
+{
+#if ENABLE(INPUT_SPEECH)
+    RenderObject* renderer = constUnwrap<HTMLInputElement>()->renderer();
+    if (!renderer)
+        return;
+
+    RenderTextControlSingleLine* control = toRenderTextControlSingleLine(renderer);
+    InputFieldSpeechButtonElement* speechButton = toInputFieldSpeechButtonElement(control->speechButtonElement());
+    if (speechButton)
+        speechButton->stopSpeechInput();
+#endif
+}
+
 int WebInputElement::defaultMaxLength()
 {
     return HTMLInputElement::maximumLength;