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

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

Issue 2337193004: Setting the link title may change the preferred set. (Closed)
Patch Set: Rebased Created 4 years, 3 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/html/HTMLLinkElement.h ('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 5138b4038dfc3c8a056f8722238be812bd3aa37e..9146fe41ca65af3f037d7ad8613470cc5c4979f7 100644
--- a/third_party/WebKit/Source/core/html/HTMLLinkElement.cpp
+++ b/third_party/WebKit/Source/core/html/HTMLLinkElement.cpp
@@ -119,7 +119,7 @@ void HTMLLinkElement::parseAttribute(const QualifiedName& name, const AtomicStri
} else {
if (name == titleAttr) {
if (LinkStyle* link = linkStyle())
- link->setSheetTitle(value);
+ link->setSheetTitle(value, StyleEngine::UpdateActiveSheets);
}
HTMLElement::parseAttribute(name, oldValue, value);
@@ -462,7 +462,7 @@ void LinkStyle::setCSSStyleSheet(const String& href, const KURL& baseURL, const
m_sheet = CSSStyleSheet::create(restoredSheet, m_owner);
m_sheet->setMediaQueries(MediaQuerySet::create(m_owner->media()));
if (m_owner->isInDocumentTree())
- m_sheet->setTitle(m_owner->title());
+ setSheetTitle(m_owner->title());
setCrossOriginStylesheetStatus(m_sheet.get());
m_loading = false;
@@ -484,7 +484,7 @@ void LinkStyle::setCSSStyleSheet(const String& href, const KURL& baseURL, const
m_sheet = CSSStyleSheet::create(styleSheet, m_owner);
m_sheet->setMediaQueries(MediaQuerySet::create(m_owner->media()));
if (m_owner->isInDocumentTree())
- m_sheet->setTitle(m_owner->title());
+ setSheetTitle(m_owner->title());
setCrossOriginStylesheetStatus(m_sheet.get());
styleSheet->parseAuthorStyleSheet(cachedStyleSheet, m_owner->document().getSecurityOrigin());
@@ -650,7 +650,7 @@ void LinkStyle::process()
String title = m_owner->title();
if (!title.isEmpty() && !m_owner->isAlternate() && m_disabledState != EnabledViaScript && m_owner->isInDocumentTree())
- document().styleEngine().setPreferredStylesheetSetNameIfNotSet(title);
+ document().styleEngine().setPreferredStylesheetSetNameIfNotSet(title, StyleEngine::DontUpdateActiveSheets);
bool mediaQueryMatches = true;
LocalFrame* frame = loadingFrame();
@@ -698,10 +698,20 @@ void LinkStyle::process()
}
}
-void LinkStyle::setSheetTitle(const String& title)
+void LinkStyle::setSheetTitle(const String& title, StyleEngine::ActiveSheetsUpdate updateActiveSheets)
{
- if (m_sheet && m_owner->isInDocumentTree())
+ if (!m_owner->isInDocumentTree() || !m_owner->relAttribute().isStyleSheet())
+ return;
+
+ if (m_sheet)
m_sheet->setTitle(title);
+
+ if (title.isEmpty() || !isUnset() || m_owner->isAlternate())
+ return;
+
+ KURL href = m_owner->getNonEmptyURLAttribute(hrefAttr);
+ if (href.isValid() && !href.isEmpty())
+ document().styleEngine().setPreferredStylesheetSetNameIfNotSet(title, updateActiveSheets);
}
void LinkStyle::ownerRemoved()
« no previous file with comments | « third_party/WebKit/Source/core/html/HTMLLinkElement.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698