| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #include "modules/speech/DOMWindowSpeechSynthesis.h" | 31 #include "modules/speech/DOMWindowSpeechSynthesis.h" |
| 32 | 32 |
| 33 #include "bindings/core/v8/ScriptState.h" |
| 33 #include "core/frame/LocalDOMWindow.h" | 34 #include "core/frame/LocalDOMWindow.h" |
| 34 #include "core/frame/LocalFrame.h" | 35 #include "core/frame/LocalFrame.h" |
| 35 #include "wtf/PassRefPtr.h" | 36 #include "wtf/PassRefPtr.h" |
| 36 | 37 |
| 37 namespace blink { | 38 namespace blink { |
| 38 | 39 |
| 39 DOMWindowSpeechSynthesis::DOMWindowSpeechSynthesis(LocalDOMWindow& window) | 40 DOMWindowSpeechSynthesis::DOMWindowSpeechSynthesis(LocalDOMWindow& window) |
| 40 : ContextClient(window.frame()) {} | 41 : Supplement<LocalDOMWindow>(window) {} |
| 41 | 42 |
| 42 const char* DOMWindowSpeechSynthesis::supplementName() { | 43 const char* DOMWindowSpeechSynthesis::supplementName() { |
| 43 return "DOMWindowSpeechSynthesis"; | 44 return "DOMWindowSpeechSynthesis"; |
| 44 } | 45 } |
| 45 | 46 |
| 46 // static | 47 // static |
| 47 DOMWindowSpeechSynthesis& DOMWindowSpeechSynthesis::from( | 48 DOMWindowSpeechSynthesis& DOMWindowSpeechSynthesis::from( |
| 48 LocalDOMWindow& window) { | 49 LocalDOMWindow& window) { |
| 49 DOMWindowSpeechSynthesis* supplement = static_cast<DOMWindowSpeechSynthesis*>( | 50 DOMWindowSpeechSynthesis* supplement = static_cast<DOMWindowSpeechSynthesis*>( |
| 50 Supplement<LocalDOMWindow>::from(window, supplementName())); | 51 Supplement<LocalDOMWindow>::from(window, supplementName())); |
| 51 if (!supplement) { | 52 if (!supplement) { |
| 52 supplement = new DOMWindowSpeechSynthesis(window); | 53 supplement = new DOMWindowSpeechSynthesis(window); |
| 53 provideTo(window, supplementName(), supplement); | 54 provideTo(window, supplementName(), supplement); |
| 54 } | 55 } |
| 55 return *supplement; | 56 return *supplement; |
| 56 } | 57 } |
| 57 | 58 |
| 58 // static | 59 // static |
| 59 SpeechSynthesis* DOMWindowSpeechSynthesis::speechSynthesis(DOMWindow& window) { | 60 SpeechSynthesis* DOMWindowSpeechSynthesis::speechSynthesis( |
| 61 ScriptState* scriptState, |
| 62 DOMWindow& window) { |
| 60 return DOMWindowSpeechSynthesis::from(toLocalDOMWindow(window)) | 63 return DOMWindowSpeechSynthesis::from(toLocalDOMWindow(window)) |
| 61 .speechSynthesis(); | 64 .speechSynthesis(scriptState); |
| 62 } | 65 } |
| 63 | 66 |
| 64 SpeechSynthesis* DOMWindowSpeechSynthesis::speechSynthesis() { | 67 SpeechSynthesis* DOMWindowSpeechSynthesis::speechSynthesis( |
| 65 if (!m_speechSynthesis && frame()) | 68 ScriptState* scriptState) { |
| 69 if (!m_speechSynthesis) { |
| 66 m_speechSynthesis = | 70 m_speechSynthesis = |
| 67 SpeechSynthesis::create(frame()->domWindow()->getExecutionContext()); | 71 SpeechSynthesis::create(scriptState->getExecutionContext()); |
| 72 } |
| 68 return m_speechSynthesis; | 73 return m_speechSynthesis; |
| 69 } | 74 } |
| 70 | 75 |
| 71 DEFINE_TRACE(DOMWindowSpeechSynthesis) { | 76 DEFINE_TRACE(DOMWindowSpeechSynthesis) { |
| 72 visitor->trace(m_speechSynthesis); | 77 visitor->trace(m_speechSynthesis); |
| 73 Supplement<LocalDOMWindow>::trace(visitor); | 78 Supplement<LocalDOMWindow>::trace(visitor); |
| 74 ContextClient::trace(visitor); | |
| 75 } | 79 } |
| 76 | 80 |
| 77 } // namespace blink | 81 } // namespace blink |
| OLD | NEW |