OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 /** | 5 /** |
6 * @fileoverview | 6 * @fileoverview |
7 * Provide an alternative location for the application's context menu items | 7 * Provide an alternative location for the application's context menu items |
8 * on platforms that don't provide it. | 8 * on platforms that don't provide it. |
9 * | 9 * |
10 * To mimic the behaviour of an OS-provided context menu, the menu is dismissed | 10 * To mimic the behaviour of an OS-provided context menu, the menu is dismissed |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 this.stub_.addEventListener('click', this.onStubClick_.bind(this), false); | 96 this.stub_.addEventListener('click', this.onStubClick_.bind(this), false); |
97 this.icon_.addEventListener('click', this.onIconClick_.bind(this), false); | 97 this.icon_.addEventListener('click', this.onIconClick_.bind(this), false); |
98 this.screen_.addEventListener('click', this.onIconClick_.bind(this), false); | 98 this.screen_.addEventListener('click', this.onIconClick_.bind(this), false); |
99 | 99 |
100 this.root_.hidden = false; | 100 this.root_.hidden = false; |
101 this.root_.style.bottom = this.bottom_ + 'px'; | 101 this.root_.style.bottom = this.bottom_ + 'px'; |
102 remoting.windowShape.addCallback(this); | 102 remoting.windowShape.addCallback(this); |
103 }; | 103 }; |
104 | 104 |
105 /** | 105 /** |
106 * @param {Array.<{left: number, top: number, width: number, height: number}>} | 106 * @param {Array<{left: number, top: number, width: number, height: number}>} |
107 * rects List of rectangles. | 107 * rects List of rectangles. |
108 */ | 108 */ |
109 remoting.ContextMenuDom.prototype.addToRegion = function(rects) { | 109 remoting.ContextMenuDom.prototype.addToRegion = function(rects) { |
110 var rect = /** @type {ClientRect} */ (this.root_.getBoundingClientRect()); | 110 var rect = /** @type {ClientRect} */ (this.root_.getBoundingClientRect()); |
111 // Clip the menu position to the main window in case the screen size has | 111 // Clip the menu position to the main window in case the screen size has |
112 // changed or a recent drag event tried to move it out of bounds. | 112 // changed or a recent drag event tried to move it out of bounds. |
113 if (rect.top < 0) { | 113 if (rect.top < 0) { |
114 this.bottom_ += rect.top; | 114 this.bottom_ += rect.top; |
115 this.root_.style.bottom = this.bottom_ + 'px'; | 115 this.root_.style.bottom = this.bottom_ + 'px'; |
116 rect = this.root_.getBoundingClientRect(); | 116 rect = this.root_.getBoundingClientRect(); |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
319 this.bottom_ -= deltaY; | 319 this.bottom_ -= deltaY; |
320 this.root_.style.bottom = this.bottom_ + 'px'; | 320 this.root_.style.bottom = this.bottom_ + 'px'; |
321 // Deferring the window shape update until the DOM update has completed | 321 // Deferring the window shape update until the DOM update has completed |
322 // helps keep the position of the context menu consistent with the window | 322 // helps keep the position of the context menu consistent with the window |
323 // shape (though it's still not perfect). | 323 // shape (though it's still not perfect). |
324 window.requestAnimationFrame( | 324 window.requestAnimationFrame( |
325 function() { | 325 function() { |
326 remoting.windowShape.updateClientWindowShape(); | 326 remoting.windowShape.updateClientWindowShape(); |
327 }); | 327 }); |
328 }; | 328 }; |
OLD | NEW |