Skip to content

Commit

Permalink
Load Media Controls js/css from bundle
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=131086

Reviewed by Eric Carlson.

Source/WebCore:

Rather than embed encoded versions of the JS and CSS files
into C++ source, just load the files directly from the bundle.

* DerivedSources.make: Removed now unnecessary rules.
* WebCore.xcodeproj/project.pbxproj: Copy mediaControls files to the bundle.
* rendering/RenderThemeIOS.h:
* rendering/RenderThemeIOS.mm:
(WebCore::RenderThemeIOS::RenderThemeIOS):
(WebCore::RenderThemeIOS::mediaControlsStyleSheet): Load from the bundle.
(WebCore::RenderThemeIOS::mediaControlsScript): Ditto.
* rendering/RenderThemeMac.h:
* rendering/RenderThemeMac.mm:
(WebCore::RenderThemeMac::RenderThemeMac):
(WebCore::RenderThemeMac::mediaControlsStyleSheet):
(WebCore::RenderThemeMac::mediaControlsScript):

Tools:

We're now putting CSS files into the bundle, so remove the test for them.

* Scripts/check-for-inappropriate-files-in-framework:

Canonical link: https://commits.webkit.org/149173@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@166669 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
grorg committed Apr 2, 2014
1 parent fd539de commit 776749b
Show file tree
Hide file tree
Showing 9 changed files with 92 additions and 22 deletions.
23 changes: 23 additions & 0 deletions Source/WebCore/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,26 @@
2014-04-01 Dean Jackson <dino@apple.com>

Load Media Controls js/css from bundle
https://bugs.webkit.org/show_bug.cgi?id=131086

Reviewed by Eric Carlson.

Rather than embed encoded versions of the JS and CSS files
into C++ source, just load the files directly from the bundle.

* DerivedSources.make: Removed now unnecessary rules.
* WebCore.xcodeproj/project.pbxproj: Copy mediaControls files to the bundle.
* rendering/RenderThemeIOS.h:
* rendering/RenderThemeIOS.mm:
(WebCore::RenderThemeIOS::RenderThemeIOS):
(WebCore::RenderThemeIOS::mediaControlsStyleSheet): Load from the bundle.
(WebCore::RenderThemeIOS::mediaControlsScript): Ditto.
* rendering/RenderThemeMac.h:
* rendering/RenderThemeMac.mm:
(WebCore::RenderThemeMac::RenderThemeMac):
(WebCore::RenderThemeMac::mediaControlsStyleSheet):
(WebCore::RenderThemeMac::mediaControlsScript):

2014-04-02 Daniel Bates <dabates@apple.com>

