Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Modern Media Controls] add a way to show stats about the <video> #3463

Merged
merged 1 commit into from Aug 19, 2022

Conversation

dcrousso
Copy link
Member

@dcrousso dcrousso commented Aug 18, 2022

e5887c7

[Modern Media Controls] add a way to show stats about the <video>
https://bugs.webkit.org/show_bug.cgi?id=244101
<rdar://problem/98847210>

Reviewed by Eric Carlson.

This will allow developers to gleam more information about the current state of `<video>` at a
glance, rather than having to use JS APIs to gather that info. This can also be expanded to shows
information that doesn't have an equivalent JS API.

* Source/WTF/Scripts/Preferences/WebPreferencesExperimental.yaml:
Add an experimental setting for this feature.

* Source/WebKit/WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::updatePreferences):
If this new experimental setting is enabled, also require `TrackConfigurationEnabled` as that's
needed for many of the stats to be shown.

* Source/WebCore/Modules/modern-media-controls/controls/media-controls.css:
(.stats-container): Added.
(.stats-container > table): Added.
(.stats-container > table > tr > :is(th, td)): Added.
(.stats-container > table > tr > th): Added.
* Source/WebCore/Modules/modern-media-controls/media/media-controller.js:
(MediaController.prototype.setShowingStats): Added.
(MediaController.prototype.setShowingStats.createRow): Added.
When "Show Media Stats" is enabled, show a basic `<table>` containing rows for each stat that's
centered inside the `<video>`.

* Source/WebCore/Modules/modern-media-controls/media/overflow-support.js:
(OverflowSupport.prototype.syncControl):
* Source/WebCore/Modules/mediacontrols/MediaControlsHost.cpp:
(WebCore::MediaControlsHost::showMediaControlsContextMenu):
Also allow the (modern) media controls JS to provide `"includeShowMediaStats"`, which does the same
acts the same as the general context menu item.

* Source/WebCore/html/HTMLMediaElement.h:
(WebCore::HTMLMediaElement::showingStats const): Added.
The source of truth for "are we showing media stats" is in a member variable.

* Source/WebCore/html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::setShowingStats): Added.
Invoke some JS to create/remove the `<table>`, updating the member variable depending on the result.

* Source/WebCore/platform/ContextMenuItem.h:
* Source/WebCore/platform/ContextMenuItem.cpp:
(WebCore::isValidContextMenuAction):
* Source/WebCore/page/ContextMenuController.h:
* Source/WebCore/page/ContextMenuController.cpp:
(WebCore::ContextMenuController::showContextMenu):
(WebCore::ContextMenuController::contextMenuItemSelected):
(WebCore::ContextMenuController::addDebuggingItems): Renamed from `addInspectElementItem`.
(WebCore::ContextMenuController::checkOrEnableIfNeeded const):
* Source/WebCore/rendering/HitTestResult.h:
* Source/WebCore/rendering/HitTestResult.cpp:
(WebCore::HitTestResult::toggleShowMediaStats const): Added.
(WebCore::HitTestResult::mediaStatsShowing const): Added.
* Source/WebKit/UIProcess/API/Cocoa/WKMenuItemIdentifiersPrivate.h:
* Source/WebKit/UIProcess/API/Cocoa/WKMenuItemIdentifiers.mm:
* Source/WebKit/UIProcess/mac/WebContextMenuProxyMac.mm:
(WebKit::menuItemIdentifier):
* Source/WebKitLegacy/mac/WebView/WebHTMLView.mm:
(toTag):
Create a new `ContextMenuItemTagShowMediaStats`, adding it after `ContextMenuItemTagInspectElement`.

* Source/WebKit/UIProcess/ios/WKActionSheetAssistant.mm:
(-[WKActionSheetAssistant _uiMenuElementsForMediaControlContextMenuItems:]):
Add a way to create a separator in the (modern) media controls context menu on iOS.

* Source/WebCore/en.lproj/modern-media-controls-localized-strings.js:
* Source/WebCore/Modules/modern-media-controls/main.js:
(UIString):
Allow for multiple replacements in a single string.

