Move testRunner.startSpeechInput/setValueForUser to internals

Now TestRunner is being moved from CppBoundClass to gin::Wrappable,
where it is not appropriate to use WebElements directly. This CL moves
some functions which treats WebElement* from testRunner to internals.
(To be exact, this CL only copies some functions, but I'll remove those ones
in testRunner later.)

BUG=331301

Committed: https://src.chromium.org/viewvc/blink?view=rev&revision=168495

Review URL: https://codereview.chromium.org/176953009

git-svn-id: svn://svn.chromium.org/blink/trunk@168588 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent e6b710c7
...@@ -15,8 +15,8 @@ ...@@ -15,8 +15,8 @@
} }
tf.focus(); tf.focus();
if (window.testRunner) { if (window.internals) {
testRunner.setValueForUser(tf, 'Hello!'); internals.setValueForUser(tf, 'Hello!');
} }
// Should not fire the event until focus is lost. // Should not fire the event until focus is lost.
......
...@@ -14,7 +14,7 @@ function startSpeechInput(id) { ...@@ -14,7 +14,7 @@ function startSpeechInput(id) {
// will be set in input during the generated TextInput event. // will be set in input during the generated TextInput event.
var input = document.getElementById(id); var input = document.getElementById(id);
input.select(); input.select();
testRunner.startSpeechInput(input); internals.startSpeechInput(input);
} }
function onWebkitSpeechChange() { function onWebkitSpeechChange() {
......
...@@ -89,6 +89,8 @@ ...@@ -89,6 +89,8 @@
#include "core/html/HTMLSelectElement.h" #include "core/html/HTMLSelectElement.h"
#include "core/html/HTMLTextAreaElement.h" #include "core/html/HTMLTextAreaElement.h"
#include "core/html/forms/FormController.h" #include "core/html/forms/FormController.h"
#include "core/html/shadow/ShadowElementNames.h"
#include "core/html/shadow/TextControlInnerElements.h"
#include "core/inspector/InspectorClient.h" #include "core/inspector/InspectorClient.h"
#include "core/inspector/InspectorConsoleAgent.h" #include "core/inspector/InspectorConsoleAgent.h"
#include "core/inspector/InspectorController.h" #include "core/inspector/InspectorController.h"
...@@ -2387,4 +2389,22 @@ void Internals::trace(Visitor* visitor) ...@@ -2387,4 +2389,22 @@ void Internals::trace(Visitor* visitor)
visitor->trace(m_profilers); visitor->trace(m_profilers);
} }
void Internals::startSpeechInput(Element* element)
{
#if ENABLE(INPUT_SPEECH)
HTMLInputElement* input = toHTMLInputElement(element);
if (!input->isSpeechEnabled())
return;
InputFieldSpeechButtonElement* speechButton = toInputFieldSpeechButtonElement(input->userAgentShadowRoot()->getElementById(ShadowElementNames::speechButton()));
if (speechButton)
speechButton->startSpeechInput();
#endif
}
void Internals::setValueForUser(Element* element, const String& value)
{
toHTMLInputElement(element)->setValueForUser(value);
}
} }
...@@ -314,6 +314,9 @@ public: ...@@ -314,6 +314,9 @@ public:
void trace(Visitor*); void trace(Visitor*);
void startSpeechInput(Element*);
void setValueForUser(Element*, const String&);
private: private:
explicit Internals(Document*); explicit Internals(Document*);
Document* contextDocument() const; Document* contextDocument() const;
......
...@@ -279,4 +279,7 @@ ...@@ -279,4 +279,7 @@
[RaisesException] void setShouldRevealPassword(Element element, boolean reveal); [RaisesException] void setShouldRevealPassword(Element element, boolean reveal);
[CallWith=ExecutionContext] Promise addOneToPromise(Promise promise); [CallWith=ExecutionContext] Promise addOneToPromise(Promise promise);
void startSpeechInput(Element element);
void setValueForUser(Element element, DOMString value);
}; };
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment