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

Side by Side Diff: tools/grit/grit/gather/chrome_html.py

Issue 2179033002: Strip comments and whitespace from javascript resources (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Revert changes to screen.js (no longer needed for this CL) 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 unified diff | Download patch
« no previous file with comments | « tools/grit/grit/format/minifier.py ('k') | tools/grit/grit/node/include.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """Prepares a Chrome HTML file by inlining resources and adding references to 6 """Prepares a Chrome HTML file by inlining resources and adding references to
7 high DPI resources and removing references to unsupported scale factors. 7 high DPI resources and removing references to unsupported scale factors.
8 8
9 This is a small gatherer that takes a HTML file, looks for src attributes 9 This is a small gatherer that takes a HTML file, looks for src attributes
10 and inlines the specified file, producing one HTML file with no external 10 and inlines the specified file, producing one HTML file with no external
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 if self.filename_expansion_function: 342 if self.filename_expansion_function:
343 filename = self.filename_expansion_function(filename) 343 filename = self.filename_expansion_function(filename)
344 # Hack: some unit tests supply an absolute path and no root node. 344 # Hack: some unit tests supply an absolute path and no root node.
345 if not os.path.isabs(filename): 345 if not os.path.isabs(filename):
346 filename = self.grd_node.ToRealPath(filename) 346 filename = self.grd_node.ToRealPath(filename)
347 if self.flatten_html_: 347 if self.flatten_html_:
348 self.inlined_text_ = html_inline.InlineToString( 348 self.inlined_text_ = html_inline.InlineToString(
349 filename, 349 filename,
350 self.grd_node, 350 self.grd_node,
351 allow_external_script = self.allow_external_script_, 351 allow_external_script = self.allow_external_script_,
352 strip_whitespace=True,
352 preprocess_only = self.preprocess_only_, 353 preprocess_only = self.preprocess_only_,
353 rewrite_function=lambda fp, t, d: ProcessImageSets( 354 rewrite_function=lambda fp, t, d: ProcessImageSets(
354 fp, t, self.scale_factors_, d, 355 fp, t, self.scale_factors_, d,
355 filename_expansion_function=self.filename_expansion_function), 356 filename_expansion_function=self.filename_expansion_function),
356 filename_expansion_function=self.filename_expansion_function) 357 filename_expansion_function=self.filename_expansion_function)
357 else: 358 else:
358 distribution = html_inline.GetDistribution() 359 distribution = html_inline.GetDistribution()
359 self.inlined_text_ = ProcessImageSets( 360 self.inlined_text_ = ProcessImageSets(
360 os.path.dirname(filename), 361 os.path.dirname(filename),
361 util.ReadFile(filename, 'utf-8'), 362 util.ReadFile(filename, 'utf-8'),
362 self.scale_factors_, 363 self.scale_factors_,
363 distribution, 364 distribution,
364 filename_expansion_function=self.filename_expansion_function) 365 filename_expansion_function=self.filename_expansion_function)
OLDNEW
« no previous file with comments | « tools/grit/grit/format/minifier.py ('k') | tools/grit/grit/node/include.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698