[webkit-changes] cvs commit: WebCore/layout-tests/fast/text/whitespace 013-expected.txt

Darin darin at opensource.apple.com
Fri Sep 23 10:38:07 PDT 2005


darin       05/09/23 10:38:07

  Modified:    .        ChangeLog
               khtml/html htmltokenizer.cpp htmltokenizer.h
               layout-tests/fast/text/whitespace 013-expected.txt
  Log:
          Reviewed by Maciej.
          Tested, landed, and tweaked a tiny bit by Darin.
  
          - fixed http://bugzilla.opendarwin.org/show_bug.cgi?id=5092
            Random crashes when running the layout tests
  
          Fix was to remove the "pending" concept from the tokenizer, which streamlined the
          code and also fixed one minor bug seen in one of the layout tests where we discarded
          too much after the <pre>.
  
          * khtml/html/htmltokenizer.h: Removed the addPending function and the pending
          field. Also removed SpaceDiscard and AllDiscard since we don't use them any more.
          We still use LFDiscard to discard the first LF after a <pre>.
  
          * khtml/html/htmltokenizer.cpp:
          (khtml::HTMLTokenizer::begin): Don't initialize pending.
          (khtml::HTMLTokenizer::processListing): Tweaked formatting to match guidelines.
          Removed calls to addPending. Write "\n" right away instead of using LFPending.
          Write " " right away instead of using SpacePending by removing separate code for space.
          (khtml::HTMLTokenizer::write): Ditto.
          (khtml::HTMLTokenizer::finish): Remove the call to addPending we just added a few
          days ago. This is what was causing the crash.
  
          * layout-tests/fast/text/whitespace/013-expected.txt: Updated results. Old results
          incorrectly expected spaces *and* a newline to be discarded after a <pre> tag, which
          was happening by accident. I tested Firefox and it matches what we do now -- only
          discards a newline just after a <pre>, not a run of spaces and a subsequent newline.
  
  Revision  Changes    Path
  1.149     +30 -0     WebCore/ChangeLog
  
  Index: ChangeLog
  ===================================================================
  RCS file: /cvs/root/WebCore/ChangeLog,v
  retrieving revision 1.148
  retrieving revision 1.149
  diff -u -r1.148 -r1.149
  --- ChangeLog	23 Sep 2005 03:54:59 -0000	1.148
  +++ ChangeLog	23 Sep 2005 17:38:05 -0000	1.149
  @@ -1,3 +1,33 @@
  +2005-09-23  David Hyatt  <hyatt at apple.com>
  +
  +        Reviewed by Maciej.
  +        Tested, landed, and tweaked a tiny bit by Darin.
  +
  +        - fixed http://bugzilla.opendarwin.org/show_bug.cgi?id=5092
  +          Random crashes when running the layout tests
  +        
  +        Fix was to remove the "pending" concept from the tokenizer, which streamlined the
  +        code and also fixed one minor bug seen in one of the layout tests where we discarded
  +        too much after the <pre>.
  +
  +        * khtml/html/htmltokenizer.h: Removed the addPending function and the pending
  +        field. Also removed SpaceDiscard and AllDiscard since we don't use them any more.
  +        We still use LFDiscard to discard the first LF after a <pre>.
  +
  +        * khtml/html/htmltokenizer.cpp:
  +        (khtml::HTMLTokenizer::begin): Don't initialize pending.
  +        (khtml::HTMLTokenizer::processListing): Tweaked formatting to match guidelines.
  +        Removed calls to addPending. Write "\n" right away instead of using LFPending.
  +        Write " " right away instead of using SpacePending by removing separate code for space.
  +        (khtml::HTMLTokenizer::write): Ditto.
  +        (khtml::HTMLTokenizer::finish): Remove the call to addPending we just added a few
  +        days ago. This is what was causing the crash.
  +
  +        * layout-tests/fast/text/whitespace/013-expected.txt: Updated results. Old results
  +        incorrectly expected spaces *and* a newline to be discarded after a <pre> tag, which
  +        was happening by accident. I tested Firefox and it matches what we do now -- only
  +        discards a newline just after a <pre>, not a run of spaces and a subsequent newline.
  +
   2005-09-22  Eric Seidel  <eseidel at apple.com>
           Fix by Kimmo Kinnunen <kimmo.t.kinnunen at nokia.com>
   
  
  
  
  1.115     +16 -157   WebCore/khtml/html/htmltokenizer.cpp
  
  Index: htmltokenizer.cpp
  ===================================================================
  RCS file: /cvs/root/WebCore/khtml/html/htmltokenizer.cpp,v
  retrieving revision 1.114
  retrieving revision 1.115
  diff -u -r1.114 -r1.115
  --- htmltokenizer.cpp	20 Sep 2005 23:01:40 -0000	1.114
  +++ htmltokenizer.cpp	23 Sep 2005 17:38:06 -0000	1.115
  @@ -241,7 +241,6 @@
       buffer = KHTML_ALLOC_QCHAR_VEC( 255 );
       dest = buffer;
       tag = NoTag;
  -    pending = NonePending;
       discard = NoneDiscard;
       plaintext = false;
       xmp = false;
  @@ -281,63 +280,33 @@
   {
       // This function adds the listing 'list' as
       // preformatted text-tokens to the token-collection
  -    while ( !list.isEmpty() )
  -    {
  +    while (!list.isEmpty()) {
           checkBuffer();
   
  -        if (skipLF && ( *list != '\n' ))
  -        {
  +        if (skipLF && *list != '\n')
               skipLF = false;
  -        }
   
  -        if (skipLF)
  -        {
  +        if (skipLF) {
               skipLF = false;
               ++list;
  -        }
  -        else if (( *list == '\n' ) || ( *list == '\r' ))
  -        {
  +        } else if (*list == '\n' || *list == '\r') {
               if (discard == LFDiscard)
  -            {
                   // Ignore this LF
                   discard = NoneDiscard; // We have discarded 1 LF
  -            }
               else
  -            {
  -                // Process this LF
  -                if (pending)
  -                    addPending();
  -                pending = LFPending;
  -            }
  +                *dest++ = '\n';
  +
               /* Check for MS-DOS CRLF sequence */
               if (*list == '\r')
  -            {
                   skipLF = true;
  -            }
  -            ++list;
  -        }
  -        else if ( *list == ' ' )
  -        {
  -            if (pending)
  -                addPending();
  -            pending = SpacePending;
   
               ++list;
  -        }
  -        else
  -        {
  +        } else {
               discard = NoneDiscard;
  -            if (pending)
  -                addPending();
  -
               *dest++ = *list;
               ++list;
           }
  -
       }
  -
  -    if (pending)
  -        addPending();
   }
   
   void HTMLTokenizer::parseSpecial(TokenizerString &src)
  @@ -674,7 +643,7 @@
               // We got a '?>' sequence
               processingInstruction = false;
               ++src;
  -            discard=LFDiscard;
  +            discard = LFDiscard;
               return; // Finished parsing comment!
           }
           ++src;
  @@ -1358,44 +1327,6 @@
       return;
   }
   
  -void HTMLTokenizer::addPending()
  -{
  -    if ( select && !script )
  -    {
  -        *dest++ = ' ';
  -    }
  -    else if ( textarea || script )
  -    {
  -        switch(pending) {
  -        case LFPending:  *dest++ = '\n'; break;
  -        case SpacePending: *dest++ = ' '; break;
  -        case NonePending:
  -            assert(0);
  -        }
  -    }
  -    else
  -    {
  -        switch (pending)
  -        {
  -        case SpacePending:
  -            // Insert a breaking space
  -            *dest++ = QChar(' ');
  -            break;
  -
  -        case LFPending:
  -            *dest = '\n';
  -            dest++;
  -            break;
  -
  -        case NonePending:
  -            assert(0);
  -            break;
  -        }
  -    }
  -    
  -    pending = NonePending;
  -}
  -
   void HTMLTokenizer::write(const TokenizerString &str, bool appendData)
   {
   #ifdef TOKEN_DEBUG
  @@ -1530,8 +1461,6 @@
                   {
                       // Invalid tag
                       // Add as is
  -                    if (pending)
  -                        addPending();
                       *dest = '<';
                       dest++;
                       continue;
  @@ -1539,17 +1468,6 @@
               }
               }; // end case
   
  -            if ( pending ) {
  -                if ( script || (!parser->selectMode() && (!parser->noSpaces() || dest > buffer )))
  -                    addPending();
  -                // just forget it
  -                else
  -                    pending = NonePending;
  -            }
  -
  -            if (cc == '/' && discard == AllDiscard)
  -                discard = NoneDiscard; // A close tag. No need to discard LF.
  -                    
               processToken();
   
               cBufferPos = 0;
  @@ -1559,8 +1477,6 @@
           else if ( cc == '&' && !src.escaped())
           {
               ++src;
  -            if ( pending )
  -                addPending();
               parseEntity(src, dest, true);
           }
           else if ( cc == '<' && !src.escaped())
  @@ -1569,74 +1485,19 @@
               ++src;
               startTag = true;
           }
  -        else if (( cc == '\n' ) || ( cc == '\r' ))
  -        {
  -	    if (select && !script)
  -            {
  -                if (discard == LFDiscard)
  -                {
  -                    // Ignore this LF
  -                    discard = NoneDiscard; // We have discarded 1 LF
  -                }
  -                else if(discard == AllDiscard)
  -                {
  -                }
  -                else
  -                 {
  -                     // Process this LF
  -                    if (pending == NonePending)
  -                         pending = LFPending;
  -                }
  -            }
  -            else {
  -                if (discard == LFDiscard || discard == AllDiscard)
  -                {
  -                    // Ignore this LF
  -                    discard = NoneDiscard; // We have discarded 1 LF
  -                }
  -                else
  -                {
  -                    // Process this LF
  -                    if (pending)
  -                        addPending();
  -                    pending = LFPending;
  -                }
  -            }
  +        else if (cc == '\n' || cc == '\r') {
  +            if (discard == LFDiscard)
  +                // Ignore this LF
  +                discard = NoneDiscard; // We have discarded 1 LF
  +            else
  +                // Process this LF
  +                *dest++ = '\n';
               
               /* Check for MS-DOS CRLF sequence */
               if (cc == '\r')
  -            {
                   skipLF = true;
  -            }
               ++src;
  -        }
  -        else if (cc == ' ')
  -        {
  -	    if (select && !script) {
  -                if(discard == SpaceDiscard)
  -                    discard = NoneDiscard;
  -                 else if(discard == AllDiscard)
  -                 { }
  -                 else
  -                     pending = SpacePending;
  -            
  -            }
  -            else {
  -                if (discard == AllDiscard)
  -                    discard = NoneDiscard;
  -            
  -                if (pending)
  -                    addPending();
  -                pending = SpacePending;
  -            }
  -            
  -            ++src;
  -        }
  -        else
  -        {
  -            if (pending)
  -                addPending();
  -
  +        } else {
               discard = NoneDiscard;
   #if QT_VERSION < 300
               unsigned char row = src->row();
  @@ -1817,8 +1678,6 @@
       // this indicates we will not receive any more data... but if we are waiting on
       // an external script to load, we can't finish parsing until that is done
       noMoreData = true;
  -    if (pending) // Flush any remaining whitespace.
  -        addPending();
       if (!inWrite && !loadingExtScript && !m_executingScript && !onHold && !timerId)
           end(); // this actually causes us to be deleted
   }
  
  
  
  1.40      +2 -13     WebCore/khtml/html/htmltokenizer.h
  
  Index: htmltokenizer.h
  ===================================================================
  RCS file: /cvs/root/WebCore/khtml/html/htmltokenizer.h,v
  retrieving revision 1.39
  retrieving revision 1.40
  diff -u -r1.39 -r1.40
  --- htmltokenizer.h	29 Jul 2005 23:42:48 -0000	1.39
  +++ htmltokenizer.h	23 Sep 2005 17:38:06 -0000	1.40
  @@ -132,7 +132,6 @@
       void end();
   
       void reset();
  -    void addPending();
       void processToken();
       void processListing(TokenizerString list);
   
  @@ -193,21 +192,11 @@
           DoubleQuote
       } tquote;
   
  -    enum
  -    {
  -        NonePending = 0,
  -        SpacePending,
  -        LFPending,
  -    } pending;
  -
  -    // Discard line breaks immediately after start-tags
  -    // Discard spaces after '=' within tags
  +    // Discard line breaks immediately after <pre> tags
       enum
       {
           NoneDiscard = 0,
  -        SpaceDiscard,
  -        LFDiscard,
  -        AllDiscard  // discard all spaces, LF's etc until next non white char
  +        LFDiscard
       } discard;
   
       // Discard the LF part of CRLF sequence
  
  
  
  1.4       +15 -14    WebCore/layout-tests/fast/text/whitespace/013-expected.txt
  
  Index: 013-expected.txt
  ===================================================================
  RCS file: /cvs/root/WebCore/layout-tests/fast/text/whitespace/013-expected.txt,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- 013-expected.txt	14 Jun 2005 22:37:09 -0000	1.3
  +++ 013-expected.txt	23 Sep 2005 17:38:06 -0000	1.4
  @@ -1,22 +1,23 @@
   layer at (0,0) size 800x600
     RenderCanvas at (0,0) size 800x600
  -layer at (0,0) size 800x144
  -  RenderBlock {HTML} at (0,0) size 800x144
  -    RenderBody {BODY} at (8,8) size 784x128
  +layer at (0,0) size 800x157
  +  RenderBlock {HTML} at (0,0) size 800x157
  +    RenderBody {BODY} at (8,8) size 784x141
         RenderBlock (anonymous) at (0,0) size 784x18
           RenderInline {DIV} at (0,0) size 528x16 [color=#FFFFFF] [bgcolor=#FF0000]
             RenderText {TEXT} at (0,1) size 528x16
               text run at (0,1) width 528: "Ahem_font_required_for_this_test."
           RenderText {TEXT} at (0,0) size 0x0
  -      RenderTable {TABLE} at (0,18) size 552x110
  -        RenderTableSection {TBODY} at (0,0) size 0x110
  +      RenderTable {TABLE} at (0,18) size 279x123
  +        RenderTableSection {TBODY} at (0,0) size 0x123
             RenderTableRow {TR} at (0,0) size 0x0
  -            RenderTableCell {TD} at (2,2) size 548x106 [r=0 c=0 rs=1 cs=1]
  -              RenderBlock {PRE} at (1,14) size 546x78 [color=#00FF00] [bgcolor=#008000]
  -                RenderText {TEXT} at (0,0) size 546x78
  -                  text run at (0,0) width 546: "                      xxxx xxxx xxxx xxxx "
  -                  text run at (0,13) width 273: " x  x x  x x    x    "
  -                  text run at (0,26) width 260: " xxxx xxxx xxxx xxxx"
  -                  text run at (0,39) width 273: " x    x  x    x    x "
  -                  text run at (0,52) width 273: " x    x  x xxxx xxxx "
  -                  text run at (0,65) width 273: "                     "
  +            RenderTableCell {TD} at (2,2) size 275x119 [r=0 c=0 rs=1 cs=1]
  +              RenderBlock {PRE} at (1,14) size 273x91 [color=#00FF00] [bgcolor=#008000]
  +                RenderText {TEXT} at (0,0) size 273x91
  +                  text run at (0,0) width 273: "                     "
  +                  text run at (0,13) width 273: " xxxx xxxx xxxx xxxx "
  +                  text run at (0,26) width 273: " x  x x  x x    x    "
  +                  text run at (0,39) width 260: " xxxx xxxx xxxx xxxx"
  +                  text run at (0,52) width 273: " x    x  x    x    x "
  +                  text run at (0,65) width 273: " x    x  x xxxx xxxx "
  +                  text run at (0,78) width 273: "                     "
  
  
  



More information about the webkit-changes mailing list