Add the <t> element and ignore whitespace outside it.

We now only preserve the whitespace inside a <t> element inside
the parser. This removes the known n^2 from reattaching whitespace
which should make parsing and appending nodes faster. I also
removed the dead WhitespaceMode code from the parser, and made
the dom-seralizer.sky auto indent the markup so the test output
would be readable.

R=abarth@chromium.org

Review URL: https://codereview.chromium.org/867963006
This commit is contained in:
Elliott Sprehn
2015-01-23 16:50:00 -08:00
parent f51a99fbd8
commit a43c73c52f
11 changed files with 149 additions and 113 deletions

View File

@@ -41,5 +41,4 @@ layer at (686,582) size 114x18
RenderInline {a} at (0,0) size 36x12
RenderText {#text} at (75,3) size 36x12
text run at (75,3) width 36: "J\x{E9}r\x{F4}me"
RenderText {#text} at (0,0) size 0x0

View File

@@ -1,6 +1,6 @@
<html>
<import src="../resources/dump-as-markup.sky"></import>
<body>
<import src="../resources/dump-as-markup.sky"></import>
<body>
THIS TEST SHOULD PASS
(control test for success)
</body>

View File

@@ -1,11 +1,11 @@
<html>
<import src="../resources/dump-as-markup.sky"></import>
<body>
<diva>1</diva>
<divb>2</divb>
<divc>3</divc>
<divd>4</divd>;&gt;
<import src="../resources/dump-as-markup.sky"></import>
<body>
<diva>1</diva>
<divb>2</divb>
<divc>3</divc>
<divd>4</divd>;&gt;
</body>
</html>

View File

@@ -1,19 +1,19 @@
<html>
<import src="../resources/dump-as-markup.sky"></import>
<body>
<div>aaa'bbb</div>
<div>&lt;</div>
<div>aaa<61>bbb</div>
<div foo="bar ">A</div>
<div>&amp;</div>
<div>&amp;#</div>
<div>&amp;#x</div>
<div>&amp;#x41</div>
<div>&amp;;</div>
<div>&amp;#;</div>
<div>&amp;#x;</div>
<div>A</div>
<div><3E></div>
</body>
<import src="../resources/dump-as-markup.sky"></import>
<body>
<div>aaa'bbb</div>
<div>&lt;</div>
<div>aaa<61>bbb</div>
<div foo="bar ">A</div>
<div>&amp;</div>
<div>&amp;#</div>
<div>&amp;#x</div>
<div>&amp;#x41</div>
<div>&amp;;</div>
<div>&amp;#;</div>
<div>&amp;#x;</div>
<div>A</div>
<div><3E></div>
</body>
</html>

View File

@@ -1,7 +1,7 @@
&lt;!DOCTYPE HTML&gt;
<html>
<import src="../resources/dump-as-markup.sky"></import>
<body>
<import src="../resources/dump-as-markup.sky"></import>
<body>
A &lt;!DOCTYPE HTMLAGAIN&gt;
B &lt;!BOGUSCOMMENT&gt;
@@ -11,13 +11,20 @@ G &lt;! -- -- &gt;
H <image></image>
I <keygen>
J <isindex>
K <table><div></div><input type="hidden"></input></table>
K <table>
<div></div>
<input type="hidden"></input>
</table>
L <frameset></frameset>
M <p></p>
N
O <br></br>
P
Q <template><div>contents</div></template>
</isindex></keygen></body>
Q <template>
<div>contents</div>
</template>
</isindex>
</keygen>
</body>
</html>

View File

@@ -13,45 +13,36 @@ SOURCE: http://127.0.0.1:8000/sky/tests/parser/script.sky:38
ERROR: Uncaught SyntaxError: Unexpected token }
SOURCE: http://127.0.0.1:8000/sky/tests/parser/script.sky:43
<html>
<import src="../resources/dump-as-markup.sky"></import>
<body>
<script>
<import src="../resources/dump-as-markup.sky"></import>
<body>
<script>
TEST <a></a>
</script>
<SCRIPT>
<SCRIPT>
TEST <a></a>
</SCRIPT>
<script>
</SCRIPT>
<script>
<SCRIPT>
TEST <a></a>
</SCRIPT>
</script>
<SCRIPT>
<script>
<SCRIPT>
<script>
TEST <a></a>
</SCRIPT>
</script>
</SCRIPT>
<script> TEST </script>
</SCRIPT>
<script> TEST </script>
&lt;
script
&gt; TEST
<script> TEST </
&gt; TEST <script> TEST </
script>
</script>
<script> TEST </scrip>
<script> TEST </scrip>
</script>
<script> TEST <//script>
<script> TEST <//script>
</script>
</body>
</body>
</html>

View File

@@ -1,28 +1,24 @@
<html>
<import src="../resources/dump-as-markup.sky"></import>
<body>
<a>1</a>
<a>2</a>
<a.>3</a.>
<a_>4</a_>
<a->5</a->
<a!>6</a!>
<a%>7</a%>
<import src="../resources/dump-as-markup.sky"></import>
<body>
<a>1</a>
<a>2</a>
<a.>3</a.>
<a_>4</a_>
<a->5</a->
<a!>6</a!>
<a%>7</a%>
&lt; a&gt;8&lt;/ a&gt;
<.a>9</.a>
<_a>a</_a>
<-a>b</-a>
<_a>a</_a>
<-a>b</-a>
&lt;!a&gt;c&lt;/!a&gt;
&lt;%a&gt;d&lt;/%a&gt;
<a _a=""></a>
<a foo="bar" <="" a=""></a>
<a a1="" a2="xx=xx" a3="&amp;" a4="&amp;#" a5="&amp;#x" a6="&amp;#x1" a7="" a8="&amp;#1" a9="" aa="&amp;a" ab="<22>" ac="&amp;;" ad="a" ae="<" af="&amp;lt" ag="<22>" b3="&amp;" b4="&amp;#" b5="&amp;#x" b6="&amp;#x1" b7="" b8="&amp;#1" b9="" ba="&amp;a" bb="<22>" bc="&amp;;" bd="a" be="<" bf="&amp;lt" bg="<22>" c3="&amp;" c4="&amp;#" c5="&amp;#x" c6="&amp;#x1" c7="" c8="&amp;#1" c9="" ca="&amp;a" cb="<22>" cc="&amp;;" cd="a" ce="<" cf="&amp;lt" cg="<22>">
</a></body>
<a foo="bar" <="" a=""></a>
<a a1="" a2="xx=xx" a3="&amp;" a4="&amp;#" a5="&amp;#x" a6="&amp;#x1" a7="" a8="&amp;#1" a9="" aa="&amp;a" ab="<22>" ac="&amp;;" ad="a" ae="<" af="&amp;lt" ag="<22>" b3="&amp;" b4="&amp;#" b5="&amp;#x" b6="&amp;#x1" b7="" b8="&amp;#1" b9="" ba="&amp;a" bb="<22>" bc="&amp;;" bd="a" be="<" bf="&amp;lt" bg="<22>" c3="&amp;" c4="&amp;#" c5="&amp;#x" c6="&amp;#x1" c7="" c8="&amp;#1" c9="" ca="&amp;a" cb="<22>" cc="&amp;;" cd="a" ce="<" cf="&amp;lt" cg="<22>"></a>
</body>
</html>

View File

@@ -1,24 +1,20 @@
<html>
<import src="../resources/dump-as-markup.sky"></import>
<body>
<style>
<import src="../resources/dump-as-markup.sky"></import>
<body>
<style>
& TEST <a></a>
</style>
<STYLE>
<STYLE>
&amp; TEST <a></a>
</STYLE>
<style>
</STYLE>
<style>
& TEST
<STYLE>
& TEST <a></a>
</STYLE>
& TEST
</style>
<STYLE>
<STYLE>
&amp; TEST
<style>
TEST <a></a>
@@ -27,8 +23,7 @@
</style>
&amp; TEST
</STYLE>
<style> TEST </style>
<style> TEST </style>
&lt;
style
@@ -40,12 +35,10 @@ style
style>
& TEST
</style>
<style> & TEST </styl>
<style> & TEST </styl>
& TEST
</style>
<style> & TEST <//style>
<style> & TEST <//style>
& TEST
</style>
@@ -53,3 +46,4 @@ style>
</body>
</html>

View File

@@ -1,23 +1,11 @@
<html>
<import src="../resources/dump-as-markup.sky"></import>
<body>
<p></p> a
<p></p> a
<p test=""></p> a
<p test=""></p> a
<p test="/"> a </p>
<p test="/"> a </p>
<p test="a/"> a </p>
<p test="a"></p> a
<p test="a"></p> a
<p test="a"></p> a
<p test="a"></p> a
<p test="a"></p> a
<p test="&amp;/"> a </p>
<p test="&amp;"></p> a
<p test="a/"> a </p>
<p test="a"></p> a
</body>
<import src="../resources/dump-as-markup.sky"></import>
<body>
<p></p> a <p></p> a <p test=""></p> a <p test=""></p> a <p test="/"> a </p>
<p test="/"> a </p>
<p test="a/"> a </p>
<p test="a"></p> a <p test="a"></p> a <p test="a"></p> a <p test="a"></p> a <p test="a"></p> a <p test="&amp;/"> a </p>
<p test="&amp;"></p> a <p test="a/"> a </p>
<p test="a"></p> a </body>
</html>

View File

@@ -0,0 +1,28 @@
<sky>
<import src="../resources/dump-as-markup.sky"></import>
<t>
<span>
A
<div>
<span></span>
<span></span>
</div>
</span>
<span>B</span>
</t>
<div>
<span>
A
</span>
<span>B</span>
</div>
</sky>

View File

@@ -0,0 +1,33 @@
<sky>
<import src="../resources/dump-as-markup.sky"></import>
<t>
<span>
A
<div>
<span></span>
<!-- All whitespace in a subtree should be kept under <t>. -->
<span></span>
</div>
</span>
<!-- This whitespace should be preserved. -->
<span>B</span>
</t>
<div>
<span>
A
</span>
<!-- This whitespace should be ignored. -->
<span>B</span>
</div>
</sky>