Changeset 115627 in webkit
- Timestamp:
- Apr 30, 2012 6:49:12 AM (12 years ago)
- Location:
- trunk/Source/WebKit2
- Files:
-
- 3 added
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit2/ChangeLog
r115559 r115627 1 2012-04-30 Mario Sanchez Prada <msanchez@igalia.com> 2 3 [GTK] Implement WebUIClient's runOpenPanel in WebKit2GTK+ 4 https://bugs.webkit.org/show_bug.cgi?id=78491 5 6 Reviewed by Martin Robinson. 7 8 Add a new public class to the API, WebKitFileChooserRequest, to be 9 emitted along with a new WebKitWebView::run-file-chooser signal to 10 let client applications to provide their own file chooser dialog 11 when the use interacts with HTML Input elements of type 'file'. 12 13 * GNUmakefile.am: Added new source files and headers. 14 * UIProcess/API/gtk/WebKitFileChooserRequest.cpp: Added. 15 (_WebKitFileChooserRequestPrivate): 16 (webkit_file_chooser_request_init): 17 (webkitFileChooserRequestFinalize): 18 (webkitFileChooserRequestGetProperty): 19 (webkit_file_chooser_request_class_init): 20 (webkitFileChooserRequestCreate): 21 (webkit_file_chooser_request_get_mime_types): 22 (webkit_file_chooser_request_get_mime_types_filter): 23 (webkit_file_chooser_request_get_select_multiple): 24 (webkit_file_chooser_request_select_files): 25 (webkit_file_chooser_request_get_selected_files): 26 (webkit_file_chooser_request_cancel): 27 * UIProcess/API/gtk/WebKitFileChooserRequest.h: Added. 28 (_WebKitFileChooserRequest): 29 (_WebKitFileChooserRequestClass): 30 * UIProcess/API/gtk/WebKitFileChooserRequestPrivate.h: Added, 31 containing the prototype of webkitFileChooserRequestCreate. 32 33 Provide private API to make a file chooser request from the 34 WebView, and provide a default handler for it. 35 36 * UIProcess/API/gtk/WebKitWebView.cpp: 37 (fileChooserDialogResponseCallback): Handler for the 'response' 38 signal for the GtkFileChooserDialog used in the default 39 handler. It will call to webkit_file_chooser_request_select_files 40 or webkit_file_chooser_request_cancel as needed. 41 (webkitWebViewRunFileChooser): Default handler for the new 42 'run-file-chooser' signal. It will create a GtkFileChooserDialog, 43 connect to the 'response' signal and show it. 44 (webkit_web_view_class_init): Connect the 'run-file-chooser' 45 signal to the default handler, webkitWebViewRunFileChooser. 46 (webkitWebViewRunFileChooserRequest): 47 * UIProcess/API/gtk/WebKitWebView.h: 48 (_WebKitWebViewClass): Added prototype for the handler of the new 49 'run-file-chooser' signal. 50 * UIProcess/API/gtk/WebKitWebViewPrivate.h: Added prototype for 51 private new function webkitWebViewRunFileChooserRequest. 52 53 Provide an implementation for runOpenPanel in WebKitUIClient. 54 55 * UIProcess/API/gtk/WebKitUIClient.cpp: 56 (runOpenPanel): New, implements runOpenPanel by creating an 57 instance of WebKitFileChooserRequest and asking the WebView to 58 emit the 'run-file-chooser' signal with it. 59 (attachUIClientToView): Reference the new runOpenPanel function. 60 61 Added the new publich header to the main header. 62 63 * UIProcess/API/gtk/webkit2.h: Added WebKitFileChooserRequest.h. 64 65 New unit tests for the new WebKitFileChooserRequest API. Also, 66 extended the WebViewTest class to allow simulating mouse clicks. 67 68 * UIProcess/API/gtk/tests/TestWebKitWebView.cpp: 69 (checkMimeTypeForFilter): New, checks whether a GtkFileFilter 70 filters a given MIME type, as specified by RFC 2046. 71 (testWebViewFileChooserRequest): New unit test. 72 (beforeAll): Add the new unit test as an UIClientTest. 73 74 * UIProcess/API/gtk/tests/WebViewTest.cpp: 75 (WebViewTest::clickMouseButton): New public function to simulate a 76 mouse click through GdkEvents, as the combination of a 'press' and 77 a 'release' event. Used from the new unit test to simulate the 78 user pressing in the button rendered for a HTML Input element. 79 (WebViewTest::executeMouseButtonEvent): New private function to 80 simulate a mouse event through GdkEvents. 81 * UIProcess/API/gtk/tests/WebViewTest.h: 82 83 Updated documentation related files with the new API. 84 85 * UIProcess/API/gtk/docs/webkit2gtk-sections.txt: Added new API. 86 * UIProcess/API/gtk/docs/webkit2gtk-docs.sgml: Added new section. 87 * UIProcess/API/gtk/docs/webkit2gtk.types: Added get_type function. 88 1 89 2012-04-28 Yury Semikhatsky <yurys@chromium.org> 2 90 -
trunk/Source/WebKit2/GNUmakefile.am
r115411 r115627 97 97 $(WebKit2)/UIProcess/API/gtk/WebKitEditingCommands.h \ 98 98 $(WebKit2)/UIProcess/API/gtk/WebKitError.h \ 99 $(WebKit2)/UIProcess/API/gtk/WebKitFileChooserRequest.h \ 99 100 $(WebKit2)/UIProcess/API/gtk/WebKitFindController.h \ 100 101 $(WebKit2)/UIProcess/API/gtk/WebKitHitTestResult.h \ … … 578 579 Source/WebKit2/UIProcess/API/gtk/WebKitError.h \ 579 580 Source/WebKit2/UIProcess/API/gtk/WebKitError.cpp \ 581 Source/WebKit2/UIProcess/API/gtk/WebKitFileChooserRequest.cpp \ 582 Source/WebKit2/UIProcess/API/gtk/WebKitFileChooserRequest.h \ 583 Source/WebKit2/UIProcess/API/gtk/WebKitFileChooserRequestPrivate.h \ 580 584 Source/WebKit2/UIProcess/API/gtk/WebKitFullscreenClient.cpp \ 581 585 Source/WebKit2/UIProcess/API/gtk/WebKitFullscreenClient.h \ -
trunk/Source/WebKit2/UIProcess/API/gtk/WebKitUIClient.cpp
r107947 r115627 21 21 #include "WebKitUIClient.h" 22 22 23 #include "WebKitFileChooserRequestPrivate.h" 23 24 #include "WebKitPrivate.h" 24 25 #include "WebKitWebViewBasePrivate.h" … … 27 28 #include "WebPageProxy.h" 28 29 #include <WebCore/GtkUtilities.h> 30 #include <wtf/gobject/GRefPtr.h> 29 31 30 32 using namespace WebKit; … … 137 139 } 138 140 141 static void runOpenPanel(WKPageRef page, WKFrameRef frame, WKOpenPanelParametersRef parameters, WKOpenPanelResultListenerRef listener, const void *clientInfo) 142 { 143 GRefPtr<WebKitFileChooserRequest> request = adoptGRef(webkitFileChooserRequestCreate(parameters, listener)); 144 webkitWebViewRunFileChooserRequest(WEBKIT_WEB_VIEW(clientInfo), request.get()); 145 } 146 139 147 void attachUIClientToView(WebKitWebView* webView) 140 148 { … … 170 178 0, // pageDidScroll 171 179 0, // exceededDatabaseQuota 172 0, // runOpenPanel180 runOpenPanel, 173 181 0, // decidePolicyForGeolocationPermissionRequest 174 182 0, // headerHeight -
trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp
r114719 r115627 75 75 LEAVE_FULLSCREEN, 76 76 77 RUN_FILE_CHOOSER, 78 77 79 LAST_SIGNAL 78 80 }; … … 207 209 } 208 210 211 static void fileChooserDialogResponseCallback(GtkDialog* dialog, gint responseID, WebKitFileChooserRequest* request) 212 { 213 GRefPtr<WebKitFileChooserRequest> adoptedRequest = adoptGRef(request); 214 if (responseID == GTK_RESPONSE_ACCEPT) { 215 GOwnPtr<GSList> filesList(gtk_file_chooser_get_filenames(GTK_FILE_CHOOSER(dialog))); 216 GRefPtr<GPtrArray> filesArray = adoptGRef(g_ptr_array_new()); 217 for (GSList* file = filesList.get(); file; file = g_slist_next(file)) 218 g_ptr_array_add(filesArray.get(), file->data); 219 g_ptr_array_add(filesArray.get(), 0); 220 webkit_file_chooser_request_select_files(adoptedRequest.get(), reinterpret_cast<const gchar* const*>(filesArray->pdata)); 221 } else 222 webkit_file_chooser_request_cancel(adoptedRequest.get()); 223 224 gtk_widget_destroy(GTK_WIDGET(dialog)); 225 } 226 227 static gboolean webkitWebViewRunFileChooser(WebKitWebView* webView, WebKitFileChooserRequest* request) 228 { 229 GtkWidget* toplevel = gtk_widget_get_toplevel(GTK_WIDGET(webView)); 230 if (!widgetIsOnscreenToplevelWindow(toplevel)) 231 toplevel = 0; 232 233 gboolean allowsMultipleSelection = webkit_file_chooser_request_get_select_multiple(request); 234 GtkWidget* dialog = gtk_file_chooser_dialog_new(allowsMultipleSelection ? _("Select Files") : _("Select File"), 235 toplevel ? GTK_WINDOW(toplevel) : 0, 236 GTK_FILE_CHOOSER_ACTION_OPEN, 237 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, 238 GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, 239 NULL); 240 241 if (GtkFileFilter* filter = webkit_file_chooser_request_get_mime_types_filter(request)) 242 gtk_file_chooser_set_filter(GTK_FILE_CHOOSER(dialog), filter); 243 gtk_file_chooser_set_select_multiple(GTK_FILE_CHOOSER(dialog), allowsMultipleSelection); 244 245 if (const gchar* const* selectedFiles = webkit_file_chooser_request_get_selected_files(request)) 246 gtk_file_chooser_select_filename(GTK_FILE_CHOOSER(dialog), selectedFiles[0]); 247 248 g_signal_connect(dialog, "response", G_CALLBACK(fileChooserDialogResponseCallback), g_object_ref(request)); 249 gtk_widget_show(dialog); 250 251 return TRUE; 252 } 253 209 254 static void webkitWebViewConstructed(GObject* object) 210 255 { … … 314 359 webViewClass->script_dialog = webkitWebViewScriptDialog; 315 360 webViewClass->decide_policy = webkitWebViewDecidePolicy; 361 webViewClass->run_file_chooser = webkitWebViewRunFileChooser; 316 362 317 363 g_type_class_add_private(webViewClass, sizeof(WebKitWebViewPrivate)); … … 758 804 webkit_marshal_BOOLEAN__VOID, 759 805 G_TYPE_BOOLEAN, 0); 806 /** 807 * WebKitWebView::run-file-chooser: 808 * @web_view: the #WebKitWebView on which the signal is emitted 809 * @request: a #WebKitFileChooserRequest 810 * 811 * This signal is emitted when the user interacts with a <input 812 * type='file' /> HTML element, requesting from WebKit to show 813 * a dialog to select one or more files to be uploaded. To let the 814 * application know the details of the file chooser, as well as to 815 * allow the client application to either cancel the request or 816 * perform an actual selection of files, the signal will pass an 817 * instance of the #WebKitFileChooserRequest in the @request 818 * argument. 819 * 820 * The default signal handler will asynchronously run a regular 821 * #GtkFileChooserDialog for the user to interact with. 822 * 823 * Returns: %TRUE to stop other handlers from being invoked for the event. 824 * %FALSE to propagate the event further. 825 * 826 */ 827 signals[RUN_FILE_CHOOSER] = 828 g_signal_new("run-file-chooser", 829 G_TYPE_FROM_CLASS(webViewClass), 830 G_SIGNAL_RUN_LAST, 831 G_STRUCT_OFFSET(WebKitWebViewClass, run_file_chooser), 832 g_signal_accumulator_true_handled, 0 /* accumulator data */, 833 webkit_marshal_BOOLEAN__OBJECT, 834 G_TYPE_BOOLEAN, 1, /* number of parameters */ 835 WEBKIT_TYPE_FILE_CHOOSER_REQUEST); 760 836 } 761 837 … … 983 1059 g_signal_emit(webView, signals[LEAVE_FULLSCREEN], 0, &returnValue); 984 1060 return !returnValue; 1061 } 1062 1063 void webkitWebViewRunFileChooserRequest(WebKitWebView* webView, WebKitFileChooserRequest* request) 1064 { 1065 gboolean returnValue; 1066 g_signal_emit(webView, signals[RUN_FILE_CHOOSER], 0, request, &returnValue); 985 1067 } 986 1068 -
trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.h
r113697 r115627 32 32 #include <webkit2/WebKitBackForwardList.h> 33 33 #include <webkit2/WebKitDefines.h> 34 #include <webkit2/WebKitFileChooserRequest.h> 34 35 #include <webkit2/WebKitFindController.h> 35 36 #include <webkit2/WebKitHitTestResult.h> 36 37 #include <webkit2/WebKitJavascriptResult.h> 38 #include <webkit2/WebKitPolicyDecision.h> 37 39 #include <webkit2/WebKitScriptDialog.h> 38 40 #include <webkit2/WebKitSettings.h> … … 42 44 #include <webkit2/WebKitWebViewBase.h> 43 45 #include <webkit2/WebKitWindowProperties.h> 44 #include <webkit2/WebKitPolicyDecision.h>45 46 46 47 G_BEGIN_DECLS … … 152 153 gboolean (* enter_fullscreen) (WebKitWebView *web_view); 153 154 gboolean (* leave_fullscreen) (WebKitWebView *web_view); 155 gboolean (* run_file_chooser) (WebKitWebView *web_view, 156 WebKitFileChooserRequest *request); 154 157 155 158 /* Padding for future expansion */ -
trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewPrivate.h
r113697 r115627 47 47 void webkitWebViewPrintFrame(WebKitWebView*, WKFrameRef); 48 48 void webkitWebViewResourceLoadStarted(WebKitWebView*, WKFrameRef, uint64_t resourceIdentifier, WebKitURIRequest*, bool isMainResource); 49 void webkitWebViewRunFileChooserRequest(WebKitWebView*, WebKitFileChooserRequest*); 49 50 WebKitWebResource* webkitWebViewGetLoadingWebResource(WebKitWebView*, uint64_t resourceIdentifier); 50 51 void webkitWebViewRemoveLoadingWebResource(WebKitWebView*, uint64_t resourceIdentifier); -
trunk/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-docs.sgml
r113870 r115627 29 29 <xi:include href="xml/WebKitWebResource.xml"/> 30 30 <xi:include href="xml/WebKitError.xml"/> 31 <xi:include href="xml/WebKitFileChooserRequest.xml"/> 31 32 <xi:include href="xml/WebKitFindController.xml"/> 32 33 <xi:include href="xml/WebKitCookieManager.xml"/> -
trunk/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-sections.txt
r113870 r115627 522 522 523 523 <SECTION> 524 <FILE>WebKitFileChooserRequest</FILE> 525 WebKitFileChooserRequest 526 webkit_file_chooser_request_get_mime_types 527 webkit_file_chooser_request_get_mime_types_filter 528 webkit_file_chooser_request_get_select_multiple 529 webkit_file_chooser_request_select_files 530 webkit_file_chooser_request_get_selected_files 531 webkit_file_chooser_request_cancel 532 533 <SUBSECTION Standard> 534 WebKitFileChooserRequestClass 535 WEBKIT_TYPE_FILE_CHOOSER_REQUEST 536 WEBKIT_FILE_CHOOSER_REQUEST 537 WEBKIT_IS_FILE_CHOOSER_REQUEST 538 WEBKIT_FILE_CHOOSER_REQUEST_CLASS 539 WEBKIT_IS_FILE_CHOOSER_REQUEST_CLASS 540 WEBKIT_FILE_CHOOSER_REQUEST_GET_CLASS 541 542 <SUBSECTION Private> 543 WebKitFileChooserRequestPrivate 544 webkit_file_chooser_request_get_type 545 </SECTION> 546 547 <SECTION> 524 548 <FILE>WebKitFindController</FILE> 525 549 WebKitFindController -
trunk/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk.types
r113870 r115627 10 10 webkit_window_properties_get_type 11 11 webkit_download_get_type 12 webkit_file_chooser_request_get_type 12 13 webkit_find_controller_get_type 13 14 webkit_script_dialog_get_type -
trunk/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebView.cpp
r113697 r115627 333 333 } 334 334 335 static gboolean checkMimeTypeForFilter(GtkFileFilter* filter, const gchar* mimeType) 336 { 337 GtkFileFilterInfo filterInfo; 338 filterInfo.contains = GTK_FILE_FILTER_MIME_TYPE; 339 filterInfo.mime_type = mimeType; 340 return gtk_file_filter_filter(filter, &filterInfo); 341 } 342 335 343 static void testWebViewJavaScriptDialogs(UIClientTest* test, gconstpointer) 336 344 { … … 513 521 } 514 522 523 class FileChooserTest: public UIClientTest { 524 public: 525 MAKE_GLIB_TEST_FIXTURE(FileChooserTest); 526 527 FileChooserTest() 528 { 529 g_signal_connect(m_webView, "run-file-chooser", G_CALLBACK(runFileChooserCallback), this); 530 } 531 532 static gboolean runFileChooserCallback(WebKitWebView*, WebKitFileChooserRequest* request, FileChooserTest* test) 533 { 534 test->runFileChooser(request); 535 return TRUE; 536 } 537 538 void runFileChooser(WebKitFileChooserRequest* request) 539 { 540 assertObjectIsDeletedWhenTestFinishes(G_OBJECT(request)); 541 m_fileChooserRequest = request; 542 g_main_loop_quit(m_mainLoop); 543 } 544 545 WebKitFileChooserRequest* clickMouseButtonAndWaitForFileChooserRequest(int x, int y) 546 { 547 clickMouseButton(x, y); 548 g_main_loop_run(m_mainLoop); 549 return m_fileChooserRequest.get(); 550 } 551 552 private: 553 GRefPtr<WebKitFileChooserRequest> m_fileChooserRequest; 554 }; 555 556 static void testWebViewFileChooserRequest(FileChooserTest* test, gconstpointer) 557 { 558 test->showInWindowAndWaitUntilMapped(); 559 static const char* fileChooserHTMLFormat = "<html><body><input style='position:absolute;left:0;top:0;margin:0;padding:0' type='file' %s/></body></html>"; 560 561 // Multiple selections not allowed, no MIME filtering. 562 GOwnPtr<char> simpleFileUploadHTML(g_strdup_printf(fileChooserHTMLFormat, "")); 563 test->loadHtml(simpleFileUploadHTML.get(), 0); 564 test->waitUntilLoadFinished(); 565 WebKitFileChooserRequest* fileChooserRequest = test->clickMouseButtonAndWaitForFileChooserRequest(5, 5); 566 g_assert(!webkit_file_chooser_request_get_select_multiple(fileChooserRequest)); 567 568 const gchar* const* mimeTypes = webkit_file_chooser_request_get_mime_types(fileChooserRequest); 569 g_assert(!mimeTypes); 570 GtkFileFilter* filter = webkit_file_chooser_request_get_mime_types_filter(fileChooserRequest); 571 g_assert(!filter); 572 const gchar* const* selectedFiles = webkit_file_chooser_request_get_selected_files(fileChooserRequest); 573 g_assert(!selectedFiles); 574 webkit_file_chooser_request_cancel(fileChooserRequest); 575 576 // Multiple selections allowed, no MIME filtering, some pre-selected files. 577 GOwnPtr<char> multipleSelectionFileUploadHTML(g_strdup_printf(fileChooserHTMLFormat, "multiple")); 578 test->loadHtml(multipleSelectionFileUploadHTML.get(), 0); 579 test->waitUntilLoadFinished(); 580 fileChooserRequest = test->clickMouseButtonAndWaitForFileChooserRequest(5, 5); 581 g_assert(webkit_file_chooser_request_get_select_multiple(fileChooserRequest)); 582 583 mimeTypes = webkit_file_chooser_request_get_mime_types(fileChooserRequest); 584 g_assert(!mimeTypes); 585 filter = webkit_file_chooser_request_get_mime_types_filter(fileChooserRequest); 586 g_assert(!filter); 587 selectedFiles = webkit_file_chooser_request_get_selected_files(fileChooserRequest); 588 g_assert(!selectedFiles); 589 590 // Select some files. 591 const gchar* filesToSelect[4] = { "/foo", "/foo/bar", "/foo/bar/baz", 0 }; 592 webkit_file_chooser_request_select_files(fileChooserRequest, filesToSelect); 593 594 // Check the files that have been just selected. 595 selectedFiles = webkit_file_chooser_request_get_selected_files(fileChooserRequest); 596 g_assert(selectedFiles); 597 g_assert_cmpstr(selectedFiles[0], ==, "/foo"); 598 g_assert_cmpstr(selectedFiles[1], ==, "/foo/bar"); 599 g_assert_cmpstr(selectedFiles[2], ==, "/foo/bar/baz"); 600 g_assert(!selectedFiles[3]); 601 602 // Perform another request to check if the list of files selected 603 // in the previous step appears now as part of the new request. 604 fileChooserRequest = test->clickMouseButtonAndWaitForFileChooserRequest(5, 5); 605 selectedFiles = webkit_file_chooser_request_get_selected_files(fileChooserRequest); 606 g_assert(selectedFiles); 607 g_assert_cmpstr(selectedFiles[0], ==, "/foo"); 608 g_assert_cmpstr(selectedFiles[1], ==, "/foo/bar"); 609 g_assert_cmpstr(selectedFiles[2], ==, "/foo/bar/baz"); 610 g_assert(!selectedFiles[3]); 611 webkit_file_chooser_request_cancel(fileChooserRequest); 612 613 // Multiple selections not allowed, only accept images, audio and video files.. 614 GOwnPtr<char> mimeFilteredFileUploadHTML(g_strdup_printf(fileChooserHTMLFormat, "accept='audio/*,video/*,image/*'")); 615 test->loadHtml(mimeFilteredFileUploadHTML.get(), 0); 616 test->waitUntilLoadFinished(); 617 fileChooserRequest = test->clickMouseButtonAndWaitForFileChooserRequest(5, 5); 618 g_assert(!webkit_file_chooser_request_get_select_multiple(fileChooserRequest)); 619 620 mimeTypes = webkit_file_chooser_request_get_mime_types(fileChooserRequest); 621 g_assert(mimeTypes); 622 g_assert_cmpstr(mimeTypes[0], ==, "audio/*"); 623 g_assert_cmpstr(mimeTypes[1], ==, "video/*"); 624 g_assert_cmpstr(mimeTypes[2], ==, "image/*"); 625 g_assert(!mimeTypes[3]); 626 627 filter = webkit_file_chooser_request_get_mime_types_filter(fileChooserRequest); 628 g_assert(GTK_IS_FILE_FILTER(filter)); 629 g_assert(checkMimeTypeForFilter(filter, "audio/*")); 630 g_assert(checkMimeTypeForFilter(filter, "video/*")); 631 g_assert(checkMimeTypeForFilter(filter, "image/*")); 632 633 selectedFiles = webkit_file_chooser_request_get_selected_files(fileChooserRequest); 634 g_assert(!selectedFiles); 635 webkit_file_chooser_request_cancel(fileChooserRequest); 636 } 637 515 638 class FullScreenClientTest: public WebViewTest { 516 639 public: … … 596 719 WebViewTest::add("WebKitWebView", "zoom-level", testWebViewZoomLevel); 597 720 WebViewTest::add("WebKitWebView", "run-javascript", testWebViewRunJavaScript); 721 FileChooserTest::add("WebKitWebView", "file-chooser-request", testWebViewFileChooserRequest); 598 722 FullScreenClientTest::add("WebKitWebView", "fullscreen", testWebViewFullScreen); 599 723 } -
trunk/Source/WebKit2/UIProcess/API/gtk/tests/WebViewTest.cpp
r113697 r115627 199 199 } 200 200 201 void WebViewTest::clickMouseButton(int x, int y, unsigned int button, unsigned int mouseModifiers) 202 { 203 doMouseButtonEvent(GDK_BUTTON_PRESS, x, y, button, mouseModifiers); 204 doMouseButtonEvent(GDK_BUTTON_RELEASE, x, y, button, mouseModifiers); 205 } 206 201 207 void WebViewTest::keyStroke(unsigned int keyVal, unsigned int keyModifiers) 202 208 { … … 225 231 } 226 232 233 void WebViewTest::doMouseButtonEvent(GdkEventType eventType, int x, int y, unsigned int button, unsigned int mouseModifiers) 234 { 235 g_assert(m_parentWindow); 236 GtkWidget* viewWidget = GTK_WIDGET(m_webView); 237 g_assert(gtk_widget_get_realized(viewWidget)); 238 239 GOwnPtr<GdkEvent> event(gdk_event_new(eventType)); 240 event->button.window = gtk_widget_get_window(viewWidget); 241 g_object_ref(event->button.window); 242 243 event->button.time = GDK_CURRENT_TIME; 244 event->button.x = x; 245 event->button.y = y; 246 event->button.axes = 0; 247 event->button.state = mouseModifiers; 248 event->button.button = button; 249 250 event->button.device = gdk_device_manager_get_client_pointer(gdk_display_get_device_manager(gtk_widget_get_display(viewWidget))); 251 252 int xRoot, yRoot; 253 gdk_window_get_root_coords(gtk_widget_get_window(viewWidget), x, y, &xRoot, &yRoot); 254 event->button.x_root = xRoot; 255 event->button.y_root = yRoot; 256 gtk_main_do_event(event.get()); 257 } 258 227 259 static void runJavaScriptReadyCallback(GObject*, GAsyncResult* result, WebViewTest* test) 228 260 { -
trunk/Source/WebKit2/UIProcess/API/gtk/tests/WebViewTest.h
r113697 r115627 48 48 49 49 void mouseMoveTo(int x, int y, unsigned int mouseModifiers = 0); 50 void clickMouseButton(int x, int y, unsigned int button = 1, unsigned int mouseModifiers = 0); 50 51 void keyStroke(unsigned int keyVal, unsigned int keyModifiers = 0); 51 52 … … 66 67 WebKitJavascriptResult* m_javascriptResult; 67 68 GError** m_javascriptError; 69 70 private: 71 void doMouseButtonEvent(GdkEventType, int, int, unsigned int, unsigned int); 68 72 }; 69 73 -
trunk/Source/WebKit2/UIProcess/API/gtk/webkit2.h
r113870 r115627 32 32 #include <webkit2/WebKitEnumTypes.h> 33 33 #include <webkit2/WebKitError.h> 34 #include <webkit2/WebKitFileChooserRequest.h> 34 35 #include <webkit2/WebKitFindController.h> 35 36 #include <webkit2/WebKitHitTestResult.h> … … 42 43 #include <webkit2/WebKitWebContext.h> 43 44 #include <webkit2/WebKitWebResource.h> 45 #include <webkit2/WebKitWebView.h> 44 46 #include <webkit2/WebKitWebViewBase.h> 45 #include <webkit2/WebKitWebView.h>46 47 #include <webkit2/WebKitWindowProperties.h> 47 48
Note: See TracChangeset
for help on using the changeset viewer.