Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(668)

Unified Diff: third_party/WebKit/Source/modules/compositorworker/WindowAnimationWorklet.cpp

Issue 2668753006: Special-case LocalDOMWindow for same-origin access in bindings. (Closed)
Patch Set: Rebase and address comments. Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..70af55d7a1d7ce8381a7797605323ec11efcbfaa 100644
--- a/third_party/WebKit/Source/modules/compositorworker/WindowAnimationWorklet.cpp
+++ b/third_party/WebKit/Source/modules/compositorworker/WindowAnimationWorklet.cpp
@@ -7,43 +7,15 @@
#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());
- }
- return m_animationWorklet.get();
+ if (!window.frame())
+ return nullptr;
+ return from(window).m_animationWorklet.get();
}
// Break the following cycle when the context gets detached.
@@ -65,4 +37,25 @@ 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())) {
+ DCHECK(getExecutionContext());
+}
+
+const char* WindowAnimationWorklet::supplementName() {
+ return "WindowAnimationWorklet";
+}
+
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698