Commit ecdc7b0a authored by antti@apple.com's avatar antti@apple.com
Browse files

<https://webkit.org/b/120166> Add Traversal<ElementType> template

Reviewed by Andreas Kling.

It is common to traverse through a subtree looking for elements of specific type and then casting to the type. This pattern can be generalized.
        
This patch adds a new Traversal<typename ElementType> template. It works like ElementTraversal except that the traversal is limited to the specified type.
The patch also uses the template in a bunch of applicable places.

* WebCore.exp.in:
* accessibility/AccessibilityRenderObject.cpp:
(WebCore::AccessibilityRenderObject::addImageMapChildren):
* dom/Document.cpp:
(WebCore::Document::removeTitle):
(WebCore::Document::updateBaseURL):
(WebCore::Document::processBaseElement):
* dom/Element.h:
* dom/ElementTraversal.h:
(WebCore::::firstChildTemplate):
(WebCore::::firstWithinTemplate):
(WebCore::::lastChildTemplate):
(WebCore::::lastWithinTemplate):
(WebCore::::nextTemplate):
(WebCore::::previousTemplate):
(WebCore::::nextSiblingTemplate):
(WebCore::::previousSiblingTemplate):
(WebCore::::nextSkippingChildrenTemplate):
(WebCore::::firstChild):
(WebCore::::lastChild):
(WebCore::::firstWithin):
(WebCore::::lastWithin):
(WebCore::::next):
(WebCore::::previous):
(WebCore::::nextSibling):
(WebCore::::previousSibling):
(WebCore::::nextSkippingChildren):
(WebCore::ElementTraversal::previousIncludingPseudo):
(WebCore::ElementTraversal::nextIncludingPseudo):
(WebCore::ElementTraversal::nextIncludingPseudoSkippingChildren):
(WebCore::ElementTraversal::pseudoAwarePreviousSibling):
* dom/Node.cpp:
(WebCore::Node::numberOfScopedHTMLStyleChildren):
* dom/NodeIterator.cpp:
(WebCore::NodeIterator::NodeIterator):
* dom/NodeIterator.h:
* dom/Traversal.cpp:
(WebCore::NodeIteratorBase::NodeIteratorBase):
(WebCore::NodeIteratorBase::acceptNode):
* dom/Traversal.h:
        
    Renamed existing class called Traversal to less generic NodeIteratorBase.

