Chromium Code Reviews| Index: third_party/WebKit/Source/modules/compositorworker/WindowAnimationWorklet.cpp |
| diff --git a/third_party/WebKit/Source/modules/compositorworker/WindowAnimationWorklet.cpp b/third_party/WebKit/Source/modules/compositorworker/WindowAnimationWorklet.cpp |
| index 366d3a678f7c2f7b426fd56476a58596dd442741..e3dba9e76d124d4ba99c356dae781682ce9d3e5c 100644 |
| --- a/third_party/WebKit/Source/modules/compositorworker/WindowAnimationWorklet.cpp |
| +++ b/third_party/WebKit/Source/modules/compositorworker/WindowAnimationWorklet.cpp |
| @@ -7,47 +7,20 @@ |
| #include "core/dom/Document.h" |
| #include "core/frame/LocalDOMWindow.h" |
| #include "core/frame/LocalFrame.h" |
| -#include "modules/compositorworker/AnimationWorklet.h" |
| namespace blink { |
| -WindowAnimationWorklet::WindowAnimationWorklet(LocalDOMWindow& window) |
| - : ContextLifecycleObserver(window.frame()->document()) {} |
| - |
| -const char* WindowAnimationWorklet::supplementName() { |
| - return "WindowAnimationWorklet"; |
| -} |
| - |
| // static |
| -WindowAnimationWorklet& WindowAnimationWorklet::from(LocalDOMWindow& window) { |
| - WindowAnimationWorklet* supplement = static_cast<WindowAnimationWorklet*>( |
| - Supplement<LocalDOMWindow>::from(window, supplementName())); |
| - if (!supplement) { |
| - supplement = new WindowAnimationWorklet(window); |
| - provideTo(window, supplementName(), supplement); |
| - } |
| - return *supplement; |
| -} |
| - |
| -// static |
| -Worklet* WindowAnimationWorklet::animationWorklet(DOMWindow& window) { |
| - if (!window.frame()) |
| - return nullptr; |
| - return from(toLocalDOMWindow(window)) |
| - .animationWorklet(toLocalDOMWindow(window)); |
| -} |
| - |
| AnimationWorklet* WindowAnimationWorklet::animationWorklet( |
| LocalDOMWindow& window) { |
| - if (!m_animationWorklet && getExecutionContext()) { |
| - DCHECK(window.frame()); |
| - m_animationWorklet = AnimationWorklet::create(window.frame()); |
|
dcheng
2017/02/01 07:22:59
This helper got moved into the constructor: there'
|
| - } |
| - return m_animationWorklet.get(); |
| + if (!window.frame()) |
| + return nullptr; |
| + return from(window).m_animationWorklet.get(); |
| } |
| // Break the following cycle when the context gets detached. |
| // Otherwise, the worklet object will leak. |
| +// TODO(dcheng): Why isn't this just all on the Oilpan heap? |
|
dcheng
2017/02/01 07:22:59
Something that might be good to fix... not really
haraken
2017/02/01 08:32:01
I'm not sure how easy it will be to move ThreadedW
dcheng
2017/02/01 18:30:28
OK, removed the TODO. It feels like it's harder th
|
| // |
| // window => window.animationWorklet |
| // => WindowAnimationWorklet |
| @@ -65,4 +38,23 @@ DEFINE_TRACE(WindowAnimationWorklet) { |
| ContextLifecycleObserver::trace(visitor); |
| } |
| +// static |
| +WindowAnimationWorklet& WindowAnimationWorklet::from(LocalDOMWindow& window) { |
| + WindowAnimationWorklet* supplement = static_cast<WindowAnimationWorklet*>( |
| + Supplement<LocalDOMWindow>::from(window, supplementName())); |
| + if (!supplement) { |
| + supplement = new WindowAnimationWorklet(window); |
| + provideTo(window, supplementName(), supplement); |
| + } |
| + return *supplement; |
| +} |
| + |
| +WindowAnimationWorklet::WindowAnimationWorklet(LocalDOMWindow& window) |
| + : ContextLifecycleObserver(window.frame()->document()), |
| + m_animationWorklet(AnimationWorklet::create(window.frame())) {} |
| + |
| +const char* WindowAnimationWorklet::supplementName() { |
| + return "WindowAnimationWorklet"; |
| +} |
| + |
| } // namespace blink |