[Modern Media Controls] Allow non-PNG resources
authorgraouts@webkit.org <graouts@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 19 Apr 2017 14:57:52 +0000 (14:57 +0000)
committergraouts@webkit.org <graouts@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 19 Apr 2017 14:57:52 +0000 (14:57 +0000)
https://bugs.webkit.org/show_bug.cgi?id=170992
<rdar://problem/31706590>

Reviewed by Dean Jackson.

Instead of passing in a name and a platform to MediaControlsHost::base64StringForIconAndPlatform(),
we now pass in a name and a type to MediaControlsHost::base64StringForIconNameAndType(). We've removed
the need to provide a platform by copying the resources directly under "Resources/modern-media-controls"
insted of "Resources/modern-media-controls/platform-name-here", and now we provide a type so that it
may be passed down to -[NSBundle pathForResource:ofType:inDirectory:].

* Modules/mediacontrols/MediaControlsHost.cpp:
(WebCore::MediaControlsHost::base64StringForIconNameAndType):
(WebCore::MediaControlsHost::base64StringForIconAndPlatform): Deleted.
* Modules/mediacontrols/MediaControlsHost.h:
* Modules/mediacontrols/MediaControlsHost.idl:
* Modules/modern-media-controls/controls/icon-service.js:
(const.iconService.new.IconService.prototype.imageForIconNameAndLayoutTraits):
* WebCore.xcodeproj/project.pbxproj:
* rendering/RenderTheme.h:
(WebCore::RenderTheme::mediaControlsBase64StringForIconNameAndType):
(WebCore::RenderTheme::mediaControlsBase64StringForIconAndPlatform): Deleted.
* rendering/RenderThemeIOS.h:
* rendering/RenderThemeIOS.mm:
(WebCore::RenderThemeIOS::mediaControlsBase64StringForIconNameAndType):
(WebCore::RenderThemeIOS::mediaControlsBase64StringForIconAndPlatform): Deleted.
* rendering/RenderThemeMac.h:
* rendering/RenderThemeMac.mm:
(WebCore::RenderThemeMac::mediaControlsBase64StringForIconNameAndType):
(WebCore::RenderThemeMac::mediaControlsBase64StringForIconAndPlatform): Deleted.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@215509 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/Modules/mediacontrols/MediaControlsHost.cpp
Source/WebCore/Modules/mediacontrols/MediaControlsHost.h
Source/WebCore/Modules/mediacontrols/MediaControlsHost.idl
Source/WebCore/Modules/modern-media-controls/controls/icon-service.js
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/rendering/RenderTheme.h
Source/WebCore/rendering/RenderThemeIOS.h
Source/WebCore/rendering/RenderThemeIOS.mm
Source/WebCore/rendering/RenderThemeMac.h
Source/WebCore/rendering/RenderThemeMac.mm

index f88ef80..019ea6c 100644 (file)
@@ -1,3 +1,37 @@
+2017-04-19  Antoine Quint  <graouts@apple.com>
+
+        [Modern Media Controls] Allow non-PNG resources
+        https://bugs.webkit.org/show_bug.cgi?id=170992
+        <rdar://problem/31706590>
+
+        Reviewed by Dean Jackson.
+
+        Instead of passing in a name and a platform to MediaControlsHost::base64StringForIconAndPlatform(),
+        we now pass in a name and a type to MediaControlsHost::base64StringForIconNameAndType(). We've removed
+        the need to provide a platform by copying the resources directly under "Resources/modern-media-controls"
+        insted of "Resources/modern-media-controls/platform-name-here", and now we provide a type so that it
+        may be passed down to -[NSBundle pathForResource:ofType:inDirectory:].
+
+        * Modules/mediacontrols/MediaControlsHost.cpp:
+        (WebCore::MediaControlsHost::base64StringForIconNameAndType):
+        (WebCore::MediaControlsHost::base64StringForIconAndPlatform): Deleted.
+        * Modules/mediacontrols/MediaControlsHost.h:
+        * Modules/mediacontrols/MediaControlsHost.idl:
+        * Modules/modern-media-controls/controls/icon-service.js:
+        (const.iconService.new.IconService.prototype.imageForIconNameAndLayoutTraits):
+        * WebCore.xcodeproj/project.pbxproj:
+        * rendering/RenderTheme.h:
+        (WebCore::RenderTheme::mediaControlsBase64StringForIconNameAndType):
+        (WebCore::RenderTheme::mediaControlsBase64StringForIconAndPlatform): Deleted.
+        * rendering/RenderThemeIOS.h:
+        * rendering/RenderThemeIOS.mm:
+        (WebCore::RenderThemeIOS::mediaControlsBase64StringForIconNameAndType):
+        (WebCore::RenderThemeIOS::mediaControlsBase64StringForIconAndPlatform): Deleted.
+        * rendering/RenderThemeMac.h:
+        * rendering/RenderThemeMac.mm:
+        (WebCore::RenderThemeMac::mediaControlsBase64StringForIconNameAndType):
+        (WebCore::RenderThemeMac::mediaControlsBase64StringForIconAndPlatform): Deleted.
+
 2017-04-19  Antti Koivisto  <antti@apple.com>
 
         Avoid repaints for invisible animations on tumblr.com/search/aww