* dom/TreeScope.cpp:
(WebCore::TreeScope::labelElementForId):
(WebCore::TreeScope::findAnchor):
* dom/TreeWalker.cpp:
(WebCore::TreeWalker::TreeWalker):
* dom/TreeWalker.h:
* editing/FrameSelection.cpp:
(WebCore::scanForForm):
* editing/markup.cpp:
(WebCore::createContextualFragment):
* html/HTMLAnchorElement.h:
(WebCore::isHTMLAnchorElement):
(WebCore::HTMLAnchorElement):
* html/HTMLAreaElement.h:
(WebCore::isHTMLAreaElement):
(WebCore::HTMLAreaElement):
* html/HTMLBaseElement.h:
(WebCore::isHTMLBaseElement):
(WebCore::HTMLBaseElement):
* html/HTMLElement.h:
(WebCore::HTMLElement):
* html/HTMLFieldSetElement.cpp:
(WebCore::HTMLFieldSetElement::invalidateDisabledStateUnder):
(WebCore::HTMLFieldSetElement::childrenChanged):
(WebCore::HTMLFieldSetElement::legend):
* html/HTMLFormControlElement.h:
(WebCore::toHTMLFormControlElement):
(WebCore::HTMLFormControlElement):
* html/HTMLLabelElement.cpp:
(WebCore::nodeAsSupportedLabelableElement):
(WebCore::HTMLLabelElement::control):
* html/HTMLLabelElement.h:
(WebCore::isHTMLLabelElement):
(WebCore::HTMLLabelElement):
* html/HTMLLegendElement.h:
(WebCore::isHTMLLegendElement):
(WebCore::HTMLLegendElement):
* html/HTMLMapElement.cpp:
(WebCore::HTMLMapElement::mapMouseEvent):
* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::finishParsingChildren):
* html/HTMLStyleElement.h:
(WebCore::isHTMLStyleElement):
(WebCore::HTMLStyleElement):
* html/HTMLTitleElement.h:
(WebCore::HTMLTitleElement):
* html/HTMLTrackElement.h:
(WebCore::isHTMLTrackElement):
(WebCore::HTMLTrackElement):
* html/LabelableElement.h:
(WebCore::isLabelableElement):
(WebCore::LabelableElement):
* rendering/FilterEffectRenderer.cpp:
(WebCore::FilterEffectRenderer::buildReferenceFilter):
* svg/SVGElement.h:
(WebCore::SVGElement):
* svg/SVGForeignObjectElement.h:
(WebCore::isSVGForeignObjectElement):
(WebCore::SVGForeignObjectElement):
* svg/SVGSVGElement.cpp:
(WebCore::SVGSVGElement::collectIntersectionOrEnclosureList):
(WebCore::SVGSVGElement::getElementById):
* svg/SVGStyledElement.cpp:
(WebCore::SVGStyledElement::title):
* svg/SVGTitleElement.h:
(WebCore::SVGTitleElement):
* svg/animation/SMILTimeContainer.cpp:
(WebCore::SMILTimeContainer::updateDocumentOrderIndexes):
* svg/animation/SVGSMILElement.cpp:
(WebCore::SVGSMILElement::isSMILElement):
* svg/animation/SVGSMILElement.h:
(WebCore::SVGSMILElement):
* svg/graphics/SVGImage.cpp:
(WebCore::SVGImage::hasSingleSecurityOrigin):



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@154481 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent d63232eb
2013-08-23 Antti Koivisto <antti@apple.com>
<https://webkit.org/b/120166> Add Traversal<ElementType> template
Reviewed by Andreas Kling.
It is common to traverse through a subtree looking for elements of specific type and then casting to the type. This pattern can be generalized.
This patch adds a new Traversal<typename ElementType> template. It works like ElementTraversal except that the traversal is limited to the specified type.
The patch also uses the template in a bunch of applicable places.
* WebCore.exp.in:
* accessibility/AccessibilityRenderObject.cpp:
(WebCore::AccessibilityRenderObject::addImageMapChildren):
* dom/Document.cpp:
(WebCore::Document::removeTitle):
(WebCore::Document::updateBaseURL):
(WebCore::Document::processBaseElement):
* dom/Element.h:
* dom/ElementTraversal.h:
(WebCore::::firstChildTemplate):
(WebCore::::firstWithinTemplate):
(WebCore::::lastChildTemplate):
(WebCore::::lastWithinTemplate):
(WebCore::::nextTemplate):
(WebCore::::previousTemplate):
(WebCore::::nextSiblingTemplate):
(WebCore::::previousSiblingTemplate):
(WebCore::::nextSkippingChildrenTemplate):
(WebCore::::firstChild):
(WebCore::::lastChild):
(WebCore::::firstWithin):
(WebCore::::lastWithin):
(WebCore::::next):
(WebCore::::previous):
(WebCore::::nextSibling):
(WebCore::::previousSibling):
(WebCore::::nextSkippingChildren):
(WebCore::ElementTraversal::previousIncludingPseudo):
(WebCore::ElementTraversal::nextIncludingPseudo):
(WebCore::ElementTraversal::nextIncludingPseudoSkippingChildren):
(WebCore::ElementTraversal::pseudoAwarePreviousSibling):
* dom/Node.cpp:
(WebCore::Node::numberOfScopedHTMLStyleChildren):
* dom/NodeIterator.cpp:
(WebCore::NodeIterator::NodeIterator):
* dom/NodeIterator.h:
* dom/Traversal.cpp:
(WebCore::NodeIteratorBase::NodeIteratorBase):
(WebCore::NodeIteratorBase::acceptNode):
* dom/Traversal.h:
Renamed existing class called Traversal to less generic NodeIteratorBase.
* dom/TreeScope.cpp:
(WebCore::TreeScope::labelElementForId):
(WebCore::TreeScope::findAnchor):
* dom/TreeWalker.cpp:
(WebCore::TreeWalker::TreeWalker):
* dom/TreeWalker.h:
* editing/FrameSelection.cpp:
(WebCore::scanForForm):
* editing/markup.cpp:
(WebCore::createContextualFragment):
* html/HTMLAnchorElement.h:
(WebCore::isHTMLAnchorElement):
(WebCore::HTMLAnchorElement):
* html/HTMLAreaElement.h:
(WebCore::isHTMLAreaElement):
(WebCore::HTMLAreaElement):
* html/HTMLBaseElement.h:
(WebCore::isHTMLBaseElement):
(WebCore::HTMLBaseElement):
* html/HTMLElement.h:
(WebCore::HTMLElement):
* html/HTMLFieldSetElement.cpp:
(WebCore::HTMLFieldSetElement::invalidateDisabledStateUnder):
(WebCore::HTMLFieldSetElement::childrenChanged):
(WebCore::HTMLFieldSetElement::legend):
* html/HTMLFormControlElement.h:
(WebCore::toHTMLFormControlElement):
(WebCore::HTMLFormControlElement):
* html/HTMLLabelElement.cpp:
(WebCore::nodeAsSupportedLabelableElement):
(WebCore::HTMLLabelElement::control):
* html/HTMLLabelElement.h:
(WebCore::isHTMLLabelElement):
(WebCore::HTMLLabelElement):
* html/HTMLLegendElement.h:
(WebCore::isHTMLLegendElement):
(WebCore::HTMLLegendElement):
* html/HTMLMapElement.cpp:
(WebCore::HTMLMapElement::mapMouseEvent):
* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::finishParsingChildren):
* html/HTMLStyleElement.h:
(WebCore::isHTMLStyleElement):
(WebCore::HTMLStyleElement):
* html/HTMLTitleElement.h:
(WebCore::HTMLTitleElement):
* html/HTMLTrackElement.h:
(WebCore::isHTMLTrackElement):
(WebCore::HTMLTrackElement):
* html/LabelableElement.h:
(WebCore::isLabelableElement):
(WebCore::LabelableElement):
* rendering/FilterEffectRenderer.cpp:
(WebCore::FilterEffectRenderer::buildReferenceFilter):
* svg/SVGElement.h:
(WebCore::SVGElement):
* svg/SVGForeignObjectElement.h:
(WebCore::isSVGForeignObjectElement):
(WebCore::SVGForeignObjectElement):
* svg/SVGSVGElement.cpp:
(WebCore::SVGSVGElement::collectIntersectionOrEnclosureList):
(WebCore::SVGSVGElement::getElementById):
* svg/SVGStyledElement.cpp:
(WebCore::SVGStyledElement::title):
* svg/SVGTitleElement.h:
(WebCore::SVGTitleElement):
* svg/animation/SMILTimeContainer.cpp:
(WebCore::SMILTimeContainer::updateDocumentOrderIndexes):
* svg/animation/SVGSMILElement.cpp:
(WebCore::SVGSMILElement::isSMILElement):
* svg/animation/SVGSMILElement.h:
(WebCore::SVGSMILElement):
* svg/graphics/SVGImage.cpp:
(WebCore::SVGImage::hasSingleSecurityOrigin):
2013-08-23 Arpita Bahuguna <a.bah@samsung.com>
 
