1f486d19d62f1bc33246748b14b14a9dfa617b57fIain Merrick/* 2f486d19d62f1bc33246748b14b14a9dfa617b57fIain Merrick * Copyright (C) 2010 Google, Inc. All Rights Reserved. 3f486d19d62f1bc33246748b14b14a9dfa617b57fIain Merrick * 4f486d19d62f1bc33246748b14b14a9dfa617b57fIain Merrick * Redistribution and use in source and binary forms, with or without 5f486d19d62f1bc33246748b14b14a9dfa617b57fIain Merrick * modification, are permitted provided that the following conditions 6f486d19d62f1bc33246748b14b14a9dfa617b57fIain Merrick * are met: 7f486d19d62f1bc33246748b14b14a9dfa617b57fIain Merrick * 1. Redistributions of source code must retain the above copyright 8f486d19d62f1bc33246748b14b14a9dfa617b57fIain Merrick * notice, this list of conditions and the following disclaimer. 9f486d19d62f1bc33246748b14b14a9dfa617b57fIain Merrick * 2. Redistributions in binary form must reproduce the above copyright 10f486d19d62f1bc33246748b14b14a9dfa617b57fIain Merrick * notice, this list of conditions and the following disclaimer in the 11f486d19d62f1bc33246748b14b14a9dfa617b57fIain Merrick * documentation and/or other materials provided with the distribution. 12f486d19d62f1bc33246748b14b14a9dfa617b57fIain Merrick * 13f486d19d62f1bc33246748b14b14a9dfa617b57fIain Merrick * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY 14f486d19d62f1bc33246748b14b14a9dfa617b57fIain Merrick * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 15f486d19d62f1bc33246748b14b14a9dfa617b57fIain Merrick * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 16f486d19d62f1bc33246748b14b14a9dfa617b57fIain Merrick * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR 17f486d19d62f1bc33246748b14b14a9dfa617b57fIain Merrick * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 18f486d19d62f1bc33246748b14b14a9dfa617b57fIain Merrick * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 19f486d19d62f1bc33246748b14b14a9dfa617b57fIain Merrick * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 20f486d19d62f1bc33246748b14b14a9dfa617b57fIain Merrick * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 21f486d19d62f1bc33246748b14b14a9dfa617b57fIain Merrick * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22f486d19d62f1bc33246748b14b14a9dfa617b57fIain Merrick * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 23f486d19d62f1bc33246748b14b14a9dfa617b57fIain Merrick * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24f486d19d62f1bc33246748b14b14a9dfa617b57fIain Merrick */ 25f486d19d62f1bc33246748b14b14a9dfa617b57fIain Merrick 26f486d19d62f1bc33246748b14b14a9dfa617b57fIain Merrick#ifndef HTMLViewSourceParser_h 27f486d19d62f1bc33246748b14b14a9dfa617b57fIain Merrick#define HTMLViewSourceParser_h 28f486d19d62f1bc33246748b14b14a9dfa617b57fIain Merrick 29f486d19d62f1bc33246748b14b14a9dfa617b57fIain Merrick#include "DecodedDataDocumentParser.h" 30f486d19d62f1bc33246748b14b14a9dfa617b57fIain Merrick#include "HTMLInputStream.h" 312fc2651226baac27029e38c9d6ef883fa32084dbSteve Block#include "HTMLSourceTracker.h" 32f486d19d62f1bc33246748b14b14a9dfa617b57fIain Merrick#include "HTMLToken.h" 33f486d19d62f1bc33246748b14b14a9dfa617b57fIain Merrick#include "HTMLTokenizer.h" 34f486d19d62f1bc33246748b14b14a9dfa617b57fIain Merrick#include "HTMLViewSourceDocument.h" 35f486d19d62f1bc33246748b14b14a9dfa617b57fIain Merrick#include <wtf/PassOwnPtr.h> 36f486d19d62f1bc33246748b14b14a9dfa617b57fIain Merrick 37f486d19d62f1bc33246748b14b14a9dfa617b57fIain Merricknamespace WebCore { 38f486d19d62f1bc33246748b14b14a9dfa617b57fIain Merrick 39f486d19d62f1bc33246748b14b14a9dfa617b57fIain Merrickclass HTMLTokenizer; 40f486d19d62f1bc33246748b14b14a9dfa617b57fIain Merrickclass HTMLScriptRunner; 41f486d19d62f1bc33246748b14b14a9dfa617b57fIain Merrickclass HTMLTreeBuilder; 42f486d19d62f1bc33246748b14b14a9dfa617b57fIain Merrickclass HTMLPreloadScanner; 43f486d19d62f1bc33246748b14b14a9dfa617b57fIain Merrickclass ScriptController; 44f486d19d62f1bc33246748b14b14a9dfa617b57fIain Merrickclass ScriptSourceCode; 45f486d19d62f1bc33246748b14b14a9dfa617b57fIain Merrick 46f486d19d62f1bc33246748b14b14a9dfa617b57fIain Merrickclass HTMLViewSourceParser : public DecodedDataDocumentParser { 47f486d19d62f1bc33246748b14b14a9dfa617b57fIain Merrickpublic: 48e8b154fd68f9b33be40a3590e58347f353835f5cSteve Block static PassRefPtr<HTMLViewSourceParser> create(HTMLViewSourceDocument* document) 49f486d19d62f1bc33246748b14b14a9dfa617b57fIain Merrick { 50e8b154fd68f9b33be40a3590e58347f353835f5cSteve Block return adoptRef(new HTMLViewSourceParser(document)); 51f486d19d62f1bc33246748b14b14a9dfa617b57fIain Merrick } 52f486d19d62f1bc33246748b14b14a9dfa617b57fIain Merrick virtual ~HTMLViewSourceParser(); 53f486d19d62f1bc33246748b14b14a9dfa617b57fIain Merrick 545abb8606fa57c3ebfc8b3c3dbc3fa4a25d2ae306Iain Merrickprotected: 555abb8606fa57c3ebfc8b3c3dbc3fa4a25d2ae306Iain Merrick explicit HTMLViewSourceParser(HTMLViewSourceDocument*); 565abb8606fa57c3ebfc8b3c3dbc3fa4a25d2ae306Iain Merrick 575abb8606fa57c3ebfc8b3c3dbc3fa4a25d2ae306Iain Merrick HTMLTokenizer* tokenizer() const { return m_tokenizer.get(); } 58e8b154fd68f9b33be40a3590e58347f353835f5cSteve Block 595abb8606fa57c3ebfc8b3c3dbc3fa4a25d2ae306Iain Merrickprivate: 60f486d19d62f1bc33246748b14b14a9dfa617b57fIain Merrick // DocumentParser 61f486d19d62f1bc33246748b14b14a9dfa617b57fIain Merrick virtual void insert(const SegmentedString&); 62f486d19d62f1bc33246748b14b14a9dfa617b57fIain Merrick virtual void append(const SegmentedString&); 63f486d19d62f1bc33246748b14b14a9dfa617b57fIain Merrick virtual void finish(); 64f486d19d62f1bc33246748b14b14a9dfa617b57fIain Merrick virtual bool finishWasCalled(); 65f486d19d62f1bc33246748b14b14a9dfa617b57fIain Merrick 66e8b154fd68f9b33be40a3590e58347f353835f5cSteve Block HTMLViewSourceDocument* document() const { return static_cast<HTMLViewSourceDocument*>(DecodedDataDocumentParser::document()); } 67f486d19d62f1bc33246748b14b14a9dfa617b57fIain Merrick 68f486d19d62f1bc33246748b14b14a9dfa617b57fIain Merrick void pumpTokenizer(); 69f486d19d62f1bc33246748b14b14a9dfa617b57fIain Merrick String sourceForToken(); 70f486d19d62f1bc33246748b14b14a9dfa617b57fIain Merrick void updateTokenizerState(); 71f486d19d62f1bc33246748b14b14a9dfa617b57fIain Merrick 72f486d19d62f1bc33246748b14b14a9dfa617b57fIain Merrick HTMLInputStream m_input; 73f486d19d62f1bc33246748b14b14a9dfa617b57fIain Merrick HTMLToken m_token; 742fc2651226baac27029e38c9d6ef883fa32084dbSteve Block HTMLSourceTracker m_sourceTracker; 75e8b154fd68f9b33be40a3590e58347f353835f5cSteve Block OwnPtr<HTMLTokenizer> m_tokenizer; 76f486d19d62f1bc33246748b14b14a9dfa617b57fIain Merrick}; 77f486d19d62f1bc33246748b14b14a9dfa617b57fIain Merrick 78f486d19d62f1bc33246748b14b14a9dfa617b57fIain Merrick} 79f486d19d62f1bc33246748b14b14a9dfa617b57fIain Merrick 80f486d19d62f1bc33246748b14b14a9dfa617b57fIain Merrick#endif 81