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

Side by Side Diff: Source/core/dom/StyleEngine.cpp

Issue 975933002: Return reference from styleEngine() accessor. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 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
« no previous file with comments | « Source/core/dom/StyleEngine.h ('k') | Source/core/dom/shadow/ShadowRoot.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 * (C) 2006 Alexey Proskuryakov (ap@webkit.org) 5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org)
6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All r ights reserved. 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All r ights reserved.
7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/) 7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/)
8 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved. 8 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved.
9 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) 9 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
10 * Copyright (C) Research In Motion Limited 2010-2011. All rights reserved. 10 * Copyright (C) Research In Motion Limited 2010-2011. All rights reserved.
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after
400 documentStyleSheetCollection()->clearMediaQueryRuleSetStyleSheets(); 400 documentStyleSheetCollection()->clearMediaQueryRuleSetStyleSheets();
401 clearMediaQueryRuleSetOnTreeScopeStyleSheets(m_activeTreeScopes.beginUnorder ed(), m_activeTreeScopes.endUnordered()); 401 clearMediaQueryRuleSetOnTreeScopeStyleSheets(m_activeTreeScopes.beginUnorder ed(), m_activeTreeScopes.endUnordered());
402 clearMediaQueryRuleSetOnTreeScopeStyleSheets(m_dirtyTreeScopes.begin(), m_di rtyTreeScopes.end()); 402 clearMediaQueryRuleSetOnTreeScopeStyleSheets(m_dirtyTreeScopes.begin(), m_di rtyTreeScopes.end());
403 } 403 }
404 404
405 void StyleEngine::updateStyleSheetsInImport(DocumentStyleSheetCollector& parentC ollector) 405 void StyleEngine::updateStyleSheetsInImport(DocumentStyleSheetCollector& parentC ollector)
406 { 406 {
407 ASSERT(!isMaster()); 407 ASSERT(!isMaster());
408 WillBeHeapVector<RefPtrWillBeMember<StyleSheet> > sheetsForList; 408 WillBeHeapVector<RefPtrWillBeMember<StyleSheet> > sheetsForList;
409 ImportedDocumentStyleSheetCollector subcollector(parentCollector, sheetsForL ist); 409 ImportedDocumentStyleSheetCollector subcollector(parentCollector, sheetsForL ist);
410 documentStyleSheetCollection()->collectStyleSheets(this, subcollector); 410 documentStyleSheetCollection()->collectStyleSheets(*this, subcollector);
411 documentStyleSheetCollection()->swapSheetsForSheetList(sheetsForList); 411 documentStyleSheetCollection()->swapSheetsForSheetList(sheetsForList);
412 } 412 }
413 413
414 void StyleEngine::updateActiveStyleSheetsInShadow(StyleResolverUpdateMode update Mode, TreeScope* treeScope, UnorderedTreeScopeSet& treeScopesRemoved) 414 void StyleEngine::updateActiveStyleSheetsInShadow(StyleResolverUpdateMode update Mode, TreeScope* treeScope, UnorderedTreeScopeSet& treeScopesRemoved)
415 { 415 {
416 ASSERT(treeScope != m_document); 416 ASSERT(treeScope != m_document);
417 ShadowTreeStyleSheetCollection* collection = static_cast<ShadowTreeStyleShee tCollection*>(styleSheetCollectionFor(*treeScope)); 417 ShadowTreeStyleSheetCollection* collection = static_cast<ShadowTreeStyleShee tCollection*>(styleSheetCollectionFor(*treeScope));
418 ASSERT(collection); 418 ASSERT(collection);
419 collection->updateActiveStyleSheets(this, updateMode); 419 collection->updateActiveStyleSheets(*this, updateMode);
420 if (!collection->hasStyleSheetCandidateNodes()) { 420 if (!collection->hasStyleSheetCandidateNodes()) {
421 treeScopesRemoved.add(treeScope); 421 treeScopesRemoved.add(treeScope);
422 // When removing TreeScope from ActiveTreeScopes, 422 // When removing TreeScope from ActiveTreeScopes,
423 // its resolver should be destroyed by invoking resetAuthorStyle. 423 // its resolver should be destroyed by invoking resetAuthorStyle.
424 ASSERT(!treeScope->scopedStyleResolver()); 424 ASSERT(!treeScope->scopedStyleResolver());
425 } 425 }
426 } 426 }
427 427
428 void StyleEngine::updateActiveStyleSheets(StyleResolverUpdateMode updateMode) 428 void StyleEngine::updateActiveStyleSheets(StyleResolverUpdateMode updateMode)
429 { 429 {
430 ASSERT(isMaster()); 430 ASSERT(isMaster());
431 ASSERT(!document().inStyleRecalc()); 431 ASSERT(!document().inStyleRecalc());
432 432
433 if (!document().isActive()) 433 if (!document().isActive())
434 return; 434 return;
435 435
436 if (shouldUpdateDocumentStyleSheetCollection(updateMode)) 436 if (shouldUpdateDocumentStyleSheetCollection(updateMode))
437 documentStyleSheetCollection()->updateActiveStyleSheets(this, updateMode ); 437 documentStyleSheetCollection()->updateActiveStyleSheets(*this, updateMod e);
438 438
439 if (shouldUpdateShadowTreeStyleSheetCollection(updateMode)) { 439 if (shouldUpdateShadowTreeStyleSheetCollection(updateMode)) {
440 UnorderedTreeScopeSet treeScopesRemoved; 440 UnorderedTreeScopeSet treeScopesRemoved;
441 441
442 if (updateMode == FullStyleUpdate) { 442 if (updateMode == FullStyleUpdate) {
443 for (unsigned i = 0; i < m_activeTreeScopes.size(); ++i) 443 for (unsigned i = 0; i < m_activeTreeScopes.size(); ++i)
444 updateActiveStyleSheetsInShadow(updateMode, m_activeTreeScopes[i ], treeScopesRemoved); 444 updateActiveStyleSheetsInShadow(updateMode, m_activeTreeScopes[i ], treeScopesRemoved);
445 } else { 445 } else {
446 for (UnorderedTreeScopeSet::iterator it = m_dirtyTreeScopes.begin(); it != m_dirtyTreeScopes.end(); ++it) { 446 for (UnorderedTreeScopeSet::iterator it = m_dirtyTreeScopes.begin(); it != m_dirtyTreeScopes.end(); ++it) {
447 updateActiveStyleSheetsInShadow(updateMode, *it, treeScopesRemov ed); 447 updateActiveStyleSheetsInShadow(updateMode, *it, treeScopesRemov ed);
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
538 (*it)->clearScopedStyleResolver(); 538 (*it)->clearScopedStyleResolver();
539 539
540 if (m_resolver) 540 if (m_resolver)
541 document().updateStyleInvalidationIfNeeded(); 541 document().updateStyleInvalidationIfNeeded();
542 m_resolver.clear(); 542 m_resolver.clear();
543 } 543 }
544 544
545 void StyleEngine::clearMasterResolver() 545 void StyleEngine::clearMasterResolver()
546 { 546 {
547 if (Document* master = this->master()) 547 if (Document* master = this->master())
548 master->styleEngine()->clearResolver(); 548 master->styleEngine().clearResolver();
549 } 549 }
550 550
551 unsigned StyleEngine::resolverAccessCount() const 551 unsigned StyleEngine::resolverAccessCount() const
552 { 552 {
553 return m_resolver ? m_resolver->accessCount() : 0; 553 return m_resolver ? m_resolver->accessCount() : 0;
554 } 554 }
555 555
556 void StyleEngine::didDetach() 556 void StyleEngine::didDetach()
557 { 557 {
558 clearResolver(); 558 clearResolver();
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
623 return; 623 return;
624 } 624 }
625 625
626 m_dirtyTreeScopes.add(&scope); 626 m_dirtyTreeScopes.add(&scope);
627 } 627 }
628 628
629 void StyleEngine::markDocumentDirty() 629 void StyleEngine::markDocumentDirty()
630 { 630 {
631 m_documentScopeDirty = true; 631 m_documentScopeDirty = true;
632 if (document().importLoader()) 632 if (document().importLoader())
633 document().importsController()->master()->styleEngine()->markDocumentDir ty(); 633 document().importsController()->master()->styleEngine().markDocumentDirt y();
634 } 634 }
635 635
636 static bool isCacheableForStyleElement(const StyleSheetContents& contents) 636 static bool isCacheableForStyleElement(const StyleSheetContents& contents)
637 { 637 {
638 // FIXME: Support copying import rules. 638 // FIXME: Support copying import rules.
639 if (!contents.importRules().isEmpty()) 639 if (!contents.importRules().isEmpty())
640 return false; 640 return false;
641 // Until import rules are supported in cached sheets it's not possible for l oading to fail. 641 // Until import rules are supported in cached sheets it's not possible for l oading to fail.
642 ASSERT(!contents.didLoadErrorOccur()); 642 ASSERT(!contents.didLoadErrorOccur());
643 // It is not the original sheet anymore. 643 // It is not the original sheet anymore.
644 if (contents.isMutable()) 644 if (contents.isMutable())
645 return false; 645 return false;
646 if (!contents.hasSyntacticallyValidCSSHeader()) 646 if (!contents.hasSyntacticallyValidCSSHeader())
647 return false; 647 return false;
648 return true; 648 return true;
649 } 649 }
650 650
651 PassRefPtrWillBeRawPtr<CSSStyleSheet> StyleEngine::createSheet(Element* e, const String& text, TextPosition startPosition, bool createdByParser) 651 PassRefPtrWillBeRawPtr<CSSStyleSheet> StyleEngine::createSheet(Element* e, const String& text, TextPosition startPosition, bool createdByParser)
652 { 652 {
653 RefPtrWillBeRawPtr<CSSStyleSheet> styleSheet = nullptr; 653 RefPtrWillBeRawPtr<CSSStyleSheet> styleSheet = nullptr;
654 654
655 e->document().styleEngine()->addPendingSheet(); 655 e->document().styleEngine().addPendingSheet();
656 656
657 if (!e->document().inQuirksMode()) { 657 if (!e->document().inQuirksMode()) {
658 AtomicString textContent(text); 658 AtomicString textContent(text);
659 659
660 WillBeHeapHashMap<AtomicString, RawPtrWillBeMember<StyleSheetContents> > ::AddResult result = m_textToSheetCache.add(textContent, nullptr); 660 WillBeHeapHashMap<AtomicString, RawPtrWillBeMember<StyleSheetContents> > ::AddResult result = m_textToSheetCache.add(textContent, nullptr);
661 if (result.isNewEntry || !result.storedValue->value) { 661 if (result.isNewEntry || !result.storedValue->value) {
662 styleSheet = StyleEngine::parseSheet(e, text, startPosition, created ByParser); 662 styleSheet = StyleEngine::parseSheet(e, text, startPosition, created ByParser);
663 if (result.isNewEntry && isCacheableForStyleElement(*styleSheet->con tents())) { 663 if (result.isNewEntry && isCacheableForStyleElement(*styleSheet->con tents())) {
664 result.storedValue->value = styleSheet->contents(); 664 result.storedValue->value = styleSheet->contents();
665 m_sheetToTextCache.add(styleSheet->contents(), textContent); 665 m_sheetToTextCache.add(styleSheet->contents(), textContent);
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
750 visitor->trace(m_dirtyTreeScopes); 750 visitor->trace(m_dirtyTreeScopes);
751 visitor->trace(m_activeTreeScopes); 751 visitor->trace(m_activeTreeScopes);
752 visitor->trace(m_fontSelector); 752 visitor->trace(m_fontSelector);
753 visitor->trace(m_textToSheetCache); 753 visitor->trace(m_textToSheetCache);
754 visitor->trace(m_sheetToTextCache); 754 visitor->trace(m_sheetToTextCache);
755 #endif 755 #endif
756 CSSFontSelectorClient::trace(visitor); 756 CSSFontSelectorClient::trace(visitor);
757 } 757 }
758 758
759 } 759 }
OLDNEW
« no previous file with comments | « Source/core/dom/StyleEngine.h ('k') | Source/core/dom/shadow/ShadowRoot.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698