#ifndef WebNode_h
#define WebNode_h
#include "../platform/WebCommon.h"
#include "../platform/WebPrivatePtr.h"
#include "../platform/WebString.h"
#include "WebExceptionCode.h"
namespace WebCore { class Node; }
namespace blink {
class WebDOMEvent;
class WebDOMEventListener;
class WebDOMEventListenerPrivate;
class WebDocument;
class WebElement;
class WebElementCollection;
class WebNodeList;
class WebPluginContainer;
class WebNode {
public:
virtual ~WebNode() { reset(); }
WebNode() { }
WebNode(const WebNode& n) { assign(n); }
WebNode& operator=(const WebNode& n)
{
assign(n);
return *this;
}
BLINK_EXPORT void reset();
BLINK_EXPORT void assign(const WebNode&);
BLINK_EXPORT bool equals(const WebNode&) const;
BLINK_EXPORT bool lessThan(const WebNode&) const;
bool isNull() const { return m_private.isNull(); }
enum NodeType {
ElementNode = 1,
AttributeNode = 2,
TextNode = 3,
CDataSectionNode = 4,
ProcessingInstructionsNode = 7,
CommentNode = 8,
DocumentNode = 9,
DocumentTypeNode = 10,
DocumentFragmentNode = 11,
ShadowRootNode = 14
};
BLINK_EXPORT NodeType nodeType() const;
BLINK_EXPORT WebNode parentNode() const;
BLINK_EXPORT WebString nodeName() const;
BLINK_EXPORT WebString nodeValue() const;
BLINK_EXPORT WebDocument document() const;
BLINK_EXPORT WebNode firstChild() const;
BLINK_EXPORT WebNode lastChild() const;
BLINK_EXPORT WebNode previousSibling() const;
BLINK_EXPORT WebNode nextSibling() const;
BLINK_EXPORT bool hasChildNodes() const;
BLINK_EXPORT WebNodeList childNodes();
BLINK_EXPORT WebString createMarkup() const;
BLINK_EXPORT bool isLink() const;
BLINK_EXPORT bool isTextNode() const;
BLINK_EXPORT bool isFocusable() const;
BLINK_EXPORT bool isContentEditable() const;
BLINK_EXPORT bool isElementNode() const;
BLINK_EXPORT void addEventListener(const WebString& eventType, WebDOMEventListener* listener, bool useCapture);
BLINK_EXPORT bool dispatchEvent(const WebDOMEvent&);
BLINK_EXPORT void simulateClick();
BLINK_EXPORT WebElementCollection getElementsByTagName(const WebString&) const;
BLINK_EXPORT WebElement querySelector(const WebString&, WebExceptionCode&) const;
BLINK_EXPORT WebElement rootEditableElement() const;
BLINK_EXPORT bool focused() const;
BLINK_EXPORT bool remove();
BLINK_EXPORT bool hasNonEmptyBoundingBox() const;
BLINK_EXPORT WebPluginContainer* pluginContainer() const;
BLINK_EXPORT WebElement shadowHost() const;
template<typename T> T to()
{
T res;
res.WebNode::assign(*this);
return res;
}
template<typename T> const T toConst() const
{
T res;
res.WebNode::assign(*this);
return res;
}
#if BLINK_IMPLEMENTATION
WebNode(const WTF::PassRefPtr<WebCore::Node>&);
WebNode& operator=(const WTF::PassRefPtr<WebCore::Node>&);
operator WTF::PassRefPtr<WebCore::Node>() const;
#endif
#if BLINK_IMPLEMENTATION
template<typename T> T* unwrap()
{
return static_cast<T*>(m_private.get());
}
template<typename T> const T* constUnwrap() const
{
return static_cast<const T*>(m_private.get());
}
#endif
protected:
WebPrivatePtr<WebCore::Node> m_private;
};
inline bool operator==(const WebNode& a, const WebNode& b)
{
return a.equals(b);
}
inline bool operator!=(const WebNode& a, const WebNode& b)
{
return !(a == b);
}
inline bool operator<(const WebNode& a, const WebNode& b)
{
return a.lessThan(b);
}
}
#endif