|
1 /* |
|
2 * Copyright (C) 2007, 2008 Holger Hans Peter Freyther |
|
3 * Copyright (C) 2007 Alp Toker <alp@atoker.com> |
|
4 * Copyright (C) 2007 Apple Inc. |
|
5 * Copyright (C) 2008 Christian Dywan <christian@imendio.com> |
|
6 * Copyright (C) 2008 Collabora Ltd. |
|
7 * Copyright (C) 2008 Nuanti Ltd. |
|
8 * Copyright (C) 2009 Jan Alonzo <jmalonzo@gmail.com> |
|
9 * Copyright (C) 2009 Gustavo Noronha Silva <gns@gnome.org> |
|
10 * |
|
11 * This library is free software; you can redistribute it and/or |
|
12 * modify it under the terms of the GNU Library General Public |
|
13 * License as published by the Free Software Foundation; either |
|
14 * version 2 of the License, or (at your option) any later version. |
|
15 * |
|
16 * This library is distributed in the hope that it will be useful, |
|
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
19 * Library General Public License for more details. |
|
20 * |
|
21 * You should have received a copy of the GNU Library General Public License |
|
22 * along with this library; see the file COPYING.LIB. If not, write to |
|
23 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
|
24 * Boston, MA 02110-1301, USA. |
|
25 */ |
|
26 |
|
27 #include "config.h" |
|
28 |
|
29 #include "webkitenumtypes.h" |
|
30 #include "webkitwebframe.h" |
|
31 #include "webkitwebview.h" |
|
32 #include "webkitmarshal.h" |
|
33 #include "webkitprivate.h" |
|
34 |
|
35 #include "AccessibilityObjectWrapperAtk.h" |
|
36 #include "AnimationController.h" |
|
37 #include "AXObjectCache.h" |
|
38 #include "DocumentLoader.h" |
|
39 #include "DocumentLoaderGtk.h" |
|
40 #include "FrameLoader.h" |
|
41 #include "FrameLoaderClientGtk.h" |
|
42 #include "FrameTree.h" |
|
43 #include "FrameView.h" |
|
44 #include <glib/gi18n-lib.h> |
|
45 #include "GCController.h" |
|
46 #include "GraphicsContext.h" |
|
47 #include "GtkVersioning.h" |
|
48 #include "HTMLFrameOwnerElement.h" |
|
49 #include "JSDOMWindow.h" |
|
50 #include "JSElement.h" |
|
51 #include "JSLock.h" |
|
52 #include "PrintContext.h" |
|
53 #include "RenderListItem.h" |
|
54 #include "RenderView.h" |
|
55 #include "RenderTreeAsText.h" |
|
56 #include "JSDOMBinding.h" |
|
57 #include "ScriptController.h" |
|
58 #include "SubstituteData.h" |
|
59 #if ENABLE(SVG) |
|
60 #include "SVGSMILElement.h" |
|
61 #endif |
|
62 |
|
63 #include <atk/atk.h> |
|
64 #include <JavaScriptCore/APICast.h> |
|
65 #include <wtf/text/CString.h> |
|
66 |
|
67 /** |
|
68 * SECTION:webkitwebframe |
|
69 * @short_description: The content of a #WebKitWebView |
|
70 * |
|
71 * A #WebKitWebView contains a main #WebKitWebFrame. A #WebKitWebFrame |
|
72 * contains the content of one URI. The URI and name of the frame can |
|
73 * be retrieved, the load status and progress can be observed using the |
|
74 * signals and can be controlled using the methods of the #WebKitWebFrame. |
|
75 * A #WebKitWebFrame can have any number of children and one child can |
|
76 * be found by using #webkit_web_frame_find_frame. |
|
77 * |
|
78 * <informalexample><programlisting> |
|
79 * /<!-- -->* Get the frame from the #WebKitWebView *<!-- -->/ |
|
80 * WebKitWebFrame *frame = webkit_web_view_get_main_frame (WEBKIT_WEB_VIEW(my_view)); |
|
81 * g_print("The URI of this frame is '%s'", webkit_web_frame_get_uri (frame)); |
|
82 * </programlisting></informalexample> |
|
83 */ |
|
84 |
|
85 using namespace WebKit; |
|
86 using namespace WebCore; |
|
87 using namespace std; |
|
88 |
|
89 enum { |
|
90 CLEARED, |
|
91 LOAD_COMMITTED, |
|
92 LOAD_DONE, |
|
93 TITLE_CHANGED, |
|
94 HOVERING_OVER_LINK, |
|
95 SCROLLBARS_POLICY_CHANGED, |
|
96 LAST_SIGNAL |
|
97 }; |
|
98 |
|
99 enum { |
|
100 PROP_0, |
|
101 |
|
102 PROP_NAME, |
|
103 PROP_TITLE, |
|
104 PROP_URI, |
|
105 PROP_LOAD_STATUS, |
|
106 PROP_HORIZONTAL_SCROLLBAR_POLICY, |
|
107 PROP_VERTICAL_SCROLLBAR_POLICY |
|
108 }; |
|
109 |
|
110 static guint webkit_web_frame_signals[LAST_SIGNAL] = { 0, }; |
|
111 |
|
112 G_DEFINE_TYPE(WebKitWebFrame, webkit_web_frame, G_TYPE_OBJECT) |
|
113 |
|
114 static void webkit_web_frame_get_property(GObject* object, guint prop_id, GValue* value, GParamSpec* pspec) |
|
115 { |
|
116 WebKitWebFrame* frame = WEBKIT_WEB_FRAME(object); |
|
117 |
|
118 switch(prop_id) { |
|
119 case PROP_NAME: |
|
120 g_value_set_string(value, webkit_web_frame_get_name(frame)); |
|
121 break; |
|
122 case PROP_TITLE: |
|
123 g_value_set_string(value, webkit_web_frame_get_title(frame)); |
|
124 break; |
|
125 case PROP_URI: |
|
126 g_value_set_string(value, webkit_web_frame_get_uri(frame)); |
|
127 break; |
|
128 case PROP_LOAD_STATUS: |
|
129 g_value_set_enum(value, webkit_web_frame_get_load_status(frame)); |
|
130 break; |
|
131 case PROP_HORIZONTAL_SCROLLBAR_POLICY: |
|
132 g_value_set_enum(value, webkit_web_frame_get_horizontal_scrollbar_policy(frame)); |
|
133 break; |
|
134 case PROP_VERTICAL_SCROLLBAR_POLICY: |
|
135 g_value_set_enum(value, webkit_web_frame_get_vertical_scrollbar_policy(frame)); |
|
136 break; |
|
137 default: |
|
138 G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); |
|
139 break; |
|
140 } |
|
141 } |
|
142 |
|
143 // Called from the FrameLoaderClient when it is destroyed. Normally |
|
144 // the unref in the FrameLoaderClient is destroying this object as |
|
145 // well but due reference counting a user might have added a reference... |
|
146 void webkit_web_frame_core_frame_gone(WebKitWebFrame* frame) |
|
147 { |
|
148 ASSERT(WEBKIT_IS_WEB_FRAME(frame)); |
|
149 frame->priv->coreFrame = 0; |
|
150 } |
|
151 |
|
152 static WebKitWebDataSource* webkit_web_frame_get_data_source_from_core_loader(WebCore::DocumentLoader* loader) |
|
153 { |
|
154 return loader ? static_cast<WebKit::DocumentLoader*>(loader)->dataSource() : NULL; |
|
155 } |
|
156 |
|
157 static void webkit_web_frame_finalize(GObject* object) |
|
158 { |
|
159 WebKitWebFrame* frame = WEBKIT_WEB_FRAME(object); |
|
160 WebKitWebFramePrivate* priv = frame->priv; |
|
161 |
|
162 if (priv->coreFrame) { |
|
163 priv->coreFrame->loader()->cancelAndClear(); |
|
164 priv->coreFrame = 0; |
|
165 } |
|
166 |
|
167 g_free(priv->name); |
|
168 g_free(priv->title); |
|
169 g_free(priv->uri); |
|
170 |
|
171 G_OBJECT_CLASS(webkit_web_frame_parent_class)->finalize(object); |
|
172 } |
|
173 |
|
174 static void webkit_web_frame_class_init(WebKitWebFrameClass* frameClass) |
|
175 { |
|
176 webkit_init(); |
|
177 |
|
178 /* |
|
179 * signals |
|
180 */ |
|
181 webkit_web_frame_signals[CLEARED] = g_signal_new("cleared", |
|
182 G_TYPE_FROM_CLASS(frameClass), |
|
183 (GSignalFlags)G_SIGNAL_RUN_LAST, |
|
184 0, |
|
185 NULL, |
|
186 NULL, |
|
187 g_cclosure_marshal_VOID__VOID, |
|
188 G_TYPE_NONE, 0); |
|
189 |
|
190 /** |
|
191 * WebKitWebFrame::load-done |
|
192 * @web_frame: the object on which the signal is emitted |
|
193 * |
|
194 * Emitted when frame loading is done. |
|
195 * |
|
196 * Deprecated: Use the "load-status" property instead. |
|
197 */ |
|
198 webkit_web_frame_signals[LOAD_COMMITTED] = g_signal_new("load-committed", |
|
199 G_TYPE_FROM_CLASS(frameClass), |
|
200 (GSignalFlags)G_SIGNAL_RUN_LAST, |
|
201 0, |
|
202 NULL, |
|
203 NULL, |
|
204 g_cclosure_marshal_VOID__VOID, |
|
205 G_TYPE_NONE, 0); |
|
206 |
|
207 /** |
|
208 * WebKitWebFrame::load-done |
|
209 * @web_frame: the object on which the signal is emitted |
|
210 * |
|
211 * Emitted when frame loading is done. |
|
212 * |
|
213 * Deprecated: Use the "load-status" property instead, and/or |
|
214 * WebKitWebView::load-error to be notified of load errors |
|
215 */ |
|
216 webkit_web_frame_signals[LOAD_DONE] = g_signal_new("load-done", |
|
217 G_TYPE_FROM_CLASS(frameClass), |
|
218 (GSignalFlags)G_SIGNAL_RUN_LAST, |
|
219 0, |
|
220 NULL, |
|
221 NULL, |
|
222 g_cclosure_marshal_VOID__BOOLEAN, |
|
223 G_TYPE_NONE, 1, |
|
224 G_TYPE_BOOLEAN); |
|
225 |
|
226 /** |
|
227 * WebKitWebFrame::title-changed: |
|
228 * @frame: the object on which the signal is emitted |
|
229 * @title: the new title |
|
230 * |
|
231 * When a #WebKitWebFrame changes the document title this signal is emitted. |
|
232 * |
|
233 * Deprecated: 1.1.18: Use "notify::title" instead. |
|
234 */ |
|
235 webkit_web_frame_signals[TITLE_CHANGED] = g_signal_new("title-changed", |
|
236 G_TYPE_FROM_CLASS(frameClass), |
|
237 (GSignalFlags)G_SIGNAL_RUN_LAST, |
|
238 0, |
|
239 NULL, |
|
240 NULL, |
|
241 webkit_marshal_VOID__STRING, |
|
242 G_TYPE_NONE, 1, |
|
243 G_TYPE_STRING); |
|
244 |
|
245 webkit_web_frame_signals[HOVERING_OVER_LINK] = g_signal_new("hovering-over-link", |
|
246 G_TYPE_FROM_CLASS(frameClass), |
|
247 (GSignalFlags)G_SIGNAL_RUN_LAST, |
|
248 0, |
|
249 NULL, |
|
250 NULL, |
|
251 webkit_marshal_VOID__STRING_STRING, |
|
252 G_TYPE_NONE, 2, |
|
253 G_TYPE_STRING, G_TYPE_STRING); |
|
254 |
|
255 /** |
|
256 * WebKitWebFrame::scrollbars-policy-changed: |
|
257 * @web_view: the object which received the signal |
|
258 * |
|
259 * Signal emitted when policy for one or both of the scrollbars of |
|
260 * the view has changed. The default handler will apply the new |
|
261 * policy to the container that holds the #WebKitWebFrame if it is |
|
262 * a #GtkScrolledWindow and the frame is the main frame. If you do |
|
263 * not want this to be handled automatically, you need to handle |
|
264 * this signal. |
|
265 * |
|
266 * The exception to this rule is that policies to disable the |
|
267 * scrollbars are applied as %GTK_POLICY_AUTOMATIC instead, since |
|
268 * the size request of the widget would force browser windows to |
|
269 * not be resizable. |
|
270 * |
|
271 * You can obtain the new policies from the |
|
272 * WebKitWebFrame:horizontal-scrollbar-policy and |
|
273 * WebKitWebFrame:vertical-scrollbar-policy properties. |
|
274 * |
|
275 * Return value: %TRUE to stop other handlers from being invoked for the |
|
276 * event. %FALSE to propagate the event further. |
|
277 * |
|
278 * Since: 1.1.14 |
|
279 */ |
|
280 webkit_web_frame_signals[SCROLLBARS_POLICY_CHANGED] = g_signal_new("scrollbars-policy-changed", |
|
281 G_TYPE_FROM_CLASS(frameClass), |
|
282 (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION), |
|
283 0, |
|
284 g_signal_accumulator_true_handled, |
|
285 NULL, |
|
286 webkit_marshal_BOOLEAN__VOID, |
|
287 G_TYPE_BOOLEAN, 0); |
|
288 |
|
289 /* |
|
290 * implementations of virtual methods |
|
291 */ |
|
292 GObjectClass* objectClass = G_OBJECT_CLASS(frameClass); |
|
293 objectClass->finalize = webkit_web_frame_finalize; |
|
294 objectClass->get_property = webkit_web_frame_get_property; |
|
295 |
|
296 /* |
|
297 * properties |
|
298 */ |
|
299 g_object_class_install_property(objectClass, PROP_NAME, |
|
300 g_param_spec_string("name", |
|
301 _("Name"), |
|
302 _("The name of the frame"), |
|
303 NULL, |
|
304 WEBKIT_PARAM_READABLE)); |
|
305 |
|
306 g_object_class_install_property(objectClass, PROP_TITLE, |
|
307 g_param_spec_string("title", |
|
308 _("Title"), |
|
309 _("The document title of the frame"), |
|
310 NULL, |
|
311 WEBKIT_PARAM_READABLE)); |
|
312 |
|
313 g_object_class_install_property(objectClass, PROP_URI, |
|
314 g_param_spec_string("uri", |
|
315 _("URI"), |
|
316 _("The current URI of the contents displayed by the frame"), |
|
317 NULL, |
|
318 WEBKIT_PARAM_READABLE)); |
|
319 |
|
320 /** |
|
321 * WebKitWebFrame:load-status: |
|
322 * |
|
323 * Determines the current status of the load. |
|
324 * |
|
325 * Since: 1.1.7 |
|
326 */ |
|
327 g_object_class_install_property(objectClass, PROP_LOAD_STATUS, |
|
328 g_param_spec_enum("load-status", |
|
329 "Load Status", |
|
330 "Determines the current status of the load", |
|
331 WEBKIT_TYPE_LOAD_STATUS, |
|
332 WEBKIT_LOAD_FINISHED, |
|
333 WEBKIT_PARAM_READABLE)); |
|
334 |
|
335 /** |
|
336 * WebKitWebFrame:horizontal-scrollbar-policy: |
|
337 * |
|
338 * Determines the current policy for the horizontal scrollbar of |
|
339 * the frame. For the main frame, make sure to set the same policy |
|
340 * on the scrollable widget containing the #WebKitWebView, unless |
|
341 * you know what you are doing. |
|
342 * |
|
343 * Since: 1.1.14 |
|
344 */ |
|
345 g_object_class_install_property(objectClass, PROP_HORIZONTAL_SCROLLBAR_POLICY, |
|
346 g_param_spec_enum("horizontal-scrollbar-policy", |
|
347 _("Horizontal Scrollbar Policy"), |
|
348 _("Determines the current policy for the horizontal scrollbar of the frame."), |
|
349 GTK_TYPE_POLICY_TYPE, |
|
350 GTK_POLICY_AUTOMATIC, |
|
351 WEBKIT_PARAM_READABLE)); |
|
352 |
|
353 /** |
|
354 * WebKitWebFrame:vertical-scrollbar-policy: |
|
355 * |
|
356 * Determines the current policy for the vertical scrollbar of |
|
357 * the frame. For the main frame, make sure to set the same policy |
|
358 * on the scrollable widget containing the #WebKitWebView, unless |
|
359 * you know what you are doing. |
|
360 * |
|
361 * Since: 1.1.14 |
|
362 */ |
|
363 g_object_class_install_property(objectClass, PROP_VERTICAL_SCROLLBAR_POLICY, |
|
364 g_param_spec_enum("vertical-scrollbar-policy", |
|
365 _("Vertical Scrollbar Policy"), |
|
366 _("Determines the current policy for the vertical scrollbar of the frame."), |
|
367 GTK_TYPE_POLICY_TYPE, |
|
368 GTK_POLICY_AUTOMATIC, |
|
369 WEBKIT_PARAM_READABLE)); |
|
370 |
|
371 g_type_class_add_private(frameClass, sizeof(WebKitWebFramePrivate)); |
|
372 } |
|
373 |
|
374 static void webkit_web_frame_init(WebKitWebFrame* frame) |
|
375 { |
|
376 WebKitWebFramePrivate* priv = WEBKIT_WEB_FRAME_GET_PRIVATE(frame); |
|
377 |
|
378 // TODO: Move constructor code here. |
|
379 frame->priv = priv; |
|
380 } |
|
381 |
|
382 /** |
|
383 * webkit_web_frame_new: |
|
384 * @web_view: the controlling #WebKitWebView |
|
385 * |
|
386 * Creates a new #WebKitWebFrame initialized with a controlling #WebKitWebView. |
|
387 * |
|
388 * Returns: a new #WebKitWebFrame |
|
389 * |
|
390 * Deprecated: 1.0.2: #WebKitWebFrame can only be used to inspect existing |
|
391 * frames. |
|
392 **/ |
|
393 WebKitWebFrame* webkit_web_frame_new(WebKitWebView* webView) |
|
394 { |
|
395 g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), NULL); |
|
396 |
|
397 WebKitWebFrame* frame = WEBKIT_WEB_FRAME(g_object_new(WEBKIT_TYPE_WEB_FRAME, NULL)); |
|
398 WebKitWebFramePrivate* priv = frame->priv; |
|
399 WebKitWebViewPrivate* viewPriv = WEBKIT_WEB_VIEW_GET_PRIVATE(webView); |
|
400 |
|
401 priv->webView = webView; |
|
402 WebKit::FrameLoaderClient* client = new WebKit::FrameLoaderClient(frame); |
|
403 priv->coreFrame = Frame::create(viewPriv->corePage, 0, client).get(); |
|
404 priv->coreFrame->init(); |
|
405 |
|
406 priv->origin = NULL; |
|
407 |
|
408 return frame; |
|
409 } |
|
410 |
|
411 PassRefPtr<Frame> webkit_web_frame_init_with_web_view(WebKitWebView* webView, HTMLFrameOwnerElement* element) |
|
412 { |
|
413 WebKitWebFrame* frame = WEBKIT_WEB_FRAME(g_object_new(WEBKIT_TYPE_WEB_FRAME, NULL)); |
|
414 WebKitWebFramePrivate* priv = frame->priv; |
|
415 WebKitWebViewPrivate* viewPriv = WEBKIT_WEB_VIEW_GET_PRIVATE(webView); |
|
416 |
|
417 priv->webView = webView; |
|
418 WebKit::FrameLoaderClient* client = new WebKit::FrameLoaderClient(frame); |
|
419 |
|
420 RefPtr<Frame> coreFrame = Frame::create(viewPriv->corePage, element, client); |
|
421 priv->coreFrame = coreFrame.get(); |
|
422 |
|
423 return coreFrame.release(); |
|
424 } |
|
425 |
|
426 /** |
|
427 * webkit_web_frame_get_title: |
|
428 * @frame: a #WebKitWebFrame |
|
429 * |
|
430 * Returns the @frame's document title |
|
431 * |
|
432 * Return value: the title of @frame |
|
433 */ |
|
434 G_CONST_RETURN gchar* webkit_web_frame_get_title(WebKitWebFrame* frame) |
|
435 { |
|
436 g_return_val_if_fail(WEBKIT_IS_WEB_FRAME(frame), NULL); |
|
437 |
|
438 WebKitWebFramePrivate* priv = frame->priv; |
|
439 return priv->title; |
|
440 } |
|
441 |
|
442 /** |
|
443 * webkit_web_frame_get_uri: |
|
444 * @frame: a #WebKitWebFrame |
|
445 * |
|
446 * Returns the current URI of the contents displayed by the @frame |
|
447 * |
|
448 * Return value: the URI of @frame |
|
449 */ |
|
450 G_CONST_RETURN gchar* webkit_web_frame_get_uri(WebKitWebFrame* frame) |
|
451 { |
|
452 g_return_val_if_fail(WEBKIT_IS_WEB_FRAME(frame), NULL); |
|
453 |
|
454 WebKitWebFramePrivate* priv = frame->priv; |
|
455 return priv->uri; |
|
456 } |
|
457 |
|
458 /** |
|
459 * webkit_web_frame_get_web_view: |
|
460 * @frame: a #WebKitWebFrame |
|
461 * |
|
462 * Returns the #WebKitWebView that manages this #WebKitWebFrame. |
|
463 * |
|
464 * The #WebKitWebView returned manages the entire hierarchy of #WebKitWebFrame |
|
465 * objects that contains @frame. |
|
466 * |
|
467 * Return value: the #WebKitWebView that manages @frame |
|
468 */ |
|
469 WebKitWebView* webkit_web_frame_get_web_view(WebKitWebFrame* frame) |
|
470 { |
|
471 g_return_val_if_fail(WEBKIT_IS_WEB_FRAME(frame), NULL); |
|
472 |
|
473 WebKitWebFramePrivate* priv = frame->priv; |
|
474 return priv->webView; |
|
475 } |
|
476 |
|
477 /** |
|
478 * webkit_web_frame_get_name: |
|
479 * @frame: a #WebKitWebFrame |
|
480 * |
|
481 * Returns the @frame's name |
|
482 * |
|
483 * Return value: the name of @frame |
|
484 */ |
|
485 G_CONST_RETURN gchar* webkit_web_frame_get_name(WebKitWebFrame* frame) |
|
486 { |
|
487 g_return_val_if_fail(WEBKIT_IS_WEB_FRAME(frame), NULL); |
|
488 |
|
489 WebKitWebFramePrivate* priv = frame->priv; |
|
490 |
|
491 if (priv->name) |
|
492 return priv->name; |
|
493 |
|
494 Frame* coreFrame = core(frame); |
|
495 if (!coreFrame) |
|
496 return ""; |
|
497 |
|
498 String string = coreFrame->tree()->name(); |
|
499 priv->name = g_strdup(string.utf8().data()); |
|
500 return priv->name; |
|
501 } |
|
502 |
|
503 /** |
|
504 * webkit_web_frame_get_parent: |
|
505 * @frame: a #WebKitWebFrame |
|
506 * |
|
507 * Returns the @frame's parent frame, or %NULL if it has none. |
|
508 * |
|
509 * Return value: the parent #WebKitWebFrame or %NULL in case there is none |
|
510 */ |
|
511 WebKitWebFrame* webkit_web_frame_get_parent(WebKitWebFrame* frame) |
|
512 { |
|
513 g_return_val_if_fail(WEBKIT_IS_WEB_FRAME(frame), NULL); |
|
514 |
|
515 Frame* coreFrame = core(frame); |
|
516 if (!coreFrame) |
|
517 return NULL; |
|
518 |
|
519 return kit(coreFrame->tree()->parent()); |
|
520 } |
|
521 |
|
522 /** |
|
523 * webkit_web_frame_load_uri: |
|
524 * @frame: a #WebKitWebFrame |
|
525 * @uri: an URI string |
|
526 * |
|
527 * Requests loading of the specified URI string. |
|
528 * |
|
529 * Since: 1.1.1 |
|
530 */ |
|
531 void webkit_web_frame_load_uri(WebKitWebFrame* frame, const gchar* uri) |
|
532 { |
|
533 g_return_if_fail(WEBKIT_IS_WEB_FRAME(frame)); |
|
534 g_return_if_fail(uri); |
|
535 |
|
536 Frame* coreFrame = core(frame); |
|
537 if (!coreFrame) |
|
538 return; |
|
539 |
|
540 coreFrame->loader()->load(ResourceRequest(KURL(KURL(), String::fromUTF8(uri))), false); |
|
541 } |
|
542 |
|
543 static void webkit_web_frame_load_data(WebKitWebFrame* frame, const gchar* content, const gchar* mimeType, const gchar* encoding, const gchar* baseURL, const gchar* unreachableURL) |
|
544 { |
|
545 Frame* coreFrame = core(frame); |
|
546 ASSERT(coreFrame); |
|
547 |
|
548 KURL baseKURL = baseURL ? KURL(KURL(), String::fromUTF8(baseURL)) : blankURL(); |
|
549 |
|
550 ResourceRequest request(baseKURL); |
|
551 |
|
552 RefPtr<SharedBuffer> sharedBuffer = SharedBuffer::create(content, strlen(content)); |
|
553 SubstituteData substituteData(sharedBuffer.release(), |
|
554 mimeType ? String::fromUTF8(mimeType) : String::fromUTF8("text/html"), |
|
555 encoding ? String::fromUTF8(encoding) : String::fromUTF8("UTF-8"), |
|
556 KURL(KURL(), String::fromUTF8(unreachableURL)), |
|
557 KURL(KURL(), String::fromUTF8(unreachableURL))); |
|
558 |
|
559 coreFrame->loader()->load(request, substituteData, false); |
|
560 } |
|
561 |
|
562 /** |
|
563 * webkit_web_frame_load_string: |
|
564 * @frame: a #WebKitWebFrame |
|
565 * @content: an URI string |
|
566 * @mime_type: the MIME type, or %NULL |
|
567 * @encoding: the encoding, or %NULL |
|
568 * @base_uri: the base URI for relative locations |
|
569 * |
|
570 * Requests loading of the given @content with the specified @mime_type, |
|
571 * @encoding and @base_uri. |
|
572 * |
|
573 * If @mime_type is %NULL, "text/html" is assumed. |
|
574 * |
|
575 * If @encoding is %NULL, "UTF-8" is assumed. |
|
576 * |
|
577 * Since: 1.1.1 |
|
578 */ |
|
579 void webkit_web_frame_load_string(WebKitWebFrame* frame, const gchar* content, const gchar* contentMimeType, const gchar* contentEncoding, const gchar* baseUri) |
|
580 { |
|
581 g_return_if_fail(WEBKIT_IS_WEB_FRAME(frame)); |
|
582 g_return_if_fail(content); |
|
583 |
|
584 webkit_web_frame_load_data(frame, content, contentMimeType, contentEncoding, baseUri, NULL); |
|
585 } |
|
586 |
|
587 /** |
|
588 * webkit_web_frame_load_alternate_string: |
|
589 * @frame: a #WebKitWebFrame |
|
590 * @content: the alternate content to display as the main page of the @frame |
|
591 * @base_url: the base URI for relative locations |
|
592 * @unreachable_url: the URL for the alternate page content |
|
593 * |
|
594 * Request loading of an alternate content for a URL that is unreachable. |
|
595 * Using this method will preserve the back-forward list. The URI passed in |
|
596 * @base_url has to be an absolute URI. |
|
597 * |
|
598 * Since: 1.1.6 |
|
599 */ |
|
600 void webkit_web_frame_load_alternate_string(WebKitWebFrame* frame, const gchar* content, const gchar* baseURL, const gchar* unreachableURL) |
|
601 { |
|
602 g_return_if_fail(WEBKIT_IS_WEB_FRAME(frame)); |
|
603 g_return_if_fail(content); |
|
604 |
|
605 webkit_web_frame_load_data(frame, content, NULL, NULL, baseURL, unreachableURL); |
|
606 } |
|
607 |
|
608 /** |
|
609 * webkit_web_frame_load_request: |
|
610 * @frame: a #WebKitWebFrame |
|
611 * @request: a #WebKitNetworkRequest |
|
612 * |
|
613 * Connects to a given URI by initiating an asynchronous client request. |
|
614 * |
|
615 * Creates a provisional data source that will transition to a committed data |
|
616 * source once any data has been received. Use webkit_web_frame_stop_loading() to |
|
617 * stop the load. This function is typically invoked on the main frame. |
|
618 */ |
|
619 void webkit_web_frame_load_request(WebKitWebFrame* frame, WebKitNetworkRequest* request) |
|
620 { |
|
621 g_return_if_fail(WEBKIT_IS_WEB_FRAME(frame)); |
|
622 g_return_if_fail(WEBKIT_IS_NETWORK_REQUEST(request)); |
|
623 |
|
624 Frame* coreFrame = core(frame); |
|
625 if (!coreFrame) |
|
626 return; |
|
627 |
|
628 coreFrame->loader()->load(core(request), false); |
|
629 } |
|
630 |
|
631 /** |
|
632 * webkit_web_frame_stop_loading: |
|
633 * @frame: a #WebKitWebFrame |
|
634 * |
|
635 * Stops any pending loads on @frame's data source, and those of its children. |
|
636 */ |
|
637 void webkit_web_frame_stop_loading(WebKitWebFrame* frame) |
|
638 { |
|
639 g_return_if_fail(WEBKIT_IS_WEB_FRAME(frame)); |
|
640 |
|
641 Frame* coreFrame = core(frame); |
|
642 if (!coreFrame) |
|
643 return; |
|
644 |
|
645 coreFrame->loader()->stopAllLoaders(); |
|
646 } |
|
647 |
|
648 /** |
|
649 * webkit_web_frame_reload: |
|
650 * @frame: a #WebKitWebFrame |
|
651 * |
|
652 * Reloads the initial request. |
|
653 */ |
|
654 void webkit_web_frame_reload(WebKitWebFrame* frame) |
|
655 { |
|
656 g_return_if_fail(WEBKIT_IS_WEB_FRAME(frame)); |
|
657 |
|
658 Frame* coreFrame = core(frame); |
|
659 if (!coreFrame) |
|
660 return; |
|
661 |
|
662 coreFrame->loader()->reload(); |
|
663 } |
|
664 |
|
665 /** |
|
666 * webkit_web_frame_find_frame: |
|
667 * @frame: a #WebKitWebFrame |
|
668 * @name: the name of the frame to be found |
|
669 * |
|
670 * For pre-defined names, returns @frame if @name is "_self" or "_current", |
|
671 * returns @frame's parent frame if @name is "_parent", and returns the main |
|
672 * frame if @name is "_top". Also returns @frame if it is the main frame and |
|
673 * @name is either "_parent" or "_top". For other names, this function returns |
|
674 * the first frame that matches @name. This function searches @frame and its |
|
675 * descendents first, then @frame's parent and its children moving up the |
|
676 * hierarchy until a match is found. If no match is found in @frame's |
|
677 * hierarchy, this function will search for a matching frame in other main |
|
678 * frame hierarchies. Returns %NULL if no match is found. |
|
679 * |
|
680 * Return value: the found #WebKitWebFrame or %NULL in case none is found |
|
681 */ |
|
682 WebKitWebFrame* webkit_web_frame_find_frame(WebKitWebFrame* frame, const gchar* name) |
|
683 { |
|
684 g_return_val_if_fail(WEBKIT_IS_WEB_FRAME(frame), NULL); |
|
685 g_return_val_if_fail(name, NULL); |
|
686 |
|
687 Frame* coreFrame = core(frame); |
|
688 if (!coreFrame) |
|
689 return NULL; |
|
690 |
|
691 String nameString = String::fromUTF8(name); |
|
692 return kit(coreFrame->tree()->find(AtomicString(nameString))); |
|
693 } |
|
694 |
|
695 /** |
|
696 * webkit_web_frame_get_global_context: |
|
697 * @frame: a #WebKitWebFrame |
|
698 * |
|
699 * Gets the global JavaScript execution context. Use this function to bridge |
|
700 * between the WebKit and JavaScriptCore APIs. |
|
701 * |
|
702 * Return value: the global JavaScript context |
|
703 */ |
|
704 JSGlobalContextRef webkit_web_frame_get_global_context(WebKitWebFrame* frame) |
|
705 { |
|
706 g_return_val_if_fail(WEBKIT_IS_WEB_FRAME(frame), NULL); |
|
707 |
|
708 Frame* coreFrame = core(frame); |
|
709 if (!coreFrame) |
|
710 return NULL; |
|
711 |
|
712 return toGlobalRef(coreFrame->script()->globalObject(mainThreadNormalWorld())->globalExec()); |
|
713 } |
|
714 |
|
715 /** |
|
716 * webkit_web_frame_get_data_source: |
|
717 * @frame: a #WebKitWebFrame |
|
718 * |
|
719 * Returns the committed data source. |
|
720 * |
|
721 * Return value: the committed #WebKitWebDataSource. |
|
722 * |
|
723 * Since: 1.1.14 |
|
724 */ |
|
725 WebKitWebDataSource* webkit_web_frame_get_data_source(WebKitWebFrame* frame) |
|
726 { |
|
727 g_return_val_if_fail(WEBKIT_IS_WEB_FRAME(frame), NULL); |
|
728 |
|
729 Frame* coreFrame = core(frame); |
|
730 return webkit_web_frame_get_data_source_from_core_loader(coreFrame->loader()->documentLoader()); |
|
731 } |
|
732 |
|
733 /** |
|
734 * webkit_web_frame_get_provisional_data_source: |
|
735 * @frame: a #WebKitWebFrame |
|
736 * |
|
737 * You use the webkit_web_frame_load_request method to initiate a request that |
|
738 * creates a provisional data source. The provisional data source will |
|
739 * transition to a committed data source once any data has been received. Use |
|
740 * webkit_web_frame_get_data_source to get the committed data source. |
|
741 * |
|
742 * Return value: the provisional #WebKitWebDataSource or %NULL if a load |
|
743 * request is not in progress. |
|
744 * |
|
745 * Since: 1.1.14 |
|
746 */ |
|
747 WebKitWebDataSource* webkit_web_frame_get_provisional_data_source(WebKitWebFrame* frame) |
|
748 { |
|
749 g_return_val_if_fail(WEBKIT_IS_WEB_FRAME(frame), NULL); |
|
750 |
|
751 Frame* coreFrame = core(frame); |
|
752 return webkit_web_frame_get_data_source_from_core_loader(coreFrame->loader()->provisionalDocumentLoader()); |
|
753 } |
|
754 |
|
755 /** |
|
756 * webkit_web_frame_get_children: |
|
757 * @frame: a #WebKitWebFrame |
|
758 * |
|
759 * Return value: child frames of @frame |
|
760 */ |
|
761 GSList* webkit_web_frame_get_children(WebKitWebFrame* frame) |
|
762 { |
|
763 g_return_val_if_fail(WEBKIT_IS_WEB_FRAME(frame), NULL); |
|
764 |
|
765 Frame* coreFrame = core(frame); |
|
766 if (!coreFrame) |
|
767 return NULL; |
|
768 |
|
769 GSList* children = NULL; |
|
770 for (Frame* child = coreFrame->tree()->firstChild(); child; child = child->tree()->nextSibling()) { |
|
771 FrameLoader* loader = child->loader(); |
|
772 WebKit::FrameLoaderClient* client = static_cast<WebKit::FrameLoaderClient*>(loader->client()); |
|
773 if (client) |
|
774 children = g_slist_append(children, client->webFrame()); |
|
775 } |
|
776 |
|
777 return children; |
|
778 } |
|
779 |
|
780 /** |
|
781 * webkit_web_frame_get_inner_text: |
|
782 * @frame: a #WebKitWebFrame |
|
783 * |
|
784 * Return value: inner text of @frame |
|
785 */ |
|
786 gchar* webkit_web_frame_get_inner_text(WebKitWebFrame* frame) |
|
787 { |
|
788 g_return_val_if_fail(WEBKIT_IS_WEB_FRAME(frame), NULL); |
|
789 |
|
790 Frame* coreFrame = core(frame); |
|
791 if (!coreFrame) |
|
792 return g_strdup(""); |
|
793 |
|
794 FrameView* view = coreFrame->view(); |
|
795 |
|
796 if (view && view->layoutPending()) |
|
797 view->layout(); |
|
798 |
|
799 Element* documentElement = coreFrame->document()->documentElement(); |
|
800 String string = documentElement->innerText(); |
|
801 return g_strdup(string.utf8().data()); |
|
802 } |
|
803 |
|
804 /** |
|
805 * webkit_web_frame_dump_render_tree: |
|
806 * @frame: a #WebKitWebFrame |
|
807 * |
|
808 * Return value: Non-recursive render tree dump of @frame |
|
809 */ |
|
810 gchar* webkit_web_frame_dump_render_tree(WebKitWebFrame* frame) |
|
811 { |
|
812 g_return_val_if_fail(WEBKIT_IS_WEB_FRAME(frame), NULL); |
|
813 |
|
814 Frame* coreFrame = core(frame); |
|
815 if (!coreFrame) |
|
816 return g_strdup(""); |
|
817 |
|
818 FrameView* view = coreFrame->view(); |
|
819 |
|
820 if (view && view->layoutPending()) |
|
821 view->layout(); |
|
822 |
|
823 String string = externalRepresentation(coreFrame); |
|
824 return g_strdup(string.utf8().data()); |
|
825 } |
|
826 |
|
827 /** |
|
828 * webkit_web_frame_counter_value_for_element_by_id: |
|
829 * @frame: a #WebKitWebFrame |
|
830 * @id: an element ID string |
|
831 * |
|
832 * Return value: The counter value of element @id in @frame |
|
833 */ |
|
834 gchar* webkit_web_frame_counter_value_for_element_by_id(WebKitWebFrame* frame, const gchar* id) |
|
835 { |
|
836 g_return_val_if_fail(WEBKIT_IS_WEB_FRAME(frame), NULL); |
|
837 |
|
838 Frame* coreFrame = core(frame); |
|
839 if (!coreFrame) |
|
840 return 0; |
|
841 |
|
842 Element* coreElement = coreFrame->document()->getElementById(AtomicString(id)); |
|
843 if (!coreElement) |
|
844 return 0; |
|
845 String counterValue = counterValueForElement(coreElement); |
|
846 return g_strdup(counterValue.utf8().data()); |
|
847 } |
|
848 |
|
849 /** |
|
850 * webkit_web_frame_page_number_for_element_by_id |
|
851 * @frame: a #WebKitWebFrame |
|
852 * @id: an element ID string |
|
853 * @pageWidth: width of a page |
|
854 * @pageHeight: height of a page |
|
855 * |
|
856 * Return value: The number of page where the specified element will be put |
|
857 */ |
|
858 int webkit_web_frame_page_number_for_element_by_id(WebKitWebFrame* frame, const gchar* id, float pageWidth, float pageHeight) |
|
859 { |
|
860 g_return_val_if_fail(WEBKIT_IS_WEB_FRAME(frame), NULL); |
|
861 |
|
862 Frame* coreFrame = core(frame); |
|
863 if (!coreFrame) |
|
864 return -1; |
|
865 |
|
866 Element* coreElement = coreFrame->document()->getElementById(AtomicString(id)); |
|
867 if (!coreElement) |
|
868 return -1; |
|
869 return PrintContext::pageNumberForElement(coreElement, FloatSize(pageWidth, pageHeight)); |
|
870 } |
|
871 |
|
872 /** |
|
873 * webkit_web_frame_number_of_pages |
|
874 * @frame: a #WebKitWebFrame |
|
875 * @pageWidth: width of a page |
|
876 * @pageHeight: height of a page |
|
877 * |
|
878 * Return value: The number of pages to be printed. |
|
879 */ |
|
880 int webkit_web_frame_number_of_pages(WebKitWebFrame* frame, float pageWidth, float pageHeight) |
|
881 { |
|
882 g_return_val_if_fail(WEBKIT_IS_WEB_FRAME(frame), NULL); |
|
883 |
|
884 Frame* coreFrame = core(frame); |
|
885 if (!coreFrame) |
|
886 return -1; |
|
887 |
|
888 return PrintContext::numberOfPages(coreFrame, FloatSize(pageWidth, pageHeight)); |
|
889 } |
|
890 |
|
891 /** |
|
892 * webkit_web_frame_get_pending_unload_event_count: |
|
893 * @frame: a #WebKitWebFrame |
|
894 * |
|
895 * Return value: number of pending unload events |
|
896 */ |
|
897 guint webkit_web_frame_get_pending_unload_event_count(WebKitWebFrame* frame) |
|
898 { |
|
899 g_return_val_if_fail(WEBKIT_IS_WEB_FRAME(frame), 0); |
|
900 |
|
901 return core(frame)->domWindow()->pendingUnloadEventListeners(); |
|
902 } |
|
903 |
|
904 static void begin_print_callback(GtkPrintOperation* op, GtkPrintContext* context, gpointer user_data) |
|
905 { |
|
906 PrintContext* printContext = reinterpret_cast<PrintContext*>(user_data); |
|
907 |
|
908 float width = gtk_print_context_get_width(context); |
|
909 float height = gtk_print_context_get_height(context); |
|
910 FloatRect printRect = FloatRect(0, 0, width, height); |
|
911 |
|
912 printContext->begin(width); |
|
913 |
|
914 // TODO: Margin adjustments and header/footer support |
|
915 float headerHeight = 0; |
|
916 float footerHeight = 0; |
|
917 float pageHeight; // height of the page adjusted by margins |
|
918 printContext->computePageRects(printRect, headerHeight, footerHeight, 1.0, pageHeight); |
|
919 gtk_print_operation_set_n_pages(op, printContext->pageCount()); |
|
920 } |
|
921 |
|
922 static void draw_page_callback(GtkPrintOperation* op, GtkPrintContext* context, gint page_nr, gpointer user_data) |
|
923 { |
|
924 PrintContext* printContext = reinterpret_cast<PrintContext*>(user_data); |
|
925 |
|
926 if (page_nr >= printContext->pageCount()) |
|
927 return; |
|
928 |
|
929 cairo_t* cr = gtk_print_context_get_cairo_context(context); |
|
930 GraphicsContext ctx(cr); |
|
931 float width = gtk_print_context_get_width(context); |
|
932 printContext->spoolPage(ctx, page_nr, width); |
|
933 } |
|
934 |
|
935 static void end_print_callback(GtkPrintOperation* op, GtkPrintContext* context, gpointer user_data) |
|
936 { |
|
937 PrintContext* printContext = reinterpret_cast<PrintContext*>(user_data); |
|
938 printContext->end(); |
|
939 } |
|
940 |
|
941 /** |
|
942 * webkit_web_frame_print_full: |
|
943 * @frame: a #WebKitWebFrame to be printed |
|
944 * @operation: the #GtkPrintOperation to be carried |
|
945 * @action: the #GtkPrintOperationAction to be performed |
|
946 * @error: #GError for error return |
|
947 * |
|
948 * Prints the given #WebKitWebFrame, using the given #GtkPrintOperation |
|
949 * and #GtkPrintOperationAction. This function wraps a call to |
|
950 * gtk_print_operation_run() for printing the contents of the |
|
951 * #WebKitWebFrame. |
|
952 * |
|
953 * Since: 1.1.5 |
|
954 */ |
|
955 GtkPrintOperationResult webkit_web_frame_print_full(WebKitWebFrame* frame, GtkPrintOperation* operation, GtkPrintOperationAction action, GError** error) |
|
956 { |
|
957 g_return_val_if_fail(WEBKIT_IS_WEB_FRAME(frame), GTK_PRINT_OPERATION_RESULT_ERROR); |
|
958 g_return_val_if_fail(GTK_IS_PRINT_OPERATION(operation), GTK_PRINT_OPERATION_RESULT_ERROR); |
|
959 |
|
960 GtkWidget* topLevel = gtk_widget_get_toplevel(GTK_WIDGET(webkit_web_frame_get_web_view(frame))); |
|
961 |
|
962 if (!gtk_widget_is_toplevel(topLevel)) |
|
963 topLevel = NULL; |
|
964 |
|
965 Frame* coreFrame = core(frame); |
|
966 if (!coreFrame) |
|
967 return GTK_PRINT_OPERATION_RESULT_ERROR; |
|
968 |
|
969 PrintContext printContext(coreFrame); |
|
970 |
|
971 g_signal_connect(operation, "begin-print", G_CALLBACK(begin_print_callback), &printContext); |
|
972 g_signal_connect(operation, "draw-page", G_CALLBACK(draw_page_callback), &printContext); |
|
973 g_signal_connect(operation, "end-print", G_CALLBACK(end_print_callback), &printContext); |
|
974 |
|
975 return gtk_print_operation_run(operation, action, GTK_WINDOW(topLevel), error); |
|
976 } |
|
977 |
|
978 /** |
|
979 * webkit_web_frame_print: |
|
980 * @frame: a #WebKitWebFrame |
|
981 * |
|
982 * Prints the given #WebKitWebFrame, by presenting a print dialog to the |
|
983 * user. If you need more control over the printing process, see |
|
984 * webkit_web_frame_print_full(). |
|
985 * |
|
986 * Since: 1.1.5 |
|
987 */ |
|
988 void webkit_web_frame_print(WebKitWebFrame* frame) |
|
989 { |
|
990 g_return_if_fail(WEBKIT_IS_WEB_FRAME(frame)); |
|
991 |
|
992 WebKitWebFramePrivate* priv = frame->priv; |
|
993 GtkPrintOperation* operation = gtk_print_operation_new(); |
|
994 GError* error = 0; |
|
995 |
|
996 webkit_web_frame_print_full(frame, operation, GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG, &error); |
|
997 g_object_unref(operation); |
|
998 |
|
999 if (error) { |
|
1000 GtkWidget* window = gtk_widget_get_toplevel(GTK_WIDGET(priv->webView)); |
|
1001 GtkWidget* dialog = gtk_message_dialog_new(gtk_widget_is_toplevel(window) ? GTK_WINDOW(window) : 0, |
|
1002 GTK_DIALOG_DESTROY_WITH_PARENT, |
|
1003 GTK_MESSAGE_ERROR, |
|
1004 GTK_BUTTONS_CLOSE, |
|
1005 "%s", error->message); |
|
1006 |
|
1007 g_error_free(error); |
|
1008 |
|
1009 g_signal_connect(dialog, "response", G_CALLBACK(gtk_widget_destroy), NULL); |
|
1010 gtk_widget_show(dialog); |
|
1011 } |
|
1012 } |
|
1013 |
|
1014 bool webkit_web_frame_pause_animation(WebKitWebFrame* frame, const gchar* name, double time, const gchar* element) |
|
1015 { |
|
1016 ASSERT(core(frame)); |
|
1017 Element* coreElement = core(frame)->document()->getElementById(AtomicString(element)); |
|
1018 if (!coreElement || !coreElement->renderer()) |
|
1019 return false; |
|
1020 return core(frame)->animation()->pauseAnimationAtTime(coreElement->renderer(), AtomicString(name), time); |
|
1021 } |
|
1022 |
|
1023 bool webkit_web_frame_pause_transition(WebKitWebFrame* frame, const gchar* name, double time, const gchar* element) |
|
1024 { |
|
1025 ASSERT(core(frame)); |
|
1026 Element* coreElement = core(frame)->document()->getElementById(AtomicString(element)); |
|
1027 if (!coreElement || !coreElement->renderer()) |
|
1028 return false; |
|
1029 return core(frame)->animation()->pauseTransitionAtTime(coreElement->renderer(), AtomicString(name), time); |
|
1030 } |
|
1031 |
|
1032 bool webkit_web_frame_pause_svg_animation(WebKitWebFrame* frame, const gchar* animationId, double time, const gchar* elementId) |
|
1033 { |
|
1034 ASSERT(core(frame)); |
|
1035 #if ENABLE(SVG) |
|
1036 Document* document = core(frame)->document(); |
|
1037 if (!document || !document->svgExtensions()) |
|
1038 return false; |
|
1039 Element* coreElement = document->getElementById(AtomicString(animationId)); |
|
1040 if (!coreElement || !SVGSMILElement::isSMILElement(coreElement)) |
|
1041 return false; |
|
1042 return document->accessSVGExtensions()->sampleAnimationAtTime(elementId, static_cast<SVGSMILElement*>(coreElement), time); |
|
1043 #else |
|
1044 return false; |
|
1045 #endif |
|
1046 } |
|
1047 |
|
1048 gchar* webkit_web_frame_marker_text_for_list_item(WebKitWebFrame* frame, JSContextRef context, JSValueRef nodeObject) |
|
1049 { |
|
1050 JSC::ExecState* exec = toJS(context); |
|
1051 Element* element = toElement(toJS(exec, nodeObject)); |
|
1052 if (!element) |
|
1053 return 0; |
|
1054 |
|
1055 return g_strdup(markerTextForListItem(element).utf8().data()); |
|
1056 } |
|
1057 |
|
1058 unsigned int webkit_web_frame_number_of_active_animations(WebKitWebFrame* frame) |
|
1059 { |
|
1060 Frame* coreFrame = core(frame); |
|
1061 if (!coreFrame) |
|
1062 return 0; |
|
1063 |
|
1064 AnimationController* controller = coreFrame->animation(); |
|
1065 if (!controller) |
|
1066 return 0; |
|
1067 |
|
1068 return controller->numberOfActiveAnimations(); |
|
1069 } |
|
1070 |
|
1071 gchar* webkit_web_frame_get_response_mime_type(WebKitWebFrame* frame) |
|
1072 { |
|
1073 Frame* coreFrame = core(frame); |
|
1074 WebCore::DocumentLoader* docLoader = coreFrame->loader()->documentLoader(); |
|
1075 String mimeType = docLoader->responseMIMEType(); |
|
1076 return g_strdup(mimeType.utf8().data()); |
|
1077 } |
|
1078 |
|
1079 /** |
|
1080 * webkit_web_frame_get_load_status: |
|
1081 * @frame: a #WebKitWebView |
|
1082 * |
|
1083 * Determines the current status of the load. |
|
1084 * |
|
1085 * Since: 1.1.7 |
|
1086 */ |
|
1087 WebKitLoadStatus webkit_web_frame_get_load_status(WebKitWebFrame* frame) |
|
1088 { |
|
1089 g_return_val_if_fail(WEBKIT_IS_WEB_FRAME(frame), WEBKIT_LOAD_FINISHED); |
|
1090 |
|
1091 WebKitWebFramePrivate* priv = frame->priv; |
|
1092 return priv->loadStatus; |
|
1093 } |
|
1094 |
|
1095 void webkit_web_frame_clear_main_frame_name(WebKitWebFrame* frame) |
|
1096 { |
|
1097 g_return_if_fail(WEBKIT_IS_WEB_FRAME(frame)); |
|
1098 |
|
1099 core(frame)->tree()->clearName(); |
|
1100 } |
|
1101 |
|
1102 void webkit_gc_collect_javascript_objects() |
|
1103 { |
|
1104 gcController().garbageCollectNow(); |
|
1105 } |
|
1106 |
|
1107 void webkit_gc_collect_javascript_objects_on_alternate_thread(gboolean waitUntilDone) |
|
1108 { |
|
1109 gcController().garbageCollectOnAlternateThreadForDebugging(waitUntilDone); |
|
1110 } |
|
1111 |
|
1112 gsize webkit_gc_count_javascript_objects() |
|
1113 { |
|
1114 JSC::JSLock lock(JSC::SilenceAssertionsOnly); |
|
1115 return JSDOMWindow::commonJSGlobalData()->heap.objectCount(); |
|
1116 |
|
1117 } |
|
1118 |
|
1119 AtkObject* webkit_web_frame_get_focused_accessible_element(WebKitWebFrame* frame) |
|
1120 { |
|
1121 g_return_val_if_fail(WEBKIT_IS_WEB_FRAME(frame), NULL); |
|
1122 |
|
1123 #if HAVE(ACCESSIBILITY) |
|
1124 if (!AXObjectCache::accessibilityEnabled()) |
|
1125 AXObjectCache::enableAccessibility(); |
|
1126 |
|
1127 WebKitWebFramePrivate* priv = frame->priv; |
|
1128 if (!priv->coreFrame || !priv->coreFrame->document()) |
|
1129 return NULL; |
|
1130 |
|
1131 RenderView* root = toRenderView(priv->coreFrame->document()->renderer()); |
|
1132 if (!root) |
|
1133 return NULL; |
|
1134 |
|
1135 AtkObject* wrapper = priv->coreFrame->document()->axObjectCache()->getOrCreate(root)->wrapper(); |
|
1136 if (!wrapper) |
|
1137 return NULL; |
|
1138 |
|
1139 return webkit_accessible_get_focused_element(WEBKIT_ACCESSIBLE(wrapper)); |
|
1140 #else |
|
1141 return NULL; |
|
1142 #endif |
|
1143 } |
|
1144 |
|
1145 GtkPolicyType webkit_web_frame_get_horizontal_scrollbar_policy(WebKitWebFrame* frame) |
|
1146 { |
|
1147 g_return_val_if_fail(WEBKIT_IS_WEB_FRAME(frame), GTK_POLICY_AUTOMATIC); |
|
1148 |
|
1149 Frame* coreFrame = core(frame); |
|
1150 FrameView* view = coreFrame->view(); |
|
1151 if (!view) |
|
1152 return GTK_POLICY_AUTOMATIC; |
|
1153 |
|
1154 ScrollbarMode hMode = view->horizontalScrollbarMode(); |
|
1155 |
|
1156 if (hMode == ScrollbarAlwaysOn) |
|
1157 return GTK_POLICY_ALWAYS; |
|
1158 |
|
1159 if (hMode == ScrollbarAlwaysOff) |
|
1160 return GTK_POLICY_NEVER; |
|
1161 |
|
1162 return GTK_POLICY_AUTOMATIC; |
|
1163 } |
|
1164 |
|
1165 GtkPolicyType webkit_web_frame_get_vertical_scrollbar_policy(WebKitWebFrame* frame) |
|
1166 { |
|
1167 g_return_val_if_fail(WEBKIT_IS_WEB_FRAME(frame), GTK_POLICY_AUTOMATIC); |
|
1168 |
|
1169 Frame* coreFrame = core(frame); |
|
1170 FrameView* view = coreFrame->view(); |
|
1171 if (!view) |
|
1172 return GTK_POLICY_AUTOMATIC; |
|
1173 |
|
1174 ScrollbarMode vMode = view->verticalScrollbarMode(); |
|
1175 |
|
1176 if (vMode == ScrollbarAlwaysOn) |
|
1177 return GTK_POLICY_ALWAYS; |
|
1178 |
|
1179 if (vMode == ScrollbarAlwaysOff) |
|
1180 return GTK_POLICY_NEVER; |
|
1181 |
|
1182 return GTK_POLICY_AUTOMATIC; |
|
1183 } |
|
1184 |
|
1185 /** |
|
1186 * webkit_web_frame_get_security_origin: |
|
1187 * @frame: a #WebKitWebFrame |
|
1188 * |
|
1189 * Returns the @frame's security origin. |
|
1190 * |
|
1191 * Return value: the security origin of @frame |
|
1192 * |
|
1193 * Since: 1.1.14 |
|
1194 */ |
|
1195 WebKitSecurityOrigin* webkit_web_frame_get_security_origin(WebKitWebFrame* frame) |
|
1196 { |
|
1197 WebKitWebFramePrivate* priv = frame->priv; |
|
1198 if (!priv->coreFrame || !priv->coreFrame->document() || !priv->coreFrame->document()->securityOrigin()) |
|
1199 return NULL; |
|
1200 |
|
1201 if (priv->origin && priv->origin->priv->coreOrigin.get() == priv->coreFrame->document()->securityOrigin()) |
|
1202 return priv->origin; |
|
1203 |
|
1204 if (priv->origin) |
|
1205 g_object_unref(priv->origin); |
|
1206 |
|
1207 priv->origin = kit(priv->coreFrame->document()->securityOrigin()); |
|
1208 return priv->origin; |
|
1209 } |
|
1210 |
|
1211 void webkit_web_frame_layout(WebKitWebFrame* frame) |
|
1212 { |
|
1213 Frame* coreFrame = core(frame); |
|
1214 if (!coreFrame) |
|
1215 return; |
|
1216 |
|
1217 FrameView* view = coreFrame->view(); |
|
1218 if (!view) |
|
1219 return; |
|
1220 |
|
1221 view->layout(); |
|
1222 } |
|
1223 |
|
1224 /** |
|
1225 * webkit_web_frame_get_network_response: |
|
1226 * @frame: a #WebKitWebFrame |
|
1227 * |
|
1228 * Returns a #WebKitNetworkResponse object representing the response |
|
1229 * that was given to the request for the given frame, or NULL if the |
|
1230 * frame was not created by a load. You must unref the object when you |
|
1231 * are done with it. |
|
1232 * |
|
1233 * Return value: a #WebKitNetworkResponse object |
|
1234 * |
|
1235 * Since: 1.1.18 |
|
1236 */ |
|
1237 WebKitNetworkResponse* webkit_web_frame_get_network_response(WebKitWebFrame* frame) |
|
1238 { |
|
1239 Frame* coreFrame = core(frame); |
|
1240 if (!coreFrame) |
|
1241 return NULL; |
|
1242 |
|
1243 WebCore::DocumentLoader* loader = coreFrame->loader()->activeDocumentLoader(); |
|
1244 if (!loader) |
|
1245 return NULL; |
|
1246 |
|
1247 return webkit_network_response_new_with_core_response(loader->response()); |
|
1248 } |