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

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

Issue 2094193004: Strip comments and whitespace from Javascript resources (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Respond to comments, plus rebases. Created 4 years, 5 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
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 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 340
341 filename = self.GetInputPath() 341 filename = self.GetInputPath()
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.EvaluateCondition if self.grd_node else None,
351 allow_external_script = self.allow_external_script_, 351 allow_external_script = self.allow_external_script_,
352 preprocess_only = self.preprocess_only_, 352 preprocess_only = self.preprocess_only_,
353 rewrite_function=lambda fp, t, d: ProcessImageSets( 353 rewrite_function=lambda fp, t, d: ProcessImageSets(
354 fp, t, self.scale_factors_, d, 354 fp, t, self.scale_factors_, d,
355 filename_expansion_function=self.filename_expansion_function), 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 else: 357 else:
358 distribution = html_inline.GetDistribution() 358 distribution = html_inline.GetDistribution()
359 self.inlined_text_ = ProcessImageSets( 359 self.inlined_text_ = ProcessImageSets(
360 os.path.dirname(filename), 360 os.path.dirname(filename),
361 util.ReadFile(filename, 'utf-8'), 361 util.ReadFile(filename, 'utf-8'),
362 self.scale_factors_, 362 self.scale_factors_,
363 distribution, 363 distribution,
364 filename_expansion_function=self.filename_expansion_function) 364 filename_expansion_function=self.filename_expansion_function)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698