Changeset 90551 in webkit


Ignore:
Timestamp:
Jul 7, 2011 3:29:19 AM (13 years ago)
Author:
Carlos Garcia Campos
Message:

2011-07-07 Carlos Garcia Campos <cgarcia@igalia.com>

[GTK] Open links in a new window when clicking with the middle button in MiniBrowser
https://bugs.webkit.org/show_bug.cgi?id=63988

Reviewed by Martin Robinson.

  • MiniBrowser/gtk/BrowserWindow.c: (browserWindowConstructed): (decidePolicyForNavigationAction): Ignore the action if a link is clicked with the middle buttonm and open the link in a new window. (browserWindowPolicyClientInit):
Location:
trunk/Tools
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Tools/ChangeLog

    r90549 r90551  
     12011-07-07  Carlos Garcia Campos  <cgarcia@igalia.com>
     2
     3        [GTK] Open links in a new window when clicking with the middle button in MiniBrowser
     4        https://bugs.webkit.org/show_bug.cgi?id=63988
     5
     6        Reviewed by Martin Robinson.
     7
     8        * MiniBrowser/gtk/BrowserWindow.c:
     9        (browserWindowConstructed):
     10        (decidePolicyForNavigationAction): Ignore the action if a link is
     11        clicked with the middle buttonm and open the link in a new window.
     12        (browserWindowPolicyClientInit):
     13
    1142011-07-07  Adam Barth  <abarth@webkit.org>
    215
  • trunk/Tools/MiniBrowser/gtk/BrowserWindow.c

    r90163 r90551  
    5757static void browserWindowLoaderClientInit(BrowserWindow*);
    5858static void browserWindowUIClientInit(BrowserWindow*);
     59static void browserWindowPolicyClientInit(BrowserWindow*);
    5960
    6061static gint windowCount = 0;
     
    184185    browserWindowLoaderClientInit(window);
    185186    browserWindowUIClientInit(window);
     187    browserWindowPolicyClientInit(window);
    186188}
    187189
     
    655657}
    656658
     659static void decidePolicyForNavigationAction(WKPageRef page, WKFrameRef frame, WKFrameNavigationType navigationType, WKEventModifiers modifiers, WKEventMouseButton mouseButton, WKURLRequestRef request, WKFramePolicyListenerRef listener, WKTypeRef userData, const void* clientInfo)
     660{
     661    if (navigationType != kWKFrameNavigationTypeLinkClicked || mouseButton != kWKEventMouseButtonMiddleButton) {
     662        WKFramePolicyListenerUse(listener);
     663        return;
     664    }
     665
     666    WKViewRef webView = WKViewCreate(WKPageGetContext(page), 0);
     667    GtkWidget *window = browser_window_new(webView);
     668    WKURLRef url = WKURLRequestCopyURL(request);
     669    WKPageLoadURL(WKViewGetPage(webView), url);
     670    WKRelease(url);
     671    gtk_widget_grab_focus(GTK_WIDGET(webView));
     672    gtk_widget_show(window);
     673
     674    WKFramePolicyListenerIgnore(listener);
     675}
     676
     677static void browserWindowPolicyClientInit(BrowserWindow* window)
     678{
     679    WKPagePolicyClient policyClient = {
     680        kWKPagePolicyClientCurrentVersion,
     681        window, /* clientInfo */
     682        decidePolicyForNavigationAction,
     683        0,      /* decidePolicyForNewWindowAction */
     684        0,      /* decidePolicyForResponse */
     685        0       /* unableToImplementPolicy */
     686    };
     687    WKPageSetPagePolicyClient(WKViewGetPage(window->webView), &policyClient);
     688}
     689
    657690// Public API.
    658691GtkWidget* browser_window_new(WKViewRef view)
Note: See TracChangeset for help on using the changeset viewer.