Changeset 200778 in webkit
- Timestamp:
- May 12, 2016, 10:53:38 AM (10 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 5 edited
-
LayoutTests/ChangeLog (modified) (1 diff)
-
LayoutTests/media/video-main-content-allow.html (modified) (1 diff)
-
LayoutTests/media/video-main-content-autoplay-expected.txt (added)
-
LayoutTests/media/video-main-content-autoplay.html (added)
-
LayoutTests/media/video-main-content-deny-too-small.html (modified) (2 diffs)
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/html/MediaElementSession.cpp (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r200769 r200778 1 2016-05-12 Eric Carlson <eric.carlson@apple.com> 2 3 Adjust "main content" video heuristic 4 https://bugs.webkit.org/show_bug.cgi?id=157532 5 6 Reviewed by Darin Adler. 7 8 * media/video-main-content-allow.html: 9 * media/video-main-content-autoplay-expected.txt: Added. 10 * media/video-main-content-autoplay.html: Added. 11 * media/video-main-content-deny-too-small.html: 12 1 13 2016-05-12 Antoine Quint <graouts@apple.com> 2 14 -
trunk/LayoutTests/media/video-main-content-allow.html
r197953 r200778 23 23 <style> 24 24 video { 25 width: 600px;26 height: 4 00px;25 width: 270px; 26 height: 480px; 27 27 } 28 28 </style> -
trunk/LayoutTests/media/video-main-content-deny-too-small.html
r197953 r200778 8 8 function go() { 9 9 video = document.createElement('video'); 10 video.controls = "" 10 11 run('internals.setMediaElementRestrictions(video, "RequireUserGestureForVideoRateChange,OverrideUserGestureRequirementForMainContent")'); 11 12 document.body.appendChild(video); … … 28 29 <style> 29 30 video { 30 width: 200px;31 height: 100px;31 width: 400px; 32 height: 299px; 32 33 } 33 34 </style> -
trunk/Source/WebCore/ChangeLog
r200776 r200778 1 2016-05-12 Eric Carlson <eric.carlson@apple.com> 2 3 Adjust "main content" video heuristic 4 https://bugs.webkit.org/show_bug.cgi?id=157532 5 <rdar://problem/25840861> 6 7 Reviewed by Darin Adler. 8 9 Test: media/video-main-content-autoplay.html, plus existing tests updated. 10 11 * html/MediaElementSession.cpp: 12 (WebCore::MediaElementSession::canControlControlsManager): Use isElementLargeEnoughForMainContent. 13 (WebCore::isMainContent): Ditto. 14 (WebCore::isElementLargeEnoughForMainContent): Check video area and aspect ratio. 15 (WebCore::MediaElementSession::mainContentCheckTimerFired): Call result.setToNonUserAgentShadowAncestor 16 so it doesn't hit test the video controls in the shadow DOM. 17 1 18 2016-05-12 Fujii Hironori <Hironori.Fujii@sony.com> 2 19 -
trunk/Source/WebCore/html/MediaElementSession.cpp
r200688 r200778 55 55 namespace WebCore { 56 56 57 static const int elementMainContentMinimumWidth = 400;58 static const int elementMainContentMinimumHeight = 300;59 57 static const double elementMainContentCheckInterval = .250; 60 58 61 59 static bool isMainContent(const HTMLMediaElement&); 60 static bool isElementLargeEnoughForMainContent(const HTMLMediaElement&); 62 61 63 62 #if !LOG_DISABLED … … 225 224 return false; 226 225 227 if ( element.hasVideo() && renderer->clientWidth() >= elementMainContentMinimumWidth && renderer->clientHeight() >= elementMainContentMinimumHeight)228 return true;226 if (isElementLargeEnoughForMainContent(element)) 227 return true; 229 228 230 229 if (ScriptController::processingUserGestureForMedia()) … … 507 506 return false; 508 507 509 if (renderer->clientWidth() < elementMainContentMinimumWidth 510 || renderer->clientHeight() < elementMainContentMinimumHeight) 508 if (!isElementLargeEnoughForMainContent(element)) 511 509 return false; 512 510 … … 540 538 // Elements which are obscured by other elements cannot be main content. 541 539 mainRenderView.hitTest(request, result); 540 result.setToNonUserAgentShadowAncestor(); 542 541 Element* hitElement = result.innerElement(); 543 542 if (hitElement != &element) … … 547 546 } 548 547 548 static bool isElementLargeEnoughForMainContent(const HTMLMediaElement& element) 549 { 550 static const double elementMainContentAreaMinimum = 400 * 300; 551 static const double maximumAspectRatio = 1.8; // Slightly larger than 16:9. 552 static const double minimumAspectRatio = .5; // Slightly smaller than 16:9. 553 554 // Elements which have not yet been laid out, or which are not yet in the DOM, cannot be main content. 555 RenderBox* renderer = downcast<RenderBox>(element.renderer()); 556 if (!renderer) 557 return false; 558 559 double width = renderer->clientWidth(); 560 double height = renderer->clientHeight(); 561 double area = width * height; 562 double aspectRatio = width / height; 563 return area >= elementMainContentAreaMinimum && aspectRatio >= minimumAspectRatio && aspectRatio <= maximumAspectRatio; 564 } 565 549 566 void MediaElementSession::mainContentCheckTimerFired() 550 567 {
Note:
See TracChangeset
for help on using the changeset viewer.