<br> does not get deleted when inlined after some non-textual content.
......@@ -2694,7 +2694,6 @@ __ZN7WebCore22RuntimeEnabledFeatures22isDialogElementEnabledE
#endif
#if ENABLE(SVG)
__ZN7WebCore14SVGSMILElement13isSMILElementEPNS_4NodeE
__ZN7WebCore8Document13svgExtensionsEv
__ZN7WebCore8Document19accessSVGExtensionsEv
#endif
......
......@@ -2753,9 +2753,9 @@ void AccessibilityRenderObject::addImageMapChildren()
if (!map)
return;
for (Element* current = ElementTraversal::firstWithin(map); current; current = ElementTraversal::next(current, map)) {
for (HTMLAreaElement* current = Traversal<HTMLAreaElement>::firstWithin(map); current; current = Traversal<HTMLAreaElement>::next(current, map)) {
// add an <area> element for this child if it has a link
if (isHTMLAreaElement(current) && current->isLink()) {
if (current->isLink()) {
AccessibilityImageMapLink* areaObject = static_cast<AccessibilityImageMapLink*>(axObjectCache()->getOrCreate(ImageMapLinkRole));
areaObject->setHTMLAreaElement(toHTMLAreaElement(current));
areaObject->setHTMLMapElement(map);
......
......@@ -78,6 +78,7 @@
#include "History.h"
#include "HTMLAllCollection.h"
#include "HTMLAnchorElement.h"
#include "HTMLBaseElement.h"
#include "HTMLCanvasElement.h"
#include "HTMLCollection.h"
#include "HTMLDocument.h"
......@@ -1559,13 +1560,8 @@ void Document::removeTitle(Element* titleElement)
// Update title based on first title element in the head, if one exists.
if (HTMLElement* headElement = head()) {
for (Element* element = ElementTraversal::firstWithin(headElement); element; element = ElementTraversal::nextSibling(element)) {
if (isHTMLTitleElement(element)) {
HTMLTitleElement* titleElement = toHTMLTitleElement(element);
setTitleElement(titleElement->textWithDirection(), titleElement);
break;
}
}
if (HTMLTitleElement* titleElement = Traversal<HTMLTitleElement>::firstWithin(headElement))
setTitleElement(titleElement->textWithDirection(), titleElement);
}
if (!m_titleElement)
......@@ -2613,10 +2609,8 @@ void Document::updateBaseURL()
if (!equalIgnoringFragmentIdentifier(oldBaseURL, m_baseURL)) {
// Base URL change changes any relative visited links.
// FIXME: There are other URLs in the tree that would need to be re-evaluated on dynamic base URL change. Style should be invalidated too.
for (Element* element = ElementTraversal::firstWithin(this); element; element = ElementTraversal::next(element)) {
if (isHTMLAnchorElement(element))
toHTMLAnchorElement(element)->invalidateCachedVisitedLinkHash();
}
for (HTMLAnchorElement* anchor = Traversal<HTMLAnchorElement>::firstWithin(this); anchor; anchor = Traversal<HTMLAnchorElement>::next(anchor))
anchor->invalidateCachedVisitedLinkHash();
}
}
......@@ -2631,18 +2625,16 @@ void Document::processBaseElement()
// Find the first href attribute in a base element and the first target attribute in a base element.
const AtomicString* href = 0;
const AtomicString* target = 0;
for (Element* element = ElementTraversal::firstWithin(this); element && (!href || !target); element = ElementTraversal::next(element)) {
if (element->hasTagName(baseTag)) {
if (!href) {
const AtomicString& value = element->fastGetAttribute(hrefAttr);
if (!value.isNull())
href = &value;
}
if (!target) {
const AtomicString& value = element->fastGetAttribute(targetAttr);
if (!value.isNull())
target = &value;
}
for (HTMLBaseElement* base = Traversal<HTMLBaseElement>::firstWithin(this); base && (!href || !target); base = Traversal<HTMLBaseElement>::next(base)) {
if (!href) {
const AtomicString& value = base->fastGetAttribute(hrefAttr);
if (!value.isNull())
href = &value;
}
if (!target) {
const AtomicString& value = base->fastGetAttribute(targetAttr);
if (!value.isNull())
target = &value;
}
}
......
......@@ -692,6 +692,10 @@ inline const Element* toElement(const Node* node)
// This will catch anyone doing an unnecessary cast.
void toElement(const Element*);
template <typename Type> bool isElementOfType(const Element*);
template <typename Type> bool isElementOfType(const Node* node) { return node->isElementNode() && isElementOfType<Type>(toElement(node)); }
template <> inline bool isElementOfType<Element>(const Element*) { return true; }
inline bool isDisabledFormControl(const Node* node)
{
return node->isElementNode() && toElement(node)->isDisabledFormControl();
......
This diff is collapsed.
......@@ -2380,9 +2380,10 @@ void Node::unregisterScopedHTMLStyleChild()
size_t Node::numberOfScopedHTMLStyleChildren() const
{
size_t count = 0;
for (Element* element = ElementTraversal::firstWithin(this); element; element = ElementTraversal::next(element, this))
if (isHTMLStyleElement(element) && toHTMLStyleElement(element)->isRegisteredAsScoped())
for (HTMLStyleElement* style = Traversal<HTMLStyleElement>::firstWithin(this); style; style = Traversal<HTMLStyleElement>::next(style, this)) {
if (style->isRegisteredAsScoped())
count++;
}
return count;
}
......
......@@ -73,7 +73,7 @@ bool NodeIterator::NodePointer::moveToPrevious(Node* root)
}
NodeIterator::NodeIterator(PassRefPtr<Node> rootNode, unsigned whatToShow, PassRefPtr<NodeFilter> filter, bool expandEntityReferences)
: Traversal(rootNode, whatToShow, filter, expandEntityReferences)
: NodeIteratorBase(rootNode, whatToShow, filter, expandEntityReferences)
, m_referenceNode(root(), true)
, m_detached(false)
{
......
......@@ -35,7 +35,7 @@ namespace WebCore {
typedef int ExceptionCode;
class NodeIterator : public ScriptWrappable, public RefCounted<NodeIterator>, public Traversal {
class NodeIterator : public ScriptWrappable, public RefCounted<NodeIterator>, public NodeIteratorBase {
public:
static PassRefPtr<NodeIterator> create(PassRefPtr<Node> rootNode, unsigned whatToShow, PassRefPtr<NodeFilter> filter, bool expandEntityReferences)
{
......
......@@ -30,7 +30,7 @@
namespace WebCore {
Traversal::Traversal(PassRefPtr<Node> rootNode, unsigned whatToShow, PassRefPtr<NodeFilter> nodeFilter, bool expandEntityReferences)
NodeIteratorBase::NodeIteratorBase(PassRefPtr<Node> rootNode, unsigned whatToShow, PassRefPtr<NodeFilter> nodeFilter, bool expandEntityReferences)
: m_root(rootNode)
, m_whatToShow(whatToShow)
, m_filter(nodeFilter)
......@@ -38,7 +38,7 @@ Traversal::Traversal(PassRefPtr<Node> rootNode, unsigned whatToShow, PassRefPtr<
{
}
short Traversal::acceptNode(ScriptState* state, Node* node) const
short NodeIteratorBase::acceptNode(ScriptState* state, Node* node) const
{
// FIXME: To handle XML properly we would have to check m_expandEntityReferences.
......
......@@ -33,7 +33,7 @@ namespace WebCore {
class Node;
class NodeFilter;
class Traversal {
class NodeIteratorBase {
public:
Node* root() const { return m_root.get(); }
unsigned whatToShow() const { return m_whatToShow; }
......@@ -41,7 +41,7 @@ namespace WebCore {
bool expandEntityReferences() const { return m_expandEntityReferences; }
protected:
Traversal(PassRefPtr<Node>, unsigned whatToShow, PassRefPtr<NodeFilter>, bool expandEntityReferences);
NodeIteratorBase(PassRefPtr<Node>, unsigned whatToShow, PassRefPtr<NodeFilter>, bool expandEntityReferences);
short acceptNode(ScriptState*, Node*) const;
private:
......
......@@ -298,13 +298,10 @@ HTMLLabelElement* TreeScope::labelElementForId(const AtomicString& forAttributeV
if (!m_labelsByForAttribute) {
// Populate the map on first access.
m_labelsByForAttribute = adoptPtr(new DocumentOrderedMap);
for (Element* element = ElementTraversal::firstWithin(rootNode()); element; element = ElementTraversal::next(element)) {
if (isHTMLLabelElement(element)) {
HTMLLabelElement* label = toHTMLLabelElement(element);
const AtomicString& forValue = label->fastGetAttribute(forAttr);
if (!forValue.isEmpty())
addLabel(forValue, label);
}
for (HTMLLabelElement* label = Traversal<HTMLLabelElement>::firstWithin(rootNode()); label; label = Traversal<HTMLLabelElement>::next(label)) {
const AtomicString& forValue = label->fastGetAttribute(forAttr);
if (!forValue.isEmpty())
addLabel(forValue, label);
}
}
......@@ -342,18 +339,15 @@ Element* TreeScope::findAnchor(const String& name)
return 0;
if (Element* element = getElementById(name))
return element;
for (Element* element = ElementTraversal::firstWithin(rootNode()); element; element = ElementTraversal::next(element)) {
if (isHTMLAnchorElement(element)) {
HTMLAnchorElement* anchor = toHTMLAnchorElement(element);
if (rootNode()->document()->inQuirksMode()) {
// Quirks mode, case insensitive comparison of names.
if (equalIgnoringCase(anchor->name(), name))
return anchor;
} else {
// Strict mode, names need to match exactly.
if (anchor->name() == name)
return anchor;
}
for (HTMLAnchorElement* anchor = Traversal<HTMLAnchorElement>::firstWithin(rootNode()); anchor; anchor = Traversal<HTMLAnchorElement>::next(anchor)) {
if (rootNode()->document()->inQuirksMode()) {
// Quirks mode, case insensitive comparison of names.
if (equalIgnoringCase(anchor->name(), name))
return anchor;
} else {
// Strict mode, names need to match exactly.
if (anchor->name() == name)
return anchor;
}
}
return 0;
......
......@@ -35,7 +35,7 @@
namespace WebCore {
TreeWalker::TreeWalker(PassRefPtr<Node> rootNode, unsigned whatToShow, PassRefPtr<NodeFilter> filter, bool expandEntityReferences)
: Traversal(rootNode, whatToShow, filter, expandEntityReferences)
: NodeIteratorBase(rootNode, whatToShow, filter, expandEntityReferences)
, m_current(root())
{
}
......
......@@ -35,7 +35,7 @@ namespace WebCore {
typedef int ExceptionCode;
class TreeWalker : public ScriptWrappable, public RefCounted<TreeWalker>, public Traversal {
class TreeWalker : public ScriptWrappable, public RefCounted<TreeWalker>, public NodeIteratorBase {
public:
static PassRefPtr<TreeWalker> create(PassRefPtr<Node> rootNode, unsigned whatToShow, PassRefPtr<NodeFilter> filter, bool expandEntityReferences)
{
......
......@@ -1970,11 +1970,11 @@ static HTMLFormElement* scanForForm(Node* start)
{
if (!start)
return 0;
Element* element = start->isElementNode() ? toElement(start) : ElementTraversal::next(start);
for (; element; element = ElementTraversal::next(element)) {
HTMLElement* element = start->isHTMLElement() ? toHTMLElement(start) : Traversal<HTMLElement>::next(start);
for (; element; element = Traversal<HTMLElement>::next(element)) {
if (isHTMLFormElement(element))
return toHTMLFormElement(element);
if (element->isHTMLElement() && toHTMLElement(element)->isFormControlElement())
if (element->isFormControlElement())
return static_cast<HTMLFormControlElement*>(element)->form();
if (element->hasTagName(frameTag) || element->hasTagName(iframeTag))
if (HTMLFormElement* frameResult = scanForForm(toHTMLFrameElementBase(element)->contentDocument()))
......
......@@ -1055,14 +1055,13 @@ PassRefPtr<DocumentFragment> createContextualFragment(const String& markup, HTML
// accommodate folks passing complete HTML documents to make the
// child of an element.
RefPtr<Element> nextElement;
for (RefPtr<Element> element = ElementTraversal::firstWithin(fragment.get()); element; element = nextElement) {
nextElement = ElementTraversal::nextSibling(element.get());
RefPtr<HTMLElement> nextElement;
for (RefPtr<HTMLElement> element = Traversal<HTMLElement>::firstWithin(fragment.get()); element; element = nextElement) {
nextElement = Traversal<HTMLElement>::nextSibling(element.get());
if (element->hasTagName(htmlTag) || element->hasTagName(headTag) || element->hasTagName(bodyTag)) {
HTMLElement* htmlElement = toHTMLElement(element.get());
if (Element* firstChild = ElementTraversal::firstWithin(htmlElement))
if (HTMLElement* firstChild = Traversal<HTMLElement>::firstChild(element.get()))
nextElement = firstChild;
removeElementPreservingChildren(fragment, htmlElement);
removeElementPreservingChildren(fragment, element.get());
}
}
return fragment.release();
......
......@@ -149,12 +149,12 @@ inline LinkHash HTMLAnchorElement::visitedLinkHash() const
return m_cachedVisitedLinkHash;
}
inline bool isHTMLAnchorElement(Node* node)
inline bool isHTMLAnchorElement(const Node* node)
{
return node->hasTagName(HTMLNames::aTag);
}
inline bool isHTMLAnchorElement(Element* element)
inline bool isHTMLAnchorElement(const Element* element)
{
return element->hasTagName(HTMLNames::aTag);
}
......@@ -165,6 +165,8 @@ inline HTMLAnchorElement* toHTMLAnchorElement(Node* node)
return static_cast<HTMLAnchorElement*>(node);
}
template <> inline bool isElementOfType<HTMLAnchorElement>(const Element* element) { return isHTMLAnchorElement(element); }
// Functions shared with the other anchor elements (i.e., SVG).
bool isEnterKeyKeydownEvent(Event*);
......
......@@ -70,16 +70,18 @@ private:
Shape m_shape;
};
inline bool isHTMLAreaElement(Node* node)
inline bool isHTMLAreaElement(const Node* node)
{
return node->hasTagName(HTMLNames::areaTag);
}
inline bool isHTMLAreaElement(Element* element)
inline bool isHTMLAreaElement(const Element* element)
{
return element->hasTagName(HTMLNames::areaTag);
}
template <> inline bool isElementOfType<HTMLAreaElement>(const Element* element) { return isHTMLAreaElement(element); }
inline HTMLAreaElement* toHTMLAreaElement(Node* node)
{
ASSERT_WITH_SECURITY_IMPLICATION(!node || isHTMLAreaElement(node));
......
......@@ -44,6 +44,18 @@ private:
virtual void removedFrom(ContainerNode*) OVERRIDE;
};
inline bool isHTMLBaseElement(const Node* node)
{
return node->hasTagName(HTMLNames::baseTag);
}
inline bool isHTMLBaseElement(const Element* element)
{
return element->hasTagName(HTMLNames::baseTag);
}
template <> inline bool isElementOfType<HTMLBaseElement>(const Element* element) { return isHTMLBaseElement(element); }
} // namespace
#endif
......@@ -154,6 +154,8 @@ inline HTMLElement::HTMLElement(const QualifiedName& tagName, Document* document
ASSERT(tagName.localName().impl());
}
template <> inline bool isElementOfType<HTMLElement>(const Element* element) { return element->isHTMLElement(); }
} // namespace WebCore
#endif // HTMLElement_h
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment