Commit 9d09b0ae authored by dgozman's avatar dgozman Committed by Commit bot

[DevTools] Listen to mousedown in SoftContextMenu once

We used to handle that through GlassPane, which has problems
with multiple layers of SoftContextMenus. Now we have a single
listener on bubble, and cancel all menus at that point.

BUG=709350

Review-Url: https://codereview.chromium.org/2801373002
Cr-Commit-Position: refs/heads/master@{#463032}
parent e4b092f1
...@@ -123,7 +123,7 @@ UI.GlassPane = class { ...@@ -123,7 +123,7 @@ UI.GlassPane = class {
return; return;
// Deliberately starts with 3000 to hide other z-indexed elements below. // Deliberately starts with 3000 to hide other z-indexed elements below.
this.element.style.zIndex = 3000 + 1000 * UI.GlassPane._panes.size; this.element.style.zIndex = 3000 + 1000 * UI.GlassPane._panes.size;
document.body.addEventListener('click', this._onMouseDownBound, true); document.body.addEventListener('mousedown', this._onMouseDownBound, true);
this._widget.show(document.body); this._widget.show(document.body);
UI.GlassPane._panes.add(this); UI.GlassPane._panes.add(this);
this._positionContent(); this._positionContent();
...@@ -133,7 +133,7 @@ UI.GlassPane = class { ...@@ -133,7 +133,7 @@ UI.GlassPane = class {
if (!this.isShowing()) if (!this.isShowing())
return; return;
UI.GlassPane._panes.delete(this); UI.GlassPane._panes.delete(this);
this.element.ownerDocument.body.removeEventListener('click', this._onMouseDownBound, true); this.element.ownerDocument.body.removeEventListener('mousedown', this._onMouseDownBound, true);
this._widget.detach(); this._widget.detach();
} }
......
...@@ -50,10 +50,6 @@ UI.SoftContextMenu = class { ...@@ -50,10 +50,6 @@ UI.SoftContextMenu = class {
this._glassPane = new UI.GlassPane(); this._glassPane = new UI.GlassPane();
this._glassPane.setBlockPointerEvents(!this._parentMenu); this._glassPane.setBlockPointerEvents(!this._parentMenu);
this._glassPane.setSetOutsideClickCallback(event => {
this._discardMenu(true, event);
event.consume();
});
this._glassPane.registerRequiredCSS('ui/softContextMenu.css'); this._glassPane.registerRequiredCSS('ui/softContextMenu.css');
this._glassPane.setContentAnchorBox(anchorBox); this._glassPane.setContentAnchorBox(anchorBox);
this._glassPane.setSizeBehavior(UI.GlassPane.SizeBehavior.MeasureContent); this._glassPane.setSizeBehavior(UI.GlassPane.SizeBehavior.MeasureContent);
...@@ -71,6 +67,11 @@ UI.SoftContextMenu = class { ...@@ -71,6 +67,11 @@ UI.SoftContextMenu = class {
this._glassPane.show(document); this._glassPane.show(document);
this._focus(); this._focus();
if (!this._parentMenu) {
this._onBodyMouseDown = event => this._discardMenu(true, event);
this._document.body.addEventListener('mousedown', this._onBodyMouseDown, false);
}
} }
discard() { discard() {
...@@ -330,6 +331,10 @@ UI.SoftContextMenu = class { ...@@ -330,6 +331,10 @@ UI.SoftContextMenu = class {
if (this._glassPane) { if (this._glassPane) {
this._glassPane.hide(); this._glassPane.hide();
delete this._glassPane; delete this._glassPane;
if (this._onBodyMouseDown) {
this._document.body.removeEventListener('mousedown', this._onBodyMouseDown, false);
delete this._onBodyMouseDown;
}
} }
if (this._parentMenu) if (this._parentMenu)
delete this._parentMenu._subMenu; delete this._parentMenu._subMenu;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment