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

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

Issue 1793933002: Don't trigger a link resource fetch on media change. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed test and made mediaChanged() virtual Created 4 years, 9 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 f6d32a7a5cff7fcb0e4ea9357b1ce220e256ad9a..e3babb089a2c16b38db1374be050feb7458c6932 100644
--- a/third_party/WebKit/Source/core/html/HTMLLinkElement.cpp
+++ b/third_party/WebKit/Source/core/html/HTMLLinkElement.cpp
@@ -192,7 +192,8 @@ void HTMLLinkElement::parseAttribute(const QualifiedName& name, const AtomicStri
m_sizes->setValue(value);
} else if (name == mediaAttr) {
m_media = value.lower();
- process();
+ if (m_link)
+ m_link->mediaChanged();
Yoav Weiss 2016/03/14 15:23:51 Seems to me that we would want "process()" not to
rune 2016/04/07 07:56:07 Yes, mediaChanged() is necessary to trigger a styl
} else if (name == disabledAttr) {
UseCounter::count(document(), UseCounter::HTMLLinkElementDisabled);
if (LinkStyle* link = linkStyle())
@@ -687,6 +688,14 @@ void LinkStyle::setDisabledState(bool disabled)
}
}
+void LinkStyle::mediaChanged()
+{
+ if (m_sheet) {
+ m_sheet->setMediaQueries(MediaQuerySet::create(m_owner->media()));
+ document().modifiedStyleSheet(m_sheet.get());
+ }
+}
+
void LinkStyle::setCrossOriginStylesheetStatus(CSSStyleSheet* sheet)
{
if (m_fetchFollowingCORS && resource() && !resource()->errorOccurred()) {

Powered by Google App Engine
This is Rietveld 408576698