Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(49)

Side by Side Diff: Source/WebKit/chromium/public/WebNode.h

Issue 16358003: mv Source/WebKit/chromium/public to public/webview (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 #include "../../../../public/webview/WebNode.h"
2 * Copyright (C) 2009 Google Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above
11 * copyright notice, this list of conditions and the following disclaimer
12 * in the documentation and/or other materials provided with the
13 * distribution.
14 * * Neither the name of Google Inc. nor the names of its
15 * contributors may be used to endorse or promote products derived from
16 * this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31 #ifndef WebNode_h
32 #define WebNode_h
33
34 #include "../../../../public/platform/WebCommon.h"
35 #include "../../../../public/platform/WebPrivatePtr.h"
36 #include "../../../../public/platform/WebString.h"
37 #include "WebExceptionCode.h"
38
39 namespace WebCore { class Node; }
40
41 namespace WebKit {
42 class WebDOMEvent;
43 class WebDOMEventListener;
44 class WebDOMEventListenerPrivate;
45 class WebDocument;
46 class WebElement;
47 class WebFrame;
48 class WebNodeList;
49 class WebPluginContainer;
50
51 // Provides access to some properties of a DOM node.
52 class WebNode {
53 public:
54 virtual ~WebNode() { reset(); }
55
56 WebNode() { }
57 WebNode(const WebNode& n) { assign(n); }
58 WebNode& operator=(const WebNode& n)
59 {
60 assign(n);
61 return *this;
62 }
63
64 WEBKIT_EXPORT void reset();
65 WEBKIT_EXPORT void assign(const WebNode&);
66
67 WEBKIT_EXPORT bool equals(const WebNode&) const;
68 // Required for using WebNodes in std maps. Note the order used is
69 // arbitrary and should not be expected to have any specific meaning.
70 WEBKIT_EXPORT bool lessThan(const WebNode&) const;
71
72 bool isNull() const { return m_private.isNull(); }
73
74 enum NodeType {
75 ElementNode = 1,
76 AttributeNode = 2,
77 TextNode = 3,
78 CDataSectionNode = 4,
79 // EntityReferenceNodes are deprecated and impossible to create in WebKi t.
80 EntityNode = 6,
81 ProcessingInstructionsNode = 7,
82 CommentNode = 8,
83 DocumentNode = 9,
84 DocumentTypeNode = 10,
85 DocumentFragmentNode = 11,
86 NotationNode = 12,
87 XPathNamespaceNode = 13,
88 ShadowRootNode = 14
89 };
90
91 WEBKIT_EXPORT NodeType nodeType() const;
92 WEBKIT_EXPORT WebNode parentNode() const;
93 WEBKIT_EXPORT WebString nodeName() const;
94 WEBKIT_EXPORT WebString nodeValue() const;
95 WEBKIT_EXPORT bool setNodeValue(const WebString&);
96 WEBKIT_EXPORT WebDocument document() const;
97 WEBKIT_EXPORT WebNode firstChild() const;
98 WEBKIT_EXPORT WebNode lastChild() const;
99 WEBKIT_EXPORT WebNode previousSibling() const;
100 WEBKIT_EXPORT WebNode nextSibling() const;
101 WEBKIT_EXPORT bool hasChildNodes() const;
102 WEBKIT_EXPORT WebNodeList childNodes();
103 WEBKIT_EXPORT bool appendChild(const WebNode& child);
104 WEBKIT_EXPORT WebString createMarkup() const;
105 WEBKIT_EXPORT bool isLink() const;
106 WEBKIT_EXPORT bool isTextNode() const;
107 WEBKIT_EXPORT bool isFocusable() const;
108 WEBKIT_EXPORT bool isContentEditable() const;
109 WEBKIT_EXPORT bool isElementNode() const;
110 // addEventListener only works with a small set of eventTypes.
111 WEBKIT_EXPORT void addEventListener(const WebString& eventType, WebDOMEventL istener* listener, bool useCapture);
112 WEBKIT_EXPORT bool dispatchEvent(const WebDOMEvent&);
113 WEBKIT_EXPORT void simulateClick();
114 WEBKIT_EXPORT WebNodeList getElementsByTagName(const WebString&) const;
115 WEBKIT_EXPORT WebElement querySelector(const WebString&, WebExceptionCode&) const;
116 WEBKIT_EXPORT WebElement rootEditableElement() const;
117 WEBKIT_EXPORT bool focused() const;
118 WEBKIT_EXPORT bool remove();
119
120 // Returns true if the node has a non-empty bounding box in layout.
121 // This does not 100% guarantee the user can see it, but is pretty close.
122 // Note: This method only works properly after layout has occurred.
123 WEBKIT_EXPORT bool hasNonEmptyBoundingBox() const;
124 WEBKIT_EXPORT WebPluginContainer* pluginContainer() const;
125 WEBKIT_EXPORT WebElement shadowHost() const;
126
127 template<typename T> T to()
128 {
129 T res;
130 res.WebNode::assign(*this);
131 return res;
132 }
133
134 template<typename T> const T toConst() const
135 {
136 T res;
137 res.WebNode::assign(*this);
138 return res;
139 }
140
141 #if WEBKIT_IMPLEMENTATION
142 WebNode(const WTF::PassRefPtr<WebCore::Node>&);
143 WebNode& operator=(const WTF::PassRefPtr<WebCore::Node>&);
144 operator WTF::PassRefPtr<WebCore::Node>() const;
145 #endif
146
147 #if WEBKIT_IMPLEMENTATION
148 template<typename T> T* unwrap()
149 {
150 return static_cast<T*>(m_private.get());
151 }
152
153 template<typename T> const T* constUnwrap() const
154 {
155 return static_cast<const T*>(m_private.get());
156 }
157 #endif
158
159 protected:
160 WebPrivatePtr<WebCore::Node> m_private;
161 };
162
163 inline bool operator==(const WebNode& a, const WebNode& b)
164 {
165 return a.equals(b);
166 }
167
168 inline bool operator!=(const WebNode& a, const WebNode& b)
169 {
170 return !(a == b);
171 }
172
173 inline bool operator<(const WebNode& a, const WebNode& b)
174 {
175 return a.lessThan(b);
176 }
177
178 } // namespace WebKit
179
180 #endif
OLDNEW
« no previous file with comments | « Source/WebKit/chromium/public/WebNetworkStateNotifier.h ('k') | Source/WebKit/chromium/public/WebNodeCollection.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698