Bug 37694 - [Qt] Issue with using QWebPage::setLinkDelegationPolicy...
Summary: [Qt] Issue with using QWebPage::setLinkDelegationPolicy...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit Qt (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Nobody
URL:
Keywords: Qt
Depends on:
Blocks:
 
Reported: 2010-04-15 20:46 PDT by Dawit A.
Modified: 2010-05-08 06:31 PDT (History)
2 users (show)

See Also:


Attachments
Document the limitation (965 bytes, patch)
2010-05-07 02:58 PDT, Jocelyn Turcotte
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Dawit A. 2010-04-15 20:46:50 PDT
Clicking on the type of links shown below completely renders QWebPage::setLinkDelegationPolicy(QWebPage::DelegateAllLinks) calls useless:

<a href="javascript:window.location='http://qt.nokia.com'">Click me</a>

When you click on a link like the one above, you will never receive the linkClicked signal. Instead the click will be treated as a non-click event and handled internally as if the default QWebPage::DontDelegateLinks is set. I guess this happens because the click triggers the execution of a javascript code which might do things other than making navigation requests. Regardless, the setLinkDelegationPolicy should mention this issue or perhaps there should be another NavigationType, QWebPage::NavigationTypeJavascript ???
Comment 1 Jocelyn Turcotte 2010-05-06 09:02:45 PDT
In this case it is hard to know if the navigation was trigger by a user action from other types of events, so linkClicked cannot fit reliably.

A NavigationTypeJavascript might make sense if you cannot rely on re-implementing acceptNavigationRequest listening for NavigationTypeOther requests.
Comment 2 Dawit A. 2010-05-06 09:25:14 PDT
(In reply to comment #1)
> In this case it is hard to know if the navigation was trigger by a user action
> from other types of events, so linkClicked cannot fit reliably.
> 
> A NavigationTypeJavascript might make sense if you cannot rely on
> re-implementing acceptNavigationRequest listening for NavigationTypeOther
> requests.

Unfortunately that is the case. That is one cannot rely on the meaning of NavigationTypeOther since there is no way you can distinguish that from say a call that originated from QWebView::load(...). :( 

After opening this bug report I took a look at the Qtwebkit source code and realized that this issue is actually the result of QtWebKit directly relying on the navigation types present in WebKit. All the Navigation types in QtWebKit are an exact equivalent right down to the name of the ones that exist in WebKit ; so the problem I guess is beyond just QtWebKit. 

Anyhow, I guess I have to come up with yet another hack to distinguish between requests that originate from a user clicking on a javascript link and those that originated from other means. In the meantime could this perhaps be clearly documented in the API ?
Comment 3 Jocelyn Turcotte 2010-05-07 02:58:21 PDT
Created attachment 55353 [details]
Document the limitation

How about that?
Comment 4 Kenneth Rohde Christiansen 2010-05-07 05:43:41 PDT
Comment on attachment 55353 [details]
Document the limitation


> +    \note This signal possibly won't be emitted for clicked links which use
> +    JavaScript to trigger navigation.

I don't like the 'possibly'

\note The signal will not be emitted for navigation triggered by JavaScript, such as ...
Comment 5 WebKit Commit Bot 2010-05-08 06:31:22 PDT
Comment on attachment 55353 [details]
Document the limitation

Clearing flags on attachment: 55353

Committed r59026: <http://trac.webkit.org/changeset/59026>
Comment 6 WebKit Commit Bot 2010-05-08 06:31:27 PDT
All reviewed patches have been landed.  Closing bug.