* Source/WebCore/en.lproj/Localizable.strings:
* Source/WebCore/platform/LocalizedStrings.h:
* Source/WebCore/platform/LocalizedStrings.cpp:
(WebCore::contextMenuItemTagShowMediaStats): Added.

Canonical link: https://commits.webkit.org/253583@main

25103a9

Misc iOS, tvOS & watchOS macOS Linux Windows
βœ… πŸ§ͺ style βœ… πŸ›  ios βœ… πŸ›  mac βœ… πŸ›  wpe βœ… πŸ›  πŸ§ͺ win
βœ… πŸ§ͺ bindings βœ… πŸ›  ios-sim βœ… πŸ›  mac-debug βœ… πŸ›  gtk βœ… πŸ›  wincairo
βœ… πŸ§ͺ webkitperl βœ… πŸ§ͺ ios-wk2 βœ… πŸ›  mac-AS-debug βœ… πŸ§ͺ gtk-wk2
βœ… πŸ§ͺ api-ios βœ… πŸ§ͺ api-mac βœ… πŸ§ͺ api-gtk
βœ… πŸ›  πŸ§ͺ jsc βœ… πŸ›  tv βœ… πŸ§ͺ mac-wk1 βœ… πŸ›  jsc-armv7
βœ… πŸ›  tv-sim βœ… πŸ§ͺ mac-wk2 βœ… πŸ§ͺ jsc-armv7-tests
βœ… πŸ›  πŸ§ͺ merge βœ… πŸ›  watch βœ… πŸ§ͺ mac-AS-debug-wk2 βœ… πŸ›  jsc-mips
βœ… πŸ›  watch-sim βœ… πŸ§ͺ mac-wk2-stress βœ… πŸ§ͺ jsc-mips-tests

@dcrousso dcrousso self-assigned this Aug 18, 2022
@dcrousso dcrousso added Media Bugs related to the HTML 5 Media elements. WebKit Nightly Build labels Aug 18, 2022
@dcrousso
Copy link
Member Author

Screenshot 2022-08-18 at 14 18 54

@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label Aug 18, 2022
@dcrousso dcrousso removed the merging-blocked Applied to prevent a change from being merged label Aug 18, 2022
Copy link
Contributor

@eric-carlson eric-carlson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

r=me

void HitTestResult::toggleShowMediaStats() const
{
#if ENABLE(VIDEO)
if (HTMLMediaElement* mediaElt = mediaElement())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't the first use of mediaElt in this file, but surely you can come up with a more descriptive variable name of the new code.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lol yeah fair i can rename this

i didn't even really notice this cause it was mostly a copy pasta from "Loop" πŸ˜…

bool HitTestResult::mediaStatsShowing() const
{
#if ENABLE(VIDEO)
if (HTMLMediaElement* mediaElt = mediaElement())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto

Comment on lines +605 to +606
default:
break;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why add a default??

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

both cause i need to add a case for ContextMenuItemTagShowMediaStats and so that in the future if others add new items like that they don't even have to worry about handling it here

@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label Aug 19, 2022
@dcrousso dcrousso removed the merging-blocked Applied to prevent a change from being merged label Aug 19, 2022
@dcrousso dcrousso added the merge-queue Applied to send a pull request to merge-queue label Aug 19, 2022
https://bugs.webkit.org/show_bug.cgi?id=244101
<rdar://problem/98847210>

Reviewed by Eric Carlson.

This will allow developers to gleam more information about the current state of `<video>` at a
glance, rather than having to use JS APIs to gather that info. This can also be expanded to shows
information that doesn't have an equivalent JS API.

* Source/WTF/Scripts/Preferences/WebPreferencesExperimental.yaml:
Add an experimental setting for this feature.

* Source/WebKit/WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::updatePreferences):
If this new experimental setting is enabled, also require `TrackConfigurationEnabled` as that's
needed for many of the stats to be shown.

* Source/WebCore/Modules/modern-media-controls/controls/media-controls.css:
(.stats-container): Added.
(.stats-container > table): Added.
(.stats-container > table > tr > :is(th, td)): Added.
(.stats-container > table > tr > th): Added.
* Source/WebCore/Modules/modern-media-controls/media/media-controller.js:
(MediaController.prototype.setShowingStats): Added.
(MediaController.prototype.setShowingStats.createRow): Added.
When "Show Media Stats" is enabled, show a basic `<table>` containing rows for each stat that's
centered inside the `<video>`.

* Source/WebCore/Modules/modern-media-controls/media/overflow-support.js:
(OverflowSupport.prototype.syncControl):
* Source/WebCore/Modules/mediacontrols/MediaControlsHost.cpp:
(WebCore::MediaControlsHost::showMediaControlsContextMenu):
Also allow the (modern) media controls JS to provide `"includeShowMediaStats"`, which does the same
acts the same as the general context menu item.

* Source/WebCore/html/HTMLMediaElement.h:
(WebCore::HTMLMediaElement::showingStats const): Added.
The source of truth for "are we showing media stats" is in a member variable.

* Source/WebCore/html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::setShowingStats): Added.
Invoke some JS to create/remove the `<table>`, updating the member variable depending on the result.

