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

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

Powered by Google App Engine
This is Rietveld 408576698