Title: [114090] trunk/Source/WebCore
Revision
114090
Author
tk...@chromium.org
Date
2012-04-12 23:33:14 -0700 (Thu, 12 Apr 2012)

Log Message

Calendar Picker: remove unnecessary code from calendarPicker.{css,js}
https://bugs.webkit.org/show_bug.cgi?id=83685

Reviewed by Kentaro Hara.

Remove the followings from input files:
 - multi line comments /*...*/ (.js and .css)
 - single line comment //... (.js)
 - repeating whitespace (.js and .css)
 - leading and trailing whitespace (.js and .css)
 - empty lines (.js and .css)

This doesn't work for arbitrary _javascript_ or CSS inputs, but
works well for expected input files like
css/make-css-file-arrays.pl

* make-file-arrays.py:
(strip_whitespace_and_comments):
(main):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (114089 => 114090)


--- trunk/Source/WebCore/ChangeLog	2012-04-13 06:19:01 UTC (rev 114089)
+++ trunk/Source/WebCore/ChangeLog	2012-04-13 06:33:14 UTC (rev 114090)
@@ -1,3 +1,25 @@
+2012-04-12  Kent Tamura  <tk...@chromium.org>
+
+        Calendar Picker: remove unnecessary code from calendarPicker.{css,js}
+        https://bugs.webkit.org/show_bug.cgi?id=83685
+
+        Reviewed by Kentaro Hara.
+
+        Remove the followings from input files:
+         - multi line comments /*...*/ (.js and .css)
+         - single line comment //... (.js)
+         - repeating whitespace (.js and .css)
+         - leading and trailing whitespace (.js and .css)
+         - empty lines (.js and .css)
+
+        This doesn't work for arbitrary _javascript_ or CSS inputs, but
+        works well for expected input files like
+        css/make-css-file-arrays.pl
+
+        * make-file-arrays.py:
+        (strip_whitespace_and_comments):
+        (main):
+
 2012-04-12  Sailesh Agrawal  <s...@chromium.org>
 
         Chromium: Fix scrollbar tickmark drawing on Mountain Lion

Modified: trunk/Source/WebCore/make-file-arrays.py (114089 => 114090)


--- trunk/Source/WebCore/make-file-arrays.py	2012-04-13 06:19:01 UTC (rev 114089)
+++ trunk/Source/WebCore/make-file-arrays.py	2012-04-13 06:33:14 UTC (rev 114090)
@@ -47,6 +47,34 @@
     return (variable_name, content)
 
 
+def strip_whitespace_and_comments(file_name, content):
+    result = re.match(r".*\.([^.]+)", file_name)
+    if not result:
+        print "The file name has no extension:", file_name
+        sys.exit(1)
+    extension = result.group(1).lower()
+    multi_line_comment = re.compile(r"/\*.*?\*/", re.MULTILINE | re.DOTALL)
+    single_line_comment = re.compile(r"//.*$", re.MULTILINE)
+    repeating_space = re.compile(r"[ \t]+", re.MULTILINE)
+    leading_space = re.compile(r"^[ \t]+", re.MULTILINE)
+    trailing_space = re.compile(r"[ \t]+$", re.MULTILINE)
+    empty_line = re.compile(r"\n+")
+    if extension == "js":
+        content = multi_line_comment.sub("", content)
+        content = single_line_comment.sub("", content)
+        content = repeating_space.sub(" ", content)
+        content = leading_space.sub("", content)
+        content = trailing_space.sub("", content)
+        content = empty_line.sub("\n", content)
+    elif extension == "css":
+        content = multi_line_comment.sub("", content)
+        content = repeating_space.sub(" ", content)
+        content = leading_space.sub("", content)
+        content = trailing_space.sub("", content)
+        content = empty_line.sub("\n", content)
+    return content
+
+
 def main():
     parser = OptionParser()
     parser.add_option("--out-h", dest="out_header")
@@ -74,6 +102,7 @@
 
     for file_name in args:
         (variable_name, content) = make_variable_name_and_read(file_name)
+        content = strip_whitespace_and_comments(file_name, content)
         size = len(content)
         header_file.write("extern const char %s[%d];\n" % (variable_name, size))
         cpp_file.write("const char %s[%d] = {\n" % (variable_name, size))
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to