[webkit-changes] cvs commit: WebCore/khtml/xml xml_tokenizer.cpp xml_tokenizer.h

Adele adele at opensource.apple.com
Tue Oct 25 15:32:56 PDT 2005


adele       05/10/25 15:32:55

  Modified:    .        ChangeLog
               khtml/html htmltokenizer.cpp htmltokenizer.h
               khtml/xml xml_tokenizer.cpp xml_tokenizer.h
  Log:
          Reviewed by Vicki.
  
          Fixed <rdar://problem/4098450> RoboHelp-generated html help system crashes in latest Safari -KWQValueListImpl::copyOnWrite
  
          The tokenizer's timer was causing the tokenizer to be deleted twice.
          In timerEvent, we'll now check to see if the write has destroyed the tokenizer before trying to do it again.
  
          * khtml/html/htmltokenizer.cpp:
          (khtml::HTMLTokenizer::write): Returns a boolean to indicate whether end() gets called
          (khtml::HTMLTokenizer::timerEvent): Moved code from allDataProcessed, and now, checks to see if write() called end() to notify WebKit that processing is done.
          * khtml/html/htmltokenizer.h: write() returns a bool.
          * khtml/xml/xml_tokenizer.cpp: (khtml::XMLTokenizer::write): returns a bool (always false in the XMLTokenizer case).
          * khtml/xml/xml_tokenizer.h: ditto.
  
  Revision  Changes    Path
  1.287     +16 -0     WebCore/ChangeLog
  
  Index: ChangeLog
  ===================================================================
  RCS file: /cvs/root/WebCore/ChangeLog,v
  retrieving revision 1.286
  retrieving revision 1.287
  diff -u -r1.286 -r1.287
  --- ChangeLog	25 Oct 2005 22:26:26 -0000	1.286
  +++ ChangeLog	25 Oct 2005 22:32:51 -0000	1.287
  @@ -1,3 +1,19 @@
  +2005-10-25  Adele Peterson  <adele at apple.com>
  +
  +        Reviewed by Vicki.
  +
  +        Fixed <rdar://problem/4098450> RoboHelp-generated html help system crashes in latest Safari -KWQValueListImpl::copyOnWrite
  +
  +        The tokenizer's timer was causing the tokenizer to be deleted twice.  
  +        In timerEvent, we'll now check to see if the write has destroyed the tokenizer before trying to do it again.
  +
  +        * khtml/html/htmltokenizer.cpp:
  +        (khtml::HTMLTokenizer::write): Returns a boolean to indicate whether end() gets called
  +        (khtml::HTMLTokenizer::timerEvent): Moved code from allDataProcessed, and now, checks to see if write() called end() to notify WebKit that processing is done.
  +        * khtml/html/htmltokenizer.h: write() returns a bool.
  +        * khtml/xml/xml_tokenizer.cpp: (khtml::XMLTokenizer::write): returns a bool (always false in the XMLTokenizer case).
  +        * khtml/xml/xml_tokenizer.h: ditto.
  +
   2005-10-25  Beth Dakin  <bdakin at apple.com>
   
           Reviewed by Maciej
  
  
  
  1.123     +14 -22    WebCore/khtml/html/htmltokenizer.cpp
  
  Index: htmltokenizer.cpp
  ===================================================================
  RCS file: /cvs/root/WebCore/khtml/html/htmltokenizer.cpp,v
  retrieving revision 1.122
  retrieving revision 1.123
  diff -u -r1.122 -r1.123
  --- htmltokenizer.cpp	24 Oct 2005 01:39:40 -0000	1.122
  +++ htmltokenizer.cpp	25 Oct 2005 22:32:54 -0000	1.123
  @@ -1373,17 +1373,17 @@
       return true;
   }
   
  -void HTMLTokenizer::write(const TokenizerString &str, bool appendData)
  +bool HTMLTokenizer::write(const TokenizerString &str, bool appendData)
   {
   #ifdef TOKEN_DEBUG
       kdDebug( 6036 ) << this << " Tokenizer::write(\"" << str.toString() << "\"," << appendData << ")" << endl;
   #endif
   
       if (!buffer)
  -        return;
  +        return false;
       
       if (m_parserStopped)
  -        return;
  +        return false;
   
       if ( ( m_executingScript && appendData ) || !pendingScripts.isEmpty() ) {
           // don't parse; we will do this later
  @@ -1392,12 +1392,12 @@
   	} else {
   	    pendingSrc.append(str);
   	}
  -        return;
  +        return false;
       }
   
       if (onHold) {
           src.append(str);
  -        return;
  +        return false;
       }
       
       if (!src.isEmpty())
  @@ -1407,7 +1407,7 @@
   
       // Once a timer is set, it has control of when the tokenizer continues.
       if (timerId)
  -        return;
  +        return false;
   
       bool wasInWrite = inWrite;
       inWrite = true;
  @@ -1546,8 +1546,11 @@
   
       m_state = state;
   
  -    if (noMoreData && !inWrite && !state.loadingExtScript() && !m_executingScript && !timerId)
  +    if (noMoreData && !inWrite && !state.loadingExtScript() && !m_executingScript && !timerId) {
           end(); // this actually causes us to be deleted
  +        return true;
  +    }
  +    return false;
   }
   
   void HTMLTokenizer::stopParsing()
  @@ -1589,22 +1592,11 @@
           }
           
           // Invoke write() as though more data came in.
  -        bool oldNoMoreData = noMoreData;
  -        noMoreData = false;  // This prevents write() from deleting the tokenizer.
  -        write(TokenizerString(), true);
  -        noMoreData = oldNoMoreData;
  -        
  -        // If the timer dies (and stays dead after the write),  we need to let WebKit know that we're done processing the data.
  -        allDataProcessed();
  -    }
  -}
  -
  -void HTMLTokenizer::allDataProcessed()
  -{
  -    if (noMoreData && !inWrite && !m_state.loadingExtScript() && !m_executingScript && !onHold && !timerId) {
           QGuardedPtr<KHTMLView> savedView = view;
  -        end();
  -        if (savedView) {
  +        bool didCallEnd = write(TokenizerString(), true);
  +      
  +        // If we called end() during the write,  we need to let WebKit know that we're done processing the data.
  +        if (didCallEnd && savedView) {
               KHTMLPart *part = savedView->part();
               if (part) {
                   part->tokenizerProcessedData();
  
  
  
  1.44      +1 -1      WebCore/khtml/html/htmltokenizer.h
  
  Index: htmltokenizer.h
  ===================================================================
  RCS file: /cvs/root/WebCore/khtml/html/htmltokenizer.h,v
  retrieving revision 1.43
  retrieving revision 1.44
  diff -u -r1.43 -r1.44
  --- htmltokenizer.h	22 Oct 2005 01:41:35 -0000	1.43
  +++ htmltokenizer.h	25 Oct 2005 22:32:54 -0000	1.44
  @@ -119,7 +119,7 @@
       HTMLTokenizer(DOM::DocumentPtr *, DOM::DocumentFragmentImpl *frag, bool includesComments=false);
       virtual ~HTMLTokenizer();
   
  -    virtual void write(const TokenizerString &str, bool appendData);
  +    virtual bool write(const TokenizerString &str, bool appendData);
       virtual void finish();
       virtual void setOnHold(bool onHold);
       virtual void setForceSynchronous(bool force);
  
  
  
  1.47      +3 -2      WebCore/khtml/xml/xml_tokenizer.cpp
  
  Index: xml_tokenizer.cpp
  ===================================================================
  RCS file: /cvs/root/WebCore/khtml/xml/xml_tokenizer.cpp,v
  retrieving revision 1.46
  retrieving revision 1.47
  diff -u -r1.46 -r1.47
  --- xml_tokenizer.cpp	22 Oct 2005 01:41:36 -0000	1.46
  +++ xml_tokenizer.cpp	25 Oct 2005 22:32:55 -0000	1.47
  @@ -92,7 +92,7 @@
       enum ErrorType { warning, nonFatal, fatal };
   
       // from Tokenizer
  -    virtual void write(const TokenizerString &str, bool);
  +    virtual bool write(const TokenizerString &str, bool);
       virtual void finish();
       virtual void setOnHold(bool onHold);
       virtual bool isWaitingForScripts() const;
  @@ -257,9 +257,10 @@
           m_cachedScript->deref(this);
   }
   
  -void XMLTokenizer::write(const TokenizerString &s, bool /*appendData*/ )
  +bool XMLTokenizer::write(const TokenizerString &s, bool /*appendData*/ )
   {
       m_xmlCode += s.toString();
  +    return false;
   }
   
   void XMLTokenizer::setOnHold(bool onHold)
  
  
  
  1.20      +1 -1      WebCore/khtml/xml/xml_tokenizer.h
  
  Index: xml_tokenizer.h
  ===================================================================
  RCS file: /cvs/root/WebCore/khtml/xml/xml_tokenizer.h,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- xml_tokenizer.h	22 Oct 2005 01:41:36 -0000	1.19
  +++ xml_tokenizer.h	25 Oct 2005 22:32:55 -0000	1.20
  @@ -56,7 +56,7 @@
       // received during executing a script must be appended, hence the
       // extra bool to be able to distinguish between both cases. document.write()
       // always uses false, while khtmlpart uses true
  -    virtual void write(const TokenizerString &str, bool appendData) = 0;
  +    virtual bool write(const TokenizerString &str, bool appendData) = 0;
       virtual void finish() = 0;
       virtual void setOnHold(bool onHold) = 0;
       virtual bool isWaitingForScripts() const = 0;
  
  
  



More information about the webkit-changes mailing list