webengine/osswebengine/WebCore/dom/Tokenizer.h
changeset 0 dd21522fd290
equal deleted inserted replaced
-1:000000000000 0:dd21522fd290
       
     1 /*
       
     2  * This file is part of the DOM implementation for KDE.
       
     3  *
       
     4  * Copyright (C) 2000 Peter Kelly (pmk@post.com)
       
     5  * Copyright (C) 2005, 2006 Apple Computer, Inc.
       
     6  * Copyright (C) 2007 Samuel Weinig (sam@webkit.org)
       
     7  *
       
     8  * This library is free software; you can redistribute it and/or
       
     9  * modify it under the terms of the GNU Library General Public
       
    10  * License as published by the Free Software Foundation; either
       
    11  * version 2 of the License, or (at your option) any later version.
       
    12  *
       
    13  * This library is distributed in the hope that it will be useful,
       
    14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
       
    15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
       
    16  * Library General Public License for more details.
       
    17  *
       
    18  * You should have received a copy of the GNU Library General Public License
       
    19  * along with this library; see the file COPYING.LIB.  If not, write to
       
    20  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
       
    21  * Boston, MA 02110-1301, USA.
       
    22  *
       
    23  */
       
    24 
       
    25 #ifndef Tokenizer_h
       
    26 #define Tokenizer_h
       
    27 
       
    28 namespace WebCore {
       
    29 
       
    30     class SegmentedString;
       
    31 
       
    32     class Tokenizer {
       
    33     public:
       
    34         Tokenizer(bool viewSourceMode = false) 
       
    35             : m_parserStopped(false)
       
    36             , m_inViewSourceMode(viewSourceMode)
       
    37         {
       
    38         }
       
    39 
       
    40         virtual ~Tokenizer() { }
       
    41 
       
    42         // Script output must be prepended, while new data
       
    43         // received during executing a script must be appended, hence the
       
    44         // extra bool to be able to distinguish between both cases.
       
    45         // document.write() always uses false, while the loader uses true.
       
    46         virtual bool write(const SegmentedString&, bool appendData) = 0;
       
    47         virtual void finish() = 0;
       
    48         virtual bool isWaitingForScripts() const = 0;
       
    49         virtual void stopParsing() { m_parserStopped = true; }
       
    50         virtual bool processingData() const { return false; }
       
    51         virtual int executingScript() const { return 0; }
       
    52 
       
    53         virtual bool wantsRawData() const { return false; }
       
    54         virtual bool writeRawData(const char* data, int len) { return false; }
       
    55 
       
    56         bool inViewSourceMode() const { return m_inViewSourceMode; }
       
    57         void setInViewSourceMode(bool mode) { m_inViewSourceMode = mode; }
       
    58 
       
    59         virtual bool wellFormed() const { return true; }
       
    60 
       
    61         virtual int lineNumber() const { return -1; }
       
    62         virtual int columnNumber() const { return -1; }
       
    63         
       
    64         virtual void executeScriptsWaitingForStylesheets() {}
       
    65 
       
    66         virtual bool isHTMLTokenizer() const { return false; }
       
    67 
       
    68     protected:
       
    69         // The tokenizer has buffers, so parsing may continue even after
       
    70         // it stops receiving data. We use m_parserStopped to stop the tokenizer
       
    71         // even when it has buffered data.
       
    72         bool m_parserStopped;
       
    73         bool m_inViewSourceMode;
       
    74     };
       
    75 
       
    76 } // namespace WebCore
       
    77 
       
    78 #endif // Tokenizer_h