Skip to content

Commit

Permalink
Revert of Move the user agent styles sheets to blink_resources.grd (P…
Browse files Browse the repository at this point in the history
…art 3) (patchset #10 id:260001 of https://codereview.chromium.org/438843004/)

Reason for revert:
Speculative revert for breaking quite a few browser_tests and content_browsertests across multiple platforms:
https://build.chromium.org/p/chromium.webkit/builders/Mac10.6%20Tests/builds/26427
http://build.chromium.org/p/chromium.webkit/builders/Mac10.8%20Tests/builds/9662
http://build.chromium.org/p/chromium.webkit/builders/Win7%20Tests/builds/5566


Original issue's description:
> Move the user agent styles sheets to blink_resources.grd (Part 3)
> 
> Blink should make use of blink_resources.grd for the inline resources of user agent stylesheets.
> This removes the dependency upon using make-file-arrays.py which embeds these resources as strings. 
> 
> Also the .rodata section of libblink_web (in component build mode) is reduced by ~33kb.
> 
> Part 1: https://codereview.chromium.org/436843004/
> Part 2: https://codereview.chromium.org/422023008
> Part 2 Unit Test support: https://codereview.chromium.org/456413002/
> 
> BUG=312586
> 
> Committed: https://src.chromium.org/viewvc/blink?view=rev&revision=181917

[email protected],[email protected],[email protected],[email protected],[email protected]
NOTREECHECKS=true
NOTRY=true
BUG=312586

Review URL: https://codereview.chromium.org/567073004

git-svn-id: svn://svn.chromium.org/blink/trunk@181938 bbb929c8-8fbe-4397-9dbb-9b2b20218538
  • Loading branch information
jianli-chromium committed Sep 12, 2014
1 parent b040a1d commit 0bf4bb0
Show file tree
Hide file tree
Showing 10 changed files with 127 additions and 31 deletions.
44 changes: 44 additions & 0 deletions Source/core/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,7 @@ source_set("core_generated") {
"$blink_core_output_dir/InputTypeNames.cpp",
"$blink_core_output_dir/MathMLNames.cpp",
"$blink_core_output_dir/SVGNames.cpp",
"$blink_core_output_dir/UserAgentStyleSheetsData.cpp",
"$blink_core_output_dir/XLinkNames.cpp",
"$blink_core_output_dir/XMLNSNames.cpp",
"$blink_core_output_dir/XMLNames.cpp",
Expand Down Expand Up @@ -570,6 +571,7 @@ group("make_core_generated") {
":make_core_generated_event_names",
":make_core_generated_event_target_names",
":make_core_generated_math_ml_names",
":make_core_generated_user_agent_style_sheets",
":make_core_generated_fetch_initiator_type_names",
":make_core_generated_event_type_names",
":make_core_generated_html_tokenizer_names",
Expand Down Expand Up @@ -982,6 +984,48 @@ action("make_core_generated_media_query_tokenizer_codepoints") {
deps = make_core_generated_deps
}

# "UserAgentStyleSheets" in make_core_generated from GYP.
action("make_core_generated_user_agent_style_sheets") {
visibility = [] # Allow re-assignment of list.
visibility = [ ":make_core_generated" ]
script = "../build/scripts/make-file-arrays.py"

inputs = [
"css/html.css",
"css/quirks.css",
"css/view-source.css",
"css/themeChromium.css",
"css/themeChromiumAndroid.css",
"css/themeChromiumLinux.css",
"css/themeChromiumSkia.css",
"css/themeInputMultipleFields.css",
"css/themeMac.css",
"css/themeWin.css",
"css/themeWinQuirks.css",
"css/svg.css",
"css/navigationTransitions.css",
"css/mathml.css",
"css/mediaControls.css",
"css/mediaControlsAndroid.css",
"css/fullscreen.css",
"css/xhtmlmp.css",
"css/viewportAndroid.css",
]

outputs = [
"$blink_core_output_dir/UserAgentStyleSheets.h",
"$blink_core_output_dir/UserAgentStyleSheetsData.cpp",
]

args =
[ "--namespace", "blink" ] +
[ "--out-h=" + rebase_path(outputs[0], root_build_dir) ] +
[ "--out-cpp=" + rebase_path(outputs[1], root_build_dir) ] +
rebase_path(inputs, root_build_dir)

deps = make_core_generated_deps
}

# "HTMLElementLookupTrie" in make_core_generated from GYP.
action("make_core_generated_html_element_lookup_trie") {
visibility = [] # Allow re-assignment of list.
Expand Down
1 change: 1 addition & 0 deletions Source/core/core.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@
'<(blink_core_output_dir)/InputTypeNames.cpp',
'<(blink_core_output_dir)/MathMLNames.cpp',
'<(blink_core_output_dir)/SVGNames.cpp',
'<(blink_core_output_dir)/UserAgentStyleSheetsData.cpp',
'<(blink_core_output_dir)/XLinkNames.cpp',
'<(blink_core_output_dir)/XMLNSNames.cpp',
'<(blink_core_output_dir)/XMLNames.cpp',
Expand Down
46 changes: 46 additions & 0 deletions Source/core/core_generated.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,52 @@
'<(blink_core_output_dir)',
],
},
{
'action_name': 'UserAgentStyleSheets',
'variables': {
'scripts': [
'../build/scripts/make-file-arrays.py',
],
'stylesheets': [
'css/html.css',
'css/quirks.css',
'css/view-source.css',
'css/themeChromium.css',
'css/themeChromiumAndroid.css',
'css/themeChromiumLinux.css',
'css/themeChromiumSkia.css',
'css/themeInputMultipleFields.css',
'css/themeMac.css',
'css/themeWin.css',
'css/themeWinQuirks.css',
'css/svg.css',
'css/navigationTransitions.css',
'css/mathml.css',
'css/mediaControls.css',
'css/mediaControlsAndroid.css',
'css/fullscreen.css',
'css/xhtmlmp.css',
'css/viewportAndroid.css',
],
},
'inputs': [
'<@(scripts)',
'<@(stylesheets)'
],
'outputs': [
'<(blink_core_output_dir)/UserAgentStyleSheets.h',
'<(blink_core_output_dir)/UserAgentStyleSheetsData.cpp',
],
'action': [
'python',
'<@(scripts)',
'--namespace',
'blink',
'--out-h=<(blink_core_output_dir)/UserAgentStyleSheets.h',
'--out-cpp=<(blink_core_output_dir)/UserAgentStyleSheetsData.cpp',
'<@(stylesheets)',
],
},
{
'action_name': 'FetchInitiatorTypeNames',
'inputs': [
Expand Down
27 changes: 16 additions & 11 deletions Source/core/css/CSSDefaultStyleSheets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@
#include "core/css/CSSDefaultStyleSheets.h"

#include "core/MathMLNames.h"
#include "core/UserAgentStyleSheets.h"
#include "core/css/MediaQueryEvaluator.h"
#include "core/css/RuleSet.h"
#include "core/css/StyleSheetContents.h"
#include "core/dom/Fullscreen.h"
#include "core/html/HTMLAnchorElement.h"
#include "core/html/HTMLHtmlElement.h"
#include "core/rendering/RenderTheme.h"
#include "platform/PlatformResourceLoader.h"
#include "wtf/LeakAnnotations.h"

namespace blink {
Expand Down Expand Up @@ -72,6 +72,11 @@ static PassRefPtrWillBeRawPtr<StyleSheetContents> parseUASheet(const String& str
return sheet.release();
}

static PassRefPtrWillBeRawPtr<StyleSheetContents> parseUASheet(const char* characters, unsigned size)
{
return parseUASheet(String(characters, size));
}

CSSDefaultStyleSheets::CSSDefaultStyleSheets()
: m_defaultStyle(nullptr)
, m_defaultViewportStyle(nullptr)
Expand All @@ -94,11 +99,11 @@ CSSDefaultStyleSheets::CSSDefaultStyleSheets()
m_defaultQuirksStyle = RuleSet::create();

// Strict-mode rules.
String defaultRules = loadResourceAsASCIIString("html.css") + RenderTheme::theme().extraDefaultStyleSheet();
String defaultRules = String(htmlCss, sizeof(htmlCss)) + RenderTheme::theme().extraDefaultStyleSheet();
m_defaultStyleSheet = parseUASheet(defaultRules);
m_defaultStyle->addRulesFromSheet(defaultStyleSheet(), screenEval());
#if OS(ANDROID)
String viewportRules = loadResourceAsASCIIString("viewportAndroid.css");
String viewportRules(viewportAndroidCss, sizeof(viewportAndroidCss));
#else
String viewportRules;
#endif
Expand All @@ -107,7 +112,7 @@ CSSDefaultStyleSheets::CSSDefaultStyleSheets()
m_defaultPrintStyle->addRulesFromSheet(defaultStyleSheet(), printEval());

// Quirks-mode rules.
String quirksRules = loadResourceAsASCIIString("quirks.css") + RenderTheme::theme().extraQuirksStyleSheet();
String quirksRules = String(quirksCss, sizeof(quirksCss)) + RenderTheme::theme().extraQuirksStyleSheet();
m_quirksStyleSheet = parseUASheet(quirksRules);
m_defaultQuirksStyle->addRulesFromSheet(quirksStyleSheet(), screenEval());
}
Expand All @@ -117,7 +122,7 @@ RuleSet* CSSDefaultStyleSheets::defaultViewSourceStyle()
if (!m_defaultViewSourceStyle) {
m_defaultViewSourceStyle = RuleSet::create();
// Loaded stylesheet is leaked on purpose.
RefPtrWillBeRawPtr<StyleSheetContents> stylesheet = parseUASheet(loadResourceAsASCIIString("view-source.css"));
RefPtrWillBeRawPtr<StyleSheetContents> stylesheet = parseUASheet(viewSourceCss, sizeof(viewSourceCss));
m_defaultViewSourceStyle->addRulesFromSheet(stylesheet.release().leakRef(), screenEval());
}
return m_defaultViewSourceStyle.get();
Expand All @@ -128,7 +133,7 @@ RuleSet* CSSDefaultStyleSheets::defaultTransitionStyle()
if (!m_defaultTransitionStyle) {
m_defaultTransitionStyle = RuleSet::create();
// Loaded stylesheet is leaked on purpose.
RefPtrWillBeRawPtr<StyleSheetContents> stylesheet = parseUASheet(loadResourceAsASCIIString("navigationTransitions.css"));
RefPtrWillBeRawPtr<StyleSheetContents> stylesheet = parseUASheet(navigationTransitionsCss, sizeof(navigationTransitionsCss));
m_defaultTransitionStyle->addRulesFromSheet(stylesheet.release().leakRef(), screenEval());
}
return m_defaultTransitionStyle.get();
Expand All @@ -139,7 +144,7 @@ RuleSet* CSSDefaultStyleSheets::defaultXHTMLMobileProfileStyle()
if (!m_defaultXHTMLMobileProfileStyle) {
m_defaultXHTMLMobileProfileStyle = RuleSet::create();
// Loaded stylesheet is leaked on purpose.
RefPtrWillBeRawPtr<StyleSheetContents> stylesheet = parseUASheet(loadResourceAsASCIIString("xhtmlmp.css"));
RefPtrWillBeRawPtr<StyleSheetContents> stylesheet = parseUASheet(xhtmlmpCss, sizeof(xhtmlmpCss));
m_defaultXHTMLMobileProfileStyle->addRulesFromSheet(stylesheet.release().leakRef(), screenEval());
}
return m_defaultXHTMLMobileProfileStyle.get();
Expand All @@ -149,7 +154,7 @@ void CSSDefaultStyleSheets::ensureDefaultStyleSheetsForElement(Element* element,
{
// FIXME: We should assert that the sheet only styles SVG elements.
if (element->isSVGElement() && !m_svgStyleSheet) {
m_svgStyleSheet = parseUASheet(loadResourceAsASCIIString("svg.css"));
m_svgStyleSheet = parseUASheet(svgCss, sizeof(svgCss));
m_defaultStyle->addRulesFromSheet(svgStyleSheet(), screenEval());
m_defaultPrintStyle->addRulesFromSheet(svgStyleSheet(), printEval());
changedDefaultStyle = true;
Expand All @@ -158,15 +163,15 @@ void CSSDefaultStyleSheets::ensureDefaultStyleSheetsForElement(Element* element,
// FIXME: We should assert that the sheet only styles MathML elements.
if (element->namespaceURI() == MathMLNames::mathmlNamespaceURI
&& !m_mathmlStyleSheet) {
m_mathmlStyleSheet = parseUASheet(loadResourceAsASCIIString("mathml.css"));
m_mathmlStyleSheet = parseUASheet(mathmlCss, sizeof(mathmlCss));
m_defaultStyle->addRulesFromSheet(mathmlStyleSheet(), screenEval());
m_defaultPrintStyle->addRulesFromSheet(mathmlStyleSheet(), printEval());
changedDefaultStyle = true;
}

// FIXME: We should assert that this sheet only contains rules for <video> and <audio>.
if (!m_mediaControlsStyleSheet && (isHTMLVideoElement(*element) || isHTMLAudioElement(*element))) {
String mediaRules = loadResourceAsASCIIString("mediaControls.css") + RenderTheme::theme().extraMediaControlsStyleSheet();
String mediaRules = String(mediaControlsCss, sizeof(mediaControlsCss)) + RenderTheme::theme().extraMediaControlsStyleSheet();
m_mediaControlsStyleSheet = parseUASheet(mediaRules);
m_defaultStyle->addRulesFromSheet(mediaControlsStyleSheet(), screenEval());
m_defaultPrintStyle->addRulesFromSheet(mediaControlsStyleSheet(), printEval());
Expand All @@ -176,7 +181,7 @@ void CSSDefaultStyleSheets::ensureDefaultStyleSheetsForElement(Element* element,
// FIXME: This only works because we Force recalc the entire document so the new sheet
// is loaded for <html> and the correct styles apply to everyone.
if (!m_fullscreenStyleSheet && Fullscreen::isFullScreen(element->document())) {
String fullscreenRules = loadResourceAsASCIIString("fullscreen.css") + RenderTheme::theme().extraFullScreenStyleSheet();
String fullscreenRules = String(fullscreenCss, sizeof(fullscreenCss)) + RenderTheme::theme().extraFullScreenStyleSheet();
m_fullscreenStyleSheet = parseUASheet(fullscreenRules);
m_defaultStyle->addRulesFromSheet(fullscreenStyleSheet(), screenEval());
m_defaultQuirksStyle->addRulesFromSheet(fullscreenStyleSheet(), screenEval());
Expand Down
4 changes: 2 additions & 2 deletions Source/core/inspector/InspectorPageAgent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include "bindings/core/v8/ScriptController.h"
#include "bindings/core/v8/ScriptRegexp.h"
#include "core/HTMLNames.h"
#include "core/UserAgentStyleSheets.h"
#include "core/css/StyleSheetContents.h"
#include "core/css/resolver/StyleResolver.h"
#include "core/css/resolver/ViewportStyleResolver.h"
Expand Down Expand Up @@ -73,7 +74,6 @@
#include "core/page/Page.h"
#include "platform/Cookie.h"
#include "platform/JSONValues.h"
#include "platform/PlatformResourceLoader.h"
#include "platform/UserGestureIndicator.h"
#include "platform/weborigin/SecurityOrigin.h"
#include "wtf/CurrentTime.h"
Expand Down Expand Up @@ -1418,7 +1418,7 @@ bool InspectorPageAgent::applyViewportStyleOverride(StyleResolver* resolver)
return false;

RefPtrWillBeRawPtr<StyleSheetContents> styleSheet = StyleSheetContents::create(CSSParserContext(UASheetMode, 0));
styleSheet->parseString(loadResourceAsASCIIString("viewportAndroid.css"));
styleSheet->parseString(String(viewportAndroidCss, sizeof(viewportAndroidCss)));
OwnPtrWillBeRawPtr<RuleSet> ruleSet = RuleSet::create();
ruleSet->addRulesFromSheet(styleSheet.get(), MediaQueryEvaluator("screen"));
resolver->viewportStyleResolver()->collectViewportRules(ruleSet.get(), ViewportStyleResolver::UserAgentOrigin);
Expand Down
6 changes: 3 additions & 3 deletions Source/core/rendering/RenderThemeChromiumAndroid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@

#include "core/CSSValueKeywords.h"
#include "core/InputTypeNames.h"
#include "core/UserAgentStyleSheets.h"
#include "core/rendering/PaintInfo.h"
#include "core/rendering/RenderMediaControls.h"
#include "core/rendering/RenderObject.h"
#include "core/rendering/RenderProgress.h"
#include "core/rendering/RenderSlider.h"
#include "platform/LayoutTestSupport.h"
#include "platform/PlatformResourceLoader.h"
#include "platform/graphics/Color.h"
#include "platform/scroll/ScrollbarTheme.h"
#include "public/platform/Platform.h"
Expand All @@ -60,13 +60,13 @@ RenderThemeChromiumAndroid::~RenderThemeChromiumAndroid()

String RenderThemeChromiumAndroid::extraMediaControlsStyleSheet()
{
return loadResourceAsASCIIString("mediaControlsAndroid.css");
return String(mediaControlsAndroidCss, sizeof(mediaControlsAndroidCss));
}

String RenderThemeChromiumAndroid::extraDefaultStyleSheet()
{
return RenderThemeChromiumDefault::extraDefaultStyleSheet() +
loadResourceAsASCIIString("themeChromiumAndroid.css");
String(themeChromiumAndroidCss, sizeof(themeChromiumAndroidCss));
}

void RenderThemeChromiumAndroid::adjustInnerSpinButtonStyle(RenderStyle* style, Element*) const
Expand Down
8 changes: 4 additions & 4 deletions Source/core/rendering/RenderThemeChromiumDefault.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@
#include "core/rendering/RenderThemeChromiumDefault.h"

#include "core/CSSValueKeywords.h"
#include "core/UserAgentStyleSheets.h"
#include "core/rendering/PaintInfo.h"
#include "core/rendering/RenderObject.h"
#include "core/rendering/RenderProgress.h"
#include "platform/LayoutTestSupport.h"
#include "platform/PlatformResourceLoader.h"
#include "platform/graphics/Color.h"
#include "platform/graphics/GraphicsContext.h"
#include "platform/graphics/GraphicsContextStateSaver.h"
Expand Down Expand Up @@ -133,12 +133,12 @@ String RenderThemeChromiumDefault::extraDefaultStyleSheet()
#if !OS(WIN)
return RenderThemeChromiumSkia::extraDefaultStyleSheet() +
#if !OS(ANDROID)
loadResourceAsASCIIString("themeInputMultipleFields.css") +
String(themeInputMultipleFieldsCss, sizeof(themeInputMultipleFieldsCss)) +
#endif
loadResourceAsASCIIString("themeChromiumLinux.css");
String(themeChromiumLinuxCss, sizeof(themeChromiumLinuxCss));
#else
return RenderThemeChromiumSkia::extraDefaultStyleSheet() +
loadResourceAsASCIIString("themeInputMultipleFields.css");
String(themeInputMultipleFieldsCss, sizeof(themeInputMultipleFieldsCss));
#endif
}

Expand Down
8 changes: 4 additions & 4 deletions Source/core/rendering/RenderThemeChromiumMac.mm
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

#import "core/CSSValueKeywords.h"
#import "core/HTMLNames.h"
#import "core/UserAgentStyleSheets.h"
#import "core/css/CSSValueList.h"
#import "core/dom/Document.h"
#import "core/dom/Element.h"
Expand All @@ -43,7 +44,6 @@
#import "core/rendering/RenderView.h"
#import "core/rendering/style/ShadowList.h"
#import "platform/LayoutTestSupport.h"
#import "platform/PlatformResourceLoader.h"
#import "platform/SharedBuffer.h"
#import "platform/graphics/BitmapImage.h"
#import "platform/graphics/GraphicsContextStateSaver.h"
Expand Down Expand Up @@ -1808,9 +1808,9 @@ IntSize shadowOffset(isVerticalSlider ? 1 : 0,
String RenderThemeChromiumMac::extraDefaultStyleSheet()
{
return RenderTheme::extraDefaultStyleSheet() +
loadResourceAsASCIIString("themeChromium.css") +
loadResourceAsASCIIString("themeInputMultipleFields.css") +
loadResourceAsASCIIString("themeMac.css");
String(themeChromiumCss, sizeof(themeChromiumCss)) +
String(themeInputMultipleFieldsCss, sizeof(themeInputMultipleFieldsCss)) +
String(themeMacCss, sizeof(themeMacCss));
}

bool RenderThemeChromiumMac::paintMediaVolumeSliderContainer(RenderObject* object, const PaintInfo& paintInfo, const IntRect& rect)
Expand Down
10 changes: 5 additions & 5 deletions Source/core/rendering/RenderThemeChromiumSkia.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@
#include "config.h"
#include "core/rendering/RenderThemeChromiumSkia.h"

#include "core/UserAgentStyleSheets.h"
#include "core/rendering/PaintInfo.h"
#include "core/rendering/RenderBox.h"
#include "core/rendering/RenderMediaControls.h"
#include "core/rendering/RenderObject.h"
#include "core/rendering/RenderProgress.h"
#include "core/rendering/RenderThemeChromiumFontProvider.h"
#include "platform/LayoutTestSupport.h"
#include "platform/PlatformResourceLoader.h"
#include "platform/graphics/GraphicsContext.h"
#include "platform/graphics/Image.h"
#include "platform/scroll/ScrollbarTheme.h"
Expand Down Expand Up @@ -70,14 +70,14 @@ RenderThemeChromiumSkia::~RenderThemeChromiumSkia()
String RenderThemeChromiumSkia::extraDefaultStyleSheet()
{
return RenderTheme::extraDefaultStyleSheet() +
loadResourceAsASCIIString("themeWin.css") +
loadResourceAsASCIIString("themeChromiumSkia.css") +
loadResourceAsASCIIString("themeChromium.css");
String(themeWinCss, sizeof(themeWinCss)) +
String(themeChromiumSkiaCss, sizeof(themeChromiumSkiaCss)) +
String(themeChromiumCss, sizeof(themeChromiumCss));
}

String RenderThemeChromiumSkia::extraQuirksStyleSheet()
{
return loadResourceAsASCIIString("themeWinQuirks.css");
return String(themeWinQuirksCss, sizeof(themeWinQuirksCss));
}

bool RenderThemeChromiumSkia::supportsHover(const RenderStyle* style) const
Expand Down
Loading

0 comments on commit 0bf4bb0

Please sign in to comment.