Changeset 170702 in webkit
- Timestamp:
- Jul 2, 2014 12:19:46 AM (10 years ago)
- Location:
- trunk
- Files:
-
- 3 added
- 22 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit2/ChangeLog
r170696 r170702 1 2014-07-02 Carlos Garcia Campos <cgarcia@igalia.com> 2 3 [GTK] WebKitWebView::create should receive information about the navigation action 4 https://bugs.webkit.org/show_bug.cgi?id=133680 5 6 Reviewed by Martin Robinson. 7 8 Add WebKitNavigationAction boxed type representing a navigation 9 action to be passed as parameter of WebKitWebView::create 10 signal. In the future it could be also for the 11 WebKitNavigationPolicyDecision class. The class contains 12 information about a navigation action like the navigation type, 13 the request, the mouse button and key modifiers and whether it was 14 started by a user gesture. This information is needed to be able 15 to implement a proper popup blocker. Since all that information is 16 not provided by the C API, we have switched the UI client to use a 17 custom client derived from API::UIClient. This also avoids a lot 18 of toAPI -> toImpl unneeded conversions. 19 20 * PlatformGTK.cmake: Add new files to compilation. 21 * UIProcess/API/gtk/WebKitHitTestResult.cpp: 22 (webkitHitTestResultCreate): Use a WebHitTestResult::Data const 23 reference instead of a pointer to a WebHitTestResult. 24 (webkitHitTestResultCompare): Ditto. 25 * UIProcess/API/gtk/WebKitHitTestResultPrivate.h: 26 * UIProcess/API/gtk/WebKitNavigationAction.cpp: Added. 27 (webkitNavigationActionCreate): Create a WebKitNavigationAction 28 for the given ResourceRequest and NavigationActionData. 29 (webkit_navigation_action_copy): 30 (webkit_navigation_action_free): 31 (webkit_navigation_action_get_navigation_type): 32 (webkit_navigation_action_get_mouse_button): 33 (webkit_navigation_action_get_modifiers): 34 (webkit_navigation_action_get_request): 35 (webkit_navigation_action_is_user_gesture): 36 * UIProcess/API/gtk/WebKitNavigationAction.h: Added. 37 * UIProcess/API/gtk/WebKitNavigationActionPrivate.h: Added. 38 * UIProcess/API/gtk/WebKitNavigationPolicyDecision.h: 39 * UIProcess/API/gtk/WebKitPrivate.cpp: 40 (toGdkModifiers): 41 (toWebKitNavigationType): 42 (toWebKitMouseButton): 43 * UIProcess/API/gtk/WebKitPrivate.h: 44 * UIProcess/API/gtk/WebKitUIClient.cpp: 45 (UIClient::UIClient): Implement the UIClient using a custom class. 46 (attachUIClientToView): Set the UIClient directly to the WebPageProxy. 47 (createNewPage): Deleted. 48 (showPage): Deleted. 49 (closePage): Deleted. 50 (runJavaScriptAlert): Deleted. 51 (runJavaScriptConfirm): Deleted. 52 (runJavaScriptPrompt): Deleted. 53 (toolbarsAreVisible): Deleted. 54 (setToolbarsAreVisible): Deleted. 55 (menuBarIsVisible): Deleted. 56 (setMenuBarIsVisible): Deleted. 57 (statusBarIsVisible): Deleted. 58 (setStatusBarIsVisible): Deleted. 59 (isResizable): Deleted. 60 (setIsResizable): Deleted. 61 (getWindowFrame): Deleted. 62 (setWindowFrame): Deleted. 63 (mouseDidMoveOverElement): Deleted. 64 (printFrame): Deleted. 65 (runOpenPanel): Deleted. 66 (decidePolicyForGeolocationPermissionRequest): Deleted. 67 (runModal): Deleted. 68 * UIProcess/API/gtk/WebKitWebView.cpp: 69 (webkitWebViewCreate): Add WebKitNavigationAction parameter. 70 (webkit_web_view_class_init): Add WebKitNavigationAction paramter 71 to CREATE signal. 72 (webkitWebViewCreateNewPage): Add WebKitNavigationAction parameter 73 and pass it to the signal callbacks. 74 (webkitWebViewMouseTargetChanged): Use a WebHitTestResult::Data 75 const reference. 76 (webkitWebViewPopulateContextMenu): Ditto. 77 * UIProcess/API/gtk/WebKitWebView.h: 78 * UIProcess/API/gtk/WebKitWebViewPrivate.h: 79 * UIProcess/API/gtk/WebKitWindowProperties.cpp: 80 (webkitWindowPropertiesUpdateFromWebWindowFeatures): Use a 81 WebCore::WindowFeatures const reference. 82 * UIProcess/API/gtk/WebKitWindowPropertiesPrivate.h: 83 * UIProcess/API/gtk/docs/webkit2gtk-docs.sgml: Add new section. 84 * UIProcess/API/gtk/docs/webkit2gtk-sections.txt: Add new symbols. 85 * UIProcess/API/gtk/webkit2.h: Include WebKitNavigationAction.h. 86 1 87 2014-07-01 KwangHyuk Kim <hyuki.kim@samsung.com> 2 88 -
trunk/Source/WebKit2/PlatformGTK.cmake
r169446 r170702 163 163 UIProcess/API/gtk/WebKitMimeInfo.h 164 164 UIProcess/API/gtk/WebKitMimeInfoPrivate.h 165 UIProcess/API/gtk/WebKitNavigationAction.cpp 166 UIProcess/API/gtk/WebKitNavigationAction.h 167 UIProcess/API/gtk/WebKitNavigationActionPrivate.h 165 168 UIProcess/API/gtk/WebKitNavigationPolicyDecision.cpp 166 169 UIProcess/API/gtk/WebKitNavigationPolicyDecision.h … … 338 341 ${WEBKIT2_DIR}/UIProcess/API/gtk/WebKitJavascriptResult.h 339 342 ${WEBKIT2_DIR}/UIProcess/API/gtk/WebKitMimeInfo.h 343 ${WEBKIT2_DIR}/UIProcess/API/gtk/WebKitNavigationAction.h 340 344 ${WEBKIT2_DIR}/UIProcess/API/gtk/WebKitNavigationPolicyDecision.h 341 345 ${WEBKIT2_DIR}/UIProcess/API/gtk/WebKitPermissionRequest.h -
trunk/Source/WebKit2/UIProcess/API/gtk/WebKitHitTestResult.cpp
r137192 r170702 222 222 } 223 223 224 WebKitHitTestResult* webkitHitTestResultCreate( WebHitTestResult*hitTestResult)224 WebKitHitTestResult* webkitHitTestResultCreate(const WebHitTestResult::Data& hitTestResult) 225 225 { 226 226 unsigned context = WEBKIT_HIT_TEST_RESULT_CONTEXT_DOCUMENT; 227 227 228 const String& linkURL = hitTestResult->absoluteLinkURL(); 229 if (!linkURL.isEmpty()) 228 if (!hitTestResult.absoluteLinkURL.isEmpty()) 230 229 context |= WEBKIT_HIT_TEST_RESULT_CONTEXT_LINK; 231 230 232 const String& imageURL = hitTestResult->absoluteImageURL(); 233 if (!imageURL.isEmpty()) 231 if (!hitTestResult.absoluteImageURL.isEmpty()) 234 232 context |= WEBKIT_HIT_TEST_RESULT_CONTEXT_IMAGE; 235 233 236 const String& mediaURL = hitTestResult->absoluteMediaURL(); 237 if (!mediaURL.isEmpty()) 234 if (!hitTestResult.absoluteMediaURL.isEmpty()) 238 235 context |= WEBKIT_HIT_TEST_RESULT_CONTEXT_MEDIA; 239 236 240 if (hitTestResult ->isContentEditable())237 if (hitTestResult.isContentEditable) 241 238 context |= WEBKIT_HIT_TEST_RESULT_CONTEXT_EDITABLE; 242 239 243 if (hitTestResult ->isScrollbar())240 if (hitTestResult.isScrollbar) 244 241 context |= WEBKIT_HIT_TEST_RESULT_CONTEXT_SCROLLBAR; 245 242 246 const String& linkTitle = hitTestResult->linkTitle();247 const String& linkLabel = hitTestResult->linkLabel();248 249 243 return WEBKIT_HIT_TEST_RESULT(g_object_new(WEBKIT_TYPE_HIT_TEST_RESULT, 250 251 "link-uri", !linkURL.isEmpty() ? linkURL.utf8().data() : 0,252 "image-uri", !imageURL.isEmpty() ? imageURL.utf8().data() : 0,253 "media-uri", !mediaURL.isEmpty() ? mediaURL.utf8().data() : 0,254 "link-title", !linkTitle.isEmpty() ? linkTitle.utf8().data() : 0,255 "link-label", !linkLabel.isEmpty() ? linkLabel.utf8().data() : 0,256 NULL));244 "context", context, 245 "link-uri", context & WEBKIT_HIT_TEST_RESULT_CONTEXT_LINK ? hitTestResult.absoluteLinkURL.utf8().data() : nullptr, 246 "image-uri", context & WEBKIT_HIT_TEST_RESULT_CONTEXT_IMAGE ? hitTestResult.absoluteImageURL.utf8().data() : nullptr, 247 "media-uri", context & WEBKIT_HIT_TEST_RESULT_CONTEXT_MEDIA ? hitTestResult.absoluteMediaURL.utf8().data() : nullptr, 248 "link-title", !hitTestResult.linkTitle.isEmpty() ? hitTestResult.linkTitle.utf8().data() : nullptr, 249 "link-label", !hitTestResult.linkLabel.isEmpty() ? hitTestResult.linkLabel.utf8().data() : nullptr, 250 nullptr)); 257 251 } 258 252 … … 262 256 } 263 257 264 bool webkitHitTestResultCompare(WebKitHitTestResult* hitTestResult, WebHitTestResult*webHitTestResult)258 bool webkitHitTestResultCompare(WebKitHitTestResult* hitTestResult, const WebHitTestResult::Data& webHitTestResult) 265 259 { 266 260 WebKitHitTestResultPrivate* priv = hitTestResult->priv; 267 return webHitTestResult ->isContentEditable()== webkit_hit_test_result_context_is_editable(hitTestResult)268 && webHitTestResult ->isScrollbar()== webkit_hit_test_result_context_is_scrollbar(hitTestResult)269 && stringIsEqualToCString(webHitTestResult ->absoluteLinkURL(), priv->linkURI)270 && stringIsEqualToCString(webHitTestResult ->linkTitle(), priv->linkTitle)271 && stringIsEqualToCString(webHitTestResult ->linkLabel(), priv->linkLabel)272 && stringIsEqualToCString(webHitTestResult ->absoluteImageURL(), priv->imageURI)273 && stringIsEqualToCString(webHitTestResult ->absoluteMediaURL(), priv->mediaURI);261 return webHitTestResult.isContentEditable == webkit_hit_test_result_context_is_editable(hitTestResult) 262 && webHitTestResult.isScrollbar == webkit_hit_test_result_context_is_scrollbar(hitTestResult) 263 && stringIsEqualToCString(webHitTestResult.absoluteLinkURL, priv->linkURI) 264 && stringIsEqualToCString(webHitTestResult.linkTitle, priv->linkTitle) 265 && stringIsEqualToCString(webHitTestResult.linkLabel, priv->linkLabel) 266 && stringIsEqualToCString(webHitTestResult.absoluteImageURL, priv->imageURI) 267 && stringIsEqualToCString(webHitTestResult.absoluteMediaURL, priv->mediaURI); 274 268 } 275 269 -
trunk/Source/WebKit2/UIProcess/API/gtk/WebKitHitTestResultPrivate.h
r131760 r170702 24 24 #include "WebKitPrivate.h" 25 25 26 WebKitHitTestResult* webkitHitTestResultCreate( WebKit::WebHitTestResult*);27 bool webkitHitTestResultCompare(WebKitHitTestResult*, WebKit::WebHitTestResult*);26 WebKitHitTestResult* webkitHitTestResultCreate(const WebKit::WebHitTestResult::Data&); 27 bool webkitHitTestResultCompare(WebKitHitTestResult*, const WebKit::WebHitTestResult::Data&); 28 28 29 29 #endif // WebKitHitTestResultPrivate_h -
trunk/Source/WebKit2/UIProcess/API/gtk/WebKitNavigationPolicyDecision.h
r150130 r170702 27 27 #include <glib-object.h> 28 28 #include <webkit2/WebKitDefines.h> 29 #include <webkit2/WebKitNavigationAction.h> 29 30 #include <webkit2/WebKitPolicyDecision.h> 30 31 #include <webkit2/WebKitURIRequest.h> 31 32 32 33 G_BEGIN_DECLS 33 34 /**35 * WebKitNavigationType:36 * @WEBKIT_NAVIGATION_TYPE_LINK_CLICKED: The navigation was triggered by clicking a link.37 * @WEBKIT_NAVIGATION_TYPE_FORM_SUBMITTED: The navigation was triggered by submitting a form.38 * @WEBKIT_NAVIGATION_TYPE_BACK_FORWARD: The navigation was triggered by navigating forward or backward.39 * @WEBKIT_NAVIGATION_TYPE_RELOAD: The navigation was triggered by reloading.40 * @WEBKIT_NAVIGATION_TYPE_FORM_RESUBMITTED: The navigation was triggered by resubmitting a form.41 * @WEBKIT_NAVIGATION_TYPE_OTHER: The navigation was triggered by some other action.42 *43 * Enum values used to denote the various navigation types.44 */45 typedef enum {46 WEBKIT_NAVIGATION_TYPE_LINK_CLICKED,47 WEBKIT_NAVIGATION_TYPE_FORM_SUBMITTED,48 WEBKIT_NAVIGATION_TYPE_BACK_FORWARD,49 WEBKIT_NAVIGATION_TYPE_RELOAD,50 WEBKIT_NAVIGATION_TYPE_FORM_RESUBMITTED,51 WEBKIT_NAVIGATION_TYPE_OTHER,52 } WebKitNavigationType;53 34 54 35 #define WEBKIT_TYPE_NAVIGATION_POLICY_DECISION (webkit_navigation_policy_decision_get_type()) -
trunk/Source/WebKit2/UIProcess/API/gtk/WebKitPrivate.cpp
r164597 r170702 22 22 23 23 #include "ErrorsGtk.h" 24 #include "WebEvent.h" 24 25 #include "WebKitError.h" 25 26 #include <gdk/gdk.h> … … 37 38 modifiers |= GDK_META_MASK; 38 39 return modifiers; 40 } 41 42 unsigned toGdkModifiers(WebKit::WebEvent::Modifiers wkModifiers) 43 { 44 unsigned modifiers = 0; 45 if (wkModifiers & WebKit::WebEvent::Modifiers::ShiftKey) 46 modifiers |= GDK_SHIFT_MASK; 47 if (wkModifiers & WebKit::WebEvent::Modifiers::ControlKey) 48 modifiers |= GDK_CONTROL_MASK; 49 if (wkModifiers & WebKit::WebEvent::Modifiers::AltKey) 50 modifiers |= GDK_MOD1_MASK; 51 if (wkModifiers & WebKit::WebEvent::Modifiers::MetaKey) 52 modifiers |= GDK_META_MASK; 53 return modifiers; 54 } 55 56 WebKitNavigationType toWebKitNavigationType(WebCore::NavigationType type) 57 { 58 switch (type) { 59 case WebCore::NavigationType::NavigationTypeLinkClicked: 60 return WEBKIT_NAVIGATION_TYPE_LINK_CLICKED; 61 case WebCore::NavigationType::NavigationTypeFormSubmitted: 62 return WEBKIT_NAVIGATION_TYPE_FORM_SUBMITTED; 63 case WebCore::NavigationType::NavigationTypeBackForward: 64 return WEBKIT_NAVIGATION_TYPE_BACK_FORWARD; 65 case WebCore::NavigationType::NavigationTypeReload: 66 return WEBKIT_NAVIGATION_TYPE_RELOAD; 67 case WebCore::NavigationType::NavigationTypeFormResubmitted: 68 return WEBKIT_NAVIGATION_TYPE_FORM_RESUBMITTED; 69 case WebCore::NavigationType::NavigationTypeOther: 70 return WEBKIT_NAVIGATION_TYPE_OTHER; 71 default: 72 ASSERT_NOT_REACHED(); 73 return WEBKIT_NAVIGATION_TYPE_OTHER; 74 } 75 } 76 77 unsigned toWebKitMouseButton(WebKit::WebMouseEvent::Button button) 78 { 79 switch (button) { 80 case WebKit::WebMouseEvent::Button::NoButton: 81 return 0; 82 case WebKit::WebMouseEvent::Button::LeftButton: 83 return 1; 84 case WebKit::WebMouseEvent::Button::MiddleButton: 85 return 2; 86 case WebKit::WebMouseEvent::Button::RightButton: 87 return 3; 88 } 89 ASSERT_NOT_REACHED(); 90 return 0; 39 91 } 40 92 -
trunk/Source/WebKit2/UIProcess/API/gtk/WebKitPrivate.h
r168961 r170702 27 27 #define WebKitPrivate_h 28 28 29 #include "WebKitNavigationAction.h" 29 30 #include <WebKit/WKAPICast.h> 30 31 #include <WebKit/WKDownload.h> … … 116 117 unsigned wkEventModifiersToGdkModifiers(WKEventModifiers); 117 118 unsigned wkEventMouseButtonToWebKitMouseButton(WKEventMouseButton); 119 unsigned toGdkModifiers(WebKit::WebEvent::Modifiers); 120 WebKitNavigationType toWebKitNavigationType(WebCore::NavigationType); 121 unsigned toWebKitMouseButton(WebKit::WebMouseEvent::Button); 118 122 unsigned toWebKitError(unsigned webCoreError); 119 123 unsigned toWebCoreError(unsigned webKitError); -
trunk/Source/WebKit2/UIProcess/API/gtk/WebKitUIClient.cpp
r165760 r170702 21 21 #include "WebKitUIClient.h" 22 22 23 #include "APIUIClient.h" 23 24 #include "WebKitFileChooserRequestPrivate.h" 24 25 #include "WebKitGeolocationPermissionRequestPrivate.h" 26 #include "WebKitNavigationActionPrivate.h" 25 27 #include "WebKitPrivate.h" 28 #include "WebKitURIRequestPrivate.h" 26 29 #include "WebKitWebViewBasePrivate.h" 27 30 #include "WebKitWebViewPrivate.h" … … 33 36 using namespace WebKit; 34 37 35 static WKPageRef createNewPage(WKPageRef, WKURLRequestRef, WKDictionaryRef wkWindowFeatures, WKEventModifiers, WKEventMouseButton, const void* clientInfo) 36 { 37 return static_cast<WKPageRef>(toAPI(webkitWebViewCreateNewPage(WEBKIT_WEB_VIEW(clientInfo), toImpl(wkWindowFeatures)))); 38 } 38 class UIClient : public API::UIClient { 39 public: 40 explicit UIClient(WebKitWebView* webView) 41 : m_webView(webView) 42 { 43 } 39 44 40 static void showPage(WKPageRef, const void* clientInfo) 41 { 42 webkitWebViewReadyToShowPage(WEBKIT_WEB_VIEW(clientInfo)); 43 } 45 private: 46 virtual PassRefPtr<WebPageProxy> createNewPage(WebPageProxy*, WebFrameProxy*, const WebCore::ResourceRequest& resourceRequest, const WebCore::WindowFeatures& windowFeatures, const NavigationActionData& navigationActionData) override 47 { 48 GRefPtr<WebKitURIRequest> request = adoptGRef(webkitURIRequestCreateForResourceRequest(resourceRequest)); 49 WebKitNavigationAction navigationAction(request.get(), navigationActionData); 50 return webkitWebViewCreateNewPage(m_webView, windowFeatures, &navigationAction); 51 } 44 52 45 static void closePage(WKPageRef, const void* clientInfo) 46 {47 webkitWebViewClosePage(WEBKIT_WEB_VIEW(clientInfo));48 }53 virtual void showPage(WebPageProxy*) override 54 { 55 webkitWebViewReadyToShowPage(m_webView); 56 } 49 57 50 static void runJavaScriptAlert(WKPageRef, WKStringRef message, WKFrameRef, const void* clientInfo) 51 {52 webkitWebViewRunJavaScriptAlert(WEBKIT_WEB_VIEW(clientInfo), toImpl(message)->string().utf8());53 }58 virtual void close(WebPageProxy*) override 59 { 60 webkitWebViewClosePage(m_webView); 61 } 54 62 55 static bool runJavaScriptConfirm(WKPageRef, WKStringRef message, WKFrameRef, const void* clientInfo) 56 { 57 return webkitWebViewRunJavaScriptConfirm(WEBKIT_WEB_VIEW(clientInfo), toImpl(message)->string().utf8()); 58 } 63 virtual void runJavaScriptAlert(WebPageProxy*, const String& message, WebFrameProxy*, std::function<void ()> completionHandler) override 64 { 65 webkitWebViewRunJavaScriptAlert(m_webView, message.utf8()); 66 completionHandler(); 67 } 59 68 60 static WKStringRef runJavaScriptPrompt(WKPageRef, WKStringRef message, WKStringRef defaultValue, WKFrameRef, const void* clientInfo) 61 { 62 CString result = webkitWebViewRunJavaScriptPrompt(WEBKIT_WEB_VIEW(clientInfo), toImpl(message)->string().utf8(), 63 toImpl(defaultValue)->string().utf8()); 64 return WKStringCreateWithUTF8CString(result.data()); 65 } 69 virtual void runJavaScriptConfirm(WebPageProxy*, const String& message, WebFrameProxy*, std::function<void (bool)> completionHandler) override 70 { 71 completionHandler(webkitWebViewRunJavaScriptConfirm(m_webView, message.utf8())); 72 } 66 73 67 static bool toolbarsAreVisible(WKPageRef, const void* clientInfo) 68 { 69 WebKitWindowProperties* windowProperties = webkit_web_view_get_window_properties(WEBKIT_WEB_VIEW(clientInfo)); 70 return webkit_window_properties_get_toolbar_visible(windowProperties); 71 } 74 virtual void runJavaScriptPrompt(WebPageProxy*, const String& message, const String& defaultValue, WebFrameProxy*, std::function<void (const String&)> completionHandler) override 75 { 76 CString result = webkitWebViewRunJavaScriptPrompt(m_webView, message.utf8(), defaultValue.utf8()); 77 if (result.isNull()) { 78 completionHandler(String()); 79 return; 80 } 72 81 73 static void setToolbarsAreVisible(WKPageRef, bool toolbarsVisible, const void* clientInfo) 74 { 75 WebKitWindowProperties* windowProperties = webkit_web_view_get_window_properties(WEBKIT_WEB_VIEW(clientInfo)); 76 webkitWindowPropertiesSetToolbarVisible(windowProperties, toolbarsVisible); 77 } 82 completionHandler(String::fromUTF8(result.data())); 83 } 78 84 79 static bool menuBarIsVisible(WKPageRef, const void* clientInfo) 80 { 81 WebKitWindowProperties* windowProperties = webkit_web_view_get_window_properties(WEBKIT_WEB_VIEW(clientInfo)); 82 return webkit_window_properties_get_menubar_visible(windowProperties); 83 } 85 virtual void mouseDidMoveOverElement(WebPageProxy*, const WebHitTestResult::Data& data, WebEvent::Modifiers modifiers, API::Object*) override 86 { 87 webkitWebViewMouseTargetChanged(m_webView, data, toGdkModifiers(modifiers)); 88 } 84 89 85 static void setMenuBarIsVisible(WKPageRef, bool menuBarVisible, const void* clientInfo) 86 { 87 WebKitWindowProperties* windowProperties = webkit_web_view_get_window_properties(WEBKIT_WEB_VIEW(clientInfo)); 88 webkitWindowPropertiesSetMenubarVisible(windowProperties, menuBarVisible); 89 } 90 virtual bool toolbarsAreVisible(WebPageProxy*) override 91 { 92 return webkit_window_properties_get_toolbar_visible(webkit_web_view_get_window_properties(m_webView)); 93 } 90 94 91 static bool statusBarIsVisible(WKPageRef, const void* clientInfo) 92 { 93 WebKitWindowProperties* windowProperties = webkit_web_view_get_window_properties(WEBKIT_WEB_VIEW(clientInfo)); 94 return webkit_window_properties_get_statusbar_visible(windowProperties); 95 } 95 virtual void setToolbarsAreVisible(WebPageProxy*, bool visible) override 96 { 97 webkitWindowPropertiesSetToolbarVisible(webkit_web_view_get_window_properties(m_webView), visible); 98 } 96 99 97 static void setStatusBarIsVisible(WKPageRef, bool statusBarVisible, const void* clientInfo) 98 { 99 WebKitWindowProperties* windowProperties = webkit_web_view_get_window_properties(WEBKIT_WEB_VIEW(clientInfo)); 100 webkitWindowPropertiesSetStatusbarVisible(windowProperties, statusBarVisible); 101 } 100 virtual bool menuBarIsVisible(WebPageProxy*) override 101 { 102 return webkit_window_properties_get_menubar_visible(webkit_web_view_get_window_properties(m_webView)); 103 } 102 104 103 static bool isResizable(WKPageRef, const void* clientInfo) 104 { 105 WebKitWindowProperties* windowProperties = webkit_web_view_get_window_properties(WEBKIT_WEB_VIEW(clientInfo)); 106 return webkit_window_properties_get_resizable(windowProperties); 107 } 105 virtual void setMenuBarIsVisible(WebPageProxy*, bool visible) override 106 { 107 webkitWindowPropertiesSetToolbarVisible(webkit_web_view_get_window_properties(m_webView), visible); 108 } 108 109 109 static void setIsResizable(WKPageRef, bool resizable, const void* clientInfo) 110 { 111 WebKitWindowProperties* windowProperties = webkit_web_view_get_window_properties(WEBKIT_WEB_VIEW(clientInfo)); 112 webkitWindowPropertiesSetResizable(windowProperties, resizable); 113 } 110 virtual bool statusBarIsVisible(WebPageProxy*) override 111 { 112 return webkit_window_properties_get_statusbar_visible(webkit_web_view_get_window_properties(m_webView)); 113 } 114 114 115 static WKRect getWindowFrame(WKPageRef, const void* clientInfo) 116 { 117 GdkRectangle geometry = { 0, 0, 0, 0 }; 118 GtkWidget* window = gtk_widget_get_toplevel(GTK_WIDGET(clientInfo)); 119 if (WebCore::widgetIsOnscreenToplevelWindow(window) && gtk_widget_get_visible(window)) { 120 gtk_window_get_position(GTK_WINDOW(window), &geometry.x, &geometry.y); 121 gtk_window_get_size(GTK_WINDOW(window), &geometry.width, &geometry.height); 115 virtual void setStatusBarIsVisible(WebPageProxy*, bool visible) override 116 { 117 webkitWindowPropertiesSetStatusbarVisible(webkit_web_view_get_window_properties(m_webView), visible); 122 118 } 123 return WKRectMake(geometry.x, geometry.y, geometry.width, geometry.height);124 }125 119 126 static void setWindowFrame(WKPageRef, WKRect frame, const void* clientInfo) 127 { 128 WebKitWindowProperties* windowProperties = webkit_web_view_get_window_properties(WEBKIT_WEB_VIEW(clientInfo)); 129 GdkRectangle geometry = { static_cast<int>(frame.origin.x), static_cast<int>(frame.origin.y), 130 static_cast<int>(frame.size.width), static_cast<int>(frame.size.height) }; 131 webkitWindowPropertiesSetGeometry(windowProperties, &geometry); 132 } 120 virtual bool isResizable(WebPageProxy*) override 121 { 122 return webkit_window_properties_get_resizable(webkit_web_view_get_window_properties(m_webView)); 123 } 133 124 134 static void mouseDidMoveOverElement(WKPageRef, WKHitTestResultRef hitTestResult, WKEventModifiers modifiers, WKTypeRef /* userData */, const void* clientInfo) 135 {136 webkitWebViewMouseTargetChanged(WEBKIT_WEB_VIEW(clientInfo), toImpl(hitTestResult), wkEventModifiersToGdkModifiers(modifiers));137 }125 virtual void setIsResizable(WebPageProxy*, bool resizable) override 126 { 127 webkitWindowPropertiesSetResizable(webkit_web_view_get_window_properties(m_webView), resizable); 128 } 138 129 139 static void printFrame(WKPageRef page, WKFrameRef frame, const void*) 140 { 141 webkitWebViewPrintFrame(WEBKIT_WEB_VIEW(toImpl(page)->viewWidget()), toImpl(frame)); 142 } 130 virtual void setWindowFrame(WebPageProxy*, const WebCore::FloatRect& frame) override 131 { 132 GdkRectangle geometry = WebCore::IntRect(frame); 133 webkitWindowPropertiesSetGeometry(webkit_web_view_get_window_properties(m_webView), &geometry); 134 } 143 135 144 static void runOpenPanel(WKPageRef, WKFrameRef, WKOpenPanelParametersRef parameters, WKOpenPanelResultListenerRef listener, const void *clientInfo) 145 { 146 GRefPtr<WebKitFileChooserRequest> request = adoptGRef(webkitFileChooserRequestCreate(toImpl(parameters), toImpl(listener))); 147 webkitWebViewRunFileChooserRequest(WEBKIT_WEB_VIEW(clientInfo), request.get()); 148 } 136 virtual WebCore::FloatRect windowFrame(WebPageProxy*) override 137 { 138 GdkRectangle geometry = { 0, 0, 0, 0 }; 139 GtkWidget* window = gtk_widget_get_toplevel(GTK_WIDGET(m_webView)); 140 if (WebCore::widgetIsOnscreenToplevelWindow(window) && gtk_widget_get_visible(window)) { 141 gtk_window_get_position(GTK_WINDOW(window), &geometry.x, &geometry.y); 142 gtk_window_get_size(GTK_WINDOW(window), &geometry.width, &geometry.height); 143 } 144 return WebCore::FloatRect(geometry); 145 } 149 146 150 static void decidePolicyForGeolocationPermissionRequest(WKPageRef, WKFrameRef, WKSecurityOriginRef, WKGeolocationPermissionRequestRef request, const void* clientInfo) 151 { 152 GRefPtr<WebKitGeolocationPermissionRequest> geolocationPermissionRequest = adoptGRef(webkitGeolocationPermissionRequestCreate(toImpl(request))); 153 webkitWebViewMakePermissionRequest(WEBKIT_WEB_VIEW(clientInfo), WEBKIT_PERMISSION_REQUEST(geolocationPermissionRequest.get())); 154 } 147 virtual bool runOpenPanel(WebPageProxy*, WebFrameProxy*, WebOpenPanelParameters* parameters, WebOpenPanelResultListenerProxy* listener) override 148 { 149 GRefPtr<WebKitFileChooserRequest> request = adoptGRef(webkitFileChooserRequestCreate(parameters, listener)); 150 webkitWebViewRunFileChooserRequest(m_webView, request.get()); 151 return true; 152 } 155 153 156 static void runModal(WKPageRef, const void* clientInfo) 157 { 158 webkitWebViewRunAsModal(WEBKIT_WEB_VIEW(clientInfo)); 159 } 154 virtual bool decidePolicyForGeolocationPermissionRequest(WebPageProxy*, WebFrameProxy*, WebSecurityOrigin*, GeolocationPermissionRequestProxy* permissionRequest) override 155 { 156 GRefPtr<WebKitGeolocationPermissionRequest> geolocationPermissionRequest = adoptGRef(webkitGeolocationPermissionRequestCreate(permissionRequest)); 157 webkitWebViewMakePermissionRequest(m_webView, WEBKIT_PERMISSION_REQUEST(geolocationPermissionRequest.get())); 158 return true; 159 } 160 161 virtual void printFrame(WebPageProxy*, WebFrameProxy* frame) override 162 { 163 webkitWebViewPrintFrame(m_webView, frame); 164 } 165 166 virtual bool canRunModal() const override { return true; } 167 168 virtual void runModal(WebPageProxy*) override 169 { 170 webkitWebViewRunAsModal(m_webView); 171 } 172 173 WebKitWebView* m_webView; 174 }; 160 175 161 176 void attachUIClientToView(WebKitWebView* webView) 162 177 { 163 WKPageUIClientV2 wkUIClient = { 164 { 165 2, // version 166 webView, // clientInfo 167 }, 168 0, // createNewPage_deprecatedForUseWithV0 169 showPage, 170 closePage, 171 0, // takeFocus 172 0, // focus 173 0, // unfocus 174 runJavaScriptAlert, 175 runJavaScriptConfirm, 176 runJavaScriptPrompt, 177 0, // setStatusText 178 0, // mouseDidMoveOverElement_deprecatedForUseWithV0 179 0, // missingPluginButtonClicked 180 0, // didNotHandleKeyEvent 181 0, // didNotHandleWheelEvent 182 toolbarsAreVisible, 183 setToolbarsAreVisible, 184 menuBarIsVisible, 185 setMenuBarIsVisible, 186 statusBarIsVisible, 187 setStatusBarIsVisible, 188 isResizable, 189 setIsResizable, 190 getWindowFrame, 191 setWindowFrame, 192 0, // runBeforeUnloadConfirmPanel 193 0, // didDraw 194 0, // pageDidScroll 195 0, // exceededDatabaseQuota 196 runOpenPanel, 197 decidePolicyForGeolocationPermissionRequest, 198 0, // headerHeight 199 0, // footerHeight 200 0, // drawHeader 201 0, // drawFooter 202 printFrame, 203 runModal, 204 0, // didCompleteRubberBandForMainFrame 205 0, // saveDataToFileInDownloadsFolder 206 0, // shouldInterruptJavaScript 207 createNewPage, 208 mouseDidMoveOverElement, 209 0, // decidePolicyForNotificationPermissionRequest 210 0, // unavailablePluginButtonClicked 211 0, // showColorPicker 212 0, // hideColorPicker 213 0, // pluginLoadPolicy 214 }; 215 WKPageRef wkPage = toAPI(webkitWebViewBaseGetPage(WEBKIT_WEB_VIEW_BASE(webView))); 216 WKPageSetPageUIClient(wkPage, &wkUIClient.base); 178 WebPageProxy* page = webkitWebViewBaseGetPage(WEBKIT_WEB_VIEW_BASE(webView)); 179 page->setUIClient(std::make_unique<UIClient>(webView)); 217 180 } 218 181 -
trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp
r170048 r170702 218 218 } 219 219 220 static GtkWidget* webkitWebViewCreate(WebKitWebView* )221 { 222 return 0;220 static GtkWidget* webkitWebViewCreate(WebKitWebView*, WebKitNavigationAction*) 221 { 222 return nullptr; 223 223 } 224 224 … … 890 890 * WebKitWebView::create: 891 891 * @web_view: the #WebKitWebView on which the signal is emitted 892 * @navigation_action: a #WebKitNavigationAction 892 893 * 893 894 * Emitted when the creation of a new #WebKitWebView is requested. … … 895 896 * newly created #WebKitWebView. 896 897 * 898 * The #WebKitNavigationAction parameter contains information about the 899 * navigation action that triggered this signal. 900 * 897 901 * When using %WEBKIT_PROCESS_MODEL_MULTIPLE_SECONDARY_PROCESSES 898 902 * process model, the new #WebKitWebView should be related to 899 * @web_view to share the same web process, see webkit_web_view_new_with_related_view 903 * @web_view to share the same web process, see webkit_web_view_new_with_related_view() 900 904 * for more details. 901 905 * … … 906 910 * or %NULL to propagate the event further. 907 911 */ 908 signals[CREATE] = 909 g_signal_new("create", 910 G_TYPE_FROM_CLASS(webViewClass), 911 G_SIGNAL_RUN_LAST, 912 G_STRUCT_OFFSET(WebKitWebViewClass, create), 913 webkitWebViewAccumulatorObjectHandled, 0, 914 webkit_marshal_OBJECT__VOID, 915 GTK_TYPE_WIDGET, 0); 912 signals[CREATE] = g_signal_new( 913 "create", 914 G_TYPE_FROM_CLASS(webViewClass), 915 G_SIGNAL_RUN_LAST, 916 G_STRUCT_OFFSET(WebKitWebViewClass, create), 917 webkitWebViewAccumulatorObjectHandled, 0, 918 g_cclosure_marshal_generic, 919 GTK_TYPE_WIDGET, 1, 920 WEBKIT_TYPE_NAVIGATION_ACTION | G_SIGNAL_TYPE_STATIC_SCOPE); 916 921 917 922 /** … … 1602 1607 } 1603 1608 1604 WebPageProxy* webkitWebViewCreateNewPage(WebKitWebView* webView, ImmutableDictionary* windowFeatures)1609 WebPageProxy* webkitWebViewCreateNewPage(WebKitWebView* webView, const WindowFeatures& windowFeatures, WebKitNavigationAction* navigationAction) 1605 1610 { 1606 1611 WebKitWebView* newWebView; 1607 g_signal_emit(webView, signals[CREATE], 0, &newWebView);1612 g_signal_emit(webView, signals[CREATE], 0, navigationAction, &newWebView); 1608 1613 if (!newWebView) 1609 1614 return 0; … … 1675 1680 } 1676 1681 1677 void webkitWebViewMouseTargetChanged(WebKitWebView* webView, WebHitTestResult*hitTestResult, unsigned modifiers)1678 { 1679 webkitWebViewBaseSetTooltipArea(WEBKIT_WEB_VIEW_BASE(webView), hitTestResult ->elementBoundingBox());1682 void webkitWebViewMouseTargetChanged(WebKitWebView* webView, const WebHitTestResult::Data& hitTestResult, unsigned modifiers) 1683 { 1684 webkitWebViewBaseSetTooltipArea(WEBKIT_WEB_VIEW_BASE(webView), hitTestResult.elementBoundingBox); 1680 1685 1681 1686 WebKitWebViewPrivate* priv = webView->priv; … … 1829 1834 webkitWebViewCreateAndAppendInputMethodsMenuItem(webView, contextMenu.get()); 1830 1835 1831 GRefPtr<WebKitHitTestResult> hitTestResult = adoptGRef(webkitHitTestResultCreate(webHitTestResult)); 1836 // FIXME: we should use a custom ContextMenuClient at some point, that will receive a 1837 // const WebHitTestResult::Data& that we can use directly here. 1838 WebHitTestResult::Data data; 1839 data.absoluteImageURL = webHitTestResult->absoluteImageURL(); 1840 data.absoluteLinkURL = webHitTestResult->absoluteLinkURL(); 1841 data.absoluteMediaURL = webHitTestResult->absoluteMediaURL(); 1842 data.linkLabel = webHitTestResult->linkLabel(); 1843 data.linkTitle = webHitTestResult->linkTitle(); 1844 data.isContentEditable = webHitTestResult->isContentEditable(); 1845 data.elementBoundingBox = webHitTestResult->elementBoundingBox(); 1846 data.isScrollbar = webHitTestResult->isScrollbar(); 1847 1848 GRefPtr<WebKitHitTestResult> hitTestResult = adoptGRef(webkitHitTestResultCreate(data)); 1832 1849 GUniquePtr<GdkEvent> contextMenuEvent(webkitWebViewBaseTakeContextMenuEvent(webViewBase)); 1833 1850 -
trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.h
r169884 r170702 39 39 #include <webkit2/WebKitHitTestResult.h> 40 40 #include <webkit2/WebKitJavascriptResult.h> 41 #include <webkit2/WebKitNavigationAction.h> 41 42 #include <webkit2/WebKitPermissionRequest.h> 42 43 #include <webkit2/WebKitPolicyDecision.h> … … 195 196 GError *error); 196 197 197 GtkWidget *(* create) (WebKitWebView *web_view); 198 GtkWidget *(* create) (WebKitWebView *web_view, 199 WebKitNavigationAction *navigation_action); 198 200 void (* ready_to_show) (WebKitWebView *web_view); 199 201 void (* run_as_modal) (WebKitWebView *web_view); -
trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewPrivate.h
r159252 r170702 28 28 #define WebKitWebViewPrivate_h 29 29 30 #include "WebHitTestResult.h" 30 31 #include "WebImage.h" 31 32 #include "WebKitWebView.h" … … 38 39 void webkitWebViewSetTitle(WebKitWebView*, const CString&); 39 40 void webkitWebViewUpdateURI(WebKitWebView*); 40 WebKit::WebPageProxy* webkitWebViewCreateNewPage(WebKitWebView*, WebKit::ImmutableDictionary* windowFeatures);41 WebKit::WebPageProxy* webkitWebViewCreateNewPage(WebKitWebView*, const WebCore::WindowFeatures&, WebKitNavigationAction*); 41 42 void webkitWebViewReadyToShowPage(WebKitWebView*); 42 43 void webkitWebViewRunAsModal(WebKitWebView*); … … 47 48 void webkitWebViewMakePermissionRequest(WebKitWebView*, WebKitPermissionRequest*); 48 49 void webkitWebViewMakePolicyDecision(WebKitWebView*, WebKitPolicyDecisionType, WebKitPolicyDecision*); 49 void webkitWebViewMouseTargetChanged(WebKitWebView*, WebKit::WebHitTestResult*, unsigned modifiers);50 void webkitWebViewMouseTargetChanged(WebKitWebView*, const WebKit::WebHitTestResult::Data&, unsigned modifiers); 50 51 void webkitWebViewPrintFrame(WebKitWebView*, WebKit::WebFrameProxy*); 51 52 void webkitWebViewResourceLoadStarted(WebKitWebView*, WebKit::WebFrameProxy*, uint64_t resourceIdentifier, WebKitURIRequest*); -
trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWindowProperties.cpp
r160750 r170702 27 27 #include "WebKitWindowPropertiesPrivate.h" 28 28 #include <WebCore/IntRect.h> 29 #include <WebCore/WindowFeatures.h> 29 30 #include <glib/gi18n-lib.h> 30 31 … … 375 376 } 376 377 377 void webkitWindowPropertiesUpdateFromWebWindowFeatures(WebKitWindowProperties* windowProperties, ImmutableDictionary* features)378 void webkitWindowPropertiesUpdateFromWebWindowFeatures(WebKitWindowProperties* windowProperties, const WindowFeatures& windowFeatures) 378 379 { 379 380 GdkRectangle geometry = windowProperties->priv->geometry; 380 381 API::Double* doubleValue = static_cast<API::Double*>(features->get("x")); 382 if (doubleValue) 383 geometry.x = doubleValue->value(); 384 385 doubleValue = static_cast<API::Double*>(features->get("y")); 386 if (doubleValue) 387 geometry.y = doubleValue->value(); 388 389 doubleValue = static_cast<API::Double*>(features->get("width")); 390 if (doubleValue) 391 geometry.width = doubleValue->value(); 392 393 doubleValue = static_cast<API::Double*>(features->get("height")); 394 if (doubleValue) 395 geometry.height = doubleValue->value(); 381 if (windowFeatures.xSet) 382 geometry.x = windowFeatures.x; 383 if (windowFeatures.ySet) 384 geometry.y = windowFeatures.y; 385 if (windowFeatures.widthSet) 386 geometry.width = windowFeatures.width; 387 if (windowFeatures.heightSet) 388 geometry.height = windowFeatures.height; 396 389 webkitWindowPropertiesSetGeometry(windowProperties, &geometry); 397 390 398 API::Boolean* booleanValue = static_cast<API::Boolean*>(features->get("menuBarVisible")); 399 if (booleanValue) 400 webkitWindowPropertiesSetMenubarVisible(windowProperties, booleanValue->value()); 401 402 booleanValue = static_cast<API::Boolean*>(features->get("statusBarVisible")); 403 if (booleanValue) 404 webkitWindowPropertiesSetStatusbarVisible(windowProperties, booleanValue->value()); 405 406 booleanValue = static_cast<API::Boolean*>(features->get("toolBarVisible")); 407 if (booleanValue) 408 webkitWindowPropertiesSetToolbarVisible(windowProperties, booleanValue->value()); 409 410 booleanValue = static_cast<API::Boolean*>(features->get("locationBarVisible")); 411 if (booleanValue) 412 webkitWindowPropertiesSetLocationbarVisible(windowProperties, booleanValue->value()); 413 414 booleanValue = static_cast<API::Boolean*>(features->get("scrollbarsVisible")); 415 if (booleanValue) 416 webkitWindowPropertiesSetScrollbarsVisible(windowProperties, booleanValue->value()); 417 418 booleanValue = static_cast<API::Boolean*>(features->get("resizable")); 419 if (booleanValue) 420 webkitWindowPropertiesSetResizable(windowProperties, booleanValue->value()); 421 422 booleanValue = static_cast<API::Boolean*>(features->get("fullscreen")); 423 if (booleanValue) 424 webkitWindowPropertiesSetFullscreen(windowProperties, booleanValue->value()); 391 webkitWindowPropertiesSetMenubarVisible(windowProperties, windowFeatures.menuBarVisible); 392 webkitWindowPropertiesSetStatusbarVisible(windowProperties, windowFeatures.statusBarVisible); 393 webkitWindowPropertiesSetToolbarVisible(windowProperties, windowFeatures.toolBarVisible); 394 webkitWindowPropertiesSetLocationbarVisible(windowProperties, windowFeatures.locationBarVisible); 395 webkitWindowPropertiesSetScrollbarsVisible(windowProperties, windowFeatures.scrollbarsVisible); 396 webkitWindowPropertiesSetResizable(windowProperties, windowFeatures.resizable); 397 webkitWindowPropertiesSetFullscreen(windowProperties, windowFeatures.fullscreen); 425 398 } 426 399 -
trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWindowPropertiesPrivate.h
r131760 r170702 32 32 33 33 WebKitWindowProperties* webkitWindowPropertiesCreate(); 34 void webkitWindowPropertiesUpdateFromWebWindowFeatures(WebKitWindowProperties*, WebKit::ImmutableDictionary* features);34 void webkitWindowPropertiesUpdateFromWebWindowFeatures(WebKitWindowProperties*, const WebCore::WindowFeatures&); 35 35 void webkitWindowPropertiesSetGeometry(WebKitWindowProperties*, GdkRectangle*); 36 36 void webkitWindowPropertiesSetToolbarVisible(WebKitWindowProperties*, bool toolbarsVisible); -
trunk/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-docs.sgml
r157781 r170702 24 24 <xi:include href="xml/WebKitPermissionRequest.xml"/> 25 25 <xi:include href="xml/WebKitGeolocationPermissionRequest.xml"/> 26 <xi:include href="xml/WebKitNavigationAction.xml"/> 26 27 <xi:include href="xml/WebKitPolicyDecision.xml"/> 27 28 <xi:include href="xml/WebKitNavigationPolicyDecision.xml"/> -
trunk/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-sections.txt
r169884 r170702 522 522 523 523 <SECTION> 524 <FILE>WebKitNavigationAction</FILE> 525 WebKitNavigationAction 526 webkit_navigation_action_copy 527 webkit_navigation_action_free 528 webkit_navigation_action_get_navigation_type 529 webkit_navigation_action_get_mouse_button 530 webkit_navigation_action_get_modifiers 531 webkit_navigation_action_get_request 532 webkit_navigation_action_is_user_gesture 533 534 <SUBSECTION Standard> 535 WEBKIT_TYPE_NAVIGATION_ACTION 536 537 <SUBSECTION Private> 538 webkit_navigation_action_get_type 539 </SECTION> 540 541 <SECTION> 524 542 <FILE>WebKitPolicyDecision</FILE> 525 543 WebKitPolicyDecision -
trunk/Source/WebKit2/UIProcess/API/gtk/webkit2.h
r164940 r170702 50 50 #include <webkit2/WebKitJavascriptResult.h> 51 51 #include <webkit2/WebKitMimeInfo.h> 52 #include <webkit2/WebKitNavigationAction.h> 52 53 #include <webkit2/WebKitNavigationPolicyDecision.h> 53 54 #include <webkit2/WebKitPermissionRequest.h> -
trunk/Tools/ChangeLog
r170701 r170702 1 2014-07-02 Carlos Garcia Campos <cgarcia@igalia.com> 2 3 [GTK] WebKitWebView::create should receive information about the navigation action 4 https://bugs.webkit.org/show_bug.cgi?id=133680 5 6 Reviewed by Martin Robinson. 7 8 Add unit test to check the WebKitNavigationAction passed to 9 WebKitWebView::create callback. 10 11 * MiniBrowser/gtk/BrowserWindow.c: 12 (webViewCreate): Add WebKitNavigationAction parameter. 13 * TestWebKitAPI/Tests/WebKit2Gtk/TestMultiprocess.cpp: 14 * TestWebKitAPI/Tests/WebKit2Gtk/TestPrinting.cpp: 15 * TestWebKitAPI/Tests/WebKit2Gtk/TestUIClient.cpp: 16 (testWebViewCreateNavigationData): 17 (beforeAll): 18 * TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitPolicyClient.cpp: 19 (createCallback): 20 1 21 2014-07-02 Carlos Garcia Campos <cgarcia@igalia.com> 2 22 -
trunk/Tools/MiniBrowser/gtk/BrowserWindow.c
r166239 r170702 349 349 } 350 350 351 static GtkWidget *webViewCreate(WebKitWebView *webView, BrowserWindow *window)351 static GtkWidget *webViewCreate(WebKitWebView *webView, WebKitNavigationAction *navigation, BrowserWindow *window) 352 352 { 353 353 WebKitWebView *newWebView = WEBKIT_WEB_VIEW(webkit_web_view_new_with_related_view(webView)); -
trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestMultiprocess.cpp
r169377 r170702 139 139 }; 140 140 141 static GtkWidget* viewCreateCallback(WebKitWebView* webView, UIClientMultiprocessTest* test)141 static GtkWidget* viewCreateCallback(WebKitWebView* webView, WebKitNavigationAction*, UIClientMultiprocessTest* test) 142 142 { 143 143 return test->viewCreate(webView); -
trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestPrinting.cpp
r162599 r170702 195 195 MAKE_GLIB_TEST_FIXTURE(CloseAfterPrintTest); 196 196 197 static GtkWidget* webViewCreate(WebKitWebView* webView, CloseAfterPrintTest* test)197 static GtkWidget* webViewCreate(WebKitWebView* webView, WebKitNavigationAction*, CloseAfterPrintTest* test) 198 198 { 199 199 return test->createWebView(); -
trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestUIClient.cpp
r162599 r170702 118 118 } 119 119 120 static GtkWidget* viewCreateCallback(WebKitWebView* webView, UIClientTest* test)121 { 122 return test->viewCreate(webView );120 static GtkWidget* viewCreateCallback(WebKitWebView* webView, WebKitNavigationAction* navigation, UIClientTest* test) 121 { 122 return test->viewCreate(webView, navigation); 123 123 } 124 124 … … 241 241 } 242 242 243 virtual GtkWidget* viewCreate(WebKitWebView* webView )243 virtual GtkWidget* viewCreate(WebKitWebView* webView, WebKitNavigationAction* navigation) 244 244 { 245 245 g_assert(webView == m_webView); 246 g_assert(navigation); 246 247 247 248 GtkWidget* newWebView = webkit_web_view_new_with_context(webkit_web_view_get_context(webView)); … … 306 307 } 307 308 309 class CreateNavigationDataTest: public UIClientTest { 310 public: 311 MAKE_GLIB_TEST_FIXTURE(CreateNavigationDataTest); 312 313 CreateNavigationDataTest() 314 : m_navigation(nullptr) 315 { 316 } 317 318 ~CreateNavigationDataTest() 319 { 320 clearNavigation(); 321 } 322 323 void clearNavigation() 324 { 325 if (m_navigation) 326 webkit_navigation_action_free(m_navigation); 327 m_navigation = nullptr; 328 } 329 330 GtkWidget* viewCreate(WebKitWebView* webView, WebKitNavigationAction* navigation) 331 { 332 g_assert(navigation); 333 g_assert(!m_navigation); 334 m_navigation = webkit_navigation_action_copy(navigation); 335 g_main_loop_quit(m_mainLoop); 336 return nullptr; 337 } 338 339 void loadHTML(const char* html) 340 { 341 clearNavigation(); 342 WebViewTest::loadHtml(html, nullptr); 343 } 344 345 void clickAndWaitUntilMainLoopFinishes(int x, int y) 346 { 347 clearNavigation(); 348 clickMouseButton(x, y, 1); 349 g_main_loop_run(m_mainLoop); 350 } 351 352 WebKitNavigationAction* m_navigation; 353 }; 354 355 static void testWebViewCreateNavigationData(CreateNavigationDataTest* test, gconstpointer) 356 { 357 test->showInWindowAndWaitUntilMapped(); 358 359 test->loadHTML( 360 "<html><body>" 361 "<input style=\"position:absolute; left:0; top:0; margin:0; padding:0\" type=\"button\" value=\"click to show a popup\" onclick=\"window.open('data:foo');\"/>" 362 "<a style=\"position:absolute; left:20; top:20;\" href=\"data:bar\" target=\"_blank\">popup link</a>" 363 "</body></html>"); 364 test->waitUntilLoadFinished(); 365 366 // Click on a button. 367 test->clickAndWaitUntilMainLoopFinishes(5, 5); 368 g_assert_cmpstr(webkit_uri_request_get_uri(webkit_navigation_action_get_request(test->m_navigation)), ==, "data:foo"); 369 g_assert_cmpuint(webkit_navigation_action_get_navigation_type(test->m_navigation), ==, WEBKIT_NAVIGATION_TYPE_OTHER); 370 // FIXME: This should be button 1. 371 g_assert_cmpuint(webkit_navigation_action_get_mouse_button(test->m_navigation), ==, 0); 372 g_assert_cmpuint(webkit_navigation_action_get_modifiers(test->m_navigation), ==, 0); 373 g_assert(webkit_navigation_action_is_user_gesture(test->m_navigation)); 374 375 // Click on a link. 376 test->clickAndWaitUntilMainLoopFinishes(21, 21); 377 g_assert_cmpstr(webkit_uri_request_get_uri(webkit_navigation_action_get_request(test->m_navigation)), ==, "data:bar"); 378 g_assert_cmpuint(webkit_navigation_action_get_navigation_type(test->m_navigation), ==, WEBKIT_NAVIGATION_TYPE_LINK_CLICKED); 379 g_assert_cmpuint(webkit_navigation_action_get_mouse_button(test->m_navigation), ==, 1); 380 g_assert_cmpuint(webkit_navigation_action_get_modifiers(test->m_navigation), ==, 0); 381 g_assert(webkit_navigation_action_is_user_gesture(test->m_navigation)); 382 383 // No user interaction. 384 test->loadHTML("<html><body onLoad=\"window.open();\"></html>"); 385 test->waitUntilMainLoopFinishes(); 386 387 g_assert_cmpstr(webkit_uri_request_get_uri(webkit_navigation_action_get_request(test->m_navigation)), ==, ""); 388 g_assert_cmpuint(webkit_navigation_action_get_navigation_type(test->m_navigation), ==, WEBKIT_NAVIGATION_TYPE_OTHER); 389 g_assert_cmpuint(webkit_navigation_action_get_mouse_button(test->m_navigation), ==, 0); 390 g_assert_cmpuint(webkit_navigation_action_get_modifiers(test->m_navigation), ==, 0); 391 g_assert(!webkit_navigation_action_is_user_gesture(test->m_navigation)); 392 } 393 308 394 static gboolean checkMimeTypeForFilter(GtkFileFilter* filter, const gchar* mimeType) 309 395 { … … 324 410 } 325 411 326 GtkWidget* viewCreate(WebKitWebView* webView )412 GtkWidget* viewCreate(WebKitWebView* webView, WebKitNavigationAction* navigation) 327 413 { 328 414 g_assert(webView == m_webView); 329 415 330 GtkWidget* newWebView = UIClientTest::viewCreate(webView );416 GtkWidget* newWebView = UIClientTest::viewCreate(webView, navigation); 331 417 g_signal_connect(newWebView, "run-as-modal", G_CALLBACK(dialogRunAsModalCallback), this); 332 418 return newWebView; … … 666 752 { 667 753 UIClientTest::add("WebKitWebView", "create-ready-close", testWebViewCreateReadyClose); 754 CreateNavigationDataTest::add("WebKitWebView", "create-navigation-data", testWebViewCreateNavigationData); 668 755 ModalDialogsTest::add("WebKitWebView", "allow-modal-dialogs", testWebViewAllowModalDialogs); 669 756 ModalDialogsTest::add("WebKitWebView", "disallow-modal-dialogs", testWebViewDisallowModalDialogs); -
trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitPolicyClient.cpp
r161366 r170702 192 192 }; 193 193 194 static WebKitWebView* createCallback(WebKitWebView* webView, CreateCallbackData* data)194 static WebKitWebView* createCallback(WebKitWebView* webView, WebKitNavigationAction*, CreateCallbackData* data) 195 195 { 196 196 data->triedToOpenWindow = true;
Note: See TracChangeset
for help on using the changeset viewer.