Changeset 170702 in webkit


Ignore:
Timestamp:
Jul 2, 2014 12:19:46 AM (10 years ago)
Author:
Carlos Garcia Campos
Message:

[GTK] WebKitWebView::create should receive information about the navigation action
https://bugs.webkit.org/show_bug.cgi?id=133680

Reviewed by Martin Robinson.

Source/WebKit2:
Add WebKitNavigationAction boxed type representing a navigation
action to be passed as parameter of WebKitWebView::create
signal. In the future it could be also for the
WebKitNavigationPolicyDecision class. The class contains
information about a navigation action like the navigation type,
the request, the mouse button and key modifiers and whether it was
started by a user gesture. This information is needed to be able
to implement a proper popup blocker. Since all that information is
not provided by the C API, we have switched the UI client to use a
custom client derived from API::UIClient. This also avoids a lot
of toAPI -> toImpl unneeded conversions.

  • PlatformGTK.cmake: Add new files to compilation.
  • UIProcess/API/gtk/WebKitHitTestResult.cpp:

(webkitHitTestResultCreate): Use a WebHitTestResult::Data const
reference instead of a pointer to a WebHitTestResult.
(webkitHitTestResultCompare): Ditto.

  • UIProcess/API/gtk/WebKitHitTestResultPrivate.h:
  • UIProcess/API/gtk/WebKitNavigationAction.cpp: Added.

(webkitNavigationActionCreate): Create a WebKitNavigationAction
for the given ResourceRequest and NavigationActionData.
(webkit_navigation_action_copy):
(webkit_navigation_action_free):
(webkit_navigation_action_get_navigation_type):
(webkit_navigation_action_get_mouse_button):
(webkit_navigation_action_get_modifiers):
(webkit_navigation_action_get_request):
(webkit_navigation_action_is_user_gesture):

  • UIProcess/API/gtk/WebKitNavigationAction.h: Added.
  • UIProcess/API/gtk/WebKitNavigationActionPrivate.h: Added.
  • UIProcess/API/gtk/WebKitNavigationPolicyDecision.h:
  • UIProcess/API/gtk/WebKitPrivate.cpp:

(toGdkModifiers):
(toWebKitNavigationType):
(toWebKitMouseButton):

  • UIProcess/API/gtk/WebKitPrivate.h:
  • UIProcess/API/gtk/WebKitUIClient.cpp:

(UIClient::UIClient): Implement the UIClient using a custom class.
(attachUIClientToView): Set the UIClient directly to the WebPageProxy.
(createNewPage): Deleted.
(showPage): Deleted.
(closePage): Deleted.
(runJavaScriptAlert): Deleted.
(runJavaScriptConfirm): Deleted.
(runJavaScriptPrompt): Deleted.
(toolbarsAreVisible): Deleted.
(setToolbarsAreVisible): Deleted.
(menuBarIsVisible): Deleted.
(setMenuBarIsVisible): Deleted.
(statusBarIsVisible): Deleted.
(setStatusBarIsVisible): Deleted.
(isResizable): Deleted.
(setIsResizable): Deleted.
(getWindowFrame): Deleted.
(setWindowFrame): Deleted.
(mouseDidMoveOverElement): Deleted.
(printFrame): Deleted.
(runOpenPanel): Deleted.
(decidePolicyForGeolocationPermissionRequest): Deleted.
(runModal): Deleted.

  • UIProcess/API/gtk/WebKitWebView.cpp:

(webkitWebViewCreate): Add WebKitNavigationAction parameter.
(webkit_web_view_class_init): Add WebKitNavigationAction paramter
to CREATE signal.
(webkitWebViewCreateNewPage): Add WebKitNavigationAction parameter
and pass it to the signal callbacks.
(webkitWebViewMouseTargetChanged): Use a WebHitTestResult::Data
const reference.
(webkitWebViewPopulateContextMenu): Ditto.

  • UIProcess/API/gtk/WebKitWebView.h:
  • UIProcess/API/gtk/WebKitWebViewPrivate.h:
  • UIProcess/API/gtk/WebKitWindowProperties.cpp:

(webkitWindowPropertiesUpdateFromWebWindowFeatures): Use a
WebCore::WindowFeatures const reference.

  • UIProcess/API/gtk/WebKitWindowPropertiesPrivate.h:
  • UIProcess/API/gtk/docs/webkit2gtk-docs.sgml: Add new section.
  • UIProcess/API/gtk/docs/webkit2gtk-sections.txt: Add new symbols.
  • UIProcess/API/gtk/webkit2.h: Include WebKitNavigationAction.h.

