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

Side by Side Diff: Source/core/dom/Element.h

Issue 179333004: Add template parameter to ElementTraversal to iterate over Elements of a specific type (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fix failures and port more code to the new API Created 6 years, 9 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/Document.cpp ('k') | Source/core/dom/ElementTraversal.h » ('j') | 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) 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 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2013 Appl e Inc. All rights reserved. 6 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2013 Appl e Inc. All rights reserved.
7 * 7 *
8 * This library is free software; you can redistribute it and/or 8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public 9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
(...skipping 655 matching lines...) Expand 10 before | Expand all | Expand 10 after
666 bool isJavaScriptURLAttribute(const Attribute&) const; 666 bool isJavaScriptURLAttribute(const Attribute&) const;
667 667
668 RefPtr<ElementData> m_elementData; 668 RefPtr<ElementData> m_elementData;
669 }; 669 };
670 670
671 DEFINE_NODE_TYPE_CASTS(Element, isElementNode()); 671 DEFINE_NODE_TYPE_CASTS(Element, isElementNode());
672 template <typename T> bool isElementOfType(const Element&); 672 template <typename T> bool isElementOfType(const Element&);
673 template <typename T> inline bool isElementOfType(const Node& node) { return nod e.isElementNode() && isElementOfType<const T>(toElement(node)); } 673 template <typename T> inline bool isElementOfType(const Node& node) { return nod e.isElementNode() && isElementOfType<const T>(toElement(node)); }
674 template <> inline bool isElementOfType<const Element>(const Element&) { return true; } 674 template <> inline bool isElementOfType<const Element>(const Element&) { return true; }
675 675
676 // Type casting.
677 template<typename T> inline T& toElement(Node& node)
678 {
679 ASSERT_WITH_SECURITY_IMPLICATION(isElementOfType<const T>(node));
680 return static_cast<T&>(node);
681 }
682 template<typename T> inline T* toElement(Node* node)
683 {
684 ASSERT_WITH_SECURITY_IMPLICATION(!node || isElementOfType<const T>(*node));
685 return static_cast<T*>(node);
686 }
687 template<typename T> inline const T& toElement(const Node& node)
688 {
689 ASSERT_WITH_SECURITY_IMPLICATION(isElementOfType<const T>(node));
690 return static_cast<const T&>(node);
691 }
692 template<typename T> inline const T* toElement(const Node* node)
693 {
694 ASSERT_WITH_SECURITY_IMPLICATION(!node || isElementOfType<const T>(*node));
695 return static_cast<const T*>(node);
696 }
697 template<typename T, typename U> inline T* toElement(const RefPtr<U>& node) { re turn toElement<T>(node.get()); }
698
676 inline bool isDisabledFormControl(const Node* node) 699 inline bool isDisabledFormControl(const Node* node)
677 { 700 {
678 return node->isElementNode() && toElement(node)->isDisabledFormControl(); 701 return node->isElementNode() && toElement(node)->isDisabledFormControl();
679 } 702 }
680 703
681 inline bool Node::hasTagName(const QualifiedName& name) const 704 inline bool Node::hasTagName(const QualifiedName& name) const
682 { 705 {
683 return isElementNode() && toElement(this)->hasTagName(name); 706 return isElementNode() && toElement(this)->hasTagName(name);
684 } 707 }
685 708
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
859 } 882 }
860 883
861 inline bool isShadowHost(const Element* element) 884 inline bool isShadowHost(const Element* element)
862 { 885 {
863 return element && element->shadow(); 886 return element && element->shadow();
864 } 887 }
865 888
866 } // namespace 889 } // namespace
867 890
868 #endif 891 #endif
OLDNEW
« no previous file with comments | « Source/core/dom/Document.cpp ('k') | Source/core/dom/ElementTraversal.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698