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

Side by Side Diff: third_party/WebKit/Source/core/html/LinkStyle.cpp

Issue 2552353003: Setting preferred stylesheet simplified. (Closed)
Patch Set: Rebased. Created 4 years 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
« no previous file with comments | « third_party/WebKit/Source/core/html/LinkStyle.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "core/html/LinkStyle.h" 5 #include "core/html/LinkStyle.h"
6 6
7 #include "core/css/StyleSheetContents.h" 7 #include "core/css/StyleSheetContents.h"
8 #include "core/frame/LocalFrame.h" 8 #include "core/frame/LocalFrame.h"
9 #include "core/frame/SubresourceIntegrity.h" 9 #include "core/frame/SubresourceIntegrity.h"
10 #include "core/frame/csp/ContentSecurityPolicy.h" 10 #include "core/frame/csp/ContentSecurityPolicy.h"
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 } 300 }
301 301
302 if (!m_owner->shouldLoadLink()) 302 if (!m_owner->shouldLoadLink())
303 return Bail; 303 return Bail;
304 304
305 m_loading = true; 305 m_loading = true;
306 306
307 String title = m_owner->title(); 307 String title = m_owner->title();
308 if (!title.isEmpty() && !m_owner->isAlternate() && 308 if (!title.isEmpty() && !m_owner->isAlternate() &&
309 m_disabledState != EnabledViaScript && m_owner->isInDocumentTree()) { 309 m_disabledState != EnabledViaScript && m_owner->isInDocumentTree()) {
310 document().styleEngine().setPreferredStylesheetSetNameIfNotSet( 310 document().styleEngine().setPreferredStylesheetSetNameIfNotSet(title);
311 title, StyleEngine::DontUpdateActiveSheets);
312 } 311 }
313 312
314 bool mediaQueryMatches = true; 313 bool mediaQueryMatches = true;
315 LocalFrame* frame = loadingFrame(); 314 LocalFrame* frame = loadingFrame();
316 if (!m_owner->media().isEmpty() && frame) { 315 if (!m_owner->media().isEmpty() && frame) {
317 MediaQuerySet* media = MediaQuerySet::create(m_owner->media()); 316 MediaQuerySet* media = MediaQuerySet::create(m_owner->media());
318 MediaQueryEvaluator evaluator(frame); 317 MediaQueryEvaluator evaluator(frame);
319 mediaQueryMatches = evaluator.eval(media); 318 mediaQueryMatches = evaluator.eval(media);
320 } 319 }
321 320
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 if (loadStylesheetIfNeeded(builder, type) == NotNeeded && m_sheet) { 388 if (loadStylesheetIfNeeded(builder, type) == NotNeeded && m_sheet) {
390 // we no longer contain a stylesheet, e.g. perhaps rel or type was changed 389 // we no longer contain a stylesheet, e.g. perhaps rel or type was changed
391 clearSheet(); 390 clearSheet();
392 document().styleEngine().setNeedsActiveStyleUpdate(m_owner->treeScope()); 391 document().styleEngine().setNeedsActiveStyleUpdate(m_owner->treeScope());
393 // TODO(rune@opera.com): resolverChanged() can be removed once stylesheet 392 // TODO(rune@opera.com): resolverChanged() can be removed once stylesheet
394 // updates are async. https://crbug.com/567021 393 // updates are async. https://crbug.com/567021
395 document().styleEngine().resolverChanged(FullStyleUpdate); 394 document().styleEngine().resolverChanged(FullStyleUpdate);
396 } 395 }
397 } 396 }
398 397
399 void LinkStyle::setSheetTitle( 398 void LinkStyle::setSheetTitle(const String& title) {
400 const String& title,
401 StyleEngine::ActiveSheetsUpdate updateActiveSheets) {
402 if (!m_owner->isInDocumentTree() || !m_owner->relAttribute().isStyleSheet()) 399 if (!m_owner->isInDocumentTree() || !m_owner->relAttribute().isStyleSheet())
403 return; 400 return;
404 401
405 if (m_sheet) 402 if (m_sheet)
406 m_sheet->setTitle(title); 403 m_sheet->setTitle(title);
407 404
408 if (title.isEmpty() || !isUnset() || m_owner->isAlternate()) 405 if (title.isEmpty() || !isUnset() || m_owner->isAlternate())
409 return; 406 return;
410 407
411 const KURL& href = m_owner->getNonEmptyURLAttribute(hrefAttr); 408 const KURL& href = m_owner->getNonEmptyURLAttribute(hrefAttr);
412 if (href.isValid() && !href.isEmpty()) { 409 if (href.isValid() && !href.isEmpty())
413 document().styleEngine().setPreferredStylesheetSetNameIfNotSet( 410 document().styleEngine().setPreferredStylesheetSetNameIfNotSet(title);
414 title, updateActiveSheets);
415 }
416 } 411 }
417 412
418 void LinkStyle::ownerRemoved() { 413 void LinkStyle::ownerRemoved() {
419 if (m_sheet) 414 if (m_sheet)
420 clearSheet(); 415 clearSheet();
421 416
422 if (styleSheetIsLoading()) 417 if (styleSheetIsLoading())
423 removePendingSheet(); 418 removePendingSheet();
424 } 419 }
425 420
426 DEFINE_TRACE(LinkStyle) { 421 DEFINE_TRACE(LinkStyle) {
427 visitor->trace(m_sheet); 422 visitor->trace(m_sheet);
428 LinkResource::trace(visitor); 423 LinkResource::trace(visitor);
429 ResourceOwner<StyleSheetResource>::trace(visitor); 424 ResourceOwner<StyleSheetResource>::trace(visitor);
430 } 425 }
431 426
432 } // namespace blink 427 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/html/LinkStyle.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698