Index: Source/core/dom/Node.cpp |
diff --git a/Source/core/dom/Node.cpp b/Source/core/dom/Node.cpp |
index d7e4d8ab891a5c6025735c92509d3c26d7bfb2a1..b407e14c8cb16d0bbbd5bdaae3be45d3c4da0d73 100644 |
--- a/Source/core/dom/Node.cpp |
+++ b/Source/core/dom/Node.cpp |
@@ -1815,14 +1815,17 @@ void Node::showTreeForThisAcrossFrame() const |
// -------- |
-Node* Node::enclosingLinkEventParentOrSelf() |
+Element* Node::enclosingLinkEventParentOrSelf() |
{ |
for (Node* node = this; node; node = NodeRenderingTraversal::parent(node)) { |
// For imagemaps, the enclosing link node is the associated area element not the image itself. |
// So we don't let images be the enclosingLinkNode, even though isLink sometimes returns true |
// for them. |
- if (node->isLink() && !isHTMLImageElement(*node)) |
- return node; |
+ if (node->isLink() && !isHTMLImageElement(*node)) { |
+ // Casting to Element is safe because only HTMLAnchorElement, HTMLImageElement and |
+ // SVGAElement can return true for isLink(). |
+ return toElement(node); |
+ } |
} |
return 0; |