Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(77)

Unified Diff: tools/grit/grit/format/html_inline.py

Issue 2249493002: Fixes html inlining if external stylesheet has include directive (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added new test case Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tools/grit/grit/format/html_inline_unittest.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/grit/grit/format/html_inline.py
diff --git a/tools/grit/grit/format/html_inline.py b/tools/grit/grit/format/html_inline.py
index 253632de173e6a5d44fe3952c84deb646ee1622b..ca1541358d664e5112db2b6b288f0062528c53eb 100755
--- a/tools/grit/grit/format/html_inline.py
+++ b/tools/grit/grit/format/html_inline.py
@@ -239,12 +239,18 @@ def DoInline(
rewrite_function,
filename_expansion_function=filename_expansion_function))
return ""
-
- return pattern % InlineToString(
- filepath, grd_node, allow_external_script=allow_external_script,
+ # To recursively save inlined files, we need InlinedData instance returned
+ # by DoInline.
+ inlined_data_inst=DoInline(filepath, grd_node,
+ allow_external_script=allow_external_script,
strip_whitespace=strip_whitespace,
filename_expansion_function=filename_expansion_function)
+ inlined_files.update(inlined_data_inst.inlined_files)
+
+ return pattern % inlined_data_inst.inlined_data;
+
+
def InlineIncludeFiles(src_match):
"""Helper function to directly inline generic external files (without
wrapping them with any kind of tags).
@@ -286,10 +292,15 @@ def DoInline(
# Even if names_only is set, the CSS file needs to be opened, because it
# can link to images that need to be added to the file set.
inlined_files.add(filepath)
+
+ # Inline stylesheets included in this css file.
+ text = _INCLUDE_RE.sub(InlineIncludeFiles,
+ util.ReadFile(filepath, util.BINARY))
# When resolving CSS files we need to pass in the path so that relative URLs
# can be resolved.
- return pattern % InlineCSSText(util.ReadFile(filepath, util.BINARY),
- filepath)
+
+ return pattern % InlineCSSText(text, filepath)
+
def InlineCSSImages(text, filepath=input_filepath):
"""Helper function that inlines external images in CSS backgrounds."""
« no previous file with comments | « no previous file | tools/grit/grit/format/html_inline_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698