Title: [209441] trunk/Source/WebCore
- Revision
- 209441
- Author
- commit-qu...@webkit.org
- Date
- 2016-12-06 19:03:16 -0800 (Tue, 06 Dec 2016)
Log Message
[Modern Media Controls] Instantiate iOS media controls
https://bugs.webkit.org/show_bug.cgi?id=165498
Patch by Antoine Quint <grao...@apple.com> on 2016-12-06
Reviewed by Dean Jackson.
Add support for the modern media controls runtime flags in RenderThemeIOS and, when instantiating iOS controls,
return an IOSInlineMediaControls class.
* Modules/modern-media-controls/media/media-controller.js:
(MediaController.prototype._controlsClass):
(MediaController):
* rendering/RenderThemeIOS.h:
* rendering/RenderThemeIOS.mm:
(WebCore::RenderThemeIOS::mediaControlsStyleSheet):
(WebCore::RenderThemeIOS::mediaControlsScript):
(WebCore::RenderThemeIOS::mediaControlsBase64StringForIconAndPlatform):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (209440 => 209441)
--- trunk/Source/WebCore/ChangeLog 2016-12-07 02:52:35 UTC (rev 209440)
+++ trunk/Source/WebCore/ChangeLog 2016-12-07 03:03:16 UTC (rev 209441)
@@ -1,3 +1,22 @@
+2016-12-06 Antoine Quint <grao...@apple.com>
+
+ [Modern Media Controls] Instantiate iOS media controls
+ https://bugs.webkit.org/show_bug.cgi?id=165498
+
+ Reviewed by Dean Jackson.
+
+ Add support for the modern media controls runtime flags in RenderThemeIOS and, when instantiating iOS controls,
+ return an IOSInlineMediaControls class.
+
+ * Modules/modern-media-controls/media/media-controller.js:
+ (MediaController.prototype._controlsClass):
+ (MediaController):
+ * rendering/RenderThemeIOS.h:
+ * rendering/RenderThemeIOS.mm:
+ (WebCore::RenderThemeIOS::mediaControlsStyleSheet):
+ (WebCore::RenderThemeIOS::mediaControlsScript):
+ (WebCore::RenderThemeIOS::mediaControlsBase64StringForIconAndPlatform):
+
2016-12-06 Dean Jackson <d...@apple.com>
Apply styling to media documents with modern controls
Modified: trunk/Source/WebCore/Modules/modern-media-controls/media/media-controller.js (209440 => 209441)
--- trunk/Source/WebCore/Modules/modern-media-controls/media/media-controller.js 2016-12-07 02:52:35 UTC (rev 209440)
+++ trunk/Source/WebCore/Modules/modern-media-controls/media/media-controller.js 2016-12-07 03:03:16 UTC (rev 209441)
@@ -129,6 +129,8 @@
_controlsClass()
{
const layoutTraits = this.layoutTraits;
+ if (layoutTraits & LayoutTraits.iOS)
+ return IOSInlineMediaControls;
if (layoutTraits & LayoutTraits.Fullscreen)
return MacOSFullscreenMediaControls;
return MacOSInlineMediaControls;
Modified: trunk/Source/WebCore/rendering/RenderThemeIOS.h (209440 => 209441)
--- trunk/Source/WebCore/rendering/RenderThemeIOS.h 2016-12-07 02:52:35 UTC (rev 209440)
+++ trunk/Source/WebCore/rendering/RenderThemeIOS.h 2016-12-07 03:03:16 UTC (rev 209441)
@@ -108,6 +108,7 @@
#if ENABLE(VIDEO)
String mediaControlsStyleSheet() override;
String mediaControlsScript() override;
+ String mediaControlsBase64StringForIconAndPlatform(const String&, const String&) override;
#endif
#if ENABLE(ATTACHMENT_ELEMENT)
@@ -125,7 +126,9 @@
Color systemColor(CSSValueID) const override;
+ String m_legacyMediaControlsScript;
String m_mediaControlsScript;
+ String m_legacyMediaControlsStyleSheet;
String m_mediaControlsStyleSheet;
mutable HashMap<int, Color> m_systemColorCache;
Modified: trunk/Source/WebCore/rendering/RenderThemeIOS.mm (209440 => 209441)
--- trunk/Source/WebCore/rendering/RenderThemeIOS.mm 2016-12-07 02:52:35 UTC (rev 209440)
+++ trunk/Source/WebCore/rendering/RenderThemeIOS.mm 2016-12-07 03:03:16 UTC (rev 209441)
@@ -62,6 +62,7 @@
#import "RenderStyle.h"
#import "RenderThemeIOS.h"
#import "RenderView.h"
+#import "RuntimeEnabledFeatures.h"
#import "SoftLinking.h"
#import "UIKitSPI.h"
#import "UTIUtilities.h"
@@ -1290,9 +1291,15 @@
String RenderThemeIOS::mediaControlsStyleSheet()
{
#if ENABLE(MEDIA_CONTROLS_SCRIPT)
- if (m_mediaControlsStyleSheet.isEmpty())
- m_mediaControlsStyleSheet = [NSString stringWithContentsOfFile:[[NSBundle bundleForClass:[WebCoreRenderThemeBundle class]] pathForResource:@"mediaControlsiOS" ofType:@"css"] encoding:NSUTF8StringEncoding error:nil];
- return m_mediaControlsStyleSheet;
+ if (RuntimeEnabledFeatures::sharedFeatures().modernMediaControlsEnabled()) {
+ if (m_mediaControlsStyleSheet.isEmpty())
+ m_mediaControlsStyleSheet = [NSString stringWithContentsOfFile:[[NSBundle bundleForClass:[WebCoreRenderThemeBundle class]] pathForResource:@"modern-media-controls" ofType:@"css" inDirectory:@"modern-media-controls"] encoding:NSUTF8StringEncoding error:nil];
+ return m_mediaControlsStyleSheet;
+ }
+
+ if (m_legacyMediaControlsStyleSheet.isEmpty())
+ m_legacyMediaControlsStyleSheet = [NSString stringWithContentsOfFile:[[NSBundle bundleForClass:[WebCoreRenderThemeBundle class]] pathForResource:@"mediaControlsiOS" ofType:@"css"] encoding:NSUTF8StringEncoding error:nil];
+ return m_legacyMediaControlsStyleSheet;
#else
return emptyString();
#endif
@@ -1301,19 +1308,48 @@
String RenderThemeIOS::mediaControlsScript()
{
#if ENABLE(MEDIA_CONTROLS_SCRIPT)
- if (m_mediaControlsScript.isEmpty()) {
+ if (RuntimeEnabledFeatures::sharedFeatures().modernMediaControlsEnabled()) {
+ if (m_mediaControlsScript.isEmpty()) {
+ NSBundle *bundle = [NSBundle bundleForClass:[WebCoreRenderThemeBundle class]];
+
+ StringBuilder scriptBuilder;
+ scriptBuilder.append([NSString stringWithContentsOfFile:[bundle pathForResource:@"modern-media-controls-localized-strings.js" ofType:@"js"] encoding:NSUTF8StringEncoding error:nil]);
+ scriptBuilder.append([NSString stringWithContentsOfFile:[bundle pathForResource:@"modern-media-controls" ofType:@"js" inDirectory:@"modern-media-controls"] encoding:NSUTF8StringEncoding error:nil]);
+ m_mediaControlsScript = scriptBuilder.toString();
+ }
+ return m_mediaControlsScript;
+ }
+
+ if (m_legacyMediaControlsScript.isEmpty()) {
+ NSBundle *bundle = [NSBundle bundleForClass:[WebCoreRenderThemeBundle class]];
+
StringBuilder scriptBuilder;
- NSBundle* bundle = [NSBundle bundleForClass:[WebCoreRenderThemeBundle class]];
scriptBuilder.append([NSString stringWithContentsOfFile:[bundle pathForResource:@"mediaControlsLocalizedStrings" ofType:@"js"] encoding:NSUTF8StringEncoding error:nil]);
scriptBuilder.append([NSString stringWithContentsOfFile:[bundle pathForResource:@"mediaControlsApple" ofType:@"js"] encoding:NSUTF8StringEncoding error:nil]);
scriptBuilder.append([NSString stringWithContentsOfFile:[bundle pathForResource:@"mediaControlsiOS" ofType:@"js"] encoding:NSUTF8StringEncoding error:nil]);
- m_mediaControlsScript = scriptBuilder.toString();
+
+ m_legacyMediaControlsScript = scriptBuilder.toString();
}
- return m_mediaControlsScript;
+ return m_legacyMediaControlsScript;
#else
return emptyString();
#endif
}
+
+String RenderThemeIOS::mediaControlsBase64StringForIconAndPlatform(const String& iconName, const String& platform)
+{
+#if ENABLE(MEDIA_CONTROLS_SCRIPT)
+ if (!RuntimeEnabledFeatures::sharedFeatures().modernMediaControlsEnabled())
+ return emptyString();
+
+ String directory = "modern-media-controls/images/" + platform;
+ NSBundle *bundle = [NSBundle bundleForClass:[WebCoreRenderThemeBundle class]];
+ return [[NSData dataWithContentsOfFile:[bundle pathForResource:iconName ofType:@"png" inDirectory:directory]] base64EncodedStringWithOptions:0];
+#else
+ return emptyString();
+#endif
+}
+
#endif // ENABLE(VIDEO)
Color RenderThemeIOS::systemColor(CSSValueID cssValueID) const
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes