<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[163906] trunk/Source/WebCore</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/163906">163906</a></dd>
<dt>Author</dt> <dd>jer.noble@apple.com</dd>
<dt>Date</dt> <dd>2014-02-11 13:36:06 -0800 (Tue, 11 Feb 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>Run UserAgentScripts through jsmin rather than the css preprocessor
https://bugs.webkit.org/show_bug.cgi?id=127559

Reviewed by Tim Horton.

User Agent JavaScript files were being run through the c++ preprocessor to strip out
comments (and presumably to allow #if ENABLE macros, though that feature is entirely
unused). This had the side effect of removing important whitespace, namely newlines where
there would normally be an implicit semicolon.

Instead, .js files will now be run through the jsmin minifier, used by the inspector.
Jsmin will also strip comments and whitespace, but in a syntactically aware way which will
keep newlines when their presence adds an implied semicolon.

* DerivedSources.make:
* Scripts/make-js-file-arrays.py: Added.
(stringifyCodepoint):
(chunk):
(main):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreDerivedSourcesmake">trunk/Source/WebCore/DerivedSources.make</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li>trunk/Source/WebCore/Scripts/</li>
<li><a href="#trunkSourceWebCoreScriptsmakejsfilearrayspy">trunk/Source/WebCore/Scripts/make-js-file-arrays.py</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (163905 => 163906)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2014-02-11 21:28:55 UTC (rev 163905)
+++ trunk/Source/WebCore/ChangeLog        2014-02-11 21:36:06 UTC (rev 163906)
</span><span class="lines">@@ -1,3 +1,25 @@
</span><ins>+2014-01-24  Jer Noble  &lt;jer.noble@apple.com&gt;
+
+        Run UserAgentScripts through jsmin rather than the css preprocessor
+        https://bugs.webkit.org/show_bug.cgi?id=127559
+
+        Reviewed by Tim Horton.
+
+        User Agent JavaScript files were being run through the c++ preprocessor to strip out
+        comments (and presumably to allow #if ENABLE macros, though that feature is entirely
+        unused). This had the side effect of removing important whitespace, namely newlines where
+        there would normally be an implicit semicolon.
+
+        Instead, .js files will now be run through the jsmin minifier, used by the inspector.
+        Jsmin will also strip comments and whitespace, but in a syntactically aware way which will
+        keep newlines when their presence adds an implied semicolon.
+
+        * DerivedSources.make:
+        * Scripts/make-js-file-arrays.py: Added.
+        (stringifyCodepoint):
+        (chunk):
+        (main):
+
</ins><span class="cx"> 2014-02-11  Andy Estes  &lt;aestes@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [Mac] connection:willStopBufferingData: no longer exists in NSURLConnectionDelegate
</span></span></pre></div>
<a id="trunkSourceWebCoreDerivedSourcesmake"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/DerivedSources.make (163905 => 163906)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/DerivedSources.make        2014-02-11 21:28:55 UTC (rev 163905)
+++ trunk/Source/WebCore/DerivedSources.make        2014-02-11 21:36:06 UTC (rev 163906)
</span><span class="lines">@@ -892,8 +892,8 @@
</span><span class="cx">         USER_AGENT_SCRIPTS := $(USER_AGENT_SCRIPTS) $(WebCore)/Modules/plugins/QuickTimePluginReplacement.js
</span><span class="cx"> endif
</span><span class="cx"> 
</span><del>-UserAgentScripts.h : css/make-css-file-arrays.pl bindings/scripts/preprocessor.pm $(USER_AGENT_SCRIPTS) $(PLATFORM_FEATURE_DEFINES)
-        perl -I$(WebCore)/bindings/scripts $&lt; --defines &quot;$(FEATURE_DEFINES)&quot; $@ UserAgentScriptsData.cpp $(USER_AGENT_SCRIPTS)
</del><ins>+UserAgentScripts.h : Scripts/make-js-file-arrays.py $(USER_AGENT_SCRIPTS)
+        PYTHONPATH=$(InspectorScripts) python $&lt; $@ UserAgentScriptsData.cpp $(USER_AGENT_SCRIPTS)
</ins><span class="cx"> 
</span><span class="cx"> # --------
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreScriptsmakejsfilearrayspy"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/Scripts/make-js-file-arrays.py (0 => 163906)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Scripts/make-js-file-arrays.py                                (rev 0)
+++ trunk/Source/WebCore/Scripts/make-js-file-arrays.py        2014-02-11 21:36:06 UTC (rev 163906)
</span><span class="lines">@@ -0,0 +1,91 @@
</span><ins>+#!/usr/bin/env python
+# Copyright (C) 2014 Apple Inc. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1.  Redistributions of source code must retain the above copyright
+#     notice, this list of conditions and the following disclaimer.
+# 2.  Redistributions in binary form must reproduce the above copyright
+#     notice, this list of conditions and the following disclaimer in the
+#     documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
+# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+# DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+import io
+import os
+from optparse import OptionParser
+from StringIO import StringIO
+from jsmin import JavascriptMinify
+
+
+def stringifyCodepoint(code):
+    if code &lt; 128:
+        return '{0:d}'.format(code)
+    else:
+        return &quot;'\\x{0:02x}'&quot;.format(code)
+
+
+def chunk(list, chunkSize):
+    for i in xrange(0, len(list), chunkSize):
+        yield list[i:i + chunkSize]
+
+
+def main():
+    parser = OptionParser(usage=&quot;usage: %prog [--no-minify] header source [input [input...]]&quot;)
+    parser.add_option('--no-minify', action='store_true', help='Do not run the input files through jsmin')
+    (options, arguments) = parser.parse_args()
+    if len(arguments) &lt; 3:
+        print 'Error: must provide at least 3 arguments'
+        parser.print_usage()
+        exit(-1)
+
+    headerPath = arguments[0]
+    sourcePath = arguments[1]
+    inputPaths = arguments[2:]
+
+    headerFile = open(headerPath, 'w')
+    print &gt;&gt; headerFile, 'namespace WebCore {'
+
+    sourceFile = open(sourcePath, 'w')
+    print &gt;&gt; sourceFile, '#include &quot;{0:s}&quot;'.format(os.path.basename(headerPath))
+    print &gt;&gt; sourceFile, 'namespace WebCore {'
+
+    jsm = JavascriptMinify()
+
+    for inputFileName in inputPaths:
+        inputStream = io.FileIO(inputFileName)
+        outputStream = StringIO()
+
+        if not options.no_minify:
+            jsm.minify(inputStream, outputStream)
+            characters = outputStream.getvalue()
+        else:
+            characters = inputStream.read()
+
+        size = len(characters)
+        variableName = os.path.splitext(os.path.basename(inputFileName))[0]
+
+        print &gt;&gt; headerFile, 'extern const char {0:s}JavaScript[{1:d}];'.format(variableName, size)
+        print &gt;&gt; sourceFile, 'const char {0:s}JavaScript[{1:d}] = {{'.format(variableName, size)
+
+        codepoints = map(ord, characters)
+        for codepointChunk in chunk(codepoints, 16):
+            print &gt;&gt; sourceFile, '    {0:s},'.format(','.join(map(stringifyCodepoint, codepointChunk)))
+
+        print &gt;&gt; sourceFile, '};'
+
+    print &gt;&gt; headerFile, '}'
+    print &gt;&gt; sourceFile, '}'
+
+if __name__ == '__main__':
+    main()
</ins><span class="cx">Property changes on: trunk/Source/WebCore/Scripts/make-js-file-arrays.py
</span><span class="cx">___________________________________________________________________
</span></span></pre></div>
<a id="svnexecutable"></a>
<div class="addfile"><h4>Added: svn:executable</h4></div>
</div>

</body>
</html>