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