No subject


Mon Jan 28 08:41:14 PST 2013


This gives something like a 15x speedup over compiling and matching
one property at a time and doing multiple passes over the file.

* Scripts/webkitpy/w3c/test_converter.py:
(W3CTestConverter.__init__):
(W3CTestConverter.convert_prefixed_properties):
(W3CTestConverter.add_webkit_prefix_to_unprefixed_properties):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href=3D"#trunkToolsChangeLog">trunk/Tools/ChangeLog</a></li>
<li><a href=3D"#trunkToolsScriptswebkitpyw3ctest_converterpy">trunk/Tools=
/Scripts/webkitpy/w3c/test_converter.py</a></li>
</ul>

</div>
<div id=3D"patch">
<h3>Diff</h3>
<a id=3D"trunkToolsChangeLog"></a>
<div class=3D"modfile"><h4>Modified: trunk/Tools/ChangeLog (154125 =3D> 1=
54126)</h4>
<pre class=3D"diff"><span>
<span class=3D"info">--- trunk/Tools/ChangeLog	2013-08-15 20:24:11 UTC (r=
ev 154125)
+++ trunk/Tools/ChangeLog	2013-08-15 20:26:35 UTC (rev 154126)
</span><span class=3D"lines">@@ -1,3 +1,23 @@
</span><ins>+2013-08-15  Bem Jones-Bey  &lt;bjonesbe at adobe.com&gt;
+
+        &lt;https://webkit.org/b/119850&gt; Speed up test importing by d=
oing all the regex matching in a single pass
+
+        Reviewed by Dirk Pranke.
+
+        This is a port from Blink of
+        https://src.chromium.org/viewvc/blink?revision=3D155647&amp;view=
=3Drevision
+        originally by Dirk Pranke.
+
+        From the original commit:
+
+        This gives something like a 15x speedup over compiling and match=
ing
+        one property at a time and doing multiple passes over the file.
+
+        * Scripts/webkitpy/w3c/test_converter.py:
+        (W3CTestConverter.__init__):
+        (W3CTestConverter.convert_prefixed_properties):
+        (W3CTestConverter.add_webkit_prefix_to_unprefixed_properties):
+
</ins><span class=3D"cx"> 2013-08-15  Dan Bernstein  &lt;mitz at apple.com&g=
t;
</span><span class=3D"cx">=20
</span><span class=3D"cx">         &lt;https://webkit.org/b/119856&gt; Im=
prove extract-localizable-strings messages
</span></span></pre></div>
<a id=3D"trunkToolsScriptswebkitpyw3ctest_converterpy"></a>
<div class=3D"modfile"><h4>Modified: trunk/Tools/Scripts/webkitpy/w3c/tes=
t_converter.py (154125 =3D> 154126)</h4>
<pre class=3D"diff"><span>
<span class=3D"info">--- trunk/Tools/Scripts/webkitpy/w3c/test_converter.=
py	2013-08-15 20:24:11 UTC (rev 154125)
+++ trunk/Tools/Scripts/webkitpy/w3c/test_converter.py	2013-08-15 20:26:3=
5 UTC (rev 154126)
</span><span class=3D"lines">@@ -51,6 +51,9 @@
</span><span class=3D"cx">=20
</span><span class=3D"cx">         self.prefixed_properties =3D self.read=
_webkit_prefixed_css_property_list()
</span><span class=3D"cx">=20
</span><ins>+        prop_regex =3D '([\s{]|^)(' + &quot;|&quot;.join(pro=
p.replace('-webkit-', '') for prop in self.prefixed_properties) + ')(\s+:=
|:)'
+        self.prop_re =3D re.compile(prop_regex)
+
</ins><span class=3D"cx">     def path_from_webkit_root(self, *comps):
</span><span class=3D"cx">         return self._filesystem.abspath(self._=
filesystem.join(self._webkit_root, *comps))
</span><span class=3D"cx">=20
</span><span class=3D"lines">@@ -157,13 +160,19 @@
</span><span class=3D"cx">=20
</span><span class=3D"cx">             # Rewrite tag only if changes were=
 made.
</span><span class=3D"cx">             if updated_style_text[0]:
</span><del>-                converted_properties.extend(updated_style_te=
xt[0])
</del><ins>+                converted_properties.extend(list(updated_styl=
e_text[0]))
</ins><span class=3D"cx">=20
</span><span class=3D"cx">                 new_tag =3D Tag(doc, tag.name,=
 tag.attrs)
</span><span class=3D"cx">                 new_tag.insert(0, updated_styl=
e_text[1])
</span><span class=3D"cx">=20
</span><span class=3D"cx">                 self.replace_tag(tag, new_tag)
</span><span class=3D"cx">=20
</span><ins>+        # FIXME: Doing the replace in the parsed document an=
d then writing it back out
+        # is normalizing the HTML, which may in fact alter the intent of=
 some tests.
+        # We should probably either just do basic string-replaces, or ha=
ve some other
+        # way of flagging tests that are sensitive to being rewritten.
+        # https://bugs.webkit.org/show_bug.cgi?id=3D119159
+
</ins><span class=3D"cx">         return (converted_properties, doc.prett=
ify())
</span><span class=3D"cx">=20
</span><span class=3D"cx">     def add_webkit_prefix_to_unprefixed_proper=
ties(self, text, filename):
</span><span class=3D"lines">@@ -171,22 +180,18 @@
</span><span class=3D"cx">=20
</span><span class=3D"cx">         Returns the list of converted properti=
es and the modified text.&quot;&quot;&quot;
</span><span class=3D"cx">=20
</span><del>-        converted_properties =3D []
</del><ins>+        converted_properties =3D set()
+        text_chunks =3D []
+        cur_pos =3D 0
+        for m in self.prop_re.finditer(text):
+            text_chunks.extend([text[cur_pos:m.start()], m.group(1), '-w=
ebkit-', m.group(2), m.group(3)])
+            converted_properties.add(m.group(2))
+            cur_pos =3D m.end()
+        text_chunks.append(text[cur_pos:])
</ins><span class=3D"cx">=20
</span><del>-        for raw_property in self.prefixed_properties:
-            # FIXME: add in both the prefixed and unprefixed versions, r=
ather than just replacing them?
-            # That might allow the imported test to work in other browse=
rs more easily.
</del><ins>+        for prop in converted_properties:
+            _log.info('  converting %s', prop)
</ins><span class=3D"cx">=20
</span><del>-            # Look for the various ways it might be in the C=
SS
-            # Match the the property preceded by either whitespace or le=
ft curly brace
-            # or at the beginning of the string (for inline style attrib=
ute)
-            pattern =3D '([\s{]|^)' + raw_property + '(\s+:|:)'
-            if re.search(pattern, text):
-                replacement_property =3D '-webkit-%s' % raw_property
-                _log.info('converting %s -&gt; %s' % (raw_property, repl=
acement_property))
-                converted_properties.append(replacement_property)
-                text =3D re.sub(pattern, replacement_property + ':', tex=
t)
-
</del><span class=3D"cx">         # FIXME: Handle the JS versions of thes=
e properties and GetComputedStyle, too.
</span><span class=3D"cx">         return (converted_properties, text)
</span><span class=3D"cx">=20
</span></span></pre>
</div>
</div>

</body>
</html>


More information about the webkit-changes mailing list