static void load_status_callback(WebKitWebView* webView, GParamSpec* spec, DomDomviewFixture* fixture) { WebKitLoadStatus status = webkit_web_view_get_load_status(webView); if (status == WEBKIT_LOAD_FINISHED) { WebKitDOMDocument* document; WebKitDOMDOMWindow* domWindow; WebKitDOMElement* element; WebKitDOMEvent* event; glong clientX, clientY; document = webkit_web_view_get_dom_document(WEBKIT_WEB_VIEW(fixture->webView)); g_assert(document); domWindow = webkit_dom_document_get_default_view(document); g_assert(domWindow); fixture->domWindow = domWindow; element = webkit_dom_document_get_element_by_id(document, "test"); g_assert(element); event = webkit_dom_document_create_event(document, "MouseEvent", NULL); g_assert(event); g_assert(WEBKIT_DOM_IS_EVENT(event)); g_assert(WEBKIT_DOM_IS_MOUSE_EVENT(event)); clientX = webkit_dom_element_get_client_left(element); clientY = webkit_dom_element_get_client_top(element); webkit_dom_mouse_event_init_mouse_event(WEBKIT_DOM_MOUSE_EVENT(event), "click", TRUE, TRUE, fixture->domWindow, 0, 0, 0, clientX, clientY, FALSE, FALSE, FALSE, FALSE, 1, WEBKIT_DOM_EVENT_TARGET(element)); webkit_dom_event_target_add_event_listener(WEBKIT_DOM_EVENT_TARGET(element), "click", G_CALLBACK(clicked_cb), false, fixture); g_assert(fixture->clicked == FALSE); webkit_dom_event_target_dispatch_event(WEBKIT_DOM_EVENT_TARGET(element), event, NULL); } }
void webkit_dom_event_target_dispatch_event(WebKitDOMEventTarget* target, WebKitDOMEvent* event, GError** error) { g_return_if_fail(WEBKIT_DOM_IS_EVENT_TARGET(target)); g_return_if_fail(WEBKIT_DOM_IS_EVENT(event)); WebKitDOMEventTargetIface* iface = WEBKIT_DOM_EVENT_TARGET_GET_IFACE(target); if (iface->dispatch_event) iface->dispatch_event(target, event, error); }
gboolean webkit_dom_test_event_target_dispatch_event(WebKitDOMTestEventTarget* self, WebKitDOMEvent* evt, GError** error) { WebCore::JSMainThreadNullState state; g_return_val_if_fail(WEBKIT_DOM_IS_TEST_EVENT_TARGET(self), FALSE); g_return_val_if_fail(WEBKIT_DOM_IS_EVENT(evt), FALSE); g_return_val_if_fail(!error || !*error, FALSE); WebCore::TestEventTarget* item = WebKit::core(self); WebCore::Event* convertedEvt = WebKit::core(evt); WebCore::ExceptionCode ec = 0; gboolean result = item->dispatchEvent(convertedEvt, ec); if (ec) { WebCore::ExceptionCodeDescription ecdesc(ec); g_set_error_literal(error, g_quark_from_string("WEBKIT_DOM"), ecdesc.code, ecdesc.name); } return result; }
static gboolean clickedCallback(WebKitDOMDOMWindow* view, WebKitDOMEvent* event, DomDomviewFixture* fixture) { WebKitDOMEventTarget* target; gushort phase; g_assert(event); g_assert(WEBKIT_DOM_IS_EVENT(event)); // We should catch this in the bubbling up phase, since we are connecting to the toplevel object phase = webkit_dom_event_get_event_phase(event); g_assert_cmpint(phase, ==, 3); target = webkit_dom_event_get_current_target(event); g_assert(target == WEBKIT_DOM_EVENT_TARGET(view)); g_assert(fixture->clicked == FALSE); fixture->clicked = TRUE; finish_loading(fixture); return FALSE; }