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

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

Issue 2671933002: Migrate WTF::HashMap::add() to ::insert() (Closed)
Patch Set: rebase, add TODOs Created 3 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 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All
7 * rights reserved. 7 * rights reserved.
8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. 8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved.
9 * (http://www.torchmobile.com/) 9 * (http://www.torchmobile.com/)
10 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved. 10 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved.
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 return nullptr; 91 return nullptr;
92 return import->master(); 92 return import->master();
93 } 93 }
94 94
95 TreeScopeStyleSheetCollection* StyleEngine::ensureStyleSheetCollectionFor( 95 TreeScopeStyleSheetCollection* StyleEngine::ensureStyleSheetCollectionFor(
96 TreeScope& treeScope) { 96 TreeScope& treeScope) {
97 if (treeScope == m_document) 97 if (treeScope == m_document)
98 return &documentStyleSheetCollection(); 98 return &documentStyleSheetCollection();
99 99
100 StyleSheetCollectionMap::AddResult result = 100 StyleSheetCollectionMap::AddResult result =
101 m_styleSheetCollectionMap.add(&treeScope, nullptr); 101 m_styleSheetCollectionMap.insert(&treeScope, nullptr);
102 if (result.isNewEntry) 102 if (result.isNewEntry)
103 result.storedValue->value = 103 result.storedValue->value =
104 new ShadowTreeStyleSheetCollection(toShadowRoot(treeScope)); 104 new ShadowTreeStyleSheetCollection(toShadowRoot(treeScope));
105 return result.storedValue->value.get(); 105 return result.storedValue->value.get();
106 } 106 }
107 107
108 TreeScopeStyleSheetCollection* StyleEngine::styleSheetCollectionFor( 108 TreeScopeStyleSheetCollection* StyleEngine::styleSheetCollectionFor(
109 TreeScope& treeScope) { 109 TreeScope& treeScope) {
110 if (treeScope == m_document) 110 if (treeScope == m_document)
111 return &documentStyleSheetCollection(); 111 return &documentStyleSheetCollection();
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after
523 const String& text, 523 const String& text,
524 TextPosition startPosition, 524 TextPosition startPosition,
525 StyleEngineContext& context) { 525 StyleEngineContext& context) {
526 DCHECK(element.document() == document()); 526 DCHECK(element.document() == document());
527 CSSStyleSheet* styleSheet = nullptr; 527 CSSStyleSheet* styleSheet = nullptr;
528 528
529 addPendingSheet(context); 529 addPendingSheet(context);
530 530
531 AtomicString textContent(text); 531 AtomicString textContent(text);
532 532
533 auto result = m_textToSheetCache.add(textContent, nullptr); 533 auto result = m_textToSheetCache.insert(textContent, nullptr);
534 StyleSheetContents* contents = result.storedValue->value; 534 StyleSheetContents* contents = result.storedValue->value;
535 if (result.isNewEntry || !contents || 535 if (result.isNewEntry || !contents ||
536 !contents->isCacheableForStyleElement()) { 536 !contents->isCacheableForStyleElement()) {
537 result.storedValue->value = nullptr; 537 result.storedValue->value = nullptr;
538 styleSheet = parseSheet(element, text, startPosition); 538 styleSheet = parseSheet(element, text, startPosition);
539 if (styleSheet->contents()->isCacheableForStyleElement()) { 539 if (styleSheet->contents()->isCacheableForStyleElement()) {
540 result.storedValue->value = styleSheet->contents(); 540 result.storedValue->value = styleSheet->contents();
541 m_sheetToTextCache.add(styleSheet->contents(), textContent); 541 m_sheetToTextCache.insert(styleSheet->contents(), textContent);
542 } 542 }
543 } else { 543 } else {
544 DCHECK(contents); 544 DCHECK(contents);
545 DCHECK(contents->isCacheableForStyleElement()); 545 DCHECK(contents->isCacheableForStyleElement());
546 DCHECK(contents->hasSingleOwnerDocument()); 546 DCHECK(contents->hasSingleOwnerDocument());
547 contents->setIsUsedFromTextCache(); 547 contents->setIsUsedFromTextCache();
548 styleSheet = CSSStyleSheet::createInline(contents, element, startPosition); 548 styleSheet = CSSStyleSheet::createInline(contents, element, startPosition);
549 } 549 }
550 550
551 DCHECK(styleSheet); 551 DCHECK(styleSheet);
(...skipping 594 matching lines...) Expand 10 before | Expand all | Expand 10 after
1146 } 1146 }
1147 1147
1148 DEFINE_TRACE_WRAPPERS(StyleEngine) { 1148 DEFINE_TRACE_WRAPPERS(StyleEngine) {
1149 for (auto sheet : m_injectedAuthorStyleSheets) { 1149 for (auto sheet : m_injectedAuthorStyleSheets) {
1150 visitor->traceWrappers(sheet); 1150 visitor->traceWrappers(sheet);
1151 } 1151 }
1152 visitor->traceWrappers(m_documentStyleSheetCollection); 1152 visitor->traceWrappers(m_documentStyleSheetCollection);
1153 } 1153 }
1154 1154
1155 } // namespace blink 1155 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/SpaceSplitString.cpp ('k') | third_party/WebKit/Source/core/dom/UserActionElementSet.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698