|
1 /* |
|
2 * Copyright (C) 2007, 2008 Holger Hans Peter Freyther |
|
3 * Copyright (C) 2007, 2008, 2009 Christian Dywan <christian@imendio.com> |
|
4 * Copyright (C) 2007 Xan Lopez <xan@gnome.org> |
|
5 * Copyright (C) 2007, 2008 Alp Toker <alp@atoker.com> |
|
6 * Copyright (C) 2008 Jan Alonzo <jmalonzo@unpluggable.com> |
|
7 * Copyright (C) 2008 Gustavo Noronha Silva <gns@gnome.org> |
|
8 * Copyright (C) 2008 Nuanti Ltd. |
|
9 * Copyright (C) 2008, 2009, 2010 Collabora Ltd. |
|
10 * Copyright (C) 2009, 2010 Igalia S.L. |
|
11 * Copyright (C) 2009 Movial Creative Technologies Inc. |
|
12 * Copyright (C) 2009 Bobby Powers |
|
13 * |
|
14 * This library is free software; you can redistribute it and/or |
|
15 * modify it under the terms of the GNU Lesser General Public |
|
16 * License as published by the Free Software Foundation; either |
|
17 * version 2 of the License, or (at your option) any later version. |
|
18 * |
|
19 * This library is distributed in the hope that it will be useful, |
|
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
22 * Lesser General Public License for more details. |
|
23 * |
|
24 * You should have received a copy of the GNU Lesser General Public |
|
25 * License along with this library; if not, write to the Free Software |
|
26 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
|
27 */ |
|
28 |
|
29 #include "config.h" |
|
30 #include "webkitwebview.h" |
|
31 |
|
32 #include "webkitdownload.h" |
|
33 #include "webkitenumtypes.h" |
|
34 #include "webkitgeolocationpolicydecision.h" |
|
35 #include "webkitmarshal.h" |
|
36 #include "webkitnetworkrequest.h" |
|
37 #include "webkitnetworkresponse.h" |
|
38 #include "webkitprivate.h" |
|
39 #include "webkitwebinspector.h" |
|
40 #include "webkitwebbackforwardlist.h" |
|
41 #include "webkitwebhistoryitem.h" |
|
42 |
|
43 #include "AXObjectCache.h" |
|
44 #include "AbstractDatabase.h" |
|
45 #include "BackForwardList.h" |
|
46 #include "Cache.h" |
|
47 #include "ChromeClientGtk.h" |
|
48 #include "ClipboardUtilitiesGtk.h" |
|
49 #include "ContextMenuClientGtk.h" |
|
50 #include "ContextMenuController.h" |
|
51 #include "ContextMenu.h" |
|
52 #include "Cursor.h" |
|
53 #include "Document.h" |
|
54 #include "DocumentLoader.h" |
|
55 #include "DragActions.h" |
|
56 #include "DragClientGtk.h" |
|
57 #include "DragController.h" |
|
58 #include "DragData.h" |
|
59 #include "EditorClientGtk.h" |
|
60 #include "Editor.h" |
|
61 #include "EventHandler.h" |
|
62 #include "FloatQuad.h" |
|
63 #include "FocusController.h" |
|
64 #include "FrameLoader.h" |
|
65 #include "FrameLoaderTypes.h" |
|
66 #include "FrameView.h" |
|
67 #include <glib/gi18n-lib.h> |
|
68 #include <GOwnPtr.h> |
|
69 #include <GOwnPtrGtk.h> |
|
70 #include "GraphicsContext.h" |
|
71 #include "GtkVersioning.h" |
|
72 #include "HitTestRequest.h" |
|
73 #include "HitTestResult.h" |
|
74 #include "IconDatabase.h" |
|
75 #include "InspectorClientGtk.h" |
|
76 #include "MouseEventWithHitTestResults.h" |
|
77 #include "NotImplemented.h" |
|
78 #include "PageCache.h" |
|
79 #include "Pasteboard.h" |
|
80 #include "PasteboardHelperGtk.h" |
|
81 #include "PasteboardHelper.h" |
|
82 #include "PlatformKeyboardEvent.h" |
|
83 #include "PlatformWheelEvent.h" |
|
84 #include "ProgressTracker.h" |
|
85 #include "RenderView.h" |
|
86 #include "ResourceHandle.h" |
|
87 #include "ScriptValue.h" |
|
88 #include "Scrollbar.h" |
|
89 #include "webkit/WebKitDOMDocumentPrivate.h" |
|
90 #include <wtf/text/CString.h> |
|
91 |
|
92 #include <gdk/gdkkeysyms.h> |
|
93 |
|
94 /** |
|
95 * SECTION:webkitwebview |
|
96 * @short_description: The central class of the WebKitGTK+ API |
|
97 * @see_also: #WebKitWebSettings, #WebKitWebFrame |
|
98 * |
|
99 * #WebKitWebView is the central class of the WebKitGTK+ API. It is a |
|
100 * #GtkWidget implementing the scrolling interface which means you can |
|
101 * embed in a #GtkScrolledWindow. It is responsible for managing the |
|
102 * drawing of the content, forwarding of events. You can load any URI |
|
103 * into the #WebKitWebView or any kind of data string. With #WebKitWebSettings |
|
104 * you can control various aspects of the rendering and loading of the content. |
|
105 * Each #WebKitWebView has exactly one #WebKitWebFrame as main frame. A |
|
106 * #WebKitWebFrame can have n children. |
|
107 * |
|
108 * <programlisting> |
|
109 * /<!-- -->* Create the widgets *<!-- -->/ |
|
110 * GtkWidget *main_window = gtk_window_new (GTK_WIDGET_TOPLEVEL); |
|
111 * GtkWidget *scrolled_window = gtk_scrolled_window_new (NULL, NULL); |
|
112 * GtkWidget *web_view = webkit_web_view_new (); |
|
113 * |
|
114 * /<!-- -->* Place the WebKitWebView in the GtkScrolledWindow *<!-- -->/ |
|
115 * gtk_container_add (GTK_CONTAINER (scrolled_window), web_view); |
|
116 * gtk_container_add (GTK_CONTAINER (main_window), scrolled_window); |
|
117 * |
|
118 * /<!-- -->* Open a webpage *<!-- -->/ |
|
119 * webkit_web_view_load_uri (WEBKIT_WEB_VIEW (web_view), "http://www.gnome.org"); |
|
120 * |
|
121 * /<!-- -->* Show the result *<!-- -->/ |
|
122 * gtk_window_set_default_size (GTK_WINDOW (main_window), 800, 600); |
|
123 * gtk_widget_show_all (main_window); |
|
124 * </programlisting> |
|
125 */ |
|
126 |
|
127 static const double defaultDPI = 96.0; |
|
128 static WebKitCacheModel cacheModel; |
|
129 static IntPoint globalPointForClientPoint(GdkWindow* window, const IntPoint& clientPoint); |
|
130 |
|
131 using namespace WebKit; |
|
132 using namespace WebCore; |
|
133 |
|
134 enum { |
|
135 /* normal signals */ |
|
136 NAVIGATION_REQUESTED, |
|
137 NEW_WINDOW_POLICY_DECISION_REQUESTED, |
|
138 NAVIGATION_POLICY_DECISION_REQUESTED, |
|
139 MIME_TYPE_POLICY_DECISION_REQUESTED, |
|
140 CREATE_WEB_VIEW, |
|
141 WEB_VIEW_READY, |
|
142 WINDOW_OBJECT_CLEARED, |
|
143 LOAD_STARTED, |
|
144 LOAD_COMMITTED, |
|
145 LOAD_PROGRESS_CHANGED, |
|
146 LOAD_ERROR, |
|
147 LOAD_FINISHED, |
|
148 TITLE_CHANGED, |
|
149 HOVERING_OVER_LINK, |
|
150 POPULATE_POPUP, |
|
151 STATUS_BAR_TEXT_CHANGED, |
|
152 ICON_LOADED, |
|
153 SELECTION_CHANGED, |
|
154 CONSOLE_MESSAGE, |
|
155 SCRIPT_ALERT, |
|
156 SCRIPT_CONFIRM, |
|
157 SCRIPT_PROMPT, |
|
158 SELECT_ALL, |
|
159 COPY_CLIPBOARD, |
|
160 PASTE_CLIPBOARD, |
|
161 CUT_CLIPBOARD, |
|
162 DOWNLOAD_REQUESTED, |
|
163 MOVE_CURSOR, |
|
164 PRINT_REQUESTED, |
|
165 PLUGIN_WIDGET, |
|
166 CLOSE_WEB_VIEW, |
|
167 UNDO, |
|
168 REDO, |
|
169 DATABASE_QUOTA_EXCEEDED, |
|
170 RESOURCE_REQUEST_STARTING, |
|
171 DOCUMENT_LOAD_FINISHED, |
|
172 GEOLOCATION_POLICY_DECISION_REQUESTED, |
|
173 GEOLOCATION_POLICY_DECISION_CANCELLED, |
|
174 ONLOAD_EVENT, |
|
175 LAST_SIGNAL |
|
176 }; |
|
177 |
|
178 enum { |
|
179 PROP_0, |
|
180 |
|
181 PROP_TITLE, |
|
182 PROP_URI, |
|
183 PROP_COPY_TARGET_LIST, |
|
184 PROP_PASTE_TARGET_LIST, |
|
185 PROP_EDITABLE, |
|
186 PROP_SETTINGS, |
|
187 PROP_WEB_INSPECTOR, |
|
188 PROP_WINDOW_FEATURES, |
|
189 PROP_TRANSPARENT, |
|
190 PROP_ZOOM_LEVEL, |
|
191 PROP_FULL_CONTENT_ZOOM, |
|
192 PROP_LOAD_STATUS, |
|
193 PROP_PROGRESS, |
|
194 PROP_ENCODING, |
|
195 PROP_CUSTOM_ENCODING, |
|
196 PROP_ICON_URI, |
|
197 PROP_IM_CONTEXT |
|
198 }; |
|
199 |
|
200 static guint webkit_web_view_signals[LAST_SIGNAL] = { 0, }; |
|
201 |
|
202 G_DEFINE_TYPE(WebKitWebView, webkit_web_view, GTK_TYPE_CONTAINER) |
|
203 |
|
204 static void webkit_web_view_settings_notify(WebKitWebSettings* webSettings, GParamSpec* pspec, WebKitWebView* webView); |
|
205 static void webkit_web_view_set_window_features(WebKitWebView* webView, WebKitWebWindowFeatures* webWindowFeatures); |
|
206 |
|
207 static GtkIMContext* webkit_web_view_get_im_context(WebKitWebView*); |
|
208 |
|
209 static void destroy_menu_cb(GtkObject* object, gpointer data) |
|
210 { |
|
211 WebKitWebView* webView = WEBKIT_WEB_VIEW(data); |
|
212 WebKitWebViewPrivate* priv = WEBKIT_WEB_VIEW_GET_PRIVATE(webView); |
|
213 |
|
214 g_object_unref(priv->currentMenu); |
|
215 priv->currentMenu = NULL; |
|
216 } |
|
217 |
|
218 static void PopupMenuPositionFunc(GtkMenu* menu, gint *x, gint *y, gboolean *pushIn, gpointer userData) |
|
219 { |
|
220 WebKitWebView* view = WEBKIT_WEB_VIEW(userData); |
|
221 WebKitWebViewPrivate* priv = WEBKIT_WEB_VIEW_GET_PRIVATE(view); |
|
222 GdkScreen* screen = gtk_widget_get_screen(GTK_WIDGET(view)); |
|
223 GtkRequisition menuSize; |
|
224 |
|
225 gtk_widget_size_request(GTK_WIDGET(menu), &menuSize); |
|
226 |
|
227 *x = priv->lastPopupXPosition; |
|
228 if ((*x + menuSize.width) >= gdk_screen_get_width(screen)) |
|
229 *x -= menuSize.width; |
|
230 |
|
231 *y = priv->lastPopupYPosition; |
|
232 if ((*y + menuSize.height) >= gdk_screen_get_height(screen)) |
|
233 *y -= menuSize.height; |
|
234 |
|
235 *pushIn = FALSE; |
|
236 } |
|
237 |
|
238 static gboolean webkit_web_view_forward_context_menu_event(WebKitWebView* webView, const PlatformMouseEvent& event) |
|
239 { |
|
240 Page* page = core(webView); |
|
241 page->contextMenuController()->clearContextMenu(); |
|
242 Frame* focusedFrame; |
|
243 Frame* mainFrame = page->mainFrame(); |
|
244 gboolean mousePressEventResult = FALSE; |
|
245 |
|
246 if (!mainFrame->view()) |
|
247 return FALSE; |
|
248 |
|
249 mainFrame->view()->setCursor(pointerCursor()); |
|
250 if (page->frameCount()) { |
|
251 HitTestRequest request(HitTestRequest::Active); |
|
252 IntPoint point = mainFrame->view()->windowToContents(event.pos()); |
|
253 MouseEventWithHitTestResults mev = mainFrame->document()->prepareMouseEvent(request, point, event); |
|
254 |
|
255 Frame* targetFrame = EventHandler::subframeForTargetNode(mev.targetNode()); |
|
256 if (!targetFrame) |
|
257 targetFrame = mainFrame; |
|
258 |
|
259 focusedFrame = page->focusController()->focusedOrMainFrame(); |
|
260 if (targetFrame != focusedFrame) { |
|
261 page->focusController()->setFocusedFrame(targetFrame); |
|
262 focusedFrame = targetFrame; |
|
263 } |
|
264 } else |
|
265 focusedFrame = mainFrame; |
|
266 |
|
267 if (focusedFrame->view() && focusedFrame->eventHandler()->handleMousePressEvent(event)) |
|
268 mousePressEventResult = TRUE; |
|
269 |
|
270 |
|
271 bool handledEvent = focusedFrame->eventHandler()->sendContextMenuEvent(event); |
|
272 if (!handledEvent) |
|
273 return FALSE; |
|
274 |
|
275 // If coreMenu is NULL, this means WebCore decided to not create |
|
276 // the default context menu; this may happen when the page is |
|
277 // handling the right-click for reasons other than the context menu. |
|
278 ContextMenu* coreMenu = page->contextMenuController()->contextMenu(); |
|
279 if (!coreMenu) |
|
280 return mousePressEventResult; |
|
281 |
|
282 // If we reach here, it's because WebCore is going to show the |
|
283 // default context menu. We check our setting to figure out |
|
284 // whether we want it or not. |
|
285 WebKitWebSettings* settings = webkit_web_view_get_settings(webView); |
|
286 gboolean enableDefaultContextMenu; |
|
287 g_object_get(settings, "enable-default-context-menu", &enableDefaultContextMenu, NULL); |
|
288 |
|
289 if (!enableDefaultContextMenu) |
|
290 return FALSE; |
|
291 |
|
292 GtkMenu* menu = GTK_MENU(coreMenu->platformDescription()); |
|
293 if (!menu) |
|
294 return FALSE; |
|
295 |
|
296 g_signal_emit(webView, webkit_web_view_signals[POPULATE_POPUP], 0, menu); |
|
297 |
|
298 GList* items = gtk_container_get_children(GTK_CONTAINER(menu)); |
|
299 bool empty = !g_list_nth(items, 0); |
|
300 g_list_free(items); |
|
301 if (empty) |
|
302 return FALSE; |
|
303 |
|
304 WebKitWebViewPrivate* priv = WEBKIT_WEB_VIEW_GET_PRIVATE(webView); |
|
305 priv->currentMenu = GTK_MENU(g_object_ref(menu)); |
|
306 priv->lastPopupXPosition = event.globalX(); |
|
307 priv->lastPopupYPosition = event.globalY(); |
|
308 |
|
309 g_signal_connect(menu, "destroy", |
|
310 G_CALLBACK(destroy_menu_cb), |
|
311 NULL); |
|
312 |
|
313 gtk_menu_popup(menu, NULL, NULL, |
|
314 &PopupMenuPositionFunc, |
|
315 webView, event.button() + 1, gtk_get_current_event_time()); |
|
316 return TRUE; |
|
317 } |
|
318 |
|
319 static gboolean webkit_web_view_popup_menu_handler(GtkWidget* widget) |
|
320 { |
|
321 static const int contextMenuMargin = 1; |
|
322 |
|
323 // The context menu event was generated from the keyboard, so show the context menu by the current selection. |
|
324 Page* page = core(WEBKIT_WEB_VIEW(widget)); |
|
325 Frame* frame = page->focusController()->focusedOrMainFrame(); |
|
326 FrameView* view = frame->view(); |
|
327 if (!view) |
|
328 return FALSE; |
|
329 |
|
330 Position start = frame->selection()->selection().start(); |
|
331 Position end = frame->selection()->selection().end(); |
|
332 |
|
333 int rightAligned = FALSE; |
|
334 IntPoint location; |
|
335 |
|
336 if (!start.node() || !end.node() |
|
337 || (frame->selection()->selection().isCaret() && !frame->selection()->selection().isContentEditable())) |
|
338 location = IntPoint(rightAligned ? view->contentsWidth() - contextMenuMargin : contextMenuMargin, contextMenuMargin); |
|
339 else { |
|
340 RenderObject* renderer = start.node()->renderer(); |
|
341 if (!renderer) |
|
342 return FALSE; |
|
343 |
|
344 // Calculate the rect of the first line of the selection (cribbed from -[WebCoreFrameBridge firstRectForDOMRange:], |
|
345 // now Frame::firstRectForRange(), which perhaps this should call). |
|
346 int extraWidthToEndOfLine = 0; |
|
347 |
|
348 InlineBox* startInlineBox; |
|
349 int startCaretOffset; |
|
350 start.getInlineBoxAndOffset(DOWNSTREAM, startInlineBox, startCaretOffset); |
|
351 IntRect startCaretRect = renderer->localCaretRect(startInlineBox, startCaretOffset, &extraWidthToEndOfLine); |
|
352 if (startCaretRect != IntRect()) |
|
353 startCaretRect = renderer->localToAbsoluteQuad(FloatRect(startCaretRect)).enclosingBoundingBox(); |
|
354 |
|
355 InlineBox* endInlineBox; |
|
356 int endCaretOffset; |
|
357 end.getInlineBoxAndOffset(UPSTREAM, endInlineBox, endCaretOffset); |
|
358 IntRect endCaretRect = renderer->localCaretRect(endInlineBox, endCaretOffset); |
|
359 if (endCaretRect != IntRect()) |
|
360 endCaretRect = renderer->localToAbsoluteQuad(FloatRect(endCaretRect)).enclosingBoundingBox(); |
|
361 |
|
362 IntRect firstRect; |
|
363 if (startCaretRect.y() == endCaretRect.y()) |
|
364 firstRect = IntRect(MIN(startCaretRect.x(), endCaretRect.x()), |
|
365 startCaretRect.y(), |
|
366 abs(endCaretRect.x() - startCaretRect.x()), |
|
367 MAX(startCaretRect.height(), endCaretRect.height())); |
|
368 else |
|
369 firstRect = IntRect(startCaretRect.x(), |
|
370 startCaretRect.y(), |
|
371 startCaretRect.width() + extraWidthToEndOfLine, |
|
372 startCaretRect.height()); |
|
373 |
|
374 location = IntPoint(rightAligned ? firstRect.right() : firstRect.x(), firstRect.bottom()); |
|
375 } |
|
376 |
|
377 // FIXME: The IntSize(0, -1) is a hack to get the hit-testing to result in the selected element. |
|
378 // Ideally we'd have the position of a context menu event be separate from its target node. |
|
379 location = view->contentsToWindow(location) + IntSize(0, -1); |
|
380 if (location.y() < 0) |
|
381 location.setY(contextMenuMargin); |
|
382 else if (location.y() > view->height()) |
|
383 location.setY(view->height() - contextMenuMargin); |
|
384 if (location.x() < 0) |
|
385 location.setX(contextMenuMargin); |
|
386 else if (location.x() > view->width()) |
|
387 location.setX(view->width() - contextMenuMargin); |
|
388 IntPoint global(globalPointForClientPoint(gtk_widget_get_window(widget), location)); |
|
389 |
|
390 PlatformMouseEvent event(location, global, RightButton, MouseEventPressed, 0, false, false, false, false, gtk_get_current_event_time()); |
|
391 |
|
392 return webkit_web_view_forward_context_menu_event(WEBKIT_WEB_VIEW(widget), event); |
|
393 } |
|
394 |
|
395 static void webkit_web_view_get_property(GObject* object, guint prop_id, GValue* value, GParamSpec* pspec) |
|
396 { |
|
397 WebKitWebView* webView = WEBKIT_WEB_VIEW(object); |
|
398 |
|
399 switch(prop_id) { |
|
400 case PROP_TITLE: |
|
401 g_value_set_string(value, webkit_web_view_get_title(webView)); |
|
402 break; |
|
403 case PROP_URI: |
|
404 g_value_set_string(value, webkit_web_view_get_uri(webView)); |
|
405 break; |
|
406 case PROP_COPY_TARGET_LIST: |
|
407 g_value_set_boxed(value, webkit_web_view_get_copy_target_list(webView)); |
|
408 break; |
|
409 case PROP_PASTE_TARGET_LIST: |
|
410 g_value_set_boxed(value, webkit_web_view_get_paste_target_list(webView)); |
|
411 break; |
|
412 case PROP_EDITABLE: |
|
413 g_value_set_boolean(value, webkit_web_view_get_editable(webView)); |
|
414 break; |
|
415 case PROP_SETTINGS: |
|
416 g_value_set_object(value, webkit_web_view_get_settings(webView)); |
|
417 break; |
|
418 case PROP_WEB_INSPECTOR: |
|
419 g_value_set_object(value, webkit_web_view_get_inspector(webView)); |
|
420 break; |
|
421 case PROP_WINDOW_FEATURES: |
|
422 g_value_set_object(value, webkit_web_view_get_window_features(webView)); |
|
423 break; |
|
424 case PROP_TRANSPARENT: |
|
425 g_value_set_boolean(value, webkit_web_view_get_transparent(webView)); |
|
426 break; |
|
427 case PROP_ZOOM_LEVEL: |
|
428 g_value_set_float(value, webkit_web_view_get_zoom_level(webView)); |
|
429 break; |
|
430 case PROP_FULL_CONTENT_ZOOM: |
|
431 g_value_set_boolean(value, webkit_web_view_get_full_content_zoom(webView)); |
|
432 break; |
|
433 case PROP_ENCODING: |
|
434 g_value_set_string(value, webkit_web_view_get_encoding(webView)); |
|
435 break; |
|
436 case PROP_CUSTOM_ENCODING: |
|
437 g_value_set_string(value, webkit_web_view_get_custom_encoding(webView)); |
|
438 break; |
|
439 case PROP_LOAD_STATUS: |
|
440 g_value_set_enum(value, webkit_web_view_get_load_status(webView)); |
|
441 break; |
|
442 case PROP_PROGRESS: |
|
443 g_value_set_double(value, webkit_web_view_get_progress(webView)); |
|
444 break; |
|
445 case PROP_ICON_URI: |
|
446 g_value_set_string(value, webkit_web_view_get_icon_uri(webView)); |
|
447 break; |
|
448 case PROP_IM_CONTEXT: |
|
449 g_value_set_object(value, webkit_web_view_get_im_context(webView)); |
|
450 break; |
|
451 default: |
|
452 G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); |
|
453 } |
|
454 } |
|
455 |
|
456 static void webkit_web_view_set_property(GObject* object, guint prop_id, const GValue* value, GParamSpec *pspec) |
|
457 { |
|
458 WebKitWebView* webView = WEBKIT_WEB_VIEW(object); |
|
459 |
|
460 switch(prop_id) { |
|
461 case PROP_EDITABLE: |
|
462 webkit_web_view_set_editable(webView, g_value_get_boolean(value)); |
|
463 break; |
|
464 case PROP_SETTINGS: |
|
465 webkit_web_view_set_settings(webView, WEBKIT_WEB_SETTINGS(g_value_get_object(value))); |
|
466 break; |
|
467 case PROP_WINDOW_FEATURES: |
|
468 webkit_web_view_set_window_features(webView, WEBKIT_WEB_WINDOW_FEATURES(g_value_get_object(value))); |
|
469 break; |
|
470 case PROP_TRANSPARENT: |
|
471 webkit_web_view_set_transparent(webView, g_value_get_boolean(value)); |
|
472 break; |
|
473 case PROP_ZOOM_LEVEL: |
|
474 webkit_web_view_set_zoom_level(webView, g_value_get_float(value)); |
|
475 break; |
|
476 case PROP_FULL_CONTENT_ZOOM: |
|
477 webkit_web_view_set_full_content_zoom(webView, g_value_get_boolean(value)); |
|
478 break; |
|
479 case PROP_CUSTOM_ENCODING: |
|
480 webkit_web_view_set_custom_encoding(webView, g_value_get_string(value)); |
|
481 break; |
|
482 default: |
|
483 G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); |
|
484 } |
|
485 } |
|
486 |
|
487 static bool shouldCoalesce(GdkRectangle rect, GdkRectangle* rects, int count) |
|
488 { |
|
489 const int cRectThreshold = 10; |
|
490 const float cWastedSpaceThreshold = 0.75f; |
|
491 bool useUnionedRect = (count <= 1) || (count > cRectThreshold); |
|
492 if (!useUnionedRect) { |
|
493 // Attempt to guess whether or not we should use the unioned rect or the individual rects. |
|
494 // We do this by computing the percentage of "wasted space" in the union. If that wasted space |
|
495 // is too large, then we will do individual rect painting instead. |
|
496 float unionPixels = (rect.width * rect.height); |
|
497 float singlePixels = 0; |
|
498 for (int i = 0; i < count; ++i) |
|
499 singlePixels += rects[i].width * rects[i].height; |
|
500 float wastedSpace = 1 - (singlePixels / unionPixels); |
|
501 if (wastedSpace <= cWastedSpaceThreshold) |
|
502 useUnionedRect = true; |
|
503 } |
|
504 return useUnionedRect; |
|
505 } |
|
506 |
|
507 static gboolean webkit_web_view_expose_event(GtkWidget* widget, GdkEventExpose* event) |
|
508 { |
|
509 WebKitWebView* webView = WEBKIT_WEB_VIEW(widget); |
|
510 WebKitWebViewPrivate* priv = webView->priv; |
|
511 |
|
512 Frame* frame = core(webView)->mainFrame(); |
|
513 if (frame->contentRenderer() && frame->view()) { |
|
514 frame->view()->layoutIfNeededRecursive(); |
|
515 |
|
516 cairo_t* cr = gdk_cairo_create(event->window); |
|
517 GraphicsContext ctx(cr); |
|
518 cairo_destroy(cr); |
|
519 ctx.setGdkExposeEvent(event); |
|
520 |
|
521 int rectCount; |
|
522 #ifdef GTK_API_VERSION_2 |
|
523 GOwnPtr<GdkRectangle> rects; |
|
524 gdk_region_get_rectangles(event->region, &rects.outPtr(), &rectCount); |
|
525 #else |
|
526 rectCount = cairo_region_num_rectangles(event->region); |
|
527 GOwnPtr<GdkRectangle> rects(g_new(GdkRectangle, rectCount)); |
|
528 for (int i = 0; i < rectCount; i++) |
|
529 cairo_region_get_rectangle(event->region, i, rects.get()+i); |
|
530 #endif |
|
531 // Avoid recursing into the render tree excessively |
|
532 bool coalesce = shouldCoalesce(event->area, rects.get(), rectCount); |
|
533 |
|
534 if (coalesce) { |
|
535 IntRect rect = event->area; |
|
536 ctx.clip(rect); |
|
537 if (priv->transparent) |
|
538 ctx.clearRect(rect); |
|
539 frame->view()->paint(&ctx, rect); |
|
540 } else { |
|
541 for (int i = 0; i < rectCount; i++) { |
|
542 IntRect rect = rects.get()[i]; |
|
543 ctx.save(); |
|
544 ctx.clip(rect); |
|
545 if (priv->transparent) |
|
546 ctx.clearRect(rect); |
|
547 frame->view()->paint(&ctx, rect); |
|
548 ctx.restore(); |
|
549 } |
|
550 } |
|
551 } |
|
552 |
|
553 return FALSE; |
|
554 } |
|
555 |
|
556 static gboolean webkit_web_view_key_press_event(GtkWidget* widget, GdkEventKey* event) |
|
557 { |
|
558 WebKitWebView* webView = WEBKIT_WEB_VIEW(widget); |
|
559 |
|
560 Frame* frame = core(webView)->focusController()->focusedOrMainFrame(); |
|
561 PlatformKeyboardEvent keyboardEvent(event); |
|
562 |
|
563 if (!frame->view()) |
|
564 return FALSE; |
|
565 |
|
566 if (frame->eventHandler()->keyEvent(keyboardEvent)) |
|
567 return TRUE; |
|
568 |
|
569 /* Chain up to our parent class for binding activation */ |
|
570 return GTK_WIDGET_CLASS(webkit_web_view_parent_class)->key_press_event(widget, event); |
|
571 } |
|
572 |
|
573 static gboolean webkit_web_view_key_release_event(GtkWidget* widget, GdkEventKey* event) |
|
574 { |
|
575 WebKitWebView* webView = WEBKIT_WEB_VIEW(widget); |
|
576 |
|
577 // GTK+ IM contexts often require us to filter key release events, which |
|
578 // WebCore does not do by default, so we filter the event here. We only block |
|
579 // the event if we don't have a pending composition, because that means we |
|
580 // are using a context like 'simple' which marks every keystroke as filtered. |
|
581 WebKit::EditorClient* client = static_cast<WebKit::EditorClient*>(core(webView)->editorClient()); |
|
582 if (gtk_im_context_filter_keypress(webView->priv->imContext, event) && !client->hasPendingComposition()) |
|
583 return TRUE; |
|
584 |
|
585 Frame* frame = core(webView)->focusController()->focusedOrMainFrame(); |
|
586 if (!frame->view()) |
|
587 return FALSE; |
|
588 |
|
589 PlatformKeyboardEvent keyboardEvent(event); |
|
590 if (frame->eventHandler()->keyEvent(keyboardEvent)) |
|
591 return TRUE; |
|
592 |
|
593 /* Chain up to our parent class for binding activation */ |
|
594 return GTK_WIDGET_CLASS(webkit_web_view_parent_class)->key_release_event(widget, event); |
|
595 } |
|
596 |
|
597 static guint32 getEventTime(GdkEvent* event) |
|
598 { |
|
599 guint32 time = gdk_event_get_time(event); |
|
600 if (time) |
|
601 return time; |
|
602 |
|
603 // Real events always have a non-zero time, but events synthesized |
|
604 // by the DRT do not and we must calculate a time manually. This time |
|
605 // is not calculated in the DRT, because GTK+ does not work well with |
|
606 // anything other than GDK_CURRENT_TIME on synthesized events. |
|
607 GTimeVal timeValue; |
|
608 g_get_current_time(&timeValue); |
|
609 return (timeValue.tv_sec * 1000) + (timeValue.tv_usec / 1000); |
|
610 } |
|
611 |
|
612 static gboolean webkit_web_view_button_press_event(GtkWidget* widget, GdkEventButton* event) |
|
613 { |
|
614 WebKitWebView* webView = WEBKIT_WEB_VIEW(widget); |
|
615 WebKitWebViewPrivate* priv = webView->priv; |
|
616 |
|
617 // FIXME: need to keep track of subframe focus for key events |
|
618 gtk_widget_grab_focus(widget); |
|
619 |
|
620 // For double and triple clicks GDK sends both a normal button press event |
|
621 // and a specific type (like GDK_2BUTTON_PRESS). If we detect a special press |
|
622 // coming up, ignore this event as it certainly generated the double or triple |
|
623 // click. The consequence of not eating this event is two DOM button press events |
|
624 // are generated. |
|
625 GOwnPtr<GdkEvent> nextEvent(gdk_event_peek()); |
|
626 if (nextEvent && (nextEvent->any.type == GDK_2BUTTON_PRESS || nextEvent->any.type == GDK_3BUTTON_PRESS)) |
|
627 return TRUE; |
|
628 |
|
629 gint doubleClickDistance = 250; |
|
630 gint doubleClickTime = 5; |
|
631 GtkSettings* settings = gtk_settings_get_for_screen(gdk_drawable_get_screen(gtk_widget_get_window(widget))); |
|
632 g_object_get(settings, |
|
633 "gtk-double-click-distance", &doubleClickDistance, |
|
634 "gtk-double-click-time", &doubleClickTime, NULL); |
|
635 |
|
636 // GTK+ only counts up to triple clicks, but WebCore wants to know about |
|
637 // quadruple clicks, quintuple clicks, ad infinitum. Here, we replicate the |
|
638 // GDK logic for counting clicks. |
|
639 guint32 eventTime = getEventTime(reinterpret_cast<GdkEvent*>(event)); |
|
640 if ((event->type == GDK_2BUTTON_PRESS || event->type == GDK_3BUTTON_PRESS) |
|
641 || ((abs(event->x - priv->previousClickPoint->x()) < doubleClickDistance) |
|
642 && (abs(event->y - priv->previousClickPoint->y()) < doubleClickDistance) |
|
643 && (eventTime - priv->previousClickTime < static_cast<guint>(doubleClickTime)) |
|
644 && (event->button == priv->previousClickButton))) |
|
645 priv->currentClickCount++; |
|
646 else |
|
647 priv->currentClickCount = 1; |
|
648 |
|
649 PlatformMouseEvent platformEvent(event); |
|
650 platformEvent.setClickCount(priv->currentClickCount); |
|
651 *priv->previousClickPoint = platformEvent.pos(); |
|
652 priv->previousClickButton = event->button; |
|
653 priv->previousClickTime = eventTime; |
|
654 |
|
655 if (event->button == 3) |
|
656 return webkit_web_view_forward_context_menu_event(webView, PlatformMouseEvent(event)); |
|
657 |
|
658 Frame* frame = core(webView)->mainFrame(); |
|
659 if (!frame->view()) |
|
660 return FALSE; |
|
661 |
|
662 |
|
663 gboolean result = frame->eventHandler()->handleMousePressEvent(platformEvent); |
|
664 |
|
665 #if PLATFORM(X11) |
|
666 /* Copy selection to the X11 selection clipboard */ |
|
667 if (event->button == 2) { |
|
668 bool primary = webView->priv->usePrimaryForPaste; |
|
669 webView->priv->usePrimaryForPaste = true; |
|
670 |
|
671 Editor* editor = webView->priv->corePage->focusController()->focusedOrMainFrame()->editor(); |
|
672 result = result || editor->canPaste() || editor->canDHTMLPaste(); |
|
673 editor->paste(); |
|
674 |
|
675 webView->priv->usePrimaryForPaste = primary; |
|
676 } |
|
677 #endif |
|
678 |
|
679 return result; |
|
680 } |
|
681 |
|
682 static gboolean webkit_web_view_button_release_event(GtkWidget* widget, GdkEventButton* event) |
|
683 { |
|
684 WebKitWebView* webView = WEBKIT_WEB_VIEW(widget); |
|
685 |
|
686 Frame* focusedFrame = core(webView)->focusController()->focusedFrame(); |
|
687 |
|
688 if (focusedFrame && focusedFrame->editor()->canEdit()) { |
|
689 #ifdef MAEMO_CHANGES |
|
690 WebKitWebViewPrivate* priv = webView->priv; |
|
691 hildon_gtk_im_context_filter_event(priv->imContext, (GdkEvent*)event); |
|
692 #endif |
|
693 } |
|
694 |
|
695 Frame* mainFrame = core(webView)->mainFrame(); |
|
696 if (mainFrame->view()) |
|
697 mainFrame->eventHandler()->handleMouseReleaseEvent(PlatformMouseEvent(event)); |
|
698 |
|
699 /* We always return FALSE here because WebKit can, for the same click, decide |
|
700 * to not handle press-event but handle release-event, which can totally confuse |
|
701 * some GTK+ containers when there are no other events in between. This way we |
|
702 * guarantee that this case never happens, and that if press-event goes through |
|
703 * release-event also goes through. |
|
704 */ |
|
705 |
|
706 return FALSE; |
|
707 } |
|
708 |
|
709 static gboolean webkit_web_view_motion_event(GtkWidget* widget, GdkEventMotion* event) |
|
710 { |
|
711 WebKitWebView* webView = WEBKIT_WEB_VIEW(widget); |
|
712 |
|
713 Frame* frame = core(webView)->mainFrame(); |
|
714 if (!frame->view()) |
|
715 return FALSE; |
|
716 |
|
717 return frame->eventHandler()->mouseMoved(PlatformMouseEvent(event)); |
|
718 } |
|
719 |
|
720 static gboolean webkit_web_view_scroll_event(GtkWidget* widget, GdkEventScroll* event) |
|
721 { |
|
722 WebKitWebView* webView = WEBKIT_WEB_VIEW(widget); |
|
723 |
|
724 Frame* frame = core(webView)->mainFrame(); |
|
725 if (!frame->view()) |
|
726 return FALSE; |
|
727 |
|
728 PlatformWheelEvent wheelEvent(event); |
|
729 return frame->eventHandler()->handleWheelEvent(wheelEvent); |
|
730 } |
|
731 |
|
732 static void webkit_web_view_size_request(GtkWidget* widget, GtkRequisition* requisition) |
|
733 { |
|
734 WebKitWebView* web_view = WEBKIT_WEB_VIEW(widget); |
|
735 Frame* coreFrame = core(webkit_web_view_get_main_frame(web_view)); |
|
736 if (!coreFrame) |
|
737 return; |
|
738 |
|
739 FrameView* view = coreFrame->view(); |
|
740 if (!view) |
|
741 return; |
|
742 |
|
743 requisition->width = view->contentsWidth(); |
|
744 requisition->height = view->contentsHeight(); |
|
745 } |
|
746 |
|
747 static void webkit_web_view_size_allocate(GtkWidget* widget, GtkAllocation* allocation) |
|
748 { |
|
749 GTK_WIDGET_CLASS(webkit_web_view_parent_class)->size_allocate(widget,allocation); |
|
750 |
|
751 WebKitWebView* webView = WEBKIT_WEB_VIEW(widget); |
|
752 |
|
753 Frame* frame = core(webView)->mainFrame(); |
|
754 if (!frame->view()) |
|
755 return; |
|
756 |
|
757 frame->view()->resize(allocation->width, allocation->height); |
|
758 } |
|
759 |
|
760 static void webkit_web_view_grab_focus(GtkWidget* widget) |
|
761 { |
|
762 |
|
763 if (gtk_widget_is_sensitive(widget)) { |
|
764 WebKitWebView* webView = WEBKIT_WEB_VIEW(widget); |
|
765 FocusController* focusController = core(webView)->focusController(); |
|
766 |
|
767 focusController->setActive(true); |
|
768 |
|
769 if (focusController->focusedFrame()) |
|
770 focusController->setFocused(true); |
|
771 else |
|
772 focusController->setFocusedFrame(core(webView)->mainFrame()); |
|
773 } |
|
774 |
|
775 return GTK_WIDGET_CLASS(webkit_web_view_parent_class)->grab_focus(widget); |
|
776 } |
|
777 |
|
778 static gboolean webkit_web_view_focus_in_event(GtkWidget* widget, GdkEventFocus* event) |
|
779 { |
|
780 // TODO: Improve focus handling as suggested in |
|
781 // http://bugs.webkit.org/show_bug.cgi?id=16910 |
|
782 GtkWidget* toplevel = gtk_widget_get_toplevel(widget); |
|
783 if (gtk_widget_is_toplevel(toplevel) && gtk_window_has_toplevel_focus(GTK_WINDOW(toplevel))) { |
|
784 WebKitWebView* webView = WEBKIT_WEB_VIEW(widget); |
|
785 FocusController* focusController = core(webView)->focusController(); |
|
786 |
|
787 focusController->setActive(true); |
|
788 |
|
789 if (focusController->focusedFrame()) |
|
790 focusController->setFocused(true); |
|
791 else |
|
792 focusController->setFocusedFrame(core(webView)->mainFrame()); |
|
793 |
|
794 gtk_im_context_focus_in(webView->priv->imContext); |
|
795 } |
|
796 return GTK_WIDGET_CLASS(webkit_web_view_parent_class)->focus_in_event(widget, event); |
|
797 } |
|
798 |
|
799 static gboolean webkit_web_view_focus_out_event(GtkWidget* widget, GdkEventFocus* event) |
|
800 { |
|
801 WebKitWebView* webView = WEBKIT_WEB_VIEW(widget); |
|
802 |
|
803 // We may hit this code while destroying the widget, and we might |
|
804 // no longer have a page, then. |
|
805 Page* page = core(webView); |
|
806 if (page) { |
|
807 page->focusController()->setActive(false); |
|
808 page->focusController()->setFocused(false); |
|
809 } |
|
810 |
|
811 if (webView->priv->imContext) |
|
812 gtk_im_context_focus_out(webView->priv->imContext); |
|
813 |
|
814 return GTK_WIDGET_CLASS(webkit_web_view_parent_class)->focus_out_event(widget, event); |
|
815 } |
|
816 |
|
817 static void webkit_web_view_realize(GtkWidget* widget) |
|
818 { |
|
819 gtk_widget_set_realized(widget, TRUE); |
|
820 |
|
821 GtkAllocation allocation; |
|
822 #if GTK_CHECK_VERSION(2, 18, 0) |
|
823 gtk_widget_get_allocation(widget, &allocation); |
|
824 #else |
|
825 allocation = widget->allocation; |
|
826 #endif |
|
827 |
|
828 GdkWindowAttr attributes; |
|
829 attributes.window_type = GDK_WINDOW_CHILD; |
|
830 attributes.x = allocation.x; |
|
831 attributes.y = allocation.y; |
|
832 attributes.width = allocation.width; |
|
833 attributes.height = allocation.height; |
|
834 attributes.wclass = GDK_INPUT_OUTPUT; |
|
835 attributes.visual = gtk_widget_get_visual(widget); |
|
836 attributes.colormap = gtk_widget_get_colormap(widget); |
|
837 attributes.event_mask = GDK_VISIBILITY_NOTIFY_MASK |
|
838 | GDK_EXPOSURE_MASK |
|
839 | GDK_BUTTON_PRESS_MASK |
|
840 | GDK_BUTTON_RELEASE_MASK |
|
841 | GDK_POINTER_MOTION_MASK |
|
842 | GDK_KEY_PRESS_MASK |
|
843 | GDK_KEY_RELEASE_MASK |
|
844 | GDK_BUTTON_MOTION_MASK |
|
845 | GDK_BUTTON1_MOTION_MASK |
|
846 | GDK_BUTTON2_MOTION_MASK |
|
847 | GDK_BUTTON3_MOTION_MASK; |
|
848 |
|
849 gint attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP; |
|
850 GdkWindow* window = gdk_window_new(gtk_widget_get_parent_window(widget), &attributes, attributes_mask); |
|
851 gtk_widget_set_window(widget, window); |
|
852 gdk_window_set_user_data(window, widget); |
|
853 |
|
854 #if GTK_CHECK_VERSION(2, 20, 0) |
|
855 gtk_widget_style_attach(widget); |
|
856 #else |
|
857 widget->style = gtk_style_attach(gtk_widget_get_style(widget), window); |
|
858 #endif |
|
859 gtk_style_set_background(gtk_widget_get_style(widget), window, GTK_STATE_NORMAL); |
|
860 |
|
861 WebKitWebView* webView = WEBKIT_WEB_VIEW(widget); |
|
862 WebKitWebViewPrivate* priv = webView->priv; |
|
863 gtk_im_context_set_client_window(priv->imContext, window); |
|
864 } |
|
865 |
|
866 static void webkit_web_view_set_scroll_adjustments(WebKitWebView* webView, GtkAdjustment* hadj, GtkAdjustment* vadj) |
|
867 { |
|
868 if (!core(webView)) |
|
869 return; |
|
870 |
|
871 FrameView* view = core(webkit_web_view_get_main_frame(webView))->view(); |
|
872 |
|
873 if (hadj) |
|
874 g_object_ref(hadj); |
|
875 if (vadj) |
|
876 g_object_ref(vadj); |
|
877 |
|
878 WebKitWebViewPrivate* priv = webView->priv; |
|
879 |
|
880 if (priv->horizontalAdjustment) |
|
881 g_object_unref(priv->horizontalAdjustment); |
|
882 if (priv->verticalAdjustment) |
|
883 g_object_unref(priv->verticalAdjustment); |
|
884 |
|
885 priv->horizontalAdjustment = hadj; |
|
886 priv->verticalAdjustment = vadj; |
|
887 |
|
888 if (!view) |
|
889 return; |
|
890 |
|
891 view->setGtkAdjustments(hadj, vadj); |
|
892 } |
|
893 |
|
894 static void webkit_web_view_container_add(GtkContainer* container, GtkWidget* widget) |
|
895 { |
|
896 WebKitWebView* webView = WEBKIT_WEB_VIEW(container); |
|
897 WebKitWebViewPrivate* priv = webView->priv; |
|
898 |
|
899 priv->children.add(widget); |
|
900 gtk_widget_set_parent(widget, GTK_WIDGET(container)); |
|
901 } |
|
902 |
|
903 static void webkit_web_view_container_remove(GtkContainer* container, GtkWidget* widget) |
|
904 { |
|
905 WebKitWebView* webView = WEBKIT_WEB_VIEW(container); |
|
906 WebKitWebViewPrivate* priv = webView->priv; |
|
907 |
|
908 if (priv->children.contains(widget)) { |
|
909 gtk_widget_unparent(widget); |
|
910 priv->children.remove(widget); |
|
911 } |
|
912 } |
|
913 |
|
914 static void webkit_web_view_container_forall(GtkContainer* container, gboolean, GtkCallback callback, gpointer callbackData) |
|
915 { |
|
916 WebKitWebView* webView = WEBKIT_WEB_VIEW(container); |
|
917 WebKitWebViewPrivate* priv = webView->priv; |
|
918 |
|
919 HashSet<GtkWidget*> children = priv->children; |
|
920 HashSet<GtkWidget*>::const_iterator end = children.end(); |
|
921 for (HashSet<GtkWidget*>::const_iterator current = children.begin(); current != end; ++current) |
|
922 (*callback)(*current, callbackData); |
|
923 } |
|
924 |
|
925 static WebKitWebView* webkit_web_view_real_create_web_view(WebKitWebView*, WebKitWebFrame*) |
|
926 { |
|
927 return 0; |
|
928 } |
|
929 |
|
930 static gboolean webkit_web_view_real_web_view_ready(WebKitWebView*) |
|
931 { |
|
932 return FALSE; |
|
933 } |
|
934 |
|
935 static gboolean webkit_web_view_real_close_web_view(WebKitWebView*) |
|
936 { |
|
937 return FALSE; |
|
938 } |
|
939 |
|
940 static WebKitNavigationResponse webkit_web_view_real_navigation_requested(WebKitWebView*, WebKitWebFrame*, WebKitNetworkRequest*) |
|
941 { |
|
942 return WEBKIT_NAVIGATION_RESPONSE_ACCEPT; |
|
943 } |
|
944 |
|
945 static void webkit_web_view_real_window_object_cleared(WebKitWebView*, WebKitWebFrame*, JSGlobalContextRef context, JSObjectRef window_object) |
|
946 { |
|
947 notImplemented(); |
|
948 } |
|
949 |
|
950 static gchar* webkit_web_view_real_choose_file(WebKitWebView*, WebKitWebFrame*, const gchar* old_name) |
|
951 { |
|
952 notImplemented(); |
|
953 return g_strdup(old_name); |
|
954 } |
|
955 |
|
956 typedef enum { |
|
957 WEBKIT_SCRIPT_DIALOG_ALERT, |
|
958 WEBKIT_SCRIPT_DIALOG_CONFIRM, |
|
959 WEBKIT_SCRIPT_DIALOG_PROMPT |
|
960 } WebKitScriptDialogType; |
|
961 |
|
962 static gboolean webkit_web_view_script_dialog(WebKitWebView* webView, WebKitWebFrame* frame, const gchar* message, WebKitScriptDialogType type, const gchar* defaultValue, gchar** value) |
|
963 { |
|
964 GtkMessageType messageType; |
|
965 GtkButtonsType buttons; |
|
966 gint defaultResponse; |
|
967 GtkWidget* window; |
|
968 GtkWidget* dialog; |
|
969 GtkWidget* entry = 0; |
|
970 gboolean didConfirm = FALSE; |
|
971 |
|
972 switch (type) { |
|
973 case WEBKIT_SCRIPT_DIALOG_ALERT: |
|
974 messageType = GTK_MESSAGE_WARNING; |
|
975 buttons = GTK_BUTTONS_CLOSE; |
|
976 defaultResponse = GTK_RESPONSE_CLOSE; |
|
977 break; |
|
978 case WEBKIT_SCRIPT_DIALOG_CONFIRM: |
|
979 messageType = GTK_MESSAGE_QUESTION; |
|
980 buttons = GTK_BUTTONS_YES_NO; |
|
981 defaultResponse = GTK_RESPONSE_YES; |
|
982 break; |
|
983 case WEBKIT_SCRIPT_DIALOG_PROMPT: |
|
984 messageType = GTK_MESSAGE_QUESTION; |
|
985 buttons = GTK_BUTTONS_OK_CANCEL; |
|
986 defaultResponse = GTK_RESPONSE_OK; |
|
987 break; |
|
988 default: |
|
989 g_warning("Unknown value for WebKitScriptDialogType."); |
|
990 return FALSE; |
|
991 } |
|
992 |
|
993 window = gtk_widget_get_toplevel(GTK_WIDGET(webView)); |
|
994 dialog = gtk_message_dialog_new(gtk_widget_is_toplevel(window) ? GTK_WINDOW(window) : 0, GTK_DIALOG_DESTROY_WITH_PARENT, messageType, buttons, "%s", message); |
|
995 gchar* title = g_strconcat("JavaScript - ", webkit_web_frame_get_uri(frame), NULL); |
|
996 gtk_window_set_title(GTK_WINDOW(dialog), title); |
|
997 g_free(title); |
|
998 |
|
999 if (type == WEBKIT_SCRIPT_DIALOG_PROMPT) { |
|
1000 entry = gtk_entry_new(); |
|
1001 gtk_entry_set_text(GTK_ENTRY(entry), defaultValue); |
|
1002 gtk_container_add(GTK_CONTAINER(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), entry); |
|
1003 gtk_entry_set_activates_default(GTK_ENTRY(entry), TRUE); |
|
1004 gtk_widget_show(entry); |
|
1005 } |
|
1006 |
|
1007 gtk_dialog_set_default_response(GTK_DIALOG(dialog), defaultResponse); |
|
1008 gint response = gtk_dialog_run(GTK_DIALOG(dialog)); |
|
1009 |
|
1010 switch (response) { |
|
1011 case GTK_RESPONSE_YES: |
|
1012 didConfirm = TRUE; |
|
1013 break; |
|
1014 case GTK_RESPONSE_OK: |
|
1015 didConfirm = TRUE; |
|
1016 if (entry) |
|
1017 *value = g_strdup(gtk_entry_get_text(GTK_ENTRY(entry))); |
|
1018 else |
|
1019 *value = 0; |
|
1020 break; |
|
1021 case GTK_RESPONSE_NO: |
|
1022 case GTK_RESPONSE_CANCEL: |
|
1023 didConfirm = FALSE; |
|
1024 break; |
|
1025 |
|
1026 } |
|
1027 gtk_widget_destroy(GTK_WIDGET(dialog)); |
|
1028 return didConfirm; |
|
1029 } |
|
1030 |
|
1031 static gboolean webkit_web_view_real_script_alert(WebKitWebView* webView, WebKitWebFrame* frame, const gchar* message) |
|
1032 { |
|
1033 webkit_web_view_script_dialog(webView, frame, message, WEBKIT_SCRIPT_DIALOG_ALERT, 0, 0); |
|
1034 return TRUE; |
|
1035 } |
|
1036 |
|
1037 static gboolean webkit_web_view_real_script_confirm(WebKitWebView* webView, WebKitWebFrame* frame, const gchar* message, gboolean* didConfirm) |
|
1038 { |
|
1039 *didConfirm = webkit_web_view_script_dialog(webView, frame, message, WEBKIT_SCRIPT_DIALOG_CONFIRM, 0, 0); |
|
1040 return TRUE; |
|
1041 } |
|
1042 |
|
1043 static gboolean webkit_web_view_real_script_prompt(WebKitWebView* webView, WebKitWebFrame* frame, const gchar* message, const gchar* defaultValue, gchar** value) |
|
1044 { |
|
1045 if (!webkit_web_view_script_dialog(webView, frame, message, WEBKIT_SCRIPT_DIALOG_PROMPT, defaultValue, value)) |
|
1046 *value = NULL; |
|
1047 return TRUE; |
|
1048 } |
|
1049 |
|
1050 static gboolean webkit_web_view_real_console_message(WebKitWebView* webView, const gchar* message, unsigned int line, const gchar* sourceId) |
|
1051 { |
|
1052 g_message("console message: %s @%d: %s\n", sourceId, line, message); |
|
1053 return TRUE; |
|
1054 } |
|
1055 |
|
1056 static void webkit_web_view_real_select_all(WebKitWebView* webView) |
|
1057 { |
|
1058 Frame* frame = core(webView)->focusController()->focusedOrMainFrame(); |
|
1059 frame->editor()->command("SelectAll").execute(); |
|
1060 } |
|
1061 |
|
1062 static void webkit_web_view_real_cut_clipboard(WebKitWebView* webView) |
|
1063 { |
|
1064 Frame* frame = core(webView)->focusController()->focusedOrMainFrame(); |
|
1065 frame->editor()->command("Cut").execute(); |
|
1066 } |
|
1067 |
|
1068 static void webkit_web_view_real_copy_clipboard(WebKitWebView* webView) |
|
1069 { |
|
1070 Frame* frame = core(webView)->focusController()->focusedOrMainFrame(); |
|
1071 frame->editor()->command("Copy").execute(); |
|
1072 } |
|
1073 |
|
1074 static void webkit_web_view_real_undo(WebKitWebView* webView) |
|
1075 { |
|
1076 Frame* frame = core(webView)->focusController()->focusedOrMainFrame(); |
|
1077 frame->editor()->command("Undo").execute(); |
|
1078 } |
|
1079 |
|
1080 static void webkit_web_view_real_redo(WebKitWebView* webView) |
|
1081 { |
|
1082 Frame* frame = core(webView)->focusController()->focusedOrMainFrame(); |
|
1083 frame->editor()->command("Redo").execute(); |
|
1084 } |
|
1085 |
|
1086 static gboolean webkit_web_view_real_move_cursor (WebKitWebView* webView, GtkMovementStep step, gint count) |
|
1087 { |
|
1088 g_return_val_if_fail(WEBKIT_IS_WEB_VIEW (webView), FALSE); |
|
1089 g_return_val_if_fail(step == GTK_MOVEMENT_VISUAL_POSITIONS || |
|
1090 step == GTK_MOVEMENT_DISPLAY_LINES || |
|
1091 step == GTK_MOVEMENT_PAGES || |
|
1092 step == GTK_MOVEMENT_BUFFER_ENDS, FALSE); |
|
1093 g_return_val_if_fail(count == 1 || count == -1, FALSE); |
|
1094 |
|
1095 ScrollDirection direction; |
|
1096 ScrollGranularity granularity; |
|
1097 |
|
1098 switch (step) { |
|
1099 case GTK_MOVEMENT_DISPLAY_LINES: |
|
1100 granularity = ScrollByLine; |
|
1101 if (count == 1) |
|
1102 direction = ScrollDown; |
|
1103 else |
|
1104 direction = ScrollUp; |
|
1105 break; |
|
1106 case GTK_MOVEMENT_VISUAL_POSITIONS: |
|
1107 granularity = ScrollByLine; |
|
1108 if (count == 1) |
|
1109 direction = ScrollRight; |
|
1110 else |
|
1111 direction = ScrollLeft; |
|
1112 break; |
|
1113 case GTK_MOVEMENT_PAGES: |
|
1114 granularity = ScrollByPage; |
|
1115 if (count == 1) |
|
1116 direction = ScrollDown; |
|
1117 else |
|
1118 direction = ScrollUp; |
|
1119 break; |
|
1120 case GTK_MOVEMENT_BUFFER_ENDS: |
|
1121 granularity = ScrollByDocument; |
|
1122 if (count == 1) |
|
1123 direction = ScrollDown; |
|
1124 else |
|
1125 direction = ScrollUp; |
|
1126 break; |
|
1127 default: |
|
1128 g_assert_not_reached(); |
|
1129 return false; |
|
1130 } |
|
1131 |
|
1132 Frame* frame = core(webView)->focusController()->focusedOrMainFrame(); |
|
1133 if (!frame->eventHandler()->scrollOverflow(direction, granularity)) |
|
1134 frame->view()->scroll(direction, granularity); |
|
1135 |
|
1136 return true; |
|
1137 } |
|
1138 |
|
1139 static void webkit_web_view_real_paste_clipboard(WebKitWebView* webView) |
|
1140 { |
|
1141 Frame* frame = core(webView)->focusController()->focusedOrMainFrame(); |
|
1142 frame->editor()->command("Paste").execute(); |
|
1143 } |
|
1144 |
|
1145 static void webkit_web_view_dispose(GObject* object) |
|
1146 { |
|
1147 WebKitWebView* webView = WEBKIT_WEB_VIEW(object); |
|
1148 WebKitWebViewPrivate* priv = webView->priv; |
|
1149 |
|
1150 priv->disposing = TRUE; |
|
1151 |
|
1152 if (priv->horizontalAdjustment) { |
|
1153 g_object_unref(priv->horizontalAdjustment); |
|
1154 priv->horizontalAdjustment = NULL; |
|
1155 } |
|
1156 |
|
1157 if (priv->verticalAdjustment) { |
|
1158 g_object_unref(priv->verticalAdjustment); |
|
1159 priv->verticalAdjustment = NULL; |
|
1160 } |
|
1161 |
|
1162 if (priv->backForwardList) { |
|
1163 g_object_unref(priv->backForwardList); |
|
1164 priv->backForwardList = NULL; |
|
1165 } |
|
1166 |
|
1167 if (priv->corePage) { |
|
1168 webkit_web_view_stop_loading(WEBKIT_WEB_VIEW(object)); |
|
1169 |
|
1170 core(priv->mainFrame)->loader()->detachFromParent(); |
|
1171 delete priv->corePage; |
|
1172 priv->corePage = NULL; |
|
1173 } |
|
1174 |
|
1175 if (priv->webSettings) { |
|
1176 g_signal_handlers_disconnect_by_func(priv->webSettings, (gpointer)webkit_web_view_settings_notify, webView); |
|
1177 g_object_unref(priv->webSettings); |
|
1178 priv->webSettings = NULL; |
|
1179 |
|
1180 g_object_unref(priv->webInspector); |
|
1181 priv->webInspector = NULL; |
|
1182 |
|
1183 g_object_unref(priv->webWindowFeatures); |
|
1184 priv->webWindowFeatures = NULL; |
|
1185 |
|
1186 g_object_unref(priv->imContext); |
|
1187 priv->imContext = NULL; |
|
1188 } |
|
1189 |
|
1190 if (priv->mainResource) { |
|
1191 g_object_unref(priv->mainResource); |
|
1192 priv->mainResource = NULL; |
|
1193 } |
|
1194 |
|
1195 if (priv->subResources) { |
|
1196 g_hash_table_unref(priv->subResources); |
|
1197 priv->subResources = NULL; |
|
1198 } |
|
1199 |
|
1200 priv->draggingDataObjects->clear(); |
|
1201 HashMap<GdkDragContext*, DroppingContext*>::iterator endDroppingContexts = priv->droppingContexts->end(); |
|
1202 for (HashMap<GdkDragContext*, DroppingContext*>::iterator iter = priv->droppingContexts->begin(); iter != endDroppingContexts; ++iter) |
|
1203 delete (iter->second); |
|
1204 priv->droppingContexts->clear(); |
|
1205 |
|
1206 G_OBJECT_CLASS(webkit_web_view_parent_class)->dispose(object); |
|
1207 } |
|
1208 |
|
1209 static void webkit_web_view_finalize(GObject* object) |
|
1210 { |
|
1211 WebKitWebView* webView = WEBKIT_WEB_VIEW(object); |
|
1212 WebKitWebViewPrivate* priv = webView->priv; |
|
1213 |
|
1214 g_free(priv->tooltipText); |
|
1215 g_free(priv->mainResourceIdentifier); |
|
1216 g_free(priv->encoding); |
|
1217 g_free(priv->customEncoding); |
|
1218 g_free(priv->iconURI); |
|
1219 |
|
1220 delete priv->previousClickPoint; |
|
1221 delete priv->draggingDataObjects; |
|
1222 delete priv->droppingContexts; |
|
1223 |
|
1224 G_OBJECT_CLASS(webkit_web_view_parent_class)->finalize(object); |
|
1225 } |
|
1226 |
|
1227 static gboolean webkit_signal_accumulator_object_handled(GSignalInvocationHint* ihint, GValue* returnAccu, const GValue* handlerReturn, gpointer dummy) |
|
1228 { |
|
1229 gpointer newWebView = g_value_get_object(handlerReturn); |
|
1230 g_value_set_object(returnAccu, newWebView); |
|
1231 |
|
1232 // Continue if we don't have a newWebView |
|
1233 return !newWebView; |
|
1234 } |
|
1235 |
|
1236 static gboolean webkit_navigation_request_handled(GSignalInvocationHint* ihint, GValue* returnAccu, const GValue* handlerReturn, gpointer dummy) |
|
1237 { |
|
1238 WebKitNavigationResponse navigationResponse = (WebKitNavigationResponse)g_value_get_enum(handlerReturn); |
|
1239 g_value_set_enum(returnAccu, navigationResponse); |
|
1240 |
|
1241 if (navigationResponse != WEBKIT_NAVIGATION_RESPONSE_ACCEPT) |
|
1242 return FALSE; |
|
1243 |
|
1244 return TRUE; |
|
1245 } |
|
1246 |
|
1247 static AtkObject* webkit_web_view_get_accessible(GtkWidget* widget) |
|
1248 { |
|
1249 WebKitWebView* webView = WEBKIT_WEB_VIEW(widget); |
|
1250 if (!core(webView)) |
|
1251 return NULL; |
|
1252 |
|
1253 AXObjectCache::enableAccessibility(); |
|
1254 |
|
1255 Frame* coreFrame = core(webView)->mainFrame(); |
|
1256 if (!coreFrame) |
|
1257 return NULL; |
|
1258 |
|
1259 Document* doc = coreFrame->document(); |
|
1260 if (!doc) |
|
1261 return NULL; |
|
1262 |
|
1263 AccessibilityObject* coreAccessible = doc->axObjectCache()->getOrCreate(doc->renderer()); |
|
1264 if (!coreAccessible || !coreAccessible->wrapper()) |
|
1265 return NULL; |
|
1266 |
|
1267 return coreAccessible->wrapper(); |
|
1268 } |
|
1269 |
|
1270 static gdouble webViewGetDPI(WebKitWebView* webView) |
|
1271 { |
|
1272 WebKitWebViewPrivate* priv = webView->priv; |
|
1273 WebKitWebSettings* webSettings = priv->webSettings; |
|
1274 gboolean enforce96DPI; |
|
1275 g_object_get(webSettings, "enforce-96-dpi", &enforce96DPI, NULL); |
|
1276 if (enforce96DPI) |
|
1277 return 96.0; |
|
1278 |
|
1279 gdouble DPI = defaultDPI; |
|
1280 GdkScreen* screen = gtk_widget_has_screen(GTK_WIDGET(webView)) ? gtk_widget_get_screen(GTK_WIDGET(webView)) : gdk_screen_get_default(); |
|
1281 if (screen) { |
|
1282 DPI = gdk_screen_get_resolution(screen); |
|
1283 // gdk_screen_get_resolution() returns -1 when no DPI is set. |
|
1284 if (DPI == -1) |
|
1285 DPI = defaultDPI; |
|
1286 } |
|
1287 ASSERT(DPI > 0); |
|
1288 return DPI; |
|
1289 } |
|
1290 |
|
1291 static void webkit_web_view_screen_changed(GtkWidget* widget, GdkScreen* previousScreen) |
|
1292 { |
|
1293 WebKitWebView* webView = WEBKIT_WEB_VIEW(widget); |
|
1294 WebKitWebViewPrivate* priv = webView->priv; |
|
1295 |
|
1296 if (priv->disposing) |
|
1297 return; |
|
1298 |
|
1299 WebKitWebSettings* webSettings = priv->webSettings; |
|
1300 Settings* settings = core(webView)->settings(); |
|
1301 gdouble DPI = webViewGetDPI(webView); |
|
1302 |
|
1303 guint defaultFontSize, defaultMonospaceFontSize, minimumFontSize, minimumLogicalFontSize; |
|
1304 |
|
1305 g_object_get(webSettings, |
|
1306 "default-font-size", &defaultFontSize, |
|
1307 "default-monospace-font-size", &defaultMonospaceFontSize, |
|
1308 "minimum-font-size", &minimumFontSize, |
|
1309 "minimum-logical-font-size", &minimumLogicalFontSize, |
|
1310 NULL); |
|
1311 |
|
1312 settings->setDefaultFontSize(defaultFontSize / 72.0 * DPI); |
|
1313 settings->setDefaultFixedFontSize(defaultMonospaceFontSize / 72.0 * DPI); |
|
1314 settings->setMinimumFontSize(minimumFontSize / 72.0 * DPI); |
|
1315 settings->setMinimumLogicalFontSize(minimumLogicalFontSize / 72.0 * DPI); |
|
1316 } |
|
1317 |
|
1318 static IntPoint globalPointForClientPoint(GdkWindow* window, const IntPoint& clientPoint) |
|
1319 { |
|
1320 int x, y; |
|
1321 gdk_window_get_origin(window, &x, &y); |
|
1322 return clientPoint + IntSize(x, y); |
|
1323 } |
|
1324 |
|
1325 |
|
1326 static void webkit_web_view_drag_end(GtkWidget* widget, GdkDragContext* context) |
|
1327 { |
|
1328 WebKitWebView* webView = WEBKIT_WEB_VIEW(widget); |
|
1329 WebKitWebViewPrivate* priv = WEBKIT_WEB_VIEW_GET_PRIVATE(webView); |
|
1330 |
|
1331 // This might happen if a drag is still in progress after a WebKitWebView |
|
1332 // is disposed and before it is finalized. |
|
1333 if (!priv->draggingDataObjects->contains(context)) |
|
1334 return; |
|
1335 |
|
1336 priv->draggingDataObjects->remove(context); |
|
1337 |
|
1338 Frame* frame = core(webView)->focusController()->focusedOrMainFrame(); |
|
1339 if (!frame) |
|
1340 return; |
|
1341 |
|
1342 GdkEvent* event = gdk_event_new(GDK_BUTTON_RELEASE); |
|
1343 int x, y, xRoot, yRoot; |
|
1344 GdkModifierType modifiers; |
|
1345 GdkDisplay* display = gdk_display_get_default(); |
|
1346 gdk_display_get_pointer(display, 0, &xRoot, &yRoot, &modifiers); |
|
1347 |
|
1348 GdkWindow* window = gdk_display_get_window_at_pointer(display, &x, &y); |
|
1349 if (window) { |
|
1350 g_object_ref(window); |
|
1351 event->button.window = window; |
|
1352 } |
|
1353 event->button.x = x; |
|
1354 event->button.y = y; |
|
1355 event->button.x_root = xRoot; |
|
1356 event->button.y_root = yRoot; |
|
1357 event->button.state = modifiers; |
|
1358 |
|
1359 PlatformMouseEvent platformEvent(&event->button); |
|
1360 frame->eventHandler()->dragSourceEndedAt(platformEvent, gdkDragActionToDragOperation(gdk_drag_context_get_selected_action(context))); |
|
1361 |
|
1362 gdk_event_free(event); |
|
1363 } |
|
1364 |
|
1365 static void webkit_web_view_drag_data_get(GtkWidget* widget, GdkDragContext* context, GtkSelectionData* selectionData, guint info, guint) |
|
1366 { |
|
1367 WebKitWebViewPrivate* priv = WEBKIT_WEB_VIEW_GET_PRIVATE(WEBKIT_WEB_VIEW(widget)); |
|
1368 |
|
1369 // This might happen if a drag is still in progress after a WebKitWebView |
|
1370 // is diposed and before it is finalized. |
|
1371 if (!priv->draggingDataObjects->contains(context)) |
|
1372 return; |
|
1373 |
|
1374 pasteboardHelperInstance()->fillSelectionData(selectionData, info, priv->draggingDataObjects->get(context).get()); |
|
1375 } |
|
1376 |
|
1377 static gboolean doDragLeaveLater(DroppingContext* context) |
|
1378 { |
|
1379 WebKitWebView* webView = context->webView; |
|
1380 WebKitWebViewPrivate* priv = webView->priv; |
|
1381 |
|
1382 if (!priv->droppingContexts->contains(context->gdkContext)) |
|
1383 return FALSE; |
|
1384 |
|
1385 // If the view doesn't know about the drag yet (there are still pending data) |
|
1386 // requests, don't update it with information about the drag. |
|
1387 if (context->pendingDataRequests) |
|
1388 return FALSE; |
|
1389 |
|
1390 // Don't call dragExited if we have just received a drag-drop signal. This |
|
1391 // happens in the case of a successful drop onto the view. |
|
1392 if (!context->dropHappened) { |
|
1393 const IntPoint& position = context->lastMotionPosition; |
|
1394 DragData dragData(context->dataObject.get(), position, globalPointForClientPoint(gtk_widget_get_window(GTK_WIDGET(webView)), position), DragOperationNone); |
|
1395 core(webView)->dragController()->dragExited(&dragData); |
|
1396 } |
|
1397 |
|
1398 core(webView)->dragController()->dragEnded(); |
|
1399 priv->droppingContexts->remove(context->gdkContext); |
|
1400 delete context; |
|
1401 return FALSE; |
|
1402 } |
|
1403 |
|
1404 static void webkit_web_view_drag_leave(GtkWidget* widget, GdkDragContext* context, guint time) |
|
1405 { |
|
1406 WebKitWebView* webView = WEBKIT_WEB_VIEW(widget); |
|
1407 WebKitWebViewPrivate* priv = webView->priv; |
|
1408 |
|
1409 if (!priv->droppingContexts->contains(context)) |
|
1410 return; |
|
1411 |
|
1412 // During a drop GTK+ will fire a drag-leave signal right before firing |
|
1413 // the drag-drop signal. We want the actions for drag-leave to happen after |
|
1414 // those for drag-drop, so schedule them to happen asynchronously here. |
|
1415 g_timeout_add(0, reinterpret_cast<GSourceFunc>(doDragLeaveLater), priv->droppingContexts->get(context)); |
|
1416 } |
|
1417 |
|
1418 static gboolean webkit_web_view_drag_motion(GtkWidget* widget, GdkDragContext* context, gint x, gint y, guint time) |
|
1419 { |
|
1420 WebKitWebView* webView = WEBKIT_WEB_VIEW(widget); |
|
1421 WebKitWebViewPrivate* priv = webView->priv; |
|
1422 |
|
1423 DroppingContext* droppingContext = 0; |
|
1424 IntPoint position = IntPoint(x, y); |
|
1425 if (!priv->droppingContexts->contains(context)) { |
|
1426 droppingContext = new DroppingContext; |
|
1427 droppingContext->webView = webView; |
|
1428 droppingContext->gdkContext = context; |
|
1429 droppingContext->dataObject = WebCore::DataObjectGtk::create(); |
|
1430 droppingContext->dropHappened = false; |
|
1431 droppingContext->lastMotionPosition = position; |
|
1432 priv->droppingContexts->set(context, droppingContext); |
|
1433 |
|
1434 Vector<GdkAtom> acceptableTargets(pasteboardHelperInstance()->dropAtomsForContext(widget, context)); |
|
1435 droppingContext->pendingDataRequests = acceptableTargets.size(); |
|
1436 for (size_t i = 0; i < acceptableTargets.size(); i++) |
|
1437 gtk_drag_get_data(widget, context, acceptableTargets.at(i), time); |
|
1438 } else { |
|
1439 droppingContext = priv->droppingContexts->get(context); |
|
1440 droppingContext->lastMotionPosition = position; |
|
1441 } |
|
1442 |
|
1443 // Don't send any drag information to WebCore until we've retrieved all |
|
1444 // the data for this drag operation. Otherwise we'd have to block to wait |
|
1445 // for the drag's data. |
|
1446 ASSERT(droppingContext); |
|
1447 if (droppingContext->pendingDataRequests > 0) |
|
1448 return TRUE; |
|
1449 |
|
1450 DragData dragData(droppingContext->dataObject.get(), position, globalPointForClientPoint(gtk_widget_get_window(widget), position), gdkDragActionToDragOperation(gdk_drag_context_get_actions(context))); |
|
1451 DragOperation operation = core(webView)->dragController()->dragUpdated(&dragData); |
|
1452 gdk_drag_status(context, dragOperationToSingleGdkDragAction(operation), time); |
|
1453 |
|
1454 return TRUE; |
|
1455 } |
|
1456 |
|
1457 static void webkit_web_view_drag_data_received(GtkWidget* widget, GdkDragContext* context, gint x, gint y, GtkSelectionData* selectionData, guint info, guint time) |
|
1458 { |
|
1459 WebKitWebView* webView = WEBKIT_WEB_VIEW(widget); |
|
1460 WebKitWebViewPrivate* priv = webView->priv; |
|
1461 |
|
1462 if (!priv->droppingContexts->contains(context)) |
|
1463 return; |
|
1464 |
|
1465 DroppingContext* droppingContext = priv->droppingContexts->get(context); |
|
1466 droppingContext->pendingDataRequests--; |
|
1467 pasteboardHelperInstance()->fillDataObjectFromDropData(selectionData, info, droppingContext->dataObject.get()); |
|
1468 |
|
1469 if (droppingContext->pendingDataRequests) |
|
1470 return; |
|
1471 |
|
1472 // The coordinates passed to drag-data-received signal are sometimes |
|
1473 // inaccurate in DRT, so use the coordinates of the last motion event. |
|
1474 const IntPoint& position = droppingContext->lastMotionPosition; |
|
1475 |
|
1476 // If there are no more pending requests, start sending dragging data to WebCore. |
|
1477 DragData dragData(droppingContext->dataObject.get(), position, globalPointForClientPoint(gtk_widget_get_window(widget), position), gdkDragActionToDragOperation(gdk_drag_context_get_actions(context))); |
|
1478 DragOperation operation = core(webView)->dragController()->dragEntered(&dragData); |
|
1479 gdk_drag_status(context, dragOperationToSingleGdkDragAction(operation), time); |
|
1480 } |
|
1481 |
|
1482 static gboolean webkit_web_view_drag_drop(GtkWidget* widget, GdkDragContext* context, gint x, gint y, guint time) |
|
1483 { |
|
1484 WebKitWebView* webView = WEBKIT_WEB_VIEW(widget); |
|
1485 WebKitWebViewPrivate* priv = webView->priv; |
|
1486 |
|
1487 if (!priv->droppingContexts->contains(context)) |
|
1488 return FALSE; |
|
1489 |
|
1490 DroppingContext* droppingContext = priv->droppingContexts->get(context); |
|
1491 droppingContext->dropHappened = true; |
|
1492 |
|
1493 IntPoint position(x, y); |
|
1494 DragData dragData(droppingContext->dataObject.get(), position, globalPointForClientPoint(gtk_widget_get_window(widget), position), gdkDragActionToDragOperation(gdk_drag_context_get_actions(context))); |
|
1495 core(webView)->dragController()->performDrag(&dragData); |
|
1496 |
|
1497 gtk_drag_finish(context, TRUE, FALSE, time); |
|
1498 return TRUE; |
|
1499 } |
|
1500 |
|
1501 #if GTK_CHECK_VERSION(2, 12, 0) |
|
1502 static gboolean webkit_web_view_query_tooltip(GtkWidget *widget, gint x, gint y, gboolean keyboard_mode, GtkTooltip *tooltip) |
|
1503 { |
|
1504 WebKitWebViewPrivate* priv = WEBKIT_WEB_VIEW_GET_PRIVATE(widget); |
|
1505 |
|
1506 if (priv->tooltipText) { |
|
1507 gtk_tooltip_set_text(tooltip, priv->tooltipText); |
|
1508 return TRUE; |
|
1509 } |
|
1510 |
|
1511 return FALSE; |
|
1512 } |
|
1513 #endif |
|
1514 |
|
1515 static GtkIMContext* webkit_web_view_get_im_context(WebKitWebView* webView) |
|
1516 { |
|
1517 g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), 0); |
|
1518 return GTK_IM_CONTEXT(webView->priv->imContext); |
|
1519 } |
|
1520 |
|
1521 static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass) |
|
1522 { |
|
1523 GtkBindingSet* binding_set; |
|
1524 |
|
1525 webkit_init(); |
|
1526 |
|
1527 /* |
|
1528 * Signals |
|
1529 */ |
|
1530 |
|
1531 /** |
|
1532 * WebKitWebView::create-web-view: |
|
1533 * @web_view: the object on which the signal is emitted |
|
1534 * @frame: the #WebKitWebFrame |
|
1535 * |
|
1536 * Emitted when the creation of a new window is requested. |
|
1537 * If this signal is handled the signal handler should return the |
|
1538 * newly created #WebKitWebView. |
|
1539 * |
|
1540 * The new #WebKitWebView should not be displayed to the user |
|
1541 * until the #WebKitWebView::web-view-ready signal is emitted. |
|
1542 * |
|
1543 * The signal handlers should not try to deal with the reference count for |
|
1544 * the new #WebKitWebView. The widget to which the widget is added will |
|
1545 * handle that. |
|
1546 * |
|
1547 * Return value: a newly allocated #WebKitWebView, or %NULL |
|
1548 * |
|
1549 * Since: 1.0.3 |
|
1550 */ |
|
1551 webkit_web_view_signals[CREATE_WEB_VIEW] = g_signal_new("create-web-view", |
|
1552 G_TYPE_FROM_CLASS(webViewClass), |
|
1553 (GSignalFlags)G_SIGNAL_RUN_LAST, |
|
1554 G_STRUCT_OFFSET (WebKitWebViewClass, create_web_view), |
|
1555 webkit_signal_accumulator_object_handled, |
|
1556 NULL, |
|
1557 webkit_marshal_OBJECT__OBJECT, |
|
1558 WEBKIT_TYPE_WEB_VIEW , 1, |
|
1559 WEBKIT_TYPE_WEB_FRAME); |
|
1560 |
|
1561 /** |
|
1562 * WebKitWebView::web-view-ready: |
|
1563 * @web_view: the object on which the signal is emitted |
|
1564 * |
|
1565 * Emitted after #WebKitWebView::create-web-view when the new #WebKitWebView |
|
1566 * should be displayed to the user. When this signal is emitted |
|
1567 * all the information about how the window should look, including |
|
1568 * size, position, whether the location, status and scroll bars |
|
1569 * should be displayed, is already set on the |
|
1570 * #WebKitWebWindowFeatures object contained by the #WebKitWebView. |
|
1571 * |
|
1572 * Notice that some of that information may change during the life |
|
1573 * time of the window, so you may want to connect to the ::notify |
|
1574 * signal of the #WebKitWebWindowFeatures object to handle those. |
|
1575 * |
|
1576 * Return value: %TRUE to stop handlers from being invoked for the event or |
|
1577 * %FALSE to propagate the event furter |
|
1578 * |
|
1579 * Since: 1.0.3 |
|
1580 */ |
|
1581 webkit_web_view_signals[WEB_VIEW_READY] = g_signal_new("web-view-ready", |
|
1582 G_TYPE_FROM_CLASS(webViewClass), |
|
1583 (GSignalFlags)G_SIGNAL_RUN_LAST, |
|
1584 G_STRUCT_OFFSET (WebKitWebViewClass, web_view_ready), |
|
1585 g_signal_accumulator_true_handled, |
|
1586 NULL, |
|
1587 webkit_marshal_BOOLEAN__VOID, |
|
1588 G_TYPE_BOOLEAN, 0); |
|
1589 |
|
1590 /** |
|
1591 * WebKitWebView::close-web-view: |
|
1592 * @web_view: the object on which the signal is emitted |
|
1593 * |
|
1594 * Emitted when closing a #WebKitWebView is requested. This occurs when a |
|
1595 * call is made from JavaScript's window.close function. The default |
|
1596 * signal handler does not do anything. It is the owner's responsibility |
|
1597 * to hide or delete the web view, if necessary. |
|
1598 * |
|
1599 * Return value: %TRUE to stop handlers from being invoked for the event or |
|
1600 * %FALSE to propagate the event furter |
|
1601 * |
|
1602 * Since: 1.1.11 |
|
1603 */ |
|
1604 webkit_web_view_signals[CLOSE_WEB_VIEW] = g_signal_new("close-web-view", |
|
1605 G_TYPE_FROM_CLASS(webViewClass), |
|
1606 (GSignalFlags)G_SIGNAL_RUN_LAST, |
|
1607 G_STRUCT_OFFSET (WebKitWebViewClass, close_web_view), |
|
1608 g_signal_accumulator_true_handled, |
|
1609 NULL, |
|
1610 webkit_marshal_BOOLEAN__VOID, |
|
1611 G_TYPE_BOOLEAN, 0); |
|
1612 |
|
1613 /** |
|
1614 * WebKitWebView::navigation-requested: |
|
1615 * @web_view: the object on which the signal is emitted |
|
1616 * @frame: the #WebKitWebFrame that required the navigation |
|
1617 * @request: a #WebKitNetworkRequest |
|
1618 * |
|
1619 * Emitted when @frame requests a navigation to another page. |
|
1620 * |
|
1621 * Return value: a #WebKitNavigationResponse |
|
1622 * |
|
1623 * Deprecated: Use WebKitWebView::navigation-policy-decision-requested |
|
1624 * instead |
|
1625 */ |
|
1626 webkit_web_view_signals[NAVIGATION_REQUESTED] = g_signal_new("navigation-requested", |
|
1627 G_TYPE_FROM_CLASS(webViewClass), |
|
1628 (GSignalFlags)G_SIGNAL_RUN_LAST, |
|
1629 G_STRUCT_OFFSET (WebKitWebViewClass, navigation_requested), |
|
1630 webkit_navigation_request_handled, |
|
1631 NULL, |
|
1632 webkit_marshal_ENUM__OBJECT_OBJECT, |
|
1633 WEBKIT_TYPE_NAVIGATION_RESPONSE, 2, |
|
1634 WEBKIT_TYPE_WEB_FRAME, |
|
1635 WEBKIT_TYPE_NETWORK_REQUEST); |
|
1636 |
|
1637 /** |
|
1638 * WebKitWebView::new-window-policy-decision-requested: |
|
1639 * @web_view: the object on which the signal is emitted |
|
1640 * @frame: the #WebKitWebFrame that required the navigation |
|
1641 * @request: a #WebKitNetworkRequest |
|
1642 * @navigation_action: a #WebKitWebNavigationAction |
|
1643 * @policy_decision: a #WebKitWebPolicyDecision |
|
1644 * |
|
1645 * Emitted when @frame requests opening a new window. With this |
|
1646 * signal the browser can use the context of the request to decide |
|
1647 * about the new window. If the request is not handled the default |
|
1648 * behavior is to allow opening the new window to load the URI, |
|
1649 * which will cause a create-web-view signal emission where the |
|
1650 * browser handles the new window action but without information |
|
1651 * of the context that caused the navigation. The following |
|
1652 * navigation-policy-decision-requested emissions will load the |
|
1653 * page after the creation of the new window just with the |
|
1654 * information of this new navigation context, without any |
|
1655 * information about the action that made this new window to be |
|
1656 * opened. |
|
1657 * |
|
1658 * Notice that if you return TRUE, meaning that you handled the |
|
1659 * signal, you are expected to have decided what to do, by calling |
|
1660 * webkit_web_policy_decision_ignore(), |
|
1661 * webkit_web_policy_decision_use(), or |
|
1662 * webkit_web_policy_decision_download() on the @policy_decision |
|
1663 * object. |
|
1664 * |
|
1665 * Return value: %TRUE if a decision was made, %FALSE to have the |
|
1666 * default behavior apply |
|
1667 * |
|
1668 * Since: 1.1.4 |
|
1669 */ |
|
1670 webkit_web_view_signals[NEW_WINDOW_POLICY_DECISION_REQUESTED] = |
|
1671 g_signal_new("new-window-policy-decision-requested", |
|
1672 G_TYPE_FROM_CLASS(webViewClass), |
|
1673 (GSignalFlags)G_SIGNAL_RUN_LAST, |
|
1674 0, |
|
1675 g_signal_accumulator_true_handled, |
|
1676 NULL, |
|
1677 webkit_marshal_BOOLEAN__OBJECT_OBJECT_OBJECT_OBJECT, |
|
1678 G_TYPE_BOOLEAN, 4, |
|
1679 WEBKIT_TYPE_WEB_FRAME, |
|
1680 WEBKIT_TYPE_NETWORK_REQUEST, |
|
1681 WEBKIT_TYPE_WEB_NAVIGATION_ACTION, |
|
1682 WEBKIT_TYPE_WEB_POLICY_DECISION); |
|
1683 |
|
1684 /** |
|
1685 * WebKitWebView::navigation-policy-decision-requested: |
|
1686 * @web_view: the object on which the signal is emitted |
|
1687 * @frame: the #WebKitWebFrame that required the navigation |
|
1688 * @request: a #WebKitNetworkRequest |
|
1689 * @navigation_action: a #WebKitWebNavigationAction |
|
1690 * @policy_decision: a #WebKitWebPolicyDecision |
|
1691 * |
|
1692 * Emitted when @frame requests a navigation to another page. |
|
1693 * If this signal is not handled, the default behavior is to allow the |
|
1694 * navigation. |
|
1695 * |
|
1696 * Notice that if you return TRUE, meaning that you handled the |
|
1697 * signal, you are expected to have decided what to do, by calling |
|
1698 * webkit_web_policy_decision_ignore(), |
|
1699 * webkit_web_policy_decision_use(), or |
|
1700 * webkit_web_policy_decision_download() on the @policy_decision |
|
1701 * object. |
|
1702 * |
|
1703 * Return value: %TRUE if a decision was made, %FALSE to have the |
|
1704 * default behavior apply |
|
1705 * |
|
1706 * Since: 1.0.3 |
|
1707 */ |
|
1708 webkit_web_view_signals[NAVIGATION_POLICY_DECISION_REQUESTED] = g_signal_new("navigation-policy-decision-requested", |
|
1709 G_TYPE_FROM_CLASS(webViewClass), |
|
1710 (GSignalFlags)G_SIGNAL_RUN_LAST, |
|
1711 0, |
|
1712 g_signal_accumulator_true_handled, |
|
1713 NULL, |
|
1714 webkit_marshal_BOOLEAN__OBJECT_OBJECT_OBJECT_OBJECT, |
|
1715 G_TYPE_BOOLEAN, 4, |
|
1716 WEBKIT_TYPE_WEB_FRAME, |
|
1717 WEBKIT_TYPE_NETWORK_REQUEST, |
|
1718 WEBKIT_TYPE_WEB_NAVIGATION_ACTION, |
|
1719 WEBKIT_TYPE_WEB_POLICY_DECISION); |
|
1720 |
|
1721 /** |
|
1722 * WebKitWebView::mime-type-policy-decision-requested: |
|
1723 * @web_view: the object on which the signal is emitted |
|
1724 * @frame: the #WebKitWebFrame that required the policy decision |
|
1725 * @request: a WebKitNetworkRequest |
|
1726 * @mimetype: the MIME type attempted to load |
|
1727 * @policy_decision: a #WebKitWebPolicyDecision |
|
1728 * |
|
1729 * Decide whether or not to display the given MIME type. If this |
|
1730 * signal is not handled, the default behavior is to show the |
|
1731 * content of the requested URI if WebKit can show this MIME |
|
1732 * type and the content disposition is not a download; if WebKit |
|
1733 * is not able to show the MIME type nothing happens. |
|
1734 * |
|
1735 * Notice that if you return TRUE, meaning that you handled the |
|
1736 * signal, you are expected to be aware of the "Content-Disposition" |
|
1737 * header. A value of "attachment" usually indicates a download |
|
1738 * regardless of the MIME type, see also |
|
1739 * soup_message_headers_get_content_disposition(). And you must call |
|
1740 * webkit_web_policy_decision_ignore(), |
|
1741 * webkit_web_policy_decision_use(), or |
|
1742 * webkit_web_policy_decision_download() on the @policy_decision |
|
1743 * object. |
|
1744 * |
|
1745 * Return value: %TRUE if a decision was made, %FALSE to have the |
|
1746 * default behavior apply |
|
1747 * |
|
1748 * Since: 1.0.3 |
|
1749 */ |
|
1750 webkit_web_view_signals[MIME_TYPE_POLICY_DECISION_REQUESTED] = g_signal_new("mime-type-policy-decision-requested", |
|
1751 G_TYPE_FROM_CLASS(webViewClass), |
|
1752 (GSignalFlags)G_SIGNAL_RUN_LAST, |
|
1753 0, |
|
1754 g_signal_accumulator_true_handled, |
|
1755 NULL, |
|
1756 webkit_marshal_BOOLEAN__OBJECT_OBJECT_STRING_OBJECT, |
|
1757 G_TYPE_BOOLEAN, 4, |
|
1758 WEBKIT_TYPE_WEB_FRAME, |
|
1759 WEBKIT_TYPE_NETWORK_REQUEST, |
|
1760 G_TYPE_STRING, |
|
1761 WEBKIT_TYPE_WEB_POLICY_DECISION); |
|
1762 |
|
1763 /** |
|
1764 * WebKitWebView::window-object-cleared: |
|
1765 * @web_view: the object on which the signal is emitted |
|
1766 * @frame: the #WebKitWebFrame to which @window_object belongs |
|
1767 * @context: the #JSGlobalContextRef holding the global object and other |
|
1768 * execution state; equivalent to the return value of |
|
1769 * webkit_web_frame_get_global_context(@frame) |
|
1770 * @window_object: the #JSObjectRef representing the frame's JavaScript |
|
1771 * window object |
|
1772 * |
|
1773 * Emitted when the JavaScript window object in a #WebKitWebFrame has been |
|
1774 * cleared in preparation for a new load. This is the preferred place to |
|
1775 * set custom properties on the window object using the JavaScriptCore API. |
|
1776 */ |
|
1777 webkit_web_view_signals[WINDOW_OBJECT_CLEARED] = g_signal_new("window-object-cleared", |
|
1778 G_TYPE_FROM_CLASS(webViewClass), |
|
1779 (GSignalFlags)G_SIGNAL_RUN_LAST, |
|
1780 G_STRUCT_OFFSET (WebKitWebViewClass, window_object_cleared), |
|
1781 NULL, |
|
1782 NULL, |
|
1783 webkit_marshal_VOID__OBJECT_POINTER_POINTER, |
|
1784 G_TYPE_NONE, 3, |
|
1785 WEBKIT_TYPE_WEB_FRAME, |
|
1786 G_TYPE_POINTER, |
|
1787 G_TYPE_POINTER); |
|
1788 |
|
1789 /** |
|
1790 * WebKitWebView::download-requested: |
|
1791 * @web_view: the object on which the signal is emitted |
|
1792 * @download: a #WebKitDownload object that lets you control the |
|
1793 * download process |
|
1794 * |
|
1795 * A new Download is being requested. By default, if the signal is |
|
1796 * not handled, the download is cancelled. If you handle the download |
|
1797 * and call webkit_download_set_destination_uri(), it will be |
|
1798 * started for you. If you need to set the destination asynchronously |
|
1799 * you are responsible for starting or cancelling it yourself. |
|
1800 * |
|
1801 * If you intend to handle downloads yourself rather than using |
|
1802 * the #WebKitDownload helper object you must handle this signal, |
|
1803 * and return %FALSE. |
|
1804 * |
|
1805 * Also, keep in mind that the default policy for WebKitGTK+ is to |
|
1806 * ignore files with a MIME type that it does not know how to |
|
1807 * handle, which means this signal won't be emitted in the default |
|
1808 * setup. One way to trigger downloads is to connect to |
|
1809 * WebKitWebView::mime-type-policy-decision-requested and call |
|
1810 * webkit_web_policy_decision_download() on the |
|
1811 * #WebKitWebPolicyDecision in the parameter list for the kind of |
|
1812 * files you want your application to download (a common solution |
|
1813 * is to download anything that WebKit can't handle, which you can |
|
1814 * figure out by using webkit_web_view_can_show_mime_type()). |
|
1815 * |
|
1816 * Return value: TRUE if the download should be performed, %FALSE to |
|
1817 * cancel it |
|
1818 * |
|
1819 * Since: 1.1.2 |
|
1820 */ |
|
1821 webkit_web_view_signals[DOWNLOAD_REQUESTED] = g_signal_new("download-requested", |
|
1822 G_TYPE_FROM_CLASS(webViewClass), |
|
1823 (GSignalFlags)G_SIGNAL_RUN_LAST, |
|
1824 0, |
|
1825 g_signal_accumulator_true_handled, |
|
1826 NULL, |
|
1827 webkit_marshal_BOOLEAN__OBJECT, |
|
1828 G_TYPE_BOOLEAN, 1, |
|
1829 G_TYPE_OBJECT); |
|
1830 |
|
1831 /** |
|
1832 * WebKitWebView::load-started: |
|
1833 * @web_view: the object on which the signal is emitted |
|
1834 * @frame: the frame going to do the load |
|
1835 * |
|
1836 * When a #WebKitWebFrame begins to load this signal is emitted. |
|
1837 * |
|
1838 * Deprecated: Use the "load-status" property instead. |
|
1839 */ |
|
1840 webkit_web_view_signals[LOAD_STARTED] = g_signal_new("load-started", |
|
1841 G_TYPE_FROM_CLASS(webViewClass), |
|
1842 (GSignalFlags)G_SIGNAL_RUN_LAST, |
|
1843 0, |
|
1844 NULL, |
|
1845 NULL, |
|
1846 g_cclosure_marshal_VOID__OBJECT, |
|
1847 G_TYPE_NONE, 1, |
|
1848 WEBKIT_TYPE_WEB_FRAME); |
|
1849 |
|
1850 /** |
|
1851 * WebKitWebView::load-committed: |
|
1852 * @web_view: the object on which the signal is emitted |
|
1853 * @frame: the main frame that received the first data |
|
1854 * |
|
1855 * When a #WebKitWebFrame loaded the first data this signal is emitted. |
|
1856 * |
|
1857 * Deprecated: Use the "load-status" property instead. |
|
1858 */ |
|
1859 webkit_web_view_signals[LOAD_COMMITTED] = g_signal_new("load-committed", |
|
1860 G_TYPE_FROM_CLASS(webViewClass), |
|
1861 (GSignalFlags)G_SIGNAL_RUN_LAST, |
|
1862 0, |
|
1863 NULL, |
|
1864 NULL, |
|
1865 g_cclosure_marshal_VOID__OBJECT, |
|
1866 G_TYPE_NONE, 1, |
|
1867 WEBKIT_TYPE_WEB_FRAME); |
|
1868 |
|
1869 |
|
1870 /** |
|
1871 * WebKitWebView::load-progress-changed: |
|
1872 * @web_view: the #WebKitWebView |
|
1873 * @progress: the global progress |
|
1874 * |
|
1875 * Deprecated: Use the "progress" property instead. |
|
1876 */ |
|
1877 webkit_web_view_signals[LOAD_PROGRESS_CHANGED] = g_signal_new("load-progress-changed", |
|
1878 G_TYPE_FROM_CLASS(webViewClass), |
|
1879 (GSignalFlags)G_SIGNAL_RUN_LAST, |
|
1880 0, |
|
1881 NULL, |
|
1882 NULL, |
|
1883 g_cclosure_marshal_VOID__INT, |
|
1884 G_TYPE_NONE, 1, |
|
1885 G_TYPE_INT); |
|
1886 |
|
1887 /** |
|
1888 * WebKitWebView::load-error |
|
1889 * @web_view: the object on which the signal is emitted |
|
1890 * @web_frame: the #WebKitWebFrame |
|
1891 * @uri: the URI that triggered the error |
|
1892 * @web_error: the #GError that was triggered |
|
1893 * |
|
1894 * An error occurred while loading. By default, if the signal is not |
|
1895 * handled, the @web_view will display a stock error page. You need to |
|
1896 * handle the signal if you want to provide your own error page. |
|
1897 * |
|
1898 * Since: 1.1.6 |
|
1899 * |
|
1900 * Return value: %TRUE to stop other handlers from being invoked for the |
|
1901 * event. %FALSE to propagate the event further. |
|
1902 */ |
|
1903 webkit_web_view_signals[LOAD_ERROR] = g_signal_new("load-error", |
|
1904 G_TYPE_FROM_CLASS(webViewClass), |
|
1905 (GSignalFlags)(G_SIGNAL_RUN_LAST), |
|
1906 0, |
|
1907 g_signal_accumulator_true_handled, |
|
1908 NULL, |
|
1909 webkit_marshal_BOOLEAN__OBJECT_STRING_POINTER, |
|
1910 G_TYPE_BOOLEAN, 3, |
|
1911 WEBKIT_TYPE_WEB_FRAME, |
|
1912 G_TYPE_STRING, |
|
1913 G_TYPE_POINTER); |
|
1914 |
|
1915 /** |
|
1916 * WebKitWebView::load-finished: |
|
1917 * @web_view: the #WebKitWebView |
|
1918 * @frame: the #WebKitWebFrame |
|
1919 * |
|
1920 * Deprecated: Use the "load-status" property instead. |
|
1921 */ |
|
1922 webkit_web_view_signals[LOAD_FINISHED] = g_signal_new("load-finished", |
|
1923 G_TYPE_FROM_CLASS(webViewClass), |
|
1924 (GSignalFlags)G_SIGNAL_RUN_LAST, |
|
1925 0, |
|
1926 NULL, |
|
1927 NULL, |
|
1928 g_cclosure_marshal_VOID__OBJECT, |
|
1929 G_TYPE_NONE, 1, |
|
1930 WEBKIT_TYPE_WEB_FRAME); |
|
1931 |
|
1932 /** |
|
1933 * WebKitWebView::onload-event: |
|
1934 * @web_view: the object on which the signal is emitted |
|
1935 * @frame: the frame |
|
1936 * |
|
1937 * When a #WebKitWebFrame receives an onload event this signal is emitted. |
|
1938 */ |
|
1939 webkit_web_view_signals[LOAD_STARTED] = g_signal_new("onload-event", |
|
1940 G_TYPE_FROM_CLASS(webViewClass), |
|
1941 (GSignalFlags)G_SIGNAL_RUN_LAST, |
|
1942 0, |
|
1943 NULL, |
|
1944 NULL, |
|
1945 g_cclosure_marshal_VOID__OBJECT, |
|
1946 G_TYPE_NONE, 1, |
|
1947 WEBKIT_TYPE_WEB_FRAME); |
|
1948 |
|
1949 /** |
|
1950 * WebKitWebView::title-changed: |
|
1951 * @web_view: the object on which the signal is emitted |
|
1952 * @frame: the main frame |
|
1953 * @title: the new title |
|
1954 * |
|
1955 * When a #WebKitWebFrame changes the document title this signal is emitted. |
|
1956 * |
|
1957 * Deprecated: 1.1.4: Use "notify::title" instead. |
|
1958 */ |
|
1959 webkit_web_view_signals[TITLE_CHANGED] = g_signal_new("title-changed", |
|
1960 G_TYPE_FROM_CLASS(webViewClass), |
|
1961 (GSignalFlags)G_SIGNAL_RUN_LAST, |
|
1962 0, |
|
1963 NULL, |
|
1964 NULL, |
|
1965 webkit_marshal_VOID__OBJECT_STRING, |
|
1966 G_TYPE_NONE, 2, |
|
1967 WEBKIT_TYPE_WEB_FRAME, |
|
1968 G_TYPE_STRING); |
|
1969 |
|
1970 /** |
|
1971 * WebKitWebView::hovering-over-link: |
|
1972 * @web_view: the object on which the signal is emitted |
|
1973 * @title: the link's title |
|
1974 * @uri: the URI the link points to |
|
1975 * |
|
1976 * When the cursor is over a link, this signal is emitted. |
|
1977 */ |
|
1978 webkit_web_view_signals[HOVERING_OVER_LINK] = g_signal_new("hovering-over-link", |
|
1979 G_TYPE_FROM_CLASS(webViewClass), |
|
1980 (GSignalFlags)G_SIGNAL_RUN_LAST, |
|
1981 0, |
|
1982 NULL, |
|
1983 NULL, |
|
1984 webkit_marshal_VOID__STRING_STRING, |
|
1985 G_TYPE_NONE, 2, |
|
1986 G_TYPE_STRING, |
|
1987 G_TYPE_STRING); |
|
1988 |
|
1989 /** |
|
1990 * WebKitWebView::populate-popup: |
|
1991 * @web_view: the object on which the signal is emitted |
|
1992 * @menu: the context menu |
|
1993 * |
|
1994 * When a context menu is about to be displayed this signal is emitted. |
|
1995 * |
|
1996 * Add menu items to #menu to extend the context menu. |
|
1997 */ |
|
1998 webkit_web_view_signals[POPULATE_POPUP] = g_signal_new("populate-popup", |
|
1999 G_TYPE_FROM_CLASS(webViewClass), |
|
2000 (GSignalFlags)G_SIGNAL_RUN_LAST, |
|
2001 0, |
|
2002 NULL, |
|
2003 NULL, |
|
2004 g_cclosure_marshal_VOID__OBJECT, |
|
2005 G_TYPE_NONE, 1, |
|
2006 GTK_TYPE_MENU); |
|
2007 |
|
2008 /** |
|
2009 * WebKitWebView::print-requested |
|
2010 * @web_view: the object in which the signal is emitted |
|
2011 * @web_frame: the frame that is requesting to be printed |
|
2012 * |
|
2013 * Emitted when printing is requested by the frame, usually |
|
2014 * because of a javascript call. When handling this signal you |
|
2015 * should call webkit_web_frame_print_full() or |
|
2016 * webkit_web_frame_print() to do the actual printing. |
|
2017 * |
|
2018 * The default handler will present a print dialog and carry a |
|
2019 * print operation. Notice that this means that if you intend to |
|
2020 * ignore a print request you must connect to this signal, and |
|
2021 * return %TRUE. |
|
2022 * |
|
2023 * Return value: %TRUE if the print request has been handled, %FALSE if |
|
2024 * the default handler should run |
|
2025 * |
|
2026 * Since: 1.1.5 |
|
2027 */ |
|
2028 webkit_web_view_signals[PRINT_REQUESTED] = g_signal_new("print-requested", |
|
2029 G_TYPE_FROM_CLASS(webViewClass), |
|
2030 (GSignalFlags)G_SIGNAL_RUN_LAST, |
|
2031 0, |
|
2032 g_signal_accumulator_true_handled, |
|
2033 NULL, |
|
2034 webkit_marshal_BOOLEAN__OBJECT, |
|
2035 G_TYPE_BOOLEAN, 1, |
|
2036 WEBKIT_TYPE_WEB_FRAME); |
|
2037 |
|
2038 webkit_web_view_signals[STATUS_BAR_TEXT_CHANGED] = g_signal_new("status-bar-text-changed", |
|
2039 G_TYPE_FROM_CLASS(webViewClass), |
|
2040 (GSignalFlags)G_SIGNAL_RUN_LAST, |
|
2041 0, |
|
2042 NULL, |
|
2043 NULL, |
|
2044 g_cclosure_marshal_VOID__STRING, |
|
2045 G_TYPE_NONE, 1, |
|
2046 G_TYPE_STRING); |
|
2047 |
|
2048 /** |
|
2049 * WebKitWebView::icon-loaded: |
|
2050 * @web_view: the object on which the signal is emitted |
|
2051 * @icon_uri: the URI for the icon |
|
2052 * |
|
2053 * This signal is emitted when the main frame has got a favicon. |
|
2054 * |
|
2055 * Since: 1.1.18 |
|
2056 */ |
|
2057 webkit_web_view_signals[ICON_LOADED] = g_signal_new("icon-loaded", |
|
2058 G_TYPE_FROM_CLASS(webViewClass), |
|
2059 (GSignalFlags)G_SIGNAL_RUN_LAST, |
|
2060 0, |
|
2061 NULL, |
|
2062 NULL, |
|
2063 g_cclosure_marshal_VOID__STRING, |
|
2064 G_TYPE_NONE, 1, |
|
2065 G_TYPE_STRING); |
|
2066 |
|
2067 webkit_web_view_signals[SELECTION_CHANGED] = g_signal_new("selection-changed", |
|
2068 G_TYPE_FROM_CLASS(webViewClass), |
|
2069 (GSignalFlags)G_SIGNAL_RUN_LAST, |
|
2070 0, |
|
2071 NULL, |
|
2072 NULL, |
|
2073 g_cclosure_marshal_VOID__VOID, |
|
2074 G_TYPE_NONE, 0); |
|
2075 |
|
2076 /** |
|
2077 * WebKitWebView::console-message: |
|
2078 * @web_view: the object on which the signal is emitted |
|
2079 * @message: the message text |
|
2080 * @line: the line where the error occured |
|
2081 * @source_id: the source id |
|
2082 * |
|
2083 * A JavaScript console message was created. |
|
2084 * |
|
2085 * Return value: %TRUE to stop other handlers from being invoked for the |
|
2086 * event. %FALSE to propagate the event further. |
|
2087 */ |
|
2088 webkit_web_view_signals[CONSOLE_MESSAGE] = g_signal_new("console-message", |
|
2089 G_TYPE_FROM_CLASS(webViewClass), |
|
2090 (GSignalFlags)G_SIGNAL_RUN_LAST, |
|
2091 G_STRUCT_OFFSET(WebKitWebViewClass, console_message), |
|
2092 g_signal_accumulator_true_handled, |
|
2093 NULL, |
|
2094 webkit_marshal_BOOLEAN__STRING_INT_STRING, |
|
2095 G_TYPE_BOOLEAN, 3, |
|
2096 G_TYPE_STRING, G_TYPE_INT, G_TYPE_STRING); |
|
2097 |
|
2098 /** |
|
2099 * WebKitWebView::script-alert: |
|
2100 * @web_view: the object on which the signal is emitted |
|
2101 * @frame: the relevant frame |
|
2102 * @message: the message text |
|
2103 * |
|
2104 * A JavaScript alert dialog was created. |
|
2105 * |
|
2106 * Return value: %TRUE to stop other handlers from being invoked for the |
|
2107 * event. %FALSE to propagate the event further. |
|
2108 */ |
|
2109 webkit_web_view_signals[SCRIPT_ALERT] = g_signal_new("script-alert", |
|
2110 G_TYPE_FROM_CLASS(webViewClass), |
|
2111 (GSignalFlags)G_SIGNAL_RUN_LAST, |
|
2112 G_STRUCT_OFFSET(WebKitWebViewClass, script_alert), |
|
2113 g_signal_accumulator_true_handled, |
|
2114 NULL, |
|
2115 webkit_marshal_BOOLEAN__OBJECT_STRING, |
|
2116 G_TYPE_BOOLEAN, 2, |
|
2117 WEBKIT_TYPE_WEB_FRAME, G_TYPE_STRING); |
|
2118 |
|
2119 /** |
|
2120 * WebKitWebView::script-confirm: |
|
2121 * @web_view: the object on which the signal is emitted |
|
2122 * @frame: the relevant frame |
|
2123 * @message: the message text |
|
2124 * @confirmed: whether the dialog has been confirmed |
|
2125 * |
|
2126 * A JavaScript confirm dialog was created, providing Yes and No buttons. |
|
2127 * |
|
2128 * Return value: %TRUE to stop other handlers from being invoked for the |
|
2129 * event. %FALSE to propagate the event further. |
|
2130 */ |
|
2131 webkit_web_view_signals[SCRIPT_CONFIRM] = g_signal_new("script-confirm", |
|
2132 G_TYPE_FROM_CLASS(webViewClass), |
|
2133 (GSignalFlags)G_SIGNAL_RUN_LAST, |
|
2134 G_STRUCT_OFFSET(WebKitWebViewClass, script_confirm), |
|
2135 g_signal_accumulator_true_handled, |
|
2136 NULL, |
|
2137 webkit_marshal_BOOLEAN__OBJECT_STRING_POINTER, |
|
2138 G_TYPE_BOOLEAN, 3, |
|
2139 WEBKIT_TYPE_WEB_FRAME, G_TYPE_STRING, G_TYPE_POINTER); |
|
2140 |
|
2141 /** |
|
2142 * WebKitWebView::script-prompt: |
|
2143 * @web_view: the object on which the signal is emitted |
|
2144 * @frame: the relevant frame |
|
2145 * @message: the message text |
|
2146 * @default: the default value |
|
2147 * @text: To be filled with the return value or NULL if the dialog was cancelled. |
|
2148 * |
|
2149 * A JavaScript prompt dialog was created, providing an entry to input text. |
|
2150 * |
|
2151 * Return value: %TRUE to stop other handlers from being invoked for the |
|
2152 * event. %FALSE to propagate the event further. |
|
2153 */ |
|
2154 webkit_web_view_signals[SCRIPT_PROMPT] = g_signal_new("script-prompt", |
|
2155 G_TYPE_FROM_CLASS(webViewClass), |
|
2156 (GSignalFlags)G_SIGNAL_RUN_LAST, |
|
2157 G_STRUCT_OFFSET(WebKitWebViewClass, script_prompt), |
|
2158 g_signal_accumulator_true_handled, |
|
2159 NULL, |
|
2160 webkit_marshal_BOOLEAN__OBJECT_STRING_STRING_STRING, |
|
2161 G_TYPE_BOOLEAN, 4, |
|
2162 WEBKIT_TYPE_WEB_FRAME, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_POINTER); |
|
2163 |
|
2164 /** |
|
2165 * WebKitWebView::select-all: |
|
2166 * @web_view: the object which received the signal |
|
2167 * |
|
2168 * The #WebKitWebView::select-all signal is a keybinding signal which gets emitted to |
|
2169 * select the complete contents of the text view. |
|
2170 * |
|
2171 * The default bindings for this signal is Ctrl-a. |
|
2172 */ |
|
2173 webkit_web_view_signals[SELECT_ALL] = g_signal_new("select-all", |
|
2174 G_TYPE_FROM_CLASS(webViewClass), |
|
2175 (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION), |
|
2176 G_STRUCT_OFFSET(WebKitWebViewClass, select_all), |
|
2177 NULL, NULL, |
|
2178 g_cclosure_marshal_VOID__VOID, |
|
2179 G_TYPE_NONE, 0); |
|
2180 |
|
2181 /** |
|
2182 * WebKitWebView::cut-clipboard: |
|
2183 * @web_view: the object which received the signal |
|
2184 * |
|
2185 * The #WebKitWebView::cut-clipboard signal is a keybinding signal which gets emitted to |
|
2186 * cut the selection to the clipboard. |
|
2187 * |
|
2188 * The default bindings for this signal are Ctrl-x and Shift-Delete. |
|
2189 */ |
|
2190 webkit_web_view_signals[CUT_CLIPBOARD] = g_signal_new("cut-clipboard", |
|
2191 G_TYPE_FROM_CLASS(webViewClass), |
|
2192 (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION), |
|
2193 G_STRUCT_OFFSET(WebKitWebViewClass, cut_clipboard), |
|
2194 NULL, NULL, |
|
2195 g_cclosure_marshal_VOID__VOID, |
|
2196 G_TYPE_NONE, 0); |
|
2197 |
|
2198 /** |
|
2199 * WebKitWebView::copy-clipboard: |
|
2200 * @web_view: the object which received the signal |
|
2201 * |
|
2202 * The #WebKitWebView::copy-clipboard signal is a keybinding signal which gets emitted to |
|
2203 * copy the selection to the clipboard. |
|
2204 * |
|
2205 * The default bindings for this signal are Ctrl-c and Ctrl-Insert. |
|
2206 */ |
|
2207 webkit_web_view_signals[COPY_CLIPBOARD] = g_signal_new("copy-clipboard", |
|
2208 G_TYPE_FROM_CLASS(webViewClass), |
|
2209 (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION), |
|
2210 G_STRUCT_OFFSET(WebKitWebViewClass, copy_clipboard), |
|
2211 NULL, NULL, |
|
2212 g_cclosure_marshal_VOID__VOID, |
|
2213 G_TYPE_NONE, 0); |
|
2214 |
|
2215 /** |
|
2216 * WebKitWebView::paste-clipboard: |
|
2217 * @web_view: the object which received the signal |
|
2218 * |
|
2219 * The #WebKitWebView::paste-clipboard signal is a keybinding signal which gets emitted to |
|
2220 * paste the contents of the clipboard into the Web view. |
|
2221 * |
|
2222 * The default bindings for this signal are Ctrl-v and Shift-Insert. |
|
2223 */ |
|
2224 webkit_web_view_signals[PASTE_CLIPBOARD] = g_signal_new("paste-clipboard", |
|
2225 G_TYPE_FROM_CLASS(webViewClass), |
|
2226 (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION), |
|
2227 G_STRUCT_OFFSET(WebKitWebViewClass, paste_clipboard), |
|
2228 NULL, NULL, |
|
2229 g_cclosure_marshal_VOID__VOID, |
|
2230 G_TYPE_NONE, 0); |
|
2231 |
|
2232 /** |
|
2233 * WebKitWebView::undo |
|
2234 * @web_view: the object which received the signal |
|
2235 * |
|
2236 * The #WebKitWebView::undo signal is a keybinding signal which gets emitted to |
|
2237 * undo the last editing command. |
|
2238 * |
|
2239 * The default binding for this signal is Ctrl-z |
|
2240 * |
|
2241 * Since: 1.1.14 |
|
2242 */ |
|
2243 webkit_web_view_signals[UNDO] = g_signal_new("undo", |
|
2244 G_TYPE_FROM_CLASS(webViewClass), |
|
2245 (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION), |
|
2246 G_STRUCT_OFFSET(WebKitWebViewClass, undo), |
|
2247 NULL, NULL, |
|
2248 g_cclosure_marshal_VOID__VOID, |
|
2249 G_TYPE_NONE, 0); |
|
2250 |
|
2251 /** |
|
2252 * WebKitWebView::redo |
|
2253 * @web_view: the object which received the signal |
|
2254 * |
|
2255 * The #WebKitWebView::redo signal is a keybinding signal which gets emitted to |
|
2256 * redo the last editing command. |
|
2257 * |
|
2258 * The default binding for this signal is Ctrl-Shift-z |
|
2259 * |
|
2260 * Since: 1.1.14 |
|
2261 */ |
|
2262 webkit_web_view_signals[REDO] = g_signal_new("redo", |
|
2263 G_TYPE_FROM_CLASS(webViewClass), |
|
2264 (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION), |
|
2265 G_STRUCT_OFFSET(WebKitWebViewClass, redo), |
|
2266 NULL, NULL, |
|
2267 g_cclosure_marshal_VOID__VOID, |
|
2268 G_TYPE_NONE, 0); |
|
2269 |
|
2270 /** |
|
2271 * WebKitWebView::move-cursor: |
|
2272 * @web_view: the object which received the signal |
|
2273 * @step: the type of movement, one of #GtkMovementStep |
|
2274 * @count: an integer indicating the subtype of movement. Currently |
|
2275 * the permitted values are '1' = forward, '-1' = backwards. |
|
2276 * |
|
2277 * The #WebKitWebView::move-cursor will be emitted to apply the |
|
2278 * cursor movement described by its parameters to the @view. |
|
2279 * |
|
2280 * Return value: %TRUE or %FALSE |
|
2281 * |
|
2282 * Since: 1.1.4 |
|
2283 */ |
|
2284 webkit_web_view_signals[MOVE_CURSOR] = g_signal_new("move-cursor", |
|
2285 G_TYPE_FROM_CLASS(webViewClass), |
|
2286 (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION), |
|
2287 G_STRUCT_OFFSET(WebKitWebViewClass, move_cursor), |
|
2288 NULL, NULL, |
|
2289 webkit_marshal_BOOLEAN__ENUM_INT, |
|
2290 G_TYPE_BOOLEAN, 2, |
|
2291 GTK_TYPE_MOVEMENT_STEP, |
|
2292 G_TYPE_INT); |
|
2293 |
|
2294 /** |
|
2295 * WebKitWebView::create-plugin-widget: |
|
2296 * @web_view: the object which received the signal |
|
2297 * @mime_type: the mimetype of the requested object |
|
2298 * @uri: the URI to load |
|
2299 * @param: a #GHashTable with additional attributes (strings) |
|
2300 * |
|
2301 * The #WebKitWebView::create-plugin-widget signal will be emitted to |
|
2302 * create a plugin widget for embed or object HTML tags. This |
|
2303 * allows to embed a GtkWidget as a plugin into HTML content. In |
|
2304 * case of a textual selection of the GtkWidget WebCore will attempt |
|
2305 * to set the property value of "webkit-widget-is-selected". This can |
|
2306 * be used to draw a visual indicator of the selection. |
|
2307 * |
|
2308 * Return value: a new #GtkWidget, or %NULL |
|
2309 * |
|
2310 * Since: 1.1.8 |
|
2311 */ |
|
2312 webkit_web_view_signals[PLUGIN_WIDGET] = g_signal_new("create-plugin-widget", |
|
2313 G_TYPE_FROM_CLASS(webViewClass), |
|
2314 (GSignalFlags) (G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION), |
|
2315 0, |
|
2316 webkit_signal_accumulator_object_handled, |
|
2317 NULL, |
|
2318 webkit_marshal_OBJECT__STRING_STRING_POINTER, |
|
2319 GTK_TYPE_WIDGET, 3, |
|
2320 G_TYPE_STRING, G_TYPE_STRING, G_TYPE_HASH_TABLE); |
|
2321 |
|
2322 /** |
|
2323 * WebKitWebView::database-quota-exceeded |
|
2324 * @web_view: the object which received the signal |
|
2325 * @frame: the relevant frame |
|
2326 * @database: the #WebKitWebDatabase which exceeded the quota of its #WebKitSecurityOrigin |
|
2327 * |
|
2328 * The #WebKitWebView::database-quota-exceeded signal will be emitted when |
|
2329 * a Web Database exceeds the quota of its security origin. This signal |
|
2330 * may be used to increase the size of the quota before the originating |
|
2331 * operation fails. |
|
2332 * |
|
2333 * Since: 1.1.14 |
|
2334 */ |
|
2335 webkit_web_view_signals[DATABASE_QUOTA_EXCEEDED] = g_signal_new("database-quota-exceeded", |
|
2336 G_TYPE_FROM_CLASS(webViewClass), |
|
2337 (GSignalFlags) (G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION), |
|
2338 0, |
|
2339 NULL, NULL, |
|
2340 webkit_marshal_VOID__OBJECT_OBJECT, |
|
2341 G_TYPE_NONE, 2, |
|
2342 G_TYPE_OBJECT, G_TYPE_OBJECT); |
|
2343 |
|
2344 /** |
|
2345 * WebKitWebView::resource-request-starting: |
|
2346 * @web_view: the object which received the signal |
|
2347 * @web_frame: the #WebKitWebFrame whose load dispatched this request |
|
2348 * @web_resource: an empty #WebKitWebResource object |
|
2349 * @request: the #WebKitNetworkRequest that will be dispatched |
|
2350 * @response: the #WebKitNetworkResponse representing the redirect |
|
2351 * response, if any |
|
2352 * |
|
2353 * Emitted when a request is about to be sent. You can modify the |
|
2354 * request while handling this signal. You can set the URI in the |
|
2355 * #WebKitNetworkRequest object itself, and add/remove/replace |
|
2356 * headers using the #SoupMessage object it carries, if it is |
|
2357 * present. See webkit_network_request_get_message(). Setting the |
|
2358 * request URI to "about:blank" will effectively cause the request |
|
2359 * to load nothing, and can be used to disable the loading of |
|
2360 * specific resources. |
|
2361 * |
|
2362 * Notice that information about an eventual redirect is available |
|
2363 * in @response's #SoupMessage, not in the #SoupMessage carried by |
|
2364 * the @request. If @response is %NULL, then this is not a |
|
2365 * redirected request. |
|
2366 * |
|
2367 * The #WebKitWebResource object will be the same throughout all |
|
2368 * the lifetime of the resource, but the contents may change from |
|
2369 * inbetween signal emissions. |
|
2370 * |
|
2371 * Since: 1.1.14 |
|
2372 */ |
|
2373 webkit_web_view_signals[RESOURCE_REQUEST_STARTING] = g_signal_new("resource-request-starting", |
|
2374 G_TYPE_FROM_CLASS(webViewClass), |
|
2375 (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION), |
|
2376 0, |
|
2377 NULL, NULL, |
|
2378 webkit_marshal_VOID__OBJECT_OBJECT_OBJECT_OBJECT, |
|
2379 G_TYPE_NONE, 4, |
|
2380 WEBKIT_TYPE_WEB_FRAME, |
|
2381 WEBKIT_TYPE_WEB_RESOURCE, |
|
2382 WEBKIT_TYPE_NETWORK_REQUEST, |
|
2383 WEBKIT_TYPE_NETWORK_RESPONSE); |
|
2384 |
|
2385 /** |
|
2386 * WebKitWebView::geolocation-policy-decision-requested: |
|
2387 * @web_view: the object on which the signal is emitted |
|
2388 * @frame: the frame that requests permission |
|
2389 * @policy_decision: a WebKitGeolocationPolicyDecision |
|
2390 * |
|
2391 * When a @frame wants to get its geolocation permission. |
|
2392 * The receiver must reply with a boolean wether it handled or not the |
|
2393 * request. If the request is not handled, default behaviour is to deny |
|
2394 * geolocation. |
|
2395 * |
|
2396 * Since: 1.1.23 |
|
2397 */ |
|
2398 webkit_web_view_signals[GEOLOCATION_POLICY_DECISION_REQUESTED] = g_signal_new("geolocation-policy-decision-requested", |
|
2399 G_TYPE_FROM_CLASS(webViewClass), |
|
2400 (GSignalFlags)(G_SIGNAL_RUN_LAST), |
|
2401 0, |
|
2402 NULL, NULL, |
|
2403 webkit_marshal_BOOLEAN__OBJECT_OBJECT, |
|
2404 G_TYPE_BOOLEAN, 2, |
|
2405 WEBKIT_TYPE_WEB_FRAME, |
|
2406 WEBKIT_TYPE_GEOLOCATION_POLICY_DECISION); |
|
2407 |
|
2408 /** |
|
2409 * WebKitWebView::geolocation-policy-decision-cancelled: |
|
2410 * @web_view: the object on which the signal is emitted |
|
2411 * @frame: the frame that cancels geolocation request. |
|
2412 * |
|
2413 * When a @frame wants to cancel geolocation permission it had requested |
|
2414 * before. |
|
2415 * |
|
2416 * Since: 1.1.23 |
|
2417 */ |
|
2418 webkit_web_view_signals[GEOLOCATION_POLICY_DECISION_CANCELLED] = g_signal_new("geolocation-policy-decision-cancelled", |
|
2419 G_TYPE_FROM_CLASS(webViewClass), |
|
2420 (GSignalFlags)(G_SIGNAL_RUN_LAST), |
|
2421 0, |
|
2422 NULL, NULL, |
|
2423 g_cclosure_marshal_VOID__OBJECT, |
|
2424 G_TYPE_NONE, 1, |
|
2425 WEBKIT_TYPE_WEB_FRAME); |
|
2426 |
|
2427 /* |
|
2428 * DOM-related signals. These signals are experimental, for now, |
|
2429 * and may change API and ABI. Their comments lack one * on |
|
2430 * purpose, to make them not be catched by gtk-doc. |
|
2431 */ |
|
2432 |
|
2433 /* |
|
2434 * WebKitWebView::document-load-finished |
|
2435 * @web_view: the object which received the signal |
|
2436 * @web_frame: the #WebKitWebFrame whose load dispatched this request |
|
2437 * |
|
2438 * Emitted when the DOM document object load is finished for the |
|
2439 * given frame. |
|
2440 */ |
|
2441 webkit_web_view_signals[DOCUMENT_LOAD_FINISHED] = g_signal_new("document-load-finished", |
|
2442 G_TYPE_FROM_CLASS(webViewClass), |
|
2443 (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION), |
|
2444 0, |
|
2445 NULL, NULL, |
|
2446 g_cclosure_marshal_VOID__OBJECT, |
|
2447 G_TYPE_NONE, 1, |
|
2448 WEBKIT_TYPE_WEB_FRAME); |
|
2449 |
|
2450 |
|
2451 /* |
|
2452 * implementations of virtual methods |
|
2453 */ |
|
2454 webViewClass->create_web_view = webkit_web_view_real_create_web_view; |
|
2455 webViewClass->web_view_ready = webkit_web_view_real_web_view_ready; |
|
2456 webViewClass->close_web_view = webkit_web_view_real_close_web_view; |
|
2457 webViewClass->navigation_requested = webkit_web_view_real_navigation_requested; |
|
2458 webViewClass->window_object_cleared = webkit_web_view_real_window_object_cleared; |
|
2459 webViewClass->choose_file = webkit_web_view_real_choose_file; |
|
2460 webViewClass->script_alert = webkit_web_view_real_script_alert; |
|
2461 webViewClass->script_confirm = webkit_web_view_real_script_confirm; |
|
2462 webViewClass->script_prompt = webkit_web_view_real_script_prompt; |
|
2463 webViewClass->console_message = webkit_web_view_real_console_message; |
|
2464 webViewClass->select_all = webkit_web_view_real_select_all; |
|
2465 webViewClass->cut_clipboard = webkit_web_view_real_cut_clipboard; |
|
2466 webViewClass->copy_clipboard = webkit_web_view_real_copy_clipboard; |
|
2467 webViewClass->paste_clipboard = webkit_web_view_real_paste_clipboard; |
|
2468 webViewClass->undo = webkit_web_view_real_undo; |
|
2469 webViewClass->redo = webkit_web_view_real_redo; |
|
2470 webViewClass->move_cursor = webkit_web_view_real_move_cursor; |
|
2471 |
|
2472 GObjectClass* objectClass = G_OBJECT_CLASS(webViewClass); |
|
2473 objectClass->dispose = webkit_web_view_dispose; |
|
2474 objectClass->finalize = webkit_web_view_finalize; |
|
2475 objectClass->get_property = webkit_web_view_get_property; |
|
2476 objectClass->set_property = webkit_web_view_set_property; |
|
2477 |
|
2478 GtkWidgetClass* widgetClass = GTK_WIDGET_CLASS(webViewClass); |
|
2479 widgetClass->realize = webkit_web_view_realize; |
|
2480 widgetClass->expose_event = webkit_web_view_expose_event; |
|
2481 widgetClass->key_press_event = webkit_web_view_key_press_event; |
|
2482 widgetClass->key_release_event = webkit_web_view_key_release_event; |
|
2483 widgetClass->button_press_event = webkit_web_view_button_press_event; |
|
2484 widgetClass->button_release_event = webkit_web_view_button_release_event; |
|
2485 widgetClass->motion_notify_event = webkit_web_view_motion_event; |
|
2486 widgetClass->scroll_event = webkit_web_view_scroll_event; |
|
2487 widgetClass->size_allocate = webkit_web_view_size_allocate; |
|
2488 widgetClass->size_request = webkit_web_view_size_request; |
|
2489 widgetClass->popup_menu = webkit_web_view_popup_menu_handler; |
|
2490 widgetClass->grab_focus = webkit_web_view_grab_focus; |
|
2491 widgetClass->focus_in_event = webkit_web_view_focus_in_event; |
|
2492 widgetClass->focus_out_event = webkit_web_view_focus_out_event; |
|
2493 widgetClass->get_accessible = webkit_web_view_get_accessible; |
|
2494 widgetClass->screen_changed = webkit_web_view_screen_changed; |
|
2495 widgetClass->drag_end = webkit_web_view_drag_end; |
|
2496 widgetClass->drag_data_get = webkit_web_view_drag_data_get; |
|
2497 widgetClass->drag_motion = webkit_web_view_drag_motion; |
|
2498 widgetClass->drag_leave = webkit_web_view_drag_leave; |
|
2499 widgetClass->drag_drop = webkit_web_view_drag_drop; |
|
2500 widgetClass->drag_data_received = webkit_web_view_drag_data_received; |
|
2501 #if GTK_CHECK_VERSION(2, 12, 0) |
|
2502 widgetClass->query_tooltip = webkit_web_view_query_tooltip; |
|
2503 #endif |
|
2504 |
|
2505 GtkContainerClass* containerClass = GTK_CONTAINER_CLASS(webViewClass); |
|
2506 containerClass->add = webkit_web_view_container_add; |
|
2507 containerClass->remove = webkit_web_view_container_remove; |
|
2508 containerClass->forall = webkit_web_view_container_forall; |
|
2509 |
|
2510 /* |
|
2511 * make us scrollable (e.g. addable to a GtkScrolledWindow) |
|
2512 */ |
|
2513 webViewClass->set_scroll_adjustments = webkit_web_view_set_scroll_adjustments; |
|
2514 GTK_WIDGET_CLASS(webViewClass)->set_scroll_adjustments_signal = g_signal_new("set-scroll-adjustments", |
|
2515 G_TYPE_FROM_CLASS(webViewClass), |
|
2516 (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION), |
|
2517 G_STRUCT_OFFSET(WebKitWebViewClass, set_scroll_adjustments), |
|
2518 NULL, NULL, |
|
2519 webkit_marshal_VOID__OBJECT_OBJECT, |
|
2520 G_TYPE_NONE, 2, |
|
2521 GTK_TYPE_ADJUSTMENT, GTK_TYPE_ADJUSTMENT); |
|
2522 |
|
2523 /* |
|
2524 * Key bindings |
|
2525 */ |
|
2526 |
|
2527 binding_set = gtk_binding_set_by_class(webViewClass); |
|
2528 |
|
2529 gtk_binding_entry_add_signal(binding_set, GDK_a, GDK_CONTROL_MASK, |
|
2530 "select_all", 0); |
|
2531 |
|
2532 /* Cut/copy/paste */ |
|
2533 |
|
2534 gtk_binding_entry_add_signal(binding_set, GDK_x, GDK_CONTROL_MASK, |
|
2535 "cut_clipboard", 0); |
|
2536 gtk_binding_entry_add_signal(binding_set, GDK_c, GDK_CONTROL_MASK, |
|
2537 "copy_clipboard", 0); |
|
2538 gtk_binding_entry_add_signal(binding_set, GDK_v, GDK_CONTROL_MASK, |
|
2539 "paste_clipboard", 0); |
|
2540 gtk_binding_entry_add_signal(binding_set, GDK_z, GDK_CONTROL_MASK, |
|
2541 "undo", 0); |
|
2542 gtk_binding_entry_add_signal(binding_set, GDK_z, static_cast<GdkModifierType>(GDK_CONTROL_MASK | GDK_SHIFT_MASK), |
|
2543 "redo", 0); |
|
2544 |
|
2545 gtk_binding_entry_add_signal(binding_set, GDK_Delete, GDK_SHIFT_MASK, |
|
2546 "cut_clipboard", 0); |
|
2547 gtk_binding_entry_add_signal(binding_set, GDK_Insert, GDK_CONTROL_MASK, |
|
2548 "copy_clipboard", 0); |
|
2549 gtk_binding_entry_add_signal(binding_set, GDK_Insert, GDK_SHIFT_MASK, |
|
2550 "paste_clipboard", 0); |
|
2551 |
|
2552 /* Movement */ |
|
2553 |
|
2554 gtk_binding_entry_add_signal(binding_set, GDK_Down, static_cast<GdkModifierType>(0), |
|
2555 "move-cursor", 2, |
|
2556 G_TYPE_ENUM, GTK_MOVEMENT_DISPLAY_LINES, |
|
2557 G_TYPE_INT, 1); |
|
2558 gtk_binding_entry_add_signal(binding_set, GDK_Up, static_cast<GdkModifierType>(0), |
|
2559 "move-cursor", 2, |
|
2560 G_TYPE_ENUM, GTK_MOVEMENT_DISPLAY_LINES, |
|
2561 G_TYPE_INT, -1); |
|
2562 gtk_binding_entry_add_signal(binding_set, GDK_Right, static_cast<GdkModifierType>(0), |
|
2563 "move-cursor", 2, |
|
2564 G_TYPE_ENUM, GTK_MOVEMENT_VISUAL_POSITIONS, |
|
2565 G_TYPE_INT, 1); |
|
2566 gtk_binding_entry_add_signal(binding_set, GDK_Left, static_cast<GdkModifierType>(0), |
|
2567 "move-cursor", 2, |
|
2568 G_TYPE_ENUM, GTK_MOVEMENT_VISUAL_POSITIONS, |
|
2569 G_TYPE_INT, -1); |
|
2570 gtk_binding_entry_add_signal(binding_set, GDK_space, static_cast<GdkModifierType>(0), |
|
2571 "move-cursor", 2, |
|
2572 G_TYPE_ENUM, GTK_MOVEMENT_PAGES, |
|
2573 G_TYPE_INT, 1); |
|
2574 gtk_binding_entry_add_signal(binding_set, GDK_space, GDK_SHIFT_MASK, |
|
2575 "move-cursor", 2, |
|
2576 G_TYPE_ENUM, GTK_MOVEMENT_PAGES, |
|
2577 G_TYPE_INT, -1); |
|
2578 gtk_binding_entry_add_signal(binding_set, GDK_Page_Down, static_cast<GdkModifierType>(0), |
|
2579 "move-cursor", 2, |
|
2580 G_TYPE_ENUM, GTK_MOVEMENT_PAGES, |
|
2581 G_TYPE_INT, 1); |
|
2582 gtk_binding_entry_add_signal(binding_set, GDK_Page_Up, static_cast<GdkModifierType>(0), |
|
2583 "move-cursor", 2, |
|
2584 G_TYPE_ENUM, GTK_MOVEMENT_PAGES, |
|
2585 G_TYPE_INT, -1); |
|
2586 gtk_binding_entry_add_signal(binding_set, GDK_End, static_cast<GdkModifierType>(0), |
|
2587 "move-cursor", 2, |
|
2588 G_TYPE_ENUM, GTK_MOVEMENT_BUFFER_ENDS, |
|
2589 G_TYPE_INT, 1); |
|
2590 gtk_binding_entry_add_signal(binding_set, GDK_Home, static_cast<GdkModifierType>(0), |
|
2591 "move-cursor", 2, |
|
2592 G_TYPE_ENUM, GTK_MOVEMENT_BUFFER_ENDS, |
|
2593 G_TYPE_INT, -1); |
|
2594 |
|
2595 /* |
|
2596 * properties |
|
2597 */ |
|
2598 |
|
2599 /** |
|
2600 * WebKitWebView:title: |
|
2601 * |
|
2602 * Returns the @web_view's document title. |
|
2603 * |
|
2604 * Since: 1.1.4 |
|
2605 */ |
|
2606 g_object_class_install_property(objectClass, PROP_TITLE, |
|
2607 g_param_spec_string("title", |
|
2608 _("Title"), |
|
2609 _("Returns the @web_view's document title"), |
|
2610 NULL, |
|
2611 WEBKIT_PARAM_READABLE)); |
|
2612 |
|
2613 /** |
|
2614 * WebKitWebView:uri: |
|
2615 * |
|
2616 * Returns the current URI of the contents displayed by the @web_view. |
|
2617 * |
|
2618 * Since: 1.1.4 |
|
2619 */ |
|
2620 g_object_class_install_property(objectClass, PROP_URI, |
|
2621 g_param_spec_string("uri", |
|
2622 _("URI"), |
|
2623 _("Returns the current URI of the contents displayed by the @web_view"), |
|
2624 NULL, |
|
2625 WEBKIT_PARAM_READABLE)); |
|
2626 |
|
2627 /** |
|
2628 * WebKitWebView:copy-target-list: |
|
2629 * |
|
2630 * The list of targets this web view supports for clipboard copying. |
|
2631 * |
|
2632 * Since: 1.0.2 |
|
2633 */ |
|
2634 g_object_class_install_property(objectClass, PROP_COPY_TARGET_LIST, |
|
2635 g_param_spec_boxed("copy-target-list", |
|
2636 _("Copy target list"), |
|
2637 _("The list of targets this web view supports for clipboard copying"), |
|
2638 GTK_TYPE_TARGET_LIST, |
|
2639 WEBKIT_PARAM_READABLE)); |
|
2640 |
|
2641 /** |
|
2642 * WebKitWebView:paste-target-list: |
|
2643 * |
|
2644 * The list of targets this web view supports for clipboard pasting. |
|
2645 * |
|
2646 * Since: 1.0.2 |
|
2647 */ |
|
2648 g_object_class_install_property(objectClass, PROP_PASTE_TARGET_LIST, |
|
2649 g_param_spec_boxed("paste-target-list", |
|
2650 _("Paste target list"), |
|
2651 _("The list of targets this web view supports for clipboard pasting"), |
|
2652 GTK_TYPE_TARGET_LIST, |
|
2653 WEBKIT_PARAM_READABLE)); |
|
2654 |
|
2655 g_object_class_install_property(objectClass, PROP_SETTINGS, |
|
2656 g_param_spec_object("settings", |
|
2657 _("Settings"), |
|
2658 _("An associated WebKitWebSettings instance"), |
|
2659 WEBKIT_TYPE_WEB_SETTINGS, |
|
2660 WEBKIT_PARAM_READWRITE)); |
|
2661 |
|
2662 /** |
|
2663 * WebKitWebView:web-inspector: |
|
2664 * |
|
2665 * The associated WebKitWebInspector instance. |
|
2666 * |
|
2667 * Since: 1.0.3 |
|
2668 */ |
|
2669 g_object_class_install_property(objectClass, PROP_WEB_INSPECTOR, |
|
2670 g_param_spec_object("web-inspector", |
|
2671 _("Web Inspector"), |
|
2672 _("The associated WebKitWebInspector instance"), |
|
2673 WEBKIT_TYPE_WEB_INSPECTOR, |
|
2674 WEBKIT_PARAM_READABLE)); |
|
2675 |
|
2676 /** |
|
2677 * WebKitWebView:window-features: |
|
2678 * |
|
2679 * An associated WebKitWebWindowFeatures instance. |
|
2680 * |
|
2681 * Since: 1.0.3 |
|
2682 */ |
|
2683 g_object_class_install_property(objectClass, PROP_WINDOW_FEATURES, |
|
2684 g_param_spec_object("window-features", |
|
2685 "Window Features", |
|
2686 "An associated WebKitWebWindowFeatures instance", |
|
2687 WEBKIT_TYPE_WEB_WINDOW_FEATURES, |
|
2688 WEBKIT_PARAM_READWRITE)); |
|
2689 |
|
2690 g_object_class_install_property(objectClass, PROP_EDITABLE, |
|
2691 g_param_spec_boolean("editable", |
|
2692 _("Editable"), |
|
2693 _("Whether content can be modified by the user"), |
|
2694 FALSE, |
|
2695 WEBKIT_PARAM_READWRITE)); |
|
2696 |
|
2697 g_object_class_install_property(objectClass, PROP_TRANSPARENT, |
|
2698 g_param_spec_boolean("transparent", |
|
2699 _("Transparent"), |
|
2700 _("Whether content has a transparent background"), |
|
2701 FALSE, |
|
2702 WEBKIT_PARAM_READWRITE)); |
|
2703 |
|
2704 /** |
|
2705 * WebKitWebView:zoom-level: |
|
2706 * |
|
2707 * The level of zoom of the content. |
|
2708 * |
|
2709 * Since: 1.0.1 |
|
2710 */ |
|
2711 g_object_class_install_property(objectClass, PROP_ZOOM_LEVEL, |
|
2712 g_param_spec_float("zoom-level", |
|
2713 _("Zoom level"), |
|
2714 _("The level of zoom of the content"), |
|
2715 G_MINFLOAT, |
|
2716 G_MAXFLOAT, |
|
2717 1.0f, |
|
2718 WEBKIT_PARAM_READWRITE)); |
|
2719 |
|
2720 /** |
|
2721 * WebKitWebView:full-content-zoom: |
|
2722 * |
|
2723 * Whether the full content is scaled when zooming. |
|
2724 * |
|
2725 * Since: 1.0.1 |
|
2726 */ |
|
2727 g_object_class_install_property(objectClass, PROP_FULL_CONTENT_ZOOM, |
|
2728 g_param_spec_boolean("full-content-zoom", |
|
2729 _("Full content zoom"), |
|
2730 _("Whether the full content is scaled when zooming"), |
|
2731 FALSE, |
|
2732 WEBKIT_PARAM_READWRITE)); |
|
2733 |
|
2734 /** |
|
2735 * WebKitWebView:encoding: |
|
2736 * |
|
2737 * The default encoding of the web view. |
|
2738 * |
|
2739 * Since: 1.1.2 |
|
2740 */ |
|
2741 g_object_class_install_property(objectClass, PROP_ENCODING, |
|
2742 g_param_spec_string("encoding", |
|
2743 _("Encoding"), |
|
2744 _("The default encoding of the web view"), |
|
2745 NULL, |
|
2746 WEBKIT_PARAM_READABLE)); |
|
2747 |
|
2748 /** |
|
2749 * WebKitWebView:custom-encoding: |
|
2750 * |
|
2751 * The custom encoding of the web view. |
|
2752 * |
|
2753 * Since: 1.1.2 |
|
2754 */ |
|
2755 g_object_class_install_property(objectClass, PROP_CUSTOM_ENCODING, |
|
2756 g_param_spec_string("custom-encoding", |
|
2757 _("Custom Encoding"), |
|
2758 _("The custom encoding of the web view"), |
|
2759 NULL, |
|
2760 WEBKIT_PARAM_READWRITE)); |
|
2761 |
|
2762 /** |
|
2763 * WebKitWebView:load-status: |
|
2764 * |
|
2765 * Determines the current status of the load. |
|
2766 * |
|
2767 * Connect to "notify::load-status" to monitor loading. |
|
2768 * |
|
2769 * Some versions of WebKitGTK+ emitted this signal for the default |
|
2770 * error page, while loading it. This behavior was considered bad, |
|
2771 * because it was essentially exposing an implementation |
|
2772 * detail. From 1.1.19 onwards this signal is no longer emitted for |
|
2773 * the default error pages, but keep in mind that if you override |
|
2774 * the error pages by using webkit_web_frame_load_alternate_string() |
|
2775 * the signals will be emitted. |
|
2776 * |
|
2777 * Since: 1.1.7 |
|
2778 */ |
|
2779 g_object_class_install_property(objectClass, PROP_LOAD_STATUS, |
|
2780 g_param_spec_enum("load-status", |
|
2781 "Load Status", |
|
2782 "Determines the current status of the load", |
|
2783 WEBKIT_TYPE_LOAD_STATUS, |
|
2784 WEBKIT_LOAD_FINISHED, |
|
2785 WEBKIT_PARAM_READABLE)); |
|
2786 |
|
2787 /** |
|
2788 * WebKitWebView:progress: |
|
2789 * |
|
2790 * Determines the current progress of the load. |
|
2791 * |
|
2792 * Since: 1.1.7 |
|
2793 */ |
|
2794 g_object_class_install_property(objectClass, PROP_PROGRESS, |
|
2795 g_param_spec_double("progress", |
|
2796 "Progress", |
|
2797 "Determines the current progress of the load", |
|
2798 0.0, 1.0, 1.0, |
|
2799 WEBKIT_PARAM_READABLE)); |
|
2800 |
|
2801 /** |
|
2802 * WebKitWebView:icon-uri: |
|
2803 * |
|
2804 * The URI for the favicon for the #WebKitWebView. |
|
2805 * |
|
2806 * Since: 1.1.18 |
|
2807 */ |
|
2808 g_object_class_install_property(objectClass, PROP_ICON_URI, |
|
2809 g_param_spec_string("icon-uri", |
|
2810 _("Icon URI"), |
|
2811 _("The URI for the favicon for the #WebKitWebView."), |
|
2812 NULL, |
|
2813 WEBKIT_PARAM_READABLE)); |
|
2814 /** |
|
2815 * WebKitWebView:im-context: |
|
2816 * |
|
2817 * The GtkIMMulticontext for the #WebKitWebView. |
|
2818 * |
|
2819 * This is the input method context used for all text entry widgets inside |
|
2820 * the #WebKitWebView. It can be used to generate context menu items for |
|
2821 * controlling the active input method. |
|
2822 * |
|
2823 * Since: 1.1.20 |
|
2824 */ |
|
2825 g_object_class_install_property(objectClass, PROP_IM_CONTEXT, |
|
2826 g_param_spec_object("im-context", |
|
2827 "IM Context", |
|
2828 "The GtkIMMultiContext for the #WebKitWebView.", |
|
2829 GTK_TYPE_IM_CONTEXT, |
|
2830 WEBKIT_PARAM_READABLE)); |
|
2831 |
|
2832 g_type_class_add_private(webViewClass, sizeof(WebKitWebViewPrivate)); |
|
2833 } |
|
2834 |
|
2835 static void webkit_web_view_update_settings(WebKitWebView* webView) |
|
2836 { |
|
2837 WebKitWebViewPrivate* priv = webView->priv; |
|
2838 WebKitWebSettings* webSettings = priv->webSettings; |
|
2839 Settings* settings = core(webView)->settings(); |
|
2840 |
|
2841 gchar* defaultEncoding, *cursiveFontFamily, *defaultFontFamily, *fantasyFontFamily, *monospaceFontFamily, *sansSerifFontFamily, *serifFontFamily, *userStylesheetUri; |
|
2842 gboolean autoLoadImages, autoShrinkImages, printBackgrounds, |
|
2843 enableScripts, enablePlugins, enableDeveloperExtras, resizableTextAreas, |
|
2844 enablePrivateBrowsing, enableCaretBrowsing, enableHTML5Database, enableHTML5LocalStorage, |
|
2845 enableXSSAuditor, enableSpatialNavigation, javascriptCanOpenWindows, |
|
2846 javaScriptCanAccessClipboard, enableOfflineWebAppCache, |
|
2847 enableUniversalAccessFromFileURI, enableFileAccessFromFileURI, |
|
2848 enableDOMPaste, tabKeyCyclesThroughElements, |
|
2849 enableSiteSpecificQuirks, usePageCache, enableJavaApplet; |
|
2850 |
|
2851 WebKitEditingBehavior editingBehavior; |
|
2852 |
|
2853 g_object_get(webSettings, |
|
2854 "default-encoding", &defaultEncoding, |
|
2855 "cursive-font-family", &cursiveFontFamily, |
|
2856 "default-font-family", &defaultFontFamily, |
|
2857 "fantasy-font-family", &fantasyFontFamily, |
|
2858 "monospace-font-family", &monospaceFontFamily, |
|
2859 "sans-serif-font-family", &sansSerifFontFamily, |
|
2860 "serif-font-family", &serifFontFamily, |
|
2861 "auto-load-images", &autoLoadImages, |
|
2862 "auto-shrink-images", &autoShrinkImages, |
|
2863 "print-backgrounds", &printBackgrounds, |
|
2864 "enable-scripts", &enableScripts, |
|
2865 "enable-plugins", &enablePlugins, |
|
2866 "resizable-text-areas", &resizableTextAreas, |
|
2867 "user-stylesheet-uri", &userStylesheetUri, |
|
2868 "enable-developer-extras", &enableDeveloperExtras, |
|
2869 "enable-private-browsing", &enablePrivateBrowsing, |
|
2870 "enable-caret-browsing", &enableCaretBrowsing, |
|
2871 "enable-html5-database", &enableHTML5Database, |
|
2872 "enable-html5-local-storage", &enableHTML5LocalStorage, |
|
2873 "enable-xss-auditor", &enableXSSAuditor, |
|
2874 "enable-spatial-navigation", &enableSpatialNavigation, |
|
2875 "javascript-can-open-windows-automatically", &javascriptCanOpenWindows, |
|
2876 "javascript-can-access-clipboard", &javaScriptCanAccessClipboard, |
|
2877 "enable-offline-web-application-cache", &enableOfflineWebAppCache, |
|
2878 "editing-behavior", &editingBehavior, |
|
2879 "enable-universal-access-from-file-uris", &enableUniversalAccessFromFileURI, |
|
2880 "enable-file-access-from-file-uris", &enableFileAccessFromFileURI, |
|
2881 "enable-dom-paste", &enableDOMPaste, |
|
2882 "tab-key-cycles-through-elements", &tabKeyCyclesThroughElements, |
|
2883 "enable-site-specific-quirks", &enableSiteSpecificQuirks, |
|
2884 "enable-page-cache", &usePageCache, |
|
2885 "enable-java-applet", &enableJavaApplet, |
|
2886 NULL); |
|
2887 |
|
2888 settings->setDefaultTextEncodingName(defaultEncoding); |
|
2889 settings->setCursiveFontFamily(cursiveFontFamily); |
|
2890 settings->setStandardFontFamily(defaultFontFamily); |
|
2891 settings->setFantasyFontFamily(fantasyFontFamily); |
|
2892 settings->setFixedFontFamily(monospaceFontFamily); |
|
2893 settings->setSansSerifFontFamily(sansSerifFontFamily); |
|
2894 settings->setSerifFontFamily(serifFontFamily); |
|
2895 settings->setLoadsImagesAutomatically(autoLoadImages); |
|
2896 settings->setShrinksStandaloneImagesToFit(autoShrinkImages); |
|
2897 settings->setShouldPrintBackgrounds(printBackgrounds); |
|
2898 settings->setJavaScriptEnabled(enableScripts); |
|
2899 settings->setPluginsEnabled(enablePlugins); |
|
2900 settings->setTextAreasAreResizable(resizableTextAreas); |
|
2901 settings->setUserStyleSheetLocation(KURL(KURL(), userStylesheetUri)); |
|
2902 settings->setDeveloperExtrasEnabled(enableDeveloperExtras); |
|
2903 settings->setPrivateBrowsingEnabled(enablePrivateBrowsing); |
|
2904 settings->setCaretBrowsingEnabled(enableCaretBrowsing); |
|
2905 #if ENABLE(DATABASE) |
|
2906 AbstractDatabase::setIsAvailable(enableHTML5Database); |
|
2907 #endif |
|
2908 settings->setLocalStorageEnabled(enableHTML5LocalStorage); |
|
2909 settings->setXSSAuditorEnabled(enableXSSAuditor); |
|
2910 settings->setSpatialNavigationEnabled(enableSpatialNavigation); |
|
2911 settings->setJavaScriptCanOpenWindowsAutomatically(javascriptCanOpenWindows); |
|
2912 settings->setJavaScriptCanAccessClipboard(javaScriptCanAccessClipboard); |
|
2913 settings->setOfflineWebApplicationCacheEnabled(enableOfflineWebAppCache); |
|
2914 settings->setEditingBehaviorType(core(editingBehavior)); |
|
2915 settings->setAllowUniversalAccessFromFileURLs(enableUniversalAccessFromFileURI); |
|
2916 settings->setAllowFileAccessFromFileURLs(enableFileAccessFromFileURI); |
|
2917 settings->setDOMPasteAllowed(enableDOMPaste); |
|
2918 settings->setNeedsSiteSpecificQuirks(enableSiteSpecificQuirks); |
|
2919 settings->setUsesPageCache(usePageCache); |
|
2920 settings->setJavaEnabled(enableJavaApplet); |
|
2921 |
|
2922 Page* page = core(webView); |
|
2923 if (page) |
|
2924 page->setTabKeyCyclesThroughElements(tabKeyCyclesThroughElements); |
|
2925 |
|
2926 g_free(defaultEncoding); |
|
2927 g_free(cursiveFontFamily); |
|
2928 g_free(defaultFontFamily); |
|
2929 g_free(fantasyFontFamily); |
|
2930 g_free(monospaceFontFamily); |
|
2931 g_free(sansSerifFontFamily); |
|
2932 g_free(serifFontFamily); |
|
2933 g_free(userStylesheetUri); |
|
2934 |
|
2935 webkit_web_view_screen_changed(GTK_WIDGET(webView), NULL); |
|
2936 } |
|
2937 |
|
2938 static inline gint pixelsFromSize(WebKitWebView* webView, gint size) |
|
2939 { |
|
2940 gdouble DPI = webViewGetDPI(webView); |
|
2941 return size / 72.0 * DPI; |
|
2942 } |
|
2943 |
|
2944 static void webkit_web_view_settings_notify(WebKitWebSettings* webSettings, GParamSpec* pspec, WebKitWebView* webView) |
|
2945 { |
|
2946 Settings* settings = core(webView)->settings(); |
|
2947 |
|
2948 const gchar* name = g_intern_string(pspec->name); |
|
2949 GValue value = { 0, { { 0 } } }; |
|
2950 g_value_init(&value, pspec->value_type); |
|
2951 g_object_get_property(G_OBJECT(webSettings), name, &value); |
|
2952 |
|
2953 if (name == g_intern_string("default-encoding")) |
|
2954 settings->setDefaultTextEncodingName(g_value_get_string(&value)); |
|
2955 else if (name == g_intern_string("cursive-font-family")) |
|
2956 settings->setCursiveFontFamily(g_value_get_string(&value)); |
|
2957 else if (name == g_intern_string("default-font-family")) |
|
2958 settings->setStandardFontFamily(g_value_get_string(&value)); |
|
2959 else if (name == g_intern_string("fantasy-font-family")) |
|
2960 settings->setFantasyFontFamily(g_value_get_string(&value)); |
|
2961 else if (name == g_intern_string("monospace-font-family")) |
|
2962 settings->setFixedFontFamily(g_value_get_string(&value)); |
|
2963 else if (name == g_intern_string("sans-serif-font-family")) |
|
2964 settings->setSansSerifFontFamily(g_value_get_string(&value)); |
|
2965 else if (name == g_intern_string("serif-font-family")) |
|
2966 settings->setSerifFontFamily(g_value_get_string(&value)); |
|
2967 else if (name == g_intern_string("default-font-size")) |
|
2968 settings->setDefaultFontSize(pixelsFromSize(webView, g_value_get_int(&value))); |
|
2969 else if (name == g_intern_string("default-monospace-font-size")) |
|
2970 settings->setDefaultFixedFontSize(pixelsFromSize(webView, g_value_get_int(&value))); |
|
2971 else if (name == g_intern_string("minimum-font-size")) |
|
2972 settings->setMinimumFontSize(pixelsFromSize(webView, g_value_get_int(&value))); |
|
2973 else if (name == g_intern_string("minimum-logical-font-size")) |
|
2974 settings->setMinimumLogicalFontSize(pixelsFromSize(webView, g_value_get_int(&value))); |
|
2975 else if (name == g_intern_string("enforce-96-dpi")) |
|
2976 webkit_web_view_screen_changed(GTK_WIDGET(webView), NULL); |
|
2977 else if (name == g_intern_string("auto-load-images")) |
|
2978 settings->setLoadsImagesAutomatically(g_value_get_boolean(&value)); |
|
2979 else if (name == g_intern_string("auto-shrink-images")) |
|
2980 settings->setShrinksStandaloneImagesToFit(g_value_get_boolean(&value)); |
|
2981 else if (name == g_intern_string("print-backgrounds")) |
|
2982 settings->setShouldPrintBackgrounds(g_value_get_boolean(&value)); |
|
2983 else if (name == g_intern_string("enable-scripts")) |
|
2984 settings->setJavaScriptEnabled(g_value_get_boolean(&value)); |
|
2985 else if (name == g_intern_string("enable-plugins")) |
|
2986 settings->setPluginsEnabled(g_value_get_boolean(&value)); |
|
2987 else if (name == g_intern_string("resizable-text-areas")) |
|
2988 settings->setTextAreasAreResizable(g_value_get_boolean(&value)); |
|
2989 else if (name == g_intern_string("user-stylesheet-uri")) |
|
2990 settings->setUserStyleSheetLocation(KURL(KURL(), g_value_get_string(&value))); |
|
2991 else if (name == g_intern_string("enable-developer-extras")) |
|
2992 settings->setDeveloperExtrasEnabled(g_value_get_boolean(&value)); |
|
2993 else if (name == g_intern_string("enable-private-browsing")) |
|
2994 settings->setPrivateBrowsingEnabled(g_value_get_boolean(&value)); |
|
2995 else if (name == g_intern_string("enable-caret-browsing")) |
|
2996 settings->setCaretBrowsingEnabled(g_value_get_boolean(&value)); |
|
2997 #if ENABLE(DATABASE) |
|
2998 else if (name == g_intern_string("enable-html5-database")) { |
|
2999 AbstractDatabase::setIsAvailable(g_value_get_boolean(&value)); |
|
3000 } |
|
3001 #endif |
|
3002 else if (name == g_intern_string("enable-html5-local-storage")) |
|
3003 settings->setLocalStorageEnabled(g_value_get_boolean(&value)); |
|
3004 else if (name == g_intern_string("enable-xss-auditor")) |
|
3005 settings->setXSSAuditorEnabled(g_value_get_boolean(&value)); |
|
3006 else if (name == g_intern_string("enable-spatial-navigation")) |
|
3007 settings->setSpatialNavigationEnabled(g_value_get_boolean(&value)); |
|
3008 else if (name == g_intern_string("javascript-can-open-windows-automatically")) |
|
3009 settings->setJavaScriptCanOpenWindowsAutomatically(g_value_get_boolean(&value)); |
|
3010 else if (name == g_intern_string("javascript-can-access-clipboard")) |
|
3011 settings->setJavaScriptCanAccessClipboard(g_value_get_boolean(&value)); |
|
3012 else if (name == g_intern_string("enable-offline-web-application-cache")) |
|
3013 settings->setOfflineWebApplicationCacheEnabled(g_value_get_boolean(&value)); |
|
3014 else if (name == g_intern_string("editing-behavior")) |
|
3015 settings->setEditingBehaviorType(core(static_cast<WebKitEditingBehavior>(g_value_get_enum(&value)))); |
|
3016 else if (name == g_intern_string("enable-universal-access-from-file-uris")) |
|
3017 settings->setAllowUniversalAccessFromFileURLs(g_value_get_boolean(&value)); |
|
3018 else if (name == g_intern_string("enable-file-access-from-file-uris")) |
|
3019 settings->setAllowFileAccessFromFileURLs(g_value_get_boolean(&value)); |
|
3020 else if (name == g_intern_string("enable-dom-paste")) |
|
3021 settings->setDOMPasteAllowed(g_value_get_boolean(&value)); |
|
3022 else if (name == g_intern_string("tab-key-cycles-through-elements")) { |
|
3023 Page* page = core(webView); |
|
3024 if (page) |
|
3025 page->setTabKeyCyclesThroughElements(g_value_get_boolean(&value)); |
|
3026 } else if (name == g_intern_string("enable-site-specific-quirks")) |
|
3027 settings->setNeedsSiteSpecificQuirks(g_value_get_boolean(&value)); |
|
3028 else if (name == g_intern_string("enable-page-cache")) |
|
3029 settings->setUsesPageCache(g_value_get_boolean(&value)); |
|
3030 else if (name == g_intern_string("enable-java-applet")) |
|
3031 settings->setJavaEnabled(g_value_get_boolean(&value)); |
|
3032 else if (!g_object_class_find_property(G_OBJECT_GET_CLASS(webSettings), name)) |
|
3033 g_warning("Unexpected setting '%s'", name); |
|
3034 g_value_unset(&value); |
|
3035 } |
|
3036 |
|
3037 static void webkit_web_view_init(WebKitWebView* webView) |
|
3038 { |
|
3039 WebKitWebViewPrivate* priv = WEBKIT_WEB_VIEW_GET_PRIVATE(webView); |
|
3040 webView->priv = priv; |
|
3041 |
|
3042 priv->imContext = gtk_im_multicontext_new(); |
|
3043 |
|
3044 WebKit::InspectorClient* inspectorClient = new WebKit::InspectorClient(webView); |
|
3045 priv->corePage = new Page(new WebKit::ChromeClient(webView), new WebKit::ContextMenuClient(webView), new WebKit::EditorClient(webView), new WebKit::DragClient(webView), inspectorClient, 0, 0, 0, 0); |
|
3046 |
|
3047 // We also add a simple wrapper class to provide the public |
|
3048 // interface for the Web Inspector. |
|
3049 priv->webInspector = WEBKIT_WEB_INSPECTOR(g_object_new(WEBKIT_TYPE_WEB_INSPECTOR, NULL)); |
|
3050 webkit_web_inspector_set_inspector_client(priv->webInspector, priv->corePage); |
|
3051 |
|
3052 priv->horizontalAdjustment = GTK_ADJUSTMENT(gtk_adjustment_new(0.0, 0.0, 0.0, 0.0, 0.0, 0.0)); |
|
3053 priv->verticalAdjustment = GTK_ADJUSTMENT(gtk_adjustment_new(0.0, 0.0, 0.0, 0.0, 0.0, 0.0)); |
|
3054 |
|
3055 g_object_ref_sink(priv->horizontalAdjustment); |
|
3056 g_object_ref_sink(priv->verticalAdjustment); |
|
3057 |
|
3058 gtk_widget_set_can_focus(GTK_WIDGET(webView), TRUE); |
|
3059 priv->mainFrame = WEBKIT_WEB_FRAME(webkit_web_frame_new(webView)); |
|
3060 priv->lastPopupXPosition = priv->lastPopupYPosition = -1; |
|
3061 priv->editable = false; |
|
3062 |
|
3063 priv->backForwardList = webkit_web_back_forward_list_new_with_web_view(webView); |
|
3064 |
|
3065 priv->zoomFullContent = FALSE; |
|
3066 |
|
3067 priv->webSettings = webkit_web_settings_new(); |
|
3068 webkit_web_view_update_settings(webView); |
|
3069 g_signal_connect(priv->webSettings, "notify", G_CALLBACK(webkit_web_view_settings_notify), webView); |
|
3070 |
|
3071 priv->webWindowFeatures = webkit_web_window_features_new(); |
|
3072 |
|
3073 priv->subResources = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_object_unref); |
|
3074 |
|
3075 priv->tooltipText = 0; |
|
3076 priv->currentClickCount = 0; |
|
3077 priv->previousClickPoint = new IntPoint(0, 0); |
|
3078 priv->previousClickButton = 0; |
|
3079 priv->previousClickTime = 0; |
|
3080 |
|
3081 priv->draggingDataObjects = new HashMap<GdkDragContext*, RefPtr<WebCore::DataObjectGtk> >(); |
|
3082 priv->droppingContexts = new HashMap<GdkDragContext*, DroppingContext*>(); |
|
3083 gtk_drag_dest_set(GTK_WIDGET(webView), static_cast<GtkDestDefaults>(0), 0, 0, static_cast<GdkDragAction>(GDK_ACTION_COPY | GDK_ACTION_COPY | GDK_ACTION_MOVE | GDK_ACTION_LINK | GDK_ACTION_PRIVATE)); |
|
3084 gtk_drag_dest_set_target_list(GTK_WIDGET(webView), pasteboardHelperInstance()->targetList()); |
|
3085 } |
|
3086 |
|
3087 GtkWidget* webkit_web_view_new(void) |
|
3088 { |
|
3089 WebKitWebView* webView = WEBKIT_WEB_VIEW(g_object_new(WEBKIT_TYPE_WEB_VIEW, NULL)); |
|
3090 |
|
3091 return GTK_WIDGET(webView); |
|
3092 } |
|
3093 |
|
3094 // for internal use only |
|
3095 void webkit_web_view_notify_ready(WebKitWebView* webView) |
|
3096 { |
|
3097 g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView)); |
|
3098 |
|
3099 gboolean isHandled = FALSE; |
|
3100 g_signal_emit(webView, webkit_web_view_signals[WEB_VIEW_READY], 0, &isHandled); |
|
3101 } |
|
3102 |
|
3103 void webkit_web_view_request_download(WebKitWebView* webView, WebKitNetworkRequest* request, const ResourceResponse& response, ResourceHandle* handle) |
|
3104 { |
|
3105 g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView)); |
|
3106 |
|
3107 WebKitDownload* download; |
|
3108 |
|
3109 if (handle) |
|
3110 download = webkit_download_new_with_handle(request, handle, response); |
|
3111 else |
|
3112 download = webkit_download_new(request); |
|
3113 |
|
3114 gboolean handled; |
|
3115 g_signal_emit(webView, webkit_web_view_signals[DOWNLOAD_REQUESTED], 0, download, &handled); |
|
3116 |
|
3117 if (!handled) { |
|
3118 webkit_download_cancel(download); |
|
3119 g_object_unref(download); |
|
3120 return; |
|
3121 } |
|
3122 |
|
3123 /* Start the download now if it has a destination URI, otherwise it |
|
3124 may be handled asynchronously by the application. */ |
|
3125 if (webkit_download_get_destination_uri(download)) |
|
3126 webkit_download_start(download); |
|
3127 } |
|
3128 |
|
3129 bool webkit_web_view_use_primary_for_paste(WebKitWebView* webView) |
|
3130 { |
|
3131 return webView->priv->usePrimaryForPaste; |
|
3132 } |
|
3133 |
|
3134 void webkit_web_view_set_settings(WebKitWebView* webView, WebKitWebSettings* webSettings) |
|
3135 { |
|
3136 g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView)); |
|
3137 g_return_if_fail(WEBKIT_IS_WEB_SETTINGS(webSettings)); |
|
3138 |
|
3139 WebKitWebViewPrivate* priv = webView->priv; |
|
3140 g_signal_handlers_disconnect_by_func(priv->webSettings, (gpointer)webkit_web_view_settings_notify, webView); |
|
3141 g_object_unref(priv->webSettings); |
|
3142 g_object_ref(webSettings); |
|
3143 priv->webSettings = webSettings; |
|
3144 webkit_web_view_update_settings(webView); |
|
3145 g_signal_connect(webSettings, "notify", G_CALLBACK(webkit_web_view_settings_notify), webView); |
|
3146 g_object_notify(G_OBJECT(webView), "settings"); |
|
3147 } |
|
3148 |
|
3149 WebKitWebSettings* webkit_web_view_get_settings(WebKitWebView* webView) |
|
3150 { |
|
3151 g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), NULL); |
|
3152 |
|
3153 WebKitWebViewPrivate* priv = webView->priv; |
|
3154 return priv->webSettings; |
|
3155 } |
|
3156 |
|
3157 /** |
|
3158 * webkit_web_view_get_inspector: |
|
3159 * @web_view: a #WebKitWebView |
|
3160 * |
|
3161 * Obtains the #WebKitWebInspector associated with the |
|
3162 * #WebKitWebView. Every #WebKitWebView object has a |
|
3163 * #WebKitWebInspector object attached to it as soon as it is created, |
|
3164 * so this function will only return NULL if the argument is not a |
|
3165 * valid #WebKitWebView. |
|
3166 * |
|
3167 * Returns: the #WebKitWebInspector instance associated with the |
|
3168 * #WebKitWebView; %NULL is only returned if the argument is not a |
|
3169 * valid #WebKitWebView. |
|
3170 * |
|
3171 * Since: 1.0.3 |
|
3172 */ |
|
3173 WebKitWebInspector* webkit_web_view_get_inspector(WebKitWebView* webView) |
|
3174 { |
|
3175 g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), NULL); |
|
3176 |
|
3177 WebKitWebViewPrivate* priv = webView->priv; |
|
3178 return priv->webInspector; |
|
3179 } |
|
3180 |
|
3181 // internal |
|
3182 static void webkit_web_view_set_window_features(WebKitWebView* webView, WebKitWebWindowFeatures* webWindowFeatures) |
|
3183 { |
|
3184 WebKitWebViewPrivate* priv = webView->priv; |
|
3185 |
|
3186 if (!webWindowFeatures) |
|
3187 return; |
|
3188 |
|
3189 if (webkit_web_window_features_equal(priv->webWindowFeatures, webWindowFeatures)) |
|
3190 return; |
|
3191 |
|
3192 g_object_unref(priv->webWindowFeatures); |
|
3193 g_object_ref(webWindowFeatures); |
|
3194 priv->webWindowFeatures = webWindowFeatures; |
|
3195 } |
|
3196 |
|
3197 /** |
|
3198 * webkit_web_view_get_window_features |
|
3199 * @web_view: a #WebKitWebView |
|
3200 * |
|
3201 * Returns the instance of #WebKitWebWindowFeatures held by the given |
|
3202 * #WebKitWebView. |
|
3203 * |
|
3204 * Return value: the #WebKitWebWindowFeatures |
|
3205 * |
|
3206 * Since: 1.0.3 |
|
3207 */ |
|
3208 WebKitWebWindowFeatures* webkit_web_view_get_window_features(WebKitWebView* webView) |
|
3209 { |
|
3210 g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), NULL); |
|
3211 |
|
3212 WebKitWebViewPrivate* priv = webView->priv; |
|
3213 return priv->webWindowFeatures; |
|
3214 } |
|
3215 |
|
3216 /** |
|
3217 * webkit_web_view_get_title: |
|
3218 * @web_view: a #WebKitWebView |
|
3219 * |
|
3220 * Returns the @web_view's document title |
|
3221 * |
|
3222 * Since: 1.1.4 |
|
3223 * |
|
3224 * Return value: the title of @web_view |
|
3225 */ |
|
3226 G_CONST_RETURN gchar* webkit_web_view_get_title(WebKitWebView* webView) |
|
3227 { |
|
3228 g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), NULL); |
|
3229 |
|
3230 WebKitWebViewPrivate* priv = webView->priv; |
|
3231 return priv->mainFrame->priv->title; |
|
3232 } |
|
3233 |
|
3234 /** |
|
3235 * webkit_web_view_get_uri: |
|
3236 * @web_view: a #WebKitWebView |
|
3237 * |
|
3238 * Returns the current URI of the contents displayed by the @web_view |
|
3239 * |
|
3240 * Since: 1.1.4 |
|
3241 * |
|
3242 * Return value: the URI of @web_view |
|
3243 */ |
|
3244 G_CONST_RETURN gchar* webkit_web_view_get_uri(WebKitWebView* webView) |
|
3245 { |
|
3246 g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), NULL); |
|
3247 |
|
3248 WebKitWebViewPrivate* priv = webView->priv; |
|
3249 return priv->mainFrame->priv->uri; |
|
3250 } |
|
3251 |
|
3252 /** |
|
3253 * webkit_web_view_set_maintains_back_forward_list: |
|
3254 * @web_view: a #WebKitWebView |
|
3255 * @flag: to tell the view to maintain a back or forward list |
|
3256 * |
|
3257 * Set the view to maintain a back or forward list of history items. |
|
3258 */ |
|
3259 void webkit_web_view_set_maintains_back_forward_list(WebKitWebView* webView, gboolean flag) |
|
3260 { |
|
3261 g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView)); |
|
3262 |
|
3263 core(webView)->backForwardList()->setEnabled(flag); |
|
3264 } |
|
3265 |
|
3266 /** |
|
3267 * webkit_web_view_get_back_forward_list: |
|
3268 * @web_view: a #WebKitWebView |
|
3269 * |
|
3270 * Returns a #WebKitWebBackForwardList |
|
3271 * |
|
3272 * Return value: the #WebKitWebBackForwardList |
|
3273 */ |
|
3274 WebKitWebBackForwardList* webkit_web_view_get_back_forward_list(WebKitWebView* webView) |
|
3275 { |
|
3276 g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), NULL); |
|
3277 |
|
3278 WebKitWebViewPrivate* priv = webView->priv; |
|
3279 |
|
3280 if (!core(webView) || !core(webView)->backForwardList()->enabled()) |
|
3281 return NULL; |
|
3282 |
|
3283 return priv->backForwardList; |
|
3284 } |
|
3285 |
|
3286 /** |
|
3287 * webkit_web_view_go_to_back_forward_item: |
|
3288 * @web_view: a #WebKitWebView |
|
3289 * @item: a #WebKitWebHistoryItem* |
|
3290 * |
|
3291 * Go to the specified #WebKitWebHistoryItem |
|
3292 * |
|
3293 * Return value: %TRUE if loading of item is successful, %FALSE if not |
|
3294 */ |
|
3295 gboolean webkit_web_view_go_to_back_forward_item(WebKitWebView* webView, WebKitWebHistoryItem* item) |
|
3296 { |
|
3297 g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), FALSE); |
|
3298 g_return_val_if_fail(WEBKIT_IS_WEB_HISTORY_ITEM(item), FALSE); |
|
3299 |
|
3300 WebKitWebBackForwardList* backForwardList = webkit_web_view_get_back_forward_list(webView); |
|
3301 if (!webkit_web_back_forward_list_contains_item(backForwardList, item)) |
|
3302 return FALSE; |
|
3303 |
|
3304 core(webView)->goToItem(core(item), FrameLoadTypeIndexedBackForward); |
|
3305 return TRUE; |
|
3306 } |
|
3307 |
|
3308 /** |
|
3309 * webkit_web_view_go_back: |
|
3310 * @web_view: a #WebKitWebView |
|
3311 * |
|
3312 * Loads the previous history item. |
|
3313 */ |
|
3314 void webkit_web_view_go_back(WebKitWebView* webView) |
|
3315 { |
|
3316 g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView)); |
|
3317 |
|
3318 core(webView)->goBack(); |
|
3319 } |
|
3320 |
|
3321 /** |
|
3322 * webkit_web_view_go_back_or_forward: |
|
3323 * @web_view: a #WebKitWebView |
|
3324 * @steps: the number of steps |
|
3325 * |
|
3326 * Loads the history item that is the number of @steps away from the current |
|
3327 * item. Negative values represent steps backward while positive values |
|
3328 * represent steps forward. |
|
3329 */ |
|
3330 void webkit_web_view_go_back_or_forward(WebKitWebView* webView, gint steps) |
|
3331 { |
|
3332 g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView)); |
|
3333 |
|
3334 core(webView)->goBackOrForward(steps); |
|
3335 } |
|
3336 |
|
3337 /** |
|
3338 * webkit_web_view_go_forward: |
|
3339 * @web_view: a #WebKitWebView |
|
3340 * |
|
3341 * Loads the next history item. |
|
3342 */ |
|
3343 void webkit_web_view_go_forward(WebKitWebView* webView) |
|
3344 { |
|
3345 g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView)); |
|
3346 |
|
3347 core(webView)->goForward(); |
|
3348 } |
|
3349 |
|
3350 /** |
|
3351 * webkit_web_view_can_go_back: |
|
3352 * @web_view: a #WebKitWebView |
|
3353 * |
|
3354 * Determines whether #web_view has a previous history item. |
|
3355 * |
|
3356 * Return value: %TRUE if able to move back, %FALSE otherwise |
|
3357 */ |
|
3358 gboolean webkit_web_view_can_go_back(WebKitWebView* webView) |
|
3359 { |
|
3360 g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), FALSE); |
|
3361 |
|
3362 if (!core(webView) || !core(webView)->backForwardList()->backItem()) |
|
3363 return FALSE; |
|
3364 |
|
3365 return TRUE; |
|
3366 } |
|
3367 |
|
3368 /** |
|
3369 * webkit_web_view_can_go_back_or_forward: |
|
3370 * @web_view: a #WebKitWebView |
|
3371 * @steps: the number of steps |
|
3372 * |
|
3373 * Determines whether #web_view has a history item of @steps. Negative values |
|
3374 * represent steps backward while positive values represent steps forward. |
|
3375 * |
|
3376 * Return value: %TRUE if able to move back or forward the given number of |
|
3377 * steps, %FALSE otherwise |
|
3378 */ |
|
3379 gboolean webkit_web_view_can_go_back_or_forward(WebKitWebView* webView, gint steps) |
|
3380 { |
|
3381 g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), FALSE); |
|
3382 |
|
3383 return core(webView)->canGoBackOrForward(steps); |
|
3384 } |
|
3385 |
|
3386 /** |
|
3387 * webkit_web_view_can_go_forward: |
|
3388 * @web_view: a #WebKitWebView |
|
3389 * |
|
3390 * Determines whether #web_view has a next history item. |
|
3391 * |
|
3392 * Return value: %TRUE if able to move forward, %FALSE otherwise |
|
3393 */ |
|
3394 gboolean webkit_web_view_can_go_forward(WebKitWebView* webView) |
|
3395 { |
|
3396 g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), FALSE); |
|
3397 |
|
3398 Page* page = core(webView); |
|
3399 |
|
3400 if (!page) |
|
3401 return FALSE; |
|
3402 |
|
3403 if (!page->backForwardList()->forwardItem()) |
|
3404 return FALSE; |
|
3405 |
|
3406 return TRUE; |
|
3407 } |
|
3408 |
|
3409 /** |
|
3410 * webkit_web_view_open: |
|
3411 * @web_view: a #WebKitWebView |
|
3412 * @uri: an URI |
|
3413 * |
|
3414 * Requests loading of the specified URI string. |
|
3415 * |
|
3416 * Deprecated: 1.1.1: Use webkit_web_view_load_uri() instead. |
|
3417 */ |
|
3418 void webkit_web_view_open(WebKitWebView* webView, const gchar* uri) |
|
3419 { |
|
3420 g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView)); |
|
3421 g_return_if_fail(uri); |
|
3422 |
|
3423 // We used to support local paths, unlike the newer |
|
3424 // function webkit_web_view_load_uri |
|
3425 if (g_path_is_absolute(uri)) { |
|
3426 gchar* fileUri = g_filename_to_uri(uri, NULL, NULL); |
|
3427 webkit_web_view_load_uri(webView, fileUri); |
|
3428 g_free(fileUri); |
|
3429 } |
|
3430 else |
|
3431 webkit_web_view_load_uri(webView, uri); |
|
3432 } |
|
3433 |
|
3434 void webkit_web_view_reload(WebKitWebView* webView) |
|
3435 { |
|
3436 g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView)); |
|
3437 |
|
3438 core(webView)->mainFrame()->loader()->reload(); |
|
3439 } |
|
3440 |
|
3441 /** |
|
3442 * webkit_web_view_reload_bypass_cache: |
|
3443 * @web_view: a #WebKitWebView |
|
3444 * |
|
3445 * Reloads the @web_view without using any cached data. |
|
3446 * |
|
3447 * Since: 1.0.3 |
|
3448 */ |
|
3449 void webkit_web_view_reload_bypass_cache(WebKitWebView* webView) |
|
3450 { |
|
3451 g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView)); |
|
3452 |
|
3453 core(webView)->mainFrame()->loader()->reload(true); |
|
3454 } |
|
3455 |
|
3456 /** |
|
3457 * webkit_web_view_load_uri: |
|
3458 * @web_view: a #WebKitWebView |
|
3459 * @uri: an URI string |
|
3460 * |
|
3461 * Requests loading of the specified URI string. |
|
3462 * |
|
3463 * Since: 1.1.1 |
|
3464 */ |
|
3465 void webkit_web_view_load_uri(WebKitWebView* webView, const gchar* uri) |
|
3466 { |
|
3467 g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView)); |
|
3468 g_return_if_fail(uri); |
|
3469 |
|
3470 WebKitWebFrame* frame = webView->priv->mainFrame; |
|
3471 webkit_web_frame_load_uri(frame, uri); |
|
3472 } |
|
3473 |
|
3474 /** |
|
3475 + * webkit_web_view_load_string: |
|
3476 + * @web_view: a #WebKitWebView |
|
3477 + * @content: an URI string |
|
3478 + * @mime_type: the MIME type, or %NULL |
|
3479 + * @encoding: the encoding, or %NULL |
|
3480 + * @base_uri: the base URI for relative locations |
|
3481 + * |
|
3482 + * Requests loading of the given @content with the specified @mime_type, |
|
3483 + * @encoding and @base_uri. |
|
3484 + * |
|
3485 + * If @mime_type is %NULL, "text/html" is assumed. |
|
3486 + * |
|
3487 + * If @encoding is %NULL, "UTF-8" is assumed. |
|
3488 + */ |
|
3489 void webkit_web_view_load_string(WebKitWebView* webView, const gchar* content, const gchar* mimeType, const gchar* encoding, const gchar* baseUri) |
|
3490 { |
|
3491 g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView)); |
|
3492 g_return_if_fail(content); |
|
3493 |
|
3494 WebKitWebFrame* frame = webView->priv->mainFrame; |
|
3495 webkit_web_frame_load_string(frame, content, mimeType, encoding, baseUri); |
|
3496 } |
|
3497 /** |
|
3498 * webkit_web_view_load_html_string: |
|
3499 * @web_view: a #WebKitWebView |
|
3500 * @content: an URI string |
|
3501 * @base_uri: the base URI for relative locations |
|
3502 * |
|
3503 * Requests loading of the given @content with the specified @base_uri. |
|
3504 * |
|
3505 * Deprecated: 1.1.1: Use webkit_web_view_load_string() instead. |
|
3506 */ |
|
3507 void webkit_web_view_load_html_string(WebKitWebView* webView, const gchar* content, const gchar* baseUri) |
|
3508 { |
|
3509 g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView)); |
|
3510 g_return_if_fail(content); |
|
3511 |
|
3512 webkit_web_view_load_string(webView, content, NULL, NULL, baseUri); |
|
3513 } |
|
3514 |
|
3515 /** |
|
3516 * webkit_web_view_load_request: |
|
3517 * @web_view: a #WebKitWebView |
|
3518 * @request: a #WebKitNetworkRequest |
|
3519 * |
|
3520 * Requests loading of the specified asynchronous client request. |
|
3521 * |
|
3522 * Creates a provisional data source that will transition to a committed data |
|
3523 * source once any data has been received. Use webkit_web_view_stop_loading() to |
|
3524 * stop the load. |
|
3525 * |
|
3526 * Since: 1.1.1 |
|
3527 */ |
|
3528 void webkit_web_view_load_request(WebKitWebView* webView, WebKitNetworkRequest* request) |
|
3529 { |
|
3530 g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView)); |
|
3531 g_return_if_fail(WEBKIT_IS_NETWORK_REQUEST(request)); |
|
3532 |
|
3533 WebKitWebFrame* frame = webView->priv->mainFrame; |
|
3534 webkit_web_frame_load_request(frame, request); |
|
3535 } |
|
3536 |
|
3537 /** |
|
3538 * webkit_web_view_stop_loading: |
|
3539 * @webView: a #WebKitWebView |
|
3540 * |
|
3541 * Stops any ongoing load in the @webView. |
|
3542 **/ |
|
3543 void webkit_web_view_stop_loading(WebKitWebView* webView) |
|
3544 { |
|
3545 g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView)); |
|
3546 |
|
3547 Frame* frame = core(webView)->mainFrame(); |
|
3548 |
|
3549 if (FrameLoader* loader = frame->loader()) |
|
3550 loader->stopForUserCancel(); |
|
3551 } |
|
3552 |
|
3553 /** |
|
3554 * webkit_web_view_search_text: |
|
3555 * @web_view: a #WebKitWebView |
|
3556 * @text: a string to look for |
|
3557 * @forward: whether to find forward or not |
|
3558 * @case_sensitive: whether to respect the case of text |
|
3559 * @wrap: whether to continue looking at the beginning after reaching the end |
|
3560 * |
|
3561 * Looks for a specified string inside #web_view. |
|
3562 * |
|
3563 * Return value: %TRUE on success or %FALSE on failure |
|
3564 */ |
|
3565 gboolean webkit_web_view_search_text(WebKitWebView* webView, const gchar* string, gboolean caseSensitive, gboolean forward, gboolean shouldWrap) |
|
3566 { |
|
3567 g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), FALSE); |
|
3568 g_return_val_if_fail(string, FALSE); |
|
3569 |
|
3570 TextCaseSensitivity caseSensitivity = caseSensitive ? TextCaseSensitive : TextCaseInsensitive; |
|
3571 FindDirection direction = forward ? FindDirectionForward : FindDirectionBackward; |
|
3572 |
|
3573 return core(webView)->findString(String::fromUTF8(string), caseSensitivity, direction, shouldWrap); |
|
3574 } |
|
3575 |
|
3576 /** |
|
3577 * webkit_web_view_mark_text_matches: |
|
3578 * @web_view: a #WebKitWebView |
|
3579 * @string: a string to look for |
|
3580 * @case_sensitive: whether to respect the case of text |
|
3581 * @limit: the maximum number of strings to look for or 0 for all |
|
3582 * |
|
3583 * Attempts to highlight all occurances of #string inside #web_view. |
|
3584 * |
|
3585 * Return value: the number of strings highlighted |
|
3586 */ |
|
3587 guint webkit_web_view_mark_text_matches(WebKitWebView* webView, const gchar* string, gboolean caseSensitive, guint limit) |
|
3588 { |
|
3589 g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), 0); |
|
3590 g_return_val_if_fail(string, 0); |
|
3591 |
|
3592 TextCaseSensitivity caseSensitivity = caseSensitive ? TextCaseSensitive : TextCaseInsensitive; |
|
3593 |
|
3594 return core(webView)->markAllMatchesForText(String::fromUTF8(string), caseSensitivity, false, limit); |
|
3595 } |
|
3596 |
|
3597 /** |
|
3598 * webkit_web_view_set_highlight_text_matches: |
|
3599 * @web_view: a #WebKitWebView |
|
3600 * @highlight: whether to highlight text matches |
|
3601 * |
|
3602 * Highlights text matches previously marked by webkit_web_view_mark_text_matches. |
|
3603 */ |
|
3604 void webkit_web_view_set_highlight_text_matches(WebKitWebView* webView, gboolean shouldHighlight) |
|
3605 { |
|
3606 g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView)); |
|
3607 |
|
3608 Frame *frame = core(webView)->mainFrame(); |
|
3609 do { |
|
3610 frame->setMarkedTextMatchesAreHighlighted(shouldHighlight); |
|
3611 frame = frame->tree()->traverseNextWithWrap(false); |
|
3612 } while (frame); |
|
3613 } |
|
3614 |
|
3615 /** |
|
3616 * webkit_web_view_unmark_text_matches: |
|
3617 * @web_view: a #WebKitWebView |
|
3618 * |
|
3619 * Removes highlighting previously set by webkit_web_view_mark_text_matches. |
|
3620 */ |
|
3621 void webkit_web_view_unmark_text_matches(WebKitWebView* webView) |
|
3622 { |
|
3623 g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView)); |
|
3624 |
|
3625 return core(webView)->unmarkAllTextMatches(); |
|
3626 } |
|
3627 |
|
3628 WebKitWebFrame* webkit_web_view_get_main_frame(WebKitWebView* webView) |
|
3629 { |
|
3630 g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), NULL); |
|
3631 |
|
3632 WebKitWebViewPrivate* priv = webView->priv; |
|
3633 return priv->mainFrame; |
|
3634 } |
|
3635 |
|
3636 /** |
|
3637 * webkit_web_view_get_focused_frame: |
|
3638 * @web_view: a #WebKitWebView |
|
3639 * |
|
3640 * Returns the frame that has focus or an active text selection. |
|
3641 * |
|
3642 * Return value: The focused #WebKitWebFrame or %NULL if no frame is focused |
|
3643 */ |
|
3644 WebKitWebFrame* webkit_web_view_get_focused_frame(WebKitWebView* webView) |
|
3645 { |
|
3646 g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), NULL); |
|
3647 |
|
3648 Frame* focusedFrame = core(webView)->focusController()->focusedFrame(); |
|
3649 return kit(focusedFrame); |
|
3650 } |
|
3651 |
|
3652 void webkit_web_view_execute_script(WebKitWebView* webView, const gchar* script) |
|
3653 { |
|
3654 g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView)); |
|
3655 g_return_if_fail(script); |
|
3656 |
|
3657 core(webView)->mainFrame()->script()->executeScript(String::fromUTF8(script), true); |
|
3658 } |
|
3659 |
|
3660 /** |
|
3661 * webkit_web_view_cut_clipboard: |
|
3662 * @web_view: a #WebKitWebView |
|
3663 * |
|
3664 * Determines whether or not it is currently possible to cut to the clipboard. |
|
3665 * |
|
3666 * Return value: %TRUE if a selection can be cut, %FALSE if not |
|
3667 */ |
|
3668 gboolean webkit_web_view_can_cut_clipboard(WebKitWebView* webView) |
|
3669 { |
|
3670 g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), FALSE); |
|
3671 |
|
3672 Frame* frame = core(webView)->focusController()->focusedOrMainFrame(); |
|
3673 return frame->editor()->canCut() || frame->editor()->canDHTMLCut(); |
|
3674 } |
|
3675 |
|
3676 /** |
|
3677 * webkit_web_view_copy_clipboard: |
|
3678 * @web_view: a #WebKitWebView |
|
3679 * |
|
3680 * Determines whether or not it is currently possible to copy to the clipboard. |
|
3681 * |
|
3682 * Return value: %TRUE if a selection can be copied, %FALSE if not |
|
3683 */ |
|
3684 gboolean webkit_web_view_can_copy_clipboard(WebKitWebView* webView) |
|
3685 { |
|
3686 g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), FALSE); |
|
3687 |
|
3688 Frame* frame = core(webView)->focusController()->focusedOrMainFrame(); |
|
3689 return frame->editor()->canCopy() || frame->editor()->canDHTMLCopy(); |
|
3690 } |
|
3691 |
|
3692 /** |
|
3693 * webkit_web_view_paste_clipboard: |
|
3694 * @web_view: a #WebKitWebView |
|
3695 * |
|
3696 * Determines whether or not it is currently possible to paste from the clipboard. |
|
3697 * |
|
3698 * Return value: %TRUE if a selection can be pasted, %FALSE if not |
|
3699 */ |
|
3700 gboolean webkit_web_view_can_paste_clipboard(WebKitWebView* webView) |
|
3701 { |
|
3702 g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), FALSE); |
|
3703 |
|
3704 Frame* frame = core(webView)->focusController()->focusedOrMainFrame(); |
|
3705 return frame->editor()->canPaste() || frame->editor()->canDHTMLPaste(); |
|
3706 } |
|
3707 |
|
3708 /** |
|
3709 * webkit_web_view_cut_clipboard: |
|
3710 * @web_view: a #WebKitWebView |
|
3711 * |
|
3712 * Cuts the current selection inside the @web_view to the clipboard. |
|
3713 */ |
|
3714 void webkit_web_view_cut_clipboard(WebKitWebView* webView) |
|
3715 { |
|
3716 g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView)); |
|
3717 |
|
3718 if (webkit_web_view_can_cut_clipboard(webView)) |
|
3719 g_signal_emit(webView, webkit_web_view_signals[CUT_CLIPBOARD], 0); |
|
3720 } |
|
3721 |
|
3722 /** |
|
3723 * webkit_web_view_copy_clipboard: |
|
3724 * @web_view: a #WebKitWebView |
|
3725 * |
|
3726 * Copies the current selection inside the @web_view to the clipboard. |
|
3727 */ |
|
3728 void webkit_web_view_copy_clipboard(WebKitWebView* webView) |
|
3729 { |
|
3730 g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView)); |
|
3731 |
|
3732 if (webkit_web_view_can_copy_clipboard(webView)) |
|
3733 g_signal_emit(webView, webkit_web_view_signals[COPY_CLIPBOARD], 0); |
|
3734 } |
|
3735 |
|
3736 /** |
|
3737 * webkit_web_view_paste_clipboard: |
|
3738 * @web_view: a #WebKitWebView |
|
3739 * |
|
3740 * Pastes the current contents of the clipboard to the @web_view. |
|
3741 */ |
|
3742 void webkit_web_view_paste_clipboard(WebKitWebView* webView) |
|
3743 { |
|
3744 g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView)); |
|
3745 |
|
3746 if (webkit_web_view_can_paste_clipboard(webView)) |
|
3747 g_signal_emit(webView, webkit_web_view_signals[PASTE_CLIPBOARD], 0); |
|
3748 } |
|
3749 |
|
3750 /** |
|
3751 * webkit_web_view_delete_selection: |
|
3752 * @web_view: a #WebKitWebView |
|
3753 * |
|
3754 * Deletes the current selection inside the @web_view. |
|
3755 */ |
|
3756 void webkit_web_view_delete_selection(WebKitWebView* webView) |
|
3757 { |
|
3758 g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView)); |
|
3759 |
|
3760 Frame* frame = core(webView)->focusController()->focusedOrMainFrame(); |
|
3761 frame->editor()->performDelete(); |
|
3762 } |
|
3763 |
|
3764 /** |
|
3765 * webkit_web_view_has_selection: |
|
3766 * @web_view: a #WebKitWebView |
|
3767 * |
|
3768 * Determines whether text was selected. |
|
3769 * |
|
3770 * Return value: %TRUE if there is selected text, %FALSE if not |
|
3771 */ |
|
3772 gboolean webkit_web_view_has_selection(WebKitWebView* webView) |
|
3773 { |
|
3774 g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), FALSE); |
|
3775 |
|
3776 return !core(webView)->selection().isNone(); |
|
3777 } |
|
3778 |
|
3779 /** |
|
3780 * webkit_web_view_get_selected_text: |
|
3781 * @web_view: a #WebKitWebView |
|
3782 * |
|
3783 * Retrieves the selected text if any. |
|
3784 * |
|
3785 * Return value: a newly allocated string with the selection or %NULL |
|
3786 */ |
|
3787 gchar* webkit_web_view_get_selected_text(WebKitWebView* webView) |
|
3788 { |
|
3789 g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), 0); |
|
3790 |
|
3791 Frame* frame = core(webView)->focusController()->focusedOrMainFrame(); |
|
3792 return g_strdup(frame->selectedText().utf8().data()); |
|
3793 } |
|
3794 |
|
3795 /** |
|
3796 * webkit_web_view_select_all: |
|
3797 * @web_view: a #WebKitWebView |
|
3798 * |
|
3799 * Attempts to select everything inside the @web_view. |
|
3800 */ |
|
3801 void webkit_web_view_select_all(WebKitWebView* webView) |
|
3802 { |
|
3803 g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView)); |
|
3804 |
|
3805 g_signal_emit(webView, webkit_web_view_signals[SELECT_ALL], 0); |
|
3806 } |
|
3807 |
|
3808 /** |
|
3809 * webkit_web_view_get_editable: |
|
3810 * @web_view: a #WebKitWebView |
|
3811 * |
|
3812 * Returns whether the user is allowed to edit the document. |
|
3813 * |
|
3814 * Returns %TRUE if @web_view allows the user to edit the HTML document, %FALSE if |
|
3815 * it doesn't. You can change @web_view's document programmatically regardless of |
|
3816 * this setting. |
|
3817 * |
|
3818 * Return value: a #gboolean indicating the editable state |
|
3819 */ |
|
3820 gboolean webkit_web_view_get_editable(WebKitWebView* webView) |
|
3821 { |
|
3822 g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), FALSE); |
|
3823 |
|
3824 WebKitWebViewPrivate* priv = webView->priv; |
|
3825 |
|
3826 return priv->editable; |
|
3827 } |
|
3828 |
|
3829 /** |
|
3830 * webkit_web_view_set_editable: |
|
3831 * @web_view: a #WebKitWebView |
|
3832 * @flag: a #gboolean indicating the editable state |
|
3833 * |
|
3834 * Sets whether @web_view allows the user to edit its HTML document. |
|
3835 * |
|
3836 * If @flag is %TRUE, @web_view allows the user to edit the document. If @flag is |
|
3837 * %FALSE, an element in @web_view's document can only be edited if the |
|
3838 * CONTENTEDITABLE attribute has been set on the element or one of its parent |
|
3839 * elements. You can change @web_view's document programmatically regardless of |
|
3840 * this setting. By default a #WebKitWebView is not editable. |
|
3841 |
|
3842 * Normally, an HTML document is not editable unless the elements within the |
|
3843 * document are editable. This function provides a low-level way to make the |
|
3844 * contents of a #WebKitWebView editable without altering the document or DOM |
|
3845 * structure. |
|
3846 */ |
|
3847 void webkit_web_view_set_editable(WebKitWebView* webView, gboolean flag) |
|
3848 { |
|
3849 g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView)); |
|
3850 |
|
3851 WebKitWebViewPrivate* priv = webView->priv; |
|
3852 |
|
3853 Frame* frame = core(webView)->mainFrame(); |
|
3854 g_return_if_fail(frame); |
|
3855 |
|
3856 // TODO: What happens when the frame is replaced? |
|
3857 flag = flag != FALSE; |
|
3858 if (flag == priv->editable) |
|
3859 return; |
|
3860 |
|
3861 priv->editable = flag; |
|
3862 |
|
3863 if (flag) { |
|
3864 frame->applyEditingStyleToBodyElement(); |
|
3865 // TODO: If the WebKitWebView is made editable and the selection is empty, set it to something. |
|
3866 //if (!webkit_web_view_get_selected_dom_range(webView)) |
|
3867 // mainFrame->setSelectionFromNone(); |
|
3868 } |
|
3869 g_object_notify(G_OBJECT(webView), "editable"); |
|
3870 } |
|
3871 |
|
3872 /** |
|
3873 * webkit_web_view_get_copy_target_list: |
|
3874 * @web_view: a #WebKitWebView |
|
3875 * |
|
3876 * This function returns the list of targets this #WebKitWebView can |
|
3877 * provide for clipboard copying and as DND source. The targets in the list are |
|
3878 * added with values from the #WebKitWebViewTargetInfo enum, |
|
3879 * using gtk_target_list_add() and |
|
3880 * gtk_target_list_add_text_targets(). |
|
3881 * |
|
3882 * Return value: the #GtkTargetList |
|
3883 **/ |
|
3884 GtkTargetList* webkit_web_view_get_copy_target_list(WebKitWebView* webView) |
|
3885 { |
|
3886 return pasteboardHelperInstance()->targetList(); |
|
3887 } |
|
3888 |
|
3889 /** |
|
3890 * webkit_web_view_get_paste_target_list: |
|
3891 * @web_view: a #WebKitWebView |
|
3892 * |
|
3893 * This function returns the list of targets this #WebKitWebView can |
|
3894 * provide for clipboard pasting and as DND destination. The targets in the list are |
|
3895 * added with values from the #WebKitWebViewTargetInfo enum, |
|
3896 * using gtk_target_list_add() and |
|
3897 * gtk_target_list_add_text_targets(). |
|
3898 * |
|
3899 * Return value: the #GtkTargetList |
|
3900 **/ |
|
3901 GtkTargetList* webkit_web_view_get_paste_target_list(WebKitWebView* webView) |
|
3902 { |
|
3903 return pasteboardHelperInstance()->targetList(); |
|
3904 } |
|
3905 |
|
3906 /** |
|
3907 * webkit_web_view_can_show_mime_type: |
|
3908 * @web_view: a #WebKitWebView |
|
3909 * @mime_type: a MIME type |
|
3910 * |
|
3911 * This functions returns whether or not a MIME type can be displayed using this view. |
|
3912 * |
|
3913 * Return value: a #gboolean indicating if the MIME type can be displayed |
|
3914 * |
|
3915 * Since: 1.0.3 |
|
3916 **/ |
|
3917 |
|
3918 gboolean webkit_web_view_can_show_mime_type(WebKitWebView* webView, const gchar* mimeType) |
|
3919 { |
|
3920 g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), FALSE); |
|
3921 |
|
3922 Frame* frame = core(webkit_web_view_get_main_frame(webView)); |
|
3923 if (FrameLoader* loader = frame->loader()) |
|
3924 return loader->canShowMIMEType(String::fromUTF8(mimeType)); |
|
3925 else |
|
3926 return FALSE; |
|
3927 } |
|
3928 |
|
3929 /** |
|
3930 * webkit_web_view_get_transparent: |
|
3931 * @web_view: a #WebKitWebView |
|
3932 * |
|
3933 * Returns whether the #WebKitWebView has a transparent background. |
|
3934 * |
|
3935 * Return value: %FALSE when the #WebKitWebView draws a solid background |
|
3936 * (the default), otherwise %TRUE. |
|
3937 */ |
|
3938 gboolean webkit_web_view_get_transparent(WebKitWebView* webView) |
|
3939 { |
|
3940 g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), FALSE); |
|
3941 |
|
3942 WebKitWebViewPrivate* priv = webView->priv; |
|
3943 return priv->transparent; |
|
3944 } |
|
3945 |
|
3946 /** |
|
3947 * webkit_web_view_set_transparent: |
|
3948 * @web_view: a #WebKitWebView |
|
3949 * |
|
3950 * Sets whether the #WebKitWebView has a transparent background. |
|
3951 * |
|
3952 * Pass %FALSE to have the #WebKitWebView draw a solid background |
|
3953 * (the default), otherwise %TRUE. |
|
3954 */ |
|
3955 void webkit_web_view_set_transparent(WebKitWebView* webView, gboolean flag) |
|
3956 { |
|
3957 g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView)); |
|
3958 |
|
3959 WebKitWebViewPrivate* priv = webView->priv; |
|
3960 priv->transparent = flag; |
|
3961 |
|
3962 // TODO: This needs to be made persistent or it could become a problem when |
|
3963 // the main frame is replaced. |
|
3964 Frame* frame = core(webView)->mainFrame(); |
|
3965 g_return_if_fail(frame); |
|
3966 frame->view()->setTransparent(flag); |
|
3967 g_object_notify(G_OBJECT(webView), "transparent"); |
|
3968 } |
|
3969 |
|
3970 /** |
|
3971 * webkit_web_view_get_zoom_level: |
|
3972 * @web_view: a #WebKitWebView |
|
3973 * |
|
3974 * Returns the zoom level of @web_view, i.e. the factor by which elements in |
|
3975 * the page are scaled with respect to their original size. |
|
3976 * If the "full-content-zoom" property is set to %FALSE (the default) |
|
3977 * the zoom level changes the text size, or if %TRUE, scales all |
|
3978 * elements in the page. |
|
3979 * |
|
3980 * Return value: the zoom level of @web_view |
|
3981 * |
|
3982 * Since: 1.0.1 |
|
3983 */ |
|
3984 gfloat webkit_web_view_get_zoom_level(WebKitWebView* webView) |
|
3985 { |
|
3986 g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), 1.0f); |
|
3987 |
|
3988 Frame* frame = core(webView)->mainFrame(); |
|
3989 if (!frame) |
|
3990 return 1.0f; |
|
3991 |
|
3992 FrameView* view = frame->view(); |
|
3993 if (!view) |
|
3994 return 1; |
|
3995 |
|
3996 return view->zoomFactor(); |
|
3997 } |
|
3998 |
|
3999 static void webkit_web_view_apply_zoom_level(WebKitWebView* webView, gfloat zoomLevel) |
|
4000 { |
|
4001 Frame* frame = core(webView)->mainFrame(); |
|
4002 if (!frame) |
|
4003 return; |
|
4004 |
|
4005 FrameView* view = frame->view(); |
|
4006 if (!view) |
|
4007 return; |
|
4008 |
|
4009 WebKitWebViewPrivate* priv = webView->priv; |
|
4010 view->setZoomFactor(zoomLevel, priv->zoomFullContent ? ZoomPage : ZoomTextOnly); |
|
4011 } |
|
4012 |
|
4013 /** |
|
4014 * webkit_web_view_set_zoom_level: |
|
4015 * @web_view: a #WebKitWebView |
|
4016 * @zoom_level: the new zoom level |
|
4017 * |
|
4018 * Sets the zoom level of @web_view, i.e. the factor by which elements in |
|
4019 * the page are scaled with respect to their original size. |
|
4020 * If the "full-content-zoom" property is set to %FALSE (the default) |
|
4021 * the zoom level changes the text size, or if %TRUE, scales all |
|
4022 * elements in the page. |
|
4023 * |
|
4024 * Since: 1.0.1 |
|
4025 */ |
|
4026 void webkit_web_view_set_zoom_level(WebKitWebView* webView, gfloat zoomLevel) |
|
4027 { |
|
4028 g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView)); |
|
4029 |
|
4030 webkit_web_view_apply_zoom_level(webView, zoomLevel); |
|
4031 g_object_notify(G_OBJECT(webView), "zoom-level"); |
|
4032 } |
|
4033 |
|
4034 /** |
|
4035 * webkit_web_view_zoom_in: |
|
4036 * @web_view: a #WebKitWebView |
|
4037 * |
|
4038 * Increases the zoom level of @web_view. The current zoom |
|
4039 * level is incremented by the value of the "zoom-step" |
|
4040 * property of the #WebKitWebSettings associated with @web_view. |
|
4041 * |
|
4042 * Since: 1.0.1 |
|
4043 */ |
|
4044 void webkit_web_view_zoom_in(WebKitWebView* webView) |
|
4045 { |
|
4046 g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView)); |
|
4047 |
|
4048 WebKitWebViewPrivate* priv = webView->priv; |
|
4049 gfloat zoomMultiplierRatio; |
|
4050 g_object_get(priv->webSettings, "zoom-step", &zoomMultiplierRatio, NULL); |
|
4051 |
|
4052 webkit_web_view_set_zoom_level(webView, webkit_web_view_get_zoom_level(webView) + zoomMultiplierRatio); |
|
4053 } |
|
4054 |
|
4055 /** |
|
4056 * webkit_web_view_zoom_out: |
|
4057 * @web_view: a #WebKitWebView |
|
4058 * |
|
4059 * Decreases the zoom level of @web_view. The current zoom |
|
4060 * level is decremented by the value of the "zoom-step" |
|
4061 * property of the #WebKitWebSettings associated with @web_view. |
|
4062 * |
|
4063 * Since: 1.0.1 |
|
4064 */ |
|
4065 void webkit_web_view_zoom_out(WebKitWebView* webView) |
|
4066 { |
|
4067 g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView)); |
|
4068 |
|
4069 WebKitWebViewPrivate* priv = webView->priv; |
|
4070 gfloat zoomMultiplierRatio; |
|
4071 g_object_get(priv->webSettings, "zoom-step", &zoomMultiplierRatio, NULL); |
|
4072 |
|
4073 webkit_web_view_set_zoom_level(webView, webkit_web_view_get_zoom_level(webView) - zoomMultiplierRatio); |
|
4074 } |
|
4075 |
|
4076 /** |
|
4077 * webkit_web_view_get_full_content_zoom: |
|
4078 * @web_view: a #WebKitWebView |
|
4079 * |
|
4080 * Returns whether the zoom level affects only text or all elements. |
|
4081 * |
|
4082 * Return value: %FALSE if only text should be scaled (the default), |
|
4083 * %TRUE if the full content of the view should be scaled. |
|
4084 * |
|
4085 * Since: 1.0.1 |
|
4086 */ |
|
4087 gboolean webkit_web_view_get_full_content_zoom(WebKitWebView* webView) |
|
4088 { |
|
4089 g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), FALSE); |
|
4090 |
|
4091 WebKitWebViewPrivate* priv = webView->priv; |
|
4092 return priv->zoomFullContent; |
|
4093 } |
|
4094 |
|
4095 /** |
|
4096 * webkit_web_view_set_full_content_zoom: |
|
4097 * @web_view: a #WebKitWebView |
|
4098 * @full_content_zoom: %FALSE if only text should be scaled (the default), |
|
4099 * %TRUE if the full content of the view should be scaled. |
|
4100 * |
|
4101 * Sets whether the zoom level affects only text or all elements. |
|
4102 * |
|
4103 * Since: 1.0.1 |
|
4104 */ |
|
4105 void webkit_web_view_set_full_content_zoom(WebKitWebView* webView, gboolean zoomFullContent) |
|
4106 { |
|
4107 g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView)); |
|
4108 |
|
4109 WebKitWebViewPrivate* priv = webView->priv; |
|
4110 if (priv->zoomFullContent == zoomFullContent) |
|
4111 return; |
|
4112 |
|
4113 priv->zoomFullContent = zoomFullContent; |
|
4114 webkit_web_view_apply_zoom_level(webView, webkit_web_view_get_zoom_level(webView)); |
|
4115 |
|
4116 g_object_notify(G_OBJECT(webView), "full-content-zoom"); |
|
4117 } |
|
4118 |
|
4119 /** |
|
4120 * webkit_web_view_get_load_status: |
|
4121 * @web_view: a #WebKitWebView |
|
4122 * |
|
4123 * Determines the current status of the load. |
|
4124 * |
|
4125 * Since: 1.1.7 |
|
4126 */ |
|
4127 WebKitLoadStatus webkit_web_view_get_load_status(WebKitWebView* webView) |
|
4128 { |
|
4129 g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), WEBKIT_LOAD_FINISHED); |
|
4130 |
|
4131 WebKitWebViewPrivate* priv = webView->priv; |
|
4132 return priv->loadStatus; |
|
4133 } |
|
4134 |
|
4135 /** |
|
4136 * webkit_web_view_get_progress: |
|
4137 * @web_view: a #WebKitWebView |
|
4138 * |
|
4139 * Determines the current progress of the load. |
|
4140 * |
|
4141 * Since: 1.1.7 |
|
4142 */ |
|
4143 gdouble webkit_web_view_get_progress(WebKitWebView* webView) |
|
4144 { |
|
4145 g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), 1.0); |
|
4146 |
|
4147 return core(webView)->progress()->estimatedProgress(); |
|
4148 } |
|
4149 |
|
4150 /** |
|
4151 * webkit_web_view_get_encoding: |
|
4152 * @web_view: a #WebKitWebView |
|
4153 * |
|
4154 * Returns the default encoding of the #WebKitWebView. |
|
4155 * |
|
4156 * Return value: the default encoding |
|
4157 * |
|
4158 * Since: 1.1.1 |
|
4159 */ |
|
4160 const gchar* webkit_web_view_get_encoding(WebKitWebView* webView) |
|
4161 { |
|
4162 g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), NULL); |
|
4163 |
|
4164 String encoding = core(webView)->mainFrame()->loader()->writer()->encoding(); |
|
4165 |
|
4166 if (!encoding.isEmpty()) { |
|
4167 WebKitWebViewPrivate* priv = webView->priv; |
|
4168 g_free(priv->encoding); |
|
4169 priv->encoding = g_strdup(encoding.utf8().data()); |
|
4170 return priv->encoding; |
|
4171 } else |
|
4172 return NULL; |
|
4173 } |
|
4174 |
|
4175 /** |
|
4176 * webkit_web_view_set_custom_encoding: |
|
4177 * @web_view: a #WebKitWebView |
|
4178 * @encoding: the new encoding, or %NULL to restore the default encoding |
|
4179 * |
|
4180 * Sets the current #WebKitWebView encoding, without modifying the default one, |
|
4181 * and reloads the page. |
|
4182 * |
|
4183 * Since: 1.1.1 |
|
4184 */ |
|
4185 void webkit_web_view_set_custom_encoding(WebKitWebView* webView, const char* encoding) |
|
4186 { |
|
4187 g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView)); |
|
4188 |
|
4189 core(webView)->mainFrame()->loader()->reloadWithOverrideEncoding(String::fromUTF8(encoding)); |
|
4190 } |
|
4191 |
|
4192 /** |
|
4193 * webkit_web_view_get_custom_encoding: |
|
4194 * @web_view: a #WebKitWebView |
|
4195 * |
|
4196 * Returns the current encoding of the #WebKitWebView, not the default-encoding |
|
4197 * of WebKitWebSettings. |
|
4198 * |
|
4199 * Return value: a string containing the current custom encoding for @web_view, or %NULL if there's none set. |
|
4200 * |
|
4201 * Since: 1.1.1 |
|
4202 */ |
|
4203 const char* webkit_web_view_get_custom_encoding(WebKitWebView* webView) |
|
4204 { |
|
4205 g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), NULL); |
|
4206 |
|
4207 String overrideEncoding = core(webView)->mainFrame()->loader()->documentLoader()->overrideEncoding(); |
|
4208 |
|
4209 if (!overrideEncoding.isEmpty()) { |
|
4210 WebKitWebViewPrivate* priv = webView->priv; |
|
4211 g_free (priv->customEncoding); |
|
4212 priv->customEncoding = g_strdup(overrideEncoding.utf8().data()); |
|
4213 return priv->customEncoding; |
|
4214 } else |
|
4215 return NULL; |
|
4216 } |
|
4217 |
|
4218 /** |
|
4219 * webkit_web_view_move_cursor: |
|
4220 * @web_view: a #WebKitWebView |
|
4221 * @step: a #GtkMovementStep |
|
4222 * @count: integer describing the direction of the movement. 1 for forward, -1 for backwards. |
|
4223 * |
|
4224 * Move the cursor in @view as described by @step and @count. |
|
4225 * |
|
4226 * Since: 1.1.4 |
|
4227 */ |
|
4228 void webkit_web_view_move_cursor(WebKitWebView* webView, GtkMovementStep step, gint count) |
|
4229 { |
|
4230 g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView)); |
|
4231 g_return_if_fail(step == GTK_MOVEMENT_VISUAL_POSITIONS || |
|
4232 step == GTK_MOVEMENT_DISPLAY_LINES || |
|
4233 step == GTK_MOVEMENT_PAGES || |
|
4234 step == GTK_MOVEMENT_BUFFER_ENDS); |
|
4235 g_return_if_fail(count == 1 || count == -1); |
|
4236 |
|
4237 gboolean handled; |
|
4238 g_signal_emit(webView, webkit_web_view_signals[MOVE_CURSOR], 0, step, count, &handled); |
|
4239 } |
|
4240 |
|
4241 void webkit_web_view_set_group_name(WebKitWebView* webView, const gchar* groupName) |
|
4242 { |
|
4243 g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView)); |
|
4244 |
|
4245 WebKitWebViewPrivate* priv = webView->priv; |
|
4246 |
|
4247 if (!priv->corePage) |
|
4248 return; |
|
4249 |
|
4250 priv->corePage->setGroupName(String::fromUTF8(groupName)); |
|
4251 } |
|
4252 |
|
4253 /** |
|
4254 * webkit_web_view_can_undo: |
|
4255 * @web_view: a #WebKitWebView |
|
4256 * |
|
4257 * Determines whether or not it is currently possible to undo the last |
|
4258 * editing command in the view. |
|
4259 * |
|
4260 * Return value: %TRUE if a undo can be done, %FALSE if not |
|
4261 * |
|
4262 * Since: 1.1.14 |
|
4263 */ |
|
4264 gboolean webkit_web_view_can_undo(WebKitWebView* webView) |
|
4265 { |
|
4266 g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), FALSE); |
|
4267 |
|
4268 Frame* frame = core(webView)->focusController()->focusedOrMainFrame(); |
|
4269 return frame->editor()->canUndo(); |
|
4270 } |
|
4271 |
|
4272 /** |
|
4273 * webkit_web_view_undo: |
|
4274 * @web_view: a #WebKitWebView |
|
4275 * |
|
4276 * Undoes the last editing command in the view, if possible. |
|
4277 * |
|
4278 * Since: 1.1.14 |
|
4279 */ |
|
4280 void webkit_web_view_undo(WebKitWebView* webView) |
|
4281 { |
|
4282 g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView)); |
|
4283 |
|
4284 if (webkit_web_view_can_undo(webView)) |
|
4285 g_signal_emit(webView, webkit_web_view_signals[UNDO], 0); |
|
4286 } |
|
4287 |
|
4288 /** |
|
4289 * webkit_web_view_can_redo: |
|
4290 * @web_view: a #WebKitWebView |
|
4291 * |
|
4292 * Determines whether or not it is currently possible to redo the last |
|
4293 * editing command in the view. |
|
4294 * |
|
4295 * Return value: %TRUE if a redo can be done, %FALSE if not |
|
4296 * |
|
4297 * Since: 1.1.14 |
|
4298 */ |
|
4299 gboolean webkit_web_view_can_redo(WebKitWebView* webView) |
|
4300 { |
|
4301 g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), FALSE); |
|
4302 |
|
4303 Frame* frame = core(webView)->focusController()->focusedOrMainFrame(); |
|
4304 return frame->editor()->canRedo(); |
|
4305 } |
|
4306 |
|
4307 /** |
|
4308 * webkit_web_view_redo: |
|
4309 * @web_view: a #WebKitWebView |
|
4310 * |
|
4311 * Redoes the last editing command in the view, if possible. |
|
4312 * |
|
4313 * Since: 1.1.14 |
|
4314 */ |
|
4315 void webkit_web_view_redo(WebKitWebView* webView) |
|
4316 { |
|
4317 g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView)); |
|
4318 |
|
4319 if (webkit_web_view_can_redo(webView)) |
|
4320 g_signal_emit(webView, webkit_web_view_signals[REDO], 0); |
|
4321 } |
|
4322 |
|
4323 |
|
4324 /** |
|
4325 * webkit_web_view_set_view_source_mode: |
|
4326 * @web_view: a #WebKitWebView |
|
4327 * @view_source_mode: the mode to turn on or off view source mode |
|
4328 * |
|
4329 * Set whether the view should be in view source mode. Setting this mode to |
|
4330 * %TRUE before loading a URI will display the source of the web page in a |
|
4331 * nice and readable format. |
|
4332 * |
|
4333 * Since: 1.1.14 |
|
4334 */ |
|
4335 void webkit_web_view_set_view_source_mode (WebKitWebView* webView, gboolean mode) |
|
4336 { |
|
4337 g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView)); |
|
4338 |
|
4339 if (Frame* mainFrame = core(webView)->mainFrame()) |
|
4340 mainFrame->setInViewSourceMode(mode); |
|
4341 } |
|
4342 |
|
4343 /** |
|
4344 * webkit_web_view_get_view_source_mode: |
|
4345 * @web_view: a #WebKitWebView |
|
4346 * |
|
4347 * Return value: %TRUE if @web_view is in view source mode, %FALSE otherwise. |
|
4348 * |
|
4349 * Since: 1.1.14 |
|
4350 */ |
|
4351 gboolean webkit_web_view_get_view_source_mode (WebKitWebView* webView) |
|
4352 { |
|
4353 g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), FALSE); |
|
4354 |
|
4355 if (Frame* mainFrame = core(webView)->mainFrame()) |
|
4356 return mainFrame->inViewSourceMode(); |
|
4357 |
|
4358 return FALSE; |
|
4359 } |
|
4360 |
|
4361 // Internal subresource management |
|
4362 void webkit_web_view_add_resource(WebKitWebView* webView, const char* identifier, WebKitWebResource* webResource) |
|
4363 { |
|
4364 WebKitWebViewPrivate* priv = webView->priv; |
|
4365 |
|
4366 if (!priv->mainResource) { |
|
4367 priv->mainResource = webResource; |
|
4368 priv->mainResourceIdentifier = g_strdup(identifier); |
|
4369 return; |
|
4370 } |
|
4371 |
|
4372 g_hash_table_insert(priv->subResources, g_strdup(identifier), webResource); |
|
4373 } |
|
4374 |
|
4375 WebKitWebResource* webkit_web_view_get_resource(WebKitWebView* webView, char* identifier) |
|
4376 { |
|
4377 WebKitWebViewPrivate* priv = webView->priv; |
|
4378 gpointer webResource = NULL; |
|
4379 |
|
4380 gboolean resourceFound = g_hash_table_lookup_extended(priv->subResources, identifier, NULL, &webResource); |
|
4381 |
|
4382 // The only resource we do not store in this hash table is the |
|
4383 // main! If we did not find a request, it probably means the load |
|
4384 // has been interrupted while while a resource was still being |
|
4385 // loaded. |
|
4386 if (!resourceFound && !g_str_equal(identifier, priv->mainResourceIdentifier)) |
|
4387 return NULL; |
|
4388 |
|
4389 if (!webResource) |
|
4390 return webkit_web_view_get_main_resource(webView); |
|
4391 |
|
4392 return WEBKIT_WEB_RESOURCE(webResource); |
|
4393 } |
|
4394 |
|
4395 WebKitWebResource* webkit_web_view_get_main_resource(WebKitWebView* webView) |
|
4396 { |
|
4397 return webView->priv->mainResource; |
|
4398 } |
|
4399 |
|
4400 void webkit_web_view_clear_resources(WebKitWebView* webView) |
|
4401 { |
|
4402 WebKitWebViewPrivate* priv = webView->priv; |
|
4403 |
|
4404 g_free(priv->mainResourceIdentifier); |
|
4405 priv->mainResourceIdentifier = NULL; |
|
4406 |
|
4407 if (priv->mainResource) { |
|
4408 g_object_unref(priv->mainResource); |
|
4409 priv->mainResource = NULL; |
|
4410 } |
|
4411 |
|
4412 if (priv->subResources) |
|
4413 g_hash_table_remove_all(priv->subResources); |
|
4414 } |
|
4415 |
|
4416 GList* webkit_web_view_get_subresources(WebKitWebView* webView) |
|
4417 { |
|
4418 WebKitWebViewPrivate* priv = webView->priv; |
|
4419 GList* subResources = g_hash_table_get_values(priv->subResources); |
|
4420 return g_list_remove(subResources, priv->mainResource); |
|
4421 } |
|
4422 |
|
4423 /* From EventHandler.cpp */ |
|
4424 static IntPoint documentPointForWindowPoint(Frame* frame, const IntPoint& windowPoint) |
|
4425 { |
|
4426 FrameView* view = frame->view(); |
|
4427 // FIXME: Is it really OK to use the wrong coordinates here when view is 0? |
|
4428 // Historically the code would just crash; this is clearly no worse than that. |
|
4429 return view ? view->windowToContents(windowPoint) : windowPoint; |
|
4430 } |
|
4431 |
|
4432 void webkit_web_view_set_tooltip_text(WebKitWebView* webView, const char* tooltip) |
|
4433 { |
|
4434 #if GTK_CHECK_VERSION(2, 12, 0) |
|
4435 WebKitWebViewPrivate* priv = webView->priv; |
|
4436 g_free(priv->tooltipText); |
|
4437 if (tooltip && *tooltip != '\0') { |
|
4438 priv->tooltipText = g_strdup(tooltip); |
|
4439 gtk_widget_set_has_tooltip(GTK_WIDGET(webView), TRUE); |
|
4440 } else { |
|
4441 priv->tooltipText = 0; |
|
4442 gtk_widget_set_has_tooltip(GTK_WIDGET(webView), FALSE); |
|
4443 } |
|
4444 |
|
4445 gtk_widget_trigger_tooltip_query(GTK_WIDGET(webView)); |
|
4446 #else |
|
4447 // TODO: Support older GTK+ versions |
|
4448 // See http://bugs.webkit.org/show_bug.cgi?id=15793 |
|
4449 notImplemented(); |
|
4450 #endif |
|
4451 } |
|
4452 |
|
4453 /** |
|
4454 * webkit_web_view_get_hit_test_result: |
|
4455 * @webView: a #WebKitWebView |
|
4456 * @event: a #GdkEventButton |
|
4457 * |
|
4458 * Does a 'hit test' in the coordinates specified by @event to figure |
|
4459 * out context information about that position in the @webView. |
|
4460 * |
|
4461 * Returns: a newly created #WebKitHitTestResult with the context of the |
|
4462 * specified position. |
|
4463 * |
|
4464 * Since: 1.1.15 |
|
4465 **/ |
|
4466 WebKitHitTestResult* webkit_web_view_get_hit_test_result(WebKitWebView* webView, GdkEventButton* event) |
|
4467 { |
|
4468 g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), NULL); |
|
4469 g_return_val_if_fail(event, NULL); |
|
4470 |
|
4471 PlatformMouseEvent mouseEvent = PlatformMouseEvent(event); |
|
4472 Frame* frame = core(webView)->focusController()->focusedOrMainFrame(); |
|
4473 HitTestRequest request(HitTestRequest::Active); |
|
4474 IntPoint documentPoint = documentPointForWindowPoint(frame, mouseEvent.pos()); |
|
4475 MouseEventWithHitTestResults mev = frame->document()->prepareMouseEvent(request, documentPoint, mouseEvent); |
|
4476 |
|
4477 return kit(mev.hitTestResult()); |
|
4478 } |
|
4479 |
|
4480 /** |
|
4481 * webkit_web_view_get_icon_uri: |
|
4482 * @web_view: the #WebKitWebView object |
|
4483 * |
|
4484 * Obtains the URI for the favicon for the given #WebKitWebView, or |
|
4485 * %NULL if there is none. |
|
4486 * |
|
4487 * Return value: the URI for the favicon, or %NULL |
|
4488 * |
|
4489 * Since: 1.1.18 |
|
4490 */ |
|
4491 G_CONST_RETURN gchar* webkit_web_view_get_icon_uri(WebKitWebView* webView) |
|
4492 { |
|
4493 g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), NULL); |
|
4494 |
|
4495 Page* corePage = core(webView); |
|
4496 String iconURL = iconDatabase()->iconURLForPageURL(corePage->mainFrame()->loader()->url().prettyURL()); |
|
4497 |
|
4498 WebKitWebViewPrivate* priv = webView->priv; |
|
4499 g_free(priv->iconURI); |
|
4500 priv->iconURI = g_strdup(iconURL.utf8().data()); |
|
4501 return priv->iconURI; |
|
4502 } |
|
4503 |
|
4504 /** |
|
4505 * webkit_web_view_get_dom_document: |
|
4506 * @webView: a #WebKitWebView |
|
4507 * |
|
4508 * Returns: the #WebKitDOMDocument currently loaded in the @webView |
|
4509 * |
|
4510 * Since: 1.3.1 |
|
4511 **/ |
|
4512 WebKitDOMDocument* |
|
4513 webkit_web_view_get_dom_document(WebKitWebView* webView) |
|
4514 { |
|
4515 g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), 0); |
|
4516 |
|
4517 Frame* coreFrame = core(webView)->mainFrame(); |
|
4518 if (!coreFrame) |
|
4519 return 0; |
|
4520 |
|
4521 Document* doc = coreFrame->document(); |
|
4522 if (!doc) |
|
4523 return 0; |
|
4524 |
|
4525 return static_cast<WebKitDOMDocument*>(kit(doc)); |
|
4526 } |
|
4527 |
|
4528 /** |
|
4529 * SECTION:webkit |
|
4530 * @short_description: Global functions controlling WebKit |
|
4531 * |
|
4532 * WebKit manages many resources which are not related to specific |
|
4533 * views. These functions relate to cross-view limits, such as cache |
|
4534 * sizes, database quotas, and the HTTP session management. |
|
4535 */ |
|
4536 |
|
4537 /** |
|
4538 * webkit_get_default_session: |
|
4539 * |
|
4540 * Retrieves the default #SoupSession used by all web views. |
|
4541 * Note that the session features are added by WebKit on demand, |
|
4542 * so if you insert your own #SoupCookieJar before any network |
|
4543 * traffic occurs, WebKit will use it instead of the default. |
|
4544 * |
|
4545 * Return value: the default #SoupSession |
|
4546 * |
|
4547 * Since: 1.1.1 |
|
4548 */ |
|
4549 SoupSession* webkit_get_default_session () |
|
4550 { |
|
4551 webkit_init(); |
|
4552 return ResourceHandle::defaultSession(); |
|
4553 } |
|
4554 |
|
4555 /** |
|
4556 * webkit_set_cache_model: |
|
4557 * @cache_model: a #WebKitCacheModel |
|
4558 * |
|
4559 * Specifies a usage model for WebViews, which WebKit will use to |
|
4560 * determine its caching behavior. All web views follow the cache |
|
4561 * model. This cache model determines the RAM and disk space to use |
|
4562 * for caching previously viewed content . |
|
4563 * |
|
4564 * Research indicates that users tend to browse within clusters of |
|
4565 * documents that hold resources in common, and to revisit previously |
|
4566 * visited documents. WebKit and the frameworks below it include |
|
4567 * built-in caches that take advantage of these patterns, |
|
4568 * substantially improving document load speed in browsing |
|
4569 * situations. The WebKit cache model controls the behaviors of all of |
|
4570 * these caches, including various WebCore caches. |
|
4571 * |
|
4572 * Browsers can improve document load speed substantially by |
|
4573 * specifying WEBKIT_CACHE_MODEL_WEB_BROWSER. Applications without a |
|
4574 * browsing interface can reduce memory usage substantially by |
|
4575 * specifying WEBKIT_CACHE_MODEL_DOCUMENT_VIEWER. Default value is |
|
4576 * WEBKIT_CACHE_MODEL_WEB_BROWSER. |
|
4577 * |
|
4578 * Since: 1.1.18 |
|
4579 */ |
|
4580 void webkit_set_cache_model(WebKitCacheModel model) |
|
4581 { |
|
4582 webkit_init(); |
|
4583 |
|
4584 if (cacheModel == model) |
|
4585 return; |
|
4586 |
|
4587 // FIXME: Add disk cache handling when soup has the API |
|
4588 guint cacheTotalCapacity; |
|
4589 guint cacheMinDeadCapacity; |
|
4590 guint cacheMaxDeadCapacity; |
|
4591 gdouble deadDecodedDataDeletionInterval; |
|
4592 guint pageCacheCapacity; |
|
4593 |
|
4594 switch (model) { |
|
4595 case WEBKIT_CACHE_MODEL_DOCUMENT_VIEWER: |
|
4596 pageCacheCapacity = 0; |
|
4597 cacheTotalCapacity = 0; |
|
4598 cacheMinDeadCapacity = 0; |
|
4599 cacheMaxDeadCapacity = 0; |
|
4600 deadDecodedDataDeletionInterval = 0; |
|
4601 break; |
|
4602 case WEBKIT_CACHE_MODEL_WEB_BROWSER: |
|
4603 pageCacheCapacity = 3; |
|
4604 cacheTotalCapacity = 32 * 1024 * 1024; |
|
4605 cacheMinDeadCapacity = cacheTotalCapacity / 4; |
|
4606 cacheMaxDeadCapacity = cacheTotalCapacity / 2; |
|
4607 deadDecodedDataDeletionInterval = 60; |
|
4608 break; |
|
4609 default: |
|
4610 g_return_if_reached(); |
|
4611 } |
|
4612 |
|
4613 cache()->setCapacities(cacheMinDeadCapacity, cacheMaxDeadCapacity, cacheTotalCapacity); |
|
4614 cache()->setDeadDecodedDataDeletionInterval(deadDecodedDataDeletionInterval); |
|
4615 pageCache()->setCapacity(pageCacheCapacity); |
|
4616 cacheModel = model; |
|
4617 } |
|
4618 |
|
4619 /** |
|
4620 * webkit_get_cache_model: |
|
4621 * |
|
4622 * Returns the current cache model. For more information about this |
|
4623 * value check the documentation of the function |
|
4624 * webkit_set_cache_model(). |
|
4625 * |
|
4626 * Return value: the current #WebKitCacheModel |
|
4627 * |
|
4628 * Since: 1.1.18 |
|
4629 */ |
|
4630 WebKitCacheModel webkit_get_cache_model() |
|
4631 { |
|
4632 webkit_init(); |
|
4633 return cacheModel; |
|
4634 } |