[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

abarth at webkit.org abarth at webkit.org
Wed Dec 22 11:56:00 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit 2018b2c0a1dd18c29635a5d01a013b69fd370cb7
Author: abarth at webkit.org <abarth at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Wed Aug 11 18:31:09 2010 +0000

    2010-08-11  Adam Barth  <abarth at webkit.org>
    
            Rubber-stamped by Eric Seidel.
    
            Delete LegacyHTMLDocumentParser and LegacyPreloadScanner
            https://bugs.webkit.org/show_bug.cgi?id=43836
    
            These classes are bit-rotting disturbingly quickly.  We removed the
            last dependencies on these classes and so we can remove them.
    
            We might need to preserve some of their particular quirks to handle
            some legacy applications, but our current thinking is to do that with
            individual settings that affect the new parser.
    
            * Android.mk:
            * CMakeLists.txt:
            * GNUmakefile.am:
            * WebCore.gypi:
            * WebCore.pro:
            * WebCore.vcproj/WebCore.vcproj:
            * WebCore.xcodeproj/project.pbxproj:
            * dom/Document.cpp:
            * dom/DocumentFragment.cpp:
            (WebCore::DocumentFragment::parseHTML):
            * dom/DocumentParser.h:
            * dom/XMLDocumentParserLibxml2.cpp:
            * dom/XMLDocumentParserQt.cpp:
            * html/HTMLConstructionSite.cpp:
            * html/HTMLDocument.cpp:
            (WebCore::HTMLDocument::createParser):
            * html/HTMLEntityParser.cpp:
            (WebCore::decodeNamedEntity):
            * html/HTMLEntityParser.h:
            * html/HTMLFormControlElement.cpp:
            * html/HTMLTreeBuilder.cpp:
            * html/HTMLViewSourceDocument.cpp:
            (WebCore::HTMLViewSourceDocument::createParser):
            * html/LegacyHTMLDocumentParser.cpp: Removed.
            * html/LegacyHTMLDocumentParser.h: Removed.
            * html/LegacyHTMLTreeBuilder.cpp:
            * html/LegacyPreloadScanner.cpp: Removed.
            * html/LegacyPreloadScanner.h: Removed.
            * loader/FTPDirectoryDocument.cpp:
            (WebCore::FTPDirectoryDocumentParser::FTPDirectoryDocumentParser):
            (WebCore::FTPDirectoryDocumentParser::appendEntry):
            (WebCore::FTPDirectoryDocumentParser::createTDForFilename):
            (WebCore::processFilesizeString):
            (WebCore::wasLastDayOfMonth):
            (WebCore::processFileDateString):
            (WebCore::FTPDirectoryDocumentParser::parseAndAppendOneLine):
            (WebCore::FTPDirectoryDocumentParser::loadDocumentTemplate):
            (WebCore::FTPDirectoryDocumentParser::createBasicDocument):
            (WebCore::FTPDirectoryDocumentParser::append):
            (WebCore::FTPDirectoryDocumentParser::finish):
            * page/XSSAuditor.cpp:
            (WebCore::XSSAuditor::decodeHTMLEntities):
            * page/XSSAuditor.h:
            * platform/text/SegmentedString.cpp:
            (WebCore::SegmentedString::prepend):
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@65167 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/Android.mk b/WebCore/Android.mk
index ac894f1..316ed2a 100644
--- a/WebCore/Android.mk
+++ b/WebCore/Android.mk
@@ -283,12 +283,10 @@ LOCAL_SRC_FILES := $(LOCAL_SRC_FILES) \
 	html/HTMLParserErrorCodes.cpp \
 	html/HTMLParserScheduler.cpp \
 	html/HTMLTableRowsCollection.cpp \
-	html/LegacyHTMLDocumentParser.cpp \
 	html/HTMLViewSourceDocument.cpp \
 	html/HTMLViewSourceParser.cpp \
 	html/ImageData.cpp \
 	html/ImageResizerThread.cpp \
-	html/LegacyPreloadScanner.cpp \
 	html/TimeRanges.cpp \
 	html/ValidityState.cpp \
 	\
diff --git a/WebCore/CMakeLists.txt b/WebCore/CMakeLists.txt
index 75445c2..5332b4e 100644
--- a/WebCore/CMakeLists.txt
+++ b/WebCore/CMakeLists.txt
@@ -1033,14 +1033,12 @@ SET(WebCore_SOURCES
     html/HTMLTableSectionElement.cpp
     html/HTMLTextAreaElement.cpp
     html/HTMLTitleElement.cpp
-    html/LegacyHTMLDocumentParser.cpp
     html/HTMLUListElement.cpp
     html/HTMLViewSourceDocument.cpp
     html/HTMLViewSourceParser.cpp
     html/ImageData.cpp
     html/ImageResizerThread.cpp
     html/LabelsNodeList.cpp
-    html/LegacyPreloadScanner.cpp
     html/StepRange.cpp
     html/ValidityState.cpp
     html/canvas/CanvasGradient.cpp
@@ -1858,7 +1856,6 @@ ADD_SOURCE_DERIVED_DEPENDENCIES(${WEBCORE_DIR}/css/CSSPrimitiveValueMappings.h C
 ADD_SOURCE_DERIVED_DEPENDENCIES(${WEBCORE_DIR}/html/HTMLDocument.cpp DocTypeStrings.cpp)
 ADD_SOURCE_DERIVED_DEPENDENCIES(${WEBCORE_DIR}/platform/graphics/Color.cpp ColorData.cpp)
 ADD_SOURCE_DERIVED_DEPENDENCIES(${WEBCORE_DIR}/css/CSSParser.cpp tokenizer.cpp)
-ADD_SOURCE_DERIVED_DEPENDENCIES(${WEBCORE_DIR}/html/LegacyPreloadScanner.cpp HTMLEntityNames.cpp)
 ADD_SOURCE_DERIVED_DEPENDENCIES(${WEBCORE_DIR}/html/HTMLEntityParser.cpp HTMLEntityNames.cpp)
 ADD_SOURCE_DERIVED_DEPENDENCIES(${WEBCORE_DIR}/html/HTMLTreeBuilder.cpp MathMLNames.cpp)
 ADD_SOURCE_DERIVED_DEPENDENCIES(${WEBCORE_DIR}/css/CSSStyleSelector.cpp UserAgentStyleSheetsData.cpp UserAgentStyleSheets.h)
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 35fed2d..fe1d89a 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,63 @@
+2010-08-11  Adam Barth  <abarth at webkit.org>
+
+        Rubber-stamped by Eric Seidel.
+
+        Delete LegacyHTMLDocumentParser and LegacyPreloadScanner
+        https://bugs.webkit.org/show_bug.cgi?id=43836
+
+        These classes are bit-rotting disturbingly quickly.  We removed the
+        last dependencies on these classes and so we can remove them.
+
+        We might need to preserve some of their particular quirks to handle
+        some legacy applications, but our current thinking is to do that with
+        individual settings that affect the new parser.
+
+        * Android.mk:
+        * CMakeLists.txt:
+        * GNUmakefile.am:
+        * WebCore.gypi:
+        * WebCore.pro:
+        * WebCore.vcproj/WebCore.vcproj:
+        * WebCore.xcodeproj/project.pbxproj:
+        * dom/Document.cpp:
+        * dom/DocumentFragment.cpp:
+        (WebCore::DocumentFragment::parseHTML):
+        * dom/DocumentParser.h:
+        * dom/XMLDocumentParserLibxml2.cpp:
+        * dom/XMLDocumentParserQt.cpp:
+        * html/HTMLConstructionSite.cpp:
+        * html/HTMLDocument.cpp:
+        (WebCore::HTMLDocument::createParser):
+        * html/HTMLEntityParser.cpp:
+        (WebCore::decodeNamedEntity):
+        * html/HTMLEntityParser.h:
+        * html/HTMLFormControlElement.cpp:
+        * html/HTMLTreeBuilder.cpp:
+        * html/HTMLViewSourceDocument.cpp:
+        (WebCore::HTMLViewSourceDocument::createParser):
+        * html/LegacyHTMLDocumentParser.cpp: Removed.
+        * html/LegacyHTMLDocumentParser.h: Removed.
+        * html/LegacyHTMLTreeBuilder.cpp:
+        * html/LegacyPreloadScanner.cpp: Removed.
+        * html/LegacyPreloadScanner.h: Removed.
+        * loader/FTPDirectoryDocument.cpp:
+        (WebCore::FTPDirectoryDocumentParser::FTPDirectoryDocumentParser):
+        (WebCore::FTPDirectoryDocumentParser::appendEntry):
+        (WebCore::FTPDirectoryDocumentParser::createTDForFilename):
+        (WebCore::processFilesizeString):
+        (WebCore::wasLastDayOfMonth):
+        (WebCore::processFileDateString):
+        (WebCore::FTPDirectoryDocumentParser::parseAndAppendOneLine):
+        (WebCore::FTPDirectoryDocumentParser::loadDocumentTemplate):
+        (WebCore::FTPDirectoryDocumentParser::createBasicDocument):
+        (WebCore::FTPDirectoryDocumentParser::append):
+        (WebCore::FTPDirectoryDocumentParser::finish):
+        * page/XSSAuditor.cpp:
+        (WebCore::XSSAuditor::decodeHTMLEntities):
+        * page/XSSAuditor.h:
+        * platform/text/SegmentedString.cpp:
+        (WebCore::SegmentedString::prepend):
+
 2010-08-11  Chris Jerdonek  <cjerdonek at webkit.org>
 
         Reviewed by Adam Barth.
diff --git a/WebCore/GNUmakefile.am b/WebCore/GNUmakefile.am
index 6efea85..7a14cb1 100644
--- a/WebCore/GNUmakefile.am
+++ b/WebCore/GNUmakefile.am
@@ -1549,8 +1549,6 @@ webcore_sources += \
 	WebCore/html/HTMLTextAreaElement.h \
 	WebCore/html/HTMLTitleElement.cpp \
 	WebCore/html/HTMLTitleElement.h \
-	WebCore/html/LegacyHTMLDocumentParser.cpp \
-	WebCore/html/LegacyHTMLDocumentParser.h \
 	WebCore/html/HTMLUListElement.cpp \
 	WebCore/html/HTMLUListElement.h \
 	WebCore/html/HTMLViewSourceDocument.cpp \
@@ -1564,8 +1562,6 @@ webcore_sources += \
 	WebCore/html/LabelsNodeList.cpp \
 	WebCore/html/LabelsNodeList.h \
 	WebCore/html/MediaError.h \
-	WebCore/html/LegacyPreloadScanner.cpp \
-	WebCore/html/LegacyPreloadScanner.h \
 	WebCore/html/StepRange.cpp \
 	WebCore/html/StepRange.h \
 	WebCore/html/TextMetrics.h \
diff --git a/WebCore/WebCore.gypi b/WebCore/WebCore.gypi
index a0c2d14..a2faf53 100644
--- a/WebCore/WebCore.gypi
+++ b/WebCore/WebCore.gypi
@@ -1713,8 +1713,6 @@
             'html/HTMLTextAreaElement.h',
             'html/HTMLTitleElement.cpp',
             'html/HTMLTitleElement.h',
-            'html/LegacyHTMLDocumentParser.cpp',
-            'html/LegacyHTMLDocumentParser.h',
             'html/HTMLUListElement.cpp',
             'html/HTMLUListElement.h',
             'html/HTMLVideoElement.cpp',
@@ -1730,8 +1728,6 @@
             'html/LabelsNodeList.cpp',
             'html/LabelsNodeList.h',
             'html/MediaError.h',
-            'html/LegacyPreloadScanner.cpp',
-            'html/LegacyPreloadScanner.h',
             'html/StepRange.cpp',
             'html/StepRange.h',
             'html/TextMetrics.h',
diff --git a/WebCore/WebCore.pro b/WebCore/WebCore.pro
index 0e63af8..bc87e25 100644
--- a/WebCore/WebCore.pro
+++ b/WebCore/WebCore.pro
@@ -737,14 +737,12 @@ SOURCES += \
     html/HTMLTableSectionElement.cpp \
     html/HTMLTextAreaElement.cpp \
     html/HTMLTitleElement.cpp \
-    html/LegacyHTMLDocumentParser.cpp \
     html/HTMLUListElement.cpp \
     html/HTMLViewSourceDocument.cpp \
     html/HTMLViewSourceParser.cpp \
     html/ImageData.cpp \
     html/ImageResizerThread.cpp \
     html/LabelsNodeList.cpp \
-    html/LegacyPreloadScanner.cpp \
     html/StepRange.cpp \
     html/ValidityState.cpp \
     inspector/ConsoleMessage.cpp \
@@ -1501,7 +1499,6 @@ HEADERS += \
     html/HTMLTableSectionElement.h \
     html/HTMLTextAreaElement.h \
     html/HTMLTitleElement.h \
-    html/LegacyHTMLDocumentParser.h \
     html/HTMLUListElement.h \
     html/HTMLVideoElement.h \
     html/HTMLViewSourceDocument.h \
@@ -1509,7 +1506,6 @@ HEADERS += \
     html/ImageData.h \
     html/ImageResizerThread.h \
     html/LabelsNodeList.h \
-    html/LegacyPreloadScanner.h \
     html/StepRange.h \
     html/TimeRanges.h \
     html/ValidityState.h \
diff --git a/WebCore/WebCore.vcproj/WebCore.vcproj b/WebCore/WebCore.vcproj/WebCore.vcproj
index cf0988a..463f5d9 100644
--- a/WebCore/WebCore.vcproj/WebCore.vcproj
+++ b/WebCore/WebCore.vcproj/WebCore.vcproj
@@ -40929,14 +40929,6 @@
 				>
 			</File>
 			<File
-				RelativePath="..\html\LegacyHTMLDocumentParser.cpp"
-				>
-			</File>
-			<File
-				RelativePath="..\html\LegacyHTMLDocumentParser.h"
-				>
-			</File>
-			<File
 				RelativePath="..\html\LegacyHTMLTreeBuilder.cpp"
 				>
 			</File>
@@ -40945,14 +40937,6 @@
 				>
 			</File>
 			<File
-				RelativePath="..\html\LegacyPreloadScanner.cpp"
-				>
-			</File>
-			<File
-				RelativePath="..\html\LegacyPreloadScanner.h"
-				>
-			</File>
-			<File
 				RelativePath="..\html\MediaError.h"
 				>
 			</File>
diff --git a/WebCore/WebCore.xcodeproj/project.pbxproj b/WebCore/WebCore.xcodeproj/project.pbxproj
index 81fa73f..90e53ab 100644
--- a/WebCore/WebCore.xcodeproj/project.pbxproj
+++ b/WebCore/WebCore.xcodeproj/project.pbxproj
@@ -2599,7 +2599,6 @@
 		93F198E508245E59001E9ABC /* HTMLDocument.h in Headers */ = {isa = PBXBuildFile; fileRef = F523D23C02DE4396018635CA /* HTMLDocument.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		93F198E608245E59001E9ABC /* HTMLElement.h in Headers */ = {isa = PBXBuildFile; fileRef = F523D23F02DE4396018635CA /* HTMLElement.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		93F198EF08245E59001E9ABC /* LegacyHTMLTreeBuilder.h in Headers */ = {isa = PBXBuildFile; fileRef = F523D25102DE4396018635CA /* LegacyHTMLTreeBuilder.h */; };
-		93F198F008245E59001E9ABC /* LegacyHTMLDocumentParser.h in Headers */ = {isa = PBXBuildFile; fileRef = F523D25302DE4396018635CA /* LegacyHTMLDocumentParser.h */; };
 		93F198F608245E59001E9ABC /* TextResourceDecoder.h in Headers */ = {isa = PBXBuildFile; fileRef = F523D27902DE43D7018635CA /* TextResourceDecoder.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		93F1991808245E59001E9ABC /* Range.h in Headers */ = {isa = PBXBuildFile; fileRef = F523D30402DE4476018635CA /* Range.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		93F1992108245E59001E9ABC /* XMLDocumentParser.h in Headers */ = {isa = PBXBuildFile; fileRef = F523D30A02DE4476018635CA /* XMLDocumentParser.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -2629,7 +2628,6 @@
 		93F19A9108245E59001E9ABC /* HTMLDocument.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F523D23B02DE4396018635CA /* HTMLDocument.cpp */; };
 		93F19A9208245E59001E9ABC /* HTMLElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F523D23E02DE4396018635CA /* HTMLElement.cpp */; };
 		93F19A9B08245E59001E9ABC /* LegacyHTMLTreeBuilder.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F523D25002DE4396018635CA /* LegacyHTMLTreeBuilder.cpp */; };
-		93F19A9C08245E59001E9ABC /* LegacyHTMLDocumentParser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F523D25202DE4396018635CA /* LegacyHTMLDocumentParser.cpp */; };
 		93F19A9D08245E59001E9ABC /* TextResourceDecoder.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F523D27802DE43D7018635CA /* TextResourceDecoder.cpp */; };
 		93F19AB908245E59001E9ABC /* Range.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F523D30302DE4476018635CA /* Range.cpp */; };
 		93F19ABC08245E59001E9ABC /* XMLDocumentParser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F523D30902DE4476018635CA /* XMLDocumentParser.cpp */; };
@@ -5209,8 +5207,6 @@
 		E4778B80115A581A00B5D372 /* JSCustomEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = E4778B7E115A581A00B5D372 /* JSCustomEvent.h */; };
 		E47B4BE80E71241600038854 /* CachedResourceHandle.h in Headers */ = {isa = PBXBuildFile; fileRef = E47B4BE60E71241600038854 /* CachedResourceHandle.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		E47B4BE90E71241600038854 /* CachedResourceHandle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E47B4BE70E71241600038854 /* CachedResourceHandle.cpp */; };
