Title: [103013] trunk
Revision
103013
Author
[email protected]
Date
2011-12-15 19:05:08 -0800 (Thu, 15 Dec 2011)

Log Message

Unreviewed, rolling out r103000.
http://trac.webkit.org/changeset/103000
https://bugs.webkit.org/show_bug.cgi?id=74658

Does not handle text/plain documents correctly.

Source/WebCore: 

* html/parser/HTMLTokenizer.cpp:
* html/parser/HTMLTokenizer.h:
* html/parser/HTMLTreeBuilder.cpp:
* html/parser/HTMLTreeBuilder.h:
* xml/parser/MarkupTokenizerBase.h:

LayoutTests: 

* html5lib/runner-expected.txt:
* platform/chromium/html5lib/runner-expected.txt:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (103012 => 103013)


--- trunk/LayoutTests/ChangeLog	2011-12-16 03:02:33 UTC (rev 103012)
+++ trunk/LayoutTests/ChangeLog	2011-12-16 03:05:08 UTC (rev 103013)
@@ -1,3 +1,14 @@
+2011-12-15  Kenneth Russell  <[email protected]>
+
+        Unreviewed, rolling out r103000.
+        http://trac.webkit.org/changeset/103000
+        https://bugs.webkit.org/show_bug.cgi?id=74658
+
+        Does not handle text/plain documents correctly.
+
+        * html5lib/runner-expected.txt:
+        * platform/chromium/html5lib/runner-expected.txt:
+
 2011-12-15  James Robinson  <[email protected]>
 
         [chromium] Set the CCLayerTreeHost pointer on LayerChromium instances eagerly

Modified: trunk/LayoutTests/html5lib/runner-expected.txt (103012 => 103013)


--- trunk/LayoutTests/html5lib/runner-expected.txt	2011-12-16 03:02:33 UTC (rev 103012)
+++ trunk/LayoutTests/html5lib/runner-expected.txt	2011-12-16 03:05:08 UTC (rev 103013)
@@ -126,8 +126,28 @@
 
 resources/tests2.dat: PASS
 
-resources/tests3.dat: PASS
+resources/tests3.dat:
+12
 
+Test 12 of 24 in resources/tests3.dat failed. Input:
+<!DOCTYPE html><pre>&#x0a;&#x0a;A</pre>
+Got:
+| <!DOCTYPE html>
+| <html>
+|   <head>
+|   <body>
+|     <pre>
+|       "
+
+A"
+Expected:
+| <!DOCTYPE html>
+| <html>
+|   <head>
+|   <body>
+|     <pre>
+|       "
+A"
 resources/tests4.dat: PASS
 
 resources/tests5.dat: PASS

Modified: trunk/LayoutTests/platform/chromium/html5lib/runner-expected.txt (103012 => 103013)


--- trunk/LayoutTests/platform/chromium/html5lib/runner-expected.txt	2011-12-16 03:02:33 UTC (rev 103012)
+++ trunk/LayoutTests/platform/chromium/html5lib/runner-expected.txt	2011-12-16 03:05:08 UTC (rev 103013)
@@ -126,8 +126,28 @@
 
 resources/tests2.dat: PASS
 
-resources/tests3.dat: PASS
+resources/tests3.dat:
+12
 
+Test 12 of 24 in resources/tests3.dat failed. Input:
+<!DOCTYPE html><pre>&#x0a;&#x0a;A</pre>
+Got:
+| <!DOCTYPE html>
+| <html>
+|   <head>
+|   <body>
+|     <pre>
+|       "
+
+A"
+Expected:
+| <!DOCTYPE html>
+| <html>
+|   <head>
+|   <body>
+|     <pre>
+|       "
+A"
 resources/tests4.dat: PASS
 
 resources/tests5.dat: PASS

Modified: trunk/Source/WebCore/ChangeLog (103012 => 103013)