index c49969e..eeead0d 100644 (file)
@@ -286,12 +286,12 @@ String MediaControlsHost::shadowRootCSSText() const
     return RenderTheme::themeForPage(page)->modernMediaControlsStyleSheet();
 }
 
-String MediaControlsHost::base64StringForIconAndPlatform(const String& iconName, const String& platform) const
+String MediaControlsHost::base64StringForIconNameAndType(const String& iconName, const String& iconType) const
 {
     Page* page = m_mediaElement->document().page();
     if (!page)
         return emptyString();
-    return RenderTheme::themeForPage(page)->mediaControlsBase64StringForIconAndPlatform(iconName, platform);
+    return RenderTheme::themeForPage(page)->mediaControlsBase64StringForIconNameAndType(iconName, iconType);
 }
 
 }
index 741f2f7..ebe2ed0 100644 (file)
@@ -88,7 +88,7 @@ public:
     String generateUUID() const;
 
     String shadowRootCSSText() const;
-    String base64StringForIconAndPlatform(const String& iconName, const String& platform) const;
+    String base64StringForIconNameAndType(const String& iconName, const String& iconType) const;
 
 private:
     MediaControlsHost(HTMLMediaElement*);
index a87bda4..fbbd4e8 100644 (file)
@@ -62,5 +62,5 @@ enum DeviceType {
     DOMString generateUUID();
 
     [EnabledAtRuntime=ModernMediaControls] readonly attribute DOMString shadowRootCSSText;
-    [EnabledAtRuntime=ModernMediaControls] DOMString base64StringForIconAndPlatform(DOMString iconName, DOMString platform);
+    [EnabledAtRuntime=ModernMediaControls] DOMString base64StringForIconNameAndType(DOMString iconName, DOMString iconType);
 };
index da00a61..16e2056 100644 (file)
@@ -70,7 +70,7 @@ const iconService = new class IconService {
         image = this.images[path] = new Image;
 
         if (this.mediaControlsHost)
-            image.src = "data:image/png;base64," + this.mediaControlsHost.base64StringForIconAndPlatform(fileName, platform);
+            image.src = "data:image/png;base64," + this.mediaControlsHost.base64StringForIconNameAndType(fileName, "png");
         else
             image.src = `${this.directoryPath}/${path}`;
 
index 30482c9..7eb53fd 100644 (file)
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                        shellPath = /bin/sh;
-                       shellScript = "WKA_DIR=\"$BUILT_PRODUCTS_DIR/usr/local/include/WebKitAdditions/modern-media-controls\"\nSRC_DIR=\"$SRCROOT/Modules/modern-media-controls\"\nDST_DIR=\"$BUILT_PRODUCTS_DIR/$UNLOCALIZED_RESOURCES_FOLDER_PATH/modern-media-controls\"\n\nif [ -d \"$WKA_DIR\" ]; then\n    MMC_DIR=$WKA_DIR;\nelse\n    MMC_DIR=$SRC_DIR\nfi\n\nmkdir -p \"$DST_DIR\"\n\nif [ \"${PLATFORM_NAME}\" == \"macosx\" ]; then\n    IMG_OS_PREFIX=\"macOS\"\nfi\n\nif [ \"${PLATFORM_NAME}\" == \"iphoneos\" ] || [ \"${PLATFORM_NAME}\" == \"iphonesimulator\" ]; then\n    IMG_OS_PREFIX=\"iOS\"\nfi\n\nif [ -n \"$IMG_OS_PREFIX\" ]; then\n    mkdir -p \"$DST_DIR/images\"\n    rsync -aq --exclude \".svn\" --exclude \".DS_Store\" \"$MMC_DIR/images/$IMG_OS_PREFIX\" \"$DST_DIR/images\"\nfi\n\ncd \"$MMC_DIR\"\ncat controls/*.css > \"$DST_DIR/modern-media-controls.css\"\ncat `cat js-files` > \"$DST_DIR/modern-media-controls.js\"";
+                       shellScript = "WKA_DIR=\"$BUILT_PRODUCTS_DIR/usr/local/include/WebKitAdditions/modern-media-controls\"\nSRC_DIR=\"$SRCROOT/Modules/modern-media-controls\"\nDST_DIR=\"$BUILT_PRODUCTS_DIR/$UNLOCALIZED_RESOURCES_FOLDER_PATH/modern-media-controls\"\n\nif [ -d \"$WKA_DIR\" ]; then\n    MMC_DIR=$WKA_DIR;\nelse\n    MMC_DIR=$SRC_DIR\nfi\n\nmkdir -p \"$DST_DIR\"\n\nif [ \"${PLATFORM_NAME}\" == \"macosx\" ]; then\n    IMG_OS_PREFIX=\"macOS\"\nfi\n\nif [ \"${PLATFORM_NAME}\" == \"iphoneos\" ] || [ \"${PLATFORM_NAME}\" == \"iphonesimulator\" ]; then\n    IMG_OS_PREFIX=\"iOS\"\nfi\n\nif [ -n \"$IMG_OS_PREFIX\" ]; then\n    rsync -aq --exclude \".svn\" --exclude \".DS_Store\" \"$MMC_DIR/images/$IMG_OS_PREFIX/\" \"$DST_DIR/images\"\nfi\n\ncd \"$MMC_DIR\"\ncat controls/*.css > \"$DST_DIR/modern-media-controls.css\"\ncat `cat js-files` > \"$DST_DIR/modern-media-controls.js\"";
                };
                A5E79CEC1E67F2CF00FB8153 /* Make Frameworks Symbolic Link */ = {
                        isa = PBXShellScriptBuildPhase;
index 617cadb..873c1b0 100644 (file)
@@ -101,7 +101,7 @@ public:
     virtual String modernMediaControlsStyleSheet() { return String(); }
     virtual String extraMediaControlsStyleSheet() { return String(); }
     virtual String mediaControlsScript() { return String(); }
-    virtual String mediaControlsBase64StringForIconAndPlatform(const String&, const String&) { return String(); }
+    virtual String mediaControlsBase64StringForIconNameAndType(const String&, const String&) { return String(); }
 #endif
 #if ENABLE(FULLSCREEN_API)
     virtual String extraFullScreenStyleSheet() { return String(); }
index 0b1e545..b7fd985 100644 (file)
@@ -109,7 +109,7 @@ protected:
     String mediaControlsStyleSheet() override;
     String modernMediaControlsStyleSheet() override;
     String mediaControlsScript() override;
-    String mediaControlsBase64StringForIconAndPlatform(const String&, const String&) override;
+    String mediaControlsBase64StringForIconNameAndType(const String&, const String&) override;
 #endif
 
 #if ENABLE(ATTACHMENT_ELEMENT)
index d9f4f77..e0c8e40 100644 (file)
@@ -1372,15 +1372,15 @@ String RenderThemeIOS::mediaControlsScript()
 #endif
 }
 
