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

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

Issue 1686483002: Oilpan: Remove most WillBe types from the code base (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 * (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 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 return import->master(); 109 return import->master();
110 } 110 }
111 111
112 TreeScopeStyleSheetCollection* StyleEngine::ensureStyleSheetCollectionFor(TreeSc ope& treeScope) 112 TreeScopeStyleSheetCollection* StyleEngine::ensureStyleSheetCollectionFor(TreeSc ope& treeScope)
113 { 113 {
114 if (treeScope == m_document) 114 if (treeScope == m_document)
115 return documentStyleSheetCollection(); 115 return documentStyleSheetCollection();
116 116
117 StyleSheetCollectionMap::AddResult result = m_styleSheetCollectionMap.add(&t reeScope, nullptr); 117 StyleSheetCollectionMap::AddResult result = m_styleSheetCollectionMap.add(&t reeScope, nullptr);
118 if (result.isNewEntry) 118 if (result.isNewEntry)
119 result.storedValue->value = adoptPtrWillBeNoop(new ShadowTreeStyleSheetC ollection(toShadowRoot(treeScope))); 119 result.storedValue->value = new ShadowTreeStyleSheetCollection(toShadowR oot(treeScope));
120 return result.storedValue->value.get(); 120 return result.storedValue->value.get();
121 } 121 }
122 122
123 TreeScopeStyleSheetCollection* StyleEngine::styleSheetCollectionFor(TreeScope& t reeScope) 123 TreeScopeStyleSheetCollection* StyleEngine::styleSheetCollectionFor(TreeScope& t reeScope)
124 { 124 {
125 if (treeScope == m_document) 125 if (treeScope == m_document)
126 return documentStyleSheetCollection(); 126 return documentStyleSheetCollection();
127 127
128 StyleSheetCollectionMap::iterator it = m_styleSheetCollectionMap.find(&treeS cope); 128 StyleSheetCollectionMap::iterator it = m_styleSheetCollectionMap.find(&treeS cope);
129 if (it == m_styleSheetCollectionMap.end()) 129 if (it == m_styleSheetCollectionMap.end())
130 return 0; 130 return 0;
131 return it->value.get(); 131 return it->value.get();
132 } 132 }
133 133
134 const WillBeHeapVector<RefPtrWillBeMember<StyleSheet>>& StyleEngine::styleSheets ForStyleSheetList(TreeScope& treeScope) 134 const HeapVector<Member<StyleSheet>>& StyleEngine::styleSheetsForStyleSheetList( TreeScope& treeScope)
135 { 135 {
136 if (treeScope == m_document) 136 if (treeScope == m_document)
137 return documentStyleSheetCollection()->styleSheetsForStyleSheetList(); 137 return documentStyleSheetCollection()->styleSheetsForStyleSheetList();
138 138
139 return ensureStyleSheetCollectionFor(treeScope)->styleSheetsForStyleSheetLis t(); 139 return ensureStyleSheetCollectionFor(treeScope)->styleSheetsForStyleSheetLis t();
140 } 140 }
141 141
142 void StyleEngine::resetCSSFeatureFlags(const RuleFeatureSet& features) 142 void StyleEngine::resetCSSFeatureFlags(const RuleFeatureSet& features)
143 { 143 {
144 m_usesSiblingRules = features.usesSiblingRules(); 144 m_usesSiblingRules = features.usesSiblingRules();
145 m_usesFirstLineRules = features.usesFirstLineRules(); 145 m_usesFirstLineRules = features.usesFirstLineRules();
146 m_usesWindowInactiveSelector = features.usesWindowInactiveSelector(); 146 m_usesWindowInactiveSelector = features.usesWindowInactiveSelector();
147 m_maxDirectAdjacentSelectors = features.maxDirectAdjacentSelectors(); 147 m_maxDirectAdjacentSelectors = features.maxDirectAdjacentSelectors();
148 } 148 }
149 149
150 void StyleEngine::injectAuthorSheet(PassRefPtrWillBeRawPtr<StyleSheetContents> a uthorSheet) 150 void StyleEngine::injectAuthorSheet(RawPtr<StyleSheetContents> authorSheet)
151 { 151 {
152 m_injectedAuthorStyleSheets.append(CSSStyleSheet::create(authorSheet, m_docu ment)); 152 m_injectedAuthorStyleSheets.append(CSSStyleSheet::create(authorSheet, m_docu ment));
153 markDocumentDirty(); 153 markDocumentDirty();
154 resolverChanged(AnalyzedStyleUpdate); 154 resolverChanged(AnalyzedStyleUpdate);
155 } 155 }
156 156
157 void StyleEngine::addPendingSheet() 157 void StyleEngine::addPendingSheet()
158 { 158 {
159 m_pendingStylesheets++; 159 m_pendingStylesheets++;
160 } 160 }
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 void StyleEngine::clearMediaQueryRuleSetStyleSheets() 272 void StyleEngine::clearMediaQueryRuleSetStyleSheets()
273 { 273 {
274 resolverChanged(FullStyleUpdate); 274 resolverChanged(FullStyleUpdate);
275 documentStyleSheetCollection()->clearMediaQueryRuleSetStyleSheets(); 275 documentStyleSheetCollection()->clearMediaQueryRuleSetStyleSheets();
276 clearMediaQueryRuleSetOnTreeScopeStyleSheets(m_activeTreeScopes); 276 clearMediaQueryRuleSetOnTreeScopeStyleSheets(m_activeTreeScopes);
277 } 277 }
278 278
279 void StyleEngine::updateStyleSheetsInImport(DocumentStyleSheetCollector& parentC ollector) 279 void StyleEngine::updateStyleSheetsInImport(DocumentStyleSheetCollector& parentC ollector)
280 { 280 {
281 ASSERT(!isMaster()); 281 ASSERT(!isMaster());
282 WillBeHeapVector<RefPtrWillBeMember<StyleSheet>> sheetsForList; 282 HeapVector<Member<StyleSheet>> sheetsForList;
283 ImportedDocumentStyleSheetCollector subcollector(parentCollector, sheetsForL ist); 283 ImportedDocumentStyleSheetCollector subcollector(parentCollector, sheetsForL ist);
284 documentStyleSheetCollection()->collectStyleSheets(*this, subcollector); 284 documentStyleSheetCollection()->collectStyleSheets(*this, subcollector);
285 documentStyleSheetCollection()->swapSheetsForSheetList(sheetsForList); 285 documentStyleSheetCollection()->swapSheetsForSheetList(sheetsForList);
286 } 286 }
287 287
288 void StyleEngine::updateActiveStyleSheetsInShadow(StyleResolverUpdateMode update Mode, TreeScope* treeScope, UnorderedTreeScopeSet& treeScopesRemoved) 288 void StyleEngine::updateActiveStyleSheetsInShadow(StyleResolverUpdateMode update Mode, TreeScope* treeScope, UnorderedTreeScopeSet& treeScopesRemoved)
289 { 289 {
290 ASSERT(treeScope != m_document); 290 ASSERT(treeScope != m_document);
291 ShadowTreeStyleSheetCollection* collection = static_cast<ShadowTreeStyleShee tCollection*>(styleSheetCollectionFor(*treeScope)); 291 ShadowTreeStyleSheetCollection* collection = static_cast<ShadowTreeStyleShee tCollection*>(styleSheetCollectionFor(*treeScope));
292 ASSERT(collection); 292 ASSERT(collection);
(...skipping 30 matching lines...) Expand all
323 for (TreeScope* treeScope : treeScopesRemoved) 323 for (TreeScope* treeScope : treeScopesRemoved)
324 m_activeTreeScopes.remove(treeScope); 324 m_activeTreeScopes.remove(treeScope);
325 } 325 }
326 326
327 InspectorInstrumentation::activeStyleSheetsUpdated(m_document); 327 InspectorInstrumentation::activeStyleSheetsUpdated(m_document);
328 328
329 m_dirtyTreeScopes.clear(); 329 m_dirtyTreeScopes.clear();
330 m_documentScopeDirty = false; 330 m_documentScopeDirty = false;
331 } 331 }
332 332
333 const WillBeHeapVector<RefPtrWillBeMember<CSSStyleSheet>> StyleEngine::activeSty leSheetsForInspector() const 333 const HeapVector<Member<CSSStyleSheet>> StyleEngine::activeStyleSheetsForInspect or() const
334 { 334 {
335 if (m_activeTreeScopes.isEmpty()) 335 if (m_activeTreeScopes.isEmpty())
336 return documentStyleSheetCollection()->activeAuthorStyleSheets(); 336 return documentStyleSheetCollection()->activeAuthorStyleSheets();
337 337
338 WillBeHeapVector<RefPtrWillBeMember<CSSStyleSheet>> activeStyleSheets; 338 HeapVector<Member<CSSStyleSheet>> activeStyleSheets;
339 339
340 activeStyleSheets.appendVector(documentStyleSheetCollection()->activeAuthorS tyleSheets()); 340 activeStyleSheets.appendVector(documentStyleSheetCollection()->activeAuthorS tyleSheets());
341 for (TreeScope* treeScope : m_activeTreeScopes) { 341 for (TreeScope* treeScope : m_activeTreeScopes) {
342 if (TreeScopeStyleSheetCollection* collection = m_styleSheetCollectionMa p.get(treeScope)) 342 if (TreeScopeStyleSheetCollection* collection = m_styleSheetCollectionMa p.get(treeScope))
343 activeStyleSheets.appendVector(collection->activeAuthorStyleSheets() ); 343 activeStyleSheets.appendVector(collection->activeAuthorStyleSheets() );
344 } 344 }
345 345
346 // FIXME: Inspector needs a vector which has all active stylesheets. 346 // FIXME: Inspector needs a vector which has all active stylesheets.
347 // However, creating such a large vector might cause performance regression. 347 // However, creating such a large vector might cause performance regression.
348 // Need to implement some smarter solution. 348 // Need to implement some smarter solution.
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
471 471
472 if (!m_fontSelector) 472 if (!m_fontSelector)
473 return; 473 return;
474 474
475 m_fontSelector->updateGenericFontFamilySettings(*m_document); 475 m_fontSelector->updateGenericFontFamilySettings(*m_document);
476 if (m_resolver) 476 if (m_resolver)
477 m_resolver->invalidateMatchedPropertiesCache(); 477 m_resolver->invalidateMatchedPropertiesCache();
478 FontCache::fontCache()->invalidateShapeCache(); 478 FontCache::fontCache()->invalidateShapeCache();
479 } 479 }
480 480
481 void StyleEngine::removeFontFaceRules(const WillBeHeapVector<RawPtrWillBeMember< const StyleRuleFontFace>>& fontFaceRules) 481 void StyleEngine::removeFontFaceRules(const HeapVector<Member<const StyleRuleFon tFace>>& fontFaceRules)
482 { 482 {
483 if (!m_fontSelector) 483 if (!m_fontSelector)
484 return; 484 return;
485 485
486 FontFaceCache* cache = m_fontSelector->fontFaceCache(); 486 FontFaceCache* cache = m_fontSelector->fontFaceCache();
487 for (unsigned i = 0; i < fontFaceRules.size(); ++i) 487 for (unsigned i = 0; i < fontFaceRules.size(); ++i)
488 cache->remove(fontFaceRules[i]); 488 cache->remove(fontFaceRules[i]);
489 if (m_resolver) 489 if (m_resolver)
490 m_resolver->invalidateMatchedPropertiesCache(); 490 m_resolver->invalidateMatchedPropertiesCache();
491 } 491 }
(...skipping 24 matching lines...) Expand all
516 // Until import rules are supported in cached sheets it's not possible for l oading to fail. 516 // Until import rules are supported in cached sheets it's not possible for l oading to fail.
517 ASSERT(!contents.didLoadErrorOccur()); 517 ASSERT(!contents.didLoadErrorOccur());
518 // It is not the original sheet anymore. 518 // It is not the original sheet anymore.
519 if (contents.isMutable()) 519 if (contents.isMutable())
520 return false; 520 return false;
521 if (!contents.hasSyntacticallyValidCSSHeader()) 521 if (!contents.hasSyntacticallyValidCSSHeader())
522 return false; 522 return false;
523 return true; 523 return true;
524 } 524 }
525 525
526 PassRefPtrWillBeRawPtr<CSSStyleSheet> StyleEngine::createSheet(Element* e, const String& text, TextPosition startPosition) 526 RawPtr<CSSStyleSheet> StyleEngine::createSheet(Element* e, const String& text, T extPosition startPosition)
527 { 527 {
528 RefPtrWillBeRawPtr<CSSStyleSheet> styleSheet = nullptr; 528 RawPtr<CSSStyleSheet> styleSheet = nullptr;
529 529
530 e->document().styleEngine().addPendingSheet(); 530 e->document().styleEngine().addPendingSheet();
531 531
532 AtomicString textContent(text); 532 AtomicString textContent(text);
533 533
534 WillBeHeapHashMap<AtomicString, RawPtrWillBeMember<StyleSheetContents>>::Add Result result = m_textToSheetCache.add(textContent, nullptr); 534 HeapHashMap<AtomicString, Member<StyleSheetContents>>::AddResult result = m_ textToSheetCache.add(textContent, nullptr);
535 if (result.isNewEntry || !result.storedValue->value) { 535 if (result.isNewEntry || !result.storedValue->value) {
536 styleSheet = StyleEngine::parseSheet(e, text, startPosition); 536 styleSheet = StyleEngine::parseSheet(e, text, startPosition);
537 if (result.isNewEntry && isCacheableForStyleElement(*styleSheet->content s())) { 537 if (result.isNewEntry && isCacheableForStyleElement(*styleSheet->content s())) {
538 result.storedValue->value = styleSheet->contents(); 538 result.storedValue->value = styleSheet->contents();
539 m_sheetToTextCache.add(styleSheet->contents(), textContent); 539 m_sheetToTextCache.add(styleSheet->contents(), textContent);
540 } 540 }
541 } else { 541 } else {
542 StyleSheetContents* contents = result.storedValue->value; 542 StyleSheetContents* contents = result.storedValue->value;
543 ASSERT(contents); 543 ASSERT(contents);
544 ASSERT(isCacheableForStyleElement(*contents)); 544 ASSERT(isCacheableForStyleElement(*contents));
545 ASSERT(contents->singleOwnerDocument() == e->document()); 545 ASSERT(contents->singleOwnerDocument() == e->document());
546 styleSheet = CSSStyleSheet::createInline(contents, e, startPosition); 546 styleSheet = CSSStyleSheet::createInline(contents, e, startPosition);
547 } 547 }
548 548
549 ASSERT(styleSheet); 549 ASSERT(styleSheet);
550 styleSheet->setTitle(e->title()); 550 styleSheet->setTitle(e->title());
551 return styleSheet; 551 return styleSheet;
552 } 552 }
553 553
554 PassRefPtrWillBeRawPtr<CSSStyleSheet> StyleEngine::parseSheet(Element* e, const String& text, TextPosition startPosition) 554 RawPtr<CSSStyleSheet> StyleEngine::parseSheet(Element* e, const String& text, Te xtPosition startPosition)
555 { 555 {
556 RefPtrWillBeRawPtr<CSSStyleSheet> styleSheet = nullptr; 556 RawPtr<CSSStyleSheet> styleSheet = nullptr;
557 styleSheet = CSSStyleSheet::createInline(e, KURL(), startPosition, e->docume nt().characterSet()); 557 styleSheet = CSSStyleSheet::createInline(e, KURL(), startPosition, e->docume nt().characterSet());
558 styleSheet->contents()->parseStringAtPosition(text, startPosition); 558 styleSheet->contents()->parseStringAtPosition(text, startPosition);
559 return styleSheet; 559 return styleSheet;
560 } 560 }
561 561
562 void StyleEngine::removeSheet(StyleSheetContents* contents) 562 void StyleEngine::removeSheet(StyleSheetContents* contents)
563 { 563 {
564 WillBeHeapHashMap<RawPtrWillBeMember<StyleSheetContents>, AtomicString>::ite rator it = m_sheetToTextCache.find(contents); 564 HeapHashMap<Member<StyleSheetContents>, AtomicString>::iterator it = m_sheet ToTextCache.find(contents);
565 if (it == m_sheetToTextCache.end()) 565 if (it == m_sheetToTextCache.end())
566 return; 566 return;
567 567
568 m_textToSheetCache.remove(it->value); 568 m_textToSheetCache.remove(it->value);
569 m_sheetToTextCache.remove(contents); 569 m_sheetToTextCache.remove(contents);
570 } 570 }
571 571
572 void StyleEngine::collectScopedStyleFeaturesTo(RuleFeatureSet& features) const 572 void StyleEngine::collectScopedStyleFeaturesTo(RuleFeatureSet& features) const
573 { 573 {
574 WillBeHeapHashSet<RawPtrWillBeMember<const StyleSheetContents>> visitedShare dStyleSheetContents; 574 HeapHashSet<Member<const StyleSheetContents>> visitedSharedStyleSheetContent s;
575 if (document().scopedStyleResolver()) 575 if (document().scopedStyleResolver())
576 document().scopedStyleResolver()->collectFeaturesTo(features, visitedSha redStyleSheetContents); 576 document().scopedStyleResolver()->collectFeaturesTo(features, visitedSha redStyleSheetContents);
577 for (TreeScope* treeScope : m_activeTreeScopes) { 577 for (TreeScope* treeScope : m_activeTreeScopes) {
578 // When creating StyleResolver, dirty treescopes might not be processed. 578 // When creating StyleResolver, dirty treescopes might not be processed.
579 // So some active treescopes might not have a scoped style resolver. 579 // So some active treescopes might not have a scoped style resolver.
580 // In this case, we should skip collectFeatures for the treescopes witho ut 580 // In this case, we should skip collectFeatures for the treescopes witho ut
581 // scoped style resolvers. When invoking updateActiveStyleSheets, 581 // scoped style resolvers. When invoking updateActiveStyleSheets,
582 // the treescope's features will be processed. 582 // the treescope's features will be processed.
583 if (ScopedStyleResolver* resolver = treeScope->scopedStyleResolver()) 583 if (ScopedStyleResolver* resolver = treeScope->scopedStyleResolver())
584 resolver->collectFeaturesTo(features, visitedSharedStyleSheetContent s); 584 resolver->collectFeaturesTo(features, visitedSharedStyleSheetContent s);
585 } 585 }
586 } 586 }
587 587
588 void StyleEngine::fontsNeedUpdate(CSSFontSelector*) 588 void StyleEngine::fontsNeedUpdate(CSSFontSelector*)
589 { 589 {
590 if (!document().isActive()) 590 if (!document().isActive())
591 return; 591 return;
592 592
593 if (m_resolver) 593 if (m_resolver)
594 m_resolver->invalidateMatchedPropertiesCache(); 594 m_resolver->invalidateMatchedPropertiesCache();
595 document().setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonForTraci ng::create(StyleChangeReason::Fonts)); 595 document().setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonForTraci ng::create(StyleChangeReason::Fonts));
596 } 596 }
597 597
598 void StyleEngine::setFontSelector(PassRefPtrWillBeRawPtr<CSSFontSelector> fontSe lector) 598 void StyleEngine::setFontSelector(RawPtr<CSSFontSelector> fontSelector)
599 { 599 {
600 #if !ENABLE(OILPAN) 600 #if !ENABLE(OILPAN)
601 if (m_fontSelector) 601 if (m_fontSelector)
602 m_fontSelector->unregisterForInvalidationCallbacks(this); 602 m_fontSelector->unregisterForInvalidationCallbacks(this);
603 #endif 603 #endif
604 m_fontSelector = fontSelector; 604 m_fontSelector = fontSelector;
605 if (m_fontSelector) 605 if (m_fontSelector)
606 m_fontSelector->registerForInvalidationCallbacks(this); 606 m_fontSelector->registerForInvalidationCallbacks(this);
607 } 607 }
608 608
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
790 visitor->trace(m_dirtyTreeScopes); 790 visitor->trace(m_dirtyTreeScopes);
791 visitor->trace(m_activeTreeScopes); 791 visitor->trace(m_activeTreeScopes);
792 visitor->trace(m_fontSelector); 792 visitor->trace(m_fontSelector);
793 visitor->trace(m_textToSheetCache); 793 visitor->trace(m_textToSheetCache);
794 visitor->trace(m_sheetToTextCache); 794 visitor->trace(m_sheetToTextCache);
795 #endif 795 #endif
796 CSSFontSelectorClient::trace(visitor); 796 CSSFontSelectorClient::trace(visitor);
797 } 797 }
798 798
799 } // namespace blink 799 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/StyleEngine.h ('k') | third_party/WebKit/Source/core/dom/StyleEngineTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698