Changeset 61985 in webkit
- Timestamp:
- Jun 28, 2010 12:56:10 AM (14 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 1 added
- 27 edited
- 3 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/Android.mk
r61950 r61985 115 115 dom/DOMImplementation.cpp \ 116 116 dom/DOMStringList.cpp \ 117 dom/DecodedDataDocumentParser.cpp \ 117 118 dom/Document.cpp \ 118 119 dom/DocumentFragment.cpp \ … … 159 160 dom/Range.cpp \ 160 161 dom/RegisteredEventListener.cpp \ 162 dom/ScriptableDocumentParser.cpp \ 161 163 dom/ScriptElement.cpp \ 162 164 dom/ScriptExecutionContext.cpp \ -
trunk/WebCore/CMakeLists.txt
r61950 r61985 772 772 dom/DOMImplementation.cpp 773 773 dom/DOMStringList.cpp 774 dom/DecodedDataDocumentParser.cpp 774 775 dom/DeviceOrientation.cpp 775 776 dom/DeviceOrientationEvent.cpp … … 817 818 dom/Range.cpp 818 819 dom/RegisteredEventListener.cpp 820 dom/ScriptableDocumentParser.cpp 819 821 dom/ScriptElement.cpp 820 822 dom/ScriptExecutionContext.cpp -
trunk/WebCore/ChangeLog
r61983 r61985 1 2010-06-28 Eric Seidel <eric@webkit.org> 2 3 Reviewed by Darin Adler. 4 5 Add a new baseclass for XML, HTML and Text DocumentParsers to clean up DocumentParser call sites 6 https://bugs.webkit.org/show_bug.cgi?id=41141 7 8 By splitting ScriptableDocumentParser and DecodedDataDocumentParser 9 out from DocumentParser we've made the DocumentParser and 10 RawDataDocumentParser classes simpler. 11 12 No functional change, thus no tests. 13 14 * Android.mk: 15 * CMakeLists.txt: 16 * GNUmakefile.am: 17 * WebCore.gypi: 18 * WebCore.pro: 19 * WebCore.vcproj/WebCore.vcproj: 20 * WebCore.xcodeproj/project.pbxproj: 21 * bindings/js/ScriptController.cpp: 22 (WebCore::ScriptController::eventHandlerLineNumber): 23 * css/CSSStyleSheet.cpp: 24 (WebCore::CSSStyleSheet::checkLoaded): 25 * dom/Document.cpp: 26 (WebCore::Document::scriptableDocumentParser): 27 (WebCore::Document::open): 28 (WebCore::Document::implicitOpen): 29 (WebCore::Document::implicitClose): 30 (WebCore::Document::removePendingSheet): 31 * dom/Document.h: 32 (WebCore::Document::parser): 33 * dom/DocumentParser.cpp: 34 (WebCore::DocumentParser::DocumentParser): 35 * dom/DocumentParser.h: 36 (WebCore::DocumentParser::asScriptableDocumentParser): 37 * dom/RawDataDocumentParser.h: 38 (WebCore::RawDataDocumentParser::finishWasCalled): 39 * dom/ScriptableDocumentParser.cpp: Copied from WebCore/html/HTMLEntityParser.h. 40 (WebCore::ScriptableDocumentParser::ScriptableDocumentParser): 41 * dom/ScriptableDocumentParser.h: Added. 42 (WebCore::ScriptableDocumentParser::isExecutingScript): 43 (WebCore::ScriptableDocumentParser::executeScriptsWaitingForStylesheets): 44 (WebCore::ScriptableDocumentParser::xssAuditor): 45 (WebCore::ScriptableDocumentParser::setXSSAuditor): 46 (WebCore::ScriptableDocumentParser::processingContentWrittenByScript): 47 (WebCore::ScriptableDocumentParser::asScriptableDocumentParser): 48 * dom/ViewportArguments.cpp: 49 (WebCore::parserLineNumber): 50 (WebCore::reportViewportWarning): 51 * dom/XMLDocumentParser.h: 52 * dom/XMLDocumentParserLibxml2.cpp: 53 (WebCore::XMLDocumentParser::XMLDocumentParser): 54 * html/HTMLDocumentParser.cpp: 55 (WebCore::HTMLDocumentParser::HTMLDocumentParser): 56 (WebCore::HTMLDocumentParser::shouldLoadExternalScriptFromSrc): 57 * html/HTMLDocumentParser.h: 58 * html/LegacyHTMLDocumentParser.cpp: 59 (WebCore::LegacyHTMLDocumentParser::LegacyHTMLDocumentParser): 60 (WebCore::LegacyHTMLDocumentParser::parseTag): 61 * html/LegacyHTMLDocumentParser.h: 62 (WebCore::LegacyHTMLDocumentParser::processingContentWrittenByScript): 63 * html/LegacyHTMLTreeBuilder.cpp: 64 (WebCore::LegacyHTMLTreeBuilder::reportErrorToConsole): 65 * loader/DocumentLoader.cpp: 66 * loader/DocumentWriter.cpp: 67 * loader/TextDocument.cpp: 68 (WebCore::TextDocumentParser::TextDocumentParser): 69 (WebCore::TextDocumentParser::finish): 70 * svg/SVGDocumentExtensions.cpp: 71 (WebCore::parserLineNumber): 72 (WebCore::reportMessage): 73 (WebCore::SVGDocumentExtensions::reportWarning): 74 (WebCore::SVGDocumentExtensions::reportError): 75 1 76 2010-06-27 Steve Falkenburg <sfalken@apple.com> 2 77 -
trunk/WebCore/GNUmakefile.am
r61964 r61985 779 779 WebCore/dom/DOMStringList.cpp \ 780 780 WebCore/dom/DOMStringList.h \ 781 WebCore/dom/DecodedDataDocumentParser.cpp \ 782 WebCore/dom/DecodedDataDocumentParser.h \ 781 783 WebCore/dom/DeviceOrientation.cpp \ 782 784 WebCore/dom/DeviceOrientation.h \ … … 882 884 WebCore/dom/RegisteredEventListener.cpp \ 883 885 WebCore/dom/RegisteredEventListener.h \ 886 WebCore/dom/ScriptableDocumentParser.cpp \ 887 WebCore/dom/ScriptableDocumentParser.h \ 884 888 WebCore/dom/ScriptElement.cpp \ 885 889 WebCore/dom/ScriptElement.h \ -
trunk/WebCore/WebCore.gypi
r61964 r61985 1106 1106 'dom/DOMStringList.cpp', 1107 1107 'dom/DOMStringList.h', 1108 'dom/DecodedDataDocumentParser.cpp', 1109 'dom/DecodedDataDocumentParser.h', 1108 1110 'dom/DeviceOrientation.cpp', 1109 1111 'dom/DeviceOrientation.h', … … 1210 1212 'dom/RegisteredEventListener.cpp', 1211 1213 'dom/RegisteredEventListener.h', 1214 'dom/ScriptableDocumentParser.cpp', 1215 'dom/ScriptableDocumentParser.h', 1212 1216 'dom/ScriptElement.cpp', 1213 1217 'dom/ScriptElement.h', -
trunk/WebCore/WebCore.pro
r61964 r61985 473 473 dom/CSSMappedAttributeDeclaration.cpp \ 474 474 dom/CustomEvent.cpp \ 475 dom/DecodedDataDocumentParser.cpp \ 475 476 dom/DeviceOrientation.cpp \ 476 477 dom/DeviceOrientationEvent.cpp \ … … 522 523 dom/RawDataDocumentParser.h \ 523 524 dom/RegisteredEventListener.cpp \ 525 dom/ScriptableDocumentParser.cpp \ 524 526 dom/ScriptElement.cpp \ 525 527 dom/ScriptExecutionContext.cpp \ -
trunk/WebCore/WebCore.vcproj/WebCore.vcproj
r61983 r61985 32138 32138 </File> 32139 32139 <File 32140 RelativePath="..\dom\DecodedDataDocumentParser.cpp" 32141 > 32142 </File> 32143 <File 32144 RelativePath="..\dom\DecodedDataDocumentParser.h" 32145 > 32146 </File> 32147 <File 32140 32148 RelativePath="..\dom\DeviceOrientation.cpp" 32141 32149 > … … 32551 32559 <File 32552 32560 RelativePath="..\dom\RegisteredEventListener.h" 32561 > 32562 </File> 32563 <File 32564 RelativePath="..\dom\ScriptableDocumentParser.cpp" 32565 > 32566 </File> 32567 <File 32568 RelativePath="..\dom\ScriptableDocumentParser.h" 32553 32569 > 32554 32570 </File> -
trunk/WebCore/WebCore.xcodeproj/project.pbxproj
r61964 r61985 2976 2976 A83E1C740E49042C00140B9C /* ScriptControllerMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = A83E1C720E49042B00140B9C /* ScriptControllerMac.mm */; }; 2977 2977 A84D827C11D333ED00972990 /* RawDataDocumentParser.h in Headers */ = {isa = PBXBuildFile; fileRef = A84D827B11D333ED00972990 /* RawDataDocumentParser.h */; }; 2978 A84D82C111D3474800972990 /* ScriptableDocumentParser.h in Headers */ = {isa = PBXBuildFile; fileRef = A84D82BF11D3474800972990 /* ScriptableDocumentParser.h */; }; 2979 A84D82C211D3474800972990 /* ScriptableDocumentParser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A84D82C011D3474800972990 /* ScriptableDocumentParser.cpp */; }; 2978 2980 A84EBD780CB8C89200079609 /* JSStyleSheetListCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A84EBD770CB8C89200079609 /* JSStyleSheetListCustom.cpp */; }; 2979 2981 A84EBD830CB8C97700079609 /* JSStyleSheetList.h in Headers */ = {isa = PBXBuildFile; fileRef = A84EBD810CB8C97700079609 /* JSStyleSheetList.h */; }; … … 3062 3064 A8A909AD0CBCD6B50029B807 /* RenderSVGTransformableContainer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A8A909AB0CBCD6B50029B807 /* RenderSVGTransformableContainer.cpp */; }; 3063 3065 A8C2280E11D4A59700D5A7D3 /* DocumentParser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A8C2280D11D4A59700D5A7D3 /* DocumentParser.cpp */; }; 3066 A8C228A111D5722E00D5A7D3 /* DecodedDataDocumentParser.h in Headers */ = {isa = PBXBuildFile; fileRef = A8C2289F11D5722E00D5A7D3 /* DecodedDataDocumentParser.h */; }; 3067 A8C228A211D5722E00D5A7D3 /* DecodedDataDocumentParser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A8C228A011D5722E00D5A7D3 /* DecodedDataDocumentParser.cpp */; }; 3064 3068 A8C4A7FD09D563270003AC8D /* StyledElement.h in Headers */ = {isa = PBXBuildFile; fileRef = A8C4A7EB09D563270003AC8D /* StyledElement.h */; settings = {ATTRIBUTES = (Private, ); }; }; 3065 3069 A8C4A7FE09D563270003AC8D /* StyledElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A8C4A7EC09D563270003AC8D /* StyledElement.cpp */; }; … … 8470 8474 A83E1C720E49042B00140B9C /* ScriptControllerMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ScriptControllerMac.mm; sourceTree = "<group>"; }; 8471 8475 A84D827B11D333ED00972990 /* RawDataDocumentParser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RawDataDocumentParser.h; sourceTree = "<group>"; }; 8476 A84D82BF11D3474800972990 /* ScriptableDocumentParser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScriptableDocumentParser.h; sourceTree = "<group>"; }; 8477 A84D82C011D3474800972990 /* ScriptableDocumentParser.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ScriptableDocumentParser.cpp; sourceTree = "<group>"; }; 8472 8478 A84EBD770CB8C89200079609 /* JSStyleSheetListCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSStyleSheetListCustom.cpp; sourceTree = "<group>"; }; 8473 8479 A84EBD810CB8C97700079609 /* JSStyleSheetList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSStyleSheetList.h; sourceTree = "<group>"; }; … … 8556 8562 A8A909AB0CBCD6B50029B807 /* RenderSVGTransformableContainer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderSVGTransformableContainer.cpp; sourceTree = "<group>"; }; 8557 8563 A8C2280D11D4A59700D5A7D3 /* DocumentParser.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DocumentParser.cpp; sourceTree = "<group>"; }; 8564 A8C2289F11D5722E00D5A7D3 /* DecodedDataDocumentParser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DecodedDataDocumentParser.h; sourceTree = "<group>"; }; 8565 A8C228A011D5722E00D5A7D3 /* DecodedDataDocumentParser.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DecodedDataDocumentParser.cpp; sourceTree = "<group>"; }; 8558 8566 A8C4A7EB09D563270003AC8D /* StyledElement.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = StyledElement.h; sourceTree = "<group>"; }; 8559 8567 A8C4A7EC09D563270003AC8D /* StyledElement.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = StyledElement.cpp; sourceTree = "<group>"; }; … … 16912 16920 5D15E3A90F9E6AC1009E0E3F /* XMLDocumentParserScope.cpp */, 16913 16921 5D15E3AA0F9E6AC1009E0E3F /* XMLDocumentParserScope.h */, 16922 A84D82BF11D3474800972990 /* ScriptableDocumentParser.h */, 16923 A84D82C011D3474800972990 /* ScriptableDocumentParser.cpp */, 16924 A8C2289F11D5722E00D5A7D3 /* DecodedDataDocumentParser.h */, 16925 A8C228A011D5722E00D5A7D3 /* DecodedDataDocumentParser.cpp */, 16914 16926 ); 16915 16927 path = dom; … … 19575 19587 8A844CFF11D3C17C0014065C /* NavigationTiming.h in Headers */, 19576 19588 8A844D0511D3C18E0014065C /* Performance.h in Headers */, 19589 A84D82C111D3474800972990 /* ScriptableDocumentParser.h in Headers */, 19590 A8C228A111D5722E00D5A7D3 /* DecodedDataDocumentParser.h in Headers */, 19577 19591 ); 19578 19592 runOnlyForDeploymentPostprocessing = 0; … … 21900 21914 8A844CFE11D3C17C0014065C /* NavigationTiming.cpp in Sources */, 21901 21915 8A844D0411D3C18E0014065C /* Performance.cpp in Sources */, 21916 A84D82C211D3474800972990 /* ScriptableDocumentParser.cpp in Sources */, 21917 A8C228A211D5722E00D5A7D3 /* DecodedDataDocumentParser.cpp in Sources */, 21902 21918 ); 21903 21919 runOnlyForDeploymentPostprocessing = 0; -
trunk/WebCore/bindings/js/ScriptController.cpp
r61640 r61985 22 22 #include "ScriptController.h" 23 23 24 #include " DocumentParser.h"24 #include "ScriptableDocumentParser.h" 25 25 #include "Event.h" 26 26 #include "EventNames.h" … … 239 239 { 240 240 // JSC expects 1-based line numbers, so we must add one here to get it right. 241 if (DocumentParser* parser = m_frame->document()->parser()) 241 ScriptableDocumentParser* parser = m_frame->document()->scriptableDocumentParser(); 242 if (parser) 242 243 return parser->lineNumber() + 1; 243 244 return 0; 244 245 } 245 246 246 247 bool ScriptController::processingUserGesture(DOMWrapperWorld* world) const 247 248 { -
trunk/WebCore/css/CSSStyleSheet.cpp
r61662 r61985 208 208 parent()->checkLoaded(); 209 209 210 // Avoid |this| being deleted by scripts that run via LegacyHTMLDocumentParser::executeScriptsWaitingForStylesheets(). 210 // Avoid |this| being deleted by scripts that run via 211 // ScriptableDocumentParser::executeScriptsWaitingForStylesheets(). 211 212 // See <rdar://problem/6622300>. 212 213 RefPtr<CSSStyleSheet> protector(this); -
trunk/WebCore/dom/DecodedDataDocumentParser.cpp
r61984 r61985 25 25 26 26 #include "config.h" 27 #include "D ocumentParser.h"27 #include "DecodedDataDocumentParser.h" 28 28 29 29 #include "DocumentWriter.h" … … 31 31 #include "TextResourceDecoder.h" 32 32 33 #include <wtf/Assertions.h>34 35 33 namespace WebCore { 36 34 37 D ocumentParser::DocumentParser(Document* document, bool viewSourceMode)38 : m_parserStopped(false)35 DecodedDataDocumentParser::DecodedDataDocumentParser(Document* document, bool viewSourceMode) 36 : DocumentParser(document) 39 37 , m_inViewSourceMode(viewSourceMode) 40 , m_document(document)41 , m_XSSAuditor(0)42 38 { 43 ASSERT(document);44 39 } 45 40 46 void D ocumentParser::appendBytes(DocumentWriter* writer , const char* data, int length, bool shouldFlush)41 void DecodedDataDocumentParser::appendBytes(DocumentWriter* writer , const char* data, int length, bool shouldFlush) 47 42 { 48 43 if (!length && !shouldFlush) -
trunk/WebCore/dom/DecodedDataDocumentParser.h
r61984 r61985 23 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 24 */ 25 26 #ifndef DecodedDataDocumentParser_h 27 #define DecodedDataDocumentParser_h 25 28 26 #include "config.h"27 29 #include "DocumentParser.h" 28 29 #include "DocumentWriter.h"30 #include "SegmentedString.h"31 #include "TextResourceDecoder.h"32 33 #include <wtf/Assertions.h>34 30 35 31 namespace WebCore { 36 32 37 DocumentParser::DocumentParser(Document* document, bool viewSourceMode) 38 : m_parserStopped(false) 39 , m_inViewSourceMode(viewSourceMode) 40 , m_document(document) 41 , m_XSSAuditor(0) 42 { 43 ASSERT(document); 33 class DecodedDataDocumentParser : public DocumentParser { 34 public: 35 // Only used by the XMLDocumentParser to communicate back to 36 // XMLHttpRequest if the responseXML was well formed. 37 virtual bool wellFormed() const { return true; } 38 39 bool inViewSourceMode() const { return m_inViewSourceMode; } 40 void setInViewSourceMode(bool mode) { m_inViewSourceMode = mode; } 41 42 protected: 43 DecodedDataDocumentParser(Document*, bool viewSourceMode = false); 44 45 private: 46 // append is used by DocumentWriter::replaceDocument 47 virtual void append(const SegmentedString&) = 0; 48 49 // appendBytes is used by DocumentWriter (the loader) 50 virtual void appendBytes(DocumentWriter*, const char* bytes, int length, bool flush); 51 52 bool m_inViewSourceMode; 53 }; 54 44 55 } 45 56 46 void DocumentParser::appendBytes(DocumentWriter* writer , const char* data, int length, bool shouldFlush) 47 { 48 if (!length && !shouldFlush) 49 return; 50 51 TextResourceDecoder* decoder = writer->createDecoderIfNeeded(); 52 String decoded = decoder->decode(data, length); 53 if (shouldFlush) 54 decoded += decoder->flush(); 55 if (decoded.isEmpty()) 56 return; 57 58 writer->reportDataRecieved(); 59 60 append(decoded); 61 } 62 63 }; 64 57 #endif // DecodedDataDocumentParser_h -
trunk/WebCore/dom/Document.cpp
r61975 r61985 1722 1722 } 1723 1723 1724 ScriptableDocumentParser* Document::scriptableDocumentParser() const 1725 { 1726 return parser() ? parser()->asScriptableDocumentParser() : 0; 1727 } 1728 1724 1729 void Document::open(Document* ownerDocument) 1725 1730 { … … 1731 1736 1732 1737 if (m_frame) { 1733 if (m_frame->loader()->isLoadingMainResource() || (parser() && parser()->isExecutingScript())) 1738 ScriptableDocumentParser* parser = scriptableDocumentParser(); 1739 if (m_frame->loader()->isLoadingMainResource() || (parser && parser->isExecutingScript())) 1734 1740 return; 1735 1741 1736 1742 if (m_frame->loader()->state() == FrameStateProvisional) 1737 1743 m_frame->loader()->stopAllLoaders(); … … 1770 1776 setParsing(true); 1771 1777 1772 if (m_frame) 1773 m_parser->setXSSAuditor(m_frame->script()->xssAuditor()); 1778 ScriptableDocumentParser* parser = scriptableDocumentParser(); 1779 if (m_frame && parser) 1780 parser->setXSSAuditor(m_frame->script()->xssAuditor()); 1774 1781 1775 1782 // If we reload, the animation controller sticks around and has … … 1856 1863 m_processingLoadEvent = true; 1857 1864 1858 m_wellFormed = m_parser && m_parser->wellFormed(); 1865 ScriptableDocumentParser* parser = scriptableDocumentParser(); 1866 m_wellFormed = parser && parser->wellFormed(); 1859 1867 1860 1868 // We have to clear the parser, in case someone document.write()s from the … … 2608 2616 2609 2617 updateStyleSelector(); 2610 2611 if (!m_pendingStylesheets && m_parser) 2612 m_parser->executeScriptsWaitingForStylesheets(); 2618 2619 ScriptableDocumentParser* parser = scriptableDocumentParser(); 2620 if (!m_pendingStylesheets && parser) 2621 parser->executeScriptsWaitingForStylesheets(); 2613 2622 2614 2623 if (!m_pendingStylesheets && m_gotoAnchorNeededAfterStylesheetsLoad && view()) -
trunk/WebCore/dom/Document.h
r61975 r61985 101 101 class RenderArena; 102 102 class RenderView; 103 class ScriptableDocumentParser; 103 104 class ScriptElementData; 104 105 class SecurityOrigin; … … 549 550 550 551 virtual DocumentParser* createParser(); 551 DocumentParser* parser() { return m_parser.get(); } 552 DocumentParser* parser() const { return m_parser.get(); } 553 ScriptableDocumentParser* scriptableDocumentParser() const; 552 554 553 555 bool printing() const { return m_printing; } -
trunk/WebCore/dom/DocumentParser.cpp
r61913 r61985 27 27 #include "DocumentParser.h" 28 28 29 #include "DocumentWriter.h"30 #include "SegmentedString.h"31 #include "TextResourceDecoder.h"32 33 29 #include <wtf/Assertions.h> 34 30 35 31 namespace WebCore { 36 32 37 DocumentParser::DocumentParser(Document* document , bool viewSourceMode)33 DocumentParser::DocumentParser(Document* document) 38 34 : m_parserStopped(false) 39 , m_inViewSourceMode(viewSourceMode)40 35 , m_document(document) 41 , m_XSSAuditor(0)42 36 { 43 37 ASSERT(document); 44 38 } 45 39 46 void DocumentParser::appendBytes(DocumentWriter* writer , const char* data, int length, bool shouldFlush)47 {48 if (!length && !shouldFlush)49 return;50 51 TextResourceDecoder* decoder = writer->createDecoderIfNeeded();52 String decoded = decoder->decode(data, length);53 if (shouldFlush)54 decoded += decoder->flush();55 if (decoded.isEmpty())56 return;57 58 writer->reportDataRecieved();59 60 append(decoded);61 }62 63 40 }; 64 41 -
trunk/WebCore/dom/DocumentParser.h
r61913 r61985 32 32 class DocumentWriter; 33 33 class LegacyHTMLTreeBuilder; 34 class LegacyHTMLDocumentParser;35 34 class SegmentedString; 36 class XSSAuditor;35 class ScriptableDocumentParser; 37 36 38 37 class DocumentParser : public Noncopyable { … … 40 39 virtual ~DocumentParser() { } 41 40 41 virtual ScriptableDocumentParser* asScriptableDocumentParser() { return 0; } 42 42 43 // insert is used by document.write 43 44 virtual void insert(const SegmentedString&) = 0; 45 44 46 // appendBytes is used by DocumentWriter (the loader) 45 virtual void appendBytes(DocumentWriter*, const char* bytes, int length, bool flush) ;47 virtual void appendBytes(DocumentWriter*, const char* bytes, int length, bool flush) = 0; 46 48 47 49 // FIXME: append() should be private, but DocumentWriter::replaceDocument … … 52 54 virtual bool finishWasCalled() = 0; 53 55 54 virtual bool isWaitingForScripts() const = 0;55 virtual bool isExecutingScript() const { return false; }56 57 56 virtual void stopParsing() { m_parserStopped = true; } 58 57 // FIXME: processingData() is only used by DocumentLoader::isLoadingInAPISense … … 61 60 virtual bool processingData() const { return false; } 62 61 63 virtual bool wellFormed() const { return true; } 64 65 virtual int lineNumber() const { return -1; } 66 virtual int columnNumber() const { return -1; } 67 68 virtual void executeScriptsWaitingForStylesheets() {} 69 62 // FIXME: Exposed for HTMLFormControlElement::removedFromTree. HTML DOM 63 // code should not need to reach into implementation details of the parser. 70 64 virtual LegacyHTMLTreeBuilder* htmlTreeBuilder() const { return 0; } 71 virtual LegacyHTMLDocumentParser* asHTMLDocumentParser() { return 0; }72 73 // FIXME: view source mode is only used by the HTML and Text74 // DocumentParsers and may not belong on the base-class.75 bool inViewSourceMode() const { return m_inViewSourceMode; }76 void setInViewSourceMode(bool mode) { m_inViewSourceMode = mode; }77 65 78 66 Document* document() const { return m_document; } 79 67 80 XSSAuditor* xssAuditor() const { return m_XSSAuditor; }81 void setXSSAuditor(XSSAuditor* auditor) { m_XSSAuditor = auditor; }82 83 68 protected: 84 DocumentParser(Document* , bool viewSourceMode = false);69 DocumentParser(Document*); 85 70 86 71 // The parser has buffers, so parsing may continue even after … … 88 73 // even when it has buffered data. 89 74 bool m_parserStopped; 90 bool m_inViewSourceMode;91 75 92 76 // Every DocumentParser needs a pointer back to the document. 93 77 Document* m_document; 94 // The XSSAuditor associated with this document parser.95 XSSAuditor* m_XSSAuditor;96 78 }; 97 79 -
trunk/WebCore/dom/RawDataDocumentParser.h
r61913 r61985 63 63 return false; 64 64 } 65 66 virtual bool isWaitingForScripts() const { return false; }67 65 }; 68 66 -
trunk/WebCore/dom/ScriptableDocumentParser.cpp
r61984 r61985 25 25 26 26 #include "config.h" 27 #include "DocumentParser.h" 28 29 #include "DocumentWriter.h" 30 #include "SegmentedString.h" 31 #include "TextResourceDecoder.h" 32 33 #include <wtf/Assertions.h> 27 #include "ScriptableDocumentParser.h" 34 28 35 29 namespace WebCore { 36 30 37 DocumentParser::DocumentParser(Document* document, bool viewSourceMode) 38 : m_parserStopped(false) 39 , m_inViewSourceMode(viewSourceMode) 40 , m_document(document) 41 , m_XSSAuditor(0) 31 ScriptableDocumentParser::ScriptableDocumentParser(Document* document, bool viewSourceMode) 32 : DecodedDataDocumentParser(document, viewSourceMode) 33 , m_xssAuditor(0) 42 34 { 43 ASSERT(document);44 }45 46 void DocumentParser::appendBytes(DocumentWriter* writer , const char* data, int length, bool shouldFlush)47 {48 if (!length && !shouldFlush)49 return;50 51 TextResourceDecoder* decoder = writer->createDecoderIfNeeded();52 String decoded = decoder->decode(data, length);53 if (shouldFlush)54 decoded += decoder->flush();55 if (decoded.isEmpty())56 return;57 58 writer->reportDataRecieved();59 60 append(decoded);61 35 } 62 36 63 37 }; 64 -
trunk/WebCore/dom/ViewportArguments.cpp
r61104 r61985 34 34 #include "Page.h" 35 35 #include "PlatformString.h" 36 #include " DocumentParser.h"36 #include "ScriptableDocumentParser.h" 37 37 38 38 namespace WebCore { … … 104 104 } 105 105 106 // FIXME: Why is this different from SVGDocumentExtensions parserLineNumber? 107 // FIXME: Callers should probably use ScriptController::eventHandlerLineNumber() 108 static int parserLineNumber(Document* document) 109 { 110 if (!document) 111 return 0; 112 ScriptableDocumentParser* parser = document->scriptableDocumentParser(); 113 if (!parser) 114 return 0; 115 return parser->lineNumber() + 1; 116 } 117 106 118 void reportViewportWarning(Document* document, ViewportErrorCode errorCode, const String& replacement) 107 119 { 108 DocumentParser* parser = document->parser();109 110 120 Frame* frame = document->frame(); 111 121 if (!frame) … … 115 125 message.replace("%replacement", replacement); 116 126 117 frame->domWindow()->console()->addMessage(HTMLMessageSource, LogMessageType, viewportErrorMessageLevel(errorCode), message, parser ? parser->lineNumber() + 1 : 0, document->url().string());127 frame->domWindow()->console()->addMessage(HTMLMessageSource, LogMessageType, viewportErrorMessageLevel(errorCode), message, parserLineNumber(document), document->url().string()); 118 128 } 119 129 -
trunk/WebCore/dom/XMLDocumentParser.h
r61904 r61985 28 28 #include "CachedResourceClient.h" 29 29 #include "CachedResourceHandle.h" 30 #include "FragmentScriptingPermission.h" 31 #include "ScriptableDocumentParser.h" 30 32 #include "SegmentedString.h" 31 33 #include "StringHash.h" 32 #include "DocumentParser.h"33 #include "FragmentScriptingPermission.h"34 34 #include <wtf/HashMap.h> 35 35 #include <wtf/OwnPtr.h> … … 71 71 #endif 72 72 73 class XMLDocumentParser : public DocumentParser, public CachedResourceClient {73 class XMLDocumentParser : public ScriptableDocumentParser, public CachedResourceClient { 74 74 public: 75 75 XMLDocumentParser(Document*, FrameView* = 0); -
trunk/WebCore/dom/XMLDocumentParserLibxml2.cpp
r61904 r61985 524 524 525 525 XMLDocumentParser::XMLDocumentParser(Document* document, FrameView* frameView) 526 : DocumentParser(document)526 : ScriptableDocumentParser(document) 527 527 , m_view(frameView) 528 528 , m_context(0) … … 551 551 552 552 XMLDocumentParser::XMLDocumentParser(DocumentFragment* fragment, Element* parentElement, FragmentScriptingPermission scriptingPermission) 553 : DocumentParser(fragment->document())553 : ScriptableDocumentParser(fragment->document()) 554 554 , m_view(0) 555 555 , m_context(0) -
trunk/WebCore/html/HTMLDocumentParser.cpp
r61956 r61985 67 67 68 68 HTMLDocumentParser::HTMLDocumentParser(HTMLDocument* document, bool reportErrors) 69 : DocumentParser(document)69 : ScriptableDocumentParser(document) 70 70 , m_tokenizer(new HTMLTokenizer) 71 71 , m_scriptRunner(new HTMLScriptRunner(document, this)) … … 81 81 // minimize code duplication between these constructors. 82 82 HTMLDocumentParser::HTMLDocumentParser(DocumentFragment* fragment, FragmentScriptingPermission scriptingPermission) 83 : DocumentParser(fragment->document())83 : ScriptableDocumentParser(fragment->document()) 84 84 , m_tokenizer(new HTMLTokenizer) 85 85 , m_treeBuilder(new HTMLTreeBuilder(m_tokenizer.get(), fragment, scriptingPermission)) … … 358 358 bool HTMLDocumentParser::shouldLoadExternalScriptFromSrc(const AtomicString& srcValue) 359 359 { 360 if (! m_XSSAuditor)360 if (!xssAuditor()) 361 361 return true; 362 return m_XSSAuditor->canLoadExternalScriptFromSrc(srcValue);362 return xssAuditor()->canLoadExternalScriptFromSrc(srcValue); 363 363 } 364 364 -
trunk/WebCore/html/HTMLDocumentParser.h
r61904 r61985 29 29 #include "CachedResourceClient.h" 30 30 #include "FragmentScriptingPermission.h" 31 #include "HTMLInputStream.h" 31 32 #include "HTMLScriptRunnerHost.h" 32 33 #include "HTMLToken.h" 33 #include " HTMLInputStream.h"34 #include "ScriptableDocumentParser.h" 34 35 #include "SegmentedString.h" 35 #include "DocumentParser.h"36 36 #include "Timer.h" 37 37 #include <wtf/OwnPtr.h> … … 51 51 class ScriptSourceCode; 52 52 53 class HTMLDocumentParser : public DocumentParser, HTMLScriptRunnerHost, CachedResourceClient {53 class HTMLDocumentParser : public ScriptableDocumentParser, HTMLScriptRunnerHost, CachedResourceClient { 54 54 public: 55 55 // FIXME: These constructors should be made private and replaced by create() methods. -
trunk/WebCore/html/LegacyHTMLDocumentParser.cpp
r61904 r61985 148 148 149 149 LegacyHTMLDocumentParser::LegacyHTMLDocumentParser(HTMLDocument* document, bool reportErrors) 150 : DocumentParser(document)150 : ScriptableDocumentParser(document) 151 151 , m_buffer(0) 152 152 , m_scriptCode(0) … … 168 168 169 169 LegacyHTMLDocumentParser::LegacyHTMLDocumentParser(HTMLViewSourceDocument* document) 170 : DocumentParser(document, true)170 : ScriptableDocumentParser(document, true) 171 171 , m_buffer(0) 172 172 , m_scriptCode(0) … … 187 187 188 188 LegacyHTMLDocumentParser::LegacyHTMLDocumentParser(DocumentFragment* frag, FragmentScriptingPermission scriptingPermission) 189 : DocumentParser(frag->document())189 : ScriptableDocumentParser(frag->document()) 190 190 , m_buffer(0) 191 191 , m_scriptCode(0) … … 1392 1392 if (m_currentToken.beginTag && m_currentToken.tagName == scriptTag && !inViewSourceMode() && !m_treeBuilder->skipMode() && m_attrName == srcAttr) { 1393 1393 String context(m_rawAttributeBeforeValue.data(), m_rawAttributeBeforeValue.size()); 1394 if ( m_XSSAuditor && !m_XSSAuditor->canLoadExternalScriptFromSrc(attributeValue))1394 if (xssAuditor() && !xssAuditor()->canLoadExternalScriptFromSrc(attributeValue)) 1395 1395 attributeValue = blankURL().string(); 1396 1396 } … … 1429 1429 if (m_currentToken.beginTag && m_currentToken.tagName == scriptTag && !inViewSourceMode() && !m_treeBuilder->skipMode() && m_attrName == srcAttr) { 1430 1430 String context(m_rawAttributeBeforeValue.data(), m_rawAttributeBeforeValue.size()); 1431 if ( m_XSSAuditor && !m_XSSAuditor->canLoadExternalScriptFromSrc(attributeValue))1431 if (xssAuditor() && !xssAuditor()->canLoadExternalScriptFromSrc(attributeValue)) 1432 1432 attributeValue = blankURL().string(); 1433 1433 } -
trunk/WebCore/html/LegacyHTMLDocumentParser.h
r61904 r61985 29 29 #include "FragmentScriptingPermission.h" 30 30 #include "NamedNodeMap.h" 31 #include "ScriptableDocumentParser.h" 31 32 #include "SegmentedString.h" 32 33 #include "Timer.h" 33 #include "DocumentParser.h"34 34 #include <wtf/Deque.h> 35 35 #include <wtf/OwnPtr.h> … … 141 141 // down into a separate HTML tokenizer class. 142 142 143 class LegacyHTMLDocumentParser : public DocumentParser, public CachedResourceClient {143 class LegacyHTMLDocumentParser : public ScriptableDocumentParser, public CachedResourceClient { 144 144 public: 145 145 LegacyHTMLDocumentParser(HTMLDocument*, bool reportErrors); … … 151 151 void setForceSynchronous(bool force); 152 152 153 // Exposed for LegacyHTMLTreeBuilder::reportErrorToConsole154 bool processingContentWrittenByScript() const { return m_src.excludeLineNumbers(); }155 156 153 static void parseDocumentFragment(const String&, DocumentFragment*, FragmentScriptingPermission = FragmentScriptingAllowed); 157 154 … … 162 159 163 160 private: 164 // DocumentParser161 // ScriptableDocumentParser 165 162 virtual void append(const SegmentedString&); 166 163 virtual bool finishWasCalled(); … … 173 170 virtual int columnNumber() const { return 1; } 174 171 172 virtual bool processingContentWrittenByScript() const { return m_src.excludeLineNumbers(); } 173 175 174 virtual void executeScriptsWaitingForStylesheets(); 176 175 177 176 virtual LegacyHTMLTreeBuilder* htmlTreeBuilder() const { return m_treeBuilder.get(); } 178 virtual LegacyHTMLDocumentParser* asHTMLDocumentParser() { return this; }179 177 180 178 class State; -
trunk/WebCore/html/LegacyHTMLTreeBuilder.cpp
r61835 r61985 1648 1648 if (!frame) 1649 1649 return; 1650 1651 int lineNumber = m_document->parser()->lineNumber() + 1; 1650 1651 ScriptableDocumentParser* parser = m_document->scriptableDocumentParser(); 1652 int lineNumber = parser->lineNumber() + 1; 1652 1653 1653 1654 AtomicString tag1; … … 1675 1676 1676 1677 String message; 1677 // FIXME: This doesn't work for the new HTMLDocumentParser and should. 1678 LegacyHTMLDocumentParser* htmlParser = m_document->parser()->asHTMLDocumentParser(); 1679 if (htmlParser && htmlParser->processingContentWrittenByScript()) 1678 if (parser->processingContentWrittenByScript()) 1680 1679 message += htmlParserDocumentWriteMessage(); 1681 1680 message += errorMsg; -
trunk/WebCore/loader/DocumentLoader.cpp
r61105 r61985 36 36 #include "DocLoader.h" 37 37 #include "Document.h" 38 #include "DocumentParser.h" 38 39 #include "Event.h" 39 40 #include "Frame.h" … … 47 48 #include "Settings.h" 48 49 #include "SharedBuffer.h" 49 #include "XMLDocumentParser.h"50 50 51 51 #include <wtf/Assertions.h> -
trunk/WebCore/loader/DocumentWriter.cpp
r61913 r61985 39 39 #include "PlaceholderDocument.h" 40 40 #include "PluginDocument.h" 41 #include "RawDataDocumentParser.h" 42 #include "ScriptableDocumentParser.h" 41 43 #include "SecurityOrigin.h" 42 44 #include "SegmentedString.h" … … 44 46 #include "SinkDocument.h" 45 47 #include "TextResourceDecoder.h" 46 #include "DocumentParser.h" 48 47 49 48 50 namespace WebCore { -
trunk/WebCore/loader/TextDocument.cpp
r61904 r61985 26 26 #include "TextDocument.h" 27 27 28 #include "D ocumentParser.h"28 #include "DecodedDataDocumentParser.h" 29 29 #include "Element.h" 30 30 #include "HTMLNames.h" … … 39 39 using namespace HTMLNames; 40 40 41 class TextDocumentParser : public DocumentParser { 41 // FIXME: TextDocumentParser could just be an HTMLDocumentParser 42 // which started the Tokenizer in the PlainText state. 43 class TextDocumentParser : public DecodedDataDocumentParser { 42 44 public: 43 45 TextDocumentParser(Document*); … … 50 52 virtual void finish(); 51 53 virtual bool finishWasCalled(); 52 virtual bool isWaitingForScripts() const; 53 54 54 55 inline void checkBuffer(int len = 10) 55 56 { … … 64 65 } 65 66 67 private: 66 68 Element* m_preElement; 67 69 … … 74 76 75 77 TextDocumentParser::TextDocumentParser(Document* document) 76 : D ocumentParser(document)78 : DecodedDataDocumentParser(document) 77 79 , m_preElement(0) 78 80 , m_skipLF(false) … … 85 87 86 88 TextDocumentParser::TextDocumentParser(HTMLViewSourceDocument* document) 87 : D ocumentParser(document, true)89 : DecodedDataDocumentParser(document, true) 88 90 , m_preElement(0) 89 91 , m_skipLF(false) … … 175 177 m_dest = 0; 176 178 179 // FIXME: Should this call finishParsing even if m_parserStopped is true? 180 // See equivalent implementation in RawDataDocumentParser. 177 181 document()->finishedParsing(); 178 182 } … … 185 189 } 186 190 187 bool TextDocumentParser::isWaitingForScripts() const188 {189 // A text document is never waiting for scripts190 return false;191 }192 193 191 TextDocument::TextDocument(Frame* frame, const KURL& url) 194 192 : HTMLDocument(frame, url) -
trunk/WebCore/svg/SVGDocumentExtensions.cpp
r61104 r61985 38 38 #include "SVGSVGElement.h" 39 39 #include "SMILTimeContainer.h" 40 #include " XMLDocumentParser.h"40 #include "ScriptableDocumentParser.h" 41 41 #include "ScriptController.h" 42 42 … … 126 126 } 127 127 128 // FIXME: Callers should probably use ScriptController::eventHandlerLineNumber() 129 static int parserLineNumber(Document* document) 130 { 131 ScriptableDocumentParser* parser = document->scriptableDocumentParser(); 132 if (!parser) 133 return 1; 134 return parser->lineNumber(); 135 } 136 137 static void reportMessage(Document* document, MessageLevel level, const String& message) 138 { 139 if (Frame* frame = document->frame()) 140 frame->domWindow()->console()->addMessage(JSMessageSource, LogMessageType, level, message, parserLineNumber(document), String()); 141 } 142 128 143 void SVGDocumentExtensions::reportWarning(const String& message) 129 144 { 130 if (Frame* frame = m_doc->frame()) 131 frame->domWindow()->console()->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, "Warning: " + message, m_doc->parser() ? m_doc->parser()->lineNumber() : 1, String()); 145 reportMessage(m_doc, WarningMessageLevel, "Warning: " + message); 132 146 } 133 147 134 148 void SVGDocumentExtensions::reportError(const String& message) 135 149 { 136 if (Frame* frame = m_doc->frame()) 137 frame->domWindow()->console()->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, "Error: " + message, m_doc->parser() ? m_doc->parser()->lineNumber() : 1, String()); 150 reportMessage(m_doc, ErrorMessageLevel, "Error: " + message); 138 151 } 139 152
Note: See TracChangeset
for help on using the changeset viewer.