| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "modules/csspaint/WindowPaintWorklet.h" | 5 #include "modules/csspaint/WindowPaintWorklet.h" |
| 6 | 6 |
| 7 #include "core/frame/LocalDOMWindow.h" | 7 #include "core/frame/LocalDOMWindow.h" |
| 8 #include "core/frame/LocalFrame.h" | 8 #include "core/frame/LocalFrame.h" |
| 9 #include "modules/csspaint/PaintWorklet.h" | 9 #include "modules/csspaint/PaintWorklet.h" |
| 10 | 10 |
| 11 namespace blink { | 11 namespace blink { |
| 12 | 12 |
| 13 WindowPaintWorklet::WindowPaintWorklet(LocalDOMWindow& window) | 13 WindowPaintWorklet::WindowPaintWorklet(LocalDOMWindow& window) |
| 14 : DOMWindowProperty(window.frame()) {} | 14 : Supplement<LocalDOMWindow>(window) {} |
| 15 | 15 |
| 16 const char* WindowPaintWorklet::supplementName() { | 16 const char* WindowPaintWorklet::supplementName() { |
| 17 return "WindowPaintWorklet"; | 17 return "WindowPaintWorklet"; |
| 18 } | 18 } |
| 19 | 19 |
| 20 // static | 20 // static |
| 21 WindowPaintWorklet& WindowPaintWorklet::from(LocalDOMWindow& window) { | 21 WindowPaintWorklet& WindowPaintWorklet::from(LocalDOMWindow& window) { |
| 22 WindowPaintWorklet* supplement = static_cast<WindowPaintWorklet*>( | 22 WindowPaintWorklet* supplement = static_cast<WindowPaintWorklet*>( |
| 23 Supplement<LocalDOMWindow>::from(window, supplementName())); | 23 Supplement<LocalDOMWindow>::from(window, supplementName())); |
| 24 if (!supplement) { | 24 if (!supplement) { |
| 25 supplement = new WindowPaintWorklet(window); | 25 supplement = new WindowPaintWorklet(window); |
| 26 provideTo(window, supplementName(), supplement); | 26 provideTo(window, supplementName(), supplement); |
| 27 } | 27 } |
| 28 return *supplement; | 28 return *supplement; |
| 29 } | 29 } |
| 30 | 30 |
| 31 // static | 31 // static |
| 32 Worklet* WindowPaintWorklet::paintWorklet(DOMWindow& window) { | 32 Worklet* WindowPaintWorklet::paintWorklet(DOMWindow& window) { |
| 33 return from(toLocalDOMWindow(window)).paintWorklet(); | 33 return from(toLocalDOMWindow(window)).paintWorklet(); |
| 34 } | 34 } |
| 35 | 35 |
| 36 PaintWorklet* WindowPaintWorklet::paintWorklet() { | 36 PaintWorklet* WindowPaintWorklet::paintWorklet() { |
| 37 if (!m_paintWorklet && frame()) | 37 if (!m_paintWorklet && host()->frame()) |
| 38 m_paintWorklet = PaintWorklet::create(frame()); | 38 m_paintWorklet = PaintWorklet::create(host()->frame()); |
| 39 return m_paintWorklet.get(); | 39 return m_paintWorklet.get(); |
| 40 } | 40 } |
| 41 | 41 |
| 42 DEFINE_TRACE(WindowPaintWorklet) { | 42 DEFINE_TRACE(WindowPaintWorklet) { |
| 43 visitor->trace(m_paintWorklet); | 43 visitor->trace(m_paintWorklet); |
| 44 Supplement<LocalDOMWindow>::trace(visitor); | 44 Supplement<LocalDOMWindow>::trace(visitor); |
| 45 DOMWindowProperty::trace(visitor); | |
| 46 } | 45 } |
| 47 | 46 |
| 48 } // namespace blink | 47 } // namespace blink |
| OLD | NEW |