From 3ea8b4e33977740420fa9850a37983319a5807d7 Mon Sep 17 00:00:00 2001 From: Ray Lin Date: Mon, 6 Feb 2017 10:22:37 +0800 Subject: [PATCH] Bug 1328060 - re-adjust controls when get metadata of video duration. r=jaws MozReview-Commit-ID: AKY5Umg08P6 --HG-- extra : rebase_source : c853f769839e5b02a21902eda32b59f79433fa58 --- .../tests/widgets/test_videocontrols.html | 2 +- toolkit/content/widgets/videocontrols.xml | 53 ++++++++++++++----- toolkit/themes/shared/media/videocontrols.css | 7 +-- 3 files changed, 42 insertions(+), 20 deletions(-) diff --git a/toolkit/content/tests/widgets/test_videocontrols.html b/toolkit/content/tests/widgets/test_videocontrols.html index 587f077e88f6..c737ccb4ed83 100644 --- a/toolkit/content/tests/widgets/test_videocontrols.html +++ b/toolkit/content/tests/widgets/test_videocontrols.html @@ -30,7 +30,7 @@ const playButtonWidth = 30; const playButtonHeight = 40; const muteButtonWidth = 30; const muteButtonHeight = 40; -const positionAndDurationWidth = 85; +const positionAndDurationWidth = 75; const fullscreenButtonWidth = 30; const fullscreenButtonHeight = 40; const volumeSliderWidth = 48; diff --git a/toolkit/content/widgets/videocontrols.xml b/toolkit/content/widgets/videocontrols.xml index 400d353e2dca..cdbbfd52e39e 100644 --- a/toolkit/content/widgets/videocontrols.xml +++ b/toolkit/content/widgets/videocontrols.xml @@ -59,7 +59,7 @@ switch (which) { case "curpos": // Update the time shown in the thumb. - this.positionValue = this.Utils.formatTime(newValue); + this.positionValue = this.Utils.formatTime(newValue, this.Utils.showHours); this.Utils.positionLabel.setAttribute("value", this.positionValue); // Update the value bar to match the thumb position. let percent = newValue / this.max; @@ -223,6 +223,7 @@ "error", "suspend", "stalled", "mozinterruptbegin", "mozinterruptend" ], + showHours: false, firstFrameShown : false, timeUpdateCount : 0, maxCurrentTimeSeen : 0, @@ -245,6 +246,13 @@ this.video.style.removeProperty("width"); } }, + + get isControlBarHidden() { + return this.controlBar.hidden || + this.controlBar.hideByAdjustment || + this.controlBar.getAttribute("fadeout") === "true"; + }, + suppressError : false, setupStatusFader(immediate) { @@ -384,6 +392,16 @@ value: true, writable: true }, + resized: { + value: false, + writable: true + }, + resizedHandler: { + value: () => { + control.minWidth = control.clientWidth; + }, + writable: true + }, hideByAdjustment: { set: (v) => { if (v) { @@ -410,7 +428,11 @@ this.clickToPlay.minWidth = 48; if (this.positionDurationBox) { - this.positionDurationBox.minWidth -= this.durationSpan.minWidth; + this.durationSpan.resized = true; + this.positionDurationBox.resized = true; + this.positionDurationBox.resizedHandler = () => { + this.positionDurationBox.minWidth = this.positionDurationBox.clientWidth - this.durationSpan.clientWidth; + }; } this.adjustControlSize(); @@ -526,7 +548,6 @@ } break; case "loadedmetadata": - this.adjustControlSize(); // If a