--- trunk/Source/WebCore/ChangeLog	2011-12-16 03:02:33 UTC (rev 103012)
+++ trunk/Source/WebCore/ChangeLog	2011-12-16 03:05:08 UTC (rev 103013)
@@ -1,3 +1,17 @@
+2011-12-15  Kenneth Russell  <[email protected]>
+
+        Unreviewed, rolling out r103000.
+        http://trac.webkit.org/changeset/103000
+        https://bugs.webkit.org/show_bug.cgi?id=74658
+
+        Does not handle text/plain documents correctly.
+
+        * html/parser/HTMLTokenizer.cpp:
+        * html/parser/HTMLTokenizer.h:
+        * html/parser/HTMLTreeBuilder.cpp:
+        * html/parser/HTMLTreeBuilder.h:
+        * xml/parser/MarkupTokenizerBase.h:
+
 2011-12-15  James Robinson  <[email protected]>
 
         [chromium] Set the CCLayerTreeHost pointer on LayerChromium instances eagerly

Modified: trunk/Source/WebCore/html/parser/HTMLTokenizer.cpp (103012 => 103013)


--- trunk/Source/WebCore/html/parser/HTMLTokenizer.cpp	2011-12-16 03:02:33 UTC (rev 103012)
+++ trunk/Source/WebCore/html/parser/HTMLTokenizer.cpp	2011-12-16 03:05:08 UTC (rev 103013)
@@ -136,6 +136,7 @@
     m_state = HTMLTokenizerState::DataState;
     m_token = 0;
     m_lineNumber = 0;
+    m_skipLeadingNewLineForListing = false;
     m_forceNullCharacterReplacement = false;
     m_shouldAllowCDATA = false;
     m_additionalAllowedCharacter = '\0';
@@ -210,6 +211,30 @@
         return haveBufferedCharacterToken();
     UChar cc = m_inputStreamPreprocessor.nextInputCharacter();
 