Move focus management API from HTMLDocument to Document
Expand Down
14 changes: 0 additions & 14 deletions Source/WebCore/DerivedSources.make
Original file line number Diff line number Diff line change
Expand Up @@ -882,13 +882,6 @@ ifeq ($(findstring ENABLE_FULLSCREEN_API,$(FEATURE_DEFINES)), ENABLE_FULLSCREEN_
USER_AGENT_STYLE_SHEETS := $(USER_AGENT_STYLE_SHEETS) $(WebCore)/css/fullscreen.css
endif

ifeq ($(findstring ENABLE_MEDIA_CONTROLS_SCRIPT,$(FEATURE_DEFINES)), ENABLE_MEDIA_CONTROLS_SCRIPT)
USER_AGENT_STYLE_SHEETS := $(USER_AGENT_STYLE_SHEETS) $(WebCore)/Modules/mediacontrols/mediaControlsApple.css
ifeq ($(WTF_PLATFORM_IOS), 1)
USER_AGENT_STYLE_SHEETS := $(USER_AGENT_STYLE_SHEETS) $(WebCore)/Modules/mediacontrols/mediaControlsiOS.css
endif
endif

ifeq ($(findstring ENABLE_IMAGE_CONTROLS,$(FEATURE_DEFINES)), ENABLE_IMAGE_CONTROLS)
USER_AGENT_STYLE_SHEETS := $(USER_AGENT_STYLE_SHEETS) $(WebCore)/html/shadow/mac/imageControlsMac.css
endif
Expand All @@ -906,13 +899,6 @@ UserAgentStyleSheets.h : css/make-css-file-arrays.pl bindings/scripts/preprocess

USER_AGENT_SCRIPTS =

ifeq ($(findstring ENABLE_MEDIA_CONTROLS_SCRIPT,$(FEATURE_DEFINES)), ENABLE_MEDIA_CONTROLS_SCRIPT)
USER_AGENT_SCRIPTS := $(USER_AGENT_SCRIPTS) $(WebCore)/Modules/mediacontrols/mediaControlsApple.js
ifeq ($(WTF_PLATFORM_IOS), 1)
USER_AGENT_SCRIPTS := $(USER_AGENT_SCRIPTS) $(WebCore)/Modules/mediacontrols/mediaControlsiOS.js
endif
endif

ifeq ($(OS),MACOS)
USER_AGENT_SCRIPTS := $(USER_AGENT_SCRIPTS) $(WebCore)/Modules/plugins/QuickTimePluginReplacement.js
endif
Expand Down
8 changes: 8 additions & 0 deletions Source/WebCore/WebCore.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1152,6 +1152,10 @@
31078CC81880AABB008099DC /* OESTextureHalfFloatLinear.h in Headers */ = {isa = PBXBuildFile; fileRef = 31078CC31880A6A6008099DC /* OESTextureHalfFloatLinear.h */; };
31078CC91880AAC9008099DC /* JSOESTextureHalfFloatLinear.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 31078CC51880AAAA008099DC /* JSOESTextureHalfFloatLinear.cpp */; };
31078CCA1880AACE008099DC /* JSOESTextureHalfFloatLinear.h in Headers */ = {isa = PBXBuildFile; fileRef = 31078CC61880AAAA008099DC /* JSOESTextureHalfFloatLinear.h */; };
311C08BD18EB7CAF00B65615 /* mediaControlsApple.css in Resources */ = {isa = PBXBuildFile; fileRef = CDC1DD4117CC2C48008CB55D /* mediaControlsApple.css */; };
311C08BE18EB7CAF00B65615 /* mediaControlsApple.js in Resources */ = {isa = PBXBuildFile; fileRef = CDE6560E17CA6E7600526BA7 /* mediaControlsApple.js */; };
311C08BF18EB7CAF00B65615 /* mediaControlsiOS.css in Resources */ = {isa = PBXBuildFile; fileRef = CDAAF45D1869094E003C1717 /* mediaControlsiOS.css */; };
311C08C018EB7CAF00B65615 /* mediaControlsiOS.js in Resources */ = {isa = PBXBuildFile; fileRef = CD32A189184EB46A0029B1BB /* mediaControlsiOS.js */; };
31288E720E3005D6003619AE /* WebKitCSSKeyframeRule.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 31288E6E0E3005D6003619AE /* WebKitCSSKeyframeRule.cpp */; };
31288E730E3005D6003619AE /* WebKitCSSKeyframeRule.h in Headers */ = {isa = PBXBuildFile; fileRef = 31288E6F0E3005D6003619AE /* WebKitCSSKeyframeRule.h */; };
31288E740E3005D6003619AE /* WebKitCSSKeyframesRule.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 31288E700E3005D6003619AE /* WebKitCSSKeyframesRule.cpp */; };
Expand Down Expand Up @@ -26425,6 +26429,10 @@
2D9F0E1314FF1CBF00BA0FF7 /* linearSRGB.icc in Resources */,
85136C9C0AED665900F90A3D /* linkCursor.png in Resources */,
BCAD180A131C7A0D00990406 /* Localizable.strings in Resources */,
311C08BD18EB7CAF00B65615 /* mediaControlsApple.css in Resources */,
311C08BE18EB7CAF00B65615 /* mediaControlsApple.js in Resources */,
311C08BF18EB7CAF00B65615 /* mediaControlsiOS.css in Resources */,
311C08C018EB7CAF00B65615 /* mediaControlsiOS.js in Resources */,
93153BE214195A5700FCF5BE /* missingImage.png in Resources */,
93153BDA14181F7A00FCF5BE /* missingImage@2x.png in Resources */,
85136C9D0AED665900F90A3D /* moveCursor.png in Resources */,
Expand Down
5 changes: 5 additions & 0 deletions Source/WebCore/rendering/RenderThemeIOS.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,11 @@ class RenderThemeIOS : public RenderTheme {

const Color& shadowColor() const;
FloatRect addRoundedBorderClip(RenderObject* box, GraphicsContext*, const IntRect&);

String m_mediaControlsScript;
String m_mediaControlsStyleSheet;
bool m_mediaControlsScriptLoaded;
bool m_mediaControlsStyleSheetLoaded;
};

}
Expand Down
26 changes: 21 additions & 5 deletions Source/WebCore/rendering/RenderThemeIOS.mm
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,12 @@ + (UIApplication *)sharedApplication;
SOFT_LINK_CONSTANT(UIKit, UIContentSizeCategoryDidChangeNotification, CFStringRef)
#define UIContentSizeCategoryDidChangeNotification getUIContentSizeCategoryDidChangeNotification()

