2010-07-05 Adam Barth <abarth@webkit.org>
authorabarth@webkit.org <abarth@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 6 Jul 2010 05:14:46 +0000 (05:14 +0000)
committerabarth@webkit.org <abarth@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 6 Jul 2010 05:14:46 +0000 (05:14 +0000)
        Reviewed by Eric Seidel.

        Implement basic text node coalescing
        https://bugs.webkit.org/show_bug.cgi?id=41623

        * html5lib/resources/webkit01.dat:
            - This test had incorrect expected results according to the spec
              and to Minefield.
        * html5lib/runner-expected-html5.txt:
            - Update expected results to show test progression.  In some cases,
              we continue to fail tests, but in new (also wrong) ways.  I think
              that's ok though.
        * html5lib/runner-expected.txt:
            - Update expected results w.r.t. new webkit01.dat baseline.
        * html5lib/webkit-resumer-expected.txt:
            - Update expected results w.r.t. new webkit01.dat baseline.
2010-07-05  Adam Barth  <abarth@webkit.org>

        Reviewed by Eric Seidel.

        Implement basic text node coalescing
        https://bugs.webkit.org/show_bug.cgi?id=41623

        This patch isn't the end-all, be-all of text node coalescing, but it's
        a good start.

        * dom/CharacterData.cpp:
        (WebCore::CharacterData::parserAppendData):
        (WebCore::CharacterData::appendData):
        * dom/CharacterData.h:
            - Added a new method to dance around mutation events.
        * html/HTMLTreeBuilder.cpp:
        (WebCore::HTMLTreeBuilder::insertTextNode):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@62520 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/html5lib/resources/webkit01.dat
LayoutTests/html5lib/runner-expected-html5.txt
LayoutTests/html5lib/runner-expected.txt
LayoutTests/html5lib/webkit-resumer-expected.txt
WebCore/ChangeLog
WebCore/dom/CharacterData.cpp
WebCore/dom/CharacterData.h
WebCore/html/HTMLTreeBuilder.cpp

index db95c93..b127b3e 100644 (file)
@@ -2,6 +2,25 @@
 
         Reviewed by Eric Seidel.
 
+        Implement basic text node coalescing
+        https://bugs.webkit.org/show_bug.cgi?id=41623
+
+        * html5lib/resources/webkit01.dat:
+            - This test had incorrect expected results according to the spec
+              and to Minefield.
+        * html5lib/runner-expected-html5.txt:
+            - Update expected results to show test progression.  In some cases,
+              we continue to fail tests, but in new (also wrong) ways.  I think
+              that's ok though.
+        * html5lib/runner-expected.txt:
+            - Update expected results w.r.t. new webkit01.dat baseline.
+        * html5lib/webkit-resumer-expected.txt:
+            - Update expected results w.r.t. new webkit01.dat baseline.
+
+2010-07-05  Adam Barth  <abarth@webkit.org>
+
+        Reviewed by Eric Seidel.
+
         Implement InSelectMode
         https://bugs.webkit.org/show_bug.cgi?id=41627
 
index df8c1d7..5aa8edb 100644 (file)
@@ -186,8 +186,7 @@ console.log("FOO<span>BAR</span>BAZ");
 |   <head>
 |   <body>
 |     <p>
-|       "Test"
-|       "Test2"
+|       "TestTest2"
 
 #data
 <rdar://problem/6869687>
index dd60b34..5b4979c 100644 (file)
@@ -14,12 +14,10 @@ resources/tests1.dat:
 31
 32
 33
-34
 50
 51
 53
 56
-57
 58
 59
 60
@@ -328,34 +326,6 @@ Expected:
 |       "you"
 |   <!-- do -->
 
-Test 34 of 113 in resources/tests1.dat failed. Input:
-<!DOCTYPE html>A<option>B<optgroup>C<select>D</option>E
-Got:
-| <!DOCTYPE html>
-| <html>
-|   <head>
-|   <body>
-|     "A"
-|     <option>
-|       "B"
-|     <optgroup>
-|       "C"
-|       <select>
-|         "D"
-|         "E"
-Expected:
-| <!DOCTYPE html>
-| <html>
-|   <head>
-|   <body>
-|     "A"
-|     <option>
-|       "B"
-|     <optgroup>
-|       "C"
-|       <select>
-|         "DE"
-
 Test 50 of 113 in resources/tests1.dat failed. Input:
 <!DOCTYPE html><script> <!-- </script> --> </script> EOF
 Got:
@@ -365,8 +335,7 @@ Got:
 |     <script>
 |       " <!-- "
 |   <body>
-|     " --> "
-|     " EOF"
+|     " -->  EOF"
 Expected:
 | <!DOCTYPE html>
 | <html>
