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

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: wip Created 4 years, 5 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
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 eba8125c3c599b64990771d178a5689e7d0130ca..a57dac24c4bc5da3950f70580568643e500f307f 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;
}
@@ -204,7 +203,7 @@ Node::InsertionNotificationRequest HTMLLinkElement::insertedInto(ContainerNode*
if (!insertionPoint->isConnected())
return InsertionDone;
- if (isInShadowTree()) {
+ if (isConnected() && !shouldLoadLink()) {
kochi 2016/07/26 05:35:06 Does insertionPoint->isConnected() on line 203 gua
hayato 2016/07/26 06:04:32 Good point. I have added DCHECK()s around here.
String message = "HTML element <link> is ignored in shadow tree.";
document().addConsoleMessage(ConsoleMessage::create(JSMessageSource, WarningMessageLevel, message));
return InsertionDone;
@@ -222,15 +221,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 +439,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();
@@ -663,7 +662,8 @@ void LinkStyle::process()
bool mediaQueryMatches = true;
LocalFrame* frame = loadingFrame();
- if (!m_owner->media().isEmpty() && frame && frame->document()) {
+ // MediaQuery is valid only in a document tree.
kochi 2016/07/26 05:35:06 Is this a TODO, or defined in any spec?
hayato 2016/07/26 06:04:32 Ops. That was my misunderstanding. I though this a
+ if (m_owner->isInDocumentTree() && !m_owner->media().isEmpty() && frame && frame->document()) {
RefPtr<ComputedStyle> documentStyle = StyleResolver::styleForDocument(*frame->document());
MediaQuerySet* media = MediaQuerySet::create(m_owner->media());
MediaQueryEvaluator evaluator(frame);

Powered by Google App Engine
This is Rietveld 408576698