Changeset 61783 in webkit
- Timestamp:
- Jun 24, 2010 1:13:55 PM (14 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 30 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r61781 r61783 1 2010-06-24 Nate Chapin <japhet@chromium.org> 2 3 Reviewed by Adam Barth. 4 5 Take a KURL parameter in Document's constructor. 6 This will remove the one case where Document::url() 7 and FrameLoader::url() are not equal, allowing us to 8 remove FrameLoader::url(). 9 10 https://bugs.webkit.org/show_bug.cgi?id=41166 11 12 Refactor only, no new tests. 13 14 * dom/DOMImplementation.cpp: 15 (WebCore::DOMImplementation::createDocument): Take a KURL and pass it through to Document. 16 (WebCore::DOMImplementation::createHTMLDocument): 17 * dom/DOMImplementation.h: 18 * dom/Document.cpp: 19 (WebCore::Document::Document): Call setURL() for non-empty KURL input parameters. 20 (WebCore::Document::initSecurityContext): m_url is now initialized, so use it instead 21 of m_frame->loader()->url() for initializing the SecurityOrigin. 22 * dom/Document.h: 23 (WebCore::Document::create): 24 (WebCore::Document::createXHTML): 25 * html/HTMLDocument.cpp: 26 * html/HTMLDocument.h: Add KURL parameter to create() and constructor. 27 * html/HTMLViewSourceDocument.cpp: 28 * html/HTMLViewSourceDocument.h: Add KURL parameter to create() and constructor. 29 * loader/CachedFont.cpp: 30 (WebCore::CachedFont::ensureSVGFontData): 31 * loader/DocumentWriter.cpp: 32 (WebCore::DocumentWriter::createDocument): Take a KURL and pass it through to Document. 33 (WebCore::DocumentWriter::begin): Pass existing url parameter to constructors, and remove 34 redundant Document::setURL() call. 35 * loader/DocumentWriter.h: 36 * loader/FTPDirectoryDocument.cpp: 37 * loader/FTPDirectoryDocument.h: Add KURL parameter to create() and constructor. 38 * loader/ImageDocument.cpp: 39 * loader/ImageDocument.h: Add KURL parameter to create() and constructor. 40 * loader/MediaDocument.cpp: 41 * loader/MediaDocument.h: Add KURL parameter to create() and constructor. 42 * loader/PlaceholderDocument.h: Add KURL parameter to create() and constructor. 43 * loader/PluginDocument.cpp: 44 * loader/PluginDocument.h: Add KURL parameter to create() and constructor. 45 * loader/SinkDocument.cpp: 46 * loader/SinkDocument.h: Add KURL parameter to create() and constructor. 47 * loader/TextDocument.cpp: 48 * loader/TextDocument.h: Add KURL parameter to create() and constructor. 49 * svg/SVGDocument.cpp: 50 * svg/SVGDocument.h: Add KURL parameter to create() and constructor. 51 * xml/DOMParser.cpp: 52 (WebCore::DOMParser::parseFromString): 53 * xml/XMLHttpRequest.cpp: 54 (WebCore::XMLHttpRequest::responseXML): 55 * xml/XSLTProcessor.cpp: 56 (WebCore::XSLTProcessor::createDocumentFromSource): 57 1 58 2010-06-24 Brady Eidson <beidson@apple.com> 2 59 -
trunk/WebCore/dom/DOMImplementation.cpp
r61584 r61783 228 228 #if ENABLE(SVG) 229 229 if (namespaceURI == SVGNames::svgNamespaceURI) 230 doc = SVGDocument::create(0 );230 doc = SVGDocument::create(0, KURL()); 231 231 else 232 232 #endif 233 233 #if ENABLE(WML) 234 234 if (namespaceURI == WMLNames::wmlNamespaceURI) 235 doc = WMLDocument::create(0 );235 doc = WMLDocument::create(0, KURL()); 236 236 else 237 237 #endif 238 238 if (namespaceURI == HTMLNames::xhtmlNamespaceURI) 239 doc = Document::createXHTML(0 );239 doc = Document::createXHTML(0, KURL()); 240 240 else 241 doc = Document::create(0 );241 doc = Document::create(0, KURL()); 242 242 243 243 RefPtr<Node> documentElement; … … 296 296 PassRefPtr<HTMLDocument> DOMImplementation::createHTMLDocument(const String& title) 297 297 { 298 RefPtr<HTMLDocument> d = HTMLDocument::create(0 );298 RefPtr<HTMLDocument> d = HTMLDocument::create(0, KURL()); 299 299 d->open(); 300 300 d->write("<!doctype html><html><body></body></html>"); … … 303 303 } 304 304 305 PassRefPtr<Document> DOMImplementation::createDocument(const String& type, Frame* frame, bool inViewSourceMode)305 PassRefPtr<Document> DOMImplementation::createDocument(const String& type, Frame* frame, const KURL& url, bool inViewSourceMode) 306 306 { 307 307 if (inViewSourceMode) 308 return HTMLViewSourceDocument::create(frame, type);308 return HTMLViewSourceDocument::create(frame, url, type); 309 309 310 310 // Plugins cannot take HTML and XHTML from us, and we don't even need to initialize the plugin database for those. 311 311 if (type == "text/html") 312 return HTMLDocument::create(frame );312 return HTMLDocument::create(frame, url); 313 313 if (type == "application/xhtml+xml" 314 314 #if ENABLE(XHTMLMP) … … 316 316 #endif 317 317 ) 318 return Document::createXHTML(frame );318 return Document::createXHTML(frame, url); 319 319 320 320 #if ENABLE(WML) 321 321 if (type == "text/vnd.wap.wml" || type == "application/vnd.wap.wmlc") 322 return WMLDocument::create(frame );322 return WMLDocument::create(frame, url); 323 323 #endif 324 324 … … 326 326 // Plugins cannot take FTP from us either 327 327 if (type == "application/x-ftp-directory") 328 return FTPDirectoryDocument::create(frame );328 return FTPDirectoryDocument::create(frame, url); 329 329 #endif 330 330 … … 336 336 // We do not want QuickTime to take over all image types, obviously. 337 337 if ((type == "application/pdf" || type == "text/pdf") && pluginData && pluginData->supportsMimeType(type)) 338 return PluginDocument::create(frame );338 return PluginDocument::create(frame, url); 339 339 if (Image::supportsType(type)) 340 return ImageDocument::create(frame );340 return ImageDocument::create(frame, url); 341 341 342 342 #if ENABLE(VIDEO) 343 343 // Check to see if the type can be played by our MediaPlayer, if so create a MediaDocument 344 344 if (MediaPlayer::supportsType(ContentType(type))) 345 return MediaDocument::create(frame );345 return MediaDocument::create(frame, url); 346 346 #endif 347 347 … … 350 350 // and also serves as an optimization to prevent loading the plug-in database in the common case. 351 351 if (type != "text/plain" && pluginData && pluginData->supportsMimeType(type)) 352 return PluginDocument::create(frame );352 return PluginDocument::create(frame, url); 353 353 if (isTextMIMEType(type)) 354 return TextDocument::create(frame );354 return TextDocument::create(frame, url); 355 355 356 356 #if ENABLE(SVG) … … 360 360 if (!settings || !settings->usesDashboardBackwardCompatibilityMode()) 361 361 #endif 362 return SVGDocument::create(frame );362 return SVGDocument::create(frame, url); 363 363 } 364 364 #endif 365 365 if (isXMLMIMEType(type)) 366 return Document::create(frame );367 368 return HTMLDocument::create(frame );369 } 370 371 } 366 return Document::create(frame, url); 367 368 return HTMLDocument::create(frame, url); 369 } 370 371 } -
trunk/WebCore/dom/DOMImplementation.h
r56412 r61783 35 35 class Frame; 36 36 class HTMLDocument; 37 class KURL; 37 38 class String; 38 39 … … 57 58 58 59 // Other methods (not part of DOM) 59 static PassRefPtr<Document> createDocument(const String& MIMEType, Frame*, bool inViewSourceMode);60 static PassRefPtr<Document> createDocument(const String& MIMEType, Frame*, const KURL&, bool inViewSourceMode); 60 61 61 62 static bool isXMLMIMEType(const String& MIMEType); -
trunk/WebCore/dom/Document.cpp
r61736 r61783 355 355 }; 356 356 357 Document::Document(Frame* frame, bool isXHTML, bool isHTML)357 Document::Document(Frame* frame, const KURL& url, bool isXHTML, bool isHTML) 358 358 : ContainerNode(0) 359 359 , m_domtree_version(0) … … 413 413 414 414 m_frame = frame; 415 416 if (!url.isEmpty()) 417 setURL(url); 415 418 416 419 m_axObjectCache = 0; … … 4613 4616 // In the common case, create the security context from the currently 4614 4617 // loading URL. 4615 const KURL& url = m_frame->loader()->url(); 4616 m_cookieURL = url; 4617 ScriptExecutionContext::setSecurityOrigin(SecurityOrigin::create(url, m_frame->loader()->sandboxFlags())); 4618 m_cookieURL = m_url; 4619 ScriptExecutionContext::setSecurityOrigin(SecurityOrigin::create(m_url, m_frame->loader()->sandboxFlags())); 4618 4620 4619 4621 if (SecurityOrigin::allowSubstituteDataAccessToLocal()) { -
trunk/WebCore/dom/Document.h
r61670 r61783 186 186 class Document : public ContainerNode, public ScriptExecutionContext { 187 187 public: 188 static PassRefPtr<Document> create(Frame* frame )188 static PassRefPtr<Document> create(Frame* frame, const KURL& url) 189 189 { 190 return adoptRef(new Document(frame, false, false));190 return adoptRef(new Document(frame, url, false, false)); 191 191 } 192 static PassRefPtr<Document> createXHTML(Frame* frame )192 static PassRefPtr<Document> createXHTML(Frame* frame, const KURL& url) 193 193 { 194 return adoptRef(new Document(frame, true, false));194 return adoptRef(new Document(frame, url, true, false)); 195 195 } 196 196 virtual ~Document(); … … 992 992 993 993 protected: 994 Document(Frame*, bool isXHTML, bool isHTML);994 Document(Frame*, const KURL&, bool isXHTML, bool isHTML); 995 995 996 996 void clearXMLVersion() { m_xmlVersion = String(); } -
trunk/WebCore/html/HTMLDocument.cpp
r61674 r61783 82 82 using namespace HTMLNames; 83 83 84 HTMLDocument::HTMLDocument(Frame* frame )85 : Document(frame, false, true)84 HTMLDocument::HTMLDocument(Frame* frame, const KURL& url) 85 : Document(frame, url, false, true) 86 86 { 87 87 clearXMLVersion(); -
trunk/WebCore/html/HTMLDocument.h
r61104 r61783 36 36 class HTMLDocument : public Document, public CachedResourceClient { 37 37 public: 38 static PassRefPtr<HTMLDocument> create(Frame* frame )38 static PassRefPtr<HTMLDocument> create(Frame* frame, const KURL& url) 39 39 { 40 return adoptRef(new HTMLDocument(frame ));40 return adoptRef(new HTMLDocument(frame, url)); 41 41 } 42 42 virtual ~HTMLDocument(); … … 81 81 82 82 protected: 83 HTMLDocument(Frame* );83 HTMLDocument(Frame*, const KURL&); 84 84 85 85 private: -
trunk/WebCore/html/HTMLViewSourceDocument.cpp
r61662 r61783 45 45 using namespace HTMLNames; 46 46 47 HTMLViewSourceDocument::HTMLViewSourceDocument(Frame* frame, const String& mimeType)48 : HTMLDocument(frame )47 HTMLViewSourceDocument::HTMLViewSourceDocument(Frame* frame, const KURL& url, const String& mimeType) 48 : HTMLDocument(frame, url) 49 49 , m_type(mimeType) 50 50 { -
trunk/WebCore/html/HTMLViewSourceDocument.h
r61662 r61783 38 38 class HTMLViewSourceDocument : public HTMLDocument { 39 39 public: 40 static PassRefPtr<HTMLViewSourceDocument> create(Frame* frame, const String& mimeType)40 static PassRefPtr<HTMLViewSourceDocument> create(Frame* frame, const KURL& url, const String& mimeType) 41 41 { 42 return adoptRef(new HTMLViewSourceDocument(frame, mimeType));42 return adoptRef(new HTMLViewSourceDocument(frame, url, mimeType)); 43 43 } 44 44 … … 48 48 49 49 private: 50 HTMLViewSourceDocument(Frame*, const String& mimeType);50 HTMLViewSourceDocument(Frame*, const KURL&, const String& mimeType); 51 51 52 52 // Returns LegacyHTMLDocumentParser or TextDocumentParser based on m_type. -
trunk/WebCore/loader/CachedFont.cpp
r61094 r61783 137 137 ASSERT(m_isSVGFont); 138 138 if (!m_externalSVGDocument && !errorOccurred() && !isLoading() && m_data) { 139 m_externalSVGDocument = SVGDocument::create(0 );139 m_externalSVGDocument = SVGDocument::create(0, KURL()); 140 140 m_externalSVGDocument->open(); 141 141 -
trunk/WebCore/loader/DocumentWriter.cpp
r61568 r61783 81 81 } 82 82 83 PassRefPtr<Document> DocumentWriter::createDocument( )83 PassRefPtr<Document> DocumentWriter::createDocument(const KURL& url) 84 84 { 85 85 if (!m_frame->loader()->stateMachine()->isDisplayingInitialEmptyDocument() && m_frame->loader()->client()->shouldUsePluginDocument(m_mimeType)) 86 return PluginDocument::create(m_frame );86 return PluginDocument::create(m_frame, url); 87 87 if (!m_frame->loader()->client()->hasHTMLView()) 88 return PlaceholderDocument::create(m_frame );89 return DOMImplementation::createDocument(m_mimeType, m_frame, m_frame->inViewSourceMode());88 return PlaceholderDocument::create(m_frame, url); 89 return DOMImplementation::createDocument(m_mimeType, m_frame, url, m_frame->inViewSourceMode()); 90 90 } 91 91 … … 98 98 // Create a new document before clearing the frame, because it may need to 99 99 // inherit an aliased security context. 100 RefPtr<Document> document = createDocument( );100 RefPtr<Document> document = createDocument(url); 101 101 102 102 // If the new document is for a Plugin but we're supposed to be sandboxed from Plugins, 103 103 // then replace the document with one whose parser will ignore the incoming data (bug 39323) 104 104 if (document->isPluginDocument() && m_frame->loader()->isSandboxed(SandboxPlugins)) 105 document = SinkDocument::create(m_frame );105 document = SinkDocument::create(m_frame, url); 106 106 107 107 bool resetScripting = !(m_frame->loader()->stateMachine()->isDisplayingInitialEmptyDocument() && m_frame->document()->securityOrigin()->isSecureTransitionTo(url)); … … 111 111 112 112 m_frame->loader()->setURL(url); 113 document->setURL(url);114 113 m_frame->setDocument(document); 115 114 -
trunk/WebCore/loader/DocumentWriter.h
r57927 r61783 68 68 69 69 private: 70 PassRefPtr<Document> createDocument( );70 PassRefPtr<Document> createDocument(const KURL&); 71 71 72 72 Frame* m_frame; -
trunk/WebCore/loader/FTPDirectoryDocument.cpp
r61737 r61783 432 432 } 433 433 434 FTPDirectoryDocument::FTPDirectoryDocument(Frame* frame )435 : HTMLDocument(frame )434 FTPDirectoryDocument::FTPDirectoryDocument(Frame* frame, const KURL& url) 435 : HTMLDocument(frame, url) 436 436 { 437 437 #ifndef NDEBUG -
trunk/WebCore/loader/FTPDirectoryDocument.h
r61104 r61783 34 34 class FTPDirectoryDocument : public HTMLDocument { 35 35 public: 36 static PassRefPtr<FTPDirectoryDocument> create(Frame* frame )36 static PassRefPtr<FTPDirectoryDocument> create(Frame* frame, const KURL& url) 37 37 { 38 return adoptRef(new FTPDirectoryDocument(frame ));38 return adoptRef(new FTPDirectoryDocument(frame, url)); 39 39 } 40 40 41 41 private: 42 FTPDirectoryDocument(Frame* );42 FTPDirectoryDocument(Frame*, const KURL&); 43 43 virtual DocumentParser* createParser(); 44 44 }; -
trunk/WebCore/loader/ImageDocument.cpp
r61737 r61783 196 196 // -------- 197 197 198 ImageDocument::ImageDocument(Frame* frame )199 : HTMLDocument(frame )198 ImageDocument::ImageDocument(Frame* frame, const KURL& url) 199 : HTMLDocument(frame, url) 200 200 , m_imageElement(0) 201 201 , m_imageSizeIsKnown(false) -
trunk/WebCore/loader/ImageDocument.h
r61104 r61783 34 34 class ImageDocument : public HTMLDocument { 35 35 public: 36 static PassRefPtr<ImageDocument> create(Frame* frame )36 static PassRefPtr<ImageDocument> create(Frame* frame, const KURL& url) 37 37 { 38 return adoptRef(new ImageDocument(frame ));38 return adoptRef(new ImageDocument(frame, url)); 39 39 } 40 40 … … 48 48 49 49 private: 50 ImageDocument(Frame* );50 ImageDocument(Frame*, const KURL&); 51 51 52 52 virtual DocumentParser* createParser(); -
trunk/WebCore/loader/MediaDocument.cpp
r61737 r61783 139 139 } 140 140 141 MediaDocument::MediaDocument(Frame* frame )142 : HTMLDocument(frame )141 MediaDocument::MediaDocument(Frame* frame, const KURL& url) 142 : HTMLDocument(frame, url) 143 143 , m_replaceMediaElementTimer(this, &MediaDocument::replaceMediaElementTimerFired) 144 144 { -
trunk/WebCore/loader/MediaDocument.h
r61104 r61783 35 35 class MediaDocument : public HTMLDocument { 36 36 public: 37 static PassRefPtr<MediaDocument> create(Frame* frame )37 static PassRefPtr<MediaDocument> create(Frame* frame, const KURL& url) 38 38 { 39 return adoptRef(new MediaDocument(frame ));39 return adoptRef(new MediaDocument(frame, url)); 40 40 } 41 41 virtual ~MediaDocument(); … … 44 44 45 45 private: 46 MediaDocument(Frame* );46 MediaDocument(Frame*, const KURL&); 47 47 48 48 virtual bool isMediaDocument() const { return true; } -
trunk/WebCore/loader/PlaceholderDocument.h
r53514 r61783 33 33 class PlaceholderDocument : public Document { 34 34 public: 35 static PassRefPtr<PlaceholderDocument> create(Frame* frame )35 static PassRefPtr<PlaceholderDocument> create(Frame* frame, const KURL& url) 36 36 { 37 return adoptRef(new PlaceholderDocument(frame ));37 return adoptRef(new PlaceholderDocument(frame, url)); 38 38 } 39 39 … … 41 41 42 42 private: 43 PlaceholderDocument(Frame* frame ) : Document(frame, false, false) { }43 PlaceholderDocument(Frame* frame, const KURL& url) : Document(frame, url, false, false) { } 44 44 }; 45 45 -
trunk/WebCore/loader/PluginDocument.cpp
r61737 r61783 159 159 } 160 160 161 PluginDocument::PluginDocument(Frame* frame )162 : HTMLDocument(frame )161 PluginDocument::PluginDocument(Frame* frame, const KURL& url) 162 : HTMLDocument(frame, url) 163 163 { 164 164 setParseMode(Compat); -
trunk/WebCore/loader/PluginDocument.h
r61104 r61783 34 34 class PluginDocument : public HTMLDocument { 35 35 public: 36 static PassRefPtr<PluginDocument> create(Frame* frame )36 static PassRefPtr<PluginDocument> create(Frame* frame, const KURL& url) 37 37 { 38 return adoptRef(new PluginDocument(frame ));38 return adoptRef(new PluginDocument(frame, url)); 39 39 } 40 40 … … 45 45 46 46 private: 47 PluginDocument(Frame* );47 PluginDocument(Frame*, const KURL&); 48 48 49 49 virtual DocumentParser* createParser(); -
trunk/WebCore/loader/SinkDocument.cpp
r61737 r61783 61 61 } 62 62 63 SinkDocument::SinkDocument(Frame* frame )64 : HTMLDocument(frame )63 SinkDocument::SinkDocument(Frame* frame, const KURL& url) 64 : HTMLDocument(frame, url) 65 65 { 66 66 setParseMode(Compat); -
trunk/WebCore/loader/SinkDocument.h
r61104 r61783 33 33 class SinkDocument : public HTMLDocument { 34 34 public: 35 static PassRefPtr<SinkDocument> create(Frame* frame )35 static PassRefPtr<SinkDocument> create(Frame* frame, const KURL& url) 36 36 { 37 return adoptRef(new SinkDocument(frame ));37 return adoptRef(new SinkDocument(frame, url)); 38 38 } 39 39 40 40 private: 41 SinkDocument(Frame* );41 SinkDocument(Frame*, const KURL&); 42 42 43 43 virtual DocumentParser* createParser(); -
trunk/WebCore/loader/TextDocument.cpp
r61737 r61783 185 185 } 186 186 187 TextDocument::TextDocument(Frame* frame )188 : HTMLDocument(frame )187 TextDocument::TextDocument(Frame* frame, const KURL& url) 188 : HTMLDocument(frame, url) 189 189 { 190 190 } -
trunk/WebCore/loader/TextDocument.h
r61104 r61783 34 34 class TextDocument : public HTMLDocument { 35 35 public: 36 static PassRefPtr<TextDocument> create(Frame* frame )36 static PassRefPtr<TextDocument> create(Frame* frame, const KURL& url) 37 37 { 38 return adoptRef(new TextDocument(frame ));38 return adoptRef(new TextDocument(frame, url)); 39 39 } 40 40 41 41 private: 42 TextDocument(Frame* );42 TextDocument(Frame*, const KURL&); 43 43 44 44 virtual DocumentParser* createParser(); -
trunk/WebCore/svg/SVGDocument.cpp
r53514 r61783 36 36 namespace WebCore { 37 37 38 SVGDocument::SVGDocument(Frame* frame )39 : Document(frame, false, false)38 SVGDocument::SVGDocument(Frame* frame, const KURL& url) 39 : Document(frame, url, false, false) 40 40 { 41 41 } -
trunk/WebCore/svg/SVGDocument.h
r47313 r61783 34 34 class SVGDocument : public Document { 35 35 public: 36 static PassRefPtr<SVGDocument> create(Frame* frame )36 static PassRefPtr<SVGDocument> create(Frame* frame, const KURL& url) 37 37 { 38 return adoptRef(new SVGDocument(frame ));38 return adoptRef(new SVGDocument(frame, url)); 39 39 } 40 40 … … 52 52 53 53 private: 54 SVGDocument(Frame* );54 SVGDocument(Frame*, const KURL&); 55 55 56 56 virtual bool isSVGDocument() const { return true; } -
trunk/WebCore/xml/DOMParser.cpp
r34574 r61783 30 30 return 0; 31 31 32 RefPtr<Document> doc = DOMImplementation::createDocument(contentType, 0, false);32 RefPtr<Document> doc = DOMImplementation::createDocument(contentType, 0, KURL(), false); 33 33 34 34 doc->open(); -
trunk/WebCore/xml/XMLHttpRequest.cpp
r61654 r61783 241 241 m_responseXML = 0; 242 242 } else { 243 m_responseXML = Document::create(0 );243 m_responseXML = Document::create(0, KURL()); 244 244 m_responseXML->open(); 245 245 m_responseXML->setURL(m_url); -
trunk/WebCore/xml/XSLTProcessor.cpp
r61637 r61783 69 69 RefPtr<Document> result; 70 70 if (sourceMIMEType == "text/plain") { 71 result = Document::create(frame );71 result = Document::create(frame, sourceIsDocument ? ownerDocument->url() : KURL()); 72 72 transformTextStringToXHTMLDocumentString(documentSource); 73 73 } else 74 result = DOMImplementation::createDocument(sourceMIMEType, frame, false);74 result = DOMImplementation::createDocument(sourceMIMEType, frame, sourceIsDocument ? ownerDocument->url() : KURL(), false); 75 75 76 76 // Before parsing, we need to save & detach the old document and get the new document … … 83 83 } 84 84 85 if (sourceIsDocument)86 result->setURL(ownerDocument->url());87 85 result->open(); 88 86
Note: See TracChangeset
for help on using the changeset viewer.