d95a0bb93128e3dfa0a8aa88fcd047bfe445a526
[WebKit-https.git] / WebKit / gtk / Api / webkitgtkpage.cpp
1 /*
2  * Copyright (C) 2007 Holger Hans Peter Freyther
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  *
8  * 1.  Redistributions of source code must retain the above copyright
9  *     notice, this list of conditions and the following disclaimer. 
10  * 2.  Redistributions in binary form must reproduce the above copyright
11  *     notice, this list of conditions and the following disclaimer in the
12  *     documentation and/or other materials provided with the distribution. 
13  * 3.  Neither the name of Apple, Inc. ("Apple") nor the names of
14  *     its contributors may be used to endorse or promote products derived
15  *     from this software without specific prior written permission. 
16  *
17  * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
18  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20  * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
21  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27  */
28
29 #include "config.h"
30
31 #include "webkitgtkpage.h"
32 #include "webkitgtk-marshal.h"
33 #include "webkitgtkprivate.h"
34
35 #include "NotImplemented.h"
36 #include "ChromeClientGtk.h"
37 #include "ContextMenuClientGtk.h"
38 #include "DragClientGtk.h"
39 #include "EditorClientGtk.h"
40 #include "EventHandler.h"
41 #include "HitTestRequest.h"
42 #include "HitTestResult.h"
43 #include "GraphicsContext.h"
44 #include "InspectorClientGtk.h"
45 #include "FrameLoader.h"
46 #include "FrameView.h"
47 #include "PlatformKeyboardEvent.h"
48 #include "PlatformWheelEvent.h"
49 #include "SubstituteData.h"
50
51
52 using namespace WebKit;
53 using namespace WebCore;
54
55 extern "C" {
56
57 enum {
58     /* normal signals */
59     LOAD_STARTED,
60     LOAD_PROGRESS_CHANGED,
61     LOAD_FINISHED,
62     TITLE_CHANGED,
63     HOVERING_OVER_LINK,
64     STATUS_BAR_TEXT_CHANGED,
65     ICOND_LOADED,
66     SELECTION_CHANGED,
67     LAST_SIGNAL
68 };
69
70 static guint webkit_page_signals[LAST_SIGNAL] = { 0, };
71
72 G_DEFINE_TYPE(WebKitPage, webkit_page, GTK_TYPE_CONTAINER)
73
74 static gboolean webkit_page_expose_event(GtkWidget* widget, GdkEventExpose* event)
75 {
76     Frame* frame = core(getFrameFromPage(WEBKIT_PAGE(widget)));
77     GdkRectangle clip;
78     gdk_region_get_clipbox(event->region, &clip);
79     cairo_t* cr = gdk_cairo_create(event->window);
80     GraphicsContext ctx(cr);
81     ctx.setGdkExposeEvent(event);
82     if (frame->renderer()) {
83         frame->view()->layoutIfNeededRecursive();
84         frame->view()->paint(&ctx, clip);
85     }
86     cairo_destroy(cr);
87
88     return FALSE;
89 }
90
91 static gboolean webkit_page_key_event(GtkWidget* widget, GdkEventKey* event)
92 {
93     Frame* frame = core(getFrameFromPage(WEBKIT_PAGE(widget)));
94     return frame->eventHandler()->keyEvent(PlatformKeyboardEvent(event));
95 }
96
97 static gboolean webkit_page_button_event(GtkWidget* widget, GdkEventButton* event)
98 {
99     Frame* frame = core(getFrameFromPage(WEBKIT_PAGE(widget)));
100
101     switch (event->type) {
102         case GDK_BUTTON_PRESS:
103             // FIXME: need to keep track of subframe focus for key events
104             gtk_widget_grab_focus(GTK_WIDGET(widget));
105             return frame->eventHandler()->handleMousePressEvent(PlatformMouseEvent(event));
106         case GDK_BUTTON_RELEASE:
107             return frame->eventHandler()->handleMouseReleaseEvent(PlatformMouseEvent(event));
108         default:
109             return FALSE;
110     }
111 }
112
113 static gboolean webkit_page_motion_event(GtkWidget* widget, GdkEventMotion* event)
114 {
115     Frame* frame = core(getFrameFromPage(WEBKIT_PAGE(widget)));
116     return frame->eventHandler()->mouseMoved(PlatformMouseEvent(event));
117 }
118
119 static gboolean webkit_page_scroll_event(GtkWidget* widget, GdkEventScroll* event)
120 {
121     Frame* frame = core(getFrameFromPage(WEBKIT_PAGE(widget)));
122     PlatformWheelEvent wheelEvent(event);
123     return frame->eventHandler()->handleWheelEvent(wheelEvent);
124 }
125
126 static void webkit_page_size_allocate(GtkWidget* widget, GtkAllocation* allocation)
127 {
128     GTK_WIDGET_CLASS(webkit_page_parent_class)->size_allocate(widget,allocation);
129
130     Frame* frame = core(getFrameFromPage(WEBKIT_PAGE(widget)));
131     frame->view()->resize(allocation->width, allocation->height);
132     frame->forceLayout();
133     frame->view()->adjustViewSize();
134     frame->sendResizeEvent();
135 }
136
137 static void webkit_page_realize(GtkWidget* widget)
138 {
139     GTK_WIDGET_SET_FLAGS(widget, GTK_REALIZED);
140
141     GdkWindowAttr attributes;
142     attributes.window_type = GDK_WINDOW_CHILD;
143     attributes.x = widget->allocation.x;
144     attributes.y = widget->allocation.y;
145     attributes.width = widget->allocation.width;
146     attributes.height = widget->allocation.height;
147     attributes.wclass = GDK_INPUT_OUTPUT;
148     attributes.visual = gtk_widget_get_visual (widget);
149     attributes.colormap = gtk_widget_get_colormap (widget);
150     attributes.event_mask = GDK_VISIBILITY_NOTIFY_MASK
151                             | GDK_EXPOSURE_MASK
152                             | GDK_BUTTON_PRESS_MASK
153                             | GDK_BUTTON_RELEASE_MASK
154                             | GDK_POINTER_MOTION_MASK
155                             | GDK_KEY_PRESS_MASK
156                             | GDK_KEY_RELEASE_MASK
157                             | GDK_BUTTON_MOTION_MASK
158                             | GDK_BUTTON1_MOTION_MASK
159                             | GDK_BUTTON2_MOTION_MASK
160                             | GDK_BUTTON3_MOTION_MASK;
161
162     gint attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
163     widget->window = gdk_window_new(gtk_widget_get_parent_window (widget), &attributes, attributes_mask);
164     gdk_window_set_user_data(widget->window, widget);
165 }
166
167 static void webkit_page_map(GtkWidget* widget)
168 {
169     GTK_WIDGET_SET_FLAGS(widget, GTK_MAPPED);
170     WebKitPagePrivate* private_data = WEBKIT_PAGE_GET_PRIVATE(WEBKIT_PAGE(widget));
171
172     HashSet<GtkWidget*>::const_iterator end = private_data->children.end();
173     for (HashSet<GtkWidget*>::const_iterator current = private_data->children.begin(); current != end; ++current)
174         if (GTK_WIDGET_VISIBLE(*current) && !GTK_WIDGET_MAPPED(*current))
175             gtk_widget_map((*current));
176
177     gdk_window_show(widget->window);
178 }
179
180 static void webkit_page_set_scroll_adjustments(WebKitPage* page, GtkAdjustment* hadj, GtkAdjustment* vadj)
181 {
182     FrameView* view = core(getFrameFromPage(page))->view();
183     view->setGtkAdjustments(hadj, vadj);
184 }
185
186 static void webkit_page_container_add(GtkContainer* container, GtkWidget* widget)
187 {
188     WebKitPage* page = WEBKIT_PAGE(container);
189     WebKitPagePrivate* private_data = WEBKIT_PAGE_GET_PRIVATE(page);
190
191     private_data->children.add(widget);
192     if (GTK_WIDGET_REALIZED(container))
193         gtk_widget_set_parent_window(widget, GTK_WIDGET(page)->window);
194     gtk_widget_set_parent(widget, GTK_WIDGET(container));
195 }
196
197 static void webkit_page_container_remove(GtkContainer* container, GtkWidget* widget)
198 {
199     WebKitPagePrivate* private_data = WEBKIT_PAGE_GET_PRIVATE(WEBKIT_PAGE(container));
200
201     if (private_data->children.contains(widget)) {
202         gtk_widget_unparent(widget);
203         private_data->children.remove(widget);
204     }
205 }
206
207 static void webkit_page_container_forall(GtkContainer* container, gboolean, GtkCallback callback, gpointer callbackData)
208 {
209     WebKitPagePrivate* privateData = WEBKIT_PAGE_GET_PRIVATE(WEBKIT_PAGE(container));
210
211     HashSet<GtkWidget*> children = privateData->children;
212     HashSet<GtkWidget*>::const_iterator end = children.end();
213     for (HashSet<GtkWidget*>::const_iterator current = children.begin(); current != end; ++current)
214         (*callback)(*current, callbackData);
215 }
216
217 static WebKitPage* webkit_page_real_create_page(WebKitPage*)
218 {
219     notImplemented();
220     return 0;
221 }
222
223 static WEBKIT_NAVIGATION_REQUEST_RESPONSE webkit_page_real_navigation_requested(WebKitPage*, WebKitFrame* frame, WebKitNetworkRequest*)
224 {
225     notImplemented();
226     return WEBKIT_ACCEPT_NAVIGATION_REQUEST;
227 }
228
229 static gchar* webkit_page_real_choose_file(WebKitPage*, WebKitFrame*, const gchar* old_name)
230 {
231     notImplemented();
232     return g_strdup(old_name);
233 }
234
235 static void webkit_page_real_java_script_alert(WebKitPage*, WebKitFrame*, const gchar*)
236 {
237     notImplemented();
238 }
239
240 static gboolean webkit_page_real_java_script_confirm(WebKitPage*, WebKitFrame*, const gchar*)
241 {
242     notImplemented();
243     return FALSE;
244 }
245
246 /**
247  * WebKitPage::java_script_prompt
248  *
249  * @return: NULL to cancel the prompt
250  */
251 static gchar* webkit_page_real_java_script_prompt(WebKitPage*, WebKitFrame*, const gchar*, const gchar* defaultValue)
252 {
253     notImplemented();
254     return g_strdup(defaultValue);
255 }
256
257 static void webkit_page_real_java_script_console_message(WebKitPage*, const gchar*, unsigned int, const gchar*)
258 {
259     notImplemented();
260 }
261
262 static void webkit_page_finalize(GObject* object)
263 {
264     webkit_page_stop_loading(WEBKIT_PAGE(object));
265
266     WebKitPagePrivate* pageData = WEBKIT_PAGE_GET_PRIVATE(WEBKIT_PAGE(object));
267     delete pageData->page;
268     delete pageData->settings;
269     g_object_unref(pageData->mainFrame);
270     delete pageData->userAgent;
271
272     G_OBJECT_CLASS(webkit_page_parent_class)->finalize(object);
273 }
274
275 static void webkit_page_class_init(WebKitPageClass* pageClass)
276 {
277     g_type_class_add_private(pageClass, sizeof(WebKitPagePrivate));
278
279
280     /*
281      * signals
282      */
283     /**
284      * WebKitPage::load-started
285      * @page: the object on which the signal is emitted
286      * @frame: the frame going to do the load
287      *
288      * When a WebKitFrame begins to load this signal is emitted.
289      */
290     webkit_page_signals[LOAD_STARTED] = g_signal_new("load_started",
291             G_TYPE_FROM_CLASS(pageClass),
292             (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
293             0,
294             NULL,
295             NULL,
296             g_cclosure_marshal_VOID__OBJECT,
297             G_TYPE_NONE, 1,
298             WEBKIT_TYPE_FRAME);
299
300     /**
301      * WebKitPage::load-progress-changed
302      * @page: The WebKitPage
303      * @progress: Global progress
304      */
305     webkit_page_signals[LOAD_PROGRESS_CHANGED] = g_signal_new("load_progress_changed",
306             G_TYPE_FROM_CLASS(pageClass),
307             (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
308             0,
309             NULL,
310             NULL,
311             g_cclosure_marshal_VOID__INT,
312             G_TYPE_NONE, 1,
313             G_TYPE_INT);
314     
315     webkit_page_signals[LOAD_FINISHED] = g_signal_new("load_finished",
316             G_TYPE_FROM_CLASS(pageClass),
317             (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
318             0,
319             NULL,
320             NULL,
321             g_cclosure_marshal_VOID__OBJECT,
322             G_TYPE_NONE, 1,
323             WEBKIT_TYPE_FRAME);
324
325     webkit_page_signals[TITLE_CHANGED] = g_signal_new("title_changed",
326             G_TYPE_FROM_CLASS(pageClass),
327             (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
328             0,
329             NULL,
330             NULL,
331             webkit_marshal_VOID__STRING_STRING,
332             G_TYPE_NONE, 2,
333             G_TYPE_STRING, G_TYPE_STRING);
334
335     webkit_page_signals[HOVERING_OVER_LINK] = g_signal_new("hovering_over_link",
336             G_TYPE_FROM_CLASS(pageClass),
337             (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
338             0,
339             NULL,
340             NULL,
341             webkit_marshal_VOID__STRING_STRING,
342             G_TYPE_NONE, 2,
343             G_TYPE_STRING,
344             G_TYPE_STRING);
345
346     webkit_page_signals[STATUS_BAR_TEXT_CHANGED] = g_signal_new("status_bar_text_changed",
347             G_TYPE_FROM_CLASS(pageClass),
348             (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
349             0,
350             NULL,
351             NULL,
352             g_cclosure_marshal_VOID__STRING,
353             G_TYPE_NONE, 1,
354             G_TYPE_STRING);
355
356     webkit_page_signals[ICOND_LOADED] = g_signal_new("icon_loaded",
357             G_TYPE_FROM_CLASS(pageClass),
358             (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
359             0,
360             NULL,
361             NULL,
362             g_cclosure_marshal_VOID__VOID,
363             G_TYPE_NONE, 0);
364
365     webkit_page_signals[SELECTION_CHANGED] = g_signal_new("selection_changed",
366             G_TYPE_FROM_CLASS(pageClass),
367             (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
368             0,
369             NULL,
370             NULL,
371             g_cclosure_marshal_VOID__VOID,
372             G_TYPE_NONE, 0);
373
374
375     /*
376      * implementations of virtual methods
377      */
378     pageClass->create_page = webkit_page_real_create_page;
379     pageClass->navigation_requested = webkit_page_real_navigation_requested;
380     pageClass->choose_file = webkit_page_real_choose_file;
381     pageClass->java_script_alert = webkit_page_real_java_script_alert;
382     pageClass->java_script_confirm = webkit_page_real_java_script_confirm;
383     pageClass->java_script_prompt = webkit_page_real_java_script_prompt;
384     pageClass->java_script_console_message = webkit_page_real_java_script_console_message;
385
386     G_OBJECT_CLASS(pageClass)->finalize = webkit_page_finalize;
387
388     GtkWidgetClass* widgetClass = GTK_WIDGET_CLASS(pageClass);
389     widgetClass->realize = webkit_page_realize;
390     widgetClass->map = webkit_page_map;
391     widgetClass->expose_event = webkit_page_expose_event;
392     widgetClass->key_press_event = webkit_page_key_event;
393     widgetClass->key_release_event = webkit_page_key_event;
394     widgetClass->button_press_event = webkit_page_button_event;
395     widgetClass->button_release_event = webkit_page_button_event;
396     widgetClass->motion_notify_event = webkit_page_motion_event;
397     widgetClass->scroll_event = webkit_page_scroll_event;
398     widgetClass->size_allocate = webkit_page_size_allocate;
399
400     GtkContainerClass* containerClass = GTK_CONTAINER_CLASS(pageClass);
401     containerClass->add = webkit_page_container_add;
402     containerClass->remove = webkit_page_container_remove;
403     containerClass->forall = webkit_page_container_forall;
404
405     /*
406      * make us scrollable (e.g. addable to a GtkScrolledWindow)
407      */
408     pageClass->set_scroll_adjustments = webkit_page_set_scroll_adjustments;
409     GTK_WIDGET_CLASS(pageClass)->set_scroll_adjustments_signal = g_signal_new("set_scroll_adjustments",
410             G_TYPE_FROM_CLASS(pageClass),
411             (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
412             G_STRUCT_OFFSET(WebKitPageClass, set_scroll_adjustments),
413             NULL, NULL,
414             webkit_marshal_VOID__OBJECT_OBJECT,
415             G_TYPE_NONE, 2,
416             GTK_TYPE_ADJUSTMENT, GTK_TYPE_ADJUSTMENT);
417 }
418
419 static void webkit_page_init(WebKitPage* page)
420 {
421     WebKitPagePrivate* pageData = WEBKIT_PAGE_GET_PRIVATE(WEBKIT_PAGE(page));
422     pageData->page = new Page(new WebKit::ChromeClient(page), new WebKit::ContextMenuClient, new WebKit::EditorClient(page), new WebKit::DragClient, new WebKit::InspectorClient);
423
424     Settings* settings = pageData->page->settings();
425     settings->setLoadsImagesAutomatically(true);
426     settings->setMinimumFontSize(5);
427     settings->setMinimumLogicalFontSize(5);
428     settings->setShouldPrintBackgrounds(true);
429     settings->setJavaScriptEnabled(true);
430     settings->setDefaultFixedFontSize(14);
431     settings->setDefaultFontSize(14);
432     settings->setSerifFontFamily("Times New Roman");
433     settings->setSansSerifFontFamily("Arial");
434     settings->setFixedFontFamily("Courier");
435     settings->setStandardFontFamily("Arial");
436
437     GTK_WIDGET_SET_FLAGS(page, GTK_CAN_FOCUS);
438     pageData->mainFrame = WEBKIT_FRAME(webkit_frame_new(page));
439 }
440
441 GtkWidget* webkit_page_new(void)
442 {
443     WebKitPage* page = WEBKIT_PAGE(g_object_new(WEBKIT_TYPE_PAGE, NULL));
444
445     return GTK_WIDGET(page);
446 }
447
448 void webkit_page_set_settings(WebKitPage* page, WebKitSettings* settings)
449 {
450     notImplemented();
451 }
452
453 WebKitSettings* webkit_page_get_settings(WebKitPage* page)
454 {
455     notImplemented();
456     return 0;
457 }
458
459 void webkit_page_go_backward(WebKitPage* page)
460 {
461     WebKitPagePrivate* pageData = WEBKIT_PAGE_GET_PRIVATE(page);
462     WebKitFramePrivate* frameData = WEBKIT_FRAME_GET_PRIVATE(pageData->mainFrame);
463     frameData->frame->loader()->goBackOrForward(-1);
464 }
465
466 void webkit_page_go_forward(WebKitPage* page)
467 {
468     WebKitPagePrivate* pageData = WEBKIT_PAGE_GET_PRIVATE(page);
469     WebKitFramePrivate* frameData = WEBKIT_FRAME_GET_PRIVATE(pageData->mainFrame);
470     frameData->frame->loader()->goBackOrForward(1);
471 }
472
473 gboolean webkit_page_can_go_backward(WebKitPage* page)
474 {
475     WebKitPagePrivate* pageData = WEBKIT_PAGE_GET_PRIVATE(page);
476     WebKitFramePrivate* frameData = WEBKIT_FRAME_GET_PRIVATE(pageData->mainFrame);
477     return frameData->frame->loader()->canGoBackOrForward(-1);
478 }
479
480 gboolean webkit_page_can_go_forward(WebKitPage* page)
481 {
482     WebKitPagePrivate* pageData = WEBKIT_PAGE_GET_PRIVATE(page);
483     WebKitFramePrivate* frameData = WEBKIT_FRAME_GET_PRIVATE(pageData->mainFrame);
484     return frameData->frame->loader()->canGoBackOrForward(1);
485 }
486
487 void webkit_page_open(WebKitPage* page, const gchar* url)
488 {
489     WebKitPagePrivate* pageData = WEBKIT_PAGE_GET_PRIVATE(page);
490     WebKitFramePrivate* frameData = WEBKIT_FRAME_GET_PRIVATE(pageData->mainFrame);
491
492     DeprecatedString string = DeprecatedString::fromUtf8(url);
493     frameData->frame->loader()->load(ResourceRequest(KURL(string)));
494 }
495
496 void webkit_page_reload(WebKitPage* page)
497 {
498     WebKitPagePrivate* pageData = WEBKIT_PAGE_GET_PRIVATE(page);
499     WebKitFramePrivate* frameData = WEBKIT_FRAME_GET_PRIVATE(pageData->mainFrame);
500     frameData->frame->loader()->reload();
501 }
502
503 void webkit_page_load_string(WebKitPage* page, const gchar* content, const gchar* contentMimeType, const gchar* contentEncoding, const gchar* baseUrl)
504 {
505     WebKitPagePrivate* pageData = WEBKIT_PAGE_GET_PRIVATE(page);
506     WebKitFramePrivate* frameData = WEBKIT_FRAME_GET_PRIVATE(pageData->mainFrame);
507     
508     KURL url(DeprecatedString::fromUtf8(baseUrl));
509     RefPtr<SharedBuffer> sharedBuffer = new SharedBuffer(strdup(content), strlen(content));    
510     SubstituteData substituteData(sharedBuffer.release(), String(contentMimeType), String(contentEncoding), KURL("about:blank"), url);
511
512     frameData->frame->loader()->load(ResourceRequest(url), substituteData);
513 }
514
515 void webkit_page_load_html_string(WebKitPage* page, const gchar* content, const gchar* baseUrl)
516 {
517     webkit_page_load_string(page, content, "text/html", "UTF-8", baseUrl);
518 }
519
520 void webkit_page_stop_loading(WebKitPage* page)
521 {
522     WebKitPagePrivate* pageData = WEBKIT_PAGE_GET_PRIVATE(page);
523     WebKitFramePrivate* frameData = WEBKIT_FRAME_GET_PRIVATE(pageData->mainFrame);
524     
525     if (FrameLoader* loader = frameData->frame->loader())
526         loader->stopAllLoaders();
527         
528 }
529
530 WebKitFrame* webkit_page_get_main_frame(WebKitPage* page)
531 {
532     WebKitPagePrivate* pageData = WEBKIT_PAGE_GET_PRIVATE(page);
533     return pageData->mainFrame;
534 }
535
536 void webkit_page_execute_script(WebKitPage* page, const gchar* script)
537 {
538     WebKitPagePrivate* pageData = WEBKIT_PAGE_GET_PRIVATE(page);
539     WebKitFramePrivate* frameData = WEBKIT_FRAME_GET_PRIVATE(pageData->mainFrame);
540
541     if (FrameLoader* loader = frameData->frame->loader())
542         loader->executeScript(String::fromUTF8(script), true);
543 }
544 }