Tools:
Add unit test to check the WebKitNavigationAction passed to
WebKitWebView::create callback.

  • MiniBrowser/gtk/BrowserWindow.c:

(webViewCreate): Add WebKitNavigationAction parameter.

  • TestWebKitAPI/Tests/WebKit2Gtk/TestMultiprocess.cpp:
  • TestWebKitAPI/Tests/WebKit2Gtk/TestPrinting.cpp:
  • TestWebKitAPI/Tests/WebKit2Gtk/TestUIClient.cpp:

(testWebViewCreateNavigationData):
(beforeAll):

  • TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitPolicyClient.cpp:

(createCallback):

Location:
trunk
Files:
3 added
22 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r170696 r170702  
     12014-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
    1872014-07-01  KwangHyuk Kim  <hyuki.kim@samsung.com>
    288
  • trunk/Source/WebKit2/PlatformGTK.cmake

    r169446 r170702  
    163163    UIProcess/API/gtk/WebKitMimeInfo.h
    164164    UIProcess/API/gtk/WebKitMimeInfoPrivate.h
     165    UIProcess/API/gtk/WebKitNavigationAction.cpp
     166    UIProcess/API/gtk/WebKitNavigationAction.h
     167    UIProcess/API/gtk/WebKitNavigationActionPrivate.h
    165168    UIProcess/API/gtk/WebKitNavigationPolicyDecision.cpp
    166169    UIProcess/API/gtk/WebKitNavigationPolicyDecision.h
     
    338341    ${WEBKIT2_DIR}/UIProcess/API/gtk/WebKitJavascriptResult.h
    339342    ${WEBKIT2_DIR}/UIProcess/API/gtk/WebKitMimeInfo.h
     343    ${WEBKIT2_DIR}/UIProcess/API/gtk/WebKitNavigationAction.h
    340344    ${WEBKIT2_DIR}/UIProcess/API/gtk/WebKitNavigationPolicyDecision.h
    341345    ${WEBKIT2_DIR}/UIProcess/API/gtk/WebKitPermissionRequest.h
  • trunk/Source/WebKit2/UIProcess/API/gtk/WebKitHitTestResult.cpp

    r137192 r170702  
    222222}
    223223
    224 WebKitHitTestResult* webkitHitTestResultCreate(WebHitTestResult* hitTestResult)
     224WebKitHitTestResult* webkitHitTestResultCreate(const WebHitTestResult::Data& hitTestResult)
    225225{
    226226    unsigned context = WEBKIT_HIT_TEST_RESULT_CONTEXT_DOCUMENT;
    227227
    228     const String& linkURL = hitTestResult->absoluteLinkURL();
    229     if (!linkURL.isEmpty())
     228    if (!hitTestResult.absoluteLinkURL.isEmpty())
    230229        context |= WEBKIT_HIT_TEST_RESULT_CONTEXT_LINK;
    231230
    232     const String& imageURL = hitTestResult->absoluteImageURL();
    233     if (!imageURL.isEmpty())
     231    if (!hitTestResult.absoluteImageURL.isEmpty())
    234232        context |= WEBKIT_HIT_TEST_RESULT_CONTEXT_IMAGE;
    235233
    236     const String& mediaURL = hitTestResult->absoluteMediaURL();
    237     if (!mediaURL.isEmpty())
     234    if (!hitTestResult.absoluteMediaURL.isEmpty())
    238235        context |= WEBKIT_HIT_TEST_RESULT_CONTEXT_MEDIA;
    239236
    240     if (hitTestResult->isContentEditable())
     237    if (hitTestResult.isContentEditable)
    241238        context |= WEBKIT_HIT_TEST_RESULT_CONTEXT_EDITABLE;
    242239
    243     if (hitTestResult->isScrollbar())
     240    if (hitTestResult.isScrollbar)
    244241        context |= WEBKIT_HIT_TEST_RESULT_CONTEXT_SCROLLBAR;
    245242
    246     const String& linkTitle = hitTestResult->linkTitle();
    247     const String& linkLabel = hitTestResult->linkLabel();
    248 
    249243    return WEBKIT_HIT_TEST_RESULT(g_object_new(WEBKIT_TYPE_HIT_TEST_RESULT,
    250                                                "context", context,
    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));
    257251}
    258252
     
    262256}
    263257
    264 bool webkitHitTestResultCompare(WebKitHitTestResult* hitTestResult, WebHitTestResult* webHitTestResult)
     258bool webkitHitTestResultCompare(WebKitHitTestResult* hitTestResult, const WebHitTestResult::Data& webHitTestResult)
    265259{
    266260    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);
    274268}
    275269
  • trunk/Source/WebKit2/UIProcess/API/gtk/WebKitHitTestResultPrivate.h

    r131760 r170702  
    2424#include "WebKitPrivate.h"
    2525
    26 WebKitHitTestResult* webkitHitTestResultCreate(WebKit::WebHitTestResult*);
    27 bool webkitHitTestResultCompare(WebKitHitTestResult*, WebKit::WebHitTestResult*);
     26WebKitHitTestResult* webkitHitTestResultCreate(const WebKit::WebHitTestResult::Data&);
     27bool webkitHitTestResultCompare(WebKitHitTestResult*, const WebKit::WebHitTestResult::Data&);
    2828
    2929#endif // WebKitHitTestResultPrivate_h
  • trunk/Source/WebKit2/UIProcess/API/gtk/WebKitNavigationPolicyDecision.h

    r150130 r170702  
    2727#include <glib-object.h>
    2828#include <webkit2/WebKitDefines.h>
     29#include <webkit2/WebKitNavigationAction.h>
    2930#include <webkit2/WebKitPolicyDecision.h>
    3031#include <webkit2/WebKitURIRequest.h>
    3132
    3233G_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;
    5334
    5435#define WEBKIT_TYPE_NAVIGATION_POLICY_DECISION            (webkit_navigation_policy_decision_get_type())
  • trunk/Source/WebKit2/UIProcess/API/gtk/WebKitPrivate.cpp

    r164597 r170702  
    2222
    2323#include "ErrorsGtk.h"
     24#include "WebEvent.h"
    2425#include "WebKitError.h"
    2526#include <gdk/gdk.h>
     
    3738        modifiers |= GDK_META_MASK;
    3839    return modifiers;
     40}
     41
     42unsigned 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
     56WebKitNavigationType 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
     77unsigned 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;
    3991}
    4092
  • trunk/Source/WebKit2/UIProcess/API/gtk/WebKitPrivate.h

    r168961 r170702  
    2727#define WebKitPrivate_h
    2828
     29#include "WebKitNavigationAction.h"
    2930#include <WebKit/WKAPICast.h>
    3031#include <WebKit/WKDownload.h>
     
    116117unsigned wkEventModifiersToGdkModifiers(WKEventModifiers);
    117118unsigned wkEventMouseButtonToWebKitMouseButton(WKEventMouseButton);
     119unsigned toGdkModifiers(WebKit::WebEvent::Modifiers);
     120WebKitNavigationType toWebKitNavigationType(WebCore::NavigationType);
     121unsigned toWebKitMouseButton(WebKit::WebMouseEvent::Button);
    118122unsigned toWebKitError(unsigned webCoreError);
    119123unsigned toWebCoreError(unsigned webKitError);
  • trunk/Source/WebKit2/UIProcess/API/gtk/WebKitUIClient.cpp

    r165760 r170702  
    2121#include "WebKitUIClient.h"
    2222
     23#include "APIUIClient.h"
    2324#include "WebKitFileChooserRequestPrivate.h"
    2425#include "WebKitGeolocationPermissionRequestPrivate.h"
     26#include "WebKitNavigationActionPrivate.h"
    2527#include "WebKitPrivate.h"
     28#include "WebKitURIRequestPrivate.h"
    2629#include "WebKitWebViewBasePrivate.h"
    2730#include "WebKitWebViewPrivate.h"
     
    3336using namespace WebKit;
    3437
    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 }
     38class UIClient : public API::UIClient {
     39public:
     40    explicit UIClient(WebKitWebView* webView)
     41        : m_webView(webView)
     42    {
     43    }
    3944
    40 static void showPage(WKPageRef, const void* clientInfo)
    41 {
    42     webkitWebViewReadyToShowPage(WEBKIT_WEB_VIEW(clientInfo));
    43 }
     45private:
     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    }
    4452
    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    }
    4957
    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    }
    5462
    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    }
    5968
    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    }
    6673
    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        }
    7281
    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    }
    7884
    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    }
    8489
    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    }
    9094
    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    }
    9699
    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    }
    102104
    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    }
    108109
    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    }
    114114
    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);
    122118    }
    123     return WKRectMake(geometry.x, geometry.y, geometry.width, geometry.height);
    124 }
    125119
    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    }
    133124
    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    }
    138129
    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    }
    143135
    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    }
    149146
    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    }
    155153
    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};
    160175
    161176void attachUIClientToView(WebKitWebView* webView)
    162177{
    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));
    217180}
    218181
  • trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp

    r170048 r170702  
    218218}
    219219
    220 static GtkWidget* webkitWebViewCreate(WebKitWebView*)
    221 {
    222     return 0;
     220static GtkWidget* webkitWebViewCreate(WebKitWebView*, WebKitNavigationAction*)
     221{
     222    return nullptr;
    223223}
    224224
     
    890890     * WebKitWebView::create:
    891891     * @web_view: the #WebKitWebView on which the signal is emitted
     892     * @navigation_action: a #WebKitNavigationAction
    892893     *
    893894     * Emitted when the creation of a new #WebKitWebView is requested.
     
    895896     * newly created #WebKitWebView.
    896897     *
     898     * The #WebKitNavigationAction parameter contains information about the
     899     * navigation action that triggered this signal.
     900     *
    897901     * When using %WEBKIT_PROCESS_MODEL_MULTIPLE_SECONDARY_PROCESSES
    898902     * 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()
    900904     * for more details.
    901905     *
     
    906910     *    or %NULL to propagate the event further.
    907911     */
    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);
    916921
    917922    /**
     
    16021607}
    16031608
    1604 WebPageProxy* webkitWebViewCreateNewPage(WebKitWebView* webView, ImmutableDictionary* windowFeatures)
     1609WebPageProxy* webkitWebViewCreateNewPage(WebKitWebView* webView, const WindowFeatures& windowFeatures, WebKitNavigationAction* navigationAction)
    16051610{
    16061611    WebKitWebView* newWebView;
    1607     g_signal_emit(webView, signals[CREATE], 0, &newWebView);
     1612    g_signal_emit(webView, signals[CREATE], 0, navigationAction, &newWebView);
    16081613    if (!newWebView)
    16091614        return 0;
     
    16751680}
    16761681
    1677 void webkitWebViewMouseTargetChanged(WebKitWebView* webView, WebHitTestResult* hitTestResult, unsigned modifiers)
    1678 {
    1679     webkitWebViewBaseSetTooltipArea(WEBKIT_WEB_VIEW_BASE(webView), hitTestResult->elementBoundingBox());
     1682void webkitWebViewMouseTargetChanged(WebKitWebView* webView, const WebHitTestResult::Data& hitTestResult, unsigned modifiers)
     1683{
     1684    webkitWebViewBaseSetTooltipArea(WEBKIT_WEB_VIEW_BASE(webView), hitTestResult.elementBoundingBox);
    16801685
    16811686    WebKitWebViewPrivate* priv = webView->priv;
     
    18291834        webkitWebViewCreateAndAppendInputMethodsMenuItem(webView, contextMenu.get());
    18301835
    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));
    18321849    GUniquePtr<GdkEvent> contextMenuEvent(webkitWebViewBaseTakeContextMenuEvent(webViewBase));
    18331850
  • trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.h

    r169884 r170702  
    3939#include <webkit2/WebKitHitTestResult.h>
    4040#include <webkit2/WebKitJavascriptResult.h>
     41#include <webkit2/WebKitNavigationAction.h>
    4142#include <webkit2/WebKitPermissionRequest.h>
    4243#include <webkit2/WebKitPolicyDecision.h>
     
    195196                                                GError                      *error);
    196197
    197     GtkWidget *(* create)                      (WebKitWebView               *web_view);
     198    GtkWidget *(* create)                      (WebKitWebView               *web_view,
     199                                                WebKitNavigationAction      *navigation_action);
    198200    void       (* ready_to_show)               (WebKitWebView               *web_view);
    199201    void       (* run_as_modal)                (WebKitWebView               *web_view);
  • trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewPrivate.h

    r159252 r170702  
    2828#define WebKitWebViewPrivate_h
    2929
     30#include "WebHitTestResult.h"
    3031#include "WebImage.h"
    3132#include "WebKitWebView.h"
     
    3839void webkitWebViewSetTitle(WebKitWebView*, const CString&);
    3940void webkitWebViewUpdateURI(WebKitWebView*);
    40 WebKit::WebPageProxy* webkitWebViewCreateNewPage(WebKitWebView*, WebKit::ImmutableDictionary* windowFeatures);
     41WebKit::WebPageProxy* webkitWebViewCreateNewPage(WebKitWebView*, const WebCore::WindowFeatures&, WebKitNavigationAction*);
    4142void webkitWebViewReadyToShowPage(WebKitWebView*);
    4243void webkitWebViewRunAsModal(WebKitWebView*);
     
    4748void webkitWebViewMakePermissionRequest(WebKitWebView*, WebKitPermissionRequest*);
    4849void webkitWebViewMakePolicyDecision(WebKitWebView*, WebKitPolicyDecisionType, WebKitPolicyDecision*);
    49 void webkitWebViewMouseTargetChanged(WebKitWebView*, WebKit::WebHitTestResult*, unsigned modifiers);
     50void webkitWebViewMouseTargetChanged(WebKitWebView*, const WebKit::WebHitTestResult::Data&, unsigned modifiers);
    5051void webkitWebViewPrintFrame(WebKitWebView*, WebKit::WebFrameProxy*);
    5152void webkitWebViewResourceLoadStarted(WebKitWebView*, WebKit::WebFrameProxy*, uint64_t resourceIdentifier, WebKitURIRequest*);
  • trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWindowProperties.cpp

    r160750 r170702  
    2727#include "WebKitWindowPropertiesPrivate.h"
    2828#include <WebCore/IntRect.h>
     29#include <WebCore/WindowFeatures.h>
    2930#include <glib/gi18n-lib.h>
    3031
     
    375376}
    376377
    377 void webkitWindowPropertiesUpdateFromWebWindowFeatures(WebKitWindowProperties* windowProperties, ImmutableDictionary* features)
     378void webkitWindowPropertiesUpdateFromWebWindowFeatures(WebKitWindowProperties* windowProperties, const WindowFeatures& windowFeatures)
    378379{
    379380    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;
    396389    webkitWindowPropertiesSetGeometry(windowProperties, &geometry);
    397390
    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);
    425398}
    426399
  • trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWindowPropertiesPrivate.h

    r131760 r170702  
    3232
    3333WebKitWindowProperties* webkitWindowPropertiesCreate();
    34 void webkitWindowPropertiesUpdateFromWebWindowFeatures(WebKitWindowProperties*, WebKit::ImmutableDictionary* features);
     34void webkitWindowPropertiesUpdateFromWebWindowFeatures(WebKitWindowProperties*, const WebCore::WindowFeatures&);
    3535void webkitWindowPropertiesSetGeometry(WebKitWindowProperties*, GdkRectangle*);
    3636void webkitWindowPropertiesSetToolbarVisible(WebKitWindowProperties*, bool toolbarsVisible);
  • trunk/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-docs.sgml

    r157781 r170702  
    2424    <xi:include href="xml/WebKitPermissionRequest.xml"/>
    2525    <xi:include href="xml/WebKitGeolocationPermissionRequest.xml"/>
     26    <xi:include href="xml/WebKitNavigationAction.xml"/>
    2627    <xi:include href="xml/WebKitPolicyDecision.xml"/>
    2728    <xi:include href="xml/WebKitNavigationPolicyDecision.xml"/>
  • trunk/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-sections.txt

    r169884 r170702  
    522522
    523523<SECTION>
     524<FILE>WebKitNavigationAction</FILE>
     525WebKitNavigationAction
     526webkit_navigation_action_copy
     527webkit_navigation_action_free
     528webkit_navigation_action_get_navigation_type
     529webkit_navigation_action_get_mouse_button
     530webkit_navigation_action_get_modifiers
     531webkit_navigation_action_get_request
     532webkit_navigation_action_is_user_gesture
     533
     534<SUBSECTION Standard>
     535WEBKIT_TYPE_NAVIGATION_ACTION
     536
     537<SUBSECTION Private>
     538webkit_navigation_action_get_type
     539</SECTION>
     540
     541<SECTION>
    524542<FILE>WebKitPolicyDecision</FILE>
    525543WebKitPolicyDecision
  • trunk/Source/WebKit2/UIProcess/API/gtk/webkit2.h

    r164940 r170702  
    5050#include <webkit2/WebKitJavascriptResult.h>
    5151#include <webkit2/WebKitMimeInfo.h>
     52#include <webkit2/WebKitNavigationAction.h>
    5253#include <webkit2/WebKitNavigationPolicyDecision.h>
    5354#include <webkit2/WebKitPermissionRequest.h>
  • trunk/Tools/ChangeLog

    r170701 r170702  
     12014-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
    1212014-07-02  Carlos Garcia Campos  <cgarcia@igalia.com>
    222
  • trunk/Tools/MiniBrowser/gtk/BrowserWindow.c

    r166239 r170702  
    349349}
    350350
    351 static GtkWidget *webViewCreate(WebKitWebView *webView, BrowserWindow *window)
     351static GtkWidget *webViewCreate(WebKitWebView *webView, WebKitNavigationAction *navigation, BrowserWindow *window)
    352352{
    353353    WebKitWebView *newWebView = WEBKIT_WEB_VIEW(webkit_web_view_new_with_related_view(webView));
  • trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestMultiprocess.cpp

    r169377 r170702  
    139139    };
    140140
    141     static GtkWidget* viewCreateCallback(WebKitWebView* webView, UIClientMultiprocessTest* test)
     141    static GtkWidget* viewCreateCallback(WebKitWebView* webView, WebKitNavigationAction*, UIClientMultiprocessTest* test)
    142142    {
    143143        return test->viewCreate(webView);
  • trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestPrinting.cpp

    r162599 r170702  
    195195    MAKE_GLIB_TEST_FIXTURE(CloseAfterPrintTest);
    196196
    197     static GtkWidget* webViewCreate(WebKitWebView* webView, CloseAfterPrintTest* test)
     197    static GtkWidget* webViewCreate(WebKitWebView* webView, WebKitNavigationAction*, CloseAfterPrintTest* test)
    198198    {
    199199        return test->createWebView();
  • trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestUIClient.cpp

    r162599 r170702  
    118118    }
    119119
    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);
    123123    }
    124124
     
    241241    }
    242242
    243     virtual GtkWidget* viewCreate(WebKitWebView* webView)
     243    virtual GtkWidget* viewCreate(WebKitWebView* webView, WebKitNavigationAction* navigation)
    244244    {
    245245        g_assert(webView == m_webView);
     246        g_assert(navigation);
    246247
    247248        GtkWidget* newWebView = webkit_web_view_new_with_context(webkit_web_view_get_context(webView));
     
    306307}
    307308
     309class CreateNavigationDataTest: public UIClientTest {
     310public:
     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
     355static 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
    308394static gboolean checkMimeTypeForFilter(GtkFileFilter* filter, const gchar* mimeType)
    309395{
     
    324410    }
    325411
    326     GtkWidget* viewCreate(WebKitWebView* webView)
     412    GtkWidget* viewCreate(WebKitWebView* webView, WebKitNavigationAction* navigation)
    327413    {
    328414        g_assert(webView == m_webView);
    329415
    330         GtkWidget* newWebView = UIClientTest::viewCreate(webView);
     416        GtkWidget* newWebView = UIClientTest::viewCreate(webView, navigation);
    331417        g_signal_connect(newWebView, "run-as-modal", G_CALLBACK(dialogRunAsModalCallback), this);
    332418        return newWebView;
     
    666752{
    667753    UIClientTest::add("WebKitWebView", "create-ready-close", testWebViewCreateReadyClose);
     754    CreateNavigationDataTest::add("WebKitWebView", "create-navigation-data", testWebViewCreateNavigationData);
    668755    ModalDialogsTest::add("WebKitWebView", "allow-modal-dialogs", testWebViewAllowModalDialogs);
    669756    ModalDialogsTest::add("WebKitWebView", "disallow-modal-dialogs", testWebViewDisallowModalDialogs);
  • trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitPolicyClient.cpp

    r161366 r170702  
    192192};
    193193
    194 static WebKitWebView* createCallback(WebKitWebView* webView, CreateCallbackData* data)
     194static WebKitWebView* createCallback(WebKitWebView* webView, WebKitNavigationAction*, CreateCallbackData* data)
    195195{
    196196    data->triedToOpenWindow = true;
Note: See TracChangeset for help on using the changeset viewer.