Chromium Code Reviews| Index: third_party/WebKit/public/web/WebNode.h |
| diff --git a/third_party/WebKit/public/web/WebNode.h b/third_party/WebKit/public/web/WebNode.h |
| index 3313073ea3c11b728ddc48e3be24d7e2df47f73b..90515a45e3dc455c6772f42403aff84935f360d1 100644 |
| --- a/third_party/WebKit/public/web/WebNode.h |
| +++ b/third_party/WebKit/public/web/WebNode.h |
| @@ -75,24 +75,6 @@ public: |
| bool isNull() const { return m_private.isNull(); } |
| - enum NodeType { |
| - ElementNode = 1, |
| - AttributeNode = 2, |
| - TextNode = 3, |
| - CDataSectionNode = 4, |
| - // EntityReferenceNodes are impossible to create in Blink. |
| - // EntityNodes are impossible to create in Blink. |
| - ProcessingInstructionsNode = 7, |
| - CommentNode = 8, |
| - DocumentNode = 9, |
| - DocumentTypeNode = 10, |
| - DocumentFragmentNode = 11, |
| - // NotationNodes are impossible to create in Blink. |
| - // XPathNamespaceNodes are impossible to create in Blink. |
| - ShadowRootNode = 14 |
| - }; |
| - |
| - BLINK_EXPORT NodeType nodeType() const; |
| BLINK_EXPORT WebNode parentNode() const; |
| BLINK_EXPORT WebString nodeValue() const; |
| BLINK_EXPORT WebDocument document() const; |
| @@ -103,6 +85,7 @@ public: |
| BLINK_EXPORT bool hasChildNodes() const; |
| BLINK_EXPORT WebNodeList childNodes(); |
| BLINK_EXPORT bool isLink() const; |
| + BLINK_EXPORT bool isDocumentNode() const; |
| BLINK_EXPORT bool isCommentNode() const; |
| BLINK_EXPORT bool isTextNode() const; |
| BLINK_EXPORT bool isFocusable() const; |
| @@ -129,19 +112,8 @@ public: |
| BLINK_EXPORT bool isInsideFocusableElementOrARIAWidget() const; |
| BLINK_EXPORT WebAXObject accessibilityObject(); |
| - 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; |
| - } |
| + template<typename T> T to(); |
| + template<typename T> const T toConst() const; |
| #if BLINK_IMPLEMENTATION |
| WebNode(const PassRefPtrWillBeRawPtr<Node>&); |
| @@ -165,6 +137,28 @@ protected: |
| WebPrivatePtr<Node> m_private; |
| }; |
| +#define DECLARE_WEB_NODE_TYPE_CASTS(type) \ |
| +template<> \ |
| +BLINK_EXPORT type WebNode::to<type>(); \ |
| +template<> \ |
| +BLINK_EXPORT const type WebNode::toConst<type>() const; |
| + |
| +#define DEFINE_WEB_NODE_TYPE_CASTS(type, predicate) \ |
|
dglazkov
2015/09/25 14:39:08
this guy should be only when BLINK_IMPLEMENTATION,
esprehn
2015/09/25 22:06:54
Yeah done.
|
| +template<> \ |
| +type WebNode::to<type>() { \ |
| + ASSERT_WITH_SECURITY_IMPLICATION(isNull() || (predicate)); \ |
| + type result; \ |
| + result.WebNode::assign(*this); \ |
| + return result; \ |
| +} \ |
| +template<> \ |
| +const type WebNode::toConst<type>() const { \ |
| + ASSERT_WITH_SECURITY_IMPLICATION(isNull() || (predicate)); \ |
| + type result; \ |
| + result.WebNode::assign(*this); \ |
| + return result; \ |
| +} |
| + |
| inline bool operator==(const WebNode& a, const WebNode& b) |
| { |
| return a.equals(b); |