* Source/WebCore/platform/ContextMenuItem.h:
* Source/WebCore/platform/ContextMenuItem.cpp:
(WebCore::isValidContextMenuAction):
* Source/WebCore/page/ContextMenuController.h:
* Source/WebCore/page/ContextMenuController.cpp:
(WebCore::ContextMenuController::showContextMenu):
(WebCore::ContextMenuController::contextMenuItemSelected):
(WebCore::ContextMenuController::addDebuggingItems): Renamed from `addInspectElementItem`.
(WebCore::ContextMenuController::checkOrEnableIfNeeded const):
* Source/WebCore/rendering/HitTestResult.h:
* Source/WebCore/rendering/HitTestResult.cpp:
(WebCore::HitTestResult::toggleShowMediaStats const): Added.
(WebCore::HitTestResult::mediaStatsShowing const): Added.
* Source/WebKit/UIProcess/API/Cocoa/WKMenuItemIdentifiersPrivate.h:
* Source/WebKit/UIProcess/API/Cocoa/WKMenuItemIdentifiers.mm:
* Source/WebKit/UIProcess/mac/WebContextMenuProxyMac.mm:
(WebKit::menuItemIdentifier):
* Source/WebKitLegacy/mac/WebView/WebHTMLView.mm:
(toTag):
Create a new `ContextMenuItemTagShowMediaStats`, adding it after `ContextMenuItemTagInspectElement`.

* Source/WebKit/UIProcess/ios/WKActionSheetAssistant.mm:
(-[WKActionSheetAssistant _uiMenuElementsForMediaControlContextMenuItems:]):
Add a way to create a separator in the (modern) media controls context menu on iOS.

* Source/WebCore/en.lproj/modern-media-controls-localized-strings.js:
* Source/WebCore/Modules/modern-media-controls/main.js:
(UIString):
Allow for multiple replacements in a single string.

* Source/WebCore/en.lproj/Localizable.strings:
* Source/WebCore/platform/LocalizedStrings.h:
* Source/WebCore/platform/LocalizedStrings.cpp:
(WebCore::contextMenuItemTagShowMediaStats): Added.

Canonical link: https://commits.webkit.org/253583@main
@webkit-commit-queue
Copy link
Collaborator

Committed 253583@main (e5887c7): https://commits.webkit.org/253583@main

Reviewed commits have been landed. Closing PR #3463 and removing active labels.

@webkit-commit-queue webkit-commit-queue removed the merge-queue Applied to send a pull request to merge-queue label Aug 19, 2022
@dcrousso dcrousso deleted the eng/244101 branch August 19, 2022 05:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Media Bugs related to the HTML 5 Media elements.
Projects
None yet
5 participants