Commit 7e483a01 authored by haraken's avatar haraken Committed by Commit bot

Remove ContextClient from DOMWindowSpeechSynthesis

If we pass in ScriptState to DOMWindowSpeechSynthesis::speechSynthesis,
DOMWindowSpeechSynthesis doesn't need to observe ContextClient.

BUG=610176

Review-Url: https://codereview.chromium.org/2618613006
Cr-Commit-Position: refs/heads/master@{#441918}
parent dabb937b
...@@ -186,6 +186,10 @@ PASS childWindow.screenY is 0 ...@@ -186,6 +186,10 @@ PASS childWindow.screenY is 0
PASS childWindow.scrollX is 0 PASS childWindow.scrollX is 0
PASS childWindow.scrollY is 0 PASS childWindow.scrollY is 0
PASS childWindow.scrollbars.visible is false PASS childWindow.scrollbars.visible is false
PASS childWindow.speechSynthesis.onvoiceschanged is null
PASS childWindow.speechSynthesis.paused is false
PASS childWindow.speechSynthesis.pending is false
PASS childWindow.speechSynthesis.speaking is false
PASS childWindow.status is '' PASS childWindow.status is ''
PASS childWindow.statusbar.visible is false PASS childWindow.statusbar.visible is false
PASS childWindow.styleMedia.type is '' PASS childWindow.styleMedia.type is ''
......
...@@ -186,6 +186,10 @@ PASS childWindow.screenY is 0 ...@@ -186,6 +186,10 @@ PASS childWindow.screenY is 0
PASS childWindow.scrollX is 0 PASS childWindow.scrollX is 0
PASS childWindow.scrollY is 0 PASS childWindow.scrollY is 0
PASS childWindow.scrollbars.visible is false PASS childWindow.scrollbars.visible is false
PASS childWindow.speechSynthesis.onvoiceschanged is null
PASS childWindow.speechSynthesis.paused is false
PASS childWindow.speechSynthesis.pending is false
PASS childWindow.speechSynthesis.speaking is false
PASS childWindow.status is '' PASS childWindow.status is ''
PASS childWindow.statusbar.visible is false PASS childWindow.statusbar.visible is false
PASS childWindow.styleMedia.type is '' PASS childWindow.styleMedia.type is ''
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
testRunner.waitUntilDone(); testRunner.waitUntilDone();
if (window.internals) if (window.internals)
window.internals.enableMockSpeechSynthesizer(document); window.internals.enableMockSpeechSynthesizer(window);
window.jsTestIsAsync = true; window.jsTestIsAsync = true;
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
description("This tests that cancelling an utterance a second time after garbage collection doesn't crash under ASAN."); description("This tests that cancelling an utterance a second time after garbage collection doesn't crash under ASAN.");
if (window.internals) if (window.internals)
window.internals.enableMockSpeechSynthesizer(document); window.internals.enableMockSpeechSynthesizer(window);
speechSynthesis.speak(new SpeechSynthesisUtterance("Hello")); speechSynthesis.speak(new SpeechSynthesisUtterance("Hello"));
speechSynthesis.cancel(); speechSynthesis.cancel();
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
testRunner.waitUntilDone(); testRunner.waitUntilDone();
if (window.internals) if (window.internals)
window.internals.enableMockSpeechSynthesizer(document); window.internals.enableMockSpeechSynthesizer(window);
window.jsTestIsAsync = true; window.jsTestIsAsync = true;
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
<script> <script>
if (window.internals) if (window.internals)
window.internals.enableMockSpeechSynthesizer(document); window.internals.enableMockSpeechSynthesizer(window);
description("This tests that there isn't a crash if the utterance object is garbage-collected before speaking finishes."); description("This tests that there isn't a crash if the utterance object is garbage-collected before speaking finishes.");
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
description("This tests that the mock speech synthesizer is well behaved when attempting to pause/resume without first speaking."); description("This tests that the mock speech synthesizer is well behaved when attempting to pause/resume without first speaking.");
if (window.internals) if (window.internals)
window.internals.enableMockSpeechSynthesizer(document); window.internals.enableMockSpeechSynthesizer(window);
shouldBeUndefined("speechSynthesis.pause()"); shouldBeUndefined("speechSynthesis.pause()");
shouldBeUndefined("speechSynthesis.resume()"); shouldBeUndefined("speechSynthesis.resume()");
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
if (window.testRunner) if (window.testRunner)
testRunner.waitUntilDone(); testRunner.waitUntilDone();
if (window.internals) if (window.internals)
window.internals.enableMockSpeechSynthesizer(document); window.internals.enableMockSpeechSynthesizer(window);
window.jsTestIsAsync = true; window.jsTestIsAsync = true;
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
<script> <script>
if (window.internals) if (window.internals)
window.internals.enableMockSpeechSynthesizer(document); window.internals.enableMockSpeechSynthesizer(window);
description("This tests that passing an argument other than a SpeechSynthesisUtterance to speechSynthesis.speak throws a TypeError exception."); description("This tests that passing an argument other than a SpeechSynthesisUtterance to speechSynthesis.speak throws a TypeError exception.");
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
description("This tests that multiple speak utterances are handled in sequence."); description("This tests that multiple speak utterances are handled in sequence.");
if (window.internals) if (window.internals)
window.internals.enableMockSpeechSynthesizer(document); window.internals.enableMockSpeechSynthesizer(window);
if (window.testRunner) if (window.testRunner)
testRunner.waitUntilDone(); testRunner.waitUntilDone();
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
<script> <script>
if (window.internals) if (window.internals)
window.internals.enableMockSpeechSynthesizer(document); window.internals.enableMockSpeechSynthesizer(window);
description("This tests that the basic mechanisms of speaking text work, including sending the job and receving the callback."); description("This tests that the basic mechanisms of speaking text work, including sending the job and receving the callback.");
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
<script> <script>
setup(function() { setup(function() {
if (window.internals) if (window.internals)
window.internals.enableMockSpeechSynthesizer(document); window.internals.enableMockSpeechSynthesizer(window);
}); });
test(function() { test(function() {
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
description("This tests that we can get synthesizer voices on the Mac"); description("This tests that we can get synthesizer voices on the Mac");
if (window.internals) if (window.internals)
window.internals.enableMockSpeechSynthesizer(document); window.internals.enableMockSpeechSynthesizer(window);
if (window.testRunner) if (window.testRunner)
testRunner.waitUntilDone(); testRunner.waitUntilDone();
......
...@@ -25,7 +25,7 @@ test(() => { ...@@ -25,7 +25,7 @@ test(() => {
}, 'setting to non-SpeechSynthesisVoice values'); }, 'setting to non-SpeechSynthesisVoice values');
test(() => { test(() => {
internals.enableMockSpeechSynthesizer(document); internals.enableMockSpeechSynthesizer(window);
const u = new SpeechSynthesisUtterance(); const u = new SpeechSynthesisUtterance();
const voice = speechSynthesis.getVoices()[0]; const voice = speechSynthesis.getVoices()[0];
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
debug('Initially, there are ' + list.length + ' voices.'); debug('Initially, there are ' + list.length + ' voices.');
if (window.internals) if (window.internals)
window.internals.enableMockSpeechSynthesizer(document); window.internals.enableMockSpeechSynthesizer(window);
list = speechSynthesis.getVoices(); list = speechSynthesis.getVoices();
debug('Now there are ' + list.length + ' voices.'); debug('Now there are ' + list.length + ' voices.');
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
<script> <script>
if (window.internals) if (window.internals)
window.internals.enableMockSpeechSynthesizer(document); window.internals.enableMockSpeechSynthesizer(window);
description("This tests that we can get synthesizer voices on the Mac"); description("This tests that we can get synthesizer voices on the Mac");
......
...@@ -972,7 +972,7 @@ struct NativeValueTraits<Vector<T>> { ...@@ -972,7 +972,7 @@ struct NativeValueTraits<Vector<T>> {
CORE_EXPORT v8::Isolate* toIsolate(ExecutionContext*); CORE_EXPORT v8::Isolate* toIsolate(ExecutionContext*);
CORE_EXPORT v8::Isolate* toIsolate(LocalFrame*); CORE_EXPORT v8::Isolate* toIsolate(LocalFrame*);
DOMWindow* toDOMWindow(v8::Isolate*, v8::Local<v8::Value>); CORE_EXPORT DOMWindow* toDOMWindow(v8::Isolate*, v8::Local<v8::Value>);
DOMWindow* toDOMWindow(v8::Local<v8::Context>); DOMWindow* toDOMWindow(v8::Local<v8::Context>);
LocalDOMWindow* enteredDOMWindow(v8::Isolate*); LocalDOMWindow* enteredDOMWindow(v8::Isolate*);
CORE_EXPORT LocalDOMWindow* currentDOMWindow(v8::Isolate*); CORE_EXPORT LocalDOMWindow* currentDOMWindow(v8::Isolate*);
......
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
#include "modules/speech/DOMWindowSpeechSynthesis.h" #include "modules/speech/DOMWindowSpeechSynthesis.h"
#include "bindings/core/v8/ScriptState.h"
#include "core/frame/LocalDOMWindow.h" #include "core/frame/LocalDOMWindow.h"
#include "core/frame/LocalFrame.h" #include "core/frame/LocalFrame.h"
#include "wtf/PassRefPtr.h" #include "wtf/PassRefPtr.h"
...@@ -37,7 +38,7 @@ ...@@ -37,7 +38,7 @@
namespace blink { namespace blink {
DOMWindowSpeechSynthesis::DOMWindowSpeechSynthesis(LocalDOMWindow& window) DOMWindowSpeechSynthesis::DOMWindowSpeechSynthesis(LocalDOMWindow& window)
: ContextClient(window.frame()) {} : Supplement<LocalDOMWindow>(window) {}
const char* DOMWindowSpeechSynthesis::supplementName() { const char* DOMWindowSpeechSynthesis::supplementName() {
return "DOMWindowSpeechSynthesis"; return "DOMWindowSpeechSynthesis";
...@@ -56,22 +57,25 @@ DOMWindowSpeechSynthesis& DOMWindowSpeechSynthesis::from( ...@@ -56,22 +57,25 @@ DOMWindowSpeechSynthesis& DOMWindowSpeechSynthesis::from(
} }
// static // static
SpeechSynthesis* DOMWindowSpeechSynthesis::speechSynthesis(DOMWindow& window) { SpeechSynthesis* DOMWindowSpeechSynthesis::speechSynthesis(
ScriptState* scriptState,
DOMWindow& window) {
return DOMWindowSpeechSynthesis::from(toLocalDOMWindow(window)) return DOMWindowSpeechSynthesis::from(toLocalDOMWindow(window))
.speechSynthesis(); .speechSynthesis(scriptState);
} }
SpeechSynthesis* DOMWindowSpeechSynthesis::speechSynthesis() { SpeechSynthesis* DOMWindowSpeechSynthesis::speechSynthesis(
if (!m_speechSynthesis && frame()) ScriptState* scriptState) {
if (!m_speechSynthesis) {
m_speechSynthesis = m_speechSynthesis =
SpeechSynthesis::create(frame()->domWindow()->getExecutionContext()); SpeechSynthesis::create(scriptState->getExecutionContext());
}
return m_speechSynthesis; return m_speechSynthesis;
} }
DEFINE_TRACE(DOMWindowSpeechSynthesis) { DEFINE_TRACE(DOMWindowSpeechSynthesis) {
visitor->trace(m_speechSynthesis); visitor->trace(m_speechSynthesis);
Supplement<LocalDOMWindow>::trace(visitor); Supplement<LocalDOMWindow>::trace(visitor);
ContextClient::trace(visitor);
} }
} // namespace blink } // namespace blink
...@@ -26,7 +26,6 @@ ...@@ -26,7 +26,6 @@
#ifndef DOMWindowSpeechSynthesis_h #ifndef DOMWindowSpeechSynthesis_h
#define DOMWindowSpeechSynthesis_h #define DOMWindowSpeechSynthesis_h
#include "core/dom/ContextLifecycleObserver.h"
#include "core/frame/LocalDOMWindow.h" #include "core/frame/LocalDOMWindow.h"
#include "modules/ModulesExport.h" #include "modules/ModulesExport.h"
#include "modules/speech/SpeechSynthesis.h" #include "modules/speech/SpeechSynthesis.h"
...@@ -35,16 +34,15 @@ ...@@ -35,16 +34,15 @@
namespace blink { namespace blink {
class DOMWindow; class ScriptState;
class MODULES_EXPORT DOMWindowSpeechSynthesis final class MODULES_EXPORT DOMWindowSpeechSynthesis final
: public GarbageCollected<DOMWindowSpeechSynthesis>, : public GarbageCollected<DOMWindowSpeechSynthesis>,
public Supplement<LocalDOMWindow>, public Supplement<LocalDOMWindow> {
public ContextClient {
USING_GARBAGE_COLLECTED_MIXIN(DOMWindowSpeechSynthesis); USING_GARBAGE_COLLECTED_MIXIN(DOMWindowSpeechSynthesis);
public: public:
static SpeechSynthesis* speechSynthesis(DOMWindow&); static SpeechSynthesis* speechSynthesis(ScriptState*, DOMWindow&);
static DOMWindowSpeechSynthesis& from(LocalDOMWindow&); static DOMWindowSpeechSynthesis& from(LocalDOMWindow&);
DECLARE_TRACE(); DECLARE_TRACE();
...@@ -52,7 +50,7 @@ class MODULES_EXPORT DOMWindowSpeechSynthesis final ...@@ -52,7 +50,7 @@ class MODULES_EXPORT DOMWindowSpeechSynthesis final
private: private:
explicit DOMWindowSpeechSynthesis(LocalDOMWindow&); explicit DOMWindowSpeechSynthesis(LocalDOMWindow&);
SpeechSynthesis* speechSynthesis(); SpeechSynthesis* speechSynthesis(ScriptState*);
static const char* supplementName(); static const char* supplementName();
Member<SpeechSynthesis> m_speechSynthesis; Member<SpeechSynthesis> m_speechSynthesis;
......
...@@ -27,5 +27,5 @@ ...@@ -27,5 +27,5 @@
ImplementedAs=DOMWindowSpeechSynthesis, ImplementedAs=DOMWindowSpeechSynthesis,
RuntimeEnabled=ScriptedSpeech, RuntimeEnabled=ScriptedSpeech,
] partial interface Window { ] partial interface Window {
[Measure] readonly attribute SpeechSynthesis speechSynthesis; [Measure, CallWith=ScriptState] readonly attribute SpeechSynthesis speechSynthesis;
}; };
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
#include "InternalsSpeechSynthesis.h" #include "InternalsSpeechSynthesis.h"
#include "core/dom/Document.h" #include "core/dom/Document.h"
#include "core/frame/LocalDOMWindow.h" #include "core/frame/DOMWindow.h"
#include "core/testing/Internals.h" #include "core/testing/Internals.h"
#include "modules/speech/DOMWindowSpeechSynthesis.h" #include "modules/speech/DOMWindowSpeechSynthesis.h"
#include "modules/speech/SpeechSynthesis.h" #include "modules/speech/SpeechSynthesis.h"
...@@ -39,12 +39,12 @@ ...@@ -39,12 +39,12 @@
namespace blink { namespace blink {
void InternalsSpeechSynthesis::enableMockSpeechSynthesizer(Internals&, void InternalsSpeechSynthesis::enableMockSpeechSynthesizer(
Document* document) { ScriptState* scriptState,
ASSERT(document && document->domWindow()); Internals&,
DOMWindow* window) {
SpeechSynthesis* synthesis = SpeechSynthesis* synthesis =
DOMWindowSpeechSynthesis::speechSynthesis(*document->domWindow()); DOMWindowSpeechSynthesis::speechSynthesis(scriptState, *window);
if (!synthesis) if (!synthesis)
return; return;
......
...@@ -35,14 +35,15 @@ ...@@ -35,14 +35,15 @@
namespace blink { namespace blink {
class Document; class DOMWindow;
class Internals; class Internals;
class ScriptState;
class InternalsSpeechSynthesis { class InternalsSpeechSynthesis {
STATIC_ONLY(InternalsSpeechSynthesis); STATIC_ONLY(InternalsSpeechSynthesis);
public: public:
static void enableMockSpeechSynthesizer(Internals&, Document*); static void enableMockSpeechSynthesizer(ScriptState*, Internals&, DOMWindow*);
}; };
} // namespace blink } // namespace blink
......
...@@ -29,5 +29,5 @@ ...@@ -29,5 +29,5 @@
*/ */
partial interface Internals { partial interface Internals {
void enableMockSpeechSynthesizer(Document document); [CallWith=ScriptState] void enableMockSpeechSynthesizer(Window window);
}; };
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