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

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

Issue 2511143006: Detect change on the intersection of video and viewport. (Closed)
Patch Set: 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..b531897046e449d0076ad5a31481b00d028e3af0 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"
@@ -2526,6 +2527,30 @@ void HTMLMediaElement::playbackProgressTimerFired(TimerBase*) {
mediaControls()->playbackProgressed();
cueTimeline().updateActiveCues(currentTime());
+
+ if (m_webMediaPlayer) {
miu 2016/11/21 21:07:03 There's an early return from this method about 6-8
xjz 2016/11/21 23:58:42 Done. Moved this to the very top of the method.
+ // 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 =
+ WebRect(geometry.intersectionRect().x().rawValue(),
miu 2016/11/21 21:07:04 This translation between rectangle data types is a
xjz 2016/11/21 23:58:42 Done. Add accessor methods in IntersectionGeometry
+ geometry.intersectionRect().y().rawValue(),
+ geometry.intersectionRect().width().rawValue(),
+ geometry.intersectionRect().height().rawValue());
+ if (m_currentViewportIntersection.intersectRect != intersectRect) {
+ m_currentViewportIntersection.intersectRect = intersectRect;
+ m_currentViewportIntersection.rootRect =
+ WebRect(geometry.rootRect().x().rawValue(),
+ geometry.rootRect().y().rawValue(),
+ geometry.rootRect().width().rawValue(),
+ geometry.rootRect().height().rawValue());
+ m_webMediaPlayer->videoViewportIntersectionChanged(
+ m_currentViewportIntersection);
+ }
+ }
}
void HTMLMediaElement::scheduleTimeupdateEvent(bool periodicEvent) {

Powered by Google App Engine
This is Rietveld 408576698