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

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

Issue 1913833002: Current work-in-progress crbug.com/567021 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed html import issue. 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
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/fetch/CSSStyleSheetResource.h" 8 #include "core/fetch/CSSStyleSheetResource.h"
9 #include "core/frame/LocalFrame.h" 9 #include "core/frame/LocalFrame.h"
10 #include "core/frame/SubresourceIntegrity.h" 10 #include "core/frame/SubresourceIntegrity.h"
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 } 299 }
300 300
301 if (!m_owner->shouldLoadLink()) 301 if (!m_owner->shouldLoadLink())
302 return Bail; 302 return Bail;
303 303
304 m_loading = true; 304 m_loading = true;
305 305
306 String title = m_owner->title(); 306 String title = m_owner->title();
307 if (!title.isEmpty() && !m_owner->isAlternate() && 307 if (!title.isEmpty() && !m_owner->isAlternate() &&
308 m_disabledState != EnabledViaScript && m_owner->isInDocumentTree()) { 308 m_disabledState != EnabledViaScript && m_owner->isInDocumentTree()) {
309 document().styleEngine().setPreferredStylesheetSetNameIfNotSet( 309 document().styleEngine().setPreferredStylesheetSetNameIfNotSet(title);
310 title, StyleEngine::DontUpdateActiveSheets);
311 } 310 }
312 311
313 bool mediaQueryMatches = true; 312 bool mediaQueryMatches = true;
314 LocalFrame* frame = loadingFrame(); 313 LocalFrame* frame = loadingFrame();
315 if (!m_owner->media().isEmpty() && frame) { 314 if (!m_owner->media().isEmpty() && frame) {
316 MediaQuerySet* media = MediaQuerySet::create(m_owner->media()); 315 MediaQuerySet* media = MediaQuerySet::create(m_owner->media());
317 MediaQueryEvaluator evaluator(frame); 316 MediaQueryEvaluator evaluator(frame);
318 mediaQueryMatches = evaluator.eval(media); 317 mediaQueryMatches = evaluator.eval(media);
319 } 318 }
320 319
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 m_owner->relAttribute().getIconType()); 379 m_owner->relAttribute().getIconType());
381 } 380 }
382 } 381 }
383 382
384 if (!m_owner->loadLink(type, as, media, m_owner->referrerPolicy(), 383 if (!m_owner->loadLink(type, as, media, m_owner->referrerPolicy(),
385 builder.url())) 384 builder.url()))
386 return; 385 return;
387 386
388 if (loadStylesheetIfNeeded(builder, type) == NotNeeded && m_sheet) { 387 if (loadStylesheetIfNeeded(builder, type) == NotNeeded && m_sheet) {
389 // we no longer contain a stylesheet, e.g. perhaps rel or type was changed 388 // we no longer contain a stylesheet, e.g. perhaps rel or type was changed
390 StyleSheet* removedSheet = m_sheet.get();
391 clearSheet(); 389 clearSheet();
392 document().styleEngine().setNeedsActiveStyleUpdate(removedSheet, 390 if (m_owner->isConnected())
393 FullStyleUpdate); 391 document().styleEngine().setNeedsActiveStyleUpdate(m_owner->treeScope());
394 } 392 }
395 } 393 }
396 394
397 void LinkStyle::setSheetTitle( 395 void LinkStyle::setSheetTitle(const String& title) {
398 const String& title,
399 StyleEngine::ActiveSheetsUpdate updateActiveSheets) {
400 if (!m_owner->isInDocumentTree() || !m_owner->relAttribute().isStyleSheet()) 396 if (!m_owner->isInDocumentTree() || !m_owner->relAttribute().isStyleSheet())
401 return; 397 return;
402 398
403 if (m_sheet) 399 if (m_sheet)
404 m_sheet->setTitle(title); 400 m_sheet->setTitle(title);
405 401
406 if (title.isEmpty() || !isUnset() || m_owner->isAlternate()) 402 if (title.isEmpty() || !isUnset() || m_owner->isAlternate())
407 return; 403 return;
408 404
409 KURL href = m_owner->getNonEmptyURLAttribute(hrefAttr); 405 KURL href = m_owner->getNonEmptyURLAttribute(hrefAttr);
410 if (href.isValid() && !href.isEmpty()) { 406 if (href.isValid() && !href.isEmpty())
411 document().styleEngine().setPreferredStylesheetSetNameIfNotSet( 407 document().styleEngine().setPreferredStylesheetSetNameIfNotSet(title);
412 title, updateActiveSheets);
413 }
414 } 408 }
415 409
416 void LinkStyle::ownerRemoved() { 410 void LinkStyle::ownerRemoved() {
417 if (m_sheet) 411 if (m_sheet)
418 clearSheet(); 412 clearSheet();
419 413
420 if (styleSheetIsLoading()) 414 if (styleSheetIsLoading())
421 removePendingSheet(); 415 removePendingSheet();
422 } 416 }
423 417
424 DEFINE_TRACE(LinkStyle) { 418 DEFINE_TRACE(LinkStyle) {
425 visitor->trace(m_sheet); 419 visitor->trace(m_sheet);
426 LinkResource::trace(visitor); 420 LinkResource::trace(visitor);
427 ResourceOwner<StyleSheetResource>::trace(visitor); 421 ResourceOwner<StyleSheetResource>::trace(visitor);
428 } 422 }
429 423
430 } // namespace blink 424 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/html/LinkStyle.h ('k') | third_party/WebKit/Source/core/html/imports/HTMLImportChild.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698