mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 998163 - 8% Tp5 Optimized regression on inbound for most all platforms [r=adw]
Bug 998387 - Middle click on newtab block button blocks the site Only add click listener once at the page level and filter/delegate click handling looking for primary/middle clicks.
This commit is contained in:
parent
459a7042c2
commit
9e49a38d29
@ -19,9 +19,10 @@ let gPage = {
|
|||||||
// Listen for 'unload' to unregister this page.
|
// Listen for 'unload' to unregister this page.
|
||||||
addEventListener("unload", this, false);
|
addEventListener("unload", this, false);
|
||||||
|
|
||||||
// Listen for toggle button clicks.
|
// XXX bug 991111 - Not all click events are correctly triggered when
|
||||||
let button = document.getElementById("newtab-toggle");
|
// listening from xhtml nodes -- in particular middle clicks on sites, so
|
||||||
button.addEventListener("click", this, false);
|
// listen from the xul window and filter then delegate
|
||||||
|
addEventListener("click", this, false);
|
||||||
|
|
||||||
// Initialize sponsored panel
|
// Initialize sponsored panel
|
||||||
this._sponsoredPanel = document.getElementById("sponsored-panel");
|
this._sponsoredPanel = document.getElementById("sponsored-panel");
|
||||||
@ -196,7 +197,22 @@ let gPage = {
|
|||||||
gAllPages.unregister(this);
|
gAllPages.unregister(this);
|
||||||
break;
|
break;
|
||||||
case "click":
|
case "click":
|
||||||
gAllPages.enabled = !gAllPages.enabled;
|
let {button, target} = aEvent;
|
||||||
|
if (target.id == "newtab-toggle") {
|
||||||
|
if (button == 0) {
|
||||||
|
gAllPages.enabled = !gAllPages.enabled;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Go up ancestors until we find a Site or not
|
||||||
|
while (target) {
|
||||||
|
if (target.hasOwnProperty("_newtabSite")) {
|
||||||
|
target._newtabSite.onClick(aEvent);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
target = target.parentNode;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case "dragover":
|
case "dragover":
|
||||||
if (gDrag.isValid(aEvent) && gDrag.draggedSite)
|
if (gDrag.isValid(aEvent) && gDrag.draggedSite)
|
||||||
|
@ -170,10 +170,6 @@ Site.prototype = {
|
|||||||
this._node.addEventListener("dragend", this, false);
|
this._node.addEventListener("dragend", this, false);
|
||||||
this._node.addEventListener("mouseover", this, false);
|
this._node.addEventListener("mouseover", this, false);
|
||||||
|
|
||||||
// XXX bug 991111 - Not all click events are correctly triggered when
|
|
||||||
// listening from the xhtml node, so listen from the xul window and filter
|
|
||||||
addEventListener("click", this, false);
|
|
||||||
|
|
||||||
// Specially treat the sponsored icon to prevent regular hover effects
|
// Specially treat the sponsored icon to prevent regular hover effects
|
||||||
let sponsored = this._querySelector(".newtab-control-sponsored");
|
let sponsored = this._querySelector(".newtab-control-sponsored");
|
||||||
sponsored.addEventListener("mouseover", () => {
|
sponsored.addEventListener("mouseover", () => {
|
||||||
@ -218,11 +214,19 @@ Site.prototype = {
|
|||||||
/**
|
/**
|
||||||
* Handles site click events.
|
* Handles site click events.
|
||||||
*/
|
*/
|
||||||
_onClick: function Site_onClick(aEvent) {
|
onClick: function Site_onClick(aEvent) {
|
||||||
let target = aEvent.target;
|
let {button, target} = aEvent;
|
||||||
if (target.classList.contains("newtab-link") ||
|
if (target.classList.contains("newtab-link") ||
|
||||||
target.parentElement.classList.contains("newtab-link")) {
|
target.parentElement.classList.contains("newtab-link")) {
|
||||||
this._recordSiteClicked(this.cell.index);
|
// Record for primary and middle clicks
|
||||||
|
if (button == 0 || button == 1) {
|
||||||
|
this._recordSiteClicked(this.cell.index);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Only handle primary clicks for the remaining targets
|
||||||
|
if (button != 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -242,13 +246,6 @@ Site.prototype = {
|
|||||||
*/
|
*/
|
||||||
handleEvent: function Site_handleEvent(aEvent) {
|
handleEvent: function Site_handleEvent(aEvent) {
|
||||||
switch (aEvent.type) {
|
switch (aEvent.type) {
|
||||||
case "click":
|
|
||||||
// Check the bitmask if the click event is for the site's descendants
|
|
||||||
if (this._node.compareDocumentPosition(aEvent.target) &
|
|
||||||
this._node.DOCUMENT_POSITION_CONTAINED_BY) {
|
|
||||||
this._onClick(aEvent);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case "mouseover":
|
case "mouseover":
|
||||||
this._node.removeEventListener("mouseover", this, false);
|
this._node.removeEventListener("mouseover", this, false);
|
||||||
this._speculativeConnect();
|
this._speculativeConnect();
|
||||||
|
@ -17,6 +17,7 @@ skip-if = os == "mac" # Intermittent failures, bug 898317
|
|||||||
[browser_newtab_bug876313.js]
|
[browser_newtab_bug876313.js]
|
||||||
[browser_newtab_bug991111.js]
|
[browser_newtab_bug991111.js]
|
||||||
[browser_newtab_bug991210.js]
|
[browser_newtab_bug991210.js]
|
||||||
|
[browser_newtab_bug998387.js]
|
||||||
[browser_newtab_disable.js]
|
[browser_newtab_disable.js]
|
||||||
[browser_newtab_drag_drop.js]
|
[browser_newtab_drag_drop.js]
|
||||||
[browser_newtab_drag_drop_ext.js]
|
[browser_newtab_drag_drop_ext.js]
|
||||||
|
@ -8,7 +8,7 @@ function runTests() {
|
|||||||
// Remember if the click handler was triggered
|
// Remember if the click handler was triggered
|
||||||
let cell = getCell(0);
|
let cell = getCell(0);
|
||||||
let clicked = false;
|
let clicked = false;
|
||||||
cell.site._onClick = e => {
|
cell.site.onClick = e => {
|
||||||
clicked = true;
|
clicked = true;
|
||||||
executeSoon(TestRunner.next);
|
executeSoon(TestRunner.next);
|
||||||
};
|
};
|
||||||
|
23
browser/base/content/test/newtab/browser_newtab_bug998387.js
Normal file
23
browser/base/content/test/newtab/browser_newtab_bug998387.js
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
/* Any copyright is dedicated to the Public Domain.
|
||||||
|
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||||
|
|
||||||
|
function runTests() {
|
||||||
|
yield setLinks("0");
|
||||||
|
yield addNewTabPageTab();
|
||||||
|
|
||||||
|
// Remember if the click handler was triggered
|
||||||
|
let cell = getCell(0);
|
||||||
|
let clicked = false;
|
||||||
|
cell.site.onClick = e => {
|
||||||
|
clicked = true;
|
||||||
|
executeSoon(TestRunner.next);
|
||||||
|
};
|
||||||
|
|
||||||
|
// Send a middle-click and make sure it happened
|
||||||
|
let block = getContentDocument().querySelector(".newtab-control-block");
|
||||||
|
yield EventUtils.synthesizeMouseAtCenter(block, {button: 1}, getContentWindow());
|
||||||
|
ok(clicked, "middle click triggered click listener");
|
||||||
|
|
||||||
|
// Make sure the cell didn't actually get blocked
|
||||||
|
checkGrid("0");
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user