@@ -446,22 +415,6 @@ Expected:
 |       <b>
 |         "world"
 
-Test 57 of 113 in resources/tests1.dat failed. Input:
-<b>Test</i>Test
-Got:
-| <html>
-|   <head>
-|   <body>
-|     <b>
-|       "Test"
-|       "Test"
-Expected:
-| <html>
-|   <head>
-|   <body>
-|     <b>
-|       "TestTest"
-
 Test 58 of 113 in resources/tests1.dat failed. Input:
 <b>A<cite>B<div>C
 Got:
@@ -498,8 +451,7 @@ Got:
 |         <cite>
 |           "B"
 |           <div>
-|             "C"
-|             "D"
+|             "CD"
 Expected:
 | <html>
 |   <head>
@@ -524,8 +476,7 @@ Got:
 |           "B"
 |       <div>
 |         <b>
-|           "C"
-|           "D"
+|           "CD"
 Expected:
 | <html>
 |   <head>
@@ -564,8 +515,7 @@ Got:
 |                 <i>
 |                   <div>
 |                     <b>
-|                       "X"
-|                       "TEST"
+|                       "XTEST"
 Expected:
 | <html>
 |   <head>
@@ -734,8 +684,7 @@ Got:
 |         <i>
 |           <p>
 |             <b>
-|               " jkl "
-|               " mno"
+|               " jkl  mno"
 Expected:
 | <html>
 |   <head>
@@ -769,8 +718,7 @@ Got:
 |         <p>
 |           <i>
 |             <b>
-|               " jkl "
-|               " mno "
+|               " jkl  mno "
 Expected:
 | <html>
 |   <head>
@@ -805,9 +753,7 @@ Got:
 |         <p>
 |           <i>
 |             <b>
-|               " jkl "
-|               " mno "
-|               " pqr"
+|               " jkl  mno  pqr"
 Expected:
 | <html>
 |   <head>
@@ -843,9 +789,7 @@ Got:
 |         <p>
 |           <i>
 |             <b>
-|               " jkl "
-|               " mno "
-|               " pqr "
+|               " jkl  mno  pqr "
 Expected:
 | <html>
 |   <head>
@@ -881,9 +825,7 @@ Got:
 |         <p>
 |           <i>
 |             <b>
-|               " jkl "
-|               " mno "
-|               " pqr "
+|               " jkl  mno  pqr "
 |         " stu"
 Expected:
 | <html>
@@ -1448,7 +1390,6 @@ resources/tests2.dat:
 9
 11
 13
-32
 34
 36
 38
@@ -1456,8 +1397,6 @@ resources/tests2.dat:
 47
 48
 49
-53
-54
 58
 
 Test 4 of 59 in resources/tests2.dat failed. Input:
@@ -1560,22 +1499,6 @@ Expected:
 |       <tbody>
 |         <tr>
 
-Test 32 of 59 in resources/tests2.dat failed. Input:
-<!DOCTYPE html>X</body>X
-Got:
-| <!DOCTYPE html>
-| <html>
-|   <head>
-|   <body>
-|     "X"
-|     "X"
-Expected:
-| <!DOCTYPE html>
-| <html>
-|   <head>
-|   <body>
-|     "XX"
-
 Test 34 of 59 in resources/tests2.dat failed. Input:
 <!DOCTYPE html><table><caption>test TEST</caption><td>test
 Got:
@@ -1717,38 +1640,6 @@ Expected:
 |     "  "
 |   <body>
 
-Test 53 of 59 in resources/tests2.dat failed. Input:
-<!DOCTYPE html>X</html>X
-Got:
-| <!DOCTYPE html>
-| <html>
-|   <head>
-|   <body>
-|     "X"
-|     "X"
-Expected:
-| <!DOCTYPE html>
-| <html>
-|   <head>
-|   <body>
-|     "XX"
-
-Test 54 of 59 in resources/tests2.dat failed. Input:
-<!DOCTYPE html>X</html> 
-Got:
-| <!DOCTYPE html>
-| <html>
-|   <head>
-|   <body>
-|     "X"
-|     " "
-Expected:
-| <!DOCTYPE html>
-| <html>
-|   <head>
-|   <body>
-|     "X "
-
 Test 58 of 59 in resources/tests2.dat failed. Input:
 <!DOCTYPE html><table><tr><td></p></table>
 Got:
@@ -1962,10 +1853,8 @@ Expected:
 |   "setting head's innerHTML"
 resources/tests5.dat:
 2
-6
 7
 8
-9
 
 Test 2 of 16 in resources/tests5.dat failed. Input:
 <style> <!-- </style> --> </style>x
@@ -1975,8 +1864,7 @@ Got:
 |     <style>
 |       " <!-- "
 |   <body>
