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

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

Issue 112843002: Make calls to AtomicString(const String&) explicit in dom/ (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Added comments Created 6 years, 11 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/NamedFlowCollection.h ('k') | Source/core/dom/Node.h » ('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) 2012 Adobe Systems Incorporated. All rights reserved. 2 * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above 8 * 1. Redistributions of source code must retain the above
9 * copyright notice, this list of conditions and the following 9 * copyright notice, this list of conditions and the following
10 * disclaimer. 10 * disclaimer.
(...skipping 16 matching lines...) Expand all
27 * SUCH DAMAGE. 27 * SUCH DAMAGE.
28 */ 28 */
29 29
30 #include "config.h" 30 #include "config.h"
31 #include "core/dom/NamedFlowCollection.h" 31 #include "core/dom/NamedFlowCollection.h"
32 32
33 #include "RuntimeEnabledFeatures.h" 33 #include "RuntimeEnabledFeatures.h"
34 #include "core/dom/DOMNamedFlowCollection.h" 34 #include "core/dom/DOMNamedFlowCollection.h"
35 #include "core/dom/Document.h" 35 #include "core/dom/Document.h"
36 #include "core/inspector/InspectorInstrumentation.h" 36 #include "core/inspector/InspectorInstrumentation.h"
37 #include "wtf/text/AtomicString.h"
37 #include "wtf/text/StringHash.h" 38 #include "wtf/text/StringHash.h"
38 #include "wtf/text/WTFString.h" 39 #include "wtf/text/WTFString.h"
39 40
40 namespace WebCore { 41 namespace WebCore {
41 42
42 NamedFlowCollection::NamedFlowCollection(Document* document) 43 NamedFlowCollection::NamedFlowCollection(Document* document)
43 : DocumentLifecycleObserver(document) 44 : DocumentLifecycleObserver(document)
44 { 45 {
45 ASSERT(RuntimeEnabledFeatures::cssRegionsEnabled()); 46 ASSERT(RuntimeEnabledFeatures::cssRegionsEnabled());
46 } 47 }
47 48
48 Vector<RefPtr<NamedFlow> > NamedFlowCollection::namedFlows() 49 Vector<RefPtr<NamedFlow> > NamedFlowCollection::namedFlows()
49 { 50 {
50 Vector<RefPtr<NamedFlow> > namedFlows; 51 Vector<RefPtr<NamedFlow> > namedFlows;
51 52
52 for (NamedFlowSet::iterator it = m_namedFlows.begin(); it != m_namedFlows.en d(); ++it) { 53 for (NamedFlowSet::iterator it = m_namedFlows.begin(); it != m_namedFlows.en d(); ++it) {
53 if ((*it)->flowState() == NamedFlow::FlowStateNull) 54 if ((*it)->flowState() == NamedFlow::FlowStateNull)
54 continue; 55 continue;
55 56
56 namedFlows.append(RefPtr<NamedFlow>(*it)); 57 namedFlows.append(RefPtr<NamedFlow>(*it));
57 } 58 }
58 59
59 return namedFlows; 60 return namedFlows;
60 } 61 }
61 62
62 NamedFlow* NamedFlowCollection::flowByName(const String& flowName) 63 // Takes an AtomicString in argument because RenderStyle::flowThread() returns a n AtomicString.
64 NamedFlow* NamedFlowCollection::flowByName(const AtomicString& flowName)
63 { 65 {
64 NamedFlowSet::iterator it = m_namedFlows.find<NamedFlowHashTranslator>(flowN ame); 66 NamedFlowSet::iterator it = m_namedFlows.find<NamedFlowHashTranslator>(flowN ame);
65 if (it == m_namedFlows.end() || (*it)->flowState() == NamedFlow::FlowStateNu ll) 67 if (it == m_namedFlows.end() || (*it)->flowState() == NamedFlow::FlowStateNu ll)
66 return 0; 68 return 0;
67 69
68 return *it; 70 return *it;
69 } 71 }
70 72
71 PassRefPtr<NamedFlow> NamedFlowCollection::ensureFlowWithName(const String& flow Name) 73 // Takes an AtomicString in argument because RenderStyle::flowThread() returns a n AtomicString.
eseidel 2013/12/30 22:31:11 It would be fine for this to take a String in that
Inactive 2013/12/30 22:39:34 Yes, I understand that. However, in this particula
74 PassRefPtr<NamedFlow> NamedFlowCollection::ensureFlowWithName(const AtomicString & flowName)
72 { 75 {
73 NamedFlowSet::iterator it = m_namedFlows.find<NamedFlowHashTranslator>(flowN ame); 76 NamedFlowSet::iterator it = m_namedFlows.find<NamedFlowHashTranslator>(flowN ame);
74 if (it != m_namedFlows.end()) { 77 if (it != m_namedFlows.end()) {
75 NamedFlow* namedFlow = *it; 78 NamedFlow* namedFlow = *it;
76 ASSERT(namedFlow->flowState() == NamedFlow::FlowStateNull); 79 ASSERT(namedFlow->flowState() == NamedFlow::FlowStateNull);
77 80
78 return namedFlow; 81 return namedFlow;
79 } 82 }
80 83
81 RefPtr<NamedFlow> newFlow = NamedFlow::create(this, flowName); 84 RefPtr<NamedFlow> newFlow = NamedFlow::create(this, flowName);
(...skipping 28 matching lines...) Expand all
110 Vector<NamedFlow*> createdFlows; 113 Vector<NamedFlow*> createdFlows;
111 for (NamedFlowSet::iterator it = m_namedFlows.begin(); it != m_namedFlows.en d(); ++it) 114 for (NamedFlowSet::iterator it = m_namedFlows.begin(); it != m_namedFlows.en d(); ++it)
112 if ((*it)->flowState() == NamedFlow::FlowStateCreated) 115 if ((*it)->flowState() == NamedFlow::FlowStateCreated)
113 createdFlows.append(*it); 116 createdFlows.append(*it);
114 return DOMNamedFlowCollection::create(createdFlows); 117 return DOMNamedFlowCollection::create(createdFlows);
115 } 118 }
116 119
117 // The HashFunctions object used by the HashSet to compare between NamedFlows. 120 // The HashFunctions object used by the HashSet to compare between NamedFlows.
118 // It is safe to set safeToCompareToEmptyOrDeleted because the HashSet will neve r contain null pointers or deleted values. 121 // It is safe to set safeToCompareToEmptyOrDeleted because the HashSet will neve r contain null pointers or deleted values.
119 struct NamedFlowCollection::NamedFlowHashFunctions { 122 struct NamedFlowCollection::NamedFlowHashFunctions {
120 static unsigned hash(NamedFlow* key) { return DefaultHash<String>::Hash::has h(key->name()); } 123 static unsigned hash(NamedFlow* key) { return DefaultHash<AtomicString>::Has h::hash(key->name()); }
121 static bool equal(NamedFlow* a, NamedFlow* b) { return a->name() == b->name( ); } 124 static bool equal(NamedFlow* a, NamedFlow* b) { return a->name() == b->name( ); }
122 static const bool safeToCompareToEmptyOrDeleted = true; 125 static const bool safeToCompareToEmptyOrDeleted = true;
123 }; 126 };
124 127
125 // The HashTranslator is used to lookup a NamedFlow in the set using a name. 128 // The HashTranslator is used to lookup a NamedFlow in the set using a name.
126 struct NamedFlowCollection::NamedFlowHashTranslator { 129 struct NamedFlowCollection::NamedFlowHashTranslator {
127 static unsigned hash(const String& key) { return DefaultHash<String>::Hash:: hash(key); } 130 static unsigned hash(const AtomicString& key) { return DefaultHash<AtomicStr ing>::Hash::hash(key); }
128 static bool equal(NamedFlow* a, const String& b) { return a->name() == b; } 131 static bool equal(NamedFlow* a, const AtomicString& b) { return a->name() == b; }
129 }; 132 };
130 133
131 } // namespace WebCore 134 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/dom/NamedFlowCollection.h ('k') | Source/core/dom/Node.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698