@interface WebCoreRenderThemeBundle : NSObject
@end

@implementation WebCoreRenderThemeBundle
@end

namespace WebCore {

const float ControlBaseHeight = 20;
Expand Down Expand Up @@ -276,6 +282,8 @@ static void contentSizeCategoryDidChange(CFNotificationCenterRef, void*, CFStrin
}

RenderThemeIOS::RenderThemeIOS()
: m_mediaControlsScriptLoaded(false)
, m_mediaControlsStyleSheetLoaded(false)
{
CFNotificationCenterAddObserver(CFNotificationCenterGetLocalCenter(), this, contentSizeCategoryDidChange, UIContentSizeCategoryDidChangeNotification, 0, CFNotificationSuspensionBehaviorDeliverImmediately);
}
Expand Down Expand Up @@ -1197,7 +1205,11 @@ static FontWeight fromCTFontWeight(float fontWeight)
String RenderThemeIOS::mediaControlsStyleSheet()
{
#if ENABLE(MEDIA_CONTROLS_SCRIPT)
return String(mediaControlsiOSUserAgentStyleSheet, sizeof(mediaControlsiOSUserAgentStyleSheet));
if (!m_mediaControlsStyleSheetLoaded) {
m_mediaControlsStyleSheet = [NSString stringWithContentsOfFile:[[NSBundle bundleForClass:[WebCoreRenderThemeBundle class]] pathForResource:@"mediaControlsiOS" ofType:@"css"] encoding:NSUTF8StringEncoding error:nil];
m_mediaControlsStyleSheetLoaded = true;
}
return m_mediaControlsStyleSheet;
#else
return emptyString();
#endif
Expand All @@ -1206,10 +1218,14 @@ static FontWeight fromCTFontWeight(float fontWeight)
String RenderThemeIOS::mediaControlsScript()
{
#if ENABLE(MEDIA_CONTROLS_SCRIPT)
StringBuilder scriptBuilder;
scriptBuilder.append(mediaControlsAppleJavaScript, sizeof(mediaControlsAppleJavaScript));
scriptBuilder.append(mediaControlsiOSJavaScript, sizeof(mediaControlsiOSJavaScript));
return scriptBuilder.toString();
if (!m_mediaControlsScriptLoaded) {
StringBuilder scriptBuilder;
scriptBuilder.append([NSString stringWithContentsOfFile:[[NSBundle bundleForClass:[WebCoreRenderThemeBundle class]] pathForResource:@"mediaControlsApple" ofType:@"js"] encoding:NSUTF8StringEncoding error:nil]);
scriptBuilder.append([NSString stringWithContentsOfFile:[[NSBundle bundleForClass:[WebCoreRenderThemeBundle class]] pathForResource:@"mediaControlsiOS" ofType:@"js"] encoding:NSUTF8StringEncoding error:nil]);
m_mediaControlsScript = scriptBuilder.toString();
m_mediaControlsScriptLoaded = true;
}
return m_mediaControlsScript;
#else
return emptyString();
#endif
Expand Down
5 changes: 5 additions & 0 deletions Source/WebCore/rendering/RenderThemeMac.h
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,11 @@ class RenderThemeMac : public RenderTheme {
mutable HashMap<int, RGBA32> m_systemColorCache;

RetainPtr<WebCoreRenderThemeNotificationObserver> m_notificationObserver;

String m_mediaControlsScript;
String m_mediaControlsStyleSheet;
bool m_mediaControlsScriptLoaded;
bool m_mediaControlsStyleSheetLoaded;
};

} // namespace WebCore
Expand Down
20 changes: 18 additions & 2 deletions Source/WebCore/rendering/RenderThemeMac.mm
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,12 @@ - (CFDictionaryRef)_coreUIDrawOptionsWithFrame:(NSRect)cellFrame inView:(NSView
}
@end

@interface WebCoreRenderThemeBundle : NSObject
@end

@implementation WebCoreRenderThemeBundle
@end

namespace WebCore {

using namespace HTMLNames;
Expand Down Expand Up @@ -198,6 +204,8 @@ - (CFDictionaryRef)_coreUIDrawOptionsWithFrame:(NSRect)cellFrame inView:(NSView
: m_isSliderThumbHorizontalPressed(false)
, m_isSliderThumbVerticalPressed(false)
, m_notificationObserver(adoptNS([[WebCoreRenderThemeNotificationObserver alloc] initWithTheme:this]))
, m_mediaControlsScriptLoaded(false)
, m_mediaControlsStyleSheetLoaded(false)
{
[[NSNotificationCenter defaultCenter] addObserver:m_notificationObserver.get()
selector:@selector(systemColorsDidChange:)
Expand All @@ -220,7 +228,11 @@ - (CFDictionaryRef)_coreUIDrawOptionsWithFrame:(NSRect)cellFrame inView:(NSView
String RenderThemeMac::mediaControlsStyleSheet()
{
#if ENABLE(MEDIA_CONTROLS_SCRIPT)
return String(mediaControlsAppleUserAgentStyleSheet, sizeof(mediaControlsAppleUserAgentStyleSheet));
if (!m_mediaControlsStyleSheetLoaded) {
m_mediaControlsStyleSheet = [NSString stringWithContentsOfFile:[[NSBundle bundleForClass:[WebCoreRenderThemeBundle class]] pathForResource:@"mediaControlsApple" ofType:@"css"] encoding:NSUTF8StringEncoding error:nil];
m_mediaControlsStyleSheetLoaded = true;
}
return m_mediaControlsStyleSheet;
#else
return emptyString();
#endif
Expand All @@ -229,7 +241,11 @@ - (CFDictionaryRef)_coreUIDrawOptionsWithFrame:(NSRect)cellFrame inView:(NSView
String RenderThemeMac::mediaControlsScript()
{
#if ENABLE(MEDIA_CONTROLS_SCRIPT)
return String(mediaControlsAppleJavaScript, sizeof(mediaControlsAppleJavaScript));
if (!m_mediaControlsScriptLoaded) {
m_mediaControlsScript = [NSString stringWithContentsOfFile:[[NSBundle bundleForClass:[WebCoreRenderThemeBundle class]] pathForResource:@"mediaControlsApple" ofType:@"js"] encoding:NSUTF8StringEncoding error:nil];
m_mediaControlsScriptLoaded = true;
}
return m_mediaControlsScript;
#else
return emptyString();
#endif
Expand Down
11 changes: 11 additions & 0 deletions Tools/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
2014-04-01 Dean Jackson <dino@apple.com>

Load Media Controls js/css from bundle
https://bugs.webkit.org/show_bug.cgi?id=131086

Reviewed by Eric Carlson.

We're now putting CSS files into the bundle, so remove the test for them.

* Scripts/check-for-inappropriate-files-in-framework:

2014-04-02 Martin Hock <mhock@apple.com>

Unify private browsing with sessions.
Expand Down
2 changes: 1 addition & 1 deletion Tools/Scripts/check-for-inappropriate-files-in-framework
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ base_directory = ENV['TARGET_BUILD_DIR'] or throw "Unable to find TARGET_BUILD_D
project_name = ENV['PROJECT_NAME'] or throw "Unable to find PROJECT_NAME in the environment!"
is_shallow_bundle = (ENV['SHALLOW_BUNDLE'] || "NO").upcase == "YES"

$INAPPROPRIATE_FILES = { "WebCore" => { "Resources" => ["*.css", "*.in", "*.idl", "*.h"] },
$INAPPROPRIATE_FILES = { "WebCore" => { "Resources" => ["*.in", "*.idl", "*.h"] },
"WebKit2" => { "Resources" => ["*.in", "*.h"] },
}

Expand Down

0 comments on commit 776749b

Please sign in to comment.