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

Unified Diff: third_party/WebKit/Source/core/dom/ElementVisibilityObserver.h

Issue 2051253002: Start autoplay muted videos with autoplay attribute when they are visible. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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/core/dom/ElementVisibilityObserver.h
diff --git a/third_party/WebKit/Source/core/dom/ElementVisibilityObserver.h b/third_party/WebKit/Source/core/dom/ElementVisibilityObserver.h
new file mode 100644
index 0000000000000000000000000000000000000000..37607c62392ebc6b457c7c1399ab46b0b84e06b3
--- /dev/null
+++ b/third_party/WebKit/Source/core/dom/ElementVisibilityObserver.h
@@ -0,0 +1,40 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef ElementVisibilityObserver_h
+#define ElementVisibilityObserver_h
+
+#include "core/dom/IntersectionObserver.h"
+#include "platform/heap/Heap.h"
+#include "platform/heap/Member.h"
+
+namespace blink {
+
+class Element;
+
+class ElementVisibilityObserver final : public GarbageCollectedFinalized<ElementVisibilityObserver>{
+ WTF_MAKE_NONCOPYABLE(ElementVisibilityObserver);
+public:
+ using VisibilityCallback = Function<void(bool), WTF::SameThreadAffinity>;
+
+ ElementVisibilityObserver(Element*, std::unique_ptr<VisibilityCallback> callback);
+ virtual ~ElementVisibilityObserver();
+
+ void start();
+ void stop();
+
+ DECLARE_VIRTUAL_TRACE();
+
+private:
+ class ElementVisibilityCallback;
+
+ Member<Element> m_element;
+ std::unique_ptr<VisibilityCallback> m_callback;
+ Member<IntersectionObserver> m_intersectionObserver;
+ Member<ElementVisibilityCallback> m_intersectionObserverCallback;
+};
+
+} // namespace blink
+
+#endif // ElementVisibilityObserver_h

Powered by Google App Engine
This is Rietveld 408576698