-		E49626C20D80D94800E3405C /* LegacyPreloadScanner.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E4D4ABE00D7542F000F96869 /* LegacyPreloadScanner.cpp */; };
-		E49626C30D80D94900E3405C /* LegacyPreloadScanner.h in Headers */ = {isa = PBXBuildFile; fileRef = E4D4ABE10D7542F100F96869 /* LegacyPreloadScanner.h */; };
 		E4AFCFA50DAF29A300F5F55C /* UnitBezier.h in Headers */ = {isa = PBXBuildFile; fileRef = E4AFCFA40DAF29A300F5F55C /* UnitBezier.h */; };
 		E4AFD00B0DAF335400F5F55C /* SMILTime.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E4AFD0050DAF335400F5F55C /* SMILTime.cpp */; };
 		E4AFD00C0DAF335400F5F55C /* SMILTime.h in Headers */ = {isa = PBXBuildFile; fileRef = E4AFD0060DAF335400F5F55C /* SMILTime.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -11004,8 +11000,6 @@
 		E4C178960EE6903800824D69 /* CSSSelectorList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CSSSelectorList.h; sourceTree = "<group>"; };
 		E4C279560CF9741900E97B98 /* RenderMedia.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderMedia.cpp; sourceTree = "<group>"; };
 		E4C279570CF9741900E97B98 /* RenderMedia.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderMedia.h; sourceTree = "<group>"; };
-		E4D4ABE00D7542F000F96869 /* LegacyPreloadScanner.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LegacyPreloadScanner.cpp; sourceTree = "<group>"; };
-		E4D4ABE10D7542F100F96869 /* LegacyPreloadScanner.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LegacyPreloadScanner.h; sourceTree = "<group>"; };
 		E4D687760ED7AE3D006EA978 /* PurgeableBufferMac.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PurgeableBufferMac.cpp; sourceTree = "<group>"; };
 		E4D687780ED7AE4F006EA978 /* PurgeableBuffer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PurgeableBuffer.h; sourceTree = "<group>"; };
 		E4EEFFC60D34550C00469A58 /* JSAudioConstructor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSAudioConstructor.cpp; sourceTree = "<group>"; };
@@ -11034,8 +11028,6 @@
 		F523D23F02DE4396018635CA /* HTMLElement.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = HTMLElement.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
 		F523D25002DE4396018635CA /* LegacyHTMLTreeBuilder.cpp */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LegacyHTMLTreeBuilder.cpp; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
 		F523D25102DE4396018635CA /* LegacyHTMLTreeBuilder.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = LegacyHTMLTreeBuilder.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
-		F523D25202DE4396018635CA /* LegacyHTMLDocumentParser.cpp */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LegacyHTMLDocumentParser.cpp; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
-		F523D25302DE4396018635CA /* LegacyHTMLDocumentParser.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = LegacyHTMLDocumentParser.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
 		F523D27802DE43D7018635CA /* TextResourceDecoder.cpp */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TextResourceDecoder.cpp; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
 		F523D27902DE43D7018635CA /* TextResourceDecoder.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = TextResourceDecoder.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
 		F523D30302DE4476018635CA /* Range.cpp */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Range.cpp; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
@@ -14184,12 +14176,8 @@
 				B0149E7C11A4B21500196A7B /* ImageResizerThread.h */,
 				A456FA2411AD4A830020B420 /* LabelsNodeList.cpp */,
 				A456FA2511AD4A830020B420 /* LabelsNodeList.h */,
-				F523D25202DE4396018635CA /* LegacyHTMLDocumentParser.cpp */,
-				F523D25302DE4396018635CA /* LegacyHTMLDocumentParser.h */,
 				F523D25002DE4396018635CA /* LegacyHTMLTreeBuilder.cpp */,
 				F523D25102DE4396018635CA /* LegacyHTMLTreeBuilder.h */,
-				E4D4ABE00D7542F000F96869 /* LegacyPreloadScanner.cpp */,
-				E4D4ABE10D7542F100F96869 /* LegacyPreloadScanner.h */,
 				E446139B0CD6331000FADA75 /* MediaError.h */,
 				E446139C0CD6331000FADA75 /* MediaError.idl */,
 				A5AFB34D115151A700B045CB /* StepRange.cpp */,
@@ -19274,9 +19262,7 @@
 				A456FA2711AD4A830020B420 /* LabelsNodeList.h in Headers */,
 				85EC9AFB0A71A2C600EEEAED /* Language.h in Headers */,
 				2D9066070BE141D400956998 /* LayoutState.h in Headers */,
-				93F198F008245E59001E9ABC /* LegacyHTMLDocumentParser.h in Headers */,
 				93F198EF08245E59001E9ABC /* LegacyHTMLTreeBuilder.h in Headers */,
-				E49626C30D80D94900E3405C /* LegacyPreloadScanner.h in Headers */,
 				512DD8F50D91E6AF000F89EE /* LegacyWebArchive.h in Headers */,
 				BCE65BEB0EACDF16007E4533 /* Length.h in Headers */,
 				BCFF64910EAD15C200C1D6F7 /* LengthBox.h in Headers */,
@@ -20215,7 +20201,6 @@
 			isa = PBXProject;
 			buildConfigurationList = 149C284308902B11008A9EFC /* Build configuration list for PBXProject "WebCore" */;
 			compatibilityVersion = "Xcode 2.4";
-			developmentRegion = English;
 			hasScannedForEncodings = 1;
 			knownRegions = (
 				English,
@@ -21814,9 +21799,7 @@
 				A456FA2611AD4A830020B420 /* LabelsNodeList.cpp in Sources */,
 				9352084509BD43B900F2038D /* Language.mm in Sources */,
 				2D9066060BE141D400956998 /* LayoutState.cpp in Sources */,
-				93F19A9C08245E59001E9ABC /* LegacyHTMLDocumentParser.cpp in Sources */,
 				93F19A9B08245E59001E9ABC /* LegacyHTMLTreeBuilder.cpp in Sources */,
-				E49626C20D80D94800E3405C /* LegacyPreloadScanner.cpp in Sources */,
 				512DD8F40D91E6AF000F89EE /* LegacyWebArchive.cpp in Sources */,
 				51B2417B0D931F3F00E83F5C /* LegacyWebArchiveMac.mm in Sources */,
 				BCE65BEA0EACDF16007E4533 /* Length.cpp in Sources */,
diff --git a/WebCore/dom/Document.cpp b/WebCore/dom/Document.cpp
index 0d39854..ef9141b 100644
--- a/WebCore/dom/Document.cpp
+++ b/WebCore/dom/Document.cpp
@@ -89,7 +89,6 @@
 #include "InspectorController.h"
 #include "InspectorTimelineAgent.h"
 #include "KeyboardEvent.h"
-#include "LegacyHTMLDocumentParser.h"
 #include "LegacyHTMLTreeBuilder.h"
 #include "Logging.h"
 #include "MessageEvent.h"
diff --git a/WebCore/dom/DocumentFragment.cpp b/WebCore/dom/DocumentFragment.cpp
index 47485b7..70e57b9 100644
--- a/WebCore/dom/DocumentFragment.cpp
+++ b/WebCore/dom/DocumentFragment.cpp
@@ -25,7 +25,6 @@
 
 #include "Document.h"
 #include "HTMLDocumentParser.h"
-#include "LegacyHTMLDocumentParser.h"
 #include "Page.h"
 #include "Settings.h"
 #include "XMLDocumentParser.h"
@@ -84,8 +83,6 @@ bool DocumentFragment::shouldUseLegacyHTMLParser() const
 
 void DocumentFragment::parseHTML(const String& source, Element* contextElement, FragmentScriptingPermission scriptingPermission)
 {
-    if (shouldUseLegacyHTMLParser())
-        return LegacyHTMLDocumentParser::parseDocumentFragment(source, this, scriptingPermission);
     HTMLDocumentParser::parseDocumentFragment(source, this, contextElement, scriptingPermission);
 }
 
diff --git a/WebCore/dom/DocumentParser.h b/WebCore/dom/DocumentParser.h
index a3545b6..e942d1f 100644
--- a/WebCore/dom/DocumentParser.h
+++ b/WebCore/dom/DocumentParser.h
@@ -58,8 +58,8 @@ public:
 
     virtual void stopParsing() { m_parserStopped = true; }
     // FIXME: processingData() is only used by DocumentLoader::isLoadingInAPISense
-    // and is very unclear as to what it actually means.  Only LegacyHTMLDocumentParser
-    // actually implements it.
+    // and is very unclear as to what it actually means.  The LegacyHTMLDocumentParser
+    // used to implements it.
     virtual bool processingData() const { return false; }
 
     // FIXME: Exposed for HTMLFormControlElement::removedFromTree.  HTML DOM
diff --git a/WebCore/dom/XMLDocumentParserLibxml2.cpp b/WebCore/dom/XMLDocumentParserLibxml2.cpp
index a6e9cd0..1309827 100644
--- a/WebCore/dom/XMLDocumentParserLibxml2.cpp
+++ b/WebCore/dom/XMLDocumentParserLibxml2.cpp
@@ -36,9 +36,9 @@
 #include "Frame.h"
 #include "FrameLoader.h"
 #include "FrameView.h"
+#include "HTMLEntityParser.h"
 #include "HTMLLinkElement.h"
 #include "HTMLStyleElement.h"
-#include "LegacyHTMLDocumentParser.h" // for decodeNamedEntity
 #include "ProcessingInstruction.h"
 #include "ResourceError.h"
 #include "ResourceHandle.h"
diff --git a/WebCore/dom/XMLDocumentParserQt.cpp b/WebCore/dom/XMLDocumentParserQt.cpp
index 678d141..715856c 100644
--- a/WebCore/dom/XMLDocumentParserQt.cpp
+++ b/WebCore/dom/XMLDocumentParserQt.cpp
@@ -36,9 +36,9 @@
 #include "Frame.h"
 #include "FrameLoader.h"
 #include "FrameView.h"
+#include "HTMLEntityParser.h"
 #include "HTMLLinkElement.h"
 #include "HTMLStyleElement.h"
-#include "LegacyHTMLDocumentParser.h"
 #include "ProcessingInstruction.h"
 #include "ResourceError.h"
 #include "ResourceHandle.h"
diff --git a/WebCore/html/HTMLConstructionSite.cpp b/WebCore/html/HTMLConstructionSite.cpp
index 9f502e3..2b28da4 100644
--- a/WebCore/html/HTMLConstructionSite.cpp
+++ b/WebCore/html/HTMLConstructionSite.cpp
@@ -39,7 +39,6 @@
 #include "HTMLScriptElement.h"
 #include "HTMLToken.h"
 #include "HTMLTokenizer.h"
-#include "LegacyHTMLDocumentParser.h"
 #include "LegacyHTMLTreeBuilder.h"
 #include "LocalizedStrings.h"
 #if ENABLE(MATHML)
diff --git a/WebCore/html/HTMLDocument.cpp b/WebCore/html/HTMLDocument.cpp
index ff0c2de..559c1e0 100644
--- a/WebCore/html/HTMLDocument.cpp
+++ b/WebCore/html/HTMLDocument.cpp
@@ -68,7 +68,6 @@
 #include "HTMLBodyElement.h"
 #include "HTMLElementFactory.h"
 #include "HTMLNames.h"
-#include "LegacyHTMLDocumentParser.h"
 #include "InspectorController.h"
 #include "KURL.h"
 #include "Page.h"
@@ -290,11 +289,7 @@ DocumentParser* HTMLDocument::createParser()
     if (Page* page = this->page())
         reportErrors = page->inspectorController()->windowVisible();
 #endif
-
-    if (settings() && settings()->html5ParserEnabled())
-        return new HTMLDocumentParser(this, reportErrors);
-
-    return new LegacyHTMLDocumentParser(this, reportErrors);
+    return new HTMLDocumentParser(this, reportErrors);
 }
 
 // --------------------------------------------------------------------------
diff --git a/WebCore/html/HTMLDocumentParser.h b/WebCore/html/HTMLDocumentParser.h
index d055861..d35cfaf 100644
--- a/WebCore/html/HTMLDocumentParser.h
+++ b/WebCore/html/HTMLDocumentParser.h
@@ -62,12 +62,14 @@ public:
 
     static void parseDocumentFragment(const String&, DocumentFragment*, Element* contextElement, FragmentScriptingPermission = FragmentScriptingAllowed);
 
+protected:
+    virtual void insert(const SegmentedString&);
+    virtual void finish();
+
 private:
     // DocumentParser
     virtual bool hasInsertionPoint();
-    virtual void insert(const SegmentedString&);
     virtual void append(const SegmentedString&);
-    virtual void finish();
     virtual bool finishWasCalled();
     virtual bool processingData() const;
     virtual void stopParsing();
diff --git a/WebCore/html/HTMLEntityParser.cpp b/WebCore/html/HTMLEntityParser.cpp
index 84b2006..b9c4dee 100644
--- a/WebCore/html/HTMLEntityParser.cpp
+++ b/WebCore/html/HTMLEntityParser.cpp
@@ -247,4 +247,10 @@ unsigned consumeHTMLEntity(SegmentedString& source, bool& notEnoughCharacters, U
     return 0;
 }
 
+UChar decodeNamedEntity(const char* name)
+{
+    const Entity* e = findEntity(name, strlen(name));
+    return e ? e->code : 0;
+}
+
 } // namespace WebCore
diff --git a/WebCore/html/HTMLEntityParser.h b/WebCore/html/HTMLEntityParser.h
index d37b0c3..1059b24 100644
--- a/WebCore/html/HTMLEntityParser.h
+++ b/WebCore/html/HTMLEntityParser.h
@@ -33,6 +33,9 @@ namespace WebCore {
 
 unsigned consumeHTMLEntity(SegmentedString&, bool& notEnoughCharacters, UChar additionalAllowedCharacter = '\0');
 
+// Used by the XML parser.  Not suitable for use in HTML parsing.  Use consumeHTMLEntity instead.
+UChar decodeNamedEntity(const char*);
+
 }
 
 #endif
diff --git a/WebCore/html/HTMLFormControlElement.cpp b/WebCore/html/HTMLFormControlElement.cpp
index 5103bfa..7d4cb00 100644
--- a/WebCore/html/HTMLFormControlElement.cpp
+++ b/WebCore/html/HTMLFormControlElement.cpp
@@ -30,6 +30,7 @@
 #include "Chrome.h"
 #include "ChromeClient.h"
 #include "Document.h"
+#include "DocumentParser.h"
 #include "ElementRareData.h"
 #include "Event.h"
 #include "EventHandler.h"
@@ -39,7 +40,6 @@
 #include "HTMLInputElement.h"
 #include "HTMLNames.h"
 #include "LegacyHTMLTreeBuilder.h"
-#include "LegacyHTMLDocumentParser.h"
 #include "LabelsNodeList.h"
 #include "Page.h"
 #include "RenderBox.h"
diff --git a/WebCore/html/HTMLTreeBuilder.cpp b/WebCore/html/HTMLTreeBuilder.cpp
index fc0b9d0..ab7e6bf 100644
--- a/WebCore/html/HTMLTreeBuilder.cpp
+++ b/WebCore/html/HTMLTreeBuilder.cpp
@@ -39,7 +39,6 @@
 #include "HTMLScriptElement.h"
 #include "HTMLToken.h"
 #include "HTMLTokenizer.h"
-#include "LegacyHTMLDocumentParser.h"
 #include "LegacyHTMLTreeBuilder.h"
 #include "LocalizedStrings.h"
 #include "MathMLNames.h"
