Changeset 61985 in webkit


Ignore:
Timestamp:
Jun 28, 2010 12:56:10 AM (14 years ago)
Author:
eric@webkit.org
Message:

2010-06-28 Eric Seidel <eric@webkit.org>

Reviewed by Darin Adler.

Add a new baseclass for XML, HTML and Text DocumentParsers to clean up DocumentParser call sites
https://bugs.webkit.org/show_bug.cgi?id=41141

By splitting ScriptableDocumentParser and DecodedDataDocumentParser
out from DocumentParser we've made the DocumentParser and
RawDataDocumentParser classes simpler.

No functional change, thus no tests.

  • Android.mk:
  • CMakeLists.txt:
  • GNUmakefile.am:
  • WebCore.gypi:
  • WebCore.pro:
  • WebCore.vcproj/WebCore.vcproj:
  • WebCore.xcodeproj/project.pbxproj:
  • bindings/js/ScriptController.cpp: (WebCore::ScriptController::eventHandlerLineNumber):
  • css/CSSStyleSheet.cpp: (WebCore::CSSStyleSheet::checkLoaded):
  • dom/Document.cpp: (WebCore::Document::scriptableDocumentParser): (WebCore::Document::open): (WebCore::Document::implicitOpen): (WebCore::Document::implicitClose): (WebCore::Document::removePendingSheet):
  • dom/Document.h: (WebCore::Document::parser):
  • dom/DocumentParser.cpp: (WebCore::DocumentParser::DocumentParser):
  • dom/DocumentParser.h: (WebCore::DocumentParser::asScriptableDocumentParser):
  • dom/RawDataDocumentParser.h: (WebCore::RawDataDocumentParser::finishWasCalled):
  • dom/ScriptableDocumentParser.cpp: Copied from WebCore/html/HTMLEntityParser.h. (WebCore::ScriptableDocumentParser::ScriptableDocumentParser):
  • dom/ScriptableDocumentParser.h: Added. (WebCore::ScriptableDocumentParser::isExecutingScript): (WebCore::ScriptableDocumentParser::executeScriptsWaitingForStylesheets): (WebCore::ScriptableDocumentParser::xssAuditor): (WebCore::ScriptableDocumentParser::setXSSAuditor): (WebCore::ScriptableDocumentParser::processingContentWrittenByScript): (WebCore::ScriptableDocumentParser::asScriptableDocumentParser):
  • dom/ViewportArguments.cpp: (WebCore::parserLineNumber): (WebCore::reportViewportWarning):
  • dom/XMLDocumentParser.h:
  • dom/XMLDocumentParserLibxml2.cpp: (WebCore::XMLDocumentParser::XMLDocumentParser):
  • html/HTMLDocumentParser.cpp: (WebCore::HTMLDocumentParser::HTMLDocumentParser): (WebCore::HTMLDocumentParser::shouldLoadExternalScriptFromSrc):
  • html/HTMLDocumentParser.h:
  • html/LegacyHTMLDocumentParser.cpp: (WebCore::LegacyHTMLDocumentParser::LegacyHTMLDocumentParser): (WebCore::LegacyHTMLDocumentParser::parseTag):
  • html/LegacyHTMLDocumentParser.h: (WebCore::LegacyHTMLDocumentParser::processingContentWrittenByScript):
  • html/LegacyHTMLTreeBuilder.cpp: (WebCore::LegacyHTMLTreeBuilder::reportErrorToConsole):
  • loader/DocumentLoader.cpp:
  • loader/DocumentWriter.cpp:
  • loader/TextDocument.cpp: (WebCore::TextDocumentParser::TextDocumentParser): (WebCore::TextDocumentParser::finish):
  • svg/SVGDocumentExtensions.cpp: (WebCore::parserLineNumber): (WebCore::reportMessage): (WebCore::SVGDocumentExtensions::reportWarning): (WebCore::SVGDocumentExtensions::reportError):
