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

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

Issue 22847004: Rename CustomElementUpgradeCandidateMap::DestructionObserverMap. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/dom/CustomElementUpgradeCandidateMap.h ('k') | no next file » | 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) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. 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 are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 21 matching lines...) Expand all
32 #include "core/dom/CustomElementUpgradeCandidateMap.h" 32 #include "core/dom/CustomElementUpgradeCandidateMap.h"
33 33
34 #include "core/dom/Element.h" 34 #include "core/dom/Element.h"
35 35
36 namespace WebCore { 36 namespace WebCore {
37 37
38 CustomElementUpgradeCandidateMap::~CustomElementUpgradeCandidateMap() 38 CustomElementUpgradeCandidateMap::~CustomElementUpgradeCandidateMap()
39 { 39 {
40 UpgradeCandidateMap::const_iterator::Keys end = m_upgradeCandidates.end().ke ys(); 40 UpgradeCandidateMap::const_iterator::Keys end = m_upgradeCandidates.end().ke ys();
41 for (UpgradeCandidateMap::const_iterator::Keys it = m_upgradeCandidates.begi n().keys(); it != end; ++it) 41 for (UpgradeCandidateMap::const_iterator::Keys it = m_upgradeCandidates.begi n().keys(); it != end; ++it)
42 unregisterForElementDestructionNotification(*it, this); 42 unobserve(*it);
43 } 43 }
44 44
45 void CustomElementUpgradeCandidateMap::add(const CustomElementDescriptor& descri ptor, Element* element) 45 void CustomElementUpgradeCandidateMap::add(const CustomElementDescriptor& descri ptor, Element* element)
46 { 46 {
47 element->setCustomElementState(Element::UpgradeCandidate); 47 element->setCustomElementState(Element::UpgradeCandidate);
48 48
49 registerForElementDestructionNotification(element, this); 49 observe(element);
50 50
51 UpgradeCandidateMap::AddResult result = m_upgradeCandidates.add(element, des criptor); 51 UpgradeCandidateMap::AddResult result = m_upgradeCandidates.add(element, des criptor);
52 ASSERT(result.isNewEntry); 52 ASSERT(result.isNewEntry);
53 53
54 UnresolvedDefinitionMap::iterator it = m_unresolvedDefinitions.find(descript or); 54 UnresolvedDefinitionMap::iterator it = m_unresolvedDefinitions.find(descript or);
55 if (it == m_unresolvedDefinitions.end()) 55 if (it == m_unresolvedDefinitions.end())
56 it = m_unresolvedDefinitions.add(descriptor, ElementSet()).iterator; 56 it = m_unresolvedDefinitions.add(descriptor, ElementSet()).iterator;
57 it->value.add(element); 57 it->value.add(element);
58 } 58 }
59 59
60 void CustomElementUpgradeCandidateMap::remove(Element* element) 60 void CustomElementUpgradeCandidateMap::remove(Element* element)
61 { 61 {
62 unregisterForElementDestructionNotification(element, this); 62 unobserve(element);
63 63
64 UpgradeCandidateMap::iterator candidate = m_upgradeCandidates.find(element); 64 UpgradeCandidateMap::iterator candidate = m_upgradeCandidates.find(element);
65 ASSERT(candidate != m_upgradeCandidates.end()); 65 ASSERT(candidate != m_upgradeCandidates.end());
66 66
67 UnresolvedDefinitionMap::iterator elements = m_unresolvedDefinitions.find(ca ndidate->value); 67 UnresolvedDefinitionMap::iterator elements = m_unresolvedDefinitions.find(ca ndidate->value);
68 ASSERT(elements != m_unresolvedDefinitions.end()); 68 ASSERT(elements != m_unresolvedDefinitions.end());
69 elements->value.remove(element); 69 elements->value.remove(element);
70 m_upgradeCandidates.remove(candidate); 70 m_upgradeCandidates.remove(candidate);
71 } 71 }
72 72
73 ListHashSet<Element*> CustomElementUpgradeCandidateMap::takeUpgradeCandidatesFor (const CustomElementDescriptor& descriptor) 73 ListHashSet<Element*> CustomElementUpgradeCandidateMap::takeUpgradeCandidatesFor (const CustomElementDescriptor& descriptor)
74 { 74 {
75 const ListHashSet<Element*>& candidates = m_unresolvedDefinitions.take(descr iptor); 75 const ListHashSet<Element*>& candidates = m_unresolvedDefinitions.take(descr iptor);
76 76
77 for (ElementSet::const_iterator candidate = candidates.begin(); candidate != candidates.end(); ++candidate) { 77 for (ElementSet::const_iterator candidate = candidates.begin(); candidate != candidates.end(); ++candidate) {
78 unregisterForElementDestructionNotification(*candidate, this); 78 unobserve(*candidate);
79 m_upgradeCandidates.remove(*candidate); 79 m_upgradeCandidates.remove(*candidate);
80 } 80 }
81 81
82 return candidates; 82 return candidates;
83 } 83 }
84 84
85 void CustomElementUpgradeCandidateMap::elementWasDestroyed(Element* element) 85 void CustomElementUpgradeCandidateMap::elementWasDestroyed(Element* element)
86 { 86 {
87 DestructionObserverMap::iterator it = destructionObservers().find(element); 87 ElementObserverMap::iterator it = elementObservers().find(element);
88 if (it == destructionObservers().end()) 88 if (it == elementObservers().end())
89 return; 89 return;
90 it->value->remove(element); // will also remove the destruction observer 90 it->value->remove(element); // will also remove the destruction observer
91 } 91 }
92 92
93 CustomElementUpgradeCandidateMap::DestructionObserverMap& CustomElementUpgradeCa ndidateMap::destructionObservers() 93 CustomElementUpgradeCandidateMap::ElementObserverMap& CustomElementUpgradeCandid ateMap::elementObservers()
94 { 94 {
95 DEFINE_STATIC_LOCAL(DestructionObserverMap, map, ()); 95 DEFINE_STATIC_LOCAL(ElementObserverMap, map, ());
96 return map; 96 return map;
97 } 97 }
98 98
99 void CustomElementUpgradeCandidateMap::registerForElementDestructionNotification (Element* element, CustomElementUpgradeCandidateMap* observer) 99 void CustomElementUpgradeCandidateMap::observe(Element* element)
100 { 100 {
101 DestructionObserverMap::AddResult result = destructionObservers().add(elemen t, observer); 101 ElementObserverMap::AddResult result = elementObservers().add(element, this) ;
102 ASSERT(result.isNewEntry); 102 ASSERT(result.isNewEntry);
103 } 103 }
104 104
105 void CustomElementUpgradeCandidateMap::unregisterForElementDestructionNotificati on(Element* element, CustomElementUpgradeCandidateMap* observer) 105 void CustomElementUpgradeCandidateMap::unobserve(Element* element)
106 { 106 {
107 CustomElementUpgradeCandidateMap* map = destructionObservers().take(element) ; 107 CustomElementUpgradeCandidateMap* map = elementObservers().take(element);
108 ASSERT(map == observer); 108 ASSERT(map == this);
109 } 109 }
110 110
111 } 111 }
OLDNEW
« no previous file with comments | « Source/core/dom/CustomElementUpgradeCandidateMap.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698