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

Side by Side Diff: sky/engine/core/dom/custom/CustomElementUpgradeCandidateMap.cpp

Issue 843063005: Remove custom element upgrades. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 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 | « sky/engine/core/dom/custom/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
(Empty)
1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above
11 * copyright notice, this list of conditions and the following disclaimer
12 * in the documentation and/or other materials provided with the
13 * distribution.
14 * * Neither the name of Google Inc. nor the names of its
15 * contributors may be used to endorse or promote products derived from
16 * this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31 #include "sky/engine/config.h"
32 #include "sky/engine/core/dom/custom/CustomElementUpgradeCandidateMap.h"
33
34 #include "sky/engine/core/dom/Element.h"
35
36 namespace blink {
37
38 PassOwnPtr<CustomElementUpgradeCandidateMap> CustomElementUpgradeCandidateMap::c reate()
39 {
40 return adoptPtr(new CustomElementUpgradeCandidateMap());
41 }
42
43 CustomElementUpgradeCandidateMap::~CustomElementUpgradeCandidateMap()
44 {
45 #if !ENABLE(OILPAN)
46 // With Oilpan enabled, the observer table keeps a weak reference to the
47 // element; no need for explicit removal.
48 UpgradeCandidateMap::const_iterator::Keys end = m_upgradeCandidates.end().ke ys();
49 for (UpgradeCandidateMap::const_iterator::Keys it = m_upgradeCandidates.begi n().keys(); it != end; ++it)
50 unobserve(*it);
51 #endif
52 }
53
54 void CustomElementUpgradeCandidateMap::add(const CustomElementDescriptor& descri ptor, Element* element)
55 {
56 observe(element);
57
58 UpgradeCandidateMap::AddResult result = m_upgradeCandidates.add(element, des criptor);
59 ASSERT_UNUSED(result, result.isNewEntry);
60
61 UnresolvedDefinitionMap::iterator it = m_unresolvedDefinitions.find(descript or);
62 ElementSet* elements;
63 if (it == m_unresolvedDefinitions.end())
64 elements = m_unresolvedDefinitions.add(descriptor, adoptPtr(new ElementS et())).storedValue->value.get();
65 else
66 elements = it->value.get();
67 elements->add(element);
68 }
69
70 void CustomElementUpgradeCandidateMap::elementWasDestroyed(Element* element)
71 {
72 CustomElementObserver::elementWasDestroyed(element);
73 UpgradeCandidateMap::iterator candidate = m_upgradeCandidates.find(element);
74 ASSERT_WITH_SECURITY_IMPLICATION(candidate != m_upgradeCandidates.end());
75
76 UnresolvedDefinitionMap::iterator elements = m_unresolvedDefinitions.find(ca ndidate->value);
77 ASSERT_WITH_SECURITY_IMPLICATION(elements != m_unresolvedDefinitions.end());
78 elements->value->remove(element);
79 m_upgradeCandidates.remove(candidate);
80 }
81
82 void CustomElementUpgradeCandidateMap::elementDidFinishParsingChildren(Element* element)
83 {
84 // An upgrade candidate finished parsing; reorder so that eventual
85 // upgrade order matches finished-parsing order.
86 moveToEnd(element);
87 }
88
89 void CustomElementUpgradeCandidateMap::moveToEnd(Element* element)
90 {
91 UpgradeCandidateMap::iterator candidate = m_upgradeCandidates.find(element);
92 ASSERT_WITH_SECURITY_IMPLICATION(candidate != m_upgradeCandidates.end());
93
94 UnresolvedDefinitionMap::iterator elements = m_unresolvedDefinitions.find(ca ndidate->value);
95 ASSERT_WITH_SECURITY_IMPLICATION(elements != m_unresolvedDefinitions.end());
96 elements->value->appendOrMoveToLast(element);
97 }
98
99 PassOwnPtr<CustomElementUpgradeCandidateMap::ElementSet> CustomElementUpgradeCan didateMap::takeUpgradeCandidatesFor(const CustomElementDescriptor& descriptor)
100 {
101 OwnPtr<ElementSet> candidates = m_unresolvedDefinitions.take(descriptor);
102
103 if (!candidates)
104 return nullptr;
105
106 for (ElementSet::const_iterator candidate = candidates->begin(); candidate ! = candidates->end(); ++candidate) {
107 unobserve(*candidate);
108 m_upgradeCandidates.remove(*candidate);
109 }
110 return candidates.release();
111 }
112
113 }
OLDNEW
« no previous file with comments | « sky/engine/core/dom/custom/CustomElementUpgradeCandidateMap.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698