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() |