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

Side by Side 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights 2 * Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights
3 * reserved. 3 * reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 21 matching lines...) Expand all
32 #include "bindings/core/v8/ScriptController.h" 32 #include "bindings/core/v8/ScriptController.h"
33 #include "bindings/core/v8/ScriptEventListener.h" 33 #include "bindings/core/v8/ScriptEventListener.h"
34 #include "bindings/core/v8/ScriptPromiseResolver.h" 34 #include "bindings/core/v8/ScriptPromiseResolver.h"
35 #include "core/HTMLNames.h" 35 #include "core/HTMLNames.h"
36 #include "core/css/MediaList.h" 36 #include "core/css/MediaList.h"
37 #include "core/dom/Attribute.h" 37 #include "core/dom/Attribute.h"
38 #include "core/dom/DOMException.h" 38 #include "core/dom/DOMException.h"
39 #include "core/dom/ElementTraversal.h" 39 #include "core/dom/ElementTraversal.h"
40 #include "core/dom/ElementVisibilityObserver.h" 40 #include "core/dom/ElementVisibilityObserver.h"
41 #include "core/dom/Fullscreen.h" 41 #include "core/dom/Fullscreen.h"
42 #include "core/dom/IntersectionGeometry.h"
42 #include "core/dom/TaskRunnerHelper.h" 43 #include "core/dom/TaskRunnerHelper.h"
43 #include "core/dom/shadow/ShadowRoot.h" 44 #include "core/dom/shadow/ShadowRoot.h"
44 #include "core/events/Event.h" 45 #include "core/events/Event.h"
45 #include "core/frame/FrameView.h" 46 #include "core/frame/FrameView.h"
46 #include "core/frame/LocalFrame.h" 47 #include "core/frame/LocalFrame.h"
47 #include "core/frame/Settings.h" 48 #include "core/frame/Settings.h"
48 #include "core/frame/UseCounter.h" 49 #include "core/frame/UseCounter.h"
49 #include "core/frame/csp/ContentSecurityPolicy.h" 50 #include "core/frame/csp/ContentSecurityPolicy.h"
50 #include "core/html/AutoplayUmaHelper.h" 51 #include "core/html/AutoplayUmaHelper.h"
51 #include "core/html/HTMLMediaSource.h" 52 #include "core/html/HTMLMediaSource.h"
(...skipping 2467 matching lines...) Expand 10 before | Expand all | Expand 10 after
2519 if (!m_seeking) 2520 if (!m_seeking)
2520 scheduleTimeupdateEvent(true); 2521 scheduleTimeupdateEvent(true);
2521 2522
2522 if (!playbackRate()) 2523 if (!playbackRate())
2523 return; 2524 return;
2524 2525
2525 if (!m_paused && mediaControls()) 2526 if (!m_paused && mediaControls())
2526 mediaControls()->playbackProgressed(); 2527 mediaControls()->playbackProgressed();
2527 2528
2528 cueTimeline().updateActiveCues(currentTime()); 2529 cueTimeline().updateActiveCues(currentTime());
2530
2531 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.
2532 // Check whether the intersection with viewport has changed.
2533 ExecutionContext* context = getExecutionContext();
2534 DCHECK(context->isDocument());
2535 Document& document = toDocument(*context);
2536 IntersectionGeometry geometry(&document, this, Vector<Length>(), true);
2537 geometry.computeGeometry();
2538 WebRect intersectRect =
2539 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
2540 geometry.intersectionRect().y().rawValue(),
2541 geometry.intersectionRect().width().rawValue(),
2542 geometry.intersectionRect().height().rawValue());
2543 if (m_currentViewportIntersection.intersectRect != intersectRect) {
2544 m_currentViewportIntersection.intersectRect = intersectRect;
2545 m_currentViewportIntersection.rootRect =
2546 WebRect(geometry.rootRect().x().rawValue(),
2547 geometry.rootRect().y().rawValue(),
2548 geometry.rootRect().width().rawValue(),
2549 geometry.rootRect().height().rawValue());
2550 m_webMediaPlayer->videoViewportIntersectionChanged(
2551 m_currentViewportIntersection);
2552 }
2553 }
2529 } 2554 }
2530 2555
2531 void HTMLMediaElement::scheduleTimeupdateEvent(bool periodicEvent) { 2556 void HTMLMediaElement::scheduleTimeupdateEvent(bool periodicEvent) {
2532 // Per spec, consult current playback position to check for changing time. 2557 // Per spec, consult current playback position to check for changing time.
2533 double mediaTime = currentPlaybackPosition(); 2558 double mediaTime = currentPlaybackPosition();
2534 double now = WTF::currentTime(); 2559 double now = WTF::currentTime();
2535 2560
2536 bool haveNotRecentlyFiredTimeupdate = 2561 bool haveNotRecentlyFiredTimeupdate =
2537 (now - m_lastTimeUpdateEventWallTime) >= maxTimeupdateEventFrequency; 2562 (now - m_lastTimeUpdateEventWallTime) >= maxTimeupdateEventFrequency;
2538 bool mediaTimeHasProgressed = mediaTime != m_lastTimeUpdateEventMediaTime; 2563 bool mediaTimeHasProgressed = mediaTime != m_lastTimeUpdateEventMediaTime;
(...skipping 1648 matching lines...) Expand 10 before | Expand all | Expand 10 after
4187 4212
4188 IntRect HTMLMediaElement::AutoplayHelperClientImpl::absoluteBoundingBoxRect() 4213 IntRect HTMLMediaElement::AutoplayHelperClientImpl::absoluteBoundingBoxRect()
4189 const { 4214 const {
4190 IntRect result; 4215 IntRect result;
4191 if (LayoutObject* object = m_element->layoutObject()) 4216 if (LayoutObject* object = m_element->layoutObject())
4192 result = object->absoluteBoundingBoxRect(); 4217 result = object->absoluteBoundingBoxRect();
4193 return result; 4218 return result;
4194 } 4219 }
4195 4220
4196 } // namespace blink 4221 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698