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

Unified Diff: third_party/WebKit/Source/core/html/HTMLLinkElement.cpp

Issue 2553803003: Refactor HTMLLinkElement
Patch Set: a Created 4 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/html/HTMLLinkElement.cpp
diff --git a/third_party/WebKit/Source/core/html/HTMLLinkElement.cpp b/third_party/WebKit/Source/core/html/HTMLLinkElement.cpp
index 06a8129631ec454bb9090660d522cbdf78bc5917..726c1d945bddfb5e124a7c25e38536e3fcd46455 100644
--- a/third_party/WebKit/Source/core/html/HTMLLinkElement.cpp
+++ b/third_party/WebKit/Source/core/html/HTMLLinkElement.cpp
@@ -50,7 +50,6 @@ using namespace HTMLNames;
inline HTMLLinkElement::HTMLLinkElement(Document& document,
bool createdByParser)
: HTMLElement(linkTag, document),
- m_linkLoader(LinkLoader::create(this)),
m_sizes(DOMTokenList::create(this)),
m_relList(this, RelList::create(this)),
m_createdByParser(createdByParser) {}
@@ -110,11 +109,26 @@ bool HTMLLinkElement::shouldLoadLink() {
return isInDocumentTree() || (isConnected() && m_relAttribute.isStyleSheet());
}
+FetchRequest HTMLLinkElement::createFetchRequest() const {
+ AtomicString charset = getAttribute(charsetAttr);
+ if (charset.isEmpty() && document().frame())
+ charset = document().characterSet();
+
+ FetchRequest request(ResourceRequest(document().completeURL(
+ getNonEmptyURLAttribute(hrefAttr))),
+ localName(), charset);
+ request.setContentSecurityPolicyNonce(fastGetAttribute(HTMLNames::nonceAttr));
+ return request;
+}
+
bool HTMLLinkElement::loadLink(const String& type,
const String& as,
const String& media,
ReferrerPolicy referrerPolicy,
const KURL& url) {
+ if (!m_linkLoader)
+ m_linkLoader = LinkLoader::create(this);
+
return m_linkLoader->loadLink(
m_relAttribute,
crossOriginAttributeValue(fastGetAttribute(HTMLNames::crossoriginAttr)),
@@ -210,7 +224,8 @@ void HTMLLinkElement::removedFrom(ContainerNode* insertionPoint) {
if (!insertionPoint->isConnected())
return;
- m_linkLoader->released();
+ if (m_linkLoader)
+ m_linkLoader->released();
if (!wasConnected) {
DCHECK(!linkStyle() || !linkStyle()->hasSheet());
« no previous file with comments | « third_party/WebKit/Source/core/html/HTMLLinkElement.h ('k') | third_party/WebKit/Source/core/html/LinkResource.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698