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

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

Issue 2177163002: Allow <link rel=stylesheet> in a connected shadow tree (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: split tests Created 4 years, 4 months 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
« no previous file with comments | « third_party/WebKit/Source/core/dom/StyleSheetCandidate.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 4427d8339ef9e42ec4953fecb3e658063ba1102b..5a9d71fb75063c7ea70baf978b181de4b6595559 100644
--- a/third_party/WebKit/Source/core/html/HTMLLinkElement.cpp
+++ b/third_party/WebKit/Source/core/html/HTMLLinkElement.cpp
@@ -133,7 +133,7 @@ void HTMLLinkElement::parseAttribute(const QualifiedName& name, const AtomicStri
bool HTMLLinkElement::shouldLoadLink()
{
- return isConnected();
+ return isInDocumentTree() || (isConnected() && m_relAttribute.isStyleSheet());
}
bool HTMLLinkElement::loadLink(const String& type, const String& as, const String& media, const KURL& url)
@@ -143,8 +143,7 @@ bool HTMLLinkElement::loadLink(const String& type, const String& as, const Strin
LinkResource* HTMLLinkElement::linkResourceToProcess()
{
- bool visible = isConnected() && !isInShadowTree();
- if (!visible) {
+ if (!shouldLoadLink()) {
ASSERT(!linkStyle() || !linkStyle()->hasSheet());
return nullptr;
}
@@ -203,8 +202,9 @@ Node::InsertionNotificationRequest HTMLLinkElement::insertedInto(ContainerNode*
logAddElementIfIsolatedWorldAndInDocument("link", relAttr, hrefAttr);
if (!insertionPoint->isConnected())
return InsertionDone;
-
- if (isInShadowTree()) {
+ DCHECK(isConnected());
+ if (!shouldLoadLink()) {
+ DCHECK(isInShadowTree());
String message = "HTML element <link> is ignored in shadow tree.";
document().addConsoleMessage(ConsoleMessage::create(JSMessageSource, WarningMessageLevel, message));
return InsertionDone;
@@ -222,15 +222,15 @@ Node::InsertionNotificationRequest HTMLLinkElement::insertedInto(ContainerNode*
void HTMLLinkElement::removedFrom(ContainerNode* insertionPoint)
{
- // Store the result of isInShadowTree() here before Node::removedFrom(..) clears the flags.
- bool wasInShadowTree = isInShadowTree();
+ // Store the result of isConnected() here before Node::removedFrom(..) clears the flags.
+ bool wasConnected = isConnected();
HTMLElement::removedFrom(insertionPoint);
if (!insertionPoint->isConnected())
return;
m_linkLoader->released();
- if (wasInShadowTree) {
+ if (!wasConnected) {
ASSERT(!linkStyle() || !linkStyle()->hasSheet());
return;
}
@@ -440,8 +440,8 @@ enum StyleSheetCacheStatus {
void LinkStyle::setCSSStyleSheet(const String& href, const KURL& baseURL, const String& charset, const CSSStyleSheetResource* cachedStyleSheet)
{
- if (!m_owner->isInDocumentTree()) {
- // While the stylesheet is asynchronously loading, the owner can be moved out of a document tree.
+ if (!m_owner->isConnected()) {
+ // While the stylesheet is asynchronously loading, the owner can be disconnected from a document.
// In that case, cancel any processing on the loaded content.
m_loading = false;
removePendingSheet();
@@ -658,7 +658,7 @@ void LinkStyle::process()
m_loading = true;
String title = m_owner->title();
- if (!title.isEmpty() && !m_owner->isAlternate() && m_disabledState != EnabledViaScript)
+ if (!title.isEmpty() && !m_owner->isAlternate() && m_disabledState != EnabledViaScript && m_owner->isInDocumentTree())
document().styleEngine().setPreferredStylesheetSetNameIfNotSet(title);
bool mediaQueryMatches = true;
« no previous file with comments | « third_party/WebKit/Source/core/dom/StyleSheetCandidate.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698