| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserv
ed. | 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserv
ed. |
| 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 17 matching lines...) Expand all Loading... |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #include "core/dom/DocumentOrderedMap.h" | 31 #include "core/dom/DocumentOrderedMap.h" |
| 32 | 32 |
| 33 #include "core/HTMLNames.h" | 33 #include "core/HTMLNames.h" |
| 34 #include "core/dom/Element.h" | 34 #include "core/dom/Element.h" |
| 35 #include "core/dom/ElementTraversal.h" | 35 #include "core/dom/ElementTraversal.h" |
| 36 #include "core/dom/TreeScope.h" | 36 #include "core/dom/TreeScope.h" |
| 37 #include "core/html/HTMLMapElement.h" | 37 #include "core/html/HTMLMapElement.h" |
| 38 #include "core/html/HTMLSlotElement.h" |
| 38 | 39 |
| 39 namespace blink { | 40 namespace blink { |
| 40 | 41 |
| 41 using namespace HTMLNames; | 42 using namespace HTMLNames; |
| 42 | 43 |
| 43 | 44 |
| 44 DocumentOrderedMap* DocumentOrderedMap::create() | 45 DocumentOrderedMap* DocumentOrderedMap::create() |
| 45 { | 46 { |
| 46 return new DocumentOrderedMap; | 47 return new DocumentOrderedMap; |
| 47 } | 48 } |
| (...skipping 20 matching lines...) Expand all Loading... |
| 68 inline bool keyMatchesId(const AtomicString& key, const Element& element) | 69 inline bool keyMatchesId(const AtomicString& key, const Element& element) |
| 69 { | 70 { |
| 70 return element.getIdAttribute() == key; | 71 return element.getIdAttribute() == key; |
| 71 } | 72 } |
| 72 | 73 |
| 73 inline bool keyMatchesMapName(const AtomicString& key, const Element& element) | 74 inline bool keyMatchesMapName(const AtomicString& key, const Element& element) |
| 74 { | 75 { |
| 75 return isHTMLMapElement(element) && toHTMLMapElement(element).getName() == k
ey; | 76 return isHTMLMapElement(element) && toHTMLMapElement(element).getName() == k
ey; |
| 76 } | 77 } |
| 77 | 78 |
| 79 inline bool keyMatchesSlotName(const AtomicString& key, const Element& element) |
| 80 { |
| 81 return isHTMLSlotElement(element) && toHTMLSlotElement(element).name() == ke
y; |
| 82 } |
| 83 |
| 78 inline bool keyMatchesLowercasedMapName(const AtomicString& key, const Element&
element) | 84 inline bool keyMatchesLowercasedMapName(const AtomicString& key, const Element&
element) |
| 79 { | 85 { |
| 80 return isHTMLMapElement(element) && toHTMLMapElement(element).getName().lowe
r() == key; | 86 return isHTMLMapElement(element) && toHTMLMapElement(element).getName().lowe
r() == key; |
| 81 } | 87 } |
| 82 | 88 |
| 83 inline bool keyMatchesLabelForAttribute(const AtomicString& key, const Element&
element) | 89 inline bool keyMatchesLabelForAttribute(const AtomicString& key, const Element&
element) |
| 84 { | 90 { |
| 85 return isHTMLLabelElement(element) && element.getAttribute(forAttr) == key; | 91 return isHTMLLabelElement(element) && element.getAttribute(forAttr) == key; |
| 86 } | 92 } |
| 87 | 93 |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 } | 194 } |
| 189 | 195 |
| 190 return entry->orderedList; | 196 return entry->orderedList; |
| 191 } | 197 } |
| 192 | 198 |
| 193 Element* DocumentOrderedMap::getElementByMapName(const AtomicString& key, const
TreeScope* scope) const | 199 Element* DocumentOrderedMap::getElementByMapName(const AtomicString& key, const
TreeScope* scope) const |
| 194 { | 200 { |
| 195 return get<keyMatchesMapName>(key, scope); | 201 return get<keyMatchesMapName>(key, scope); |
| 196 } | 202 } |
| 197 | 203 |
| 204 // TODO(hayato): Template get<> by return type. |
| 205 HTMLSlotElement* DocumentOrderedMap::getSlotByName(const AtomicString& key, cons
t TreeScope* scope) const |
| 206 { |
| 207 if (Element* slot = get<keyMatchesSlotName>(key, scope)) { |
| 208 DCHECK(isHTMLSlotElement(slot)); |
| 209 return toHTMLSlotElement(slot); |
| 210 } |
| 211 return nullptr; |
| 212 } |
| 213 |
| 198 Element* DocumentOrderedMap::getElementByLowercasedMapName(const AtomicString& k
ey, const TreeScope* scope) const | 214 Element* DocumentOrderedMap::getElementByLowercasedMapName(const AtomicString& k
ey, const TreeScope* scope) const |
| 199 { | 215 { |
| 200 return get<keyMatchesLowercasedMapName>(key, scope); | 216 return get<keyMatchesLowercasedMapName>(key, scope); |
| 201 } | 217 } |
| 202 | 218 |
| 203 Element* DocumentOrderedMap::getElementByLabelForAttribute(const AtomicString& k
ey, const TreeScope* scope) const | 219 Element* DocumentOrderedMap::getElementByLabelForAttribute(const AtomicString& k
ey, const TreeScope* scope) const |
| 204 { | 220 { |
| 205 return get<keyMatchesLabelForAttribute>(key, scope); | 221 return get<keyMatchesLabelForAttribute>(key, scope); |
| 206 } | 222 } |
| 207 | 223 |
| 208 DEFINE_TRACE(DocumentOrderedMap) | 224 DEFINE_TRACE(DocumentOrderedMap) |
| 209 { | 225 { |
| 210 visitor->trace(m_map); | 226 visitor->trace(m_map); |
| 211 } | 227 } |
| 212 | 228 |
| 213 DEFINE_TRACE(DocumentOrderedMap::MapEntry) | 229 DEFINE_TRACE(DocumentOrderedMap::MapEntry) |
| 214 { | 230 { |
| 215 visitor->trace(element); | 231 visitor->trace(element); |
| 216 visitor->trace(orderedList); | 232 visitor->trace(orderedList); |
| 217 } | 233 } |
| 218 | 234 |
| 219 } // namespace blink | 235 } // namespace blink |
| OLD | NEW |