source: webkit/trunk/Source/WebCore/css/make-css-file-arrays.pl

Last change on this file was 274613, checked in by [email protected], 4 years ago

modern-media-controls css should not allocate heap memory
https://bugs.webkit.org/show_bug.cgi?id=223410

Reviewed by Devin Rousso.

This is CSS version of <https://commits.webkit.org/235444@main>. We should not allocate heap memory for
modern-media-controls.css. This patch leverages UserAgentStyleSheets mechanism to include this style
sheet in constant DATA.

  • DerivedSources-input.xcfilelist:
  • DerivedSources-output.xcfilelist:
  • DerivedSources.make:
  • WebCore.xcodeproj/project.pbxproj:
  • css/make-css-file-arrays.pl:
  • rendering/RenderThemeIOS.mm:

(WebCore::RenderThemeIOS::modernMediaControlsStyleSheet):

  • rendering/RenderThemeMac.mm:

(WebCore::RenderThemeMac::modernMediaControlsStyleSheet):

  • Property svn:executable set to *
File size: 2.9 KB
Line 
1#!/usr/bin/env perl
2#
3# Copyright (C) 2006 Apple Inc.
4#
5# This library is free software; you can redistribute it and/or
6# modify it under the terms of the GNU Library General Public
7# License as published by the Free Software Foundation; either
8# version 2 of the License, or (at your option) any later version.
9#
10# This library is distributed in the hope that it will be useful,
11# but WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13# Library General Public License for more details.
14#
15# You should have received a copy of the GNU Library General Public License
16# along with this library; see the file COPYING.LIB. If not, write to
17# the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18# Boston, MA 02110-1301, USA.
19#
20
21# Usage: make-css-file-arrays.pl <header> <output> <input> ...
22
23use strict;
24use warnings;
25use FindBin;
26use lib "$FindBin::Bin/../bindings/scripts";
27
28use Getopt::Long;
29
30my $defines;
31my $preprocessor;
32GetOptions('defines=s' => \$defines,
33 'preprocessor=s' => \$preprocessor);
34
35my $header = $ARGV[0];
36shift;
37
38my $out = $ARGV[0];
39shift;
40
41open HEADER, ">", $header or die;
42open OUT, ">", $out or die;
43
44print HEADER "namespace WebCore {\n";
45print OUT "namespace WebCore {\n";
46
47for my $in (@ARGV) {
48 $in =~ /(\w+)\.css$/ or $in =~ /(\w+)\.js$/ or die;
49 my $name = $1;
50
51 # Slurp in the CSS file.
52 my $text;
53 require preprocessor;
54 $text = join('', applyPreprocessor($in, $defines, $preprocessor));
55
56 # Remove comments in a simple-minded way that will work fine for our files.
57 # Could do this a fancier way if we were worried about arbitrary CSS source.
58 $text =~ s|/\*.*?\*/||gs;
59
60 # Crunch whitespace just to make it a little smaller.
61 # Could do work to avoid doing this inside quote marks but our files don't have runs of spaces in quotes.
62 # Could crunch further based on places where whitespace is optional.
63 $text =~ s|\s+| |gs;
64 $text =~ s|^ ||;
65 $text =~ s| $||;
66
67 # Write out a C array of the characters.
68 my $length = length $text;
69 if ($in =~ /(\w+)\.css$/) {
70 print HEADER "extern const char ${name}UserAgentStyleSheet[${length}];\n";
71 print OUT "extern const char ${name}UserAgentStyleSheet[${length}] = {\n";
72 } else {
73 print HEADER "extern const char ${name}JavaScript[${length}];\n";
74 print OUT "extern const char ${name}JavaScript[${length}] = {\n";
75 }
76 my $i = 0;
77 while ($i < $length) {
78 print OUT " ";
79 my $j = 0;
80 while ($j < 16 && $i < $length) {
81 my $character = ord substr $text, $i, 1;
82 die if $character >= 128;
83 print OUT ", " unless $j == 0;
84 print OUT $character;
85 ++$i;
86 ++$j;
87 }
88 print OUT "," unless $i == $length;
89 print OUT "\n";
90 }
91 print OUT "};\n";
92
93}
94
95print HEADER "}\n";
96print OUT "}\n";
Note: See TracBrowser for help on using the repository browser.