OLD | NEW |
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 24 matching lines...) Expand all Loading... |
35 #include "core/dom/Document.h" | 35 #include "core/dom/Document.h" |
36 #include "core/dom/NamedFlow.h" | 36 #include "core/dom/NamedFlow.h" |
37 #include "core/inspector/InspectorInstrumentation.h" | 37 #include "core/inspector/InspectorInstrumentation.h" |
38 | 38 |
39 #include <wtf/text/StringHash.h> | 39 #include <wtf/text/StringHash.h> |
40 #include <wtf/text/WTFString.h> | 40 #include <wtf/text/WTFString.h> |
41 | 41 |
42 namespace WebCore { | 42 namespace WebCore { |
43 | 43 |
44 NamedFlowCollection::NamedFlowCollection(Document* document) | 44 NamedFlowCollection::NamedFlowCollection(Document* document) |
45 : ContextDestructionObserver(document) | 45 : ContextLifecycleObserver(document) |
46 { | 46 { |
47 ASSERT(RuntimeEnabledFeatures::cssRegionsEnabled()); | 47 ASSERT(RuntimeEnabledFeatures::cssRegionsEnabled()); |
48 } | 48 } |
49 | 49 |
50 Vector<RefPtr<NamedFlow> > NamedFlowCollection::namedFlows() | 50 Vector<RefPtr<NamedFlow> > NamedFlowCollection::namedFlows() |
51 { | 51 { |
52 Vector<RefPtr<NamedFlow> > namedFlows; | 52 Vector<RefPtr<NamedFlow> > namedFlows; |
53 | 53 |
54 for (NamedFlowSet::iterator it = m_namedFlows.begin(); it != m_namedFlows.en
d(); ++it) { | 54 for (NamedFlowSet::iterator it = m_namedFlows.begin(); it != m_namedFlows.en
d(); ++it) { |
55 if ((*it)->flowState() == NamedFlow::FlowStateNull) | 55 if ((*it)->flowState() == NamedFlow::FlowStateNull) |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 ASSERT(namedFlow->flowState() == NamedFlow::FlowStateNull); | 97 ASSERT(namedFlow->flowState() == NamedFlow::FlowStateNull); |
98 ASSERT(m_namedFlows.contains(namedFlow)); | 98 ASSERT(m_namedFlows.contains(namedFlow)); |
99 | 99 |
100 InspectorInstrumentation::willRemoveNamedFlow(document(), namedFlow); | 100 InspectorInstrumentation::willRemoveNamedFlow(document(), namedFlow); |
101 | 101 |
102 m_namedFlows.remove(namedFlow); | 102 m_namedFlows.remove(namedFlow); |
103 } | 103 } |
104 | 104 |
105 Document* NamedFlowCollection::document() const | 105 Document* NamedFlowCollection::document() const |
106 { | 106 { |
107 ScriptExecutionContext* context = ContextDestructionObserver::scriptExecutio
nContext(); | 107 ScriptExecutionContext* context = ContextLifecycleObserver::scriptExecutionC
ontext(); |
108 return toDocument(context); | 108 return toDocument(context); |
109 } | 109 } |
110 | 110 |
111 PassRefPtr<DOMNamedFlowCollection> NamedFlowCollection::createCSSOMSnapshot() | 111 PassRefPtr<DOMNamedFlowCollection> NamedFlowCollection::createCSSOMSnapshot() |
112 { | 112 { |
113 Vector<NamedFlow*> createdFlows; | 113 Vector<NamedFlow*> createdFlows; |
114 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) |
115 if ((*it)->flowState() == NamedFlow::FlowStateCreated) | 115 if ((*it)->flowState() == NamedFlow::FlowStateCreated) |
116 createdFlows.append(*it); | 116 createdFlows.append(*it); |
117 return DOMNamedFlowCollection::create(createdFlows); | 117 return DOMNamedFlowCollection::create(createdFlows); |
118 } | 118 } |
119 | 119 |
120 // The HashFunctions object used by the HashSet to compare between NamedFlows. | 120 // The HashFunctions object used by the HashSet to compare between NamedFlows. |
121 // 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. |
122 struct NamedFlowCollection::NamedFlowHashFunctions { | 122 struct NamedFlowCollection::NamedFlowHashFunctions { |
123 static unsigned hash(NamedFlow* key) { return DefaultHash<String>::Hash::has
h(key->name()); } | 123 static unsigned hash(NamedFlow* key) { return DefaultHash<String>::Hash::has
h(key->name()); } |
124 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(
); } |
125 static const bool safeToCompareToEmptyOrDeleted = true; | 125 static const bool safeToCompareToEmptyOrDeleted = true; |
126 }; | 126 }; |
127 | 127 |
128 // 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. |
129 struct NamedFlowCollection::NamedFlowHashTranslator { | 129 struct NamedFlowCollection::NamedFlowHashTranslator { |
130 static unsigned hash(const String& key) { return DefaultHash<String>::Hash::
hash(key); } | 130 static unsigned hash(const String& key) { return DefaultHash<String>::Hash::
hash(key); } |
131 static bool equal(NamedFlow* a, const String& b) { return a->name() == b; } | 131 static bool equal(NamedFlow* a, const String& b) { return a->name() == b; } |
132 }; | 132 }; |
133 | 133 |
134 } // namespace WebCore | 134 } // namespace WebCore |
OLD | NEW |