Changeset 275358 in webkit
- Timestamp:
- Apr 1, 2021 8:05:24 AM (3 years ago)
- Location:
- trunk
- Files:
-
- 2 deleted
- 29 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r275356 r275358 1 2021-04-01 Devin Rousso <drousso@apple.com> 2 3 Limit the number of buttons shown in media controls 4 https://bugs.webkit.org/show_bug.cgi?id=223909 5 6 Reviewed by Eric Carlson. 7 8 * media/modern-media-controls/ios-inline-media-controls/ios-inline-media-dropping-controls.html: 9 * media/modern-media-controls/ios-inline-media-controls/ios-inline-media-dropping-controls-expected.txt: 10 * media/modern-media-controls/macos-fullscreen-media-controls/macos-fullscreen-media-controls-buttons-containers-styles.html: 11 * media/modern-media-controls/macos-fullscreen-media-controls/macos-fullscreen-media-controls-buttons-containers-styles-expected.txt: 12 * media/modern-media-controls/macos-fullscreen-media-controls/macos-fullscreen-media-controls-buttons-styles.html: 13 * media/modern-media-controls/macos-fullscreen-media-controls/macos-fullscreen-media-controls-buttons-styles-expected.txt: 14 * media/modern-media-controls/macos-inline-media-controls/macos-inline-media-dropping-controls.html: 15 * media/modern-media-controls/macos-inline-media-controls/macos-inline-media-dropping-controls-expected.txt: 16 17 * media/modern-media-controls/macos-fullscreen-media-controls/macos-fullscreen-media-controls-constructor.html: 18 * media/modern-media-controls/macos-fullscreen-media-controls/macos-fullscreen-media-controls-constructor-expected.txt: 19 * media/modern-media-controls/macos-fullscreen-media-controls/macos-fullscreen-media-controls-right-container-margin.html: Removed. 20 * media/modern-media-controls/macos-fullscreen-media-controls/macos-fullscreen-media-controls-right-container-margin-expected.txt: Removed. 21 macOS fullscreen controls don't adjust the `buttonMargin` anymore as buttons are moved into 22 the overflow menu instead. 23 24 * media/modern-media-controls/tracks-support/auto-text-track.html: 25 * media/modern-media-controls/tracks-support/click-track-in-contextmenu.html: 26 * media/modern-media-controls/tracks-support/hidden-tracks.html: 27 * media/modern-media-controls/tracks-support/off-text-track.html: 28 * media/modern-media-controls/tracks-support/show-contextmenu-then-double-click-on-tracks-button.html: 29 * media/modern-media-controls/tracks-support/text-track-selected-via-media-api.html: 30 Override the default maximum right container button count so that the tracks button is shown. 31 1 32 2021-04-01 Commit Queue <commit-queue@webkit.org> 2 33 -
trunk/LayoutTests/media/modern-media-controls/ios-inline-media-controls/ios-inline-media-dropping-controls-expected.txt
r227979 r275358 6 6 PASS ready() became true 7 7 8 SkipForwardButton was dropped at 384. 9 SkipBackButton was dropped at 355. 10 AirplayButton was dropped at 326. 11 TracksButton was dropped at 294. 8 TracksButton was dropped at 681. 9 PiPButton was dropped at 681. 10 SkipForwardButton was dropped at 453. 11 SkipBackButton was dropped at 424. 12 MuteButton was dropped at 395. 13 AirplayButton was dropped at 357. 14 FullscreenButton was dropped at 325. 15 OverflowButton was dropped at 294. 12 16 13 17 PASS successfullyParsed is true -
trunk/LayoutTests/media/modern-media-controls/ios-inline-media-controls/ios-inline-media-dropping-controls.html
r227979 r275358 10 10 11 11 const mediaControls = new IOSInlineMediaControls({ width: 680, height: 300 }); 12 mediaControls.shouldUseSingleBarLayout = true; 12 13 13 14 const droppableControls = [ 15 mediaControls.overflowButton, 16 mediaControls.fullscreenButton, 17 mediaControls.airplayButton, 18 mediaControls.muteButton, 19 mediaControls.skipBackButton, 14 20 mediaControls.skipForwardButton, 15 mediaControls.skipBackButton, 16 mediaControls.airplayButton, 17 mediaControls.tracksButton 21 mediaControls.pipButton, 22 mediaControls.tracksButton, 18 23 ]; 19 24 … … 25 30 shouldBecomeEqual("ready()", "true", () => { 26 31 debug(""); 27 droppableControls.forEach(control => { 28 while (control.visible) 29 mediaControls.width--; 30 debug(`${control.constructor.name} was dropped at ${mediaControls.width + 1}.`); 31 }); 32 while (droppableControls.length) { 33 for (let i = droppableControls.length - 1; i >= 0; --i) { 34 if (!droppableControls[i].visible) { 35 debug(`${droppableControls[i].constructor.name} was dropped at ${mediaControls.width + 1}.`); 36 droppableControls.splice(i, 1); 37 } 38 } 39 40 mediaControls.width--; 41 } 32 42 debug(""); 33 43 finishJSTest(); -
trunk/LayoutTests/media/modern-media-controls/macos-fullscreen-media-controls/macos-fullscreen-media-controls-buttons-containers-styles-expected.txt
r274521 r275358 9 9 PASS centerContainer.element.getBoundingClientRect().height is 44 10 10 11 PASS Math.floor(rightContainer.element.getBoundingClientRect().width) became 1 3112 PASS rightContainer.element.getBoundingClientRect().left is within 0.5 of 5 0311 PASS Math.floor(rightContainer.element.getBoundingClientRect().width) became 123 12 PASS rightContainer.element.getBoundingClientRect().left is within 0.5 of 511 13 13 PASS rightContainer.element.getBoundingClientRect().top is 500 14 14 PASS rightContainer.element.getBoundingClientRect().height is 44 -
trunk/LayoutTests/media/modern-media-controls/macos-fullscreen-media-controls/macos-fullscreen-media-controls-buttons-containers-styles.html
r274521 r275358 42 42 43 43 debug(""); 44 shouldBecomeEqual("Math.floor(rightContainer.element.getBoundingClientRect().width)", "1 31", () => {45 shouldBeCloseTo("rightContainer.element.getBoundingClientRect().left", 5 03, 0.5);44 shouldBecomeEqual("Math.floor(rightContainer.element.getBoundingClientRect().width)", "123", () => { 45 shouldBeCloseTo("rightContainer.element.getBoundingClientRect().left", 511, 0.5); 46 46 shouldBe("rightContainer.element.getBoundingClientRect().top", "500"); 47 47 shouldBe("rightContainer.element.getBoundingClientRect().height", "44"); -
trunk/LayoutTests/media/modern-media-controls/macos-fullscreen-media-controls/macos-fullscreen-media-controls-buttons-styles-expected.txt
r274521 r275358 27 27 PiPButton 28 28 PASS getComputedStyle(button.element).top became "18px" 29 PASS getComputedStyle(button.element).left is " 43px"29 PASS getComputedStyle(button.element).left is "36px" 30 30 PASS getComputedStyle(button.element).height is "16px" 31 31 32 32 TracksButton 33 33 PASS getComputedStyle(button.element).top became "18px" 34 PASS getComputedStyle(button.element).left is " 74px"34 PASS getComputedStyle(button.element).left is "60px" 35 35 PASS getComputedStyle(button.element).height is "16px" 36 36 37 37 FullscreenButton 38 38 PASS getComputedStyle(button.element).top became "18px" 39 PASS getComputedStyle(button.element).left is " 103px"39 PASS getComputedStyle(button.element).left is "55px" 40 40 PASS getComputedStyle(button.element).height is "16px" 41 41 PASS successfullyParsed is true -
trunk/LayoutTests/media/modern-media-controls/macos-fullscreen-media-controls/macos-fullscreen-media-controls-buttons-styles.html
r274521 r275358 17 17 [mediaControls.forwardButton, 127, 14, 16], 18 18 [mediaControls.airplayButton, 12, 18, 16], 19 [mediaControls.pipButton, 43, 18, 16],20 [mediaControls.tracksButton, 74, 18, 16],21 [mediaControls.fullscreenButton, 103, 18, 16],19 [mediaControls.pipButton, 36, 18, 16], 20 [mediaControls.tracksButton, 60, 18, 16], 21 [mediaControls.fullscreenButton, 55, 18, 16], 22 22 ]; 23 23 -
trunk/LayoutTests/media/modern-media-controls/macos-fullscreen-media-controls/macos-fullscreen-media-controls-constructor-expected.txt
r274521 r275358 33 33 PASS mediaControls.bottomControlsBar.children[3].leftMargin is 12 34 34 PASS mediaControls.bottomControlsBar.children[3].rightMargin is 12 35 PASS mediaControls.bottomControlsBar.children[3].buttonMargin is 1635 PASS mediaControls.bottomControlsBar.children[3].buttonMargin is 24 36 36 37 37 PASS successfullyParsed is true -
trunk/LayoutTests/media/modern-media-controls/macos-fullscreen-media-controls/macos-fullscreen-media-controls-constructor.html
r274521 r275358 41 41 shouldBe("mediaControls.bottomControlsBar.children[3].leftMargin", "12"); 42 42 shouldBe("mediaControls.bottomControlsBar.children[3].rightMargin", "12"); 43 shouldBe("mediaControls.bottomControlsBar.children[3].buttonMargin", " 16");43 shouldBe("mediaControls.bottomControlsBar.children[3].buttonMargin", "24"); 44 44 45 45 debug(""); -
trunk/LayoutTests/media/modern-media-controls/macos-inline-media-controls/macos-inline-media-dropping-controls-expected.txt
r274521 r275358 6 6 PASS ready() became true 7 7 8 SkipForwardButton was dropped at 482. 9 SkipBackButton was dropped at 453. 10 AirplayButton was dropped at 424. 11 TracksButton was dropped at 392. 12 PiPButton was dropped at 392. 8 TracksButton was dropped at 681. 9 PiPButton was dropped at 681. 10 SkipForwardButton was dropped at 447. 11 SkipBackButton was dropped at 418. 12 MuteButton was dropped at 389. 13 AirplayButton was dropped at 351. 13 14 FullscreenButton was dropped at 319. 14 MuteButton was dropped at 319.15 OverflowButton was dropped at 288. 15 16 16 17 PASS successfullyParsed is true -
trunk/LayoutTests/media/modern-media-controls/macos-inline-media-controls/macos-inline-media-dropping-controls.html
r227953 r275358 13 13 14 14 const droppableControls = [ 15 mediaControls.overflowButton, 16 mediaControls.fullscreenButton, 17 mediaControls.airplayButton, 18 mediaControls.muteButton, 19 mediaControls.skipBackButton, 15 20 mediaControls.skipForwardButton, 16 mediaControls.skipBackButton, 17 mediaControls.airplayButton, 21 mediaControls.pipButton, 18 22 mediaControls.tracksButton, 19 mediaControls.pipButton,20 mediaControls.fullscreenButton,21 mediaControls.muteButton22 23 ]; 23 24 … … 29 30 shouldBecomeEqual("ready()", "true", () => { 30 31 debug(""); 31 droppableControls.forEach(control => { 32 while (control.visible) 33 mediaControls.width--; 34 debug(`${control.constructor.name} was dropped at ${mediaControls.width + 1}.`); 35 }); 32 while (droppableControls.length) { 33 for (let i = droppableControls.length - 1; i >= 0; --i) { 34 if (!droppableControls[i].visible) { 35 debug(`${droppableControls[i].constructor.name} was dropped at ${mediaControls.width + 1}.`); 36 droppableControls.splice(i, 1); 37 } 38 } 39 40 mediaControls.width--; 41 } 36 42 debug(""); 37 43 finishJSTest(); -
trunk/LayoutTests/media/modern-media-controls/tracks-support/auto-text-track.html
r275265 r275358 4 4 <script src="../../../resources/js-test-pre.js"></script> 5 5 <body> 6 <video src="../../content/counting-subtitled.m4v" style="position: absolute; left: 0; top: 0; width: 400px;" autoplay controls muted playsinline></video>6 <video src="../../content/counting-subtitled.m4v" style="position: absolute; left: 0; top: 0; width: 600px;" autoplay controls muted playsinline></video> 7 7 <script type="text/javascript"> 8 8 … … 13 13 const media = document.querySelector("video"); 14 14 const shadowRoot = window.internals.shadowRoot(media); 15 16 window.internals.setMediaControlsMaximumRightContainerButtonCountOverride(media, 100); // A finite value larger than anything likely. 15 17 16 18 let checkedItems = null; -
trunk/LayoutTests/media/modern-media-controls/tracks-support/click-track-in-contextmenu.html
r275265 r275358 4 4 <script src="../../../resources/js-test-pre.js"></script> 5 5 <body> 6 <video src="../../content/audio-tracks.mp4" style="position: absolute; left: 0; top: 0; width: 400px;" controls autoplay muted playsinline></video>6 <video src="../../content/audio-tracks.mp4" style="position: absolute; left: 0; top: 0; width: 600px;" controls autoplay muted playsinline></video> 7 7 <script type="text/javascript"> 8 8 … … 13 13 const media = document.querySelector("video"); 14 14 const shadowRoot = window.internals.shadowRoot(media); 15 16 window.internals.setMediaControlsMaximumRightContainerButtonCountOverride(media, 100); // A finite value larger than anything likely. 15 17 16 18 let selectedTrack = null; -
trunk/LayoutTests/media/modern-media-controls/tracks-support/hidden-tracks.html
r275265 r275358 4 4 <script src="../../../resources/js-test-pre.js"></script> 5 5 <body> 6 <video src="../../content/counting-subtitled.m4v" style="position: absolute; left: 0; top: 0; width: 400px;" controls autoplay muted playsinline></video>6 <video src="../../content/counting-subtitled.m4v" style="position: absolute; left: 0; top: 0; width: 600px;" controls autoplay muted playsinline></video> 7 7 <script type="text/javascript"> 8 8 … … 13 13 const media = document.querySelector("video"); 14 14 const shadowRoot = window.internals.shadowRoot(media); 15 16 window.internals.setMediaControlsMaximumRightContainerButtonCountOverride(media, 100); // A finite value larger than anything likely. 15 17 16 18 let checkedItems = null; -
trunk/LayoutTests/media/modern-media-controls/tracks-support/off-text-track.html
r275265 r275358 4 4 <script src="../../../resources/js-test-pre.js"></script> 5 5 <body> 6 <video src="../../content/counting-subtitled.m4v" style="position: absolute; left: 0; top: 0; width: 400px;" autoplay controls muted playsinline></video>6 <video src="../../content/counting-subtitled.m4v" style="position: absolute; left: 0; top: 0; width: 600px;" autoplay controls muted playsinline></video> 7 7 <script type="text/javascript"> 8 8 … … 13 13 const media = document.querySelector("video"); 14 14 const shadowRoot = window.internals.shadowRoot(media); 15 16 window.internals.setMediaControlsMaximumRightContainerButtonCountOverride(media, 100); // A finite value larger than anything likely. 15 17 16 18 let checkedItems = null; -
trunk/LayoutTests/media/modern-media-controls/tracks-support/show-contextmenu-then-double-click-on-tracks-button.html
r274521 r275358 4 4 <script src="../../../resources/js-test-pre.js"></script> 5 5 <body> 6 <video src="../../content/CC+Subtitles.mov" style="position: absolute; left: 0; top: 0; width: 400px;" autoplay controls muted playsinline></video>6 <video src="../../content/CC+Subtitles.mov" style="position: absolute; left: 0; top: 0; width: 600px;" autoplay controls muted playsinline></video> 7 7 <script type="text/javascript"> 8 8 … … 13 13 const media = document.querySelector("video"); 14 14 const shadowRoot = window.internals.shadowRoot(media); 15 16 window.internals.setMediaControlsMaximumRightContainerButtonCountOverride(media, 100); // A finite value larger than anything likely. 15 17 16 18 media.addEventListener("play", () => { -
trunk/LayoutTests/media/modern-media-controls/tracks-support/text-track-selected-via-media-api.html
r275265 r275358 4 4 <script src="../../../resources/js-test-pre.js"></script> 5 5 <body> 6 <video src="../../content/counting-subtitled.m4v" style="position: absolute; left: 0; top: 0; width: 400px;" autoplay controls muted playsinline></video>6 <video src="../../content/counting-subtitled.m4v" style="position: absolute; left: 0; top: 0; width: 600px;" autoplay controls muted playsinline></video> 7 7 <script type="text/javascript"> 8 8 … … 14 14 const media = document.querySelector("video"); 15 15 const shadowRoot = window.internals.shadowRoot(media); 16 17 window.internals.setMediaControlsMaximumRightContainerButtonCountOverride(media, 100); // A finite value larger than anything likely. 16 18 17 19 let contextmenu = null; -
trunk/Source/WebCore/ChangeLog
r275357 r275358 1 2021-04-01 Devin Rousso <drousso@apple.com> 2 3 Limit the number of buttons shown in media controls 4 https://bugs.webkit.org/show_bug.cgi?id=223909 5 6 Reviewed by Eric Carlson. 7 8 When in fullscreen, it's possible to have five different buttons to the right of "Play": 9 - AirPlay 10 - Enter Picture in Picture 11 - Audio/Languages 12 - Exit Full Screen 13 - More... 14 This turns the UI into something of an "icon soup" and should really be avoided, especially 15 now that `OverflowButton` allows for a single button to have multiple actions (via a native 16 contextmenu). This matches AVKit behavior. 17 18 Tests: media/modern-media-controls/ios-inline-media-controls/ios-inline-media-dropping-controls.html: 19 media/modern-media-controls/macos-fullscreen-media-controls/macos-fullscreen-media-controls-buttons-containers-styles.html: 20 media/modern-media-controls/macos-fullscreen-media-controls/macos-fullscreen-media-controls-buttons-styles.html: 21 media/modern-media-controls/macos-fullscreen-media-controls/macos-fullscreen-media-controls-constructor.html: 22 media/modern-media-controls/macos-inline-media-controls/macos-inline-media-dropping-controls.html: 23 24 * Modules/modern-media-controls/controls/inline-media-controls.js: 25 (InlineMediaControls.prototype.layout): 26 (InlineMediaControls.prototype._droppableButtons): 27 (InlineMediaControls.prototype._collapsableButtons): Added. 28 * Modules/modern-media-controls/controls/macos-fullscreen-media-controls.js: 29 (MacOSFullscreenMediaControls): 30 (MacOSFullscreenMediaControls.prototype.layout): 31 (MacOSFullscreenMediaControls.prototype._collapsableButtons): Added. 32 Limit the number of `visible` buttons in `rightContainer.children` by iteratively marking 33 `dropped = true` on buttons that are also in `_collapsableButtons` until either there are 34 no iterations left (`i < 0`) or the number of visible buttons is below the maximum (2 for 35 inline and 3 for fullscreen). 36 37 * Modules/modern-media-controls/controls/pip-button.js: 38 (PiPButton.prototype.get contextMenuOptions): Added. 39 * Modules/mediacontrols/MediaControlsHost.cpp: 40 (WebCore::MediaControlsHost::showMediaControlsContextMenu): 41 Add support for `includePictureInPicture` to the native contextmenu. 42 43 * en.lproj/Localizable.strings: 44 45 * testing/Internals.idl: 46 * testing/Internals.h: 47 * testing/Internals.cpp: 48 (WebCore::Internals::setMediaControlsMaximumRightContainerButtonCountOverride): Added. 49 * html/HTMLMediaElement.h: 50 * html/HTMLMediaElement.cpp: 51 (WebCore::HTMLMediaElement::setMediaControlsMaximumRightContainerButtonCountOverride): Added. 52 * Modules/modern-media-controls/media/media-controller.js: 53 (MediaController.prototype.set maximumRightContainerButtonCountOverride): Added. 54 Add a way to override the default maximum right container button count for testing. This is 55 useful for testing the functionality of a specific button when not in the collapsed state, 56 allowing for tests to not have to worry about other state that may affect collapsing (e.g. 57 the AirPlay button is shown when there are AirPlay targets). 58 1 59 2021-04-01 Zalan Bujtas <zalan@apple.com> 2 60 -
trunk/Source/WebCore/Modules/mediacontrols/MediaControlsHost.cpp
r275225 r275358 46 46 #include "HTMLElement.h" 47 47 #include "HTMLMediaElement.h" 48 #include "HTMLVideoElement.h" 48 49 #include "LocalizedStrings.h" 49 50 #include "Logging.h" … … 56 57 #include "TextTrack.h" 57 58 #include "TextTrackList.h" 59 #include "UserGestureIndicator.h" 58 60 #include "VoidCallback.h" 59 61 #include <JavaScriptCore/JSCJSValueInlines.h> … … 501 503 #endif 502 504 503 using MenuData = Variant<RefPtr<AudioTrack>, RefPtr<TextTrack> MediaControlsHostAdditions_showMediaControlsContextMenu_MenuData>; 505 #if ENABLE(VIDEO_PRESENTATION_MODE) 506 enum class PictureInPictureTag { IncludePictureInPicture }; 507 #endif // ENABLE(VIDEO_PRESENTATION_MODE) 508 509 using MenuData = Variant< 510 #if ENABLE(VIDEO_PRESENTATION_MODE) 511 PictureInPictureTag, 512 #endif // ENABLE(VIDEO_PRESENTATION_MODE) 513 RefPtr<AudioTrack>, 514 RefPtr<TextTrack> 515 MediaControlsHostAdditions_showMediaControlsContextMenu_MenuData 516 >; 504 517 HashMap<MenuItemIdentifier, MenuData> idMap; 505 518 … … 513 526 }; 514 527 515 auto createMenuItem = [&] (MenuData data, const String& title, bool checked = false ) -> MenuItem {528 auto createMenuItem = [&] (MenuData data, const String& title, bool checked = false, const String& icon = nullString()) -> MenuItem { 516 529 auto id = idMap.size() + 1; 517 530 idMap.add(id, data); 518 531 519 532 #if USE(UICONTEXTMENU) 520 return { id, title, /* icon */ nullString(), checked, /* children */ { } };533 return { id, title, icon, checked, /* children */ { } }; 521 534 #elif ENABLE(CONTEXT_MENUS) && USE(ACCESSIBILITY_CONTEXT_MENUS) 535 UNUSED_PARAM(icon); 522 536 return { CheckableActionType, static_cast<ContextMenuAction>(ContextMenuItemBaseCustomTag + id), title, /* enabled */ true, checked }; 523 537 #endif … … 525 539 526 540 Vector<MenuItem> items; 541 542 #if ENABLE(VIDEO_PRESENTATION_MODE) 543 if (optionsJSONObject->getBoolean("includePictureInPicture"_s).valueOr(false)) { 544 ASSERT(is<HTMLVideoElement>(mediaElement)); 545 ASSERT(downcast<HTMLVideoElement>(mediaElement).webkitSupportsPresentationMode(HTMLVideoElement::VideoPresentationMode::PictureInPicture)); 546 items.append(createMenuItem(PictureInPictureTag::IncludePictureInPicture, WEB_UI_STRING_KEY("Picture in Picture", "Picture in Picture (Media Controls Menu)", "Picture in Picture media controls context menu title"), false, "pip.enter"_s)); 547 } 548 #endif // ENABLE(VIDEO_PRESENTATION_MODE) 527 549 528 550 if (optionsJSONObject->getBoolean("includeLanguages"_s).valueOr(false)) { … … 602 624 auto& mediaElement = *weakMediaElement; 603 625 626 UserGestureIndicator gestureIndicator(ProcessingUserGesture, &mediaElement.document()); 627 604 628 auto selectedItem = idMap.get(selectedItemID); 605 629 WTF::switchOn(selectedItem, 630 #if ENABLE(VIDEO_PRESENTATION_MODE) 631 [&] (PictureInPictureTag) { 632 // Media controls are not shown when in PiP so we can assume that we're not in PiP. 633 downcast<HTMLVideoElement>(mediaElement).webkitSetPresentationMode(HTMLVideoElement::VideoPresentationMode::PictureInPicture); 634 }, 635 #endif // ENABLE(VIDEO_PRESENTATION_MODE) 606 636 [&] (RefPtr<AudioTrack>& selectedAudioTrack) { 607 637 for (auto& track : idMap.values()) { -
trunk/Source/WebCore/Modules/modern-media-controls/controls/inline-media-controls.js
r274521 r275358 185 185 } 186 186 187 let collapsableButtons = this._collapsableButtons(); 188 let shownRightContainerButtons = this.rightContainer.children.filter(button => button.enabled && !button.dropped); 189 let maximumRightContainerButtonCount = this.maximumRightContainerButtonCountOverride ?? 2; // Allow AirPlay and overflow if all buttons are shown. 190 for (let i = shownRightContainerButtons.length - 1; i >= 0 && shownRightContainerButtons.length > maximumRightContainerButtonCount; --i) { 191 let button = shownRightContainerButtons[i]; 192 if (!collapsableButtons.has(button)) 193 continue; 194 195 button.dropped = true; 196 this.overflowButton.addContextMenuOptions(button.contextMenuOptions); 197 } 198 187 199 // Update layouts once more. 188 200 this.leftContainer.layout(); … … 270 282 _droppableButtons() 271 283 { 284 let buttons = this._collapsableButtons(); 285 buttons.add(this.skipForwardButton); 286 buttons.add(this.skipBackButton); 287 if (this._shouldUseSingleBarLayout || this.preferredMuteButtonStyle === Button.Styles.Bar) 288 buttons.add(this.muteButton); 289 buttons.add(this.airplayButton); 272 290 if (this._shouldUseSingleBarLayout) 273 return [this.skipForwardButton, this.skipBackButton, this.airplayButton, this.tracksButton, this.pipButton, this.muteButton, this.fullscreenButton, this.overflowButton]; 274 275 const buttons = [this.skipForwardButton, this.skipBackButton, this.airplayButton, this.tracksButton]; 276 if (this.preferredMuteButtonStyle === Button.Styles.Bar) 277 buttons.push(this.muteButton); 278 buttons.push(this.overflowButton); 291 buttons.add(this.fullscreenButton); 292 buttons.add(this.overflowButton); 293 return buttons; 294 } 295 296 _collapsableButtons() 297 { 298 let buttons = new Set([ 299 this.tracksButton, 300 ]); 301 if (this._shouldUseSingleBarLayout) 302 buttons.add(this.pipButton); 279 303 return buttons; 280 304 } -
trunk/Source/WebCore/Modules/modern-media-controls/controls/macos-fullscreen-media-controls.js
r274521 r275358 24 24 */ 25 25 26 const ButtonMarginForThreeButtonsOrLess = 24;27 const ButtonMarginForFourButtons = 16;28 const ButtonMarginForFiveButtons = 12;29 26 const FullscreenTimeControlWidth = 448; 30 27 … … 69 66 cssClassName: "right", 70 67 leftMargin: 12, 71 rightMargin: 12 68 rightMargin: 12, 69 buttonMargin: 24 72 70 }); 73 71 … … 112 110 return; 113 111 114 const numberOfEnabledButtons = this._rightContainer.children.filter(button => button.enabled).length; 115 116 let buttonMargin = ButtonMarginForFiveButtons; 117 if (numberOfEnabledButtons === 4) 118 buttonMargin = ButtonMarginForFourButtons; 119 else if (numberOfEnabledButtons <= 3) 120 buttonMargin = ButtonMarginForThreeButtonsOrLess; 121 122 this._rightContainer.buttonMargin = buttonMargin; 112 this._rightContainer.children.forEach(button => delete button.dropped) 113 this.overflowButton.clearContextMenuOptions(); 123 114 124 115 this._leftContainer.visible = this.muteButton.enabled; 125 116 this._leftContainer.children = this._volumeControlsForCurrentDirection(); 117 118 let collapsableButtons = this._collapsableButtons(); 119 let shownRightContainerButtons = this._rightContainer.children.filter(button => button.enabled && !button.dropped); 120 let maximumRightContainerButtonCount = this.maximumRightContainerButtonCountOverride ?? 3; // Allow AirPlay, Exit Fullscreen, and overflow if all buttons are shown. 121 for (let i = shownRightContainerButtons.length - 1; i >= 0 && shownRightContainerButtons.length > maximumRightContainerButtonCount; --i) { 122 let button = shownRightContainerButtons[i]; 123 if (!collapsableButtons.has(button)) 124 continue; 125 126 button.dropped = true; 127 this.overflowButton.addContextMenuOptions(button.contextMenuOptions); 128 } 126 129 127 130 this._leftContainer.layout(); … … 148 151 } 149 152 153 _collapsableButtons() 154 { 155 return new Set([ 156 this.tracksButton, 157 this.pipButton, 158 ]); 159 } 160 150 161 _handleMousedown(event) 151 162 { -
trunk/Source/WebCore/Modules/modern-media-controls/controls/pip-button.js
r217823 r275358 36 36 } 37 37 38 // Public 39 40 get contextMenuOptions() 41 { 42 return { 43 includePictureInPicture: true, 44 }; 45 } 46 38 47 } -
trunk/Source/WebCore/Modules/modern-media-controls/media/media-controller.js
r274521 r275358 374 374 } 375 375 376 // Testing 377 378 set maximumRightContainerButtonCountOverride(count) 379 { 380 this.controls.maximumRightContainerButtonCountOverride = count; 381 } 382 376 383 } -
trunk/Source/WebCore/en.lproj/Localizable.strings
r274698 r275358 662 662 "Photo Library (file upload action sheet)" = "Photo Library"; 663 663 664 /* Picture in Picture media controls context menu title */ 665 "Picture in Picture (Media Controls Menu)" = "Picture in Picture"; 666 664 667 /* Media Play context menu item */ 665 668 "Play" = "Play"; -
trunk/Source/WebCore/html/HTMLMediaElement.cpp
r275262 r275358 7389 7389 } 7390 7390 7391 void HTMLMediaElement::setMediaControlsMaximumRightContainerButtonCountOverride(size_t count) 7392 { 7393 setControllerJSProperty("maximumRightContainerButtonCountOverride", JSC::jsNumber(count)); 7394 } 7395 7391 7396 unsigned long long HTMLMediaElement::fileSize() const 7392 7397 { -
trunk/Source/WebCore/html/HTMLMediaElement.h
r274264 r275358 495 495 void userInterfaceLayoutDirectionChanged(); 496 496 WEBCORE_EXPORT String getCurrentMediaControlsStatus(); 497 WEBCORE_EXPORT void setMediaControlsMaximumRightContainerButtonCountOverride(size_t); 497 498 MediaControlsHost* mediaControlsHost() { return m_mediaControlsHost.get(); } 498 499 -
trunk/Source/WebCore/testing/Internals.cpp
r275187 r275358 4765 4765 } 4766 4766 4767 #if ENABLE(VIDEO) 4768 4767 4769 String Internals::getCurrentMediaControlsStatusForElement(HTMLMediaElement& mediaElement) 4768 4770 { 4769 #if ENABLE(VIDEO)4770 4771 return mediaElement.getCurrentMediaControlsStatus(); 4771 #else 4772 UNUSED_PARAM(mediaElement); 4773 return { }; 4774 #endif 4775 } 4772 } 4773 4774 void Internals::setMediaControlsMaximumRightContainerButtonCountOverride(HTMLMediaElement& mediaElement, size_t count) 4775 { 4776 mediaElement.setMediaControlsMaximumRightContainerButtonCountOverride(count); 4777 } 4778 4779 #endif // ENABLE(VIDEO) 4776 4780 4777 4781 #if !PLATFORM(COCOA) -
trunk/Source/WebCore/testing/Internals.h
r275187 r275358 729 729 ExceptionOr<String> pathStringWithShrinkWrappedRects(const Vector<double>& rectComponents, double radius); 730 730 731 #if ENABLE(VIDEO) 731 732 String getCurrentMediaControlsStatusForElement(HTMLMediaElement&); 733 void setMediaControlsMaximumRightContainerButtonCountOverride(HTMLMediaElement&, size_t); 734 #endif // ENABLE(VIDEO) 732 735 733 736 String userVisibleString(const DOMURL&); -
trunk/Source/WebCore/testing/Internals.idl
r275187 r275358 764 764 765 765 [Conditional=VIDEO] DOMString getCurrentMediaControlsStatusForElement(HTMLMediaElement element); 766 [Conditional=VIDEO] undefined setMediaControlsMaximumRightContainerButtonCountOverride(HTMLMediaElement element, unsigned long count); 766 767 767 768 DOMString userVisibleString(DOMURL url);
Note: See TracChangeset
for help on using the changeset viewer.