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

Side by Side 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2001 Dirk Mueller (mueller@kde.org) 4 * (C) 2001 Dirk Mueller (mueller@kde.org)
5 * Copyright (C) 2003, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserv ed. 5 * Copyright (C) 2003, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserv ed.
6 * Copyright (C) 2009 Rob Buis (rwlbuis@gmail.com) 6 * Copyright (C) 2009 Rob Buis (rwlbuis@gmail.com)
7 * Copyright (C) 2011 Google Inc. All rights reserved. 7 * Copyright (C) 2011 Google Inc. All rights reserved.
8 * 8 *
9 * This library is free software; you can redistribute it and/or 9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Library General Public 10 * modify it under the terms of the GNU Library General Public
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 } else if (name == typeAttr) { 185 } else if (name == typeAttr) {
186 m_type = value; 186 m_type = value;
187 process(); 187 process();
188 } else if (name == asAttr) { 188 } else if (name == asAttr) {
189 m_as = value; 189 m_as = value;
190 process(); 190 process();
191 } else if (name == sizesAttr) { 191 } else if (name == sizesAttr) {
192 m_sizes->setValue(value); 192 m_sizes->setValue(value);
193 } else if (name == mediaAttr) { 193 } else if (name == mediaAttr) {
194 m_media = value.lower(); 194 m_media = value.lower();
195 process(); 195 if (m_link)
196 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
196 } else if (name == disabledAttr) { 197 } else if (name == disabledAttr) {
197 UseCounter::count(document(), UseCounter::HTMLLinkElementDisabled); 198 UseCounter::count(document(), UseCounter::HTMLLinkElementDisabled);
198 if (LinkStyle* link = linkStyle()) 199 if (LinkStyle* link = linkStyle())
199 link->setDisabledState(!value.isNull()); 200 link->setDisabledState(!value.isNull());
200 } else { 201 } else {
201 if (name == titleAttr) { 202 if (name == titleAttr) {
202 if (LinkStyle* link = linkStyle()) 203 if (LinkStyle* link = linkStyle())
203 link->setSheetTitle(value); 204 link->setSheetTitle(value);
204 } 205 }
205 206
(...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after
680 if (m_sheet) { 681 if (m_sheet) {
681 m_sheet->setDisabled(disabled); 682 m_sheet->setDisabled(disabled);
682 return; 683 return;
683 } 684 }
684 685
685 if (m_disabledState == EnabledViaScript && m_owner->shouldProcessStyle() ) 686 if (m_disabledState == EnabledViaScript && m_owner->shouldProcessStyle() )
686 process(); 687 process();
687 } 688 }
688 } 689 }
689 690
691 void LinkStyle::mediaChanged()
692 {
693 if (m_sheet) {
694 m_sheet->setMediaQueries(MediaQuerySet::create(m_owner->media()));
695 document().modifiedStyleSheet(m_sheet.get());
696 }
697 }
698
690 void LinkStyle::setCrossOriginStylesheetStatus(CSSStyleSheet* sheet) 699 void LinkStyle::setCrossOriginStylesheetStatus(CSSStyleSheet* sheet)
691 { 700 {
692 if (m_fetchFollowingCORS && resource() && !resource()->errorOccurred()) { 701 if (m_fetchFollowingCORS && resource() && !resource()->errorOccurred()) {
693 // Record the security origin the CORS access check succeeded at, if cro ss origin. 702 // Record the security origin the CORS access check succeeded at, if cro ss origin.
694 // Only origins that are script accessible to it may access the styleshe et's rules. 703 // Only origins that are script accessible to it may access the styleshe et's rules.
695 sheet->setAllowRuleAccessFromOrigin(m_owner->document().securityOrigin() ); 704 sheet->setAllowRuleAccessFromOrigin(m_owner->document().securityOrigin() );
696 } 705 }
697 m_fetchFollowingCORS = false; 706 m_fetchFollowingCORS = false;
698 } 707 }
699 708
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
786 } 795 }
787 796
788 DEFINE_TRACE(LinkStyle) 797 DEFINE_TRACE(LinkStyle)
789 { 798 {
790 visitor->trace(m_sheet); 799 visitor->trace(m_sheet);
791 LinkResource::trace(visitor); 800 LinkResource::trace(visitor);
792 ResourceOwner<StyleSheetResource>::trace(visitor); 801 ResourceOwner<StyleSheetResource>::trace(visitor);
793 } 802 }
794 803
795 } // namespace blink 804 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698