diff options
Diffstat (limited to 'WebKit/gtk')
| -rw-r--r-- | WebKit/gtk/ChangeLog | 248 | ||||
| -rw-r--r-- | WebKit/gtk/WebCoreSupport/DragClientGtk.cpp | 49 | ||||
| -rw-r--r-- | WebKit/gtk/WebCoreSupport/DragClientGtk.h | 6 | ||||
| -rw-r--r-- | WebKit/gtk/WebCoreSupport/FrameLoaderClientGtk.cpp | 13 | ||||
| -rw-r--r-- | WebKit/gtk/WebCoreSupport/FrameLoaderClientGtk.h | 2 | ||||
| -rw-r--r-- | WebKit/gtk/tests/testatkroles.c | 45 | ||||
| -rw-r--r-- | WebKit/gtk/tests/testdomdocument.c | 232 | ||||
| -rw-r--r-- | WebKit/gtk/webkit/webkit.h | 1 | ||||
| -rw-r--r-- | WebKit/gtk/webkit/webkitnetworkrequest.cpp | 3 | ||||
| -rw-r--r-- | WebKit/gtk/webkit/webkitnetworkresponse.cpp | 4 | ||||
| -rw-r--r-- | WebKit/gtk/webkit/webkitprivate.cpp | 41 | ||||
| -rw-r--r-- | WebKit/gtk/webkit/webkitprivate.h | 11 | ||||
| -rw-r--r-- | WebKit/gtk/webkit/webkitwebsettings.cpp | 25 | ||||
| -rw-r--r-- | WebKit/gtk/webkit/webkitwebview.cpp | 160 | ||||
| -rw-r--r-- | WebKit/gtk/webkit/webkitwebview.h | 4 |
15 files changed, 647 insertions, 197 deletions
diff --git a/WebKit/gtk/ChangeLog b/WebKit/gtk/ChangeLog index 0affc25..24c7023 100644 --- a/WebKit/gtk/ChangeLog +++ b/WebKit/gtk/ChangeLog @@ -1,3 +1,251 @@ +2010-05-06 Martin Robinson <mrobinson@webkit.org> + + Reviewed by Xan Lopez. + + Remove use of GOwnPtr to hold GObject types. + https://bugs.webkit.org/show_bug.cgi?id=38669 + + Change use of GOwnPtr to GRefPtr to types which are natively reference-counted. + + * WebCoreSupport/FrameLoaderClientGtk.cpp: + (WebKit::FrameLoaderClient::dispatchWillSendRequest): Change GOwnPtr to GRefPtr in some places. + (WebKit::FrameLoaderClient::dispatchDecidePolicyForMIMEType): Ditto. + * webkit/webkitnetworkrequest.cpp: + (webkit_network_request_new_with_core_request): Ditto. + * webkit/webkitnetworkresponse.cpp: + (webkit_network_response_new_with_core_response): Ditto. + * webkit/webkitprivate.cpp: Remove GOwnPtr reference counting template specialization. + * webkit/webkitprivate.h: Ditto. + +2010-05-06 Martin Robinson <mrobinson@webkit.org> + + Reviewed by Gustavo Noronha Silva. + + [GTK] Enable DOM clipboard and drag-and-drop access + https://bugs.webkit.org/show_bug.cgi?id=30623 + + Convert dragging portion of drag-and-drop to use DataObjectGtk. + + * WebCoreSupport/DragClientGtk.cpp: + (WebKit::DragClient::willPerformDragDestinationAction): Remove the notImplemented. It is implemented, it's just a no-op. + (WebKit::DragClient::startDrag): Start the drag context via the ClipboardGtk and PasteboardHelper now. + * WebCoreSupport/DragClientGtk.h: Small style fix. + * webkit/webkitprivate.h: Add a HashMap of contexts and DataObjects here to to represent all current drag operations. + * webkit/webkitwebview.cpp: + (webkit_web_view_dispose): Clear all data objects during disposal. + (webkit_web_view_drag_end): When a drag is over, just remove it from the map. + (webkit_web_view_drag_data_get): To get the drag data, just grab it from the DataObject. + +2010-05-03 Abhishek Arya <inferno@chromium.org> + + Reviewed by Adam Barth. + + Add support for controlling clipboard access from javascript. + Clipboard access from javascript is disabled by default. + https://bugs.webkit.org/show_bug.cgi?id=27751 + + * webkit/webkitwebsettings.cpp: + (webkit_web_settings_class_init): + (webkit_web_settings_set_property): + (webkit_web_settings_get_property): + (webkit_web_settings_copy): + * webkit/webkitwebview.cpp: + (webkit_web_view_update_settings): + (webkit_web_view_settings_notify): + +2010-05-03 Jens Alfke <snej@chromium.org> + + Reviewed by Darin Fisher. + + [chromium] Add "willSendSubmitEvent" hook to WebFrameClient and FrameLoaderClient + https://bugs.webkit.org/show_bug.cgi?id=38397 + + No tests (functionality is exposed only through native WebKit API.) + + * WebCoreSupport/FrameLoaderClientGtk.h: + (WebKit::FrameLoaderClient::dispatchWillSendSubmitEvent): + +2010-05-01 Xan Lopez <xlopez@igalia.com> + + Reviewed by Oliver Hunt. + + [GTK] GObject DOM bindings + https://bugs.webkit.org/show_bug.cgi?id=33590 + + Test webkit_dom_document_get_links. + + * tests/testdomdocument.c: + (test_dom_document_get_links): + (main): + +2010-04-29 Xan Lopez <xlopez@igalia.com> + + Reviewed by Gustavo Noronha. + + [GTK] GObject DOM bindings + https://bugs.webkit.org/show_bug.cgi?id=33590 + + Test webkit_dom_document_get_element_by_id; + + * tests/testdomdocument.c: + (test_dom_document_get_element_by_id): + (main): + +2010-04-29 Xan Lopez <xlopez@igalia.com> + + Reviewed by Gustavo Noronha. + + [GTK] GObject DOM bindings + https://bugs.webkit.org/show_bug.cgi?id=33590 + + Test webkit_dom_document_get_elements_by_class_name. + + * tests/testdomdocument.c: + (test_dom_document_get_elements_by_class_name): + (main): + +2010-04-29 Xan Lopez <xlopez@igalia.com> + + Reviewed by Gustavo Noronha. + + [GTK] GObject DOM bindings + https://bugs.webkit.org/show_bug.cgi?id=33590 + + Test webkit_dom_document_get_elements_by_tag_name. + + * tests/testdomdocument.c: + (test_dom_document_get_elements_by_tag_name): + (main): + +2010-04-29 Xan Lopez <xlopez@igalia.com> + + Reviewed by Gustavo Noronha. + + [GTK] GObject DOM bindings + https://bugs.webkit.org/show_bug.cgi?id=33590 + + Move WebKitDOMDocument unit tests to their own file. + + * tests/testdomdocument.c: Added. + (finish_loading): + (dom_document_fixture_setup): + (dom_document_fixture_teardown): + (test_dom_document_title): + (main): + * tests/testwebview.c: + +2010-04-29 Xan Lopez <xlopez@igalia.com> + + Reviewed by Gustavo Noronha. + + [GTK] GObject DOM bindings + https://bugs.webkit.org/show_bug.cgi?id=33590 + + Include <webkit/webkitdom.h> in the main webkit.h header. + + * webkit/webkit.h: + +2010-04-25 Sam Weinig <sam@webkit.org> + + Reviewed by Maciej Stachowiak. + + Fix for https://bugs.webkit.org/show_bug.cgi?id=38097 + Disentangle initializing the main thread from initializing threading + + * webkit/webkitprivate.cpp: + (webkit_init): Add call to initializeMainThread. + +2010-04-22 Dave Moore <davemoore@chromium.org> + + Reviewed by Dimitri Glazkov. + + Added notification when the favicons for a page are changed + from a script. + The Document object will notify the frame loader, which will + notify the client. Implementations of FrameLoaderClient will + have to add one method; dispatchDidChangeIcons(). + + * WebCoreSupport/FrameLoaderClientGtk.cpp: + (WebKit::FrameLoaderClient::dispatchDidChangeIcons): + * WebCoreSupport/FrameLoaderClientGtk.h: + +2010-04-22 Xan Lopez <xlopez@igalia.com> + + Reviewed by Gustavo Noronha. + + [GTK] GObject DOM bindings + https://bugs.webkit.org/show_bug.cgi?id=33590 + + Add webkit_web_view_get_document to retrieve the WebKitDOMDocument + from a WebKitWebView, and a very simple test for it. + + * tests/testwebview.c: + * webkit/webkitwebview.cpp: + (webkit_web_view_get_document): + * webkit/webkitwebview.h: + +2010-04-22 Diego Escalante Urrelo <descalante@igalia.com> + + Reviewed by Xan Lopez. + + [Gtk] Evaluate and create tests for all the AtkRole's implemented by + WebKitGtk + https://bugs.webkit.org/show_bug.cgi?id=34449 + + Expand testatkroles to test ATK_ROLE_COMBO_BOX. + + * tests/testatkroles.c: + (test_webkit_atk_get_role_combobox): + (main): + +2010-04-22 Diego Escalante Urrelo <descalante@igalia.com> + + Reviewed by Xan Lopez. + + [Gtk] Evaluate and create tests for all the AtkRole's implemented by + WebKitGtk + https://bugs.webkit.org/show_bug.cgi?id=34449 + + Expand testatkroles to test ATK_ROLE_SEPARATOR. + + * tests/testatkroles.c: + (test_webkit_atk_get_role_separator): + (main): + +2010-04-22 Adam Barth <abarth@webkit.org> + + Unreviewed, rolling out r58069. + http://trac.webkit.org/changeset/58069 + https://bugs.webkit.org/show_bug.cgi?id=27751 + + Broke compile on Windows. + + * webkit/webkitwebsettings.cpp: + (webkit_web_settings_class_init): + (webkit_web_settings_set_property): + (webkit_web_settings_get_property): + (webkit_web_settings_copy): + * webkit/webkitwebview.cpp: + (webkit_web_view_update_settings): + (webkit_web_view_settings_notify): + +2010-04-22 Abhishek Arya <inferno@chromium.org> + + Reviewed by Adam Barth. + + Add support for controlling clipboard access from javascript. + Clipboard access from javascript is disabled by default. + https://bugs.webkit.org/show_bug.cgi?id=27751 + + * webkit/webkitwebsettings.cpp: + (webkit_web_settings_class_init): + (webkit_web_settings_set_property): + (webkit_web_settings_get_property): + (webkit_web_settings_copy): + * webkit/webkitwebview.cpp: + (webkit_web_view_update_settings): + (webkit_web_view_settings_notify): + 2010-04-21 Jakub Wieczorek <jwieczorek@webkit.org> Reviewed by Darin Adler. diff --git a/WebKit/gtk/WebCoreSupport/DragClientGtk.cpp b/WebKit/gtk/WebCoreSupport/DragClientGtk.cpp index f4b0df1..900fb61 100644 --- a/WebKit/gtk/WebCoreSupport/DragClientGtk.cpp +++ b/WebKit/gtk/WebCoreSupport/DragClientGtk.cpp @@ -1,4 +1,6 @@ /* + * Copyright (C) Igalia S.L. + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either @@ -17,11 +19,16 @@ #include "config.h" #include "DragClientGtk.h" +#include "ClipboardGtk.h" +#include "DataObjectGtk.h" #include "Document.h" #include "Element.h" #include "Frame.h" +#include "GRefPtrGtk.h" #include "NotImplemented.h" +#include "PasteboardHelper.h" #include "RenderObject.h" +#include "webkitprivate.h" #include "webkitwebview.h" #include <gtk/gtk.h> @@ -41,7 +48,6 @@ DragClient::DragClient(WebKitWebView* webView) void DragClient::willPerformDragDestinationAction(DragDestinationAction, DragData*) { - notImplemented(); } void DragClient::willPerformDragSourceAction(DragSourceAction, const IntPoint& startPos, Clipboard*) @@ -61,50 +67,29 @@ DragSourceAction DragClient::dragSourceActionMaskForPoint(const IntPoint&) return DragSourceActionAny; } -void DragClient::startDrag(DragImageRef image, const IntPoint& dragImageOrigin, const IntPoint& eventPos, Clipboard*, Frame* frame, bool linkDrag) +void DragClient::startDrag(DragImageRef image, const IntPoint& dragImageOrigin, const IntPoint& eventPos, Clipboard* clipboard, Frame* frame, bool linkDrag) { - Element* targetElement = frame->document()->elementFromPoint(m_startPos.x(), m_startPos.y()); - bool imageDrag = false; - - if (targetElement) - imageDrag = targetElement->renderer()->isImage(); - - GdkAtom textHtml = gdk_atom_intern_static_string("text/html"); - GdkAtom netscapeUrl = gdk_atom_intern_static_string("_NETSCAPE_URL"); - - GtkTargetList* targetList = gtk_target_list_new(NULL, 0); - gtk_target_list_add(targetList, textHtml, 0, WEBKIT_WEB_VIEW_TARGET_INFO_HTML); - gtk_target_list_add_text_targets(targetList, WEBKIT_WEB_VIEW_TARGET_INFO_TEXT); - - if (linkDrag || imageDrag) { - gtk_target_list_add(targetList, netscapeUrl, 0, WEBKIT_WEB_VIEW_TARGET_INFO_NETSCAPE_URL); - gtk_target_list_add_uri_targets(targetList, WEBKIT_WEB_VIEW_TARGET_INFO_URI_LIST); - } - - if (imageDrag) - gtk_target_list_add_image_targets(targetList, WEBKIT_WEB_VIEW_TARGET_INFO_IMAGE, false); + ClipboardGtk* clipboardGtk = reinterpret_cast<ClipboardGtk*>(clipboard); GdkDragAction dragAction = GDK_ACTION_COPY; - if (linkDrag) { - dragAction = GDK_ACTION_LINK; - if (imageDrag) - dragAction = (GdkDragAction)(dragAction | GDK_ACTION_COPY); - } + if (linkDrag) + dragAction = (GdkDragAction) (dragAction | GDK_ACTION_LINK); + WebKitWebView* webView = webkit_web_frame_get_web_view(kit(frame)); + RefPtr<DataObjectGtk> dataObject = clipboardGtk->dataObject(); + + GRefPtr<GtkTargetList> targetList(clipboardGtk->helper()->targetListForDataObject(dataObject.get())); GdkEvent* event = gdk_event_new(GDK_BUTTON_PRESS); reinterpret_cast<GdkEventButton*>(event)->window = gtk_widget_get_window(GTK_WIDGET(m_webView)); reinterpret_cast<GdkEventButton*>(event)->time = GDK_CURRENT_TIME; - GdkDragContext* context = gtk_drag_begin(GTK_WIDGET(m_webView), - targetList, dragAction, 1, event); - g_object_ref(context); + GdkDragContext* context = gtk_drag_begin(GTK_WIDGET(m_webView), targetList.get(), dragAction, 1, event); + webView->priv->draggingDataObjects.set(context, dataObject); if (image) gtk_drag_set_icon_pixbuf(context, image, eventPos.x() - dragImageOrigin.x(), eventPos.y() - dragImageOrigin.y()); else gtk_drag_set_icon_default(context); - - gtk_target_list_unref(targetList); } DragImageRef DragClient::createDragImageForLink(KURL&, const String&, Frame*) diff --git a/WebKit/gtk/WebCoreSupport/DragClientGtk.h b/WebKit/gtk/WebCoreSupport/DragClientGtk.h index 97ea72a..6604940 100644 --- a/WebKit/gtk/WebCoreSupport/DragClientGtk.h +++ b/WebKit/gtk/WebCoreSupport/DragClientGtk.h @@ -51,9 +51,9 @@ namespace WebKit { virtual void dragControllerDestroyed(); - private: - WebKitWebView* m_webView; - WebCore::IntPoint m_startPos; + private: + WebKitWebView* m_webView; + WebCore::IntPoint m_startPos; }; } diff --git a/WebKit/gtk/WebCoreSupport/FrameLoaderClientGtk.cpp b/WebKit/gtk/WebCoreSupport/FrameLoaderClientGtk.cpp index 27ff3c8..fd2d7ed 100644 --- a/WebKit/gtk/WebCoreSupport/FrameLoaderClientGtk.cpp +++ b/WebKit/gtk/WebCoreSupport/FrameLoaderClientGtk.cpp @@ -200,19 +200,19 @@ static char* toString(unsigned long identifier) void FrameLoaderClient::dispatchWillSendRequest(WebCore::DocumentLoader* loader, unsigned long identifier, ResourceRequest& request, const ResourceResponse& redirectResponse) { - GOwnPtr<WebKitNetworkResponse> networkResponse(0); + GRefPtr<WebKitNetworkResponse> networkResponse(0); // We are adding one more resource to the load, or maybe we are // just redirecting a load. if (redirectResponse.isNull()) static_cast<WebKit::DocumentLoader*>(loader)->increaseLoadCount(identifier); else - networkResponse.set(webkit_network_response_new_with_core_response(redirectResponse)); + networkResponse = adoptGRef(webkit_network_response_new_with_core_response(redirectResponse)); WebKitWebView* webView = getViewFromFrame(m_frame); GOwnPtr<gchar> identifierString(toString(identifier)); WebKitWebResource* webResource = webkit_web_view_get_resource(webView, identifierString.get()); - GOwnPtr<WebKitNetworkRequest> networkRequest(webkit_network_request_new_with_core_request(request)); + GRefPtr<WebKitNetworkRequest> networkRequest(adoptGRef(webkit_network_request_new_with_core_request(request))); if (!redirectResponse.isNull()) { // This is a redirect, so we need to update the WebResource's knowledge @@ -312,7 +312,7 @@ void FrameLoaderClient::dispatchDecidePolicyForMIMEType(FramePolicyFunction poli if (isHandled) return; - GOwnPtr<WebKitNetworkResponse> networkResponse(webkit_web_frame_get_network_response(m_frame)); + GRefPtr<WebKitNetworkResponse> networkResponse(adoptGRef(webkit_web_frame_get_network_response(m_frame))); if (networkResponse) { ResourceResponse response = core(networkResponse.get()); if (response.isAttachment()) { @@ -753,6 +753,11 @@ void FrameLoaderClient::dispatchDidReceiveTitle(const String& title) } } +void FrameLoaderClient::dispatchDidChangeIcons() +{ + notImplemented(); +} + void FrameLoaderClient::dispatchDidCommitLoad() { if (m_loadingErrorPage) diff --git a/WebKit/gtk/WebCoreSupport/FrameLoaderClientGtk.h b/WebKit/gtk/WebCoreSupport/FrameLoaderClientGtk.h index 3819b9f..2eeeb35 100644 --- a/WebKit/gtk/WebCoreSupport/FrameLoaderClientGtk.h +++ b/WebKit/gtk/WebCoreSupport/FrameLoaderClientGtk.h @@ -82,6 +82,7 @@ namespace WebKit { virtual void dispatchDidReceiveIcon(); virtual void dispatchDidStartProvisionalLoad(); virtual void dispatchDidReceiveTitle(const WebCore::String&); + virtual void dispatchDidChangeIcons(); virtual void dispatchDidCommitLoad(); virtual void dispatchDidFailProvisionalLoad(const WebCore::ResourceError&); virtual void dispatchDidFailLoad(const WebCore::ResourceError&); @@ -100,6 +101,7 @@ namespace WebKit { virtual void dispatchUnableToImplementPolicy(const WebCore::ResourceError&); + virtual void dispatchWillSendSubmitEvent(WebCore::HTMLFormElement*) { } virtual void dispatchWillSubmitForm(WebCore::FramePolicyFunction, WTF::PassRefPtr<WebCore::FormState>); virtual void dispatchDidLoadMainResource(WebCore::DocumentLoader*); diff --git a/WebKit/gtk/tests/testatkroles.c b/WebKit/gtk/tests/testatkroles.c index d3ade6e..5fd08b0 100644 --- a/WebKit/gtk/tests/testatkroles.c +++ b/WebKit/gtk/tests/testatkroles.c @@ -34,6 +34,8 @@ #define HTML_PARAGRAPH "<html><body><p>This is a test.</p></body></html>" #define HTML_SECTION "<html><body><div>This is a test.</div></body></html>" #define HTML_TABLE "<html><body><table border='1'><tr><td>This is</td><td>a test.</td></tr></table></body></html>" +#define HTML_SEPARATOR "<html><body><hr/></body></html>" +#define HTML_COMBOBOX "<html><body><select size='1'><option>one</option><option>two</option><option>three</option></select></body></html>" /* Form roles */ #define HTML_FORM "<html><body><form>This is a test.</form></body></html>" #define HTML_CHECK_BOX "<html><body><input type='checkbox' />This is a test.</body></html>" @@ -175,6 +177,37 @@ static void test_webkit_atk_get_role_table(AtkRolesFixture* fixture, gconstpoint get_child_and_test_role(fixture->documentFrame, 0, ATK_ROLE_TABLE); } +static void test_webkit_atk_get_role_separator(AtkRolesFixture *fixture, gconstpointer data) +{ + get_child_and_test_role(fixture->documentFrame, 0, ATK_ROLE_SEPARATOR); +} + +static void test_webkit_atk_get_role_combobox(AtkRolesFixture *fixture, gconstpointer data) +{ + AtkObject* comboboxMenu; + + // This is an extraneous object of ATK_ROLE_PANEL which we should get rid of. + fixture->obj = atk_object_ref_accessible_child(fixture->documentFrame, 0); + g_assert(fixture->obj); + + fixture->obj = atk_object_ref_accessible_child(fixture->obj, 0); + g_assert(fixture->obj); + fixture->role = atk_object_get_role(fixture->obj); + g_assert(fixture->role == ATK_ROLE_COMBO_BOX); + + comboboxMenu = atk_object_ref_accessible_child(fixture->obj, 0); + g_assert(comboboxMenu); + fixture->role = atk_object_get_role(comboboxMenu); + g_assert(fixture->role == ATK_ROLE_MENU); + + get_child_and_test_role(comboboxMenu, 0, ATK_ROLE_MENU_ITEM); + get_child_and_test_role(comboboxMenu, 1, ATK_ROLE_MENU_ITEM); + get_child_and_test_role(comboboxMenu, 2, ATK_ROLE_MENU_ITEM); + + g_object_unref(fixture->obj); + g_object_unref(comboboxMenu); +} + /* Form roles */ static void test_webkit_atk_get_role_form(AtkRolesFixture *fixture, gconstpointer data) { @@ -322,6 +355,18 @@ int main(int argc, char** argv) test_webkit_atk_get_role_table, atk_roles_fixture_teardown); + g_test_add("/webkit/atk/test_webkit_atk_get_role_separator", + AtkRolesFixture, HTML_SEPARATOR, + atk_roles_fixture_setup, + test_webkit_atk_get_role_separator, + atk_roles_fixture_teardown); + + g_test_add("/webkit/atk/test_webkit_atk_get_role_combobox", + AtkRolesFixture, HTML_COMBOBOX, + atk_roles_fixture_setup, + test_webkit_atk_get_role_combobox, + atk_roles_fixture_teardown); + /* Form roles */ g_test_add("/webkit/atk/test_webkit_atk_get_role_form", AtkRolesFixture, HTML_FORM, diff --git a/WebKit/gtk/tests/testdomdocument.c b/WebKit/gtk/tests/testdomdocument.c new file mode 100644 index 0000000..4c677ea --- /dev/null +++ b/WebKit/gtk/tests/testdomdocument.c @@ -0,0 +1,232 @@ +/* + * Copyright (C) 2010 Igalia S.L. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#include "test_utils.h" + +#include <glib.h> +#include <glib/gstdio.h> +#include <gtk/gtk.h> +#include <webkit/webkit.h> + +#if GLIB_CHECK_VERSION(2, 16, 0) && GTK_CHECK_VERSION(2, 14, 0) + +#define HTML_DOCUMENT_TITLE "<html><head><title>This is the title</title></head><body></body></html>" +#define HTML_DOCUMENT_ELEMENTS "<html><body><ul><li>1</li><li>2</li><li>3</li></ul></body></html>" +#define HTML_DOCUMENT_ELEMENTS_CLASS "<html><body><div class=\"test\"></div><div class=\"strange\"></div><div class=\"test\"></div></body></html>" +#define HTML_DOCUMENT_ELEMENTS_ID "<html><body><div id=\"testok\"></div><div id=\"testbad\">first</div><div id=\"testbad\">second</div></body></html>" +#define HTML_DOCUMENT_LINKS "<html><body><a href=\"about:blank\">blank</a><a href=\"http://www.google.com\">google</a><a href=\"http://www.webkit.org\">webkit</a></body></html>" + +typedef struct { + GtkWidget* webView; + GMainLoop* loop; +} DomDocumentFixture; + +static gboolean finish_loading(DomDocumentFixture* fixture) +{ + if (g_main_loop_is_running(fixture->loop)) + g_main_loop_quit(fixture->loop); + + return FALSE; +} + +static void dom_document_fixture_setup(DomDocumentFixture* fixture, gconstpointer data) +{ + fixture->loop = g_main_loop_new(NULL, TRUE); + fixture->webView = webkit_web_view_new(); + g_object_ref_sink(fixture->webView); + + if (data != NULL) + webkit_web_view_load_string(WEBKIT_WEB_VIEW (fixture->webView), (const char*) data, NULL, NULL, NULL); + + g_idle_add((GSourceFunc)finish_loading, fixture); + g_main_loop_run(fixture->loop); +} + +static void dom_document_fixture_teardown(DomDocumentFixture* fixture, gconstpointer data) +{ + g_object_unref(fixture->webView); + g_main_loop_unref(fixture->loop); +} + +static void test_dom_document_title(DomDocumentFixture* fixture, gconstpointer data) +{ + g_assert(fixture); + WebKitWebView* view = (WebKitWebView*)fixture->webView; + g_assert(view); + WebKitDOMDocument* document = webkit_web_view_get_dom_document(view); + g_assert(document); + gchar* title = webkit_dom_document_get_title(document); + g_assert(title); + g_assert_cmpstr(title, ==, "This is the title"); + g_free(title); + webkit_dom_document_set_title(document, (gchar*)"This is the second title"); + title = webkit_dom_document_get_title(document); + g_assert(title); + g_assert_cmpstr(title, ==, "This is the second title"); + g_free(title); +} + +static void test_dom_document_get_elements_by_tag_name(DomDocumentFixture* fixture, gconstpointer data) +{ + g_assert(fixture); + WebKitWebView* view = (WebKitWebView*)fixture->webView; + g_assert(view); + WebKitDOMDocument* document = webkit_web_view_get_dom_document(view); + g_assert(document); + WebKitDOMNodeList* list = webkit_dom_document_get_elements_by_tag_name(document, (gchar*)"li"); + g_assert(list); + gulong length = webkit_dom_node_list_get_length(list); + g_assert_cmpint(length, ==, 3); + + guint i; + + for (i = 0; i < length; i++) { + WebKitDOMNode* item = webkit_dom_node_list_item(list, i); + g_assert(item); + WebKitDOMElement* element = (WebKitDOMElement*)item; + g_assert(element); + g_assert_cmpstr(webkit_dom_element_get_tag_name(element), ==, "LI"); + WebKitDOMHTMLElement* htmlElement = (WebKitDOMHTMLElement*)element; + char* n = g_strdup_printf("%d", i+1); + g_assert_cmpstr(webkit_dom_html_element_get_inner_text(htmlElement), ==, n); + g_free(n); + } +} + +static void test_dom_document_get_elements_by_class_name(DomDocumentFixture* fixture, gconstpointer data) +{ + g_assert(fixture); + WebKitWebView* view = (WebKitWebView*)fixture->webView; + g_assert(view); + WebKitDOMDocument* document = webkit_web_view_get_dom_document(view); + g_assert(document); + WebKitDOMNodeList* list = webkit_dom_document_get_elements_by_class_name(document, (gchar*)"test"); + g_assert(list); + gulong length = webkit_dom_node_list_get_length(list); + g_assert_cmpint(length, ==, 2); + + guint i; + + for (i = 0; i < length; i++) { + WebKitDOMNode* item = webkit_dom_node_list_item(list, i); + g_assert(item); + WebKitDOMElement* element = (WebKitDOMElement*)item; + g_assert(element); + g_assert_cmpstr(webkit_dom_element_get_tag_name(element), ==, "DIV"); + } +} + +static void test_dom_document_get_element_by_id(DomDocumentFixture* fixture, gconstpointer data) +{ + g_assert(fixture); + WebKitWebView* view = (WebKitWebView*)fixture->webView; + g_assert(view); + WebKitDOMDocument* document = webkit_web_view_get_dom_document(view); + g_assert(document); + WebKitDOMElement* element = webkit_dom_document_get_element_by_id(document, (gchar*)"testok"); + g_assert(element); + element = webkit_dom_document_get_element_by_id(document, (gchar*)"this-id-does-not-exist"); + g_assert(element == 0); + /* The DOM spec says the return value is undefined when there's + * more than one element with the same id; in our case the first + * one will be returned */ + element = webkit_dom_document_get_element_by_id(document, (gchar*)"testbad"); + g_assert(element); + WebKitDOMHTMLElement* htmlElement = (WebKitDOMHTMLElement*)element; + g_assert_cmpstr(webkit_dom_html_element_get_inner_text(htmlElement), ==, (gchar*)"first"); +} + +static void test_dom_document_get_links(DomDocumentFixture* fixture, gconstpointer data) +{ + g_assert(fixture); + WebKitWebView* view = (WebKitWebView*)fixture->webView; + g_assert(view); + WebKitDOMDocument* document = webkit_web_view_get_dom_document(view); + g_assert(document); + WebKitDOMHTMLCollection *collection = webkit_dom_document_get_links(document); + g_assert(collection); + gulong length = webkit_dom_html_collection_get_length(collection); + g_assert_cmpint(length, ==, 3); + + guint i; + + for (i = 0; i < length; i++) { + static const char* names[] = { "blank", "google", "webkit" }; + static const char* uris[] = { "about:blank", "http://www.google.com/", "http://www.webkit.org/" }; + WebKitDOMNode *node = webkit_dom_html_collection_item(collection, i); + g_assert(node); + WebKitDOMElement* element = (WebKitDOMElement*)node; + g_assert_cmpstr(webkit_dom_element_get_tag_name(element), ==, "A"); + WebKitDOMHTMLElement *htmlElement = (WebKitDOMHTMLElement*)element; + g_assert_cmpstr(webkit_dom_html_element_get_inner_text(htmlElement), ==, names[i]); + WebKitDOMHTMLAnchorElement *anchor = (WebKitDOMHTMLAnchorElement*)element; + g_assert_cmpstr(webkit_dom_html_anchor_element_get_href(anchor), ==, uris[i]); + } +} + +int main(int argc, char** argv) +{ + if (!g_thread_supported()) + g_thread_init(NULL); + + gtk_test_init(&argc, &argv, NULL); + + g_test_bug_base("https://bugs.webkit.org/"); + + g_test_add("/webkit/domdocument/test_title", + DomDocumentFixture, HTML_DOCUMENT_TITLE, + dom_document_fixture_setup, + test_dom_document_title, + dom_document_fixture_teardown); + + g_test_add("/webkit/domdocument/test_get_elements_by_tag_name", + DomDocumentFixture, HTML_DOCUMENT_ELEMENTS, + dom_document_fixture_setup, + test_dom_document_get_elements_by_tag_name, + dom_document_fixture_teardown); + + g_test_add("/webkit/domdocument/test_get_elements_by_class_name", + DomDocumentFixture, HTML_DOCUMENT_ELEMENTS_CLASS, + dom_document_fixture_setup, + test_dom_document_get_elements_by_class_name, + dom_document_fixture_teardown); + + g_test_add("/webkit/domdocument/test_get_element_by_id", + DomDocumentFixture, HTML_DOCUMENT_ELEMENTS_ID, + dom_document_fixture_setup, + test_dom_document_get_element_by_id, + dom_document_fixture_teardown); + + g_test_add("/webkit/domdocument/test_get_links", + DomDocumentFixture, HTML_DOCUMENT_LINKS, + dom_document_fixture_setup, + test_dom_document_get_links, + dom_document_fixture_teardown); + + return g_test_run(); +} + +#else +int main(int argc, char** argv) +{ + g_critical("You will need at least glib-2.16.0 and gtk-2.14.0 to run the unit tests. Doing nothing now."); + return 0; +} + +#endif diff --git a/WebKit/gtk/webkit/webkit.h b/WebKit/gtk/webkit/webkit.h index 17b197b..fc71c2c 100644 --- a/WebKit/gtk/webkit/webkit.h +++ b/WebKit/gtk/webkit/webkit.h @@ -23,6 +23,7 @@ #include <webkit/webkitversion.h> #include <webkit/webkitdefines.h> +#include <webkit/webkitdom.h> #include <webkit/webkitdownload.h> #include <webkit/webkitgeolocationpolicydecision.h> #include <webkit/webkithittestresult.h> diff --git a/WebKit/gtk/webkit/webkitnetworkrequest.cpp b/WebKit/gtk/webkit/webkitnetworkrequest.cpp index 78044aa..c72abbd 100644 --- a/WebKit/gtk/webkit/webkitnetworkrequest.cpp +++ b/WebKit/gtk/webkit/webkitnetworkrequest.cpp @@ -21,7 +21,6 @@ #include "config.h" #include "webkitnetworkrequest.h" -#include "GOwnPtr.h" #include "ResourceRequest.h" #include "webkitprivate.h" #include <wtf/text/CString.h> @@ -165,7 +164,7 @@ static void webkit_network_request_init(WebKitNetworkRequest* request) // for internal use only WebKitNetworkRequest* webkit_network_request_new_with_core_request(const WebCore::ResourceRequest& resourceRequest) { - GOwnPtr<SoupMessage> soupMessage(resourceRequest.toSoupMessage()); + GRefPtr<SoupMessage> soupMessage(adoptGRef(resourceRequest.toSoupMessage())); if (soupMessage) return WEBKIT_NETWORK_REQUEST(g_object_new(WEBKIT_TYPE_NETWORK_REQUEST, "message", soupMessage.get(), NULL)); diff --git a/WebKit/gtk/webkit/webkitnetworkresponse.cpp b/WebKit/gtk/webkit/webkitnetworkresponse.cpp index 33bcd28..6745b94 100644 --- a/WebKit/gtk/webkit/webkitnetworkresponse.cpp +++ b/WebKit/gtk/webkit/webkitnetworkresponse.cpp @@ -22,7 +22,7 @@ #include "config.h" #include "webkitnetworkresponse.h" -#include "GOwnPtr.h" +#include "GRefPtr.h" #include "ResourceResponse.h" #include "webkitprivate.h" @@ -161,7 +161,7 @@ static void webkit_network_response_init(WebKitNetworkResponse* response) // for internal use only WebKitNetworkResponse* webkit_network_response_new_with_core_response(const WebCore::ResourceResponse& resourceResponse) { - GOwnPtr<SoupMessage> soupMessage(resourceResponse.toSoupMessage()); + GRefPtr<SoupMessage> soupMessage(adoptGRef(resourceResponse.toSoupMessage())); if (soupMessage) return WEBKIT_NETWORK_RESPONSE(g_object_new(WEBKIT_TYPE_NETWORK_RESPONSE, "message", soupMessage.get(), NULL)); diff --git a/WebKit/gtk/webkit/webkitprivate.cpp b/WebKit/gtk/webkit/webkitprivate.cpp index 971922f..d274708 100644 --- a/WebKit/gtk/webkit/webkitprivate.cpp +++ b/WebKit/gtk/webkit/webkitprivate.cpp @@ -19,9 +19,8 @@ */ #include "config.h" - -#include "webkitsoupauthdialog.h" #include "webkitprivate.h" + #include "ApplicationCacheStorage.h" #include "Chrome.h" #include "ChromeClientGtk.h" @@ -31,7 +30,6 @@ #include "GtkVersioning.h" #include "HitTestResult.h" #include "IconDatabase.h" -#include <libintl.h> #include "Logging.h" #include "PageCache.h" #include "PageGroup.h" @@ -41,11 +39,14 @@ #include "ResourceHandleClient.h" #include "ResourceHandleInternal.h" #include "ResourceResponse.h" -#include <runtime/InitializeThreading.h> #include "SecurityOrigin.h" -#include <stdlib.h> #include "TextEncodingRegistry.h" #include "webkitnetworkresponse.h" +#include "webkitsoupauthdialog.h" +#include <libintl.h> +#include <runtime/InitializeThreading.h> +#include <stdlib.h> +#include <wtf/Threading.h> #if ENABLE(DATABASE) #include "DatabaseTracker.h" @@ -177,34 +178,6 @@ PasteboardHelperGtk* pasteboardHelperInstance() } /** end namespace WebKit */ -namespace WTF { - -template <> void freeOwnedGPtr<SoupMessage>(SoupMessage* soupMessage) -{ - if (soupMessage) - g_object_unref(soupMessage); -} - -template <> void freeOwnedGPtr<WebKitNetworkRequest>(WebKitNetworkRequest* request) -{ - if (request) - g_object_unref(request); -} - -template <> void freeOwnedGPtr<WebKitNetworkResponse>(WebKitNetworkResponse* response) -{ - if (response) - g_object_unref(response); -} - -template <> void freeOwnedGPtr<WebKitWebResource>(WebKitWebResource* resource) -{ - if (resource) - g_object_unref(resource); -} - -} - static GtkWidget* currentToplevelCallback(WebKitSoupAuthDialog* feature, SoupMessage* message, gpointer userData) { gpointer messageData = g_object_get_data(G_OBJECT(message), "resourceHandle"); @@ -246,6 +219,8 @@ void webkit_init() bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8"); JSC::initializeThreading(); + WTF::initializeMainThread(); + WebCore::InitializeLoggingChannelsIfNecessary(); // We make sure the text codecs have been initialized, because diff --git a/WebKit/gtk/webkit/webkitprivate.h b/WebKit/gtk/webkit/webkitprivate.h index 2642d50..057b0e5 100644 --- a/WebKit/gtk/webkit/webkitprivate.h +++ b/WebKit/gtk/webkit/webkitprivate.h @@ -2,6 +2,7 @@ * Copyright (C) 2007, 2008, 2009 Holger Hans Peter Freyther * Copyright (C) 2008 Jan Michael C. Alonzo * Copyright (C) 2008 Collabora Ltd. + * Copyright (C) 2010 Igalia S.L. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public @@ -46,6 +47,7 @@ #include "ArchiveResource.h" #include "BackForwardList.h" +#include "DataObjectGtk.h" #include <enchant.h> #include "GOwnPtr.h" #include "Geolocation.h" @@ -149,6 +151,8 @@ extern "C" { char* mainResourceIdentifier; GHashTable* subResources; char* tooltipText; + + HashMap<GdkDragContext*, RefPtr<WebCore::DataObjectGtk> > draggingDataObjects; }; #define WEBKIT_WEB_FRAME_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), WEBKIT_TYPE_WEB_FRAME, WebKitWebFramePrivate)) @@ -377,11 +381,4 @@ extern "C" { webkit_web_frame_layout(WebKitWebFrame* frame); } -namespace WTF { - template <> void freeOwnedGPtr<SoupMessage>(SoupMessage*); - template <> void freeOwnedGPtr<WebKitNetworkRequest>(WebKitNetworkRequest*); - template <> void freeOwnedGPtr<WebKitNetworkResponse>(WebKitNetworkResponse*); - template <> void freeOwnedGPtr<WebKitWebResource>(WebKitWebResource*); -} - #endif diff --git a/WebKit/gtk/webkit/webkitwebsettings.cpp b/WebKit/gtk/webkit/webkitwebsettings.cpp index 5d2d658..d61f3ff 100644 --- a/WebKit/gtk/webkit/webkitwebsettings.cpp +++ b/WebKit/gtk/webkit/webkitwebsettings.cpp @@ -96,6 +96,7 @@ struct _WebKitWebSettingsPrivate { gboolean enable_spatial_navigation; gchar* user_agent; gboolean javascript_can_open_windows_automatically; + gboolean javascript_can_access_clipboard; gboolean enable_offline_web_application_cache; WebKitEditingBehavior editing_behavior; gboolean enable_universal_access_from_file_uris; @@ -145,6 +146,7 @@ enum { PROP_ENABLE_SPATIAL_NAVIGATION, PROP_USER_AGENT, PROP_JAVASCRIPT_CAN_OPEN_WINDOWS_AUTOMATICALLY, + PROP_JAVASCRIPT_CAN_ACCESS_CLIPBOARD, PROP_ENABLE_OFFLINE_WEB_APPLICATION_CACHE, PROP_EDITING_BEHAVIOR, PROP_ENABLE_UNIVERSAL_ACCESS_FROM_FILE_URIS, @@ -623,6 +625,22 @@ static void webkit_web_settings_class_init(WebKitWebSettingsClass* klass) _("Whether JavaScript can open windows automatically"), FALSE, flags)); + + /** + * WebKitWebSettings:javascript-can-access-clipboard + * + * Whether JavaScript can access Clipboard. + * + * Since: 1.3.0 + */ + g_object_class_install_property(gobject_class, + PROP_JAVASCRIPT_CAN_ACCESS_CLIPBOARD, + g_param_spec_boolean("javascript-can-access-clipboard", + _("JavaScript can access Clipboard"), + _("Whether JavaScript can access Clipboard"), + FALSE, + flags)); + /** * WebKitWebSettings:enable-offline-web-application-cache * @@ -1023,6 +1041,9 @@ static void webkit_web_settings_set_property(GObject* object, guint prop_id, con case PROP_JAVASCRIPT_CAN_OPEN_WINDOWS_AUTOMATICALLY: priv->javascript_can_open_windows_automatically = g_value_get_boolean(value); break; + case PROP_JAVASCRIPT_CAN_ACCESS_CLIPBOARD: + priv->javascript_can_access_clipboard = g_value_get_boolean(value); + break; case PROP_ENABLE_OFFLINE_WEB_APPLICATION_CACHE: priv->enable_offline_web_application_cache = g_value_get_boolean(value); break; @@ -1161,6 +1182,9 @@ static void webkit_web_settings_get_property(GObject* object, guint prop_id, GVa case PROP_JAVASCRIPT_CAN_OPEN_WINDOWS_AUTOMATICALLY: g_value_set_boolean(value, priv->javascript_can_open_windows_automatically); break; + case PROP_JAVASCRIPT_CAN_ACCESS_CLIPBOARD: + g_value_set_boolean(value, priv->javascript_can_access_clipboard); + break; case PROP_ENABLE_OFFLINE_WEB_APPLICATION_CACHE: g_value_set_boolean(value, priv->enable_offline_web_application_cache); break; @@ -1255,6 +1279,7 @@ WebKitWebSettings* webkit_web_settings_copy(WebKitWebSettings* web_settings) "enable-spatial-navigation", priv->enable_spatial_navigation, "user-agent", webkit_web_settings_get_user_agent(web_settings), "javascript-can-open-windows-automatically", priv->javascript_can_open_windows_automatically, + "javascript-can-access-clipboard", priv->javascript_can_access_clipboard, "enable-offline-web-application-cache", priv->enable_offline_web_application_cache, "editing-behavior", priv->editing_behavior, "enable-universal-access-from-file-uris", priv->enable_universal_access_from_file_uris, diff --git a/WebKit/gtk/webkit/webkitwebview.cpp b/WebKit/gtk/webkit/webkitwebview.cpp index 22f6d04..10a082c 100644 --- a/WebKit/gtk/webkit/webkitwebview.cpp +++ b/WebKit/gtk/webkit/webkitwebview.cpp @@ -81,6 +81,7 @@ #include "ResourceHandle.h" #include "ScriptValue.h" #include "Scrollbar.h" +#include "webkit/WebKitDOMDocumentPrivate.h" #include <wtf/text/CString.h> #include <gdk/gdkkeysyms.h> @@ -1123,6 +1124,8 @@ static void webkit_web_view_dispose(GObject* object) priv->subResources = NULL; } + priv->draggingDataObjects.clear(); + G_OBJECT_CLASS(webkit_web_view_parent_class)->dispose(object); } @@ -1233,126 +1236,26 @@ static void webkit_web_view_screen_changed(GtkWidget* widget, GdkScreen* previou static void webkit_web_view_drag_end(GtkWidget* widget, GdkDragContext* context) { - g_object_unref(context); -} - -struct DNDContentsRequest -{ - gint info; - GtkSelectionData* dnd_selection_data; - - gboolean is_url_label_request; - gchar* url; -}; - -void clipboard_contents_received(GtkClipboard* clipboard, GtkSelectionData* selection_data, gpointer data) -{ - DNDContentsRequest* contents_request = reinterpret_cast<DNDContentsRequest*>(data); - - if (contents_request->is_url_label_request) { - // We have received contents of the label clipboard. Use them to form - // required structures. When formed, enhance the dnd's selection data - // with them and return. - - // If the label is empty, use the url itself. - gchar* url_label = reinterpret_cast<gchar*>(gtk_selection_data_get_text(selection_data)); - if (!url_label) - url_label = g_strdup(contents_request->url); - - gchar* data = 0; - switch (contents_request->info) { - case WEBKIT_WEB_VIEW_TARGET_INFO_URI_LIST: - data = g_strdup_printf("%s\r\n%s\r\n", contents_request->url, url_label); - break; - case WEBKIT_WEB_VIEW_TARGET_INFO_NETSCAPE_URL: - data = g_strdup_printf("%s\n%s", contents_request->url, url_label); - break; - } - - if (data) { - gtk_selection_data_set(contents_request->dnd_selection_data, - contents_request->dnd_selection_data->target, 8, - reinterpret_cast<const guchar*>(data), strlen(data)); - g_free(data); - } - - g_free(url_label); - g_free(contents_request->url); - g_free(contents_request); + WebKitWebViewPrivate* priv = WEBKIT_WEB_VIEW_GET_PRIVATE(WEBKIT_WEB_VIEW(widget)); + // This might happen if a drag is still in progress after a WebKitWebView + // is diposed and before it is finalized. + if (!priv->draggingDataObjects.contains(context)) return; - } - switch (contents_request->info) { - case WEBKIT_WEB_VIEW_TARGET_INFO_HTML: - case WEBKIT_WEB_VIEW_TARGET_INFO_TEXT: - { - gchar* data = reinterpret_cast<gchar*>(gtk_selection_data_get_text(selection_data)); - if (data) { - gtk_selection_data_set(contents_request->dnd_selection_data, - contents_request->dnd_selection_data->target, 8, - reinterpret_cast<const guchar*>(data), - strlen(data)); - g_free(data); - } - break; - } - case WEBKIT_WEB_VIEW_TARGET_INFO_IMAGE: - { - GdkPixbuf* pixbuf = gtk_selection_data_get_pixbuf(selection_data); - if (pixbuf) { - gtk_selection_data_set_pixbuf(contents_request->dnd_selection_data, pixbuf); - g_object_unref(pixbuf); - } - break; - } - case WEBKIT_WEB_VIEW_TARGET_INFO_URI_LIST: - case WEBKIT_WEB_VIEW_TARGET_INFO_NETSCAPE_URL: - // URL's label is stored in another clipboard, so we store URL into - // contents request, mark the latter as an url label request - // and request for contents of the label clipboard. - contents_request->is_url_label_request = TRUE; - contents_request->url = reinterpret_cast<gchar*>(gtk_selection_data_get_text(selection_data)); - - gtk_clipboard_request_contents(gtk_clipboard_get(gdk_atom_intern_static_string("WebKitClipboardUrlLabel")), - selection_data->target, clipboard_contents_received, contents_request); - break; - } + priv->draggingDataObjects.remove(context); } -static void webkit_web_view_drag_data_get(GtkWidget* widget, GdkDragContext* context, GtkSelectionData* selection_data, guint info, guint time_) -{ - GdkAtom selection_atom = GDK_NONE; - GdkAtom target_atom = selection_data->target; - - switch (info) { - case WEBKIT_WEB_VIEW_TARGET_INFO_HTML: - selection_atom = gdk_atom_intern_static_string("WebKitClipboardHtml"); - // HTML markup data is set as text, therefor, we need a text-like target atom - target_atom = gdk_atom_intern_static_string("UTF8_STRING"); - break; - case WEBKIT_WEB_VIEW_TARGET_INFO_TEXT: - selection_atom = gdk_atom_intern_static_string("WebKitClipboardText"); - break; - case WEBKIT_WEB_VIEW_TARGET_INFO_IMAGE: - selection_atom = gdk_atom_intern_static_string("WebKitClipboardImage"); - break; - case WEBKIT_WEB_VIEW_TARGET_INFO_URI_LIST: - case WEBKIT_WEB_VIEW_TARGET_INFO_NETSCAPE_URL: - selection_atom = gdk_atom_intern_static_string("WebKitClipboardUrl"); - // We require URL and label, which are both stored in text format - // and are needed to be retrieved as such. - target_atom = gdk_atom_intern_static_string("UTF8_STRING"); - break; - } +static void webkit_web_view_drag_data_get(GtkWidget* widget, GdkDragContext* context, GtkSelectionData* selectionData, guint info, guint) +{ + WebKitWebViewPrivate* priv = WEBKIT_WEB_VIEW_GET_PRIVATE(WEBKIT_WEB_VIEW(widget)); - DNDContentsRequest* contents_request = g_new(DNDContentsRequest, 1); - contents_request->info = info; - contents_request->is_url_label_request = FALSE; - contents_request->dnd_selection_data = selection_data; + // This might happen if a drag is still in progress after a WebKitWebView + // is diposed and before it is finalized. + if (!priv->draggingDataObjects.contains(context)) + return; - gtk_clipboard_request_contents(gtk_clipboard_get(selection_atom), target_atom, - clipboard_contents_received, contents_request); + pasteboardHelperInstance()->fillSelectionData(selectionData, info, priv->draggingDataObjects.get(context).get()); } #if GTK_CHECK_VERSION(2, 12, 0) @@ -2695,7 +2598,8 @@ static void webkit_web_view_update_settings(WebKitWebView* webView) gboolean autoLoadImages, autoShrinkImages, printBackgrounds, enableScripts, enablePlugins, enableDeveloperExtras, resizableTextAreas, enablePrivateBrowsing, enableCaretBrowsing, enableHTML5Database, enableHTML5LocalStorage, - enableXSSAuditor, enableSpatialNavigation, javascriptCanOpenWindows, enableOfflineWebAppCache, + enableXSSAuditor, enableSpatialNavigation, javascriptCanOpenWindows, + javaScriptCanAccessClipboard, enableOfflineWebAppCache, enableUniversalAccessFromFileURI, enableFileAccessFromFileURI, enableDOMPaste, tabKeyCyclesThroughElements, enableSiteSpecificQuirks, usePageCache, enableJavaApplet; @@ -2725,6 +2629,7 @@ static void webkit_web_view_update_settings(WebKitWebView* webView) "enable-xss-auditor", &enableXSSAuditor, "enable-spatial-navigation", &enableSpatialNavigation, "javascript-can-open-windows-automatically", &javascriptCanOpenWindows, + "javascript-can-access-clipboard", &javaScriptCanAccessClipboard, "enable-offline-web-application-cache", &enableOfflineWebAppCache, "editing-behavior", &editingBehavior, "enable-universal-access-from-file-uris", &enableUniversalAccessFromFileURI, @@ -2760,6 +2665,7 @@ static void webkit_web_view_update_settings(WebKitWebView* webView) settings->setXSSAuditorEnabled(enableXSSAuditor); settings->setSpatialNavigationEnabled(enableSpatialNavigation); settings->setJavaScriptCanOpenWindowsAutomatically(javascriptCanOpenWindows); + settings->setJavaScriptCanAccessClipboard(javaScriptCanAccessClipboard); settings->setOfflineWebApplicationCacheEnabled(enableOfflineWebAppCache); settings->setEditingBehavior(core(editingBehavior)); settings->setAllowUniversalAccessFromFileURLs(enableUniversalAccessFromFileURI); @@ -2857,6 +2763,8 @@ static void webkit_web_view_settings_notify(WebKitWebSettings* webSettings, GPar settings->setSpatialNavigationEnabled(g_value_get_boolean(&value)); else if (name == g_intern_string("javascript-can-open-windows-automatically")) settings->setJavaScriptCanOpenWindowsAutomatically(g_value_get_boolean(&value)); + else if (name == g_intern_string("javascript-can-access-clipboard")) + settings->setJavaScriptCanAccessClipboard(g_value_get_boolean(&value)); else if (name == g_intern_string("enable-offline-web-application-cache")) settings->setOfflineWebApplicationCacheEnabled(g_value_get_boolean(&value)); else if (name == g_intern_string("editing-behavior")) @@ -4431,3 +4339,27 @@ WebKitCacheModel webkit_get_cache_model() webkit_init(); return cacheModel; } + +/** + * webkit_web_view_get_dom_document: + * @webView: a #WebKitWebView + * + * Returns: the #WebKitDOMDocument currently loaded in the @webView + * + * Since: 1.3.0 + **/ +WebKitDOMDocument* +webkit_web_view_get_dom_document(WebKitWebView* webView) +{ + g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), 0); + + Frame* coreFrame = core(webView)->mainFrame(); + if (!coreFrame) + return 0; + + Document* doc = coreFrame->document(); + if (!doc) + return 0; + + return static_cast<WebKitDOMDocument*>(kit(doc)); +} diff --git a/WebKit/gtk/webkit/webkitwebview.h b/WebKit/gtk/webkit/webkitwebview.h index e69de0a..865ae9d 100644 --- a/WebKit/gtk/webkit/webkitwebview.h +++ b/WebKit/gtk/webkit/webkitwebview.h @@ -27,6 +27,7 @@ #include <JavaScriptCore/JSBase.h> #include <webkit/webkitdefines.h> +#include <webkit/webkitdom.h> #include <webkit/webkitwebbackforwardlist.h> #include <webkit/webkitwebframe.h> #include <webkit/webkitwebhistoryitem.h> @@ -381,6 +382,9 @@ webkit_set_cache_model (WebKitCacheModel cache_mode WEBKIT_API WebKitCacheModel webkit_get_cache_model (void); +WEBKIT_API WebKitDOMDocument * +webkit_web_view_get_dom_document (WebKitWebView *webView); + G_END_DECLS #endif |