-|     " --> "
-|     "x"
+|     " --> x"
 Expected:
 | <html>
 |   <head>
@@ -1986,25 +1874,6 @@ Expected:
 |   <body>
 |     "--> x"
 
-Test 6 of 16 in resources/tests5.dat failed. Input:
-<iframe> <!--- </iframe>->x</iframe> --> </iframe>x
-Got:
-| <html>
-|   <head>
-|   <body>
-|     <iframe>
-|       " <!--- "
-|     "->x"
-|     " --> "
-|     "x"
-Expected:
-| <html>
-|   <head>
-|   <body>
-|     <iframe>
-|       " <!--- "
-|     "->x --> x"
-
 Test 7 of 16 in resources/tests5.dat failed. Input:
 <script> <!-- </script> --> </script>x
 Got:
@@ -2013,8 +1882,7 @@ Got:
 |     <script>
 |       " <!-- "
 |   <body>
-|     " --> "
-|     "x"
+|     " --> x"
 Expected:
 | <html>
 |   <head>
@@ -2032,8 +1900,7 @@ Got:
 |     <title>
 |       " <!-- "
 |   <body>
-|     " --> "
-|     "x"
+|     " --> x"
 Expected:
 | <html>
 |   <head>
@@ -2042,25 +1909,6 @@ Expected:
 |     " "
 |   <body>
 |     "--> x"
-
-Test 9 of 16 in resources/tests5.dat failed. Input:
-<textarea> <!--- </textarea>->x</textarea> --> </textarea>x
-Got:
-| <html>
-|   <head>
-|   <body>
-|     <textarea>
-|       " <!--- "
-|     "->x"
-|     " --> "
-|     "x"
-Expected:
-| <html>
-|   <head>
-|   <body>
-|     <textarea>
-|       " <!--- "
-|     "->x --> x"
 resources/tests6.dat:
 1
 8
@@ -2417,7 +2265,6 @@ resources/tests7.dat:
 19
 20
 24
-25
 26
 27
 28
@@ -2671,24 +2518,6 @@ Expected:
 | <body>
 |   "X"
 
-Test 25 of 30 in resources/tests7.dat failed. Input:
-<div><p>a</x> b
-Got:
-| <html>
-|   <head>
-|   <body>
-|     <div>
-|       <p>
-|         "a"
-|         " b"
-Expected:
-| <html>
-|   <head>
-|   <body>
-|     <div>
-|       <p>
-|         "a b"
-
 Test 26 of 30 in resources/tests7.dat failed. Input:
 <table><tr><td><code></code> </table>
 Got:
@@ -2818,8 +2647,7 @@ Got:
 "
 |       <div>
 |     "
-"
-|     "x"
+x"
 Expected:
 | <html>
 |   <head>
@@ -2842,8 +2670,7 @@ Got:
 |       "x"
 |       <div>
 |     "
-"
-|     "x"
+x"
 Expected:
 | <html>
 |   <head>
@@ -2863,8 +2690,7 @@ Got:
 |     <div>
 |       "x"
 |       <div>
-|     "x"
-|     "x"
+|     "xx"
 Expected:
 | <html>
 |   <head>
@@ -2883,8 +2709,7 @@ Got:
 |     <div>
 |       "x"
 |       <div>
-|     "y"
-|     "z"
+|     "yz"
 Expected:
 | <html>
 |   <head>
@@ -5306,24 +5131,8 @@ Expected:
 |     <form>
 |       <table>
 |         <form>
-resources/webkit01.dat:
-17
+resources/webkit01.dat: PASS
 
-Test 17 of 31 in resources/webkit01.dat failed. Input:
-<A>test< /A>
-Got:
-| <html>
-|   <head>
-|   <body>
-|     <a>
-|       "test"
-|       "< /A>"
-Expected:
-| <html>
-|   <head>
-|   <body>
-|     <a>
-|       "test< /A>"
 resources/doctype01.dat: PASS
 
 resources/scriptdata01.dat: PASS
@@ -5378,8 +5187,7 @@ Got:
 |       "1"
 |     <p>
 |       <a>
-|         "2"
-|         "3"
+|         "23"
 Expected:
 | <html>
 |   <head>
@@ -5401,8 +5209,7 @@ Got:
 |       "1"
 |       <a>
 |         <button>
-|           "2"
-|           "3"
+|           "23"
 Expected:
 | <html>
 |   <head>
@@ -5448,8 +5255,7 @@ Got:
 |       <a>
 |         "2"
 |         <div>
-|           "3"
-|           "4"
+|           "34"
 |     "5"
 Expected:
 | <html>
