diff options
Diffstat (limited to 'WebKit/chromium/public/WebNode.h')
-rw-r--r-- | WebKit/chromium/public/WebNode.h | 78 |
1 files changed, 51 insertions, 27 deletions
diff --git a/WebKit/chromium/public/WebNode.h b/WebKit/chromium/public/WebNode.h index 4d2a0e9..7116dfa 100644 --- a/WebKit/chromium/public/WebNode.h +++ b/WebKit/chromium/public/WebNode.h @@ -32,17 +32,15 @@ #define WebNode_h #include "WebCommon.h" +#include "WebPrivatePtr.h" #include "WebString.h" namespace WebCore { class Node; } -#if WEBKIT_IMPLEMENTATION -namespace WTF { template <typename T> class PassRefPtr; } -#endif namespace WebKit { +class WebDOMEventListener; +class WebDOMEventListenerPrivate; class WebDocument; -class WebEventListener; -class WebEventListenerPrivate; class WebFrame; class WebNodeList; @@ -51,8 +49,8 @@ class WebNode { public: virtual ~WebNode() { reset(); } - WebNode() : m_private(0) { } - WebNode(const WebNode& n) : m_private(0) { assign(n); } + WebNode() { } + WebNode(const WebNode& n) { assign(n); } WebNode& operator=(const WebNode& n) { assign(n); @@ -62,13 +60,12 @@ public: WEBKIT_API void reset(); WEBKIT_API void assign(const WebNode&); - bool isNull() const { return !m_private; } - -#if WEBKIT_IMPLEMENTATION - WebNode(const WTF::PassRefPtr<WebCore::Node>&); - WebNode& operator=(const WTF::PassRefPtr<WebCore::Node>&); - operator WTF::PassRefPtr<WebCore::Node>() const; -#endif + WEBKIT_API bool equals(const WebNode&) const; + // Required for using WebNodes in std maps. Note the order used is + // arbitrary and should not be expected to have any specific meaning. + WEBKIT_API bool lessThan(const WebNode&) const; + + bool isNull() const { return m_private.isNull(); } enum NodeType { ElementNode = 1, @@ -90,8 +87,6 @@ public: WEBKIT_API WebString nodeName() const; WEBKIT_API WebString nodeValue() const; WEBKIT_API bool setNodeValue(const WebString&); - // Deprecated. Use document().frame() instead. - WEBKIT_API WebFrame* frame() const; WEBKIT_API WebDocument document() const; WEBKIT_API WebNode firstChild() const; WEBKIT_API WebNode lastChild() const; @@ -101,40 +96,69 @@ public: WEBKIT_API WebNodeList childNodes(); WEBKIT_API WebString createMarkup() const; WEBKIT_API bool isTextNode() const; + WEBKIT_API bool isContentEditable() const; WEBKIT_API bool isElementNode() const; - WEBKIT_API void addEventListener(const WebString& eventType, WebEventListener* listener, bool useCapture); - WEBKIT_API void removeEventListener(const WebString& eventType, WebEventListener* listener, bool useCapture); + WEBKIT_API void addEventListener(const WebString& eventType, WebDOMEventListener* listener, bool useCapture); + WEBKIT_API void removeEventListener(const WebString& eventType, WebDOMEventListener* listener, bool useCapture); + WEBKIT_API void simulateClick(); + WEBKIT_API WebNodeList getElementsByTagName(const WebString&) const; + + // Returns true if the node has a non-empty bounding box in layout. + // This does not 100% guarantee the user can see it, but is pretty close. + // Note: This method only works properly after layout has occurred. + WEBKIT_API bool hasNonEmptyBoundingBox() const; - template<typename T> T toElement() + template<typename T> T to() { T res; res.WebNode::assign(*this); return res; } - template<typename T> const T toConstElement() const + template<typename T> const T toConst() const { T res; res.WebNode::assign(*this); return res; } -protected: - typedef WebCore::Node WebNodePrivate; - void assign(WebNodePrivate*); - WebNodePrivate* m_private; - +#if WEBKIT_IMPLEMENTATION + WebNode(const WTF::PassRefPtr<WebCore::Node>&); + WebNode& operator=(const WTF::PassRefPtr<WebCore::Node>&); + operator WTF::PassRefPtr<WebCore::Node>() const; +#endif + +#if WEBKIT_IMPLEMENTATION template<typename T> T* unwrap() { - return static_cast<T*>(m_private); + return static_cast<T*>(m_private.get()); } template<typename T> const T* constUnwrap() const { - return static_cast<const T*>(m_private); + 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); +} + } // namespace WebKit #endif |