RESOLVED FIXED 163502
[Modern Media Controls] Add a MediaControlsHost API to retrieve images as base64
https://bugs.webkit.org/show_bug.cgi?id=163502
Summary [Modern Media Controls] Add a MediaControlsHost API to retrieve images as base64
Antoine Quint
Reported 2016-10-16 06:44:13 PDT
The previous media controls codebase would inline images as base64 in stylesheets, making it hard to version those resources. We could add a new method to MediaControlsHost to obtain the base64 encoded version of a given image so that we could obtain images at runtime from the WebCore bundle.
Attachments
Patch (7.24 KB, patch)
2016-10-16 06:57 PDT, Antoine Quint
no flags
Patch for landing (11.73 KB, patch)
2016-10-17 12:22 PDT, Antoine Quint
no flags
Radar WebKit Bug Importer
Comment 1 2016-10-16 06:44:36 PDT
Antoine Quint
Comment 2 2016-10-16 06:57:59 PDT
Darin Adler
Comment 3 2016-10-16 10:12:39 PDT
Comment on attachment 291747 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=291747&action=review > Source/WebCore/Modules/mediacontrols/MediaControlsHost.cpp:292 > + if (page) > + return RenderTheme::themeForPage(page)->mediaControlsBase64StringForIconAndPlatform(iconName, platform); > + return ""; Early return means error case comes first. Please use emptyString(), rather than "". > Source/WebCore/Modules/mediacontrols/MediaControlsHost.h:85 > + String base64StringForIconAndPlatform(String iconName, String platform) const; Argument types should be const String&, not String. > Source/WebCore/Modules/mediacontrols/MediaControlsHost.idl:63 > + [EnabledAtRuntime=ModernMediaControls] DOMString base64StringForIconAndPlatform(DOMString iconName, DOMString platform); Could be a dangerous API for performance because it loads the file from disk and encodes it every time with no caching.
Antoine Quint
Comment 4 2016-10-16 14:51:28 PDT
(In reply to comment #3) > Comment on attachment 291747 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=291747&action=review > > > Source/WebCore/Modules/mediacontrols/MediaControlsHost.cpp:292 > > + if (page) > > + return RenderTheme::themeForPage(page)->mediaControlsBase64StringForIconAndPlatform(iconName, platform); > > + return ""; > > Early return means error case comes first. Please use emptyString(), rather > than "". Sure thing, will change when landing. > > Source/WebCore/Modules/mediacontrols/MediaControlsHost.h:85 > > + String base64StringForIconAndPlatform(String iconName, String platform) const; > > Argument types should be const String&, not String. Thanks, will change when landing. > > Source/WebCore/Modules/mediacontrols/MediaControlsHost.idl:63 > > + [EnabledAtRuntime=ModernMediaControls] DOMString base64StringForIconAndPlatform(DOMString iconName, DOMString platform); > > Could be a dangerous API for performance because it loads the file from disk > and encodes it every time with no caching. True. I will add caching on the JS side as part of the iconService singleton (see Source/WebCore/Modules/modern-media-controls/controls/icon-service.js). Currently caching is done based on the image URL, but we need to do it based on the iconName / platform pair.
Antoine Quint
Comment 5 2016-10-17 12:22:58 PDT
Created attachment 291856 [details] Patch for landing
WebKit Commit Bot
Comment 6 2016-10-17 12:56:45 PDT
Comment on attachment 291856 [details] Patch for landing Clearing flags on attachment: 291856 Committed r207423: <http://trac.webkit.org/changeset/207423>
WebKit Commit Bot
Comment 7 2016-10-17 12:56:48 PDT
All reviewed patches have been landed. Closing bug.
Note You need to log in before you can comment on or make changes to this bug.