diff --git a/WebCore/html/HTMLViewSourceDocument.cpp b/WebCore/html/HTMLViewSourceDocument.cpp
index c330c4d..e0e71ee 100644
--- a/WebCore/html/HTMLViewSourceDocument.cpp
+++ b/WebCore/html/HTMLViewSourceDocument.cpp
@@ -55,7 +55,7 @@ HTMLViewSourceDocument::HTMLViewSourceDocument(Frame* frame, const KURL& url, co
 
 DocumentParser* HTMLViewSourceDocument::createParser()
 {
-    // Use LegacyHTMLDocumentParser if applicable, otherwise use TextDocumentParser.
+    // Use HTMLDocumentParser if applicable, otherwise use TextDocumentParser.
     if (m_type == "text/html" || m_type == "application/xhtml+xml" || m_type == "image/svg+xml" || DOMImplementation::isXMLMIMEType(m_type)
 #if ENABLE(XHTMLMP)
         || m_type == "application/vnd.wap.xhtml+xml"
diff --git a/WebCore/html/LegacyHTMLDocumentParser.cpp b/WebCore/html/LegacyHTMLDocumentParser.cpp
deleted file mode 100644
index 0d4d615..0000000
--- a/WebCore/html/LegacyHTMLDocumentParser.cpp
+++ /dev/null
@@ -1,2120 +0,0 @@
-/*
-    Copyright (C) 1997 Martin Jones (mjones at kde.org)
-              (C) 1997 Torben Weis (weis at kde.org)
-              (C) 1998 Waldo Bastian (bastian at kde.org)
-              (C) 1999 Lars Knoll (knoll at kde.org)
-              (C) 1999 Antti Koivisto (koivisto at kde.org)
-              (C) 2001 Dirk Mueller (mueller at kde.org)
-    Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
-    Copyright (C) 2005, 2006 Alexey Proskuryakov (ap at nypop.com)
-    Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/)
-
-    This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Library General Public
-    License as published by the Free Software Foundation; either
-    version 2 of the License, or (at your option) any later version.
-
-    This library is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-    Library General Public License for more details.
-
-    You should have received a copy of the GNU Library General Public License
-    along with this library; see the file COPYING.LIB.  If not, write to
-    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-    Boston, MA 02110-1301, USA.
-*/
-
-#include "config.h"
-#include "LegacyHTMLDocumentParser.h"
-
-#include "Attribute.h"
-#include "CSSHelper.h"
-#include "Cache.h"
-#include "CachedScript.h"
-#include "DocLoader.h"
-#include "DocumentFragment.h"
-#include "Event.h"
-#include "EventNames.h"
-#include "Frame.h"
-#include "FrameLoader.h"
-#include "FrameView.h"
-#include "HTMLElement.h"
-#include "HTMLNames.h"
-#include "LegacyHTMLTreeBuilder.h"
-#include "HTMLScriptElement.h"
-#include "HTMLViewSourceDocument.h"
-#include "ImageLoader.h"
-#include "InspectorTimelineAgent.h"
-#include "Page.h"
-#include "LegacyPreloadScanner.h"
-#include "ScriptSourceCode.h"
-#include "ScriptValue.h"
-#include "XSSAuditor.h"
-#include <wtf/ASCIICType.h>
-#include <wtf/CurrentTime.h>
-
-#include "HTMLEntityNames.cpp"
-
-#define PRELOAD_SCANNER_ENABLED 1
-
-using namespace WTF;
-using namespace std;
-
-namespace WebCore {
-
-using namespace HTMLNames;
-
-// This value is used to define how many loops (approximately tokens)
-// the parser will make before checking if it should yield.
-// To increase responsiveness reduce both ChunkSize and TimeDelay contants.
-static const int defaultTokenizerChunkSize = 4096;
-
-// FIXME: We would like this constant to be 200ms.
-// Yielding more aggressively results in increased responsiveness and better incremental rendering.
-// It slows down overall page-load on slower machines, though, so for now we set a value of 500.
-// TimeDelay controls the maximum time the parser will run before yielding.
-// Inline script execution can cause the parser to excede this limit.
-static const double defaultTokenizerTimeDelay = 0.500;
-
-static const char commentStart [] = "<!--";
-static const char doctypeStart [] = "<!doctype";
-static const char publicStart [] = "public";
-static const char systemStart [] = "system";
-static const char scriptEnd [] = "</script";
-static const char xmpEnd [] = "</xmp";
-static const char styleEnd [] =  "</style";
-static const char textareaEnd [] = "</textarea";
-static const char titleEnd [] = "</title";
-static const char iframeEnd [] = "</iframe";
-
-// Full support for MS Windows extensions to Latin-1.
-// Technically these extensions should only be activated for pages
-// marked "windows-1252" or "cp1252", but
-// in the standard Microsoft way, these extensions infect hundreds of thousands
-// of web pages.  Note that people with non-latin-1 Microsoft extensions
-// are SOL.
-//
-// See: http://www.microsoft.com/globaldev/reference/WinCP.asp
-//      http://www.bbsinc.com/iso8859.html
-//      http://www.obviously.com/
-//
-// There may be better equivalents
-
-// We only need this for entities. For non-entity text, we handle this in the text encoding.
-
-static const UChar windowsLatin1ExtensionArray[32] = {
-    0x20AC, 0x0081, 0x201A, 0x0192, 0x201E, 0x2026, 0x2020, 0x2021, // 80-87
-    0x02C6, 0x2030, 0x0160, 0x2039, 0x0152, 0x008D, 0x017D, 0x008F, // 88-8F
-    0x0090, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014, // 90-97
-    0x02DC, 0x2122, 0x0161, 0x203A, 0x0153, 0x009D, 0x017E, 0x0178  // 98-9F
-};
-
-static inline UChar fixUpChar(UChar c)
-{
-    if ((c & ~0x1F) != 0x0080)
-        return c;
-    return windowsLatin1ExtensionArray[c - 0x80];
-}
-
-static inline bool tagMatch(const char* s1, const UChar* s2, unsigned length)
-{
-    for (unsigned i = 0; i != length; ++i) {
-        unsigned char c1 = s1[i];
-        unsigned char uc1 = toASCIIUpper(static_cast<char>(c1));
-        UChar c2 = s2[i];
-        if (c1 != c2 && uc1 != c2)
-            return false;
-    }
-    return true;
-}
-
-inline void Token::addAttribute(AtomicString& attrName, const AtomicString& attributeValue, bool viewSourceMode)
-{
-    if (!attrName.isEmpty()) {
-        ASSERT(!attrName.contains('/'));
-        RefPtr<Attribute> a = Attribute::createMapped(attrName, attributeValue);
-        if (!attrs) {
-            attrs = NamedNodeMap::create();
-            attrs->reserveInitialCapacity(10);
-        }
-        attrs->insertAttribute(a.release(), viewSourceMode);
-    }
-
-    attrName = emptyAtom;
-}
-
-// ----------------------------------------------------------------------------
-
-LegacyHTMLDocumentParser::LegacyHTMLDocumentParser(HTMLDocument* document, bool reportErrors)
-    : ScriptableDocumentParser(document)
-    , m_buffer(0)
-    , m_scriptCode(0)
-    , m_scriptCodeSize(0)
-    , m_scriptCodeCapacity(0)
-    , m_scriptCodeResync(0)
-    , m_executingScript(0)
-    , m_requestingScript(false)
-    , m_hasScriptsWaitingForStylesheets(false)
-    , m_timer(this, &LegacyHTMLDocumentParser::timerFired)
-    , m_externalScriptsTimer(this, &LegacyHTMLDocumentParser::executeExternalScriptsTimerFired)
-    , m_treeBuilder(new LegacyHTMLTreeBuilder(document, reportErrors))
-    , m_inWrite(false)
-    , m_fragment(false)
-    , m_scriptingPermission(FragmentScriptingAllowed)
-{
-    begin();
-}
-
-LegacyHTMLDocumentParser::LegacyHTMLDocumentParser(HTMLViewSourceDocument* document)
-    : ScriptableDocumentParser(document, true)
-    , m_buffer(0)
-    , m_scriptCode(0)
-    , m_scriptCodeSize(0)
-    , m_scriptCodeCapacity(0)
-    , m_scriptCodeResync(0)
-    , m_executingScript(0)
-    , m_requestingScript(false)
-    , m_hasScriptsWaitingForStylesheets(false)
-    , m_timer(this, &LegacyHTMLDocumentParser::timerFired)
-    , m_externalScriptsTimer(this, &LegacyHTMLDocumentParser::executeExternalScriptsTimerFired)
-    , m_inWrite(false)
-    , m_fragment(false)
-    , m_scriptingPermission(FragmentScriptingAllowed)
-{
-    begin();
-}
-
-LegacyHTMLDocumentParser::LegacyHTMLDocumentParser(DocumentFragment* frag, FragmentScriptingPermission scriptingPermission)
-    : ScriptableDocumentParser(frag->document())
-    , m_buffer(0)
-    , m_scriptCode(0)
-    , m_scriptCodeSize(0)
-    , m_scriptCodeCapacity(0)
-    , m_scriptCodeResync(0)
-    , m_executingScript(0)
-    , m_requestingScript(false)
-    , m_hasScriptsWaitingForStylesheets(false)
-    , m_timer(this, &LegacyHTMLDocumentParser::timerFired)
-    , m_externalScriptsTimer(this, &LegacyHTMLDocumentParser::executeExternalScriptsTimerFired)
-    , m_treeBuilder(new LegacyHTMLTreeBuilder(frag, scriptingPermission))
-    , m_inWrite(false)
-    , m_fragment(true)
-    , m_scriptingPermission(scriptingPermission)
-{
-    begin();
-}
-
-void LegacyHTMLDocumentParser::reset()
-{
-    ASSERT(m_executingScript == 0);
-
-    while (!m_pendingScripts.isEmpty()) {
-        CachedResourceHandle<CachedScript> cs = m_pendingScripts.takeFirst();
-        ASSERT(cache()->disabled() || cs->accessCount() > 0);
-        cs->removeClient(this);
-    }
-
-    fastFree(m_buffer);
-    m_buffer = m_dest = 0;
-    m_bufferSize = 0;
-
-    fastFree(m_scriptCode);
-    m_scriptCode = 0;
-    m_scriptCodeSize = m_scriptCodeCapacity = m_scriptCodeResync = 0;
-
-    m_timer.stop();
-    m_externalScriptsTimer.stop();
-
-    m_state.setAllowYield(false);
-    m_state.setForceSynchronous(false);
-
-    m_currentToken.reset();
-    m_doctypeToken.reset();
-    m_doctypeSearchCount = 0;
-    m_doctypeSecondarySearchCount = 0;
-    m_hasScriptsWaitingForStylesheets = false;
-}
-
-void LegacyHTMLDocumentParser::begin()
-{
-    m_executingScript = 0;
-    m_requestingScript = false;
-    m_hasScriptsWaitingForStylesheets = false;
-    m_state.setLoadingExtScript(false);
-    reset();
-    m_bufferSize = 254;
-    m_buffer = static_cast<UChar*>(fastMalloc(sizeof(UChar) * 254));
-    m_dest = m_buffer;
-    tquote = NoQuote;
-    searchCount = 0;
-    m_state.setEntityState(NoEntity);
-    m_scriptTagSrcAttrValue = String();
-    m_pendingSrc.clear();
-    m_currentPrependingSrc = 0;
-    m_noMoreData = false;
-    m_brokenComments = false;
-    m_brokenServer = false;
-    m_lineNumber = 0;
-    m_currentScriptTagStartLineNumber = 0;
-    m_currentTagStartLineNumber = 0;
-    m_state.setForceSynchronous(false);
-
-    Page* page = document()->page();
-    if (page && page->hasCustomHTMLTokenizerTimeDelay())
-        m_tokenizerTimeDelay = page->customHTMLTokenizerTimeDelay();
-    else
-        m_tokenizerTimeDelay = defaultTokenizerTimeDelay;
-
-    if (page && page->hasCustomHTMLTokenizerChunkSize())
-        m_tokenizerChunkSize = page->customHTMLTokenizerChunkSize();
-    else
-        m_tokenizerChunkSize = defaultTokenizerChunkSize;
-}
-
-void LegacyHTMLDocumentParser::setForceSynchronous(bool force)
-{
-    m_state.setForceSynchronous(force);
-}
-
-LegacyHTMLDocumentParser::State LegacyHTMLDocumentParser::processListing(SegmentedString list, State state)
-{
-    // This function adds the listing 'list' as
-    // preformatted text-tokens to the token-collection
-    while (!list.isEmpty()) {
-        if (state.skipLF()) {
-            state.setSkipLF(false);
-            if (*list == '\n') {
-                list.advance();
-                continue;
-            }
-        }
-
-        checkBuffer();
-
-        if (*list == '\n' || *list == '\r') {
-            if (state.discardLF())
-                // Ignore this LF
-                state.setDiscardLF(false); // We have discarded 1 LF
-            else
-                *m_dest++ = '\n';
-
-            /* Check for MS-DOS CRLF sequence */
-            if (*list == '\r')
-                state.setSkipLF(true);
-
-            list.advance();
-        } else {
-            state.setDiscardLF(false);
-            *m_dest++ = *list;
-            list.advance();
-        }
-    }
-
-    return state;
-}
-
-LegacyHTMLDocumentParser::State LegacyHTMLDocumentParser::parseNonHTMLText(SegmentedString& src, State state)
-{
-    ASSERT(state.inTextArea() || state.inTitle() || state.inIFrame() || !state.hasEntityState());
-    ASSERT(!state.hasTagState());
-    ASSERT(state.inXmp() + state.inTextArea() + state.inTitle() + state.inStyle() + state.inScript() + state.inIFrame() == 1);
-    if (state.inScript() && !m_currentScriptTagStartLineNumber)
-        m_currentScriptTagStartLineNumber = m_lineNumber;
-
-    if (state.inComment())
-        state = parseComment(src, state);
-
-    int lastDecodedEntityPosition = -1;
-    while (!src.isEmpty()) {
-        checkScriptBuffer();
-        UChar ch = *src;
-
-        if (!m_scriptCodeResync && !m_brokenComments &&
-            !state.inXmp() && ch == '-' && m_scriptCodeSize >= 3 && !src.escaped() &&
-            m_scriptCode[m_scriptCodeSize - 3] == '<' && m_scriptCode[m_scriptCodeSize - 2] == '!' && m_scriptCode[m_scriptCodeSize - 1] == '-' &&
-            (lastDecodedEntityPosition < m_scriptCodeSize - 3)) {
-            state.setInComment(true);
-            state = parseComment(src, state);
-            continue;
-        }
-        if (m_scriptCodeResync && !tquote && ch == '>') {
-            src.advancePastNonNewline();
-            m_scriptCodeSize = m_scriptCodeResync - 1;
-            m_scriptCodeResync = 0;
-            m_scriptCode[m_scriptCodeSize] = m_scriptCode[m_scriptCodeSize + 1] = 0;
-            if (state.inScript())
-                state = scriptHandler(state);
-            else {
-                state = processListing(SegmentedString(String(m_scriptCode, m_scriptCodeSize)), state);
-                processToken();
-                if (state.inStyle()) {
-                    m_currentToken.tagName = styleTag.localName();
-                    m_currentToken.beginTag = false;
-                } else if (state.inTextArea()) {
-                    m_currentToken.tagName = textareaTag.localName();
-                    m_currentToken.beginTag = false;
-                } else if (state.inTitle()) {
-                    m_currentToken.tagName = titleTag.localName();
-                    m_currentToken.beginTag = false;
-                } else if (state.inXmp()) {
-                    m_currentToken.tagName = xmpTag.localName();
-                    m_currentToken.beginTag = false;
-                } else if (state.inIFrame()) {
-                    m_currentToken.tagName = iframeTag.localName();
-                    m_currentToken.beginTag = false;
-                }
-                processToken();
-                state.setInStyle(false);
-                state.setInScript(false);
-                state.setInTextArea(false);
-                state.setInTitle(false);
-                state.setInXmp(false);
-                state.setInIFrame(false);
-                tquote = NoQuote;
-                m_scriptCodeSize = m_scriptCodeResync = 0;
-            }
-            return state;
-        }
-        // possible end of tagname, lets check.
-        if (!m_scriptCodeResync && !state.escaped() && !src.escaped() && (ch == '>' || ch == '/' || isASCIISpace(ch)) &&
-             m_scriptCodeSize >= m_searchStopperLength &&
-             tagMatch(m_searchStopper, m_scriptCode + m_scriptCodeSize - m_searchStopperLength, m_searchStopperLength) &&
-             (lastDecodedEntityPosition < m_scriptCodeSize - m_searchStopperLength)) {
-            m_scriptCodeResync = m_scriptCodeSize-m_searchStopperLength+1;
-            tquote = NoQuote;
-            continue;
-        }
-        if (m_scriptCodeResync && !state.escaped()) {
-            if (ch == '\"')
-                tquote = (tquote == NoQuote) ? DoubleQuote : ((tquote == SingleQuote) ? SingleQuote : NoQuote);
-            else if (ch == '\'')
-                tquote = (tquote == NoQuote) ? SingleQuote : (tquote == DoubleQuote) ? DoubleQuote : NoQuote;
-            else if (tquote != NoQuote && (ch == '\r' || ch == '\n'))
-                tquote = NoQuote;
-        }
-        state.setEscaped(!state.escaped() && ch == '\\');
-        if (!m_scriptCodeResync && (state.inTextArea() || state.inTitle() || state.inIFrame()) && !src.escaped() && ch == '&') {
-            UChar* scriptCodeDest = m_scriptCode + m_scriptCodeSize;
-            src.advancePastNonNewline();
-            state = parseEntity(src, scriptCodeDest, state, m_cBufferPos, true, false);
-            if (scriptCodeDest == m_scriptCode + m_scriptCodeSize)
-                lastDecodedEntityPosition = m_scriptCodeSize;
-            else
-                m_scriptCodeSize = scriptCodeDest - m_scriptCode;
-        } else {
-            m_scriptCode[m_scriptCodeSize++] = ch;
-            src.advance(m_lineNumber);
-        }
-    }
-
-    return state;
-}
-
-LegacyHTMLDocumentParser::State LegacyHTMLDocumentParser::scriptHandler(State state)
-{
-    // We are inside a <script>
-    bool doScriptExec = false;
-    int startLine = m_currentScriptTagStartLineNumber + 1; // Script line numbers are 1 based, HTMLTokenzier line numbers are 0 based
-
-    // Reset m_currentScriptTagStartLineNumber to indicate that we've finished parsing the current script element
-    m_currentScriptTagStartLineNumber = 0;
-
-    // (Bugzilla 3837) Scripts following a frameset element should not execute or,
-    // in the case of extern scripts, even load.
-    bool followingFrameset = (document()->body() && document()->body()->hasTagName(framesetTag));
-
-    CachedScript* cs = 0;
-    // don't load external scripts for standalone documents (for now)
-    if (!inViewSourceMode()) {
-        if (!m_scriptTagSrcAttrValue.isEmpty() && document()->frame()) {
-            // forget what we just got; load from src url instead
-            if (!m_treeBuilder->skipMode() && !followingFrameset) {
-                // The parser might have been stopped by for example a window.close call in an earlier script.
-                // If so, we don't want to load scripts.
-                if (!m_parserStopped && m_scriptNode->dispatchBeforeLoadEvent(m_scriptTagSrcAttrValue) &&
-                    (cs = document()->docLoader()->requestScript(m_scriptTagSrcAttrValue, m_scriptTagCharsetAttrValue)))
-                    m_pendingScripts.append(cs);
-                else
-                    m_scriptNode = 0;
-            } else
-                m_scriptNode = 0;
-            m_scriptTagSrcAttrValue = String();
-        } else {
-            // Parse m_scriptCode containing <script> info
-            doScriptExec = m_scriptNode->shouldExecuteAsJavaScript();
-#if ENABLE(XHTMLMP)
-            if (!doScriptExec)
-                document()->setShouldProcessNoscriptElement(true);
-#endif
-            m_scriptNode = 0;
-        }
-    }
-
-    state = processListing(SegmentedString(String(m_scriptCode, m_scriptCodeSize)), state);
-    RefPtr<Node> node = processToken();
-
-    if (node && m_scriptingPermission == FragmentScriptingNotAllowed) {
-        ExceptionCode ec;
-        node->remove(ec);
-        node = 0;
-    }
-
-    String scriptString = node ? node->textContent() : "";
-    m_currentToken.tagName = scriptTag.localName();
-    m_currentToken.beginTag = false;
-    processToken();
-
-    state.setInScript(false);
-    m_scriptCodeSize = m_scriptCodeResync = 0;
-
-    // FIXME: The script should be syntax highlighted.
-    if (inViewSourceMode())
-        return state;
-
-    SegmentedString* savedPrependingSrc = m_currentPrependingSrc;
-    SegmentedString prependingSrc;
-    m_currentPrependingSrc = &prependingSrc;
-
-    if (!m_treeBuilder->skipMode() && !followingFrameset) {
-        if (cs) {
-            if (savedPrependingSrc)
-                savedPrependingSrc->append(m_src);
-            else
-                m_pendingSrc.prepend(m_src);
-            setSrc(SegmentedString());
-
-            // the ref() call below may call notifyFinished if the script is already in cache,
-            // and that mucks with the state directly, so we must write it back to the object.
-            m_state = state;
-            bool savedRequestingScript = m_requestingScript;
-            m_requestingScript = true;
-            cs->addClient(this);
-            m_requestingScript = savedRequestingScript;
-            state = m_state;
-            // will be 0 if script was already loaded and ref() executed it
-            if (!m_pendingScripts.isEmpty())
-                state.setLoadingExtScript(true);
-        } else if (!m_fragment && doScriptExec) {
-            if (!m_executingScript)
-                m_pendingSrc.prepend(m_src);
-            else
-                prependingSrc = m_src;
-            setSrc(SegmentedString());
-            state = scriptExecution(ScriptSourceCode(scriptString, document()->frame() ? document()->frame()->document()->url() : KURL(), startLine), state);
-        }
-    }
-
-    if (!m_executingScript && !state.loadingExtScript()) {
-        m_src.append(m_pendingSrc);
-        m_pendingSrc.clear();
-    } else if (!prependingSrc.isEmpty()) {
-        // restore first so that the write appends in the right place
-        // (does not hurt to do it again below)
-        m_currentPrependingSrc = savedPrependingSrc;
-
-        // we need to do this slightly modified bit of one of the write() cases
-        // because we want to prepend to m_pendingSrc rather than appending
-        // if there's no previous prependingSrc
-        if (!m_pendingScripts.isEmpty()) {
-            if (m_currentPrependingSrc)
-                m_currentPrependingSrc->append(prependingSrc);
-            else
-                m_pendingSrc.prepend(prependingSrc);
-        } else {
-            m_state = state;
-            write(prependingSrc, false);
-            state = m_state;
-        }
-    }
-
-#if PRELOAD_SCANNER_ENABLED
-    if (!m_pendingScripts.isEmpty() && !m_executingScript) {
-        if (!m_preloadScanner)
-            m_preloadScanner.set(new LegacyPreloadScanner(document()));
-        if (!m_preloadScanner->inProgress()) {
-            m_preloadScanner->begin();
-            m_preloadScanner->write(m_pendingSrc);
-        }
-    }
-#endif
-    m_currentPrependingSrc = savedPrependingSrc;
-
-    return state;
-}
-
-LegacyHTMLDocumentParser::State LegacyHTMLDocumentParser::scriptExecution(const ScriptSourceCode& sourceCode, State state)
-{
-    if (m_fragment || !document()->frame())
-        return state;
-    m_executingScript++;
-
-    SegmentedString* savedPrependingSrc = m_currentPrependingSrc;
-    SegmentedString prependingSrc;
-    m_currentPrependingSrc = &prependingSrc;
-
-    m_state = state;
-    document()->frame()->script()->executeScript(sourceCode);
-    state = m_state;
-
-    state.setAllowYield(true);
-
-    m_executingScript--;
-
-    if (!m_executingScript && !state.loadingExtScript()) {
-        m_pendingSrc.prepend(prependingSrc);
-        m_src.append(m_pendingSrc);
-        m_pendingSrc.clear();
-    } else if (!prependingSrc.isEmpty()) {
-        // restore first so that the write appends in the right place
-        // (does not hurt to do it again below)
-        m_currentPrependingSrc = savedPrependingSrc;
-
-        // we need to do this slightly modified bit of one of the write() cases
-        // because we want to prepend to m_pendingSrc rather than appending
-        // if there's no previous prependingSrc
-        if (!m_pendingScripts.isEmpty()) {
-            if (m_currentPrependingSrc)
-                m_currentPrependingSrc->append(prependingSrc);
-            else
-                m_pendingSrc.prepend(prependingSrc);
-
-#if PRELOAD_SCANNER_ENABLED
-            // We are stuck waiting for another script. Lets check the source that
-            // was just document.write()n for anything to load.
-            LegacyPreloadScanner documentWritePreloadScanner(document());
-            documentWritePreloadScanner.begin();
-            documentWritePreloadScanner.write(prependingSrc);
-            documentWritePreloadScanner.end();
-#endif
-        } else {
-            m_state = state;
-            write(prependingSrc, false);
-            state = m_state;
-        }
-    }
-
-    m_currentPrependingSrc = savedPrependingSrc;
-
-    return state;
-}
-
-LegacyHTMLDocumentParser::State LegacyHTMLDocumentParser::parseComment(SegmentedString& src, State state)
-{
-    // FIXME: Why does this code even run for comments inside <script> and <style>? This seems bogus.
-    checkScriptBuffer(src.length());
-    while (!src.isEmpty()) {
-        UChar ch = *src;
-        m_scriptCode[m_scriptCodeSize++] = ch;
-        if (ch == '>') {
-            bool handleBrokenComments = m_brokenComments && !(state.inScript() || state.inStyle());
-            int endCharsCount = 1; // start off with one for the '>' character
-            if (m_scriptCodeSize > 2 && m_scriptCode[m_scriptCodeSize-3] == '-' && m_scriptCode[m_scriptCodeSize-2] == '-') {
-                endCharsCount = 3;
-            } else if (m_scriptCodeSize > 3 && m_scriptCode[m_scriptCodeSize-4] == '-' && m_scriptCode[m_scriptCodeSize-3] == '-' &&
-                m_scriptCode[m_scriptCodeSize-2] == '!') {
-                // Other browsers will accept --!> as a close comment, even though it's
-                // not technically valid.
-                endCharsCount = 4;
-            }
-            if (handleBrokenComments || endCharsCount > 1) {
-                src.advancePastNonNewline();
-                if (!(state.inTitle() || state.inScript() || state.inXmp() || state.inTextArea() || state.inStyle() || state.inIFrame())) {
-                    checkScriptBuffer();
-                    m_scriptCode[m_scriptCodeSize] = 0;
-                    m_scriptCode[m_scriptCodeSize + 1] = 0;
-                    m_currentToken.tagName = commentAtom;
-                    m_currentToken.beginTag = true;
-                    state = processListing(SegmentedString(String(m_scriptCode, m_scriptCodeSize - endCharsCount)), state);
-                    processToken();
-                    m_currentToken.tagName = commentAtom;
-                    m_currentToken.beginTag = false;
-                    processToken();
-                    m_scriptCodeSize = 0;
-                }
-                state.setInComment(false);
-                return state; // Finished parsing comment
-            }
-        }
-        src.advance(m_lineNumber);
-    }
-
-    return state;
-}
-
-LegacyHTMLDocumentParser::State LegacyHTMLDocumentParser::parseServer(SegmentedString& src, State state)
-{
-    checkScriptBuffer(src.length());
-    while (!src.isEmpty()) {
-        UChar ch = *src;
-        m_scriptCode[m_scriptCodeSize++] = ch;
-        if (ch == '>' && m_scriptCodeSize > 1 && m_scriptCode[m_scriptCodeSize - 2] == '%') {
-            src.advancePastNonNewline();
-            state.setInServer(false);
-            m_scriptCodeSize = 0;
-            return state; // Finished parsing server include
-        }
-        src.advance(m_lineNumber);
-    }
-    return state;
-}
-
-LegacyHTMLDocumentParser::State LegacyHTMLDocumentParser::parseProcessingInstruction(SegmentedString& src, State state)
-{
-    UChar oldchar = 0;
-    while (!src.isEmpty()) {
-        UChar chbegin = *src;
-        if (chbegin == '\'')
-            tquote = tquote == SingleQuote ? NoQuote : SingleQuote;
-        else if (chbegin == '\"')
-            tquote = tquote == DoubleQuote ? NoQuote : DoubleQuote;
-        // Look for '?>'
-        // Some crappy sites omit the "?" before it, so
-        // we look for an unquoted '>' instead. (IE compatible)
-        else if (chbegin == '>' && (!tquote || oldchar == '?')) {
-            // We got a '?>' sequence
-            state.setInProcessingInstruction(false);
-            src.advancePastNonNewline();
-            state.setDiscardLF(true);
-            return state; // Finished parsing comment!
-        }
-        src.advance(m_lineNumber);
-        oldchar = chbegin;
-    }
-
-    return state;
-}
-
-LegacyHTMLDocumentParser::State LegacyHTMLDocumentParser::parseText(SegmentedString& src, State state)
-{
-    while (!src.isEmpty()) {
-        UChar cc = *src;
-
-        if (state.skipLF()) {
-            state.setSkipLF(false);
-            if (cc == '\n') {
-                src.advancePastNewline(m_lineNumber);
-                continue;
-            }
-        }
-
-        // do we need to enlarge the buffer?
-        checkBuffer();
-
-        if (cc == '\r') {
-            state.setSkipLF(true);
-            *m_dest++ = '\n';
-        } else
-            *m_dest++ = cc;
-        src.advance(m_lineNumber);
-    }
-
-    return state;
-}
-
-
-LegacyHTMLDocumentParser::State LegacyHTMLDocumentParser::parseEntity(SegmentedString& src, UChar*& dest, State state, unsigned& cBufferPos, bool start, bool parsingTag)
-{
-    if (start) {
-        cBufferPos = 0;
-        state.setEntityState(SearchEntity);
-        EntityUnicodeValue = 0;
-    }
-
-    while (!src.isEmpty()) {
-        UChar cc = *src;
-        switch (state.entityState()) {
-        case NoEntity:
-            ASSERT(state.entityState() != NoEntity);
-            return state;
-
-        case SearchEntity:
-            if (cc == '#') {
-                m_cBuffer[cBufferPos++] = cc;
-                src.advancePastNonNewline();
-                state.setEntityState(NumericSearch);
-            } else
-                state.setEntityState(EntityName);
-            break;
-
-        case NumericSearch:
-            if (cc == 'x' || cc == 'X') {
-                m_cBuffer[cBufferPos++] = cc;
-                src.advancePastNonNewline();
-                state.setEntityState(Hexadecimal);
-            } else if (cc >= '0' && cc <= '9')
-                state.setEntityState(Decimal);
-            else
-                state.setEntityState(SearchSemicolon);
-            break;
-
-        case Hexadecimal: {
-            int ll = min(src.length(), 10 - cBufferPos);
-            while (ll--) {
-                cc = *src;
-                if (!((cc >= '0' && cc <= '9') || (cc >= 'a' && cc <= 'f') || (cc >= 'A' && cc <= 'F'))) {
-                    state.setEntityState(SearchSemicolon);
-                    break;
-                }
-                int digit;
-                if (cc < 'A')
-                    digit = cc - '0';
-                else
-                    digit = (cc - 'A' + 10) & 0xF; // handle both upper and lower case without a branch
-                EntityUnicodeValue = EntityUnicodeValue * 16 + digit;
-                m_cBuffer[cBufferPos++] = cc;
-                src.advancePastNonNewline();
-            }
-            if (cBufferPos == 10)
-                state.setEntityState(SearchSemicolon);
-            break;
-        }
-        case Decimal:
-        {
-            int ll = min(src.length(), 9-cBufferPos);
-            while (ll--) {
-                cc = *src;
-
-                if (!(cc >= '0' && cc <= '9')) {
-                    state.setEntityState(SearchSemicolon);
-                    break;
-                }
-
-                EntityUnicodeValue = EntityUnicodeValue * 10 + (cc - '0');
-                m_cBuffer[cBufferPos++] = cc;
-                src.advancePastNonNewline();
-            }
-            if (cBufferPos == 9)
-                state.setEntityState(SearchSemicolon);
-            break;
-        }
-        case EntityName:
-        {
-            int ll = min(src.length(), 9-cBufferPos);
-            while (ll--) {
-                cc = *src;
-
-                if (!((cc >= 'a' && cc <= 'z') || (cc >= '0' && cc <= '9') || (cc >= 'A' && cc <= 'Z'))) {
-                    state.setEntityState(SearchSemicolon);
-                    break;
-                }
-
-                m_cBuffer[cBufferPos++] = cc;
-                src.advancePastNonNewline();
-            }
-            if (cBufferPos == 9)
-                state.setEntityState(SearchSemicolon);
-            if (state.entityState() == SearchSemicolon) {
-                if (cBufferPos > 1) {
-                    // Since the maximum length of entity name is 9,
-                    // so a single char array which is allocated on
-                    // the stack, its length is 10, should be OK.
-                    // Also if we have an illegal character, we treat it
-                    // as illegal entity name.
-                    unsigned testedEntityNameLen = 0;
-                    char tmpEntityNameBuffer[10];
-
-                    ASSERT(cBufferPos < 10);
-                    for (; testedEntityNameLen < cBufferPos; ++testedEntityNameLen) {
-                        if (m_cBuffer[testedEntityNameLen] > 0x7e)
-                            break;
-                        tmpEntityNameBuffer[testedEntityNameLen] = m_cBuffer[testedEntityNameLen];
-                    }
-
-                    const Entity *e;
-
-                    if (testedEntityNameLen == cBufferPos)
-                        e = findEntity(tmpEntityNameBuffer, cBufferPos);
-                    else
-                        e = 0;
-
-                    if (e)
-                        EntityUnicodeValue = e->code;
-
-                    // be IE compatible
-                    if (parsingTag && EntityUnicodeValue > 255 && *src != ';')
-                        EntityUnicodeValue = 0;
-                }
-            }
-            else
-                break;
-        }
-        case SearchSemicolon:
-            // Don't allow values that are more than 21 bits.
-            if (EntityUnicodeValue > 0 && EntityUnicodeValue <= 0x10FFFF) {
-                if (!inViewSourceMode()) {
-                    if (*src == ';')
-                        src.advancePastNonNewline();
-                    if (EntityUnicodeValue <= 0xFFFF) {
-                        checkBuffer();
-                        src.push(fixUpChar(EntityUnicodeValue));
-                    } else {
-                        // Convert to UTF-16, using surrogate code points.
-                        checkBuffer(2);
-                        src.push(U16_LEAD(EntityUnicodeValue));
-                        src.push(U16_TRAIL(EntityUnicodeValue));
-                    }
-                } else {
-                    // FIXME: We should eventually colorize entities by sending them as a special token.
-                    // 12 bytes required: up to 10 bytes in m_cBuffer plus the
-                    // leading '&' and trailing ';'
-                    checkBuffer(12);
-                    *dest++ = '&';
-                    for (unsigned i = 0; i < cBufferPos; i++)
-                        dest[i] = m_cBuffer[i];
-                    dest += cBufferPos;
-                    if (*src == ';') {
-                        *dest++ = ';';
-                        src.advancePastNonNewline();
-                    }
-                }
-            } else {
-                // 11 bytes required: up to 10 bytes in m_cBuffer plus the
-                // leading '&'
-                checkBuffer(11);
-                // ignore the sequence, add it to the buffer as plaintext
-                *dest++ = '&';
-                for (unsigned i = 0; i < cBufferPos; i++)
-                    dest[i] = m_cBuffer[i];
-                dest += cBufferPos;
-            }
-
-            state.setEntityState(NoEntity);
-            return state;
-        }
-    }
-
-    return state;
-}
-
-LegacyHTMLDocumentParser::State LegacyHTMLDocumentParser::parseDoctype(SegmentedString& src, State state)
-{
-    ASSERT(state.inDoctype());
-    while (!src.isEmpty() && state.inDoctype()) {
-        UChar c = *src;
-        bool isWhitespace = c == '\r' || c == '\n' || c == '\t' || c == ' ';
-        switch (m_doctypeToken.state()) {
-            case DoctypeBegin: {
-                m_doctypeToken.setState(DoctypeBeforeName);
-                if (isWhitespace) {
-                    src.advance(m_lineNumber);
-                    if (inViewSourceMode())
-                        m_doctypeToken.m_source.append(c);
-                }
-                break;
-            }
-            case DoctypeBeforeName: {
-                if (c == '>') {
-                    // Malformed.  Just exit.
-                    src.advancePastNonNewline();
-                    state.setInDoctype(false);
-                    if (inViewSourceMode())
-                        processDoctypeToken();
-                } else if (isWhitespace) {
-                    src.advance(m_lineNumber);
-                    if (inViewSourceMode())
-                        m_doctypeToken.m_source.append(c);
-                } else
-                    m_doctypeToken.setState(DoctypeName);
-                break;
-            }
-            case DoctypeName: {
-                if (c == '>') {
-                    // Valid doctype. Emit it.
-                    src.advancePastNonNewline();
-                    state.setInDoctype(false);
-                    processDoctypeToken();
-                } else if (isWhitespace) {
-                    m_doctypeSearchCount = 0; // Used now to scan for PUBLIC
-                    m_doctypeSecondarySearchCount = 0; // Used now to scan for SYSTEM
-                    m_doctypeToken.setState(DoctypeAfterName);
-                    src.advance(m_lineNumber);
-                    if (inViewSourceMode())
-                        m_doctypeToken.m_source.append(c);
-                } else {
-                    src.advancePastNonNewline();
-                    m_doctypeToken.m_name.append(c);
-                    if (inViewSourceMode())
-                        m_doctypeToken.m_source.append(c);
-                }
-                break;
-            }
-            case DoctypeAfterName: {
-                if (c == '>') {
-                    // Valid doctype. Emit it.
-                    src.advancePastNonNewline();
-                    state.setInDoctype(false);
-                    processDoctypeToken();
-                } else if (!isWhitespace) {
-                    src.advancePastNonNewline();
-                    if (toASCIILower(c) == publicStart[m_doctypeSearchCount]) {
-                        m_doctypeSearchCount++;
-                        if (m_doctypeSearchCount == 6)
-                            // Found 'PUBLIC' sequence
-                            m_doctypeToken.setState(DoctypeBeforePublicID);
-                    } else if (m_doctypeSearchCount > 0) {
-                        m_doctypeSearchCount = 0;
-                        m_doctypeToken.setState(DoctypeBogus);
-                    } else if (toASCIILower(c) == systemStart[m_doctypeSecondarySearchCount]) {
-                        m_doctypeSecondarySearchCount++;
-                        if (m_doctypeSecondarySearchCount == 6)
-                            // Found 'SYSTEM' sequence
-                            m_doctypeToken.setState(DoctypeBeforeSystemID);
-                    } else {
-                        m_doctypeSecondarySearchCount = 0;
-                        m_doctypeToken.setState(DoctypeBogus);
-                    }
-                    if (inViewSourceMode())
-                        m_doctypeToken.m_source.append(c);
-                } else {
-                    src.advance(m_lineNumber); // Whitespace keeps us in the after name state.
-                    if (inViewSourceMode())
-                        m_doctypeToken.m_source.append(c);
-                }
-                break;
-            }
-            case DoctypeBeforePublicID: {
-                if (c == '\"' || c == '\'') {
-                    tquote = c == '\"' ? DoubleQuote : SingleQuote;
-                    m_doctypeToken.setState(DoctypePublicID);
-                    src.advancePastNonNewline();
-                    if (inViewSourceMode())
-                        m_doctypeToken.m_source.append(c);
-                } else if (c == '>') {
-                    // Considered bogus.  Don't process the doctype.
-                    src.advancePastNonNewline();
-                    state.setInDoctype(false);
-                    if (inViewSourceMode())
-                        processDoctypeToken();
-                } else if (isWhitespace) {
-                    src.advance(m_lineNumber);
-                    if (inViewSourceMode())
-                        m_doctypeToken.m_source.append(c);
-                } else
-                    m_doctypeToken.setState(DoctypeBogus);
-                break;
-            }
-            case DoctypePublicID: {
-                if ((c == '\"' && tquote == DoubleQuote) || (c == '\'' && tquote == SingleQuote)) {
-                    src.advancePastNonNewline();
-                    m_doctypeToken.setState(DoctypeAfterPublicID);
-                    if (inViewSourceMode())
-                        m_doctypeToken.m_source.append(c);
-                } else if (c == '>') {
-                     // Considered bogus.  Don't process the doctype.
-                    src.advancePastNonNewline();
-                    state.setInDoctype(false);
-                    if (inViewSourceMode())
-                        processDoctypeToken();
-                } else {
-                    m_doctypeToken.m_publicID.append(c);
-                    src.advance(m_lineNumber);
-                    if (inViewSourceMode())
-                        m_doctypeToken.m_source.append(c);
-                }
-                break;
-            }
-            case DoctypeAfterPublicID:
-                if (c == '\"' || c == '\'') {
-                    tquote = c == '\"' ? DoubleQuote : SingleQuote;
-                    m_doctypeToken.setState(DoctypeSystemID);
-                    src.advancePastNonNewline();
-                    if (inViewSourceMode())
-                        m_doctypeToken.m_source.append(c);
-                } else if (c == '>') {
-                    // Valid doctype. Emit it now.
-                    src.advancePastNonNewline();
-                    state.setInDoctype(false);
-                    processDoctypeToken();
-                } else if (isWhitespace) {
-                    src.advance(m_lineNumber);
-                    if (inViewSourceMode())
-                        m_doctypeToken.m_source.append(c);
-                } else
-                    m_doctypeToken.setState(DoctypeBogus);
-                break;
-            case DoctypeBeforeSystemID:
-                if (c == '\"' || c == '\'') {
-                    tquote = c == '\"' ? DoubleQuote : SingleQuote;
-                    m_doctypeToken.setState(DoctypeSystemID);
-                    src.advancePastNonNewline();
-                    if (inViewSourceMode())
-                        m_doctypeToken.m_source.append(c);
-                } else if (c == '>') {
-                    // Considered bogus.  Don't process the doctype.
-                    src.advancePastNonNewline();
-                    state.setInDoctype(false);
-                } else if (isWhitespace) {
-                    src.advance(m_lineNumber);
-                    if (inViewSourceMode())
-                        m_doctypeToken.m_source.append(c);
-                } else
-                    m_doctypeToken.setState(DoctypeBogus);
-                break;
-            case DoctypeSystemID:
-                if ((c == '\"' && tquote == DoubleQuote) || (c == '\'' && tquote == SingleQuote)) {
-                    src.advancePastNonNewline();
-                    m_doctypeToken.setState(DoctypeAfterSystemID);
-                    if (inViewSourceMode())
-                        m_doctypeToken.m_source.append(c);
-                } else if (c == '>') {
-                     // Considered bogus.  Don't process the doctype.
-                    src.advancePastNonNewline();
-                    state.setInDoctype(false);
-                    if (inViewSourceMode())
-                        processDoctypeToken();
-                } else {
-                    m_doctypeToken.m_systemID.append(c);
-                    src.advance(m_lineNumber);
-                    if (inViewSourceMode())
-                        m_doctypeToken.m_source.append(c);
-                }
-                break;
-            case DoctypeAfterSystemID:
-                if (c == '>') {
-                    // Valid doctype. Emit it now.
-                    src.advancePastNonNewline();
-                    state.setInDoctype(false);
-                    processDoctypeToken();
-                } else if (isWhitespace) {
-                    src.advance(m_lineNumber);
-                    if (inViewSourceMode())
-                        m_doctypeToken.m_source.append(c);
-                } else
-                    m_doctypeToken.setState(DoctypeBogus);
-                break;
-            case DoctypeBogus:
-                if (c == '>') {
-                    // Done with the bogus doctype.
-                    src.advancePastNonNewline();
-                    state.setInDoctype(false);
-                    if (inViewSourceMode())
-                       processDoctypeToken();
-                } else {
-                    src.advance(m_lineNumber); // Just keep scanning for '>'
-                    if (inViewSourceMode())
-                        m_doctypeToken.m_source.append(c);
-                }
-                break;
-            default:
-                break;
-        }
-    }
-    return state;
-}
-
-LegacyHTMLDocumentParser::State LegacyHTMLDocumentParser::parseTag(SegmentedString& src, State state)
-{
-    ASSERT(!state.hasEntityState());
-
-    unsigned cBufferPos = m_cBufferPos;
-
-    bool lastIsSlash = false;
-
-    while (!src.isEmpty()) {
-        checkBuffer();
-        switch (state.tagState()) {
-        case NoTag:
-        {
-            m_cBufferPos = cBufferPos;
-            return state;
-        }
-        case TagName:
-        {
-            if (searchCount > 0) {
-                if (*src == commentStart[searchCount]) {
-                    searchCount++;
-                    if (searchCount == 2)
-                        m_doctypeSearchCount++; // A '!' is also part of a doctype, so we are moving through that still as well.
-                    else
-                        m_doctypeSearchCount = 0;
-                    if (searchCount == 4) {
-                        // Found '<!--' sequence
-                        src.advancePastNonNewline();
-                        m_dest = m_buffer; // ignore the previous part of this tag
-                        state.setInComment(true);
-                        state.setTagState(NoTag);
-
-                        // Fix bug 34302 at kde.bugs.org.  Go ahead and treat
-                        // <!--> as a valid comment, since both mozilla and IE on windows
-                        // can handle this case.  Only do this in quirks mode. -dwh
-                        if (!src.isEmpty() && *src == '>' && document()->inCompatMode()) {
-                            state.setInComment(false);
-                            src.advancePastNonNewline();
-                            if (!src.isEmpty())
-                                m_cBuffer[cBufferPos++] = *src;
-                        } else
-                          state = parseComment(src, state);
-
-                        m_cBufferPos = cBufferPos;
-                        return state; // Finished parsing tag!
-                    }
-                    m_cBuffer[cBufferPos++] = *src;
-                    src.advancePastNonNewline();
-                    break;
-                } else
-                    searchCount = 0; // Stop looking for '<!--' sequence
-            }
-
-            if (m_doctypeSearchCount > 0) {
-                if (toASCIILower(*src) == doctypeStart[m_doctypeSearchCount]) {
-                    m_doctypeSearchCount++;
-                    m_cBuffer[cBufferPos++] = *src;
-                    src.advancePastNonNewline();
-                    if (m_doctypeSearchCount == 9) {
-                        // Found '<!DOCTYPE' sequence
-                        state.setInDoctype(true);
-                        state.setTagState(NoTag);
-                        m_doctypeToken.reset();
-                        if (inViewSourceMode())
-                            m_doctypeToken.m_source.append(m_cBuffer, cBufferPos);
-                        state = parseDoctype(src, state);
-                        m_cBufferPos = cBufferPos;
-                        return state;
-                    }
-                    break;
-                } else
-                    m_doctypeSearchCount = 0; // Stop looking for '<!DOCTYPE' sequence
-            }
-
-            bool finish = false;
-            unsigned int ll = min(src.length(), CBUFLEN - cBufferPos);
-            while (ll--) {
-                UChar curchar = *src;
-                if (isASCIISpace(curchar) || curchar == '>' || curchar == '<') {
-                    finish = true;
-                    break;
-                }
-
-                // tolower() shows up on profiles. This is faster!
-                if (curchar >= 'A' && curchar <= 'Z' && !inViewSourceMode())
-                    m_cBuffer[cBufferPos++] = curchar + ('a' - 'A');
-                else
-                    m_cBuffer[cBufferPos++] = curchar;
-                src.advancePastNonNewline();
-            }
-
-            // Disadvantage: we add the possible rest of the tag
-            // as attribute names. ### judge if this causes problems
-            if (finish || CBUFLEN == cBufferPos) {
-                bool beginTag;
-                UChar* ptr = m_cBuffer;
-                unsigned int len = cBufferPos;
-                m_cBuffer[cBufferPos] = '\0';
-                if ((cBufferPos > 0) && (*ptr == '/')) {
-                    // End Tag
-                    beginTag = false;
-                    ptr++;
-                    len--;
-                }
-                else
-                    // Start Tag
-                    beginTag = true;
-
-                // Ignore the / in fake xml tags like <br/>.  We trim off the "/" so that we'll get "br" as the tag name and not "br/".
-                if (len > 1 && ptr[len-1] == '/' && !inViewSourceMode())
-                    ptr[--len] = '\0';
-
-                // Now that we've shaved off any invalid / that might have followed the name), make the tag.
-                // FIXME: FireFox and WinIE turn !foo nodes into comments, we ignore comments. (fast/parser/tag-with-exclamation-point.html)
-                if (ptr[0] != '!' || inViewSourceMode()) {
-                    m_currentToken.tagName = AtomicString(ptr);
-                    m_currentToken.beginTag = beginTag;
-                }
-                m_dest = m_buffer;
-                state.setTagState(SearchAttribute);
-                cBufferPos = 0;
-            }
-            break;
-        }
-        case SearchAttribute:
-            while (!src.isEmpty()) {
-                UChar curchar = *src;
-                // In this mode just ignore any quotes we encounter and treat them like spaces.
-                if (!isASCIISpace(curchar) && curchar != '\'' && curchar != '"') {
-                    if (curchar == '<' || curchar == '>')
-                        state.setTagState(SearchEnd);
-                    else
-                        state.setTagState(AttributeName);
-
-                    cBufferPos = 0;
-                    break;
-                }
-                if (inViewSourceMode())
-                    m_currentToken.addViewSourceChar(curchar);
-                src.advance(m_lineNumber);
-            }
-            break;
-        case AttributeName:
-        {
-            m_rawAttributeBeforeValue.clear();
-            int ll = min(src.length(), CBUFLEN - cBufferPos);
-            while (ll--) {
-                UChar curchar = *src;
-                // If we encounter a "/" when scanning an attribute name, treat it as a delimiter.  This allows the
-                // cases like <input type=checkbox checked/> to work (and accommodates XML-style syntax as per HTML5).
-                if (curchar <= '>' && (curchar >= '<' || isASCIISpace(curchar) || curchar == '/')) {
-                    m_cBuffer[cBufferPos] = '\0';
-                    m_attrName = AtomicString(m_cBuffer);
-                    m_dest = m_buffer;
-                    *m_dest++ = 0;
-                    state.setTagState(SearchEqual);
-                    if (inViewSourceMode())
-                        m_currentToken.addViewSourceChar('a');
-                    break;
-                }
-
-                // tolower() shows up on profiles. This is faster!
-                if (curchar >= 'A' && curchar <= 'Z' && !inViewSourceMode())
-                    m_cBuffer[cBufferPos++] = curchar + ('a' - 'A');
-                else
-                    m_cBuffer[cBufferPos++] = curchar;
-
-                m_rawAttributeBeforeValue.append(curchar);
-                src.advance(m_lineNumber);
-            }
-            if (cBufferPos == CBUFLEN) {
-                m_cBuffer[cBufferPos] = '\0';
-                m_attrName = AtomicString(m_cBuffer);
-                m_dest = m_buffer;
-                *m_dest++ = 0;
-                state.setTagState(SearchEqual);
-                if (inViewSourceMode())
-                    m_currentToken.addViewSourceChar('a');
-            }
-            break;
-        }
-        case SearchEqual:
-            while (!src.isEmpty()) {
-                UChar curchar = *src;
-
-                if (lastIsSlash && curchar == '>') {
-                    // This is a quirk (with a long sad history).  We have to do this
-                    // since widgets do <script src="foo.js"/> and expect the tag to close.
-                    if (m_currentToken.tagName == scriptTag)
-                        m_currentToken.selfClosingTag = true;
-                    m_currentToken.brokenXMLStyle = true;
-                }
-
-                // In this mode just ignore any quotes or slashes we encounter and treat them like spaces.
-                if (!isASCIISpace(curchar) && curchar != '\'' && curchar != '"' && curchar != '/') {
-                    if (curchar == '=') {
-                        state.setTagState(SearchValue);
-                        if (inViewSourceMode())
-                            m_currentToken.addViewSourceChar(curchar);
-                        m_rawAttributeBeforeValue.append(curchar);
-                        src.advancePastNonNewline();
-                    } else {
-                        m_currentToken.addAttribute(m_attrName, emptyAtom, inViewSourceMode());
-                        m_dest = m_buffer;
-                        state.setTagState(SearchAttribute);
-                        lastIsSlash = false;
-                    }
-                    break;
-                }
-
-                lastIsSlash = curchar == '/';
-
-                if (inViewSourceMode())
-                    m_currentToken.addViewSourceChar(curchar);
-                m_rawAttributeBeforeValue.append(curchar);
-                src.advance(m_lineNumber);
-            }
-            break;
-        case SearchValue:
-            while (!src.isEmpty()) {
-                UChar curchar = *src;
-                if (!isASCIISpace(curchar)) {
-                    if (curchar == '\'' || curchar == '\"') {
-                        tquote = curchar == '\"' ? DoubleQuote : SingleQuote;
-                        state.setTagState(QuotedValue);
-                        if (inViewSourceMode())
-                            m_currentToken.addViewSourceChar(curchar);
-                        m_rawAttributeBeforeValue.append(curchar);
-                        src.advancePastNonNewline();
-                    } else
-                        state.setTagState(Value);
-
-                    break;
-                }
-                if (inViewSourceMode())
-                    m_currentToken.addViewSourceChar(curchar);
-                m_rawAttributeBeforeValue.append(curchar);
-                src.advance(m_lineNumber);
-            }
-            break;
-        case QuotedValue:
-            while (!src.isEmpty()) {
-                checkBuffer();
-
-                UChar curchar = *src;
-                if (curchar <= '>' && !src.escaped()) {
-                    if (curchar == '>' && m_attrName.isEmpty()) {
-                        // Handle a case like <img '>.  Just go ahead and be willing
-                        // to close the whole tag.  Don't consume the character and
-                        // just go back into SearchEnd while ignoring the whole
-                        // value.
-                        // FIXME: Note that this is actually not a very good solution.
-                        // It doesn't handle the general case of
-                        // unmatched quotes among attributes that have names. -dwh
-                        while (m_dest > m_buffer + 1 && (m_dest[-1] == '\n' || m_dest[-1] == '\r'))
-                            m_dest--; // remove trailing newlines
-                        AtomicString attributeValue(m_buffer + 1, m_dest - m_buffer - 1);
-                        if (!attributeValue.contains('/'))
-                            m_attrName = attributeValue; // Just make the name/value match. (FIXME: Is this some WinIE quirk?)
-                        m_currentToken.addAttribute(m_attrName, attributeValue, inViewSourceMode());
-                        if (inViewSourceMode())
-                            m_currentToken.addViewSourceChar('x');
-                        state.setTagState(SearchAttribute);
-                        m_dest = m_buffer;
-                        tquote = NoQuote;
-                        break;
-                    }
-
-                    if (curchar == '&') {
-                        src.advancePastNonNewline();
-                        state = parseEntity(src, m_dest, state, cBufferPos, true, true);
-                        break;
-                    }
-
-                    if ((tquote == SingleQuote && curchar == '\'') || (tquote == DoubleQuote && curchar == '\"')) {
-                        // some <input type=hidden> rely on trailing spaces. argh
-                        while (m_dest > m_buffer + 1 && (m_dest[-1] == '\n' || m_dest[-1] == '\r'))
-                            m_dest--; // remove trailing newlines
-                        AtomicString attributeValue(m_buffer + 1, m_dest - m_buffer - 1);
-                        if (m_attrName.isEmpty() && !attributeValue.contains('/')) {
-                            m_attrName = attributeValue; // Make the name match the value. (FIXME: Is this a WinIE quirk?)
-                            if (inViewSourceMode())
-                                m_currentToken.addViewSourceChar('x');
-                        } else if (inViewSourceMode())
-                            m_currentToken.addViewSourceChar('v');
-
-                        if (m_currentToken.beginTag && m_currentToken.tagName == scriptTag && !inViewSourceMode() && !m_treeBuilder->skipMode() && m_attrName == srcAttr) {
-                            String context(m_rawAttributeBeforeValue.data(), m_rawAttributeBeforeValue.size());
-                            if (xssAuditor() && !xssAuditor()->canLoadExternalScriptFromSrc(attributeValue))
-                                attributeValue = blankURL().string();
-                        }
-
-                        m_currentToken.addAttribute(m_attrName, attributeValue, inViewSourceMode());
-                        m_dest = m_buffer;
-                        state.setTagState(SearchAttribute);
-                        tquote = NoQuote;
-                        if (inViewSourceMode())
-                            m_currentToken.addViewSourceChar(curchar);
-                        src.advancePastNonNewline();
-                        break;
-                    }
-                }
-
-                *m_dest++ = curchar;
-                src.advance(m_lineNumber);
-            }
-            break;
-        case Value:
-            while (!src.isEmpty()) {
-                checkBuffer();
-                UChar curchar = *src;
-                if (curchar <= '>' && !src.escaped()) {
-                    // parse Entities
-                    if (curchar == '&') {
-                        src.advancePastNonNewline();
-                        state = parseEntity(src, m_dest, state, cBufferPos, true, true);
-                        break;
-                    }
-                    // no quotes. Every space means end of value
-                    // '/' does not delimit in IE!
-                    if (isASCIISpace(curchar) || curchar == '>') {
-                        AtomicString attributeValue(m_buffer + 1, m_dest - m_buffer - 1);
-
-                        if (m_currentToken.beginTag && m_currentToken.tagName == scriptTag && !inViewSourceMode() && !m_treeBuilder->skipMode() && m_attrName == srcAttr) {
-                            String context(m_rawAttributeBeforeValue.data(), m_rawAttributeBeforeValue.size());
-                            if (xssAuditor() && !xssAuditor()->canLoadExternalScriptFromSrc(attributeValue))
-                                attributeValue = blankURL().string();
-                        }
-
-                        m_currentToken.addAttribute(m_attrName, attributeValue, inViewSourceMode());
-                        if (inViewSourceMode())
-                            m_currentToken.addViewSourceChar('v');
-                        m_dest = m_buffer;
-                        state.setTagState(SearchAttribute);
-                        break;
-                    }
-                }
-
-                *m_dest++ = curchar;
-                src.advance(m_lineNumber);
-            }
-            break;
-        case SearchEnd:
-        {
-            while (!src.isEmpty()) {
-                UChar ch = *src;
-                if (ch == '>' || ch == '<')
-                    break;
-                if (ch == '/')
-                    m_currentToken.selfClosingTag = true;
-                if (inViewSourceMode())
-                    m_currentToken.addViewSourceChar(ch);
-                src.advance(m_lineNumber);
-            }
-            if (src.isEmpty())
-                break;
-
-            searchCount = 0; // Stop looking for '<!--' sequence
-            state.setTagState(NoTag);
-            tquote = NoQuote;
-
-            if (*src != '<')
-                src.advance(m_lineNumber);
-
-            if (m_currentToken.tagName == nullAtom) { //stop if tag is unknown
-                m_cBufferPos = cBufferPos;
-                return state;
-            }
-
-            AtomicString tagName = m_currentToken.tagName;
-
-            // Handle <script src="foo"/> like Mozilla/Opera. We have to do this now for Dashboard
-            // compatibility.
-            bool isSelfClosingScript = m_currentToken.selfClosingTag && m_currentToken.beginTag && m_currentToken.tagName == scriptTag;
-            bool beginTag = !m_currentToken.selfClosingTag && m_currentToken.beginTag;
-            if (m_currentToken.beginTag && m_currentToken.tagName == scriptTag && !inViewSourceMode() && !m_treeBuilder->skipMode()) {
-                Attribute* a = 0;
-                m_scriptTagSrcAttrValue = String();
-                m_scriptTagCharsetAttrValue = String();
-                if (m_currentToken.attrs && !m_fragment) {
-                    if (document()->frame() && document()->frame()->script()->canExecuteScripts(NotAboutToExecuteScript)) {
-                        if ((a = m_currentToken.attrs->getAttributeItem(srcAttr)))
-                            m_scriptTagSrcAttrValue = document()->completeURL(deprecatedParseURL(a->value())).string();
-                    }
-                }
-            }
-
-            RefPtr<Node> n = processToken();
-            m_cBufferPos = cBufferPos;
-            if (n || inViewSourceMode()) {
-                State savedState = state;
-                SegmentedString savedSrc = src;
-                long savedLineno = m_lineNumber;
-                if ((tagName == preTag || tagName == listingTag) && !inViewSourceMode()) {
-                    if (beginTag)
-                        state.setDiscardLF(true); // Discard the first LF after we open a pre.
-                } else if (tagName == scriptTag) {
-                    ASSERT(!m_scriptNode);
-                    m_scriptNode = static_pointer_cast<HTMLScriptElement>(n);
-                    if (m_scriptNode)
-                        m_scriptTagCharsetAttrValue = m_scriptNode->scriptCharset();
-                    if (beginTag) {
-                        m_searchStopper = scriptEnd;
-                        m_searchStopperLength = 8;
-                        state.setInScript(true);
-                        state = parseNonHTMLText(src, state);
-                    } else if (isSelfClosingScript) { // Handle <script src="foo"/>
-                        state.setInScript(true);
-                        state = scriptHandler(state);
-                    }
-                } else if (tagName == styleTag) {
-                    if (beginTag) {
-                        m_searchStopper = styleEnd;
-                        m_searchStopperLength = 7;
-                        state.setInStyle(true);
-                        state = parseNonHTMLText(src, state);
-                    }
-                } else if (tagName == textareaTag) {
-                    if (beginTag) {
-                        m_searchStopper = textareaEnd;
-                        m_searchStopperLength = 10;
-                        state.setInTextArea(true);
-                        state = parseNonHTMLText(src, state);
-                    }
-                } else if (tagName == titleTag) {
-                    if (beginTag) {
-                        m_searchStopper = titleEnd;
-                        m_searchStopperLength = 7;
-                        state.setInTitle(true);
-                        state = parseNonHTMLText(src, state);
-                    }
-                } else if (tagName == xmpTag) {
-                    if (beginTag) {
-                        m_searchStopper = xmpEnd;
-                        m_searchStopperLength = 5;
-                        state.setInXmp(true);
-                        state = parseNonHTMLText(src, state);
-                    }
-                } else if (tagName == iframeTag) {
-                    if (beginTag) {
-                        m_searchStopper = iframeEnd;
-                        m_searchStopperLength = 8;
-                        state.setInIFrame(true);
-                        state = parseNonHTMLText(src, state);
-                    }
-                }
-                if (src.isEmpty() && (state.inTitle() || inViewSourceMode()) && !state.inComment() && !(state.inScript() && m_currentScriptTagStartLineNumber)) {
-                    // We just ate the rest of the document as the #text node under the special tag!
-                    // Reset the state then retokenize without special handling.
-                    // Let the parser clean up the missing close tag.
-                    // FIXME: This is incorrect, because src.isEmpty() doesn't mean we're
-                    // at the end of the document unless m_noMoreData is also true. We need
-                    // to detect this case elsewhere, and save the state somewhere other
-                    // than a local variable.
-                    state = savedState;
-                    src = savedSrc;
-                    m_lineNumber = savedLineno;
-                    m_scriptCodeSize = 0;
-                }
-            }
-            if (tagName == plaintextTag)
-                state.setInPlainText(beginTag);
-            return state; // Finished parsing tag!
-        }
-        } // end switch
-    }
-    m_cBufferPos = cBufferPos;
-    return state;
-}
-
-inline bool LegacyHTMLDocumentParser::continueProcessing(int& processedCount, double startTime, State &state)
-{
-    // We don't want to be checking elapsed time with every character, so we only check after we've
-    // processed a certain number of characters.
-    bool allowedYield = state.allowYield();
-    state.setAllowYield(false);
-    if (!state.loadingExtScript() && !state.forceSynchronous() && !m_executingScript && (processedCount > m_tokenizerChunkSize || allowedYield)) {
-        processedCount = 0;
-        if (currentTime() - startTime > m_tokenizerTimeDelay) {
-            /* FIXME: We'd like to yield aggressively to give stylesheets the opportunity to
-               load, but this hurts overall performance on slower machines.  For now turn this
-               off.
-            || (!document()->haveStylesheetsLoaded() &&
-                (document()->documentElement()->id() != ID_HTML || document()->body()))) {*/
-            // Schedule the timer to keep processing as soon as possible.
-            m_timer.startOneShot(0);
-            return false;
-        }
-    }
-
-    processedCount++;
-    return true;
-}
-
-// Turns the statemachine one crank using the passed in State object.
-// This does not modify m_state directly in order to be reentrant.
-ALWAYS_INLINE void LegacyHTMLDocumentParser::advance(State& state)
-{
-    // do we need to enlarge the buffer?
-    checkBuffer();
-
-    UChar cc = *m_src;
-
-    bool wasSkipLF = state.skipLF();
-    if (wasSkipLF)
-        state.setSkipLF(false);
-
-    if (wasSkipLF && (cc == '\n'))
-        m_src.advance();
-    else if (state.needsSpecialWriteHandling()) {
-        // it's important to keep needsSpecialWriteHandling with the flags this block tests
-        if (state.hasEntityState())
-            state = parseEntity(m_src, m_dest, state, m_cBufferPos, false, state.hasTagState());
-        else if (state.inPlainText())
-            state = parseText(m_src, state);
-        else if (state.inAnyNonHTMLText())
-            state = parseNonHTMLText(m_src, state);
-        else if (state.inComment())
-            state = parseComment(m_src, state);
-        else if (state.inDoctype())
-            state = parseDoctype(m_src, state);
-        else if (state.inServer())
-            state = parseServer(m_src, state);
-        else if (state.inProcessingInstruction())
-            state = parseProcessingInstruction(m_src, state);
-        else if (state.hasTagState())
-            state = parseTag(m_src, state);
-        else if (state.startTag()) {
-            state.setStartTag(false);
-
-            switch (cc) {
-            case '/':
-                break;
-            case '!': {
-                // <!-- comment --> or <!DOCTYPE ...>
-                searchCount = 1; // Look for '<!--' sequence to start comment or '<!DOCTYPE' sequence to start doctype
-                m_doctypeSearchCount = 1;
-                break;
-            }
-            case '?': {
-                // xml processing instruction
-                state.setInProcessingInstruction(true);
-                tquote = NoQuote;
-                state = parseProcessingInstruction(m_src, state);
-                return;
-            }
-            case '%':
-                if (!m_brokenServer) {
-                    // <% server stuff, handle as comment %>
-                    state.setInServer(true);
-                    tquote = NoQuote;
-                    state = parseServer(m_src, state);
-                    return;
-                }
-                // else fall through
-            default: {
-                if (((cc >= 'a') && (cc <= 'z')) || ((cc >= 'A') && (cc <= 'Z'))) {
-                    // Start of a Start-Tag
-                } else {
-                    // Invalid tag
-                    // Add as is
-                    *m_dest = '<';
-                    m_dest++;
-                    return;
-                }
-            }
-            }; // end case
-
-            processToken();
-
-            m_cBufferPos = 0;
-            state.setTagState(TagName);
-            state = parseTag(m_src, state);
-        }
-    } else if (cc == '&' && !m_src.escaped()) {
-        m_src.advancePastNonNewline();
-        state = parseEntity(m_src, m_dest, state, m_cBufferPos, true, state.hasTagState());
-    } else if (cc == '<' && !m_src.escaped()) {
-        m_currentTagStartLineNumber = m_lineNumber;
-        m_src.advancePastNonNewline();
-        state.setStartTag(true);
-        state.setDiscardLF(false);
-    } else if (cc == '\n' || cc == '\r') {
-        if (state.discardLF())
-            // Ignore this LF
-            state.setDiscardLF(false); // We have discarded 1 LF
-        else {
-            // Process this LF
-            *m_dest++ = '\n';
-            if (cc == '\r' && !m_src.excludeLineNumbers())
-                m_lineNumber++;
-        }
-
-        /* Check for MS-DOS CRLF sequence */
-        if (cc == '\r')
-            state.setSkipLF(true);
-        m_src.advance(m_lineNumber);
-    } else {
-        state.setDiscardLF(false);
-        *m_dest++ = cc;
-        m_src.advancePastNonNewline();
-    }
-}
-
-void LegacyHTMLDocumentParser::willWriteHTML(const SegmentedString& source)
-{
-    #if ENABLE(INSPECTOR)
-        if (InspectorTimelineAgent* timelineAgent = document()->inspectorTimelineAgent())
-            timelineAgent->willWriteHTML(source.length(), m_lineNumber);
-    #endif
-}
-
-void LegacyHTMLDocumentParser::didWriteHTML()
-{
-    #if ENABLE(INSPECTOR)
-        if (InspectorTimelineAgent* timelineAgent = document()->inspectorTimelineAgent())
-            timelineAgent->didWriteHTML(m_lineNumber);
-    #endif
-}
-
-void LegacyHTMLDocumentParser::write(const SegmentedString& str, bool appendData)
-{
-    if (!m_buffer)
-        return;
-
-    if (m_parserStopped)
-        return;
-
-    SegmentedString source(str);
-    if (m_executingScript)
-        source.setExcludeLineNumbers();
-
-    if ((m_executingScript && appendData) || !m_pendingScripts.isEmpty()) {
-        // don't parse; we will do this later
-        if (m_currentPrependingSrc)
-            m_currentPrependingSrc->append(source);
-        else {
-            m_pendingSrc.append(source);
-#if PRELOAD_SCANNER_ENABLED
-            if (m_preloadScanner && m_preloadScanner->inProgress() && appendData)
-                m_preloadScanner->write(source);
-#endif
-        }
-        return;
-    }
-
-#if PRELOAD_SCANNER_ENABLED
-    if (m_preloadScanner && m_preloadScanner->inProgress() && appendData)
-        m_preloadScanner->end();
-#endif
-
-    if (!m_src.isEmpty())
-        m_src.append(source);
-    else
-        setSrc(source);
-
-    // Once a timer is set, it has control of when the parser continues.
-    if (m_timer.isActive())
-        return;
-
-    bool wasInWrite = m_inWrite;
-    m_inWrite = true;
-
-    willWriteHTML(source);
-
-    Frame* frame = document()->frame();
-    State state = m_state;
-    int processedCount = 0;
-    double startTime = currentTime();
-
-    while (!m_src.isEmpty() && (!frame || !frame->redirectScheduler()->locationChangePending())) {
-        if (!continueProcessing(processedCount, startTime, state))
-            break;
-        advance(state);
-    }
-
-    didWriteHTML();
-
-    m_inWrite = wasInWrite;
-    m_state = state;
-
-    if (m_noMoreData && !m_inWrite && !state.loadingExtScript() && !m_executingScript && !m_timer.isActive())
-        end(); // this actually causes us to be deleted
-
-    // After parsing, go ahead and dispatch image beforeload events, but only if we're doing
-    // document parsing.  For document fragments we wait, since they'll likely end up in the document by the time
-    // the beforeload events fire.
-    if (!m_fragment)
-        ImageLoader::dispatchPendingBeforeLoadEvents();
-}
-
-void LegacyHTMLDocumentParser::insert(const SegmentedString& source)
-{
-    // FIXME: forceSynchronous should always be the same as the bool passed to
-    // write().  However LegacyHTMLDocumentParser uses write("", false) to pump
-    // the parser (after running external scripts, etc.) thus necessitating a
-    // separate state for forceSynchronous.
-    bool wasForcedSynchronous = forceSynchronous();
-    setForceSynchronous(true);
-    write(source, false);
-    setForceSynchronous(wasForcedSynchronous);
-}
-
-void LegacyHTMLDocumentParser::append(const SegmentedString& source)
-{
-    write(source, true);
-}
-
-void LegacyHTMLDocumentParser::stopParsing()
-{
-    DocumentParser::stopParsing();
-    m_timer.stop();
-
-    // FIXME: Why is LegacyHTMLDocumentParser the only DocumentParser which calls checkCompleted?
-    // The FrameLoader needs to know that the parser has finished with its data,
-    // regardless of whether it happened naturally or due to manual intervention.
-    if (!m_fragment && document()->frame())
-        document()->frame()->loader()->checkCompleted();
-}
-
-bool LegacyHTMLDocumentParser::processingData() const
-{
-    return m_timer.isActive() || m_inWrite;
-}
-
-void LegacyHTMLDocumentParser::timerFired(Timer<LegacyHTMLDocumentParser>*)
-{
-    if (document()->view() && document()->view()->layoutPending() && !document()->minimumLayoutDelay()) {
-        // Restart the timer and let layout win.  This is basically a way of ensuring that the layout
-        // timer has higher priority than our timer.
-        m_timer.startOneShot(0);
-        return;
-    }
-
-    // Invoke write() as though more data came in. This might cause us to get deleted.
-    write(SegmentedString(), true);
-}
-
-void LegacyHTMLDocumentParser::end()
-{
-    ASSERT(!m_timer.isActive());
-    m_timer.stop(); // Only helps if assertion above fires, but do it anyway.
-
-    if (m_buffer) {
-        // parseTag is using the buffer for different matters
-        if (!m_state.hasTagState())
-            processToken();
-
-        fastFree(m_scriptCode);
-        m_scriptCode = 0;
-        m_scriptCodeSize = m_scriptCodeCapacity = m_scriptCodeResync = 0;
-
-        fastFree(m_buffer);
-        m_buffer = 0;
-    }
-
-    if (!inViewSourceMode())
-        m_treeBuilder->finished();
-    else
-        document()->finishedParsing();
-}
-
-void LegacyHTMLDocumentParser::finish()
-{
-    // do this as long as we don't find matching comment ends
-    while ((m_state.inComment() || m_state.inServer()) && m_scriptCode && m_scriptCodeSize) {
-        // we've found an unmatched comment start
-        if (m_state.inComment())
-            m_brokenComments = true;
-        else
-            m_brokenServer = true;
-        checkScriptBuffer();
-        m_scriptCode[m_scriptCodeSize] = 0;
-        m_scriptCode[m_scriptCodeSize + 1] = 0;
-        int pos;
-        String food;
-        if (m_state.inScript() || m_state.inStyle() || m_state.inTextArea())
-            food = String(m_scriptCode, m_scriptCodeSize);
-        else if (m_state.inServer()) {
-            food = "<";
-            food.append(m_scriptCode, m_scriptCodeSize);
-        } else {
-            pos = find(m_scriptCode, m_scriptCodeSize, '>');
-            food = String(m_scriptCode + pos + 1, m_scriptCodeSize - pos - 1);
-        }
-        fastFree(m_scriptCode);
-        m_scriptCode = 0;
-        m_scriptCodeSize = m_scriptCodeCapacity = m_scriptCodeResync = 0;
-        m_state.setInComment(false);
-        m_state.setInServer(false);
-        if (!food.isEmpty())
-            write(food, true);
-    }
-    // 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
-    m_noMoreData = true;
-    if (!m_inWrite && !m_state.loadingExtScript() && !m_executingScript && !m_timer.isActive())
-        end(); // this actually causes us to be deleted
-}
-
-bool LegacyHTMLDocumentParser::finishWasCalled()
-{
-    return m_noMoreData;
-}
-
-PassRefPtr<Node> LegacyHTMLDocumentParser::processToken()
-{
-    if (m_dest > m_buffer) {
-        m_currentToken.text = StringImpl::createStrippingNullCharacters(m_buffer, m_dest - m_buffer);
-        if (m_currentToken.tagName != commentAtom)
-            m_currentToken.tagName = textAtom;
-    } else if (m_currentToken.tagName == nullAtom) {
-        m_currentToken.reset();
-        return 0;
-    }
-
-    m_dest = m_buffer;
-
-    RefPtr<Node> n;
-
-    if (!m_parserStopped) {
-        if (NamedNodeMap* map = m_currentToken.attrs.get())
-            map->shrinkToLength();
-        // pass the token over to the parser, the parser DOES NOT delete the token
-        n = m_treeBuilder->parseToken(&m_currentToken);
-    }
-    m_currentToken.reset();
-
-    return n.release();
-}
-
-void LegacyHTMLDocumentParser::processDoctypeToken()
-{
-    m_treeBuilder->parseDoctypeToken(&m_doctypeToken);
-}
-
-LegacyHTMLDocumentParser::~LegacyHTMLDocumentParser()
-{
-    ASSERT(!m_inWrite);
-    reset();
-}
-
-
-void LegacyHTMLDocumentParser::enlargeBuffer(int len)
-{
-    // Resize policy: Always at least double the size of the buffer each time.
-    int delta = max(len, m_bufferSize);
-
-    // Check for overflow.
-    // For now, handle overflow the same way we handle fastRealloc failure, with CRASH.
-    static const int maxSize = INT_MAX / sizeof(UChar);
-    if (delta > maxSize - m_bufferSize)
-        CRASH();
-
-    int newSize = m_bufferSize + delta;
-    int oldOffset = m_dest - m_buffer;
-    m_buffer = static_cast<UChar*>(fastRealloc(m_buffer, newSize * sizeof(UChar)));
-    m_dest = m_buffer + oldOffset;
-    m_bufferSize = newSize;
-}
-
-void LegacyHTMLDocumentParser::enlargeScriptBuffer(int len)
-{
-    // Resize policy: Always at least double the size of the buffer each time.
-    int delta = max(len, m_scriptCodeCapacity);
-
-    // Check for overflow.
-    // For now, handle overflow the same way we handle fastRealloc failure, with CRASH.
-    static const int maxSize = INT_MAX / sizeof(UChar);
-    if (delta > maxSize - m_scriptCodeCapacity)
-        CRASH();
-
-    int newSize = m_scriptCodeCapacity + delta;
-    // If we allow fastRealloc(ptr, 0), it will call CRASH(). We run into this
-    // case if the HTML being parsed begins with "<!--" and there's more data
-    // coming.
-    if (!newSize) {
-        ASSERT(!m_scriptCode);
-        return;
-    }
-
-    m_scriptCode = static_cast<UChar*>(fastRealloc(m_scriptCode, newSize * sizeof(UChar)));
-    m_scriptCodeCapacity = newSize;
-}
-
-void LegacyHTMLDocumentParser::executeScriptsWaitingForStylesheets()
-{
-    ASSERT(document()->haveStylesheetsLoaded());
-
-    if (m_hasScriptsWaitingForStylesheets)
-        notifyFinished(0);
-}
-
-void LegacyHTMLDocumentParser::notifyFinished(CachedResource*)
-{
-    executeExternalScriptsIfReady();
-}
-
-void LegacyHTMLDocumentParser::executeExternalScriptsIfReady()
-{
-    ASSERT(!m_pendingScripts.isEmpty());
-
-    // Make external scripts wait for external stylesheets.
-    // FIXME: This needs to be done for inline scripts too.
-    m_hasScriptsWaitingForStylesheets = !document()->haveStylesheetsLoaded();
-    if (m_hasScriptsWaitingForStylesheets)
-        return;
-
-    bool finished = false;
-
-    double startTime = currentTime();
-    while (!finished && m_pendingScripts.first()->isLoaded()) {
-        if (!continueExecutingExternalScripts(startTime))
-            break;
-
-        CachedResourceHandle<CachedScript> cs = m_pendingScripts.takeFirst();
-        ASSERT(cache()->disabled() || cs->accessCount() > 0);
-
-        setSrc(SegmentedString());
-
-        // make sure we forget about the script before we execute the new one
-        // infinite recursion might happen otherwise
-        ScriptSourceCode sourceCode(cs.get());
-        bool errorOccurred = cs->errorOccurred();
-        cs->removeClient(this);
-
-        RefPtr<Node> n = m_scriptNode.release();
-
-        if (errorOccurred)
-            n->dispatchEvent(Event::create(eventNames().errorEvent, true, false));
-        else {
-            if (static_cast<HTMLScriptElement*>(n.get())->shouldExecuteAsJavaScript())
-                m_state = scriptExecution(sourceCode, m_state);
-#if ENABLE(XHTMLMP)
-            else
-                document()->setShouldProcessNoscriptElement(true);
-#endif
-            n->dispatchEvent(Event::create(eventNames().loadEvent, false, false));
-        }
-
-        // The state of m_pendingScripts.isEmpty() can change inside the scriptExecution()
-        // call above, so test afterwards.
-        finished = m_pendingScripts.isEmpty();
-        if (finished) {
-            ASSERT(!m_hasScriptsWaitingForStylesheets);
-            m_state.setLoadingExtScript(false);
-        } else if (m_hasScriptsWaitingForStylesheets) {
-            // m_hasScriptsWaitingForStylesheets flag might have changed during the script execution.
-            // If it did we are now blocked waiting for stylesheets and should not execute more scripts until they arrive.
-            finished = true;
-        }
-
-        // 'm_requestingScript' is true when we are called synchronously from
-        // scriptHandler(). In that case scriptHandler() will take care
-        // of m_pendingSrc.
-        if (!m_requestingScript) {
-            SegmentedString rest = m_pendingSrc;
-            m_pendingSrc.clear();
-            write(rest, false);
-            // we might be deleted at this point, do not access any members.
-        }
-    }
-}
-
-void LegacyHTMLDocumentParser::executeExternalScriptsTimerFired(Timer<LegacyHTMLDocumentParser>*)
-{
-    if (document()->view() && document()->view()->layoutPending() && !document()->minimumLayoutDelay()) {
-        // Restart the timer and do layout first.
-        m_externalScriptsTimer.startOneShot(0);
-        return;
-    }
-
-    // Continue executing external scripts.
-    executeExternalScriptsIfReady();
-}
-
-bool LegacyHTMLDocumentParser::continueExecutingExternalScripts(double startTime)
-{
-    if (m_externalScriptsTimer.isActive())
-        return false;
-
-    if (currentTime() - startTime > m_tokenizerTimeDelay) {
-        // Schedule the timer to keep processing as soon as possible.
-        m_externalScriptsTimer.startOneShot(0);
-        return false;
-    }
-    return true;
-}
-
-bool LegacyHTMLDocumentParser::isWaitingForScripts() const
-{
-    return m_state.loadingExtScript();
-}
-
-void LegacyHTMLDocumentParser::setSrc(const SegmentedString& source)
-{
-    m_src = source;
-}
-
-void LegacyHTMLDocumentParser::parseDocumentFragment(const String& source, DocumentFragment* fragment, FragmentScriptingPermission scriptingPermission)
-{
-    LegacyHTMLDocumentParser parser(fragment, scriptingPermission);
-    parser.setForceSynchronous(true);
-    parser.write(source, true);
-    parser.finish();
-    ASSERT(!parser.processingData()); // make sure we're done (see 3963151)
-}
-
-UChar decodeNamedEntity(const char* name)
-{
-    const Entity* e = findEntity(name, strlen(name));
-    return e ? e->code : 0;
-}
-
-}
diff --git a/WebCore/html/LegacyHTMLDocumentParser.h b/WebCore/html/LegacyHTMLDocumentParser.h
deleted file mode 100644
index 49e6976..0000000
--- a/WebCore/html/LegacyHTMLDocumentParser.h
+++ /dev/null
@@ -1,452 +0,0 @@
-/*
-    Copyright (C) 1997 Martin Jones (mjones at kde.org)
-              (C) 1997 Torben Weis (weis at kde.org)
-              (C) 1998 Waldo Bastian (bastian at kde.org)
-              (C) 2001 Dirk Mueller (mueller at kde.org)
-    Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
-
-    This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Library General Public
-    License as published by the Free Software Foundation; either
-    version 2 of the License, or (at your option) any later version.
-
-    This library is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-    Library General Public License for more details.
-
-    You should have received a copy of the GNU Library General Public License
-    along with this library; see the file COPYING.LIB.  If not, write to
-    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-    Boston, MA 02110-1301, USA.
-*/
-
-#ifndef LegacyHTMLDocumentParser_h
-#define LegacyHTMLDocumentParser_h
-
-#include "CachedResourceClient.h"
-#include "CachedResourceHandle.h"
-#include "FragmentScriptingPermission.h"
-#include "NamedNodeMap.h"
-#include "ScriptableDocumentParser.h"
-#include "SegmentedString.h"
-#include "Timer.h"
-#include <wtf/Deque.h>
-#include <wtf/OwnPtr.h>
-#include <wtf/Vector.h>
-
-namespace WebCore {
-
-class CachedScript;
-class DocumentFragment;
-class Document;
-class HTMLDocument;
-class HTMLScriptElement;
-class HTMLViewSourceDocument;
-class FrameView;
-class LegacyHTMLTreeBuilder;
-class Node;
-class LegacyPreloadScanner;
-class ScriptSourceCode;
-
-/**
- * @internal
- * represents one HTML tag. Consists of a numerical id, and the list
- * of attributes. Can also represent text. In this case the id = 0 and
- * text contains the text.
- */
-struct Token {
-    Token()
-        : beginTag(true)
-        , selfClosingTag(false)
-        , brokenXMLStyle(false)
-        , m_sourceInfo(0)
-    { }
-    ~Token() { }
-
-    void addAttribute(AtomicString& attrName, const AtomicString& v, bool viewSourceMode);
-
-    bool isOpenTag(const QualifiedName& fullName) const { return beginTag && fullName.localName() == tagName; }
-    bool isCloseTag(const QualifiedName& fullName) const { return !beginTag && fullName.localName() == tagName; }
-
-    void reset()
-    {
-        attrs = 0;
-        text = 0;
-        tagName = nullAtom;
-        beginTag = true;
-        selfClosingTag = false;
-        brokenXMLStyle = false;
-        if (m_sourceInfo)
-            m_sourceInfo->clear();
-    }
-
-    void addViewSourceChar(UChar c) { if (!m_sourceInfo.get()) m_sourceInfo.set(new Vector<UChar>); m_sourceInfo->append(c); }
-
-    RefPtr<NamedNodeMap> attrs;
-    RefPtr<StringImpl> text;
-    AtomicString tagName;
-    bool beginTag;
-    bool selfClosingTag;
-    bool brokenXMLStyle;
-    OwnPtr<Vector<UChar> > m_sourceInfo;
-};
-
-enum DoctypeState {
-    DoctypeBegin,
-    DoctypeBeforeName,
-    DoctypeName,
-    DoctypeAfterName,
-    DoctypeBeforePublicID,
-    DoctypePublicID,
-    DoctypeAfterPublicID,
-    DoctypeBeforeSystemID,
-    DoctypeSystemID,
-    DoctypeAfterSystemID,
-    DoctypeBogus
-};
-
-class DoctypeToken {
-public:
-    DoctypeToken() {}
-
-    void reset()
-    {
-        m_name.clear();
-        m_publicID.clear();
-        m_systemID.clear();
-        m_state = DoctypeBegin;
-        m_source.clear();
-        m_forceQuirks = false;
-    }
-
-    DoctypeState state() { return m_state; }
-    void setState(DoctypeState s) { m_state = s; }
-
-    Vector<UChar> m_name;
-    Vector<UChar> m_publicID;
-    Vector<UChar> m_systemID;
-    DoctypeState m_state;
-
-    Vector<UChar> m_source;
-
-    bool m_forceQuirks; // Used by the HTML5 parser.
-};
-
-//-----------------------------------------------------------------------------
-
-// FIXME: This class does too much.  Right now it is both an HTML tokenizer as well
-// as handling all of the non-tokenizer-specific junk related to tokenizing HTML
-// (like dealing with <script> tags).  The HTML tokenizer bits should be pushed
-// down into a separate HTML tokenizer class.
-
-class LegacyHTMLDocumentParser : public ScriptableDocumentParser, public CachedResourceClient {
-public:
-    LegacyHTMLDocumentParser(HTMLDocument*, bool reportErrors);
-    LegacyHTMLDocumentParser(HTMLViewSourceDocument*);
-    LegacyHTMLDocumentParser(DocumentFragment*, FragmentScriptingPermission = FragmentScriptingAllowed);
-    virtual ~LegacyHTMLDocumentParser();
-
-    bool forceSynchronous() const { return m_state.forceSynchronous(); }
-    void setForceSynchronous(bool force);
-
-    static void parseDocumentFragment(const String&, DocumentFragment*, FragmentScriptingPermission = FragmentScriptingAllowed);
-
-protected:
-    // Exposed for FTPDirectoryDocumentParser
-    virtual void insert(const SegmentedString&);
-    virtual void finish();
-
-private:
-    // ScriptableDocumentParser
-    virtual void append(const SegmentedString&);
-    virtual bool finishWasCalled();
-    virtual bool isWaitingForScripts() const;
-    virtual void stopParsing();
-    virtual bool processingData() const;
-    virtual bool isExecutingScript() const { return !!m_executingScript; }
-
-    virtual int lineNumber() const { return m_lineNumber; }
-    virtual int columnNumber() const { return 1; }
-
-    virtual bool processingContentWrittenByScript() const { return m_src.excludeLineNumbers(); }
-
-    virtual void executeScriptsWaitingForStylesheets();
-
-    virtual LegacyHTMLTreeBuilder* htmlTreeBuilder() const { return m_treeBuilder.get(); }
-
-    class State;
-
-    void begin();
-    void end();
-    void reset();
-
-    void willWriteHTML(const SegmentedString&);
-    void write(const SegmentedString&, bool appendData);
-    ALWAYS_INLINE void advance(State&);
-    void didWriteHTML();
-
-    PassRefPtr<Node> processToken();
-    void processDoctypeToken();
-
-    State processListing(SegmentedString, State);
-    State parseComment(SegmentedString&, State);
-    State parseDoctype(SegmentedString&, State);
-    State parseServer(SegmentedString&, State);
-    State parseText(SegmentedString&, State);
-    State parseNonHTMLText(SegmentedString&, State);
-    State parseTag(SegmentedString&, State);
-    State parseEntity(SegmentedString&, UChar*& dest, State, unsigned& cBufferPos, bool start, bool parsingTag);
-    State parseProcessingInstruction(SegmentedString&, State);
-    State scriptHandler(State);
-    State scriptExecution(const ScriptSourceCode&, State);
-    void setSrc(const SegmentedString&);
-
-    // check if we have enough space in the buffer.
-    // if not enlarge it
-    inline void checkBuffer(int len = 10)
-    {
-        if ((m_dest - m_buffer) > m_bufferSize - len)
-            enlargeBuffer(len);
-    }
-
-    inline void checkScriptBuffer(int len = 10)
-    {
-        if (m_scriptCodeSize + len >= m_scriptCodeCapacity)
-            enlargeScriptBuffer(len);
-    }
-
-    void enlargeBuffer(int len);
-    void enlargeScriptBuffer(int len);
-
-    bool continueProcessing(int& processedCount, double startTime, State&);
-    void timerFired(Timer<LegacyHTMLDocumentParser>*);
-    void allDataProcessed();
-
-    // from CachedResourceClient
-    void notifyFinished(CachedResource*);
-
-    void executeExternalScriptsIfReady();
-    void executeExternalScriptsTimerFired(Timer<LegacyHTMLDocumentParser>*);
-    bool continueExecutingExternalScripts(double startTime);
-
-    // Internal buffers
-    ///////////////////
-    UChar* m_buffer;
-    int m_bufferSize;
-    UChar* m_dest;
-
-    Token m_currentToken;
-
-    // This buffer holds the raw characters we've seen between the beginning of
-    // the attribute name and the first character of the attribute value.
-    Vector<UChar, 32> m_rawAttributeBeforeValue;
-
-    // DocumentParser flags
-    //////////////////
-    // are we in quotes within a html tag
-    enum { NoQuote, SingleQuote, DoubleQuote } tquote;
-
-    // Are we in a &... character entity description?
-    enum EntityState {
-        NoEntity = 0,
-        SearchEntity = 1,
-        NumericSearch = 2,
-        Hexadecimal = 3,
-        Decimal = 4,
-        EntityName = 5,
-        SearchSemicolon = 6
-    };
-    unsigned EntityUnicodeValue;
-
-    enum TagState {
-        NoTag = 0,
-        TagName = 1,
-        SearchAttribute = 2,
-        AttributeName = 3,
-        SearchEqual = 4,
-        SearchValue = 5,
-        QuotedValue = 6,
-        Value = 7,
-        SearchEnd = 8
-    };
-
-    class State {
-    public:
-        State() : m_bits(0) { }
-
-        TagState tagState() const { return static_cast<TagState>(m_bits & TagMask); }
-        void setTagState(TagState t) { m_bits = (m_bits & ~TagMask) | t; }
-        EntityState entityState() const { return static_cast<EntityState>((m_bits & EntityMask) >> EntityShift); }
-        void setEntityState(EntityState e) { m_bits = (m_bits & ~EntityMask) | (e << EntityShift); }
-
-        bool inScript() const { return testBit(InScript); }
-        void setInScript(bool v) { setBit(InScript, v); }
-        bool inStyle() const { return testBit(InStyle); }
-        void setInStyle(bool v) { setBit(InStyle, v); }
-        bool inXmp() const { return testBit(InXmp); }
-        void setInXmp(bool v) { setBit(InXmp, v); }
-        bool inTitle() const { return testBit(InTitle); }
-        void setInTitle(bool v) { setBit(InTitle, v); }
-        bool inIFrame() const { return testBit(InIFrame); }
-        void setInIFrame(bool v) { setBit(InIFrame, v); }
-        bool inPlainText() const { return testBit(InPlainText); }
-        void setInPlainText(bool v) { setBit(InPlainText, v); }
-        bool inProcessingInstruction() const { return testBit(InProcessingInstruction); }
-        void setInProcessingInstruction(bool v) { return setBit(InProcessingInstruction, v); }
-        bool inComment() const { return testBit(InComment); }
-        void setInComment(bool v) { setBit(InComment, v); }
-        bool inDoctype() const { return testBit(InDoctype); }
-        void setInDoctype(bool v) { setBit(InDoctype, v); }
-        bool inTextArea() const { return testBit(InTextArea); }
-        void setInTextArea(bool v) { setBit(InTextArea, v); }
-        bool escaped() const { return testBit(Escaped); }
-        void setEscaped(bool v) { setBit(Escaped, v); }
-        bool inServer() const { return testBit(InServer); }
-        void setInServer(bool v) { setBit(InServer, v); }
-        bool skipLF() const { return testBit(SkipLF); }
-        void setSkipLF(bool v) { setBit(SkipLF, v); }
-        bool startTag() const { return testBit(StartTag); }
-        void setStartTag(bool v) { setBit(StartTag, v); }
-        bool discardLF() const { return testBit(DiscardLF); }
-        void setDiscardLF(bool v) { setBit(DiscardLF, v); }
-        bool allowYield() const { return testBit(AllowYield); }
-        void setAllowYield(bool v) { setBit(AllowYield, v); }
-        bool loadingExtScript() const { return testBit(LoadingExtScript); }
-        void setLoadingExtScript(bool v) { setBit(LoadingExtScript, v); }
-        bool forceSynchronous() const { return testBit(ForceSynchronous); }
-        void setForceSynchronous(bool v) { setBit(ForceSynchronous, v); }
-
-        bool inAnyNonHTMLText() const { return m_bits & (InScript | InStyle | InXmp | InTextArea | InTitle | InIFrame); }
-        bool hasTagState() const { return m_bits & TagMask; }
-        bool hasEntityState() const { return m_bits & EntityMask; }
-
-        bool needsSpecialWriteHandling() const { return m_bits & (InScript | InStyle | InXmp | InTextArea | InTitle | InIFrame | TagMask | EntityMask | InPlainText | InComment | InDoctype | InServer | InProcessingInstruction | StartTag); }
-
-    private:
-        static const int EntityShift = 4;
-        enum StateBits {
-            TagMask = (1 << 4) - 1,
-            EntityMask = (1 << 7) - (1 << 4),
-            InScript = 1 << 7,
-            InStyle = 1 << 8,
-            // Bit 9 unused
-            InXmp = 1 << 10,
-            InTitle = 1 << 11,
-            InPlainText = 1 << 12,
-            InProcessingInstruction = 1 << 13,
-            InComment = 1 << 14,
-            InTextArea = 1 << 15,
-            Escaped = 1 << 16,
-            InServer = 1 << 17,
-            SkipLF = 1 << 18,
-            StartTag = 1 << 19,
-            DiscardLF = 1 << 20, // FIXME: should clarify difference between skip and discard
-            AllowYield = 1 << 21,
-            LoadingExtScript = 1 << 22,
-            ForceSynchronous = 1 << 23,
-            InIFrame = 1 << 24,
-            InDoctype = 1 << 25
-        };
-
-        void setBit(StateBits bit, bool value)
-        {
-            if (value)
-                m_bits |= bit;
-            else
-                m_bits &= ~bit;
-        }
-        bool testBit(StateBits bit) const { return m_bits & bit; }
-
-        unsigned m_bits;
-    };
-
-    State m_state;
-
-    DoctypeToken m_doctypeToken;
-    int m_doctypeSearchCount;
-    int m_doctypeSecondarySearchCount;
-
-    bool m_brokenServer;
-
-    // Name of an attribute that we just scanned.
-    AtomicString m_attrName;
-
-    // Used to store the code of a scripting sequence
-    UChar* m_scriptCode;
-    // Size of the script sequenze stored in @ref #scriptCode
-    int m_scriptCodeSize;
-    // Maximal size that can be stored in @ref #scriptCode
-    int m_scriptCodeCapacity;
-    // resync point of script code size
-    int m_scriptCodeResync;
-
-    // Stores characters if we are scanning for a string like "</script>"
-    UChar searchBuffer[10];
-
-    // Counts where we are in the string we are scanning for
-    int searchCount;
-    // the stopper string
-    const char* m_searchStopper;
-    int m_searchStopperLength;
-
-    // if no more data is coming, just parse what we have (including ext scripts that
-    // may be still downloading) and finish
-    bool m_noMoreData;
-    // URL to get source code of script from
-    String m_scriptTagSrcAttrValue;
-    String m_scriptTagCharsetAttrValue;
-    // the HTML code we will parse after the external script we are waiting for has loaded
-    SegmentedString m_pendingSrc;
-
-    // the HTML code we will parse after this particular script has
-    // loaded, but before all pending HTML
-    SegmentedString* m_currentPrependingSrc;
-
-    // true if we are executing a script while parsing a document. This causes the parsing of
-    // the output of the script to be postponed until after the script has finished executing
-    int m_executingScript;
-    Deque<CachedResourceHandle<CachedScript> > m_pendingScripts;
-    RefPtr<HTMLScriptElement> m_scriptNode;
-
-    bool m_requestingScript;
-    bool m_hasScriptsWaitingForStylesheets;
-
-    // if we found one broken comment, there are most likely others as well
-    // store a flag to get rid of the O(n^2) behaviour in such a case.
-    bool m_brokenComments;
-    // current line number
-    int m_lineNumber;
-    int m_currentScriptTagStartLineNumber;
-    int m_currentTagStartLineNumber;
-
-    double m_tokenizerTimeDelay;
-    int m_tokenizerChunkSize;
-
-    // The timer for continued processing.
-    Timer<LegacyHTMLDocumentParser> m_timer;
-
-    // The timer for continued executing external scripts.
-    Timer<LegacyHTMLDocumentParser> m_externalScriptsTimer;
-
-// This buffer can hold arbitrarily long user-defined attribute names, such as in EMBED tags.
-// So any fixed number might be too small, but rather than rewriting all usage of this buffer
-// we'll just make it large enough to handle all imaginable cases.
-#define CBUFLEN 1024
-    UChar m_cBuffer[CBUFLEN + 2];
-    unsigned int m_cBufferPos;
-
-    SegmentedString m_src;
-    OwnPtr<LegacyHTMLTreeBuilder> m_treeBuilder;
-    bool m_inWrite;
-    bool m_fragment;
-    FragmentScriptingPermission m_scriptingPermission;
-
-    OwnPtr<LegacyPreloadScanner> m_preloadScanner;
-};
-
-UChar decodeNamedEntity(const char*);
-
-} // namespace WebCore
-
-#endif // LegacyHTMLDocumentParser_h
diff --git a/WebCore/html/LegacyHTMLTreeBuilder.cpp b/WebCore/html/LegacyHTMLTreeBuilder.cpp
index ee0bcfc..f39579c 100644
--- a/WebCore/html/LegacyHTMLTreeBuilder.cpp
+++ b/WebCore/html/LegacyHTMLTreeBuilder.cpp
@@ -52,9 +52,9 @@
 #include "HTMLTableCellElement.h"
 #include "HTMLTableRowElement.h"
 #include "HTMLTableSectionElement.h"
-#include "LegacyHTMLDocumentParser.h"
 #include "LocalizedStrings.h"
 #include "Page.h"
+#include "ScriptableDocumentParser.h"
 #include "Settings.h"
 #include "Text.h"
 #include "TreeDepthLimit.h"
diff --git a/WebCore/html/LegacyHTMLTreeBuilder.h b/WebCore/html/LegacyHTMLTreeBuilder.h
index 4ac8413..ed2b857 100644
--- a/WebCore/html/LegacyHTMLTreeBuilder.h
+++ b/WebCore/html/LegacyHTMLTreeBuilder.h
@@ -26,6 +26,7 @@
 
 #include "FragmentScriptingPermission.h"
 #include "HTMLParserErrorCodes.h"
+#include "NamedNodeMap.h"
 #include "QualifiedName.h"
 #include <wtf/Forward.h>
 #include <wtf/OwnPtr.h>
@@ -44,7 +45,97 @@ class HTMLParserQuirks;
 class Node;
 
 struct HTMLStackElem;
-struct Token;
+
+/**
+ * @internal
+ * represents one HTML tag. Consists of a numerical id, and the list
+ * of attributes. Can also represent text. In this case the id = 0 and
+ * text contains the text.
+ */
+struct Token {
+    Token()
+        : beginTag(true)
+        , selfClosingTag(false)
+        , brokenXMLStyle(false)
+        , m_sourceInfo(0)
+    { }
+    ~Token() { }
+
+    void addAttribute(AtomicString& attrName, const AtomicString& v, bool viewSourceMode);
+
+    bool isOpenTag(const QualifiedName& fullName) const { return beginTag && fullName.localName() == tagName; }
+    bool isCloseTag(const QualifiedName& fullName) const { return !beginTag && fullName.localName() == tagName; }
+
+    void reset()
+    {
+        attrs = 0;
+        text = 0;
+        tagName = nullAtom;
+        beginTag = true;
+        selfClosingTag = false;
+        brokenXMLStyle = false;
+        if (m_sourceInfo)
+            m_sourceInfo->clear();
+    }
+
+    void addViewSourceChar(UChar c)
+    {
+        if (!m_sourceInfo.get())
+            m_sourceInfo.set(new Vector<UChar>);
+        m_sourceInfo->append(c);
+    }
+
+    RefPtr<NamedNodeMap> attrs;
+    RefPtr<StringImpl> text;
+    AtomicString tagName;
+    bool beginTag;
+    bool selfClosingTag;
+    bool brokenXMLStyle;
+    OwnPtr<Vector<UChar> > m_sourceInfo;
+};
+
+enum DoctypeState {
+    DoctypeBegin,
+    DoctypeBeforeName,
+    DoctypeName,
+    DoctypeAfterName,
+    DoctypeBeforePublicID,
+    DoctypePublicID,
+    DoctypeAfterPublicID,
+    DoctypeBeforeSystemID,
+    DoctypeSystemID,
+    DoctypeAfterSystemID,
+    DoctypeBogus
+};
+
+class DoctypeToken {
+public:
+    DoctypeToken() {}
+
+    void reset()
+    {
+        m_name.clear();
+        m_publicID.clear();
+        m_systemID.clear();
+        m_state = DoctypeBegin;
+        m_source.clear();
+        m_forceQuirks = false;
+    }
+
+    DoctypeState state() { return m_state; }
+    void setState(DoctypeState s) { m_state = s; }
+
+    Vector<UChar> m_name;
+    Vector<UChar> m_publicID;
+    Vector<UChar> m_systemID;
+    DoctypeState m_state;
+
+    Vector<UChar> m_source;
+
+    bool m_forceQuirks; // Used by the HTML5 parser.
+};
+
+//-----------------------------------------------------------------------------
 
 /**
  * The parser for HTML. It receives a stream of tokens from the LegacyHTMLDocumentParser, and
diff --git a/WebCore/html/LegacyPreloadScanner.cpp b/WebCore/html/LegacyPreloadScanner.cpp
deleted file mode 100644
index 613eb45..0000000
--- a/WebCore/html/LegacyPreloadScanner.cpp
+++ /dev/null
@@ -1,856 +0,0 @@
-/*
- * Copyright (C) 2008 Apple Inc. All Rights Reserved.
- * Copyright (C) 2009 Torch Mobile, Inc. http://www.torchmobile.com/
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
- */
-
-#include "config.h"
-#include "LegacyPreloadScanner.h"
-
-#include "CachedCSSStyleSheet.h"
-#include "CachedImage.h"
-#include "CachedResource.h"
-#include "CachedResourceClient.h"
-#include "CachedScript.h"
-#include "CSSHelper.h"
-#include "DocLoader.h"
-#include "Document.h"
-#include "Frame.h"
-#include "FrameLoader.h"
-#include "HTMLLinkElement.h"
-#include "HTMLNames.h"
-#include <wtf/text/CString.h>
-#include <wtf/CurrentTime.h>
-#include <wtf/text/AtomicString.h>
-#include <wtf/unicode/Unicode.h>
-
-// Use __GNUC__ instead of PLATFORM(GCC) to stay consistent with the gperf generated c file
-#ifdef __GNUC__
-// The main tokenizer includes this too so we are getting two copies of the data. However, this way the code gets inlined.
-#include "HTMLEntityNames.cpp"
-#else
-// Not inlined for non-GCC compilers
-struct Entity {
-    const char* name;
-    int code;
-};
-const struct Entity* findEntity(register const char* str, register unsigned int len);
-#endif
-
-#define PRELOAD_DEBUG 0
-
-using namespace WTF;
-
-namespace WebCore {
-    
-using namespace HTMLNames;
-    
-LegacyPreloadScanner::LegacyPreloadScanner(Document* doc)
-    : m_inProgress(false)
-    , m_timeUsed(0)
-    , m_bodySeen(false)
-    , m_document(doc)
-{
-#if PRELOAD_DEBUG
-    printf("CREATING PRELOAD SCANNER FOR %s\n", m_document->url().string().latin1().data());
-#endif
-}
-    
-LegacyPreloadScanner::~LegacyPreloadScanner()
-{
-#if PRELOAD_DEBUG
-    printf("DELETING PRELOAD SCANNER FOR %s\n", m_document->url().string().latin1().data());
-    printf("TOTAL TIME USED %.4fs\n", m_timeUsed);
-#endif
-}
-    
-void LegacyPreloadScanner::begin() 
-{ 
-    ASSERT(!m_inProgress); 
-    reset(); 
-    m_inProgress = true; 
-}
-    
-void LegacyPreloadScanner::end() 
-{ 
-    ASSERT(m_inProgress); 
-    m_inProgress = false; 
-}
-
-void LegacyPreloadScanner::reset()
-{
-    m_source.clear();
-    
-    m_state = Data;
-    m_escape = false;
-    m_contentModel = PCDATA;
-    m_commentPos = 0;
-
-    m_closeTag = false;
-    m_tagName.clear();
-    m_attributeName.clear();
-    m_attributeValue.clear();
-    m_lastStartTag = AtomicString();
-    
-    m_urlToLoad = String();
-    m_charset = String();
-    m_linkIsStyleSheet = false;
-    m_lastCharacterIndex = 0;
-    clearLastCharacters();
-    
-    m_cssState = CSSInitial;
-    m_cssRule.clear();
-    m_cssRuleValue.clear();
-}
-    
-bool LegacyPreloadScanner::scanningBody() const
-{
-    return m_document->body() || m_bodySeen;
-}
-    
-void LegacyPreloadScanner::write(const SegmentedString& source)
-{
-#if PRELOAD_DEBUG
-    double startTime = currentTime();
-#endif
-    tokenize(source);
-#if PRELOAD_DEBUG
-    m_timeUsed += currentTime() - startTime;
-#endif
-}
-    
-static inline bool isWhitespace(UChar c)
-{
-    return c == ' ' || c == '\n' || c == '\r' || c == '\t';
-}
-    
-inline void LegacyPreloadScanner::clearLastCharacters()
-{
-    memset(m_lastCharacters, 0, lastCharactersBufferSize * sizeof(UChar));
-}
-    
-inline void LegacyPreloadScanner::rememberCharacter(UChar c)
-{
-    m_lastCharacterIndex = (m_lastCharacterIndex + 1) % lastCharactersBufferSize;
-    m_lastCharacters[m_lastCharacterIndex] = c;
-}
-    
-inline bool LegacyPreloadScanner::lastCharactersMatch(const char* chars, unsigned count) const
-{
-    unsigned pos = m_lastCharacterIndex;
-    while (count) {
-        if (chars[count - 1] != m_lastCharacters[pos])
-            return false;
-        --count;
-        if (!pos)
-            pos = lastCharactersBufferSize;
-        --pos;
-    }
-    return true;
-}
-    
-static inline unsigned legalEntityFor(unsigned value)
-{
-    // FIXME There is a table for more exceptions in the HTML5 specification.
-    if (value == 0 || value > 0x10FFFF || (value >= 0xD800 && value <= 0xDFFF))
-        return 0xFFFD;
-    return value;
-}
-    
-unsigned LegacyPreloadScanner::consumeEntity(SegmentedString& source, bool& notEnoughCharacters)
-{
-    enum EntityState {
-        Initial,
-        NumberType,
-        MaybeHex,
-        Hex,
-        Decimal,
-        Named
-    };
-    EntityState entityState = Initial;
-    unsigned result = 0;
-    Vector<UChar, 10> seenChars;
-    Vector<char, 10> entityName;
-    
-    while (!source.isEmpty()) {
-        UChar cc = *source;
-        seenChars.append(cc);
-        switch (entityState) {
-        case Initial:
-            if (isWhitespace(cc) || cc == '<' || cc == '&')
-                return 0;
-            else if (cc == '#') 
-                entityState = NumberType;
-            else if ((cc >= 'a' && cc <= 'z') || (cc >= 'A' && cc <= 'Z')) {
-                entityName.append(cc);
-                entityState = Named;
-            } else
-                return 0;
-            break;
-        case NumberType:
-            if (cc == 'x' || cc == 'X')
-                entityState = MaybeHex;
-            else if (cc >= '0' && cc <= '9') {
-                entityState = Decimal;
-                result = cc - '0';
-            } else {
-                source.push('#');
-                return 0;
-            }
-            break;
-        case MaybeHex:
-            if (cc >= '0' && cc <= '9')
-                result = cc - '0';
-            else if (cc >= 'a' && cc <= 'f')
-                result = 10 + cc - 'a';
-            else if (cc >= 'A' && cc <= 'F')
-                result = 10 + cc - 'A';
-            else {
-                source.push('#');
-                source.push(seenChars[1]);
-                return 0;
-            }
-            entityState = Hex;
-            break;
-        case Hex:
-            if (cc >= '0' && cc <= '9')
-                result = result * 16 + cc - '0';
-            else if (cc >= 'a' && cc <= 'f')
-                result = result * 16 + 10 + cc - 'a';
-            else if (cc >= 'A' && cc <= 'F')
-                result = result * 16 + 10 + cc - 'A';
-            else if (cc == ';') {
-                source.advance();
-                return legalEntityFor(result);
-            } else 
-                return legalEntityFor(result);
-            break;
-        case Decimal:
-            if (cc >= '0' && cc <= '9')
-                result = result * 10 + cc - '0';
-            else if (cc == ';') {
-                source.advance();
-                return legalEntityFor(result);
-            } else
-                return legalEntityFor(result);
-            break;               
-        case Named:
-            // This is the attribute only version, generic version matches somewhat differently
-            while (entityName.size() <= 8) {
-                if (cc == ';') {
-                    const Entity* entity = findEntity(entityName.data(), entityName.size());
-                    if (entity) {
-                        source.advance();
-                        return entity->code;
-                    }
-                    break;
-                }
-                if (!(cc >= 'a' && cc <= 'z') && !(cc >= 'A' && cc <= 'Z') && !(cc >= '0' && cc <= '9')) {
-                    const Entity* entity = findEntity(entityName.data(), entityName.size());
-                    if (entity)
-                        return entity->code;
-                    break;
-                }
-                entityName.append(cc);
-                source.advance();
-                if (source.isEmpty())
-                    goto outOfCharacters;
-                cc = *source;
-                seenChars.append(cc);
-            }
-            if (seenChars.size() == 2)
-                source.push(seenChars[0]);
-            else if (seenChars.size() == 3) {
-                source.push(seenChars[0]);
-                source.push(seenChars[1]);
-            } else
-                source.prepend(SegmentedString(String(seenChars.data(), seenChars.size() - 1)));
-            return 0;
-        }
-        source.advance();
-    }
-outOfCharacters:
-    notEnoughCharacters = true;
-    source.prepend(SegmentedString(String(seenChars.data(), seenChars.size())));
-    return 0;
-}
-
-void LegacyPreloadScanner::tokenize(const SegmentedString& source)
-{
-    ASSERT(m_inProgress);
-    
-    m_source.append(source);
-
-    // This is a simplified HTML5 Tokenizer
-    // http://www.whatwg.org/specs/web-apps/current-work/#tokenisation0
-    while (!m_source.isEmpty()) {
-        UChar cc = *m_source;
-        switch (m_state) {
-        case Data:
-            while (1) {
-                rememberCharacter(cc);
-                if (cc == '&') {
-                    if (m_contentModel == PCDATA || m_contentModel == RCDATA) {
-                        m_state = EntityData;
-                        break;
-                    }
-                } else if (cc == '-') {
-                    if ((m_contentModel == RCDATA || m_contentModel == CDATA) && !m_escape) {
-                        if (lastCharactersMatch("<!--", 4))
-                            m_escape = true;
-                    }
-                } else if (cc == '<') {
-                    if (m_contentModel == PCDATA || ((m_contentModel == RCDATA || m_contentModel == CDATA) && !m_escape)) {
-                        m_state = TagOpen;
-                        break;
-                    }
-                } else if (cc == '>') {
-                     if ((m_contentModel == RCDATA || m_contentModel == CDATA) && m_escape) {
-                         if (lastCharactersMatch("-->", 3))
-                             m_escape = false;
-                     }
-                }
-                emitCharacter(cc);
-                m_source.advance();
-                if (m_source.isEmpty())
-                     return;
-                cc = *m_source;
-            }
-            break;
-        case EntityData:
-            // should try to consume the entity but we only care about entities in attributes
-            m_state = Data;
-            break;
-        case TagOpen:
-            if (m_contentModel == RCDATA || m_contentModel == CDATA) {
-                if (cc == '/')
-                    m_state = CloseTagOpen;
-                else {
-                    m_state = Data;
-                    continue;
-                }
-            } else if (m_contentModel == PCDATA) {
-                if (cc == '!')
-                    m_state = MarkupDeclarationOpen;
-                else if (cc == '/')
-                    m_state = CloseTagOpen;
-                else if (cc >= 'A' && cc <= 'Z') {
-                    m_tagName.clear();
-                    m_charset = String();
-                    m_tagName.append(cc + 0x20);
-                    m_closeTag = false;
-                    m_state = TagName;
-                } else if (cc >= 'a' && cc <= 'z') {
-                    m_tagName.clear();
-                    m_charset = String();
-                    m_tagName.append(cc);
-                    m_closeTag = false;
-                    m_state = TagName;
-                } else if (cc == '>') {
-                    m_state = Data;
-                } else if (cc == '?') {
-                    m_state = BogusComment;
-                } else {
-                    m_state = Data;
-                    continue;
-                }
-            }
-            break;
-        case CloseTagOpen:
-            if (m_contentModel == RCDATA || m_contentModel == CDATA) {
-                if (!m_lastStartTag.length()) {
-                    m_state = Data;
-                    continue;
-                }
-                if (m_source.length() < m_lastStartTag.length() + 1)
-                    return;
-                Vector<UChar> tmpString;
-                UChar tmpChar = 0;
-                bool match = true;
-                for (unsigned n = 0; n < m_lastStartTag.length() + 1; n++) {
-                    tmpChar = Unicode::toLower(*m_source);
-                    if (n < m_lastStartTag.length() && tmpChar != m_lastStartTag[n])
-                        match = false;
-                    tmpString.append(tmpChar);
-                    m_source.advance();
-                }
-                m_source.prepend(SegmentedString(String(tmpString.data(), tmpString.size())));
-                if (!match || (!isWhitespace(tmpChar) && tmpChar != '>' && tmpChar != '/')) {
-                    m_state = Data;
-                    continue;
-                }
-            }
-            if (cc >= 'A' && cc <= 'Z') {
-                m_tagName.clear();
-                m_charset = String();
-                m_tagName.append(cc + 0x20);
-                m_closeTag = true;
-                m_state = TagName;
-            } else if (cc >= 'a' && cc <= 'z') {
-                m_tagName.clear();
-                m_charset = String();
-                m_tagName.append(cc);
-                m_closeTag = true;
-                m_state = TagName;
-            } else if (cc == '>') {
-                m_state = Data;
-            } else
-                m_state = BogusComment;
-            break;
-        case TagName:
-            while (1) {
-                if (isWhitespace(cc)) {
-                    m_state = BeforeAttributeName;
-                    break;
-                }
-                if (cc == '>') {
-                    emitTag();
-                    m_state = Data;
-                    break;
-                }
-                if (cc == '/') {
-                    m_state = BeforeAttributeName;
-                    break;
-                }
-                if (cc >= 'A' && cc <= 'Z')
-                    m_tagName.append(cc + 0x20);
-                else
-                    m_tagName.append(cc);
-                m_source.advance();
-                if (m_source.isEmpty())
-                    return;
-                cc = *m_source;
-            }
-            break;
-        case BeforeAttributeName:
-            if (isWhitespace(cc))
-                ;
-            else if (cc == '>') {
-                emitTag();
-                m_state = Data;
-            } else if (cc >= 'A' && cc <= 'Z') {
-                m_attributeName.clear();
-                m_attributeValue.clear();
-                m_attributeName.append(cc + 0x20);
-                m_state = AttributeName;
-            } else if (cc == '/')
-                ;
-            else {
-                m_attributeName.clear();
-                m_attributeValue.clear();
-                m_attributeName.append(cc);
-                m_state = AttributeName;
-            }
-            break;
-        case AttributeName:
-            while (1) {
-                if (isWhitespace(cc)) {
-                    m_state = AfterAttributeName;
-                    break;
-                }
-                if (cc == '=') {
-                    m_state = BeforeAttributeValue;
-                    break;
-                }
-                if (cc == '>') {
-                    emitTag();
-                    m_state = Data;
-                    break;
-                } 
-                if (cc == '/') {
-                    m_state = BeforeAttributeName;
-                    break;
-                }
-                if (cc >= 'A' && cc <= 'Z')
-                    m_attributeName.append(cc + 0x20);
-                else
-                    m_attributeName.append(cc);
-                m_source.advance();
-                if (m_source.isEmpty())
-                    return;
-                cc = *m_source;
-            }
-            break;
-        case AfterAttributeName:
-            if (isWhitespace(cc))
-                ;
-            else if (cc == '=')
-                m_state = BeforeAttributeValue; 
-            else if (cc == '>') {
-                emitTag();
-                m_state = Data;
-            } else if (cc >= 'A' && cc <= 'Z') {
-                m_attributeName.clear();
-                m_attributeValue.clear();
-                m_attributeName.append(cc + 0x20);
-                m_state = AttributeName;
-            } else if (cc == '/')
-                m_state = BeforeAttributeName;
-            else {
-                m_attributeName.clear();
-                m_attributeValue.clear();
-                m_attributeName.append(cc);
-                m_state = AttributeName;
-            }
-            break;
-        case BeforeAttributeValue:
-            if (isWhitespace(cc))
-                ;
-            else if (cc == '"')
-                m_state = AttributeValueDoubleQuoted;
-            else if (cc == '&') {
-                m_state = AttributeValueUnquoted;
-                continue;
-            } else if (cc == '\'')
-                m_state = AttributeValueSingleQuoted;
-            else if (cc == '>') {
-                emitTag();
-                m_state = Data;
-            } else {
-                m_attributeValue.append(cc);
-                m_state = AttributeValueUnquoted;
-            }
-            break;
-        case AttributeValueDoubleQuoted:
-            while (1) {
-                if (cc == '"') {
-                    processAttribute();
-                    m_state = BeforeAttributeName;
-                    break;
-                }
-                if (cc == '&') {
-                    m_stateBeforeEntityInAttributeValue = m_state;
-                    m_state = EntityInAttributeValue;
-                    break;
-                } 
-                m_attributeValue.append(cc);
-                m_source.advance();
-                if (m_source.isEmpty())
-                    return;
-                cc = *m_source;
-            }
-            break;
-        case AttributeValueSingleQuoted:
-            while (1) {
-                if (cc == '\'') {
-                    processAttribute();
-                    m_state = BeforeAttributeName;
-                    break;
-                }
-                if (cc == '&') {
-                    m_stateBeforeEntityInAttributeValue = m_state;
-                    m_state = EntityInAttributeValue;
-                    break;
-                } 
-                m_attributeValue.append(cc);
-                m_source.advance();
-                if (m_source.isEmpty())
-                    return;
-                cc = *m_source;
-            }
-            break;
-        case AttributeValueUnquoted:
-            while (1) {
-                if (isWhitespace(cc)) {
-                    processAttribute();
-                    m_state = BeforeAttributeName;
-                    break;
-                }
-                if (cc == '&') {
-                    m_stateBeforeEntityInAttributeValue = m_state;
-                    m_state = EntityInAttributeValue;
-                    break;
-                }
-                if (cc == '>') {
-                    processAttribute();
-                    emitTag();
-                    m_state = Data;
-                    break;
-                }
-                m_attributeValue.append(cc);
-                m_source.advance();
-                if (m_source.isEmpty())
-                    return;
-                cc = *m_source;
-            }
-            break;
-        case EntityInAttributeValue: 
-            {
-                bool notEnoughCharacters = false; 
-                unsigned entity = consumeEntity(m_source, notEnoughCharacters);
-                if (notEnoughCharacters)
-                    return;
-                if (entity > 0xFFFF) {
-                    m_attributeValue.append(U16_LEAD(entity));
-                    m_attributeValue.append(U16_TRAIL(entity));
-                } else if (entity)
-                    m_attributeValue.append(entity);
-                else
-                    m_attributeValue.append('&');
-            }
-            m_state = m_stateBeforeEntityInAttributeValue;
-            continue;
-        case BogusComment:
-            while (1) {
-                if (cc == '>') {
-                    m_state = Data;
-                    break;
-                }
-                m_source.advance();
-                if (m_source.isEmpty())
-                    return;
-                cc = *m_source;
-            }
-            break;
-        case MarkupDeclarationOpen: {
-            if (cc == '-') {
-                if (m_source.length() < 2)
-                    return;
-                m_source.advance();
-                cc = *m_source;
-                if (cc == '-')
-                    m_state = CommentStart;
-                else {
-                    m_state = BogusComment;
-                    continue;
-                }
-            // If we cared about the DOCTYPE we would test to enter those states here
-            } else {
-                m_state = BogusComment;
-                continue;
-            }
-            break;
-        }
-        case CommentStart:
-            if (cc == '-')
-                m_state = CommentStartDash;
-            else if (cc == '>')
-                m_state = Data;
-            else
-                m_state = Comment;
-            break;
-        case CommentStartDash:
-            if (cc == '-')
-                m_state = CommentEnd;
-            else if (cc == '>')
-                m_state = Data;
-            else
-                m_state = Comment;
-            break;
-        case Comment:
-            while (1) {
-                if (cc == '-') {
-                    m_state = CommentEndDash;
-                    break;
-                }
-                m_source.advance();
-                if (m_source.isEmpty())
-                    return;
-                cc = *m_source;
-            }
-            break;
-        case CommentEndDash:
-            if (cc == '-')
-                m_state = CommentEnd;
-            else 
-                m_state = Comment;
-            break;
-        case CommentEnd:
-            if (cc == '>')
-                m_state = Data;
-            else if (cc == '-')
-                ;
-            else 
-                m_state = Comment;
-            break;
-        }
-        m_source.advance();
-    }
-}
-    
-void LegacyPreloadScanner::processAttribute()
-{
-    AtomicString tag = AtomicString(m_tagName.data(), m_tagName.size());
-    AtomicString attribute = AtomicString(m_attributeName.data(), m_attributeName.size());
-    
-    String value(m_attributeValue.data(), m_attributeValue.size());
-    if (tag == scriptTag || tag == imgTag) {
-        if (attribute == srcAttr && m_urlToLoad.isEmpty())
-            m_urlToLoad = deprecatedParseURL(value);
-        else if (attribute == charsetAttr)
-            m_charset = value;
-    } else if (tag == linkTag) {
-        if (attribute == hrefAttr && m_urlToLoad.isEmpty())
-            m_urlToLoad = deprecatedParseURL(value);
-        else if (attribute == relAttr) {
-            HTMLLinkElement::RelAttribute rel;
-            HTMLLinkElement::tokenizeRelAttribute(value, rel);
-            m_linkIsStyleSheet = rel.m_isStyleSheet && !rel.m_isAlternate && !rel.m_isIcon && !rel.m_isDNSPrefetch;
-        } else if (attribute == charsetAttr)
-            m_charset = value;
-    }
-}
-    
-inline void LegacyPreloadScanner::emitCharacter(UChar c)
-{
-    if (m_contentModel == CDATA && m_lastStartTag == styleTag) 
-        tokenizeCSS(c);
-}
-    
-inline void LegacyPreloadScanner::tokenizeCSS(UChar c)
-{    
-    // We are just interested in @import rules, no need for real tokenization here
-    // Searching for other types of resources is probably low payoff
-    switch (m_cssState) {
-    case CSSInitial:
-        if (c == '@')
-            m_cssState = CSSRuleStart;
-        else if (c == '/')
-            m_cssState = CSSMaybeComment;
-        break;
-    case CSSMaybeComment:
-        if (c == '*')
-            m_cssState = CSSComment;
-        else
-            m_cssState = CSSInitial;
-        break;
-    case CSSComment:
-        if (c == '*')
-            m_cssState = CSSMaybeCommentEnd;
-        break;
-    case CSSMaybeCommentEnd:
-        if (c == '/')
-            m_cssState = CSSInitial;
-        else if (c == '*')
-            ;
-        else
-            m_cssState = CSSComment;
-        break;
-    case CSSRuleStart:
-        if ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z')) {
-            m_cssRule.clear();
-            m_cssRuleValue.clear();
-            m_cssRule.append(c);
-            m_cssState = CSSRule;
-        } else
-            m_cssState = CSSInitial;
-        break;
-    case CSSRule:
-        if (isWhitespace(c))
-            m_cssState = CSSAfterRule;
-        else if (c == ';')
-            m_cssState = CSSInitial;
-        else
-            m_cssRule.append(c);
-        break;
-    case CSSAfterRule:
-        if (isWhitespace(c))
-            ;
-        else if (c == ';')
-            m_cssState = CSSInitial;
-        else {
-            m_cssState = CSSRuleValue;
-            m_cssRuleValue.append(c);
-        }
-        break;
-    case CSSRuleValue:
-        if (isWhitespace(c))
-            m_cssState = CSSAfterRuleValue;
-        else if (c == ';') {
-            emitCSSRule();
-            m_cssState = CSSInitial;
-        } else 
-            m_cssRuleValue.append(c);
-        break;
-    case CSSAfterRuleValue:
-        if (isWhitespace(c))
-            ;
-        else if (c == ';') {
-            emitCSSRule();
-            m_cssState = CSSInitial;
-        } else {
-            // FIXME media rules
-             m_cssState = CSSInitial;
-        }
-        break;
-    }
-}
-    
-void LegacyPreloadScanner::emitTag()
-{
-    if (m_closeTag) {
-        m_contentModel = PCDATA;
-        m_cssState = CSSInitial;
-        clearLastCharacters();
-        return;
-    }
-    
-    AtomicString tag(m_tagName.data(), m_tagName.size());
-    m_lastStartTag = tag;
-    
-    if (tag == textareaTag || tag == titleTag)
-        m_contentModel = RCDATA;
-    else if (tag == styleTag || tag == xmpTag || tag == scriptTag || tag == iframeTag || tag == noembedTag || tag == noframesTag)
-        m_contentModel = CDATA;
-    else if (tag == noscriptTag)
-        // we wouldn't be here if scripts were disabled
-        m_contentModel = CDATA;
-    else if (tag == plaintextTag)
-        m_contentModel = PLAINTEXT;
-    else
-        m_contentModel = PCDATA;
-    
-    if (tag == bodyTag)
-        m_bodySeen = true;
-    
-    if (m_urlToLoad.isEmpty()) {
-        m_linkIsStyleSheet = false;
-        return;
-    }
-    
-    if (tag == scriptTag)
-        m_document->docLoader()->preload(CachedResource::Script, m_urlToLoad, m_charset, scanningBody());
-    else if (tag == imgTag) 
-        m_document->docLoader()->preload(CachedResource::ImageResource, m_urlToLoad, String(), scanningBody());
-    else if (tag == linkTag && m_linkIsStyleSheet) 
-        m_document->docLoader()->preload(CachedResource::CSSStyleSheet, m_urlToLoad, m_charset, scanningBody());
-
-    m_urlToLoad = String();
-    m_charset = String();
-    m_linkIsStyleSheet = false;
-}
-    
-void LegacyPreloadScanner::emitCSSRule()
-{
-    String rule(m_cssRule.data(), m_cssRule.size());
-    if (equalIgnoringCase(rule, "import") && !m_cssRuleValue.isEmpty()) {
-        String value(m_cssRuleValue.data(), m_cssRuleValue.size());
-        String url = deprecatedParseURL(value);
-        if (!url.isEmpty())
-            m_document->docLoader()->preload(CachedResource::CSSStyleSheet, url, String(), scanningBody());
-    }
-    m_cssRule.clear();
-    m_cssRuleValue.clear();
-}
-                
-}
diff --git a/WebCore/html/LegacyPreloadScanner.h b/WebCore/html/LegacyPreloadScanner.h
deleted file mode 100644
index 333366d..0000000
--- a/WebCore/html/LegacyPreloadScanner.h
+++ /dev/null
@@ -1,144 +0,0 @@
-/*
- * Copyright (C) 2008 Apple Inc. All Rights Reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
- */
-
-#ifndef LegacyPreloadScanner_h
-#define LegacyPreloadScanner_h
-
-#include "SegmentedString.h"
-#include <wtf/Noncopyable.h>
-#include <wtf/Vector.h>
-#include <wtf/text/AtomicString.h>
-
-namespace WebCore {
-    
-    class CachedResource;
-    class CachedResourceClient;
-    class Document;
-    
-    class LegacyPreloadScanner : public Noncopyable {
-    public:
-        LegacyPreloadScanner(Document*);
-        ~LegacyPreloadScanner();
-        void begin();
-        void write(const SegmentedString&);
-        void end();
-        bool inProgress() const { return m_inProgress; }
-        
-        bool scanningBody() const;
-        
-        static unsigned consumeEntity(SegmentedString&, bool& notEnoughCharacters);
-        
-    private:
-        void tokenize(const SegmentedString&);
-        void reset();
-        
-        void emitTag();
-        void emitCharacter(UChar);
-        
-        void tokenizeCSS(UChar);
-        void emitCSSRule();
-        
-        void processAttribute();
-
-        
-        void clearLastCharacters();
-        void rememberCharacter(UChar);
-        bool lastCharactersMatch(const char*, unsigned count) const;
-        
-        bool m_inProgress;
-        SegmentedString m_source;
-        
-        enum State {
-            Data,
-            EntityData,
-            TagOpen,
-            CloseTagOpen,
-            TagName,
-            BeforeAttributeName,
-            AttributeName,
-            AfterAttributeName,
-            BeforeAttributeValue,
-            AttributeValueDoubleQuoted,
-            AttributeValueSingleQuoted,
-            AttributeValueUnquoted,
-            EntityInAttributeValue,
-            BogusComment,
-            MarkupDeclarationOpen,
-            CommentStart,
-            CommentStartDash,
-            Comment,
-            CommentEndDash,
-            CommentEnd
-        };
-        State m_state;
-        bool m_escape;
-        enum ContentModel {
-            PCDATA,
-            RCDATA,
-            CDATA,
-            PLAINTEXT
-        };
-        ContentModel m_contentModel;
-        unsigned m_commentPos;
-        State m_stateBeforeEntityInAttributeValue;
-        
-        static const unsigned lastCharactersBufferSize = 8;
-        UChar m_lastCharacters[lastCharactersBufferSize];
-        unsigned m_lastCharacterIndex;
-        
-        bool m_closeTag;
-        Vector<UChar, 32> m_tagName;
-        Vector<UChar, 32> m_attributeName;
-        Vector<UChar> m_attributeValue;
-        AtomicString m_lastStartTag;
-        
-        String m_urlToLoad;
-        String m_charset;
-        bool m_linkIsStyleSheet;
-        
-        enum CSSState {
-            CSSInitial,
-            CSSMaybeComment,
-            CSSComment,
-            CSSMaybeCommentEnd,
-            CSSRuleStart,
-            CSSRule,
-            CSSAfterRule,
-            CSSRuleValue,
-            CSSAfterRuleValue
-        };
-        CSSState m_cssState;
-        Vector<UChar, 16> m_cssRule;
-        Vector<UChar> m_cssRuleValue;
-        
-        double m_timeUsed;
-        
-        bool m_bodySeen;
-        Document* m_document;
-    };
-
-}
-
-#endif
diff --git a/WebCore/loader/FTPDirectoryDocument.cpp b/WebCore/loader/FTPDirectoryDocument.cpp
index 9315e45..5c7102c 100644
--- a/WebCore/loader/FTPDirectoryDocument.cpp
+++ b/WebCore/loader/FTPDirectoryDocument.cpp
@@ -27,9 +27,9 @@
 #include "FTPDirectoryDocument.h"
 
 #include "CharacterNames.h"
+#include "HTMLDocumentParser.h"
 #include "HTMLNames.h"
 #include "HTMLTableElement.h"
-#include "LegacyHTMLDocumentParser.h"
 #include "LocalizedStrings.h"
 #include "Logging.h"
 #include "FTPDirectoryParser.h"
@@ -48,13 +48,13 @@ namespace WebCore {
 
 using namespace HTMLNames;
     
-class FTPDirectoryDocumentParser : public LegacyHTMLDocumentParser {
+class FTPDirectoryDocumentParser : public HTMLDocumentParser {
 public:
     FTPDirectoryDocumentParser(HTMLDocument*);
 
     virtual void append(const SegmentedString&);
     virtual void finish();
-    
+
     virtual bool isWaitingForScripts() const { return false; }
 
     inline void checkBuffer(int len = 10)
@@ -79,7 +79,7 @@ private:
     void parseAndAppendOneLine(const String&);
     void appendEntry(const String& name, const String& size, const String& date, bool isDirectory);    
     PassRefPtr<Element> createTDForFilename(const String&);
-    
+
     RefPtr<HTMLTableElement> m_tableElement;
 
     bool m_skipLF;
@@ -94,14 +94,14 @@ private:
 };
 
 FTPDirectoryDocumentParser::FTPDirectoryDocumentParser(HTMLDocument* document)
-    : LegacyHTMLDocumentParser(document, false)
+    : HTMLDocumentParser(document, false)
     , m_skipLF(false)
     , m_parsedTemplate(false)
     , m_size(254)
     , m_buffer(static_cast<UChar*>(fastMalloc(sizeof(UChar) * m_size)))
     , m_dest(m_buffer)
 {
-}    
+}
 
 void FTPDirectoryDocumentParser::appendEntry(const String& filename, const String& size, const String& date, bool isDirectory)
 {
@@ -109,7 +109,7 @@ void FTPDirectoryDocumentParser::appendEntry(const String& filename, const Strin
 
     RefPtr<Element> rowElement = m_tableElement->insertRow(-1, ec);
     rowElement->setAttribute("class", "ftpDirectoryEntryRow", ec);
-   
+
     RefPtr<Element> element = document()->createElement(tdTag, false);
     element->appendChild(Text::create(document(), String(&noBreakSpace, 1)), ec);
     if (isDirectory)
@@ -117,16 +117,16 @@ void FTPDirectoryDocumentParser::appendEntry(const String& filename, const Strin
     else
         element->setAttribute("class", "ftpDirectoryIcon ftpDirectoryTypeFile", ec);
     rowElement->appendChild(element, ec);
-    
+
     element = createTDForFilename(filename);
     element->setAttribute("class", "ftpDirectoryFileName", ec);
     rowElement->appendChild(element, ec);
-    
+
     element = document()->createElement(tdTag, false);
     element->appendChild(Text::create(document(), date), ec);
     element->setAttribute("class", "ftpDirectoryFileDate", ec);
     rowElement->appendChild(element, ec);
-    
+
     element = document()->createElement(tdTag, false);
     element->appendChild(Text::create(document(), size), ec);
     element->setAttribute("class", "ftpDirectoryFileSize", ec);
@@ -136,7 +136,7 @@ void FTPDirectoryDocumentParser::appendEntry(const String& filename, const Strin
 PassRefPtr<Element> FTPDirectoryDocumentParser::createTDForFilename(const String& filename)
 {
     ExceptionCode ec;
-    
+
     String fullURL = document()->baseURL().string();
     if (fullURL[fullURL.length() - 1] == '/')
         fullURL.append(filename);
@@ -146,10 +146,10 @@ PassRefPtr<Element> FTPDirectoryDocumentParser::createTDForFilename(const String
     RefPtr<Element> anchorElement = document()->createElement(aTag, false);
     anchorElement->setAttribute("href", fullURL, ec);
     anchorElement->appendChild(Text::create(document(), filename), ec);
-    
+
     RefPtr<Element> tdElement = document()->createElement(tdTag, false);
     tdElement->appendChild(anchorElement, ec);
-    
+
     return tdElement.release();
 }
 
@@ -157,18 +157,18 @@ static String processFilesizeString(const String& size, bool isDirectory)
 {
     if (isDirectory)
         return "--";
-    
+
     bool valid;
     int64_t bytes = size.toUInt64(&valid);
     if (!valid)
         return unknownFileSizeText();
-     
+
     if (bytes < 1000000)
         return String::format("%.2f KB", static_cast<float>(bytes)/1000);
 
     if (bytes < 1000000000)
         return String::format("%.2f MB", static_cast<float>(bytes)/1000000);
-        
+
     return String::format("%.2f GB", static_cast<float>(bytes)/1000000000);
 }
 
@@ -177,19 +177,19 @@ static bool wasLastDayOfMonth(int year, int month, int day)
     static int lastDays[] = { 31, 0, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
     if (month < 0 || month > 11)
         return false;
-        
+
     if (month == 2) {
         if (year % 4 == 0 && (year % 100 || year % 400 == 0)) {
             if (day == 29)
                 return true;
             return false;
         }
-         
+
         if (day == 28)
             return true;
         return false;
     }
-    
+
     return lastDays[month] == day;
 }
 
@@ -198,11 +198,11 @@ static String processFileDateString(const FTPTime& fileTime)
     // FIXME: Need to localize this string?
 
     String timeOfDay;
-    
+
     if (!(fileTime.tm_hour == 0 && fileTime.tm_min == 0 && fileTime.tm_sec == 0)) {
         int hour = fileTime.tm_hour;
         ASSERT(hour >= 0 && hour < 24);
-        
+
         if (hour < 12) {
             if (hour == 0)
                 hour = 12;
@@ -214,15 +214,15 @@ static String processFileDateString(const FTPTime& fileTime)
             timeOfDay = String::format(", %i:%02i PM", hour, fileTime.tm_min);
         }
     }
-    
+
     // If it was today or yesterday, lets just do that - but we have to compare to the current time
     struct tm now;
     time_t now_t = time(NULL);
     getLocalTime(&now_t, &now);
-    
+
     // localtime does "year = current year - 1900", compensate for that for readability and comparison purposes
     now.tm_year += 1900;
-        
+
     if (fileTime.tm_year == now.tm_year) {
         if (fileTime.tm_mon == now.tm_mon) {
             if (fileTime.tm_mday == now.tm_mday)
@@ -235,23 +235,23 @@ static String processFileDateString(const FTPTime& fileTime)
             wasLastDayOfMonth(fileTime.tm_year, fileTime.tm_mon, fileTime.tm_mday))
                 return "Yesterday" + timeOfDay;
     }
-    
+
     if (fileTime.tm_year == now.tm_year - 1 && fileTime.tm_mon == 12 && fileTime.tm_mday == 31 && now.tm_mon == 1 && now.tm_mday == 1)
         return "Yesterday" + timeOfDay;
 
     static const char* months[] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", "???" };
-    
+
     int month = fileTime.tm_mon;
     if (month < 0 || month > 11)
         month = 12;
-    
+
     String dateString;
-    
+
     if (fileTime.tm_year > -1)
         dateString = String::format("%s %i, %i", months[month], fileTime.tm_mday, fileTime.tm_year);
     else
         dateString = String::format("%s %i, %i", months[month], fileTime.tm_mday, now.tm_year);
-    
+
     return dateString + timeOfDay;
 }
 
@@ -261,22 +261,22 @@ void FTPDirectoryDocumentParser::parseAndAppendOneLine(const String& inputLine)
     CString latin1Input = inputLine.latin1();
 
     FTPEntryType typeResult = parseOneFTPLine(latin1Input.data(), m_listState, result);
-    
+
     // FTPMiscEntry is a comment or usage statistic which we don't care about, and junk is invalid data - bail in these 2 cases
     if (typeResult == FTPMiscEntry || typeResult == FTPJunkEntry)
         return;
-        
+
     String filename(result.filename, result.filenameLength);
     if (result.type == FTPDirectoryEntry) {
         filename.append("/");
-        
+
         // We have no interest in linking to "current directory"
         if (filename == "./")
             return;
     }
 
     LOG(FTP, "Appending entry - %s, %s", filename.ascii().data(), result.fileSize.ascii().data());
-        
+
     appendEntry(filename, processFilesizeString(result.fileSize, result.type == FTPDirectoryEntry), processFileDateString(result.modifiedTime), result.type == FTPDirectoryEntry);
 }
 
@@ -302,8 +302,8 @@ bool FTPDirectoryDocumentParser::loadDocumentTemplate()
         return false;
     }
 
-    LegacyHTMLDocumentParser::insert(String(templateDocumentData->data(), templateDocumentData->size()));
-    
+    HTMLDocumentParser::insert(String(templateDocumentData->data(), templateDocumentData->size()));
+
     RefPtr<Element> tableElement = document()->getElementById("ftpDirectoryTable");
     if (!tableElement)
         LOG_ERROR("Unable to find element by id \"ftpDirectoryTable\" in the template document.");
@@ -329,7 +329,7 @@ bool FTPDirectoryDocumentParser::loadDocumentTemplate()
         body->appendChild(m_tableElement, ec);
     else
         document()->appendChild(m_tableElement, ec);
-        
+
     return true;
 }
 
@@ -340,10 +340,10 @@ void FTPDirectoryDocumentParser::createBasicDocument()
     // FIXME: Make this "basic document" more acceptable
 
     RefPtr<Element> bodyElement = document()->createElement(bodyTag, false);
-                            
+
     ExceptionCode ec;
     document()->appendChild(bodyElement, ec);
-    
+
     RefPtr<Element> tableElement = document()->createElement(tableTag, false);
     m_tableElement = static_cast<HTMLTableElement*>(tableElement.get());
     m_tableElement->setAttribute("id", "ftpDirectoryTable", ec);
@@ -360,14 +360,14 @@ void FTPDirectoryDocumentParser::append(const SegmentedString& source)
             createBasicDocument();
         ASSERT(m_tableElement);
     }
-        
+
     bool foundNewLine = false;
-    
+
     m_dest = m_buffer;
     SegmentedString str = source;
     while (!str.isEmpty()) {
         UChar c = *str;
-        
+
         if (c == '\r') {
             *m_dest++ = '\n';
             foundNewLine = true;
@@ -382,13 +382,13 @@ void FTPDirectoryDocumentParser::append(const SegmentedString& source)
             *m_dest++ = c;
             m_skipLF = false;
         }
-        
+
         str.advance();
-        
+
         // Maybe enlarge the buffer
         checkBuffer();
     }
-    
+
     if (!foundNewLine) {
         m_dest = m_buffer;
         return;
@@ -396,7 +396,7 @@ void FTPDirectoryDocumentParser::append(const SegmentedString& source)
 
     UChar* start = m_buffer;
     UChar* cursor = start;
-    
+
     while (cursor < m_dest) {
         if (*cursor == '\n') {
             m_carryOver.append(String(start, cursor - start));
@@ -408,7 +408,7 @@ void FTPDirectoryDocumentParser::append(const SegmentedString& source)
         } else 
             cursor++;
     }
-    
+
     // Copy the partial line we have left to the carryover buffer
     if (cursor - start > 1)
         m_carryOver.append(String(start, cursor - start - 1));
@@ -421,11 +421,11 @@ void FTPDirectoryDocumentParser::finish()
         parseAndAppendOneLine(m_carryOver);
         m_carryOver = String();
     }
-    
+
     m_tableElement = 0;
     fastFree(m_buffer);
-        
-    LegacyHTMLDocumentParser::finish();
+
+    HTMLDocumentParser::finish();
 }
 
 FTPDirectoryDocument::FTPDirectoryDocument(Frame* frame, const KURL& url)
diff --git a/WebCore/page/XSSAuditor.cpp b/WebCore/page/XSSAuditor.cpp
index 22506b2..b2764f9 100644
--- a/WebCore/page/XSSAuditor.cpp
+++ b/WebCore/page/XSSAuditor.cpp
@@ -34,8 +34,8 @@
 #include "DocumentLoader.h"
 #include "DOMWindow.h"
 #include "Frame.h"
+#include "HTMLEntityParser.h"
 #include "KURL.h"
-#include "LegacyPreloadScanner.h"
 #include "ResourceResponseBase.h"
 #include "ScriptSourceCode.h"
 #include "Settings.h"
@@ -277,7 +277,7 @@ String XSSAuditor::decodeHTMLEntities(const String& string, bool leaveUndecodabl
         if (leaveUndecodableEntitiesUntouched)
             sourceShadow = source;
         bool notEnoughCharacters = false;
-        unsigned entity = LegacyPreloadScanner::consumeEntity(source, notEnoughCharacters);
+        unsigned entity = consumeHTMLEntity(source, notEnoughCharacters);
         // We ignore notEnoughCharacters because we might as well use this loop
         // to copy the remaining characters into |result|.
 
diff --git a/WebCore/page/XSSAuditor.h b/WebCore/page/XSSAuditor.h
index 20e0a53..2b781f1 100644
--- a/WebCore/page/XSSAuditor.h
+++ b/WebCore/page/XSSAuditor.h
@@ -66,7 +66,7 @@ namespace WebCore {
     // * ScriptController::executeIfJavaScriptURL - used to evaluate JavaScript URLs.
     // * ScriptEventListener::createAttributeEventListener - used to create JavaScript event handlers.
     // * HTMLBaseElement::process - used to set the document base URL.
-    // * LegacyHTMLDocumentParser::parseTag - used to load external JavaScript scripts.
+    // * HTMLDocumentParser::shouldLoadExternalScriptFromSrc - used to load external JavaScript scripts.
     // * SubframeLoader::requestObject - used to load <object>/<embed> elements.
     //
     class XSSAuditor : public Noncopyable {
diff --git a/WebCore/platform/text/SegmentedString.cpp b/WebCore/platform/text/SegmentedString.cpp
index dc3f424..b9ff503 100644
--- a/WebCore/platform/text/SegmentedString.cpp
+++ b/WebCore/platform/text/SegmentedString.cpp
@@ -112,8 +112,7 @@ void SegmentedString::append(const SegmentedSubstring &s)
 void SegmentedString::prepend(const SegmentedSubstring &s)
 {
     ASSERT(!escaped());
-    // FIXME: Add this ASSERT once we've deleted the LegacyHTMLDocumentParser.
-    // ASSERT(!s.numberOfCharactersConsumed());
+    ASSERT(!s.numberOfCharactersConsumed());
     if (s.m_length) {
         // FIXME: We're assuming that the prepend were originally consumed by
         //        this SegmentedString.  We're also ASSERTing that s is a fresh

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list