if (!hints.gmode && c->mode->id == 'c') {
vb_enter(c, 'n');
}
+ /* If open in new window hinting is use, set a flag on the mode after
+ * changing to normal mode. This is used in on_webview_decide_policy
+ * to enforce opening into new instance for the next navigation
+ * action. */
+ if (hints.mode == 't') {
+ c->mode->flags |= FLAG_NEW_WIN;
+ }
} else if (!strncmp(value, "INSERT:", 7)) {
fire_timeout(c, false);
vb_enter(c, 'i');
webkit_policy_decision_ignore(dec);
return TRUE;
}
- if (webkit_navigation_action_get_navigation_type(a) == WEBKIT_NAVIGATION_TYPE_LINK_CLICKED
- && (button == 2 || (button == 1 && mod & GDK_CONTROL_MASK))) {
+ /* Spawn new instance if the new win flag is set on the mode, or
+ * the navigation was triggered by CTRL-LeftMouse or MiddleMouse. */
+ if ((c->mode->flags & FLAG_NEW_WIN)
+ || (webkit_navigation_action_get_navigation_type(a) == WEBKIT_NAVIGATION_TYPE_LINK_CLICKED
+ && (button == 2 || (button == 1 && mod & GDK_CONTROL_MASK)))) {
+
+ /* Remove the FLAG_NEW_WIN after the first use. */
+ c->mode->flags &= ~FLAG_NEW_WIN;
webkit_policy_decision_ignore(dec);
spawn_new_instance(webkit_uri_request_get_uri(req), TRUE);
}
/* internal used methods */
- function open(e, newWin) {
- /* We call open() and click() in async mode to avoid return as fast as possible. */
- /* If we don't return immediately, the EvalJS dbus call will probably timeout and cause */
- /* errors. */
+ function open(e) {
var href;
if ((href = e.getAttribute('href')) && href != '#') {
- if (newWin) {
- /* Since the "noopener" vulnerability thing, it's not possible to set an anchor's */
- /* target to _blank. Therefore, we can't simulate ctrl-click through _blank like we */
- /* used to. Therefore, we limit ourselves to "window.open()" in cases we're firing a */
- /* simple <a> link. In other cases, we fire the even normally. */
- window.setTimeout(function() {
- window.open(href, '_blank');
- }, 0
- );
- } else {
- window.location.href = href;
- }
+ window.location.href = href;
} else {
+ /* We call click() in async mode to return as fast as possible. If
+ * we don't return immediately, the EvalJS dbus call will probably
+ * timeout and cause errors. */
window.setTimeout(function() {e.click();}, 0);
}
}
},
/* holds the actions to perform on hint fire */
actionmap = {
- o: function(e) {open(e, false); return "DONE:";},
- t: function(e) {open(e, true); return "DONE:";},
+ ot: function(e) {open(e); return "DONE:";},
eiIOpPsTxy: function(e) {return "DATA:" + getSrc(e);},
Y: function(e) {return "DATA:" + (e.textContent || "");}
};