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

Side by Side Diff: webkit/api/src/WebViewImpl.h

Issue 385057: Deleted webkit/api which now lives in webkit.org (Closed)
Patch Set: Created 11 years, 1 month 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
« no previous file with comments | « webkit/api/src/WebURLResponsePrivate.h ('k') | webkit/api/src/WebViewImpl.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
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 WebViewImpl_h
32 #define WebViewImpl_h
33
34 // FIXME: Remove these relative paths once consumers from glue are removed.
35 #include "../public/WebNavigationPolicy.h"
36 #include "../public/WebPoint.h"
37 #include "../public/WebSize.h"
38 #include "../public/WebString.h"
39 #include "../public/WebView.h"
40
41 #include "BackForwardListClientImpl.h"
42 #include "ChromeClientImpl.h"
43 #include "ContextMenuClientImpl.h"
44 #include "DragClientImpl.h"
45 #include "EditorClientImpl.h"
46 #include "InspectorClientImpl.h"
47 #include "NotificationPresenterImpl.h"
48
49 #include <wtf/OwnPtr.h>
50 #include <wtf/RefCounted.h>
51
52 namespace WebCore {
53 class ChromiumDataObject;
54 class Frame;
55 class HistoryItem;
56 class HitTestResult;
57 class KeyboardEvent;
58 class Page;
59 class PlatformKeyboardEvent;
60 class PopupContainer;
61 class Range;
62 class RenderTheme;
63 class Widget;
64 }
65
66 namespace WebKit {
67 class AutocompletePopupMenuClient;
68 class ContextMenuClientImpl;
69 class WebAccessibilityObject;
70 class WebDevToolsAgentPrivate;
71 class WebFrameImpl;
72 class WebKeyboardEvent;
73 class WebMouseEvent;
74 class WebMouseWheelEvent;
75 class WebSettingsImpl;
76
77 class WebViewImpl : public WebView, public RefCounted<WebViewImpl> {
78 public:
79 // WebWidget methods:
80 virtual void close();
81 virtual WebSize size() { return m_size; }
82 virtual void resize(const WebSize&);
83 virtual void layout();
84 virtual void paint(WebCanvas*, const WebRect&);
85 virtual bool handleInputEvent(const WebInputEvent&);
86 virtual void mouseCaptureLost();
87 virtual void setFocus(bool enable);
88 virtual bool handleCompositionEvent(WebCompositionCommand command,
89 int cursorPosition,
90 int targetStart,
91 int targetEnd,
92 const WebString& text);
93 virtual bool queryCompositionStatus(bool* enabled,
94 WebRect* caretRect);
95 virtual void setTextDirection(WebTextDirection direction);
96
97 // WebView methods:
98 virtual void initializeMainFrame(WebFrameClient*);
99 virtual WebSettings* settings();
100 virtual WebString pageEncoding() const;
101 virtual void setPageEncoding(const WebString& encoding);
102 virtual bool isTransparent() const;
103 virtual void setIsTransparent(bool value);
104 virtual bool tabsToLinks() const;
105 virtual void setTabsToLinks(bool value);
106 virtual bool tabKeyCyclesThroughElements() const;
107 virtual void setTabKeyCyclesThroughElements(bool value);
108 virtual bool isActive() const;
109 virtual void setIsActive(bool value);
110 virtual bool dispatchBeforeUnloadEvent();
111 virtual void dispatchUnloadEvent();
112 virtual WebFrame* mainFrame();
113 virtual WebFrame* findFrameByName(
114 const WebString& name, WebFrame* relativeToFrame);
115 virtual WebFrame* focusedFrame();
116 virtual void setFocusedFrame(WebFrame* frame);
117 virtual void setInitialFocus(bool reverse);
118 virtual void clearFocusedNode();
119 virtual void zoomIn(bool textOnly);
120 virtual void zoomOut(bool textOnly);
121 virtual void zoomDefault();
122 virtual void performMediaPlayerAction(
123 const WebMediaPlayerAction& action,
124 const WebPoint& location);
125 virtual void copyImageAt(const WebPoint& point);
126 virtual void dragSourceEndedAt(
127 const WebPoint& clientPoint,
128 const WebPoint& screenPoint,
129 WebDragOperation operation);
130 virtual void dragSourceSystemDragEnded();
131 virtual WebDragOperation dragTargetDragEnter(
132 const WebDragData& dragData, int identity,
133 const WebPoint& clientPoint,
134 const WebPoint& screenPoint,
135 WebDragOperationsMask operationsAllowed);
136 virtual WebDragOperation dragTargetDragOver(
137 const WebPoint& clientPoint,
138 const WebPoint& screenPoint,
139 WebDragOperationsMask operationsAllowed);
140 virtual void dragTargetDragLeave();
141 virtual void dragTargetDrop(
142 const WebPoint& clientPoint,
143 const WebPoint& screenPoint);
144 virtual int dragIdentity();
145 virtual bool setDropEffect(bool accept);
146 virtual void inspectElementAt(const WebPoint& point);
147 virtual WebString inspectorSettings() const;
148 virtual void setInspectorSettings(const WebString& settings);
149 virtual WebDevToolsAgent* devToolsAgent();
150 virtual void setDevToolsAgent(WebDevToolsAgent*);
151 virtual WebAccessibilityObject accessibilityObject();
152 virtual void applyAutofillSuggestions(
153 const WebNode&,
154 const WebVector<WebString>& suggestions,
155 int defaultSuggestionIndex);
156 virtual void hideAutofillPopup();
157
158 // WebViewImpl
159
160 void setIgnoreInputEvents(bool newValue);
161 WebDevToolsAgentPrivate* devToolsAgentPrivate() { return m_devToolsAgent.get(); }
162
163 const WebPoint& lastMouseDownPoint() const
164 {
165 return m_lastMouseDownPoint;
166 }
167
168 WebCore::Frame* focusedWebCoreFrame();
169
170 // Returns the currently focused Node or null if no node has focus.
171 WebCore::Node* focusedWebCoreNode();
172
173 static WebViewImpl* fromPage(WebCore::Page*);
174
175 WebViewClient* client()
176 {
177 return m_client;
178 }
179
180 // Returns the page object associated with this view. This may be null when
181 // the page is shutting down, but will be valid at all other times.
182 WebCore::Page* page() const
183 {
184 return m_page.get();
185 }
186
187 WebCore::RenderTheme* theme() const;
188
189 // Returns the main frame associated with this view. This may be null when
190 // the page is shutting down, but will be valid at all other times.
191 WebFrameImpl* mainFrameImpl();
192
193 // History related methods:
194 void setCurrentHistoryItem(WebCore::HistoryItem*);
195 WebCore::HistoryItem* previousHistoryItem();
196 void observeNewNavigation();
197
198 // Event related methods:
199 void mouseMove(const WebMouseEvent&);
200 void mouseLeave(const WebMouseEvent&);
201 void mouseDown(const WebMouseEvent&);
202 void mouseUp(const WebMouseEvent&);
203 void mouseContextMenu(const WebMouseEvent&);
204 void mouseDoubleClick(const WebMouseEvent&);
205 void mouseWheel(const WebMouseWheelEvent&);
206 bool keyEvent(const WebKeyboardEvent&);
207 bool charEvent(const WebKeyboardEvent&);
208
209 // Handles context menu events orignated via the the keyboard. These
210 // include the VK_APPS virtual key and the Shift+F10 combine. Code is
211 // based on the Webkit function bool WebView::handleContextMenuEvent(WPARAM
212 // wParam, LPARAM lParam) in webkit\webkit\win\WebView.cpp. The only
213 // significant change in this function is the code to convert from a
214 // Keyboard event to the Right Mouse button down event.
215 bool sendContextMenuEvent(const WebKeyboardEvent&);
216
217 // Notifies the WebView that a load has been committed. isNewNavigation
218 // will be true if a new session history item should be created for that
219 // load.
220 void didCommitLoad(bool* isNewNavigation);
221
222 bool contextMenuAllowed() const
223 {
224 return m_contextMenuAllowed;
225 }
226
227 // Set the disposition for how this webview is to be initially shown.
228 void setInitialNavigationPolicy(WebNavigationPolicy policy)
229 {
230 m_initialNavigationPolicy = policy;
231 }
232 WebNavigationPolicy initialNavigationPolicy() const
233 {
234 return m_initialNavigationPolicy;
235 }
236
237 // Determines whether a page should e.g. be opened in a background tab.
238 // Returns false if it has no opinion, in which case it doesn't set *policy.
239 static bool navigationPolicyFromMouseEvent(
240 unsigned short button,
241 bool ctrl,
242 bool shift,
243 bool alt,
244 bool meta,
245 WebNavigationPolicy*);
246
247 // Start a system drag and drop operation.
248 void startDragging(
249 const WebPoint& eventPos,
250 const WebDragData& dragData,
251 WebDragOperationsMask dragSourceOperationMask);
252
253 // Hides the autocomplete popup if it is showing.
254 void hideAutoCompletePopup();
255 void autoCompletePopupDidHide();
256
257 #if ENABLE(NOTIFICATIONS)
258 // Returns the provider of desktop notifications.
259 NotificationPresenterImpl* notificationPresenterImpl();
260 #endif
261
262 // Tries to scroll a frame or any parent of a frame. Returns true if the view
263 // was scrolled.
264 bool propagateScroll(WebCore::ScrollDirection, WebCore::ScrollGranularity);
265
266 // HACK: currentInputEvent() is for ChromeClientImpl::show(), until we can
267 // fix WebKit to pass enough information up into ChromeClient::show() so we
268 // can decide if the window.open event was caused by a middle-mouse click
269 static const WebInputEvent* currentInputEvent()
270 {
271 return m_currentInputEvent;
272 }
273
274 private:
275 friend class WebView; // So WebView::Create can call our constructor
276 friend class WTF::RefCounted<WebViewImpl>;
277
278 WebViewImpl(WebViewClient* client);
279 ~WebViewImpl();
280
281 // Returns true if the event was actually processed.
282 bool keyEventDefault(const WebKeyboardEvent&);
283
284 // Returns true if the autocomple has consumed the event.
285 bool autocompleteHandleKeyEvent(const WebKeyboardEvent&);
286
287 // Repaints the autofill popup. Should be called when the suggestions have
288 // changed. Note that this should only be called when the autofill popup is
289 // showing.
290 void refreshAutofillPopup();
291
292 // Returns true if the view was scrolled.
293 bool scrollViewWithKeyboard(int keyCode, int modifiers);
294
295 // Converts |pos| from window coordinates to contents coordinates and gets
296 // the HitTestResult for it.
297 WebCore::HitTestResult hitTestResultForWindowPos(const WebCore::IntPoint&);
298
299 WebViewClient* m_client;
300
301 BackForwardListClientImpl m_backForwardListClientImpl;
302 ChromeClientImpl m_chromeClientImpl;
303 ContextMenuClientImpl m_contextMenuClientImpl;
304 DragClientImpl m_dragClientImpl;
305 EditorClientImpl m_editorClientImpl;
306 InspectorClientImpl m_inspectorClientImpl;
307
308 WebSize m_size;
309
310 WebPoint m_lastMousePosition;
311 OwnPtr<WebCore::Page> m_page;
312
313 // This flag is set when a new navigation is detected. It is used to satisfy
314 // the corresponding argument to WebFrameClient::didCommitProvisionalLoad.
315 bool m_observedNewNavigation;
316 #ifndef NDEBUG
317 // Used to assert that the new navigation we observed is the same navigation
318 // when we make use of m_observedNewNavigation.
319 const WebCore::DocumentLoader* m_newNavigationLoader;
320 #endif
321
322 // An object that can be used to manipulate m_page->settings() without linking
323 // against WebCore. This is lazily allocated the first time GetWebSettings()
324 // is called.
325 OwnPtr<WebSettingsImpl> m_webSettings;
326
327 // A copy of the web drop data object we received from the browser.
328 RefPtr<WebCore::ChromiumDataObject> m_currentDragData;
329
330 // The point relative to the client area where the mouse was last pressed
331 // down. This is used by the drag client to determine what was under the
332 // mouse when the drag was initiated. We need to track this here in
333 // WebViewImpl since DragClient::startDrag does not pass the position the
334 // mouse was at when the drag was initiated, only the current point, which
335 // can be misleading as it is usually not over the element the user actually
336 // dragged by the time a drag is initiated.
337 WebPoint m_lastMouseDownPoint;
338
339 // Keeps track of the current text zoom level. 0 means no zoom, positive
340 // values mean larger text, negative numbers mean smaller.
341 int m_zoomLevel;
342
343 bool m_contextMenuAllowed;
344
345 bool m_doingDragAndDrop;
346
347 bool m_ignoreInputEvents;
348
349 // Webkit expects keyPress events to be suppressed if the associated keyDown
350 // event was handled. Safari implements this behavior by peeking out the
351 // associated WM_CHAR event if the keydown was handled. We emulate
352 // this behavior by setting this flag if the keyDown was handled.
353 bool m_suppressNextKeypressEvent;
354
355 // The policy for how this webview is to be initially shown.
356 WebNavigationPolicy m_initialNavigationPolicy;
357
358 // Represents whether or not this object should process incoming IME events.
359 bool m_imeAcceptEvents;
360
361 // True while dispatching system drag and drop events to drag/drop targets
362 // within this WebView.
363 bool m_dragTargetDispatch;
364
365 // Valid when m_dragTargetDispatch is true; the identity of the drag data
366 // copied from the WebDropData object sent from the browser process.
367 int m_dragIdentity;
368
369 // Valid when m_dragTargetDispatch is true. Used to override the default
370 // browser drop effect with the effects "none" or "copy".
371 enum DragTargetDropEffect {
372 DropEffectDefault = -1,
373 DropEffectNone,
374 DropEffectCopy
375 } m_dropEffect;
376
377 // The available drag operations (copy, move link...) allowed by the source.
378 WebDragOperation m_operationsAllowed;
379
380 // The current drag operation as negotiated by the source and destination.
381 // When not equal to DragOperationNone, the drag data can be dropped onto the
382 // current drop target in this WebView (the drop target can accept the drop).
383 WebDragOperation m_dragOperation;
384
385 // The autocomplete popup. Kept around and reused every-time new suggestions
386 // should be shown.
387 RefPtr<WebCore::PopupContainer> m_autocompletePopup;
388
389 // Whether the autocomplete popup is currently showing.
390 bool m_autocompletePopupShowing;
391
392 // The autocomplete client.
393 OwnPtr<AutocompletePopupMenuClient> m_autocompletePopupClient;
394
395 OwnPtr<WebDevToolsAgentPrivate> m_devToolsAgent;
396
397 // Whether the webview is rendering transparently.
398 bool m_isTransparent;
399
400 // Whether the user can press tab to focus links.
401 bool m_tabsToLinks;
402
403 // Inspector settings.
404 WebString m_inspectorSettings;
405
406 #if ENABLE(NOTIFICATIONS)
407 // The provider of desktop notifications;
408 NotificationPresenterImpl m_notificationPresenter;
409 #endif
410
411 static const WebInputEvent* m_currentInputEvent;
412 };
413
414 } // namespace WebKit
415
416 #endif
OLDNEW
« no previous file with comments | « webkit/api/src/WebURLResponsePrivate.h ('k') | webkit/api/src/WebViewImpl.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698