Location:
trunk/WebCore
Files:
1 added
27 edited
3 copied

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/Android.mk

    r61950 r61985  
    115115        dom/DOMImplementation.cpp \
    116116        dom/DOMStringList.cpp \
     117        dom/DecodedDataDocumentParser.cpp \
    117118        dom/Document.cpp \
    118119        dom/DocumentFragment.cpp \
     
    159160        dom/Range.cpp \
    160161        dom/RegisteredEventListener.cpp \
     162        dom/ScriptableDocumentParser.cpp \
    161163        dom/ScriptElement.cpp \
    162164        dom/ScriptExecutionContext.cpp \
  • trunk/WebCore/CMakeLists.txt

    r61950 r61985  
    772772    dom/DOMImplementation.cpp
    773773    dom/DOMStringList.cpp
     774    dom/DecodedDataDocumentParser.cpp
    774775    dom/DeviceOrientation.cpp
    775776    dom/DeviceOrientationEvent.cpp
     
    817818    dom/Range.cpp
    818819    dom/RegisteredEventListener.cpp
     820    dom/ScriptableDocumentParser.cpp
    819821    dom/ScriptElement.cpp
    820822    dom/ScriptExecutionContext.cpp
  • trunk/WebCore/ChangeLog

    r61983 r61985  
     12010-06-28  Eric Seidel  <eric@webkit.org>
     2
     3        Reviewed by Darin Adler.
     4
     5        Add a new baseclass for XML, HTML and Text DocumentParsers to clean up DocumentParser call sites
     6        https://bugs.webkit.org/show_bug.cgi?id=41141
     7
     8        By splitting ScriptableDocumentParser and DecodedDataDocumentParser
     9        out from DocumentParser we've made the DocumentParser and
     10        RawDataDocumentParser classes simpler.
     11
     12        No functional change, thus no tests.
     13
     14        * Android.mk:
     15        * CMakeLists.txt:
     16        * GNUmakefile.am:
     17        * WebCore.gypi:
     18        * WebCore.pro:
     19        * WebCore.vcproj/WebCore.vcproj:
     20        * WebCore.xcodeproj/project.pbxproj:
     21        * bindings/js/ScriptController.cpp:
     22        (WebCore::ScriptController::eventHandlerLineNumber):
     23        * css/CSSStyleSheet.cpp:
     24        (WebCore::CSSStyleSheet::checkLoaded):
     25        * dom/Document.cpp:
     26        (WebCore::Document::scriptableDocumentParser):
     27        (WebCore::Document::open):
     28        (WebCore::Document::implicitOpen):
     29        (WebCore::Document::implicitClose):
     30        (WebCore::Document::removePendingSheet):
     31        * dom/Document.h:
     32        (WebCore::Document::parser):
     33        * dom/DocumentParser.cpp:
     34        (WebCore::DocumentParser::DocumentParser):
     35        * dom/DocumentParser.h:
     36        (WebCore::DocumentParser::asScriptableDocumentParser):
     37        * dom/RawDataDocumentParser.h:
     38        (WebCore::RawDataDocumentParser::finishWasCalled):
     39        * dom/ScriptableDocumentParser.cpp: Copied from WebCore/html/HTMLEntityParser.h.
     40        (WebCore::ScriptableDocumentParser::ScriptableDocumentParser):
     41        * dom/ScriptableDocumentParser.h: Added.
     42        (WebCore::ScriptableDocumentParser::isExecutingScript):
     43        (WebCore::ScriptableDocumentParser::executeScriptsWaitingForStylesheets):
     44        (WebCore::ScriptableDocumentParser::xssAuditor):
     45        (WebCore::ScriptableDocumentParser::setXSSAuditor):
     46        (WebCore::ScriptableDocumentParser::processingContentWrittenByScript):
     47        (WebCore::ScriptableDocumentParser::asScriptableDocumentParser):
     48        * dom/ViewportArguments.cpp:
     49        (WebCore::parserLineNumber):
     50        (WebCore::reportViewportWarning):
     51        * dom/XMLDocumentParser.h:
     52        * dom/XMLDocumentParserLibxml2.cpp:
     53        (WebCore::XMLDocumentParser::XMLDocumentParser):
     54        * html/HTMLDocumentParser.cpp:
     55        (WebCore::HTMLDocumentParser::HTMLDocumentParser):
     56        (WebCore::HTMLDocumentParser::shouldLoadExternalScriptFromSrc):
     57        * html/HTMLDocumentParser.h:
     58        * html/LegacyHTMLDocumentParser.cpp:
     59        (WebCore::LegacyHTMLDocumentParser::LegacyHTMLDocumentParser):
     60        (WebCore::LegacyHTMLDocumentParser::parseTag):
     61        * html/LegacyHTMLDocumentParser.h:
     62        (WebCore::LegacyHTMLDocumentParser::processingContentWrittenByScript):
     63        * html/LegacyHTMLTreeBuilder.cpp:
     64        (WebCore::LegacyHTMLTreeBuilder::reportErrorToConsole):
     65        * loader/DocumentLoader.cpp:
     66        * loader/DocumentWriter.cpp:
     67        * loader/TextDocument.cpp:
     68        (WebCore::TextDocumentParser::TextDocumentParser):
     69        (WebCore::TextDocumentParser::finish):
     70        * svg/SVGDocumentExtensions.cpp:
     71        (WebCore::parserLineNumber):
     72        (WebCore::reportMessage):
     73        (WebCore::SVGDocumentExtensions::reportWarning):
     74        (WebCore::SVGDocumentExtensions::reportError):
     75
    1762010-06-27  Steve Falkenburg  <sfalken@apple.com>
    277
  • trunk/WebCore/GNUmakefile.am

    r61964 r61985  
    779779        WebCore/dom/DOMStringList.cpp \
    780780        WebCore/dom/DOMStringList.h \
     781        WebCore/dom/DecodedDataDocumentParser.cpp \
     782        WebCore/dom/DecodedDataDocumentParser.h \
    781783        WebCore/dom/DeviceOrientation.cpp \
    782784        WebCore/dom/DeviceOrientation.h \
     
    882884        WebCore/dom/RegisteredEventListener.cpp \
    883885        WebCore/dom/RegisteredEventListener.h \
     886        WebCore/dom/ScriptableDocumentParser.cpp \
     887        WebCore/dom/ScriptableDocumentParser.h \
    884888        WebCore/dom/ScriptElement.cpp \
    885889        WebCore/dom/ScriptElement.h \
  • trunk/WebCore/WebCore.gypi

    r61964 r61985  
    11061106            'dom/DOMStringList.cpp',
    11071107            'dom/DOMStringList.h',
     1108            'dom/DecodedDataDocumentParser.cpp',
     1109            'dom/DecodedDataDocumentParser.h',
    11081110            'dom/DeviceOrientation.cpp',
    11091111            'dom/DeviceOrientation.h',
     
    12101212            'dom/RegisteredEventListener.cpp',
    12111213            'dom/RegisteredEventListener.h',
     1214            'dom/ScriptableDocumentParser.cpp',
     1215            'dom/ScriptableDocumentParser.h',
    12121216            'dom/ScriptElement.cpp',
    12131217            'dom/ScriptElement.h',
  • trunk/WebCore/WebCore.pro

    r61964 r61985  
    473473    dom/CSSMappedAttributeDeclaration.cpp \
    474474    dom/CustomEvent.cpp \
     475    dom/DecodedDataDocumentParser.cpp \
    475476    dom/DeviceOrientation.cpp \
    476477    dom/DeviceOrientationEvent.cpp \
     
    522523    dom/RawDataDocumentParser.h \
    523524    dom/RegisteredEventListener.cpp \
     525    dom/ScriptableDocumentParser.cpp \
    524526    dom/ScriptElement.cpp \
    525527    dom/ScriptExecutionContext.cpp \
  • trunk/WebCore/WebCore.vcproj/WebCore.vcproj

    r61983 r61985  
    3213832138                        </File>
    3213932139                        <File
     32140                                RelativePath="..\dom\DecodedDataDocumentParser.cpp"
     32141                                >
     32142                        </File>
     32143                        <File
     32144                                RelativePath="..\dom\DecodedDataDocumentParser.h"
     32145                                >
     32146                        </File>
     32147                        <File
    3214032148                                RelativePath="..\dom\DeviceOrientation.cpp"
    3214132149                                >
     
    3255132559                        <File
    3255232560                                RelativePath="..\dom\RegisteredEventListener.h"
     32561                                >
     32562                        </File>
     32563                        <File
     32564                                RelativePath="..\dom\ScriptableDocumentParser.cpp"
     32565                                >
     32566                        </File>
     32567                        <File
     32568                                RelativePath="..\dom\ScriptableDocumentParser.h"
    3255332569                                >
    3255432570                        </File>
  • trunk/WebCore/WebCore.xcodeproj/project.pbxproj

    r61964 r61985  
    29762976                A83E1C740E49042C00140B9C /* ScriptControllerMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = A83E1C720E49042B00140B9C /* ScriptControllerMac.mm */; };
    29772977                A84D827C11D333ED00972990 /* RawDataDocumentParser.h in Headers */ = {isa = PBXBuildFile; fileRef = A84D827B11D333ED00972990 /* RawDataDocumentParser.h */; };
     2978                A84D82C111D3474800972990 /* ScriptableDocumentParser.h in Headers */ = {isa = PBXBuildFile; fileRef = A84D82BF11D3474800972990 /* ScriptableDocumentParser.h */; };
     2979                A84D82C211D3474800972990 /* ScriptableDocumentParser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A84D82C011D3474800972990 /* ScriptableDocumentParser.cpp */; };
    29782980                A84EBD780CB8C89200079609 /* JSStyleSheetListCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A84EBD770CB8C89200079609 /* JSStyleSheetListCustom.cpp */; };
    29792981                A84EBD830CB8C97700079609 /* JSStyleSheetList.h in Headers */ = {isa = PBXBuildFile; fileRef = A84EBD810CB8C97700079609 /* JSStyleSheetList.h */; };
     
    30623064                A8A909AD0CBCD6B50029B807 /* RenderSVGTransformableContainer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A8A909AB0CBCD6B50029B807 /* RenderSVGTransformableContainer.cpp */; };
    30633065                A8C2280E11D4A59700D5A7D3 /* DocumentParser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A8C2280D11D4A59700D5A7D3 /* DocumentParser.cpp */; };
     3066                A8C228A111D5722E00D5A7D3 /* DecodedDataDocumentParser.h in Headers */ = {isa = PBXBuildFile; fileRef = A8C2289F11D5722E00D5A7D3 /* DecodedDataDocumentParser.h */; };
     3067                A8C228A211D5722E00D5A7D3 /* DecodedDataDocumentParser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A8C228A011D5722E00D5A7D3 /* DecodedDataDocumentParser.cpp */; };
    30643068                A8C4A7FD09D563270003AC8D /* StyledElement.h in Headers */ = {isa = PBXBuildFile; fileRef = A8C4A7EB09D563270003AC8D /* StyledElement.h */; settings = {ATTRIBUTES = (Private, ); }; };
    30653069                A8C4A7FE09D563270003AC8D /* StyledElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A8C4A7EC09D563270003AC8D /* StyledElement.cpp */; };
     
    84708474                A83E1C720E49042B00140B9C /* ScriptControllerMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ScriptControllerMac.mm; sourceTree = "<group>"; };
    84718475                A84D827B11D333ED00972990 /* RawDataDocumentParser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RawDataDocumentParser.h; sourceTree = "<group>"; };
     8476                A84D82BF11D3474800972990 /* ScriptableDocumentParser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScriptableDocumentParser.h; sourceTree = "<group>"; };
     8477                A84D82C011D3474800972990 /* ScriptableDocumentParser.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ScriptableDocumentParser.cpp; sourceTree = "<group>"; };
    84728478                A84EBD770CB8C89200079609 /* JSStyleSheetListCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSStyleSheetListCustom.cpp; sourceTree = "<group>"; };
    84738479                A84EBD810CB8C97700079609 /* JSStyleSheetList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSStyleSheetList.h; sourceTree = "<group>"; };
     
    85568562                A8A909AB0CBCD6B50029B807 /* RenderSVGTransformableContainer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderSVGTransformableContainer.cpp; sourceTree = "<group>"; };
    85578563                A8C2280D11D4A59700D5A7D3 /* DocumentParser.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DocumentParser.cpp; sourceTree = "<group>"; };
     8564                A8C2289F11D5722E00D5A7D3 /* DecodedDataDocumentParser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DecodedDataDocumentParser.h; sourceTree = "<group>"; };
     8565                A8C228A011D5722E00D5A7D3 /* DecodedDataDocumentParser.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DecodedDataDocumentParser.cpp; sourceTree = "<group>"; };
    85588566                A8C4A7EB09D563270003AC8D /* StyledElement.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = StyledElement.h; sourceTree = "<group>"; };
    85598567                A8C4A7EC09D563270003AC8D /* StyledElement.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = StyledElement.cpp; sourceTree = "<group>"; };
     
    1691216920                                5D15E3A90F9E6AC1009E0E3F /* XMLDocumentParserScope.cpp */,
    1691316921                                5D15E3AA0F9E6AC1009E0E3F /* XMLDocumentParserScope.h */,
     16922                                A84D82BF11D3474800972990 /* ScriptableDocumentParser.h */,
     16923                                A84D82C011D3474800972990 /* ScriptableDocumentParser.cpp */,
     16924                                A8C2289F11D5722E00D5A7D3 /* DecodedDataDocumentParser.h */,
     16925                                A8C228A011D5722E00D5A7D3 /* DecodedDataDocumentParser.cpp */,
    1691416926                        );
    1691516927                        path = dom;
     
    1957519587                                8A844CFF11D3C17C0014065C /* NavigationTiming.h in Headers */,
    1957619588                                8A844D0511D3C18E0014065C /* Performance.h in Headers */,
     19589                                A84D82C111D3474800972990 /* ScriptableDocumentParser.h in Headers */,
     19590                                A8C228A111D5722E00D5A7D3 /* DecodedDataDocumentParser.h in Headers */,
    1957719591                        );
    1957819592                        runOnlyForDeploymentPostprocessing = 0;
     
    2190021914                                8A844CFE11D3C17C0014065C /* NavigationTiming.cpp in Sources */,
    2190121915                                8A844D0411D3C18E0014065C /* Performance.cpp in Sources */,
     21916                                A84D82C211D3474800972990 /* ScriptableDocumentParser.cpp in Sources */,
     21917                                A8C228A211D5722E00D5A7D3 /* DecodedDataDocumentParser.cpp in Sources */,
    2190221918                        );
    2190321919                        runOnlyForDeploymentPostprocessing = 0;
  • trunk/WebCore/bindings/js/ScriptController.cpp

    r61640 r61985  
    2222#include "ScriptController.h"
    2323
    24 #include "DocumentParser.h"
     24#include "ScriptableDocumentParser.h"
    2525#include "Event.h"
    2626#include "EventNames.h"
     
    239239{
    240240    // JSC expects 1-based line numbers, so we must add one here to get it right.
    241     if (DocumentParser* parser = m_frame->document()->parser())
     241    ScriptableDocumentParser* parser = m_frame->document()->scriptableDocumentParser();
     242    if (parser)
    242243        return parser->lineNumber() + 1;
    243244    return 0;
    244245}
    245    
     246
    246247bool ScriptController::processingUserGesture(DOMWrapperWorld* world) const
    247248{
  • trunk/WebCore/css/CSSStyleSheet.cpp

    r61662 r61985  
    208208        parent()->checkLoaded();
    209209
    210     // Avoid |this| being deleted by scripts that run via LegacyHTMLDocumentParser::executeScriptsWaitingForStylesheets().
     210    // Avoid |this| being deleted by scripts that run via
     211    // ScriptableDocumentParser::executeScriptsWaitingForStylesheets().
    211212    // See <rdar://problem/6622300>.
    212213    RefPtr<CSSStyleSheet> protector(this);
  • trunk/WebCore/dom/DecodedDataDocumentParser.cpp

    r61984 r61985  
    2525
    2626#include "config.h"
    27 #include "DocumentParser.h"
     27#include "DecodedDataDocumentParser.h"
    2828
    2929#include "DocumentWriter.h"
     
    3131#include "TextResourceDecoder.h"
    3232
    33 #include <wtf/Assertions.h>
    34 
    3533namespace WebCore {
    3634
    37 DocumentParser::DocumentParser(Document* document, bool viewSourceMode)
    38     : m_parserStopped(false)
     35DecodedDataDocumentParser::DecodedDataDocumentParser(Document* document, bool viewSourceMode)
     36    : DocumentParser(document)
    3937    , m_inViewSourceMode(viewSourceMode)
    40     , m_document(document)
    41     , m_XSSAuditor(0)
    4238{
    43     ASSERT(document);
    4439}
    4540
    46 void DocumentParser::appendBytes(DocumentWriter* writer , const char* data, int length, bool shouldFlush)
     41void DecodedDataDocumentParser::appendBytes(DocumentWriter* writer , const char* data, int length, bool shouldFlush)
    4742{
    4843    if (!length && !shouldFlush)
  • trunk/WebCore/dom/DecodedDataDocumentParser.h

    r61984 r61985  
    2323 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2424 */
     25 
     26#ifndef DecodedDataDocumentParser_h
     27#define DecodedDataDocumentParser_h
    2528
    26 #include "config.h"
    2729#include "DocumentParser.h"
    28 
    29 #include "DocumentWriter.h"
    30 #include "SegmentedString.h"
    31 #include "TextResourceDecoder.h"
    32 
    33 #include <wtf/Assertions.h>
    3430
    3531namespace WebCore {
    3632
    37 DocumentParser::DocumentParser(Document* document, bool viewSourceMode)
    38     : m_parserStopped(false)
    39     , m_inViewSourceMode(viewSourceMode)
    40     , m_document(document)
    41     , m_XSSAuditor(0)
    42 {
    43     ASSERT(document);
     33class DecodedDataDocumentParser : public DocumentParser {
     34public:
     35    // Only used by the XMLDocumentParser to communicate back to
     36    // XMLHttpRequest if the responseXML was well formed.
     37    virtual bool wellFormed() const { return true; }
     38
     39    bool inViewSourceMode() const { return m_inViewSourceMode; }
     40    void setInViewSourceMode(bool mode) { m_inViewSourceMode = mode; }
     41
     42protected:
     43    DecodedDataDocumentParser(Document*, bool viewSourceMode = false);
     44
     45private:
     46    // append is used by DocumentWriter::replaceDocument
     47    virtual void append(const SegmentedString&) = 0;
     48
     49    // appendBytes is used by DocumentWriter (the loader)
     50    virtual void appendBytes(DocumentWriter*, const char* bytes, int length, bool flush);
     51
     52    bool m_inViewSourceMode;
     53};
     54
    4455}
    4556
    46 void DocumentParser::appendBytes(DocumentWriter* writer , const char* data, int length, bool shouldFlush)
    47 {
    48     if (!length && !shouldFlush)
    49         return;
    50 
    51     TextResourceDecoder* decoder = writer->createDecoderIfNeeded();
    52     String decoded = decoder->decode(data, length);
    53     if (shouldFlush)
    54         decoded += decoder->flush();
    55     if (decoded.isEmpty())
    56         return;
    57 
    58     writer->reportDataRecieved();
    59 
    60     append(decoded);
    61 }
    62 
    63 };
    64 
     57#endif // DecodedDataDocumentParser_h
  • trunk/WebCore/dom/Document.cpp

    r61975 r61985  
    17221722}
    17231723
     1724ScriptableDocumentParser* Document::scriptableDocumentParser() const
     1725{
     1726    return parser() ? parser()->asScriptableDocumentParser() : 0;
     1727}
     1728
    17241729void Document::open(Document* ownerDocument)
    17251730{
     
    17311736
    17321737    if (m_frame) {
    1733         if (m_frame->loader()->isLoadingMainResource() || (parser() && parser()->isExecutingScript()))
     1738        ScriptableDocumentParser* parser = scriptableDocumentParser();
     1739        if (m_frame->loader()->isLoadingMainResource() || (parser && parser->isExecutingScript()))
    17341740            return;
    1735    
     1741
    17361742        if (m_frame->loader()->state() == FrameStateProvisional)
    17371743            m_frame->loader()->stopAllLoaders();
     
    17701776    setParsing(true);
    17711777
    1772     if (m_frame)
    1773         m_parser->setXSSAuditor(m_frame->script()->xssAuditor());
     1778    ScriptableDocumentParser* parser = scriptableDocumentParser();
     1779    if (m_frame && parser)
     1780        parser->setXSSAuditor(m_frame->script()->xssAuditor());
    17741781
    17751782    // If we reload, the animation controller sticks around and has
     
    18561863    m_processingLoadEvent = true;
    18571864
    1858     m_wellFormed = m_parser && m_parser->wellFormed();
     1865    ScriptableDocumentParser* parser = scriptableDocumentParser();
     1866    m_wellFormed = parser && parser->wellFormed();
    18591867
    18601868    // We have to clear the parser, in case someone document.write()s from the
     
    26082616
    26092617    updateStyleSelector();
    2610    
    2611     if (!m_pendingStylesheets && m_parser)
    2612         m_parser->executeScriptsWaitingForStylesheets();
     2618
     2619    ScriptableDocumentParser* parser = scriptableDocumentParser();
     2620    if (!m_pendingStylesheets && parser)
     2621        parser->executeScriptsWaitingForStylesheets();
    26132622
    26142623    if (!m_pendingStylesheets && m_gotoAnchorNeededAfterStylesheetsLoad && view())
  • trunk/WebCore/dom/Document.h

    r61975 r61985  
    101101    class RenderArena;
    102102    class RenderView;
     103    class ScriptableDocumentParser;
    103104    class ScriptElementData;
    104105    class SecurityOrigin;
     
    549550   
    550551    virtual DocumentParser* createParser();
    551     DocumentParser* parser() { return m_parser.get(); }
     552    DocumentParser* parser() const { return m_parser.get(); }
     553    ScriptableDocumentParser* scriptableDocumentParser() const;
    552554   
    553555    bool printing() const { return m_printing; }
  • trunk/WebCore/dom/DocumentParser.cpp

    r61913 r61985  
    2727#include "DocumentParser.h"
    2828
    29 #include "DocumentWriter.h"
    30 #include "SegmentedString.h"
    31 #include "TextResourceDecoder.h"
    32 
    3329#include <wtf/Assertions.h>
    3430
    3531namespace WebCore {
    3632
    37 DocumentParser::DocumentParser(Document* document, bool viewSourceMode)
     33DocumentParser::DocumentParser(Document* document)
    3834    : m_parserStopped(false)
    39     , m_inViewSourceMode(viewSourceMode)
    4035    , m_document(document)
    41     , m_XSSAuditor(0)
    4236{
    4337    ASSERT(document);
    4438}
    4539
    46 void DocumentParser::appendBytes(DocumentWriter* writer , const char* data, int length, bool shouldFlush)
    47 {
    48     if (!length && !shouldFlush)
    49         return;
    50 
    51     TextResourceDecoder* decoder = writer->createDecoderIfNeeded();
    52     String decoded = decoder->decode(data, length);
    53     if (shouldFlush)
    54         decoded += decoder->flush();
    55     if (decoded.isEmpty())
    56         return;
    57 
    58     writer->reportDataRecieved();
    59 
    60     append(decoded);
    61 }
    62 
    6340};
    6441
  • trunk/WebCore/dom/DocumentParser.h

    r61913 r61985  
    3232class DocumentWriter;
    3333class LegacyHTMLTreeBuilder;
    34 class LegacyHTMLDocumentParser;
    3534class SegmentedString;
    36 class XSSAuditor;
     35class ScriptableDocumentParser;
    3736
    3837class DocumentParser : public Noncopyable {
     
    4039    virtual ~DocumentParser() { }
    4140
     41    virtual ScriptableDocumentParser* asScriptableDocumentParser() { return 0; }
     42
    4243    // insert is used by document.write
    4344    virtual void insert(const SegmentedString&) = 0;
     45
    4446    // appendBytes is used by DocumentWriter (the loader)
    45     virtual void appendBytes(DocumentWriter*, const char* bytes, int length, bool flush);
     47    virtual void appendBytes(DocumentWriter*, const char* bytes, int length, bool flush) = 0;
    4648
    4749    // FIXME: append() should be private, but DocumentWriter::replaceDocument
     
    5254    virtual bool finishWasCalled() = 0;
    5355
    54     virtual bool isWaitingForScripts() const = 0;
    55     virtual bool isExecutingScript() const { return false; }
    56 
    5756    virtual void stopParsing() { m_parserStopped = true; }
    5857    // FIXME: processingData() is only used by DocumentLoader::isLoadingInAPISense
     
    6160    virtual bool processingData() const { return false; }
    6261
    63     virtual bool wellFormed() const { return true; }
    64 
    65     virtual int lineNumber() const { return -1; }
    66     virtual int columnNumber() const { return -1; }
    67 
    68     virtual void executeScriptsWaitingForStylesheets() {}
    69 
     62    // FIXME: Exposed for HTMLFormControlElement::removedFromTree.  HTML DOM
     63    // code should not need to reach into implementation details of the parser.
    7064    virtual LegacyHTMLTreeBuilder* htmlTreeBuilder() const { return 0; }
    71     virtual LegacyHTMLDocumentParser* asHTMLDocumentParser() { return 0; }
    72 
    73     // FIXME: view source mode is only used by the HTML and Text
    74     // DocumentParsers and may not belong on the base-class.
    75     bool inViewSourceMode() const { return m_inViewSourceMode; }
    76     void setInViewSourceMode(bool mode) { m_inViewSourceMode = mode; }
    7765
    7866    Document* document() const { return m_document; }
    7967
    80     XSSAuditor* xssAuditor() const { return m_XSSAuditor; }
    81     void setXSSAuditor(XSSAuditor* auditor) { m_XSSAuditor = auditor; }
    82 
    8368protected:
    84     DocumentParser(Document*, bool viewSourceMode = false);
     69    DocumentParser(Document*);
    8570
    8671    // The parser has buffers, so parsing may continue even after
     
    8873    // even when it has buffered data.
    8974    bool m_parserStopped;
    90     bool m_inViewSourceMode;
    9175
    9276    // Every DocumentParser needs a pointer back to the document.
    9377    Document* m_document;
    94     // The XSSAuditor associated with this document parser.
    95     XSSAuditor* m_XSSAuditor;
    9678};
    9779
  • trunk/WebCore/dom/RawDataDocumentParser.h

    r61913 r61985  
    6363        return false;
    6464    }
    65 
    66     virtual bool isWaitingForScripts() const { return false; }
    6765};
    6866
  • trunk/WebCore/dom/ScriptableDocumentParser.cpp

    r61984 r61985  
    2525
    2626#include "config.h"
    27 #include "DocumentParser.h"
    28 
    29 #include "DocumentWriter.h"
    30 #include "SegmentedString.h"
    31 #include "TextResourceDecoder.h"
    32 
    33 #include <wtf/Assertions.h>
     27#include "ScriptableDocumentParser.h"
    3428
    3529namespace WebCore {
    3630
    37 DocumentParser::DocumentParser(Document* document, bool viewSourceMode)
    38     : m_parserStopped(false)
    39     , m_inViewSourceMode(viewSourceMode)
    40     , m_document(document)
    41     , m_XSSAuditor(0)
     31ScriptableDocumentParser::ScriptableDocumentParser(Document* document, bool viewSourceMode)
     32    : DecodedDataDocumentParser(document, viewSourceMode)
     33    , m_xssAuditor(0)
    4234{
    43     ASSERT(document);
    44 }
    45 
    46 void DocumentParser::appendBytes(DocumentWriter* writer , const char* data, int length, bool shouldFlush)
    47 {
    48     if (!length && !shouldFlush)
    49         return;
    50 
    51     TextResourceDecoder* decoder = writer->createDecoderIfNeeded();
    52     String decoded = decoder->decode(data, length);
    53     if (shouldFlush)
    54         decoded += decoder->flush();
    55     if (decoded.isEmpty())
    56         return;
    57 
    58     writer->reportDataRecieved();
    59 
    60     append(decoded);
    6135}
    6236
    6337};
    64 
  • trunk/WebCore/dom/ViewportArguments.cpp

    r61104 r61985  
    3434#include "Page.h"
    3535#include "PlatformString.h"
    36 #include "DocumentParser.h"
     36#include "ScriptableDocumentParser.h"
    3737
    3838namespace WebCore {
     
    104104}
    105105
     106// FIXME: Why is this different from SVGDocumentExtensions parserLineNumber?
     107// FIXME: Callers should probably use ScriptController::eventHandlerLineNumber()
     108static int parserLineNumber(Document* document)
     109{
     110    if (!document)
     111        return 0;
     112    ScriptableDocumentParser* parser = document->scriptableDocumentParser();
     113    if (!parser)
     114        return 0;
     115    return parser->lineNumber() + 1;
     116}
     117
    106118void reportViewportWarning(Document* document, ViewportErrorCode errorCode, const String& replacement)
    107119{
    108     DocumentParser* parser = document->parser();
    109 
    110120    Frame* frame = document->frame();
    111121    if (!frame)
     
    115125    message.replace("%replacement", replacement);
    116126
    117     frame->domWindow()->console()->addMessage(HTMLMessageSource, LogMessageType, viewportErrorMessageLevel(errorCode), message, parser ? parser->lineNumber() + 1 : 0, document->url().string());
     127    frame->domWindow()->console()->addMessage(HTMLMessageSource, LogMessageType, viewportErrorMessageLevel(errorCode), message, parserLineNumber(document), document->url().string());
    118128}
    119129
  • trunk/WebCore/dom/XMLDocumentParser.h

    r61904 r61985  
    2828#include "CachedResourceClient.h"
    2929#include "CachedResourceHandle.h"
     30#include "FragmentScriptingPermission.h"
     31#include "ScriptableDocumentParser.h"
    3032#include "SegmentedString.h"
    3133#include "StringHash.h"
    32 #include "DocumentParser.h"
    33 #include "FragmentScriptingPermission.h"
    3434#include <wtf/HashMap.h>
    3535#include <wtf/OwnPtr.h>
     
    7171#endif
    7272
    73     class XMLDocumentParser : public DocumentParser, public CachedResourceClient {
     73    class XMLDocumentParser : public ScriptableDocumentParser, public CachedResourceClient {
    7474    public:
    7575        XMLDocumentParser(Document*, FrameView* = 0);
  • trunk/WebCore/dom/XMLDocumentParserLibxml2.cpp

    r61904 r61985  
    524524
    525525XMLDocumentParser::XMLDocumentParser(Document* document, FrameView* frameView)
    526     : DocumentParser(document)
     526    : ScriptableDocumentParser(document)
    527527    , m_view(frameView)
    528528    , m_context(0)
     
    551551
    552552XMLDocumentParser::XMLDocumentParser(DocumentFragment* fragment, Element* parentElement, FragmentScriptingPermission scriptingPermission)
    553     : DocumentParser(fragment->document())
     553    : ScriptableDocumentParser(fragment->document())
    554554    , m_view(0)
    555555    , m_context(0)
  • trunk/WebCore/html/HTMLDocumentParser.cpp

    r61956 r61985  
    6767
    6868HTMLDocumentParser::HTMLDocumentParser(HTMLDocument* document, bool reportErrors)
    69     : DocumentParser(document)
     69    : ScriptableDocumentParser(document)
    7070    , m_tokenizer(new HTMLTokenizer)
    7171    , m_scriptRunner(new HTMLScriptRunner(document, this))
     
    8181// minimize code duplication between these constructors.
    8282HTMLDocumentParser::HTMLDocumentParser(DocumentFragment* fragment, FragmentScriptingPermission scriptingPermission)
    83     : DocumentParser(fragment->document())
     83    : ScriptableDocumentParser(fragment->document())
    8484    , m_tokenizer(new HTMLTokenizer)
    8585    , m_treeBuilder(new HTMLTreeBuilder(m_tokenizer.get(), fragment, scriptingPermission))
     
    358358bool HTMLDocumentParser::shouldLoadExternalScriptFromSrc(const AtomicString& srcValue)
    359359{
    360     if (!m_XSSAuditor)
     360    if (!xssAuditor())
    361361        return true;
    362     return m_XSSAuditor->canLoadExternalScriptFromSrc(srcValue);
     362    return xssAuditor()->canLoadExternalScriptFromSrc(srcValue);
    363363}
    364364
  • trunk/WebCore/html/HTMLDocumentParser.h

    r61904 r61985  
    2929#include "CachedResourceClient.h"
    3030#include "FragmentScriptingPermission.h"
     31#include "HTMLInputStream.h"
    3132#include "HTMLScriptRunnerHost.h"
    3233#include "HTMLToken.h"
    33 #include "HTMLInputStream.h"
     34#include "ScriptableDocumentParser.h"
    3435#include "SegmentedString.h"
    35 #include "DocumentParser.h"
    3636#include "Timer.h"
    3737#include <wtf/OwnPtr.h>
     
    5151class ScriptSourceCode;
    5252
    53 class HTMLDocumentParser :  public DocumentParser, HTMLScriptRunnerHost, CachedResourceClient {
     53class HTMLDocumentParser :  public ScriptableDocumentParser, HTMLScriptRunnerHost, CachedResourceClient {
    5454public:
    5555    // FIXME: These constructors should be made private and replaced by create() methods.
  • trunk/WebCore/html/LegacyHTMLDocumentParser.cpp

    r61904 r61985  
    148148
    149149LegacyHTMLDocumentParser::LegacyHTMLDocumentParser(HTMLDocument* document, bool reportErrors)
    150     : DocumentParser(document)
     150    : ScriptableDocumentParser(document)
    151151    , m_buffer(0)
    152152    , m_scriptCode(0)
     
    168168
    169169LegacyHTMLDocumentParser::LegacyHTMLDocumentParser(HTMLViewSourceDocument* document)
    170     : DocumentParser(document, true)
     170    : ScriptableDocumentParser(document, true)
    171171    , m_buffer(0)
    172172    , m_scriptCode(0)
     
    187187
    188188LegacyHTMLDocumentParser::LegacyHTMLDocumentParser(DocumentFragment* frag, FragmentScriptingPermission scriptingPermission)
    189     : DocumentParser(frag->document())
     189    : ScriptableDocumentParser(frag->document())
    190190    , m_buffer(0)
    191191    , m_scriptCode(0)
     
    13921392                        if (m_currentToken.beginTag && m_currentToken.tagName == scriptTag && !inViewSourceMode() && !m_treeBuilder->skipMode() && m_attrName == srcAttr) {
    13931393                            String context(m_rawAttributeBeforeValue.data(), m_rawAttributeBeforeValue.size());
    1394                             if (m_XSSAuditor && !m_XSSAuditor->canLoadExternalScriptFromSrc(attributeValue))
     1394                            if (xssAuditor() && !xssAuditor()->canLoadExternalScriptFromSrc(attributeValue))
    13951395                                attributeValue = blankURL().string();
    13961396                        }
     
    14291429                        if (m_currentToken.beginTag && m_currentToken.tagName == scriptTag && !inViewSourceMode() && !m_treeBuilder->skipMode() && m_attrName == srcAttr) {
    14301430                            String context(m_rawAttributeBeforeValue.data(), m_rawAttributeBeforeValue.size());
    1431                             if (m_XSSAuditor && !m_XSSAuditor->canLoadExternalScriptFromSrc(attributeValue))
     1431                            if (xssAuditor() && !xssAuditor()->canLoadExternalScriptFromSrc(attributeValue))
    14321432                                attributeValue = blankURL().string();
    14331433                        }
  • trunk/WebCore/html/LegacyHTMLDocumentParser.h

    r61904 r61985  
    2929#include "FragmentScriptingPermission.h"
    3030#include "NamedNodeMap.h"
     31#include "ScriptableDocumentParser.h"
    3132#include "SegmentedString.h"
    3233#include "Timer.h"
    33 #include "DocumentParser.h"
    3434#include <wtf/Deque.h>
    3535#include <wtf/OwnPtr.h>
     
    141141// down into a separate HTML tokenizer class.
    142142
    143 class LegacyHTMLDocumentParser : public DocumentParser, public CachedResourceClient {
     143class LegacyHTMLDocumentParser : public ScriptableDocumentParser, public CachedResourceClient {
    144144public:
    145145    LegacyHTMLDocumentParser(HTMLDocument*, bool reportErrors);
     
    151151    void setForceSynchronous(bool force);
    152152
    153     // Exposed for LegacyHTMLTreeBuilder::reportErrorToConsole
    154     bool processingContentWrittenByScript() const { return m_src.excludeLineNumbers(); }
    155 
    156153    static void parseDocumentFragment(const String&, DocumentFragment*, FragmentScriptingPermission = FragmentScriptingAllowed);
    157154
     
    162159
    163160private:
    164     // DocumentParser
     161    // ScriptableDocumentParser
    165162    virtual void append(const SegmentedString&);
    166163    virtual bool finishWasCalled();
     
    173170    virtual int columnNumber() const { return 1; }
    174171
     172    virtual bool processingContentWrittenByScript() const { return m_src.excludeLineNumbers(); }
     173
    175174    virtual void executeScriptsWaitingForStylesheets();
    176175
    177176    virtual LegacyHTMLTreeBuilder* htmlTreeBuilder() const { return m_treeBuilder.get(); }
    178     virtual LegacyHTMLDocumentParser* asHTMLDocumentParser() { return this; }
    179177
    180178    class State;
  • trunk/WebCore/html/LegacyHTMLTreeBuilder.cpp

    r61835 r61985  
    16481648    if (!frame)
    16491649        return;
    1650    
    1651     int lineNumber = m_document->parser()->lineNumber() + 1;
     1650
     1651    ScriptableDocumentParser* parser = m_document->scriptableDocumentParser();
     1652    int lineNumber = parser->lineNumber() + 1;
    16521653
    16531654    AtomicString tag1;
     
    16751676
    16761677    String message;
    1677     // FIXME: This doesn't work for the new HTMLDocumentParser and should.
    1678     LegacyHTMLDocumentParser* htmlParser = m_document->parser()->asHTMLDocumentParser();
    1679     if (htmlParser && htmlParser->processingContentWrittenByScript())
     1678    if (parser->processingContentWrittenByScript())
    16801679        message += htmlParserDocumentWriteMessage();
    16811680    message += errorMsg;
  • trunk/WebCore/loader/DocumentLoader.cpp

    r61105 r61985  
    3636#include "DocLoader.h"
    3737#include "Document.h"
     38#include "DocumentParser.h"
    3839#include "Event.h"
    3940#include "Frame.h"
     
    4748#include "Settings.h"
    4849#include "SharedBuffer.h"
    49 #include "XMLDocumentParser.h"
    5050
    5151#include <wtf/Assertions.h>
  • trunk/WebCore/loader/DocumentWriter.cpp

    r61913 r61985  
    3939#include "PlaceholderDocument.h"
    4040#include "PluginDocument.h"
     41#include "RawDataDocumentParser.h"
     42#include "ScriptableDocumentParser.h"
    4143#include "SecurityOrigin.h"
    4244#include "SegmentedString.h"
     
    4446#include "SinkDocument.h"
    4547#include "TextResourceDecoder.h"
    46 #include "DocumentParser.h"
     48
    4749
    4850namespace WebCore {
  • trunk/WebCore/loader/TextDocument.cpp

    r61904 r61985  
    2626#include "TextDocument.h"
    2727
    28 #include "DocumentParser.h"
     28#include "DecodedDataDocumentParser.h"
    2929#include "Element.h"
    3030#include "HTMLNames.h"
     
    3939using namespace HTMLNames;
    4040
    41 class TextDocumentParser : public DocumentParser {
     41// FIXME: TextDocumentParser could just be an HTMLDocumentParser
     42// which started the Tokenizer in the PlainText state.
     43class TextDocumentParser : public DecodedDataDocumentParser {
    4244public:
    4345    TextDocumentParser(Document*);
     
    5052    virtual void finish();
    5153    virtual bool finishWasCalled();
    52     virtual bool isWaitingForScripts() const;
    53    
     54
    5455    inline void checkBuffer(int len = 10)
    5556    {
     
    6465    }
    6566
     67private:
    6668    Element* m_preElement;
    6769
     
    7476
    7577TextDocumentParser::TextDocumentParser(Document* document)
    76     : DocumentParser(document)
     78    : DecodedDataDocumentParser(document)
    7779    , m_preElement(0)
    7880    , m_skipLF(false)
     
    8587
    8688TextDocumentParser::TextDocumentParser(HTMLViewSourceDocument* document)
    87     : DocumentParser(document, true)
     89    : DecodedDataDocumentParser(document, true)
    8890    , m_preElement(0)
    8991    , m_skipLF(false)
     
    175177    m_dest = 0;
    176178
     179    // FIXME: Should this call finishParsing even if m_parserStopped is true?
     180    // See equivalent implementation in RawDataDocumentParser.
    177181    document()->finishedParsing();
    178182}
     
    185189}
    186190
    187 bool TextDocumentParser::isWaitingForScripts() const
    188 {
    189     // A text document is never waiting for scripts
    190     return false;
    191 }
    192 
    193191TextDocument::TextDocument(Frame* frame, const KURL& url)
    194192    : HTMLDocument(frame, url)
  • trunk/WebCore/svg/SVGDocumentExtensions.cpp

    r61104 r61985  
    3838#include "SVGSVGElement.h"
    3939#include "SMILTimeContainer.h"
    40 #include "XMLDocumentParser.h"
     40#include "ScriptableDocumentParser.h"
    4141#include "ScriptController.h"
    4242
     
    126126}
    127127
     128// FIXME: Callers should probably use ScriptController::eventHandlerLineNumber()
     129static int parserLineNumber(Document* document)
     130{
     131    ScriptableDocumentParser* parser = document->scriptableDocumentParser();
     132    if (!parser)
     133        return 1;
     134    return parser->lineNumber();
     135}
     136
     137static void reportMessage(Document* document, MessageLevel level, const String& message)
     138{
     139    if (Frame* frame = document->frame())
     140        frame->domWindow()->console()->addMessage(JSMessageSource, LogMessageType, level, message, parserLineNumber(document), String());
     141}
     142
    128143void SVGDocumentExtensions::reportWarning(const String& message)
    129144{
    130     if (Frame* frame = m_doc->frame())
    131         frame->domWindow()->console()->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, "Warning: " + message, m_doc->parser() ? m_doc->parser()->lineNumber() : 1, String());
     145    reportMessage(m_doc, WarningMessageLevel, "Warning: " + message);
    132146}
    133147
    134148void SVGDocumentExtensions::reportError(const String& message)
    135149{
    136     if (Frame* frame = m_doc->frame())
    137         frame->domWindow()->console()->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, "Error: " + message, m_doc->parser() ? m_doc->parser()->lineNumber() : 1, String());
     150    reportMessage(m_doc, ErrorMessageLevel, "Error: " + message);
    138151}
    139152
Note: See TracChangeset for help on using the changeset viewer.