OLD | NEW |
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 Loading... |
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) |
OLD | NEW |