+    // http://www.whatwg.org/specs/web-apps/current-work/multipage/tokenization.html#parsing-main-inbody
+    // Note that this logic is different than the generic \r\n collapsing
+    // handled in the input stream preprocessor. This logic is here as an
+    // "authoring convenience" so folks can write:
+    //
+    // <pre>
+    // lorem ipsum
+    // lorem ipsum
+    // </pre>
+    //
+    // without getting an extra newline at the start of their <pre> element.
+    if (m_skipLeadingNewLineForListing) {
+        m_skipLeadingNewLineForListing = false;
+        if (cc == '\n') {
+            if (m_state == HTMLTokenizerState::DataState)
+                HTML_ADVANCE_TO(DataState);
+            if (m_state == HTMLTokenizerState::RCDATAState)
+                HTML_ADVANCE_TO(RCDATAState);
+            // When parsing text/plain documents, we run the tokenizer in the
+            // PLAINTEXTState and ignore m_skipLeadingNewLineForListing.
+            ASSERT(m_state == HTMLTokenizerState::PLAINTEXTState);
+        }
+    }
+
     // Source: http://www.whatwg.org/specs/web-apps/current-work/#tokenisation0
     switch (m_state) {
     HTML_BEGIN_STATE(DataState) {

Modified: trunk/Source/WebCore/html/parser/HTMLTokenizer.h (103012 => 103013)


--- trunk/Source/WebCore/html/parser/HTMLTokenizer.h	2011-12-16 03:02:33 UTC (rev 103012)
+++ trunk/Source/WebCore/html/parser/HTMLTokenizer.h	2011-12-16 03:05:08 UTC (rev 103013)
@@ -146,6 +146,10 @@
     //
     void updateStateFor(const AtomicString& tagName, Frame*);
 
+    // Hack to skip leading newline in <pre>/<listing> for authoring ease.
+    // http://www.whatwg.org/specs/web-apps/current-work/multipage/tokenization.html#parsing-main-inbody
+    void setSkipLeadingNewLineForListing(bool value) { m_skipLeadingNewLineForListing = value; }
+
     bool forceNullCharacterReplacement() const { return m_forceNullCharacterReplacement; }
     void setForceNullCharacterReplacement(bool value) { m_forceNullCharacterReplacement = value; }
 

Modified: trunk/Source/WebCore/html/parser/HTMLTreeBuilder.cpp (103012 => 103013)


--- trunk/Source/WebCore/html/parser/HTMLTreeBuilder.cpp	2011-12-16 03:02:33 UTC (rev 103012)
+++ trunk/Source/WebCore/html/parser/HTMLTreeBuilder.cpp	2011-12-16 03:05:08 UTC (rev 103013)
@@ -268,13 +268,6 @@
 
     bool isEmpty() const { return m_current == m_end; }
 
-    void skipAtMostOneLeadingNewline()
-    {
-        ASSERT(!isEmpty());
-        if (*m_current == '\n')
-            ++m_current;
-    }
-
     void skipLeadingWhitespace()
     {
         skipLeading<isHTMLSpace>();
@@ -356,7 +349,6 @@
     , m_isPaused(false)
     , m_insertionMode(InitialMode)
     , m_originalInsertionMode(InitialMode)
-    , m_shouldSkipLeadingNewline(false)
     , m_parser(parser)
     , m_scriptToProcessStartPosition(uninitializedPositionValue1())
     , m_lastScriptElementStartPosition(TextPosition::belowRangePosition())
@@ -375,7 +367,6 @@
     , m_isPaused(false)
     , m_insertionMode(InitialMode)
     , m_originalInsertionMode(InitialMode)
-    , m_shouldSkipLeadingNewline(false)
     , m_parser(parser)
     , m_scriptToProcessStartPosition(uninitializedPositionValue1())
     , m_lastScriptElementStartPosition(TextPosition::belowRangePosition())
@@ -819,7 +810,7 @@
     if (token.name() == preTag || token.name() == listingTag) {
         processFakePEndTagIfPInButtonScope();
         m_tree.insertHTMLElement(token);
-        m_shouldSkipLeadingNewline = true;
+        m_parser->tokenizer()->setSkipLeadingNewLineForListing(true);
         m_framesetOk = false;
         return;
     }
@@ -946,7 +937,7 @@
     }
     if (token.name() == textareaTag) {
         m_tree.insertHTMLElement(token);
-        m_shouldSkipLeadingNewline = true;
+        m_parser->tokenizer()->setSkipLeadingNewLineForListing(true);
         m_parser->tokenizer()->setState(HTMLTokenizerState::RCDATAState);
         m_originalInsertionMode = m_insertionMode;
         m_framesetOk = false;
@@ -2281,24 +2272,6 @@
 void HTMLTreeBuilder::processCharacterBuffer(ExternalCharacterTokenBuffer& buffer)
 {
 ReprocessBuffer:
-    // http://www.whatwg.org/specs/web-apps/current-work/multipage/tokenization.html#parsing-main-inbody
-    // Note that this logic is different than the generic \r\n collapsing
-    // handled in the input stream preprocessor. This logic is here as an
-    // "authoring convenience" so folks can write:
-    //
-    // <pre>
-    // lorem ipsum
-    // lorem ipsum
-    // </pre>
-    //
-    // without getting an extra newline at the start of their <pre> element.
-    if (m_shouldSkipLeadingNewline) {
-        m_shouldSkipLeadingNewline = false;
-        buffer.skipAtMostOneLeadingNewline();
-        if (buffer.isEmpty())
-            return;
-    }
-
     switch (insertionMode()) {
     case InitialMode: {
         ASSERT(insertionMode() == InitialMode);

Modified: trunk/Source/WebCore/html/parser/HTMLTreeBuilder.h (103012 => 103013)


--- trunk/Source/WebCore/html/parser/HTMLTreeBuilder.h	2011-12-16 03:02:33 UTC (rev 103012)
+++ trunk/Source/WebCore/html/parser/HTMLTreeBuilder.h	2011-12-16 03:05:08 UTC (rev 103013)
@@ -239,8 +239,6 @@
     // http://www.whatwg.org/specs/web-apps/current-work/multipage/tokenization.html#pending-table-character-tokens
     StringBuilder m_pendingTableCharacters;
 
-    bool m_shouldSkipLeadingNewline;
-
     // We access parser because HTML5 spec requires that we be able to change the state of the tokenizer
     // from within parser actions. We also need it to track the current position.
     HTMLDocumentParser* m_parser;

Modified: trunk/Source/WebCore/xml/parser/MarkupTokenizerBase.h (103012 => 103013)


--- trunk/Source/WebCore/xml/parser/MarkupTokenizerBase.h	2011-12-16 03:02:33 UTC (rev 103012)
+++ trunk/Source/WebCore/xml/parser/MarkupTokenizerBase.h	2011-12-16 03:05:08 UTC (rev 103013)
@@ -197,6 +197,7 @@
     Token* m_token;
     int m_lineNumber;
 
+    bool m_skipLeadingNewLineForListing;
     bool m_forceNullCharacterReplacement;
 
     // http://www.whatwg.org/specs/web-apps/current-work/#additional-allowed-character
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to