| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "modules/csspaint/WindowPaintWorklet.h" | |
| 6 | |
| 7 #include "core/frame/LocalDOMWindow.h" | |
| 8 #include "core/frame/LocalFrame.h" | |
| 9 #include "modules/csspaint/PaintWorklet.h" | |
| 10 | |
| 11 namespace blink { | |
| 12 | |
| 13 WindowPaintWorklet::WindowPaintWorklet(LocalDOMWindow& window) | |
| 14 : Supplement<LocalDOMWindow>(window) {} | |
| 15 | |
| 16 const char* WindowPaintWorklet::SupplementName() { | |
| 17 return "WindowPaintWorklet"; | |
| 18 } | |
| 19 | |
| 20 // static | |
| 21 WindowPaintWorklet& WindowPaintWorklet::From(LocalDOMWindow& window) { | |
| 22 WindowPaintWorklet* supplement = static_cast<WindowPaintWorklet*>( | |
| 23 Supplement<LocalDOMWindow>::From(window, SupplementName())); | |
| 24 if (!supplement) { | |
| 25 supplement = new WindowPaintWorklet(window); | |
| 26 ProvideTo(window, SupplementName(), supplement); | |
| 27 } | |
| 28 return *supplement; | |
| 29 } | |
| 30 | |
| 31 // static | |
| 32 Worklet* WindowPaintWorklet::paintWorklet(LocalDOMWindow& window) { | |
| 33 return From(window).paintWorklet(); | |
| 34 } | |
| 35 | |
| 36 PaintWorklet* WindowPaintWorklet::paintWorklet() { | |
| 37 if (!paint_worklet_ && GetSupplementable()->GetFrame()) | |
| 38 paint_worklet_ = PaintWorklet::Create(GetSupplementable()->GetFrame()); | |
| 39 return paint_worklet_.Get(); | |
| 40 } | |
| 41 | |
| 42 DEFINE_TRACE(WindowPaintWorklet) { | |
| 43 visitor->Trace(paint_worklet_); | |
| 44 Supplement<LocalDOMWindow>::Trace(visitor); | |
| 45 } | |
| 46 | |
| 47 } // namespace blink | |
| OLD | NEW |