Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
[iOS] Media controls are too cramped with small video
https://bugs.webkit.org/show_bug.cgi?id=158815 <rdar://problem/26824238> Patch by Antoine Quint <graouts@apple.com> on 2016-06-27 Reviewed by Dean Jackson. Source/WebCore: In updateLayoutForDisplayedWidth(), we try to ensure a minimum width is guaranteed for the progress indicator. However, we were not accounting for the width used by the current and remaining time labels on either side of it, so we would incorrectly conclude that we were guaranteeing the minimum time and yield incorrect layouts since we were trying to fit more buttons than we had room for. In order to correctly compute the available width for the progress indicator, we now have clones of the current and remaining time labels, hidden from video and VoiceOver, that we update along with the originals. The same styles apply to both clones and originals, so we may measure the clones to determine the space used by the time labels. The reason we need to use clones is that if the time labels had previously been hidden from view, precisely because there was not enough space to display them along with the progress indicator, then trying to obtain metrics from them would yield 0 since they had "display: none" styles applied. In order to avoid extra layouts and possible flashing, we use the clones so that we never have to toggle the "display" property of the originals just to obtain their measurements. As a result of this change, we adjust the constant used to set the minimum required width available to display the progress indicator after all other essential controls and labels have been measured. That constant used to account for the width of the time labels, and this is no longer correct. Test: media/video-controls-drop-and-restore-timeline.html * Modules/mediacontrols/mediaControlsApple.css: (::-webkit-media-controls-time-remaining-display.clone): * Modules/mediacontrols/mediaControlsApple.js: (Controller): (Controller.prototype.createTimeClones): (Controller.prototype.removeTimeClass): (Controller.prototype.addTimeClass): (Controller.prototype.updateDuration): (Controller.prototype.updateLayoutForDisplayedWidth): (Controller.prototype.updateTime): (Controller.prototype.updateControlsWhileScrubbing): * Modules/mediacontrols/mediaControlsiOS.css: (::-webkit-media-controls-time-remaining-display.clone): * Modules/mediacontrols/mediaControlsiOS.js: LayoutTests: Adjust the output of this test to account for the time label clones and add a new test. * media/video-controls-drop-and-restore-timeline-expected.txt: Added. * media/video-controls-drop-and-restore-timeline.html: Added. * platform/mac-yosemite/http/tests/media/hls/video-controls-live-stream-expected.txt: * platform/mac/http/tests/media/hls/video-controls-live-stream-expected.txt: Canonical link: https://commits.webkit.org/177256@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@202505 268f45cc-cd09-0410-ab3c-d52691b4dbfc
- Loading branch information
Showing
with
205 additions
and 29 deletions.
- +15 −0 LayoutTests/ChangeLog
- +15 −0 LayoutTests/media/video-controls-drop-and-restore-timeline-expected.txt
- +56 −0 LayoutTests/media/video-controls-drop-and-restore-timeline.html
- +2 −0 LayoutTests/platform/mac-yosemite/http/tests/media/hls/video-controls-live-stream-expected.txt
- +2 −0 LayoutTests/platform/mac/http/tests/media/hls/video-controls-live-stream-expected.txt
- +47 −0 Source/WebCore/ChangeLog
- +9 −0 Source/WebCore/Modules/mediacontrols/mediaControlsApple.css
- +50 −28 Source/WebCore/Modules/mediacontrols/mediaControlsApple.js
- +8 −0 Source/WebCore/Modules/mediacontrols/mediaControlsiOS.css
- +1 −1 Source/WebCore/Modules/mediacontrols/mediaControlsiOS.js
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1,15 @@ | ||
|
||
Tests that the scrubber is dropped when a video is too narrow and restored when made wider. | ||
|
||
EXPECTED (video.controls != 'null') OK | ||
EVENT(canplaythrough) | ||
EXPECTED (shadowRoot = internals.shadowRoot(video) != 'null') OK | ||
EXPECTED (timelineContainer = mediaControlsElement(shadowRoot.firstChild, '-webkit-media-controls-timeline-container') != 'null') OK | ||
Initital test at width = 200px | ||
EXPECTED (timelineChildrenAreDropped() == 'true') OK | ||
EXPECTED (timelineChildrenAreNotDisplayed() == 'true') OK | ||
Second test at width = 500px | ||
EXPECTED (timelineChildrenAreDropped() == 'false') OK | ||
EXPECTED (timelineChildrenAreNotDisplayed() == 'false') OK | ||
END OF TEST | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1,56 @@ | ||
<html> | ||
<head> | ||
<title>Tests that the scrubber is dropped when a video is too narrow and restored when made wider</title> | ||
<script src="media-file.js"></script> | ||
<script src="media-controls.js"></script> | ||
</head> | ||
<body> | ||
<video controls style="width: 200px"></video> | ||
<p>Tests that the scrubber is dropped when a video is too narrow and restored when made wider.</p> | ||
<script src="video-test.js"></script> | ||
<script> | ||
|
||
var timelineContainer; | ||
|
||
function timelineChildrenAreDropped() { | ||
return Array.prototype.every.call(timelineContainer.children, function(child) { | ||
return child.classList.contains('dropped'); | ||
}); | ||
} | ||
|
||
function timelineChildrenAreNotDisplayed() { | ||
return Array.prototype.every.call(timelineContainer.children, function(child) { | ||
return child.ownerDocument.defaultView.getComputedStyle(child).display === "none"; | ||
}); | ||
} | ||
|
||
testExpected("video.controls", null, '!='); | ||
|
||
waitForEvent("canplaythrough", function() { | ||
if (!window.internals) { | ||
logResult(false, "window.internals == undefined"); | ||
endTest(); | ||
return; | ||
} | ||
|
||
testExpected("shadowRoot = internals.shadowRoot(video)", null, "!="); | ||
testExpected("timelineContainer = mediaControlsElement(shadowRoot.firstChild, '-webkit-media-controls-timeline-container')", null, "!="); | ||
|
||
consoleWrite("Initital test at width = 200px"); | ||
testExpected("timelineChildrenAreDropped()", true, "=="); | ||
testExpected("timelineChildrenAreNotDisplayed()", true, "=="); | ||
|
||
video.style.width = "500px"; | ||
window.requestAnimationFrame(function() { | ||
consoleWrite("Second test at width = 500px"); | ||
testExpected("timelineChildrenAreDropped()", false, "=="); | ||
testExpected("timelineChildrenAreNotDisplayed()", false, "=="); | ||
endTest(); | ||
}); | ||
}); | ||
|
||
video.src = findMediaFile("video", "content/test"); | ||
|
||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -27,7 +27,7 @@ ControllerIOS.StartPlaybackControls = 2; | ||
|
||
ControllerIOS.prototype = { | ||
/* Constants */ | ||
MinimumTimelineWidth: 150, | ||
ButtonWidth: 42, | ||
|
||
get idiom() | ||