-String RenderThemeIOS::mediaControlsBase64StringForIconAndPlatform(const String& iconName, const String& platform)
+String RenderThemeIOS::mediaControlsBase64StringForIconNameAndType(const String& iconName, const String& iconType)
 {
 #if ENABLE(MEDIA_CONTROLS_SCRIPT)
     if (!RuntimeEnabledFeatures::sharedFeatures().modernMediaControlsEnabled())
         return emptyString();
 
-    String directory = "modern-media-controls/images/" + platform;
+    String directory = "modern-media-controls/images";
     NSBundle *bundle = [NSBundle bundleForClass:[WebCoreRenderThemeBundle class]];
-    return [[NSData dataWithContentsOfFile:[bundle pathForResource:iconName ofType:@"png" inDirectory:directory]] base64EncodedStringWithOptions:0];
+    return [[NSData dataWithContentsOfFile:[bundle pathForResource:iconName ofType:iconType inDirectory:directory]] base64EncodedStringWithOptions:0];
 #else
     return emptyString();
 #endif
index f3900a0..1d4532d 100644 (file)
@@ -109,7 +109,7 @@ protected:
     String mediaControlsStyleSheet() override;
     String modernMediaControlsStyleSheet() override;
     String mediaControlsScript() override;
-    String mediaControlsBase64StringForIconAndPlatform(const String&, const String&) override;
+    String mediaControlsBase64StringForIconNameAndType(const String&, const String&) override;
 #endif
 
 #if ENABLE(SERVICE_CONTROLS)
index 9b55ef6..efc98f0 100644 (file)
@@ -292,15 +292,15 @@ String RenderThemeMac::mediaControlsScript()
 #endif
 }
 
-String RenderThemeMac::mediaControlsBase64StringForIconAndPlatform(const String& iconName, const String& platform)
+String RenderThemeMac::mediaControlsBase64StringForIconNameAndType(const String& iconName, const String& iconType)
 {
 #if ENABLE(MEDIA_CONTROLS_SCRIPT)
     if (!RuntimeEnabledFeatures::sharedFeatures().modernMediaControlsEnabled())
         return emptyString();
 
-    String directory = "modern-media-controls/images/" + platform;
+    String directory = "modern-media-controls/images";
     NSBundle *bundle = [NSBundle bundleForClass:[WebCoreRenderThemeBundle class]];
-    return [[NSData dataWithContentsOfFile:[bundle pathForResource:iconName ofType:@"png" inDirectory:directory]] base64EncodedStringWithOptions:0];
+    return [[NSData dataWithContentsOfFile:[bundle pathForResource:iconName ofType:iconType inDirectory:directory]] base64EncodedStringWithOptions:0];
 #else
     return emptyString();
 #endif