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

Side by Side Diff: third_party/WebKit/Source/core/dom/Element.cpp

Issue 2912383002: Add support for Element.getAttributeNames() (Closed)
Patch Set: rebased Created 3 years, 6 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2001 Peter Kelly (pmk@post.com) 4 * (C) 2001 Peter Kelly (pmk@post.com)
5 * (C) 2001 Dirk Mueller (mueller@kde.org) 5 * (C) 2001 Dirk Mueller (mueller@kde.org)
6 * (C) 2007 David Smith (catfish.man@gmail.com) 6 * (C) 2007 David Smith (catfish.man@gmail.com)
7 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012, 2013 Apple Inc. 7 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012, 2013 Apple Inc.
8 * All rights reserved. 8 * All rights reserved.
9 * (C) 2007 Eric Seidel (eric@webkit.org) 9 * (C) 2007 Eric Seidel (eric@webkit.org)
10 * 10 *
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 NamedNodeMap* Element::attributesForBindings() const { 317 NamedNodeMap* Element::attributesForBindings() const {
318 ElementRareData& rare_data = 318 ElementRareData& rare_data =
319 const_cast<Element*>(this)->EnsureElementRareData(); 319 const_cast<Element*>(this)->EnsureElementRareData();
320 if (NamedNodeMap* attribute_map = rare_data.AttributeMap()) 320 if (NamedNodeMap* attribute_map = rare_data.AttributeMap())
321 return attribute_map; 321 return attribute_map;
322 322
323 rare_data.SetAttributeMap(NamedNodeMap::Create(const_cast<Element*>(this))); 323 rare_data.SetAttributeMap(NamedNodeMap::Create(const_cast<Element*>(this)));
324 return rare_data.AttributeMap(); 324 return rare_data.AttributeMap();
325 } 325 }
326 326
327 Vector<AtomicString> Element::getAttributeNames() const {
328 Vector<AtomicString> attributesVector;
329 if (!hasAttributes())
330 return attributesVector;
331
332 AttributeCollection attributes = element_data_->Attributes();
333 attributesVector.ReserveInitialCapacity(attributes.size());
334 for (const Attribute& attr : attributes)
335 attributesVector.UncheckedAppend(attr.GetName().ToString());
336 return attributesVector;
337 }
338
327 ElementAnimations* Element::GetElementAnimations() const { 339 ElementAnimations* Element::GetElementAnimations() const {
328 if (HasRareData()) 340 if (HasRareData())
329 return GetElementRareData()->GetElementAnimations(); 341 return GetElementRareData()->GetElementAnimations();
330 return nullptr; 342 return nullptr;
331 } 343 }
332 344
333 ElementAnimations& Element::EnsureElementAnimations() { 345 ElementAnimations& Element::EnsureElementAnimations() {
334 ElementRareData& rare_data = EnsureElementRareData(); 346 ElementRareData& rare_data = EnsureElementRareData();
335 if (!rare_data.GetElementAnimations()) 347 if (!rare_data.GetElementAnimations())
336 rare_data.SetElementAnimations(new ElementAnimations()); 348 rare_data.SetElementAnimations(new ElementAnimations());
(...skipping 4020 matching lines...) Expand 10 before | Expand all | Expand 10 after
4357 } 4369 }
4358 4370
4359 DEFINE_TRACE_WRAPPERS(Element) { 4371 DEFINE_TRACE_WRAPPERS(Element) {
4360 if (HasRareData()) { 4372 if (HasRareData()) {
4361 visitor->TraceWrappers(GetElementRareData()); 4373 visitor->TraceWrappers(GetElementRareData());
4362 } 4374 }
4363 ContainerNode::TraceWrappers(visitor); 4375 ContainerNode::TraceWrappers(visitor);
4364 } 4376 }
4365 4377
4366 } // namespace blink 4378 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/Element.h ('k') | third_party/WebKit/Source/core/dom/Element.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698