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

Unified Diff: third_party/WebKit/Source/core/html/HTMLMediaElement.cpp

Issue 2511143006: Detect change on the intersection of video and viewport. (Closed)
Patch Set: Addressed miu's comments. Created 4 years, 1 month 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/html/HTMLMediaElement.cpp
diff --git a/third_party/WebKit/Source/core/html/HTMLMediaElement.cpp b/third_party/WebKit/Source/core/html/HTMLMediaElement.cpp
index a1f0ce6a74d593703d34135af4a59c9ecdc1652e..311186621cbf67ab19ced64c7c79d253418a6940 100644
--- a/third_party/WebKit/Source/core/html/HTMLMediaElement.cpp
+++ b/third_party/WebKit/Source/core/html/HTMLMediaElement.cpp
@@ -39,6 +39,7 @@
#include "core/dom/ElementTraversal.h"
#include "core/dom/ElementVisibilityObserver.h"
#include "core/dom/Fullscreen.h"
+#include "core/dom/IntersectionGeometry.h"
#include "core/dom/TaskRunnerHelper.h"
#include "core/dom/shadow/ShadowRoot.h"
#include "core/events/Event.h"
@@ -2504,6 +2505,22 @@ void HTMLMediaElement::startPlaybackProgressTimer() {
}
void HTMLMediaElement::playbackProgressTimerFired(TimerBase*) {
+ if (m_webMediaPlayer) {
+ // Check whether the intersection with viewport has changed.
+ ExecutionContext* context = getExecutionContext();
+ DCHECK(context->isDocument());
+ Document& document = toDocument(*context);
+ IntersectionGeometry geometry(&document, this, Vector<Length>(), true);
+ geometry.computeGeometry();
+ WebRect intersectRect = geometry.intersectionIntRect();
+ if (m_currentViewportIntersection.intersectRect != intersectRect) {
+ m_currentViewportIntersection.intersectRect = intersectRect;
+ m_currentViewportIntersection.rootRect = geometry.rootIntRect();
+ m_webMediaPlayer->viewportIntersectionChanged(
+ m_currentViewportIntersection);
+ }
+ }
+
if (!std::isnan(m_fragmentEndTime) && currentTime() >= m_fragmentEndTime &&
getDirectionOfPlayback() == Forward) {
m_fragmentEndTime = std::numeric_limits<double>::quiet_NaN();

Powered by Google App Engine
This is Rietveld 408576698