Changeset 61913 in webkit
- Timestamp:
- Jun 25, 2010 4:14:00 PM (14 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 15 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/Android.mk
r61818 r61913 114 114 dom/ContainerNode.cpp \ 115 115 dom/DOMImplementation.cpp \ 116 116 dom/DOMStringList.cpp \ 117 117 dom/Document.cpp \ 118 118 dom/DocumentFragment.cpp \ 119 dom/DocumentParser.cpp \ 119 120 dom/DocumentType.cpp \ 120 121 dom/DynamicNodeList.cpp \ -
trunk/WebCore/CMakeLists.txt
r61818 r61913 774 774 dom/Document.cpp 775 775 dom/DocumentFragment.cpp 776 dom/DocumentParser.cpp 776 777 dom/DocumentType.cpp 777 778 dom/DynamicNodeList.cpp -
trunk/WebCore/ChangeLog
r61910 r61913 47 47 * rendering/RenderThemeChromiumLinux.cpp: improve stock colors to get 48 48 better contrast and integration with stock chrome theme 49 50 2010-06-25 Eric Seidel <eric@webkit.org> 51 52 Reviewed by Adam Barth. 53 54 Move decoding into DocumentParser to further simplify RawDataDocumentParser and DocumentWriter 55 https://bugs.webkit.org/show_bug.cgi?id=41202 56 57 The silly thing about this patch is that none of the 58 RawDataDocumentParser subclasses actually use any of the 59 data passed to them via appendBytes. 60 61 This makes the relationship between DocumentWriter and 62 DocumentParser slightly more confusing, however I think this 63 DocumentParser API is slightly nicer. 64 65 Next step is to split DecodedDataDocumentParser out from 66 DocumentParser, and then the base DocumentParser won't know 67 anything about decoding or SegmentedString. 68 69 No functional change, thus no tests. 70 71 * WebCore.xcodeproj/project.pbxproj: 72 * dom/DocumentParser.h: 73 * dom/RawDataDocumentParser.h: 74 * loader/DocumentWriter.cpp: 75 (WebCore::DocumentWriter::replaceDocument): 76 (WebCore::DocumentWriter::createDecoderIfNeeded): 77 (WebCore::DocumentWriter::reportDataRecieved): 78 (WebCore::DocumentWriter::addData): 79 * loader/DocumentWriter.h: 80 * loader/ImageDocument.cpp: 81 (WebCore::ImageDocumentParser::appendBytes): 82 * loader/MediaDocument.cpp: 83 (WebCore::MediaDocumentParser::appendBytes): 84 * loader/PluginDocument.cpp: 85 (WebCore::PluginDocumentParser::appendBytes): 86 * loader/SinkDocument.cpp: 87 (WebCore::SinkDocumentParser::SinkDocumentParser): 88 (WebCore::SinkDocumentParser::appendBytes): 89 (WebCore::SinkDocument::createParser): 49 90 50 91 2010-06-25 Eric Seidel <eric@webkit.org> -
trunk/WebCore/GNUmakefile.am
r61818 r61913 780 780 WebCore/dom/DeviceOrientationEvent.h \ 781 781 WebCore/dom/Document.cpp \ 782 WebCore/dom/DocumentParser.cpp \ 782 783 WebCore/dom/Document.h \ 783 784 WebCore/dom/DocumentFragment.cpp \ -
trunk/WebCore/WebCore.gypi
r61789 r61913 1111 1111 'dom/DocumentFragment.h', 1112 1112 'dom/DocumentMarker.h', 1113 'dom/DocumentParser.cpp', 1114 'dom/DocumentParser.h', 1113 1115 'dom/DocumentType.cpp', 1114 1116 'dom/DocumentType.h', … … 1232 1234 'dom/TouchList.cpp', 1233 1235 'dom/TouchList.h', 1234 'dom/DocumentParser.h',1235 1236 'dom/TransformSourceLibxslt.cpp', 1236 1237 'dom/TransformSource.h', -
trunk/WebCore/WebCore.pro
r61863 r61913 476 476 dom/Document.cpp \ 477 477 dom/DocumentFragment.cpp \ 478 dom/DocumentParser.cpp \ 478 479 dom/DocumentType.cpp \ 479 480 dom/DOMImplementation.cpp \ -
trunk/WebCore/WebCore.xcodeproj/project.pbxproj
r61818 r61913 3053 3053 A8A909AC0CBCD6B50029B807 /* RenderSVGTransformableContainer.h in Headers */ = {isa = PBXBuildFile; fileRef = A8A909AA0CBCD6B50029B807 /* RenderSVGTransformableContainer.h */; }; 3054 3054 A8A909AD0CBCD6B50029B807 /* RenderSVGTransformableContainer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A8A909AB0CBCD6B50029B807 /* RenderSVGTransformableContainer.cpp */; }; 3055 A8C2280E11D4A59700D5A7D3 /* DocumentParser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A8C2280D11D4A59700D5A7D3 /* DocumentParser.cpp */; }; 3055 3056 A8C4A7FD09D563270003AC8D /* StyledElement.h in Headers */ = {isa = PBXBuildFile; fileRef = A8C4A7EB09D563270003AC8D /* StyledElement.h */; settings = {ATTRIBUTES = (Private, ); }; }; 3056 3057 A8C4A7FE09D563270003AC8D /* StyledElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A8C4A7EC09D563270003AC8D /* StyledElement.cpp */; }; … … 8535 8536 A8A909AA0CBCD6B50029B807 /* RenderSVGTransformableContainer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderSVGTransformableContainer.h; sourceTree = "<group>"; }; 8536 8537 A8A909AB0CBCD6B50029B807 /* RenderSVGTransformableContainer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderSVGTransformableContainer.cpp; sourceTree = "<group>"; }; 8538 A8C2280D11D4A59700D5A7D3 /* DocumentParser.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DocumentParser.cpp; sourceTree = "<group>"; }; 8537 8539 A8C4A7EB09D563270003AC8D /* StyledElement.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = StyledElement.h; sourceTree = "<group>"; }; 8538 8540 A8C4A7EC09D563270003AC8D /* StyledElement.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = StyledElement.cpp; sourceTree = "<group>"; }; … … 16624 16626 isa = PBXGroup; 16625 16627 children = ( 16626 A84D827B11D333ED00972990 /* RawDataDocumentParser.h */,16627 16628 E1C4DE6D0EA75C650023CCD6 /* ActiveDOMObject.cpp */, 16628 16629 E1C4DE680EA75C1E0023CCD6 /* ActiveDOMObject.h */, … … 16692 16693 1A494ED50A123F1A00FDAFC1 /* DocumentFragment.idl */, 16693 16694 ED2BA83B09A24B91006C0AC4 /* DocumentMarker.h */, 16695 A8C2280D11D4A59700D5A7D3 /* DocumentParser.cpp */, 16694 16696 BCCFBAE70B5152ED0001F1D7 /* DocumentParser.h */, 16695 16697 A8185F3209765765005826D9 /* DocumentType.cpp */, … … 16737 16739 93831B560D087D6000E5C984 /* ExceptionCode.cpp */, 16738 16740 935FBCF109BA143B00E230B1 /* ExceptionCode.h */, 16741 A853123C11D0471B00D4D077 /* FragmentScriptingPermission.h */, 16739 16742 08700BE60F086C5300919419 /* InputElement.cpp */, 16740 16743 08591AA40F085C4E009BACB1 /* InputElement.h */, … … 16819 16822 D23CA56B0AB0EB8D005108A5 /* RangeException.h */, 16820 16823 D23CA5480AB0E983005108A5 /* RangeException.idl */, 16824 A84D827B11D333ED00972990 /* RawDataDocumentParser.h */, 16821 16825 85031B350A44EFC700F992E0 /* RegisteredEventListener.cpp */, 16822 16826 85031B360A44EFC700F992E0 /* RegisteredEventListener.h */, … … 16878 16882 5D15E3A90F9E6AC1009E0E3F /* XMLDocumentParserScope.cpp */, 16879 16883 5D15E3AA0F9E6AC1009E0E3F /* XMLDocumentParserScope.h */, 16880 A853123C11D0471B00D4D077 /* FragmentScriptingPermission.h */,16881 16884 ); 16882 16885 path = dom; … … 21858 21861 A8E6A78211D1661B00311F4A /* HTMLParserScheduler.cpp in Sources */, 21859 21862 CEA3949C11D45CDA003094CF /* StaticHashSetNodeList.cpp in Sources */, 21863 A8C2280E11D4A59700D5A7D3 /* DocumentParser.cpp in Sources */, 21860 21864 ); 21861 21865 runOnlyForDeploymentPostprocessing = 0; -
trunk/WebCore/dom/DocumentParser.cpp
r61912 r61913 1 1 /* 2 * Copyright (C) 2010 Apple Inc. All rights reserved.2 * Copyright (C) 2010 Google, Inc. All Rights Reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 11 11 * documentation and/or other materials provided with the distribution. 12 12 * 13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER,INC. ``AS IS'' AND ANY13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY 14 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 15 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER,INC. OR16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR 17 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 18 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, … … 21 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 24 */ 25 25 26 26 #include "config.h" 27 #include " SinkDocument.h"27 #include "DocumentParser.h" 28 28 29 #include "RawDataDocumentParser.h" 29 #include "DocumentWriter.h" 30 #include "SegmentedString.h" 31 #include "TextResourceDecoder.h" 32 33 #include <wtf/Assertions.h> 30 34 31 35 namespace WebCore { 32 36 33 SinkDocument::SinkDocument(Frame* frame, const KURL& url) 34 : HTMLDocument(frame, url) 37 DocumentParser::DocumentParser(Document* document, bool viewSourceMode) 38 : m_parserStopped(false) 39 , m_inViewSourceMode(viewSourceMode) 40 , m_document(document) 41 , m_XSSAuditor(0) 35 42 { 36 setParseMode(Compat);43 ASSERT(document); 37 44 } 38 45 39 DocumentParser* SinkDocument::createParser()46 void DocumentParser::appendBytes(DocumentWriter* writer , const char* data, int length, bool shouldFlush) 40 47 { 41 // The basic RawDataDocumentParser does nothing with the data 42 // which is sufficient for our purposes here. 43 return new RawDataDocumentParser(this); 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); 44 61 } 45 62 46 } // namespace WebCore 63 }; 64 -
trunk/WebCore/dom/DocumentParser.h
r61904 r61913 25 25 #define DocumentParser_h 26 26 27 #include <wtf/ Assertions.h>27 #include <wtf/Noncopyable.h> 28 28 29 29 namespace WebCore { 30 30 31 31 class Document; 32 class DocumentWriter; 32 33 class LegacyHTMLTreeBuilder; 33 34 class LegacyHTMLDocumentParser; … … 39 40 virtual ~DocumentParser() { } 40 41 41 // insert is use by document.write42 // insert is used by document.write 42 43 virtual void insert(const SegmentedString&) = 0; 43 // apend is used by DocumentWriter (the loader) 44 // appendBytes is used by DocumentWriter (the loader) 45 virtual void appendBytes(DocumentWriter*, const char* bytes, int length, bool flush); 46 47 // FIXME: append() should be private, but DocumentWriter::replaceDocument 48 // uses it for now. 44 49 virtual void append(const SegmentedString&) = 0; 45 50 46 51 virtual void finish() = 0; 47 52 virtual bool finishWasCalled() = 0; 53 48 54 virtual bool isWaitingForScripts() const = 0; 49 55 virtual bool isExecutingScript() const { return false; } … … 54 60 // actually implements it. 55 61 virtual bool processingData() const { return false; } 56 57 virtual bool wantsRawData() const { return false; }58 virtual bool writeRawData(const char* /*data*/, int /*length*/)59 {60 ASSERT_NOT_REACHED();61 return false;62 }63 62 64 63 virtual bool wellFormed() const { return true; } … … 83 82 84 83 protected: 85 DocumentParser(Document* document, bool viewSourceMode = false) 86 : m_parserStopped(false) 87 , m_inViewSourceMode(viewSourceMode) 88 , m_document(document) 89 , m_XSSAuditor(0) 90 { 91 ASSERT(document); 92 } 84 DocumentParser(Document*, bool viewSourceMode = false); 93 85 94 86 // The parser has buffers, so parsing may continue even after -
trunk/WebCore/dom/RawDataDocumentParser.h
r61904 r61913 31 31 namespace WebCore { 32 32 33 // FIXME: It seems wrong that RawDataDocumentParser is a subclass of34 // DocumentParser. RawDataDocumentParser, just wants to override an earlier35 // version of write() before the data is decoded. Seems the decoding could36 // move into the base-class DocumentParser, and then RawDataDocumentParser37 // would just be short-circuting. That could simplify some of the38 // DocumentWriter logic.39 33 class RawDataDocumentParser : public DocumentParser { 40 34 public: … … 71 65 72 66 virtual bool isWaitingForScripts() const { return false; } 73 74 virtual bool wantsRawData() const { return true; }75 virtual bool writeRawData(const char*, int) { return false; }76 67 }; 77 68 -
trunk/WebCore/loader/DocumentWriter.cpp
r61904 r61913 74 74 } 75 75 76 // FIXME: If we wanted to support the <img src='javascript:'imagedata'>77 // case then we would need to call addData(char*, int) instead.76 // FIXME: This should call DocumentParser::appendBytes instead of append 77 // to support RawDataDocumentParsers. 78 78 if (DocumentParser* parser = m_frame->document()->parser()) 79 79 parser->append(source); … … 144 144 } 145 145 146 void DocumentWriter::addData(const char* str, int len, bool flush) 147 { 148 if (len == 0 && !flush) 149 return; 150 151 if (len == -1) 152 len = strlen(str); 153 154 DocumentParser* parser = m_frame->document()->parser(); 155 if (parser && parser->wantsRawData()) { 156 if (len > 0) 157 parser->writeRawData(str, len); 158 return; 159 } 160 146 TextResourceDecoder* DocumentWriter::createDecoderIfNeeded() 147 { 161 148 if (!m_decoder) { 162 149 if (Settings* settings = m_frame->settings()) { … … 188 175 m_frame->document()->setDecoder(m_decoder.get()); 189 176 } 190 191 String decoded = m_decoder->decode(str, len); 192 if (flush) 193 decoded += m_decoder->flush(); 194 if (decoded.isEmpty()) 195 return; 196 177 return m_decoder.get(); 178 } 179 180 void DocumentWriter::reportDataRecieved() 181 { 182 ASSERT(m_decoder); 197 183 if (!m_receivedData) { 198 184 m_receivedData = true; … … 201 187 m_frame->document()->recalcStyle(Node::Force); 202 188 } 203 204 if (parser) { 205 ASSERT(!parser->wantsRawData()); 206 parser->append(decoded); 207 } 189 } 190 191 void DocumentWriter::addData(const char* str, int len, bool flush) 192 { 193 if (len == -1) 194 len = strlen(str); 195 196 DocumentParser* parser = m_frame->document()->parser(); 197 if (parser) 198 parser->appendBytes(this, str, len, flush); 208 199 } 209 200 -
trunk/WebCore/loader/DocumentWriter.h
r61868 r61913 68 68 void setDecoder(TextResourceDecoder*); 69 69 70 // Exposed for DoucmentParser::appendBytes 71 TextResourceDecoder* createDecoderIfNeeded(); 72 void reportDataRecieved(); 73 70 74 private: 71 75 PassRefPtr<Document> createDocument(const KURL&); -
trunk/WebCore/loader/ImageDocument.cpp
r61868 r61913 85 85 86 86 private: 87 virtual bool writeRawData(const char* data, int len);87 virtual void appendBytes(DocumentWriter*, const char*, int, bool); 88 88 virtual void finish(); 89 89 }; … … 119 119 } 120 120 121 bool ImageDocumentParser::writeRawData(const char*, int)121 void ImageDocumentParser::appendBytes(DocumentWriter*, const char*, int, bool) 122 122 { 123 123 Frame* frame = document()->frame(); 124 124 Settings* settings = frame->settings(); 125 125 if (!frame->loader()->client()->allowImages(!settings || settings->areImagesEnabled())) 126 return false;126 return; 127 127 128 128 CachedImage* cachedImage = document()->cachedImage(); … … 130 130 131 131 document()->imageChanged(); 132 133 return false;134 132 } 135 133 -
trunk/WebCore/loader/MediaDocument.cpp
r61868 r61913 55 55 56 56 private: 57 virtual bool writeRawData(const char* data, int len);57 virtual void appendBytes(DocumentWriter*, const char*, int, bool); 58 58 59 59 void createDocumentStructure(); … … 91 91 frame->loader()->activeDocumentLoader()->mainResourceLoader()->setShouldBufferData(false); 92 92 } 93 94 bool MediaDocumentParser::writeRawData(const char*, int)93 94 void MediaDocumentParser::appendBytes(DocumentWriter*, const char*, int, bool) 95 95 { 96 96 ASSERT(!m_mediaElement); 97 97 if (m_mediaElement) 98 return false;99 98 return; 99 100 100 createDocumentStructure(); 101 101 finish(); 102 return false;103 102 } 104 103 -
trunk/WebCore/loader/PluginDocument.cpp
r61868 r61913 53 53 54 54 private: 55 virtual bool writeRawData(const char* data, int len);55 virtual void appendBytes(DocumentWriter*, const char*, int, bool); 56 56 57 57 void createDocumentStructure(); … … 99 99 body->appendChild(embedElement, ec); 100 100 } 101 102 bool PluginDocumentParser::writeRawData(const char*, int)101 102 void PluginDocumentParser::appendBytes(DocumentWriter*, const char*, int, bool) 103 103 { 104 104 ASSERT(!m_embedElement); 105 105 if (m_embedElement) 106 return false;107 106 return; 107 108 108 createDocumentStructure(); 109 109 110 if (Frame* frame = document()->frame()) { 111 Settings* settings = frame->settings(); 112 if (settings && frame->loader()->subframeLoader()->allowPlugins(NotAboutToInstantiatePlugin)) { 113 document()->updateLayout(); 110 Frame* frame = document()->frame(); 111 if (!frame) 112 return; 113 Settings* settings = frame->settings(); 114 if (!settings || !frame->loader()->subframeLoader()->allowPlugins(NotAboutToInstantiatePlugin)) 115 return; 114 116 115 if (RenderWidget* renderer = toRenderWidget(m_embedElement->renderer())) { 116 frame->loader()->client()->redirectDataToPlugin(renderer->widget()); 117 frame->loader()->activeDocumentLoader()->mainResourceLoader()->setShouldBufferData(false); 118 } 117 document()->updateLayout(); 119 118 120 finish(); 121 } 119 if (RenderWidget* renderer = toRenderWidget(m_embedElement->renderer())) { 120 frame->loader()->client()->redirectDataToPlugin(renderer->widget()); 121 frame->loader()->activeDocumentLoader()->mainResourceLoader()->setShouldBufferData(false); 122 122 } 123 123 124 return false;124 finish(); 125 125 } 126 126 -
trunk/WebCore/loader/SinkDocument.cpp
r61868 r61913 31 31 namespace WebCore { 32 32 33 class SinkDocumentParser : public RawDataDocumentParser { 34 public: 35 SinkDocumentParser(SinkDocument* document) 36 : RawDataDocumentParser(document) 37 { 38 } 39 40 private: 41 // Ignore all data. 42 virtual void appendBytes(DocumentWriter*, const char*, int, bool) { } 43 }; 44 33 45 SinkDocument::SinkDocument(Frame* frame, const KURL& url) 34 46 : HTMLDocument(frame, url) … … 39 51 DocumentParser* SinkDocument::createParser() 40 52 { 41 // The basic RawDataDocumentParser does nothing with the data 42 // which is sufficient for our purposes here. 43 return new RawDataDocumentParser(this); 53 return new SinkDocumentParser(this); 44 54 } 45 55
Note: See TracChangeset
for help on using the changeset viewer.