Hi,

> How can I check if a Node is a HTMLDivElement. I want to traverse from a
> child node upto the parent node, until I reach a div node.

You need first to check that it is an Element with the method
isElement(), then cast it as an Element and check its tag name with
Element::hasTagName() (in your case against HTMLNames::divTag). The
code will look like for your use case:

Node* curNode = ... ;

if (curNode->isElement() &&
static_cast<Element*>(curNode)->hasTagName(HTMLNames::divTag)) {
    // This is an html <div> element.
}

This method works for pretty much any type of element using the right tag.

Regards,
Julien
_______________________________________________
webkit-dev mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev

Reply via email to