Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(100)

Side by Side Diff: third_party/WebKit/Source/core/dom/Document.cpp

Issue 1530153002: Change how DOM Inspector fetches document's base URL. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added documentation. Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2001 Dirk Mueller (mueller@kde.org) 4 * (C) 2001 Dirk Mueller (mueller@kde.org)
5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org) 5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org)
6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All r ights reserved. 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All r ights reserved.
7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/) 7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/)
8 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved. 8 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved.
9 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) 9 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
10 * Copyright (C) Research In Motion Limited 2010-2011. All rights reserved. 10 * Copyright (C) Research In Motion Limited 2010-2011. All rights reserved.
(...skipping 4294 matching lines...) Expand 10 before | Expand all | Expand 10 after
4305 KURL Document::completeURLWithOverride(const String& url, const KURL& baseURLOve rride) const 4305 KURL Document::completeURLWithOverride(const String& url, const KURL& baseURLOve rride) const
4306 { 4306 {
4307 ASSERT(baseURLOverride.isEmpty() || baseURLOverride.isValid()); 4307 ASSERT(baseURLOverride.isEmpty() || baseURLOverride.isValid());
4308 4308
4309 // Always return a null URL when passed a null string. 4309 // Always return a null URL when passed a null string.
4310 // FIXME: Should we change the KURL constructor to have this behavior? 4310 // FIXME: Should we change the KURL constructor to have this behavior?
4311 // See also [CSS]StyleSheet::completeURL(const String&) 4311 // See also [CSS]StyleSheet::completeURL(const String&)
4312 if (url.isNull()) 4312 if (url.isNull())
4313 return KURL(); 4313 return KURL();
4314 // This logic is deliberately spread over many statements in an attempt to t rack down http://crbug.com/312410. 4314 // This logic is deliberately spread over many statements in an attempt to t rack down http://crbug.com/312410.
4315 const KURL& baseURL = baseURLForOverride(baseURLOverride);
4316 if (!encoding().isValid())
4317 return KURL(baseURL, url);
4318 return KURL(baseURL, url, encoding());
4319 }
4320
4321 const KURL& Document::baseURLForOverride(const KURL& baseURLOverride) const
4322 {
4323 // This logic is deliberately spread over many statements in an attempt to t rack down http://crbug.com/312410.
4315 const KURL* baseURLFromParent = 0; 4324 const KURL* baseURLFromParent = 0;
4316 bool shouldUseParentBaseURL = baseURLOverride.isEmpty(); 4325 bool shouldUseParentBaseURL = baseURLOverride.isEmpty();
4317 if (!shouldUseParentBaseURL) { 4326 if (!shouldUseParentBaseURL) {
4318 const KURL& aboutBlankURL = blankURL(); 4327 const KURL& aboutBlankURL = blankURL();
4319 shouldUseParentBaseURL = (baseURLOverride == aboutBlankURL); 4328 shouldUseParentBaseURL = (baseURLOverride == aboutBlankURL);
4320 } 4329 }
4321 if (shouldUseParentBaseURL) { 4330 if (shouldUseParentBaseURL) {
4322 if (Document* parent = parentDocument()) 4331 if (Document* parent = parentDocument())
4323 baseURLFromParent = &parent->baseURL(); 4332 baseURLFromParent = &parent->baseURL();
4324 } 4333 }
4325 const KURL& baseURL = baseURLFromParent ? *baseURLFromParent : baseURLOverri de; 4334 return baseURLFromParent ? *baseURLFromParent : baseURLOverride;
4326 if (!encoding().isValid())
4327 return KURL(baseURL, url);
4328 return KURL(baseURL, url, encoding());
4329 } 4335 }
4330 4336
4331 // Support for Javascript execCommand, and related methods 4337 // Support for Javascript execCommand, and related methods
4332 4338
4333 static Editor::Command command(Document* document, const String& commandName) 4339 static Editor::Command command(Document* document, const String& commandName)
4334 { 4340 {
4335 LocalFrame* frame = document->frame(); 4341 LocalFrame* frame = document->frame();
4336 if (!frame || frame->document() != document) 4342 if (!frame || frame->document() != document)
4337 return Editor::Command(); 4343 return Editor::Command();
4338 4344
(...skipping 1515 matching lines...) Expand 10 before | Expand all | Expand 10 after
5854 #ifndef NDEBUG 5860 #ifndef NDEBUG
5855 using namespace blink; 5861 using namespace blink;
5856 void showLiveDocumentInstances() 5862 void showLiveDocumentInstances()
5857 { 5863 {
5858 Document::WeakDocumentSet& set = Document::liveDocumentSet(); 5864 Document::WeakDocumentSet& set = Document::liveDocumentSet();
5859 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); 5865 fprintf(stderr, "There are %u documents currently alive:\n", set.size());
5860 for (Document* document : set) 5866 for (Document* document : set)
5861 fprintf(stderr, "- Document %p URL: %s\n", document, document->url().str ing().utf8().data()); 5867 fprintf(stderr, "- Document %p URL: %s\n", document, document->url().str ing().utf8().data());
5862 } 5868 }
5863 #endif 5869 #endif
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/Document.h ('k') | third_party/WebKit/Source/core/inspector/InspectorDOMAgent.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698