index 50d3db7..72ee5b5 100644 (file)
@@ -4686,6 +4686,7 @@ Expected:
 |       "<!--<noembed>"
 |     "-->"
 resources/webkit01.dat:
+15
 17
 20
 22
@@ -4697,6 +4698,22 @@ resources/webkit01.dat:
 30
 31
 
+Test 15 of 31 in resources/webkit01.dat failed. Input:
+<p>Test</p<p>Test2</p>
+Got:
+| <html>
+|   <head>
+|   <body>
+|     <p>
+|       "Test"
+|       "Test2"
+Expected:
+| <html>
+|   <head>
+|   <body>
+|     <p>
+|       "TestTest2"
+
 Test 17 of 31 in resources/webkit01.dat failed. Input:
 <A>test< /A>
 Got:
index 397ac8b..7bacf70 100644 (file)
@@ -157,6 +157,27 @@ CONSOLE MESSAGE: line 2: FOO<span>BAR</span>BAZ
 CONSOLE MESSAGE: line 2: FOO<span>BAR</span>BAZ
 CONSOLE MESSAGE: line 2: FOO<span>BAR</span>BAZ
 resources/webkit01.dat:
+549.1
+550.2
+551.3
+552.4
+553.5
+554.6
+555.7
+556.8
+557.9
+558.10
+559.11
+560.12
+561.13
+562.14
+563.15
+564.16
+565.17
+566.18
+567.19
+568.20
+569.21
 593.1
 594.2
 595.3
index 120b150..0158a6b 100644 (file)
@@ -2,6 +2,24 @@
 
         Reviewed by Eric Seidel.
 
+        Implement basic text node coalescing
+        https://bugs.webkit.org/show_bug.cgi?id=41623
+
+        This patch isn't the end-all, be-all of text node coalescing, but it's
+        a good start.
+
+        * dom/CharacterData.cpp:
+        (WebCore::CharacterData::parserAppendData):
+        (WebCore::CharacterData::appendData):
+        * dom/CharacterData.h:
+            - Added a new method to dance around mutation events.
+        * html/HTMLTreeBuilder.cpp:
+        (WebCore::HTMLTreeBuilder::insertTextNode):
+
+2010-07-05  Adam Barth  <abarth@webkit.org>
+
+        Reviewed by Eric Seidel.
+
         Implement InSelectMode
         https://bugs.webkit.org/show_bug.cgi?id=41627
 
index 075df47..5fbb6f2 100644 (file)
@@ -59,7 +59,7 @@ String CharacterData::substringData(unsigned offset, unsigned count, ExceptionCo
     return m_data->substring(offset, count);
 }
 
-void CharacterData::appendData(const String& arg, ExceptionCode&)
+PassRefPtr<StringImpl> CharacterData::parserAppendData(const String& arg)
 {
     String newStr = m_data;
     newStr.append(arg);
@@ -72,7 +72,13 @@ void CharacterData::appendData(const String& arg, ExceptionCode&)
         attach();
     } else if (renderer())
         toRenderText(renderer())->setTextWithOffset(m_data, oldStr->length(), 0);
-    
+
+    return oldStr.release();
+}
+
+void CharacterData::appendData(const String& arg, ExceptionCode&)
+{
+    RefPtr<StringImpl> oldStr = parserAppendData(arg);
     dispatchModifiedEvent(oldStr.get());
 }
 
index 5ca4b75..ecc0cf7 100644 (file)
@@ -42,6 +42,9 @@ public:
 
     StringImpl* dataImpl() { return m_data.get(); }
 
+    // Like appendData, but optimized for the parser (e.g., no mutation events).
+    PassRefPtr<StringImpl> parserAppendData(const String&);
+
 protected:
     CharacterData(Document* document, const String& text, ConstructionType type)
         : Node(document, type)
index 09042c9..71c8f2d 100644 (file)
@@ -1809,9 +1809,18 @@ void HTMLTreeBuilder::insertScriptElement(AtomicHTMLToken& token)
 
 void HTMLTreeBuilder::insertTextNode(AtomicHTMLToken& token)
 {
+    if (Node* lastChild = currentElement()->lastChild()) {
+        if (lastChild->isTextNode()) {
+            // FIXME: We're only supposed to append to this text node if it
+            // was the last text node inserted by the parser.
+            CharacterData* textNode = static_cast<CharacterData*>(lastChild);
+            textNode->parserAppendData(token.characters());
+            return;
+        }
+    }
     attach(currentElement(), Text::create(m_document, token.characters()));
 }
-    
+
 PassRefPtr<Element> HTMLTreeBuilder::createElement(AtomicHTMLToken& token)
 {
     RefPtr<Element> element = HTMLElementFactory::createHTMLElement(QualifiedName(nullAtom, token.name(), xhtmlNamespaceURI), m_document, 0);