Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(793)

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/ui/GlassPane.js

Issue 2695803003: [DevTools] Fix GlassPane choosing anchor side. (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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 UI.GlassPane = class { 5 UI.GlassPane = class {
6 /** 6 /**
7 * @param {!Document} document 7 * @param {!Document} document
8 * @param {boolean} dimmed 8 * @param {boolean} dimmed
9 * @param {boolean} blockPointerEvents 9 * @param {boolean} blockPointerEvents
10 * @param {function(!Event)} onClickOutside 10 * @param {function(!Event)} onClickOutside
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 height = Math.min(height, this._maxSize.height); 122 height = Math.min(height, this._maxSize.height);
123 } 123 }
124 124
125 if (this._anchorBox) { 125 if (this._anchorBox) {
126 var anchorBox = this._anchorBox.relativeToElement(container); 126 var anchorBox = this._anchorBox.relativeToElement(container);
127 var behavior = this._anchorBehavior; 127 var behavior = this._anchorBehavior;
128 128
129 if (behavior === UI.GlassPane.AnchorBehavior.PreferTop || behavior === UI. GlassPane.AnchorBehavior.PreferBottom) { 129 if (behavior === UI.GlassPane.AnchorBehavior.PreferTop || behavior === UI. GlassPane.AnchorBehavior.PreferBottom) {
130 var top = anchorBox.y - gutterSize; 130 var top = anchorBox.y - gutterSize;
131 var bottom = containerHeight - anchorBox.y - anchorBox.height - gutterSi ze; 131 var bottom = containerHeight - anchorBox.y - anchorBox.height - gutterSi ze;
132 if (behavior === UI.GlassPane.AnchorBehavior.PreferTop && top < height & & bottom >= height) 132 if (behavior === UI.GlassPane.AnchorBehavior.PreferTop && top < height & & bottom > top)
133 behavior = UI.GlassPane.AnchorBehavior.PreferBottom; 133 behavior = UI.GlassPane.AnchorBehavior.PreferBottom;
134 if (behavior === UI.GlassPane.AnchorBehavior.PreferBottom && bottom < he ight && top >= height) 134 if (behavior === UI.GlassPane.AnchorBehavior.PreferBottom && bottom < he ight && top > bottom)
135 behavior = UI.GlassPane.AnchorBehavior.PreferTop; 135 behavior = UI.GlassPane.AnchorBehavior.PreferTop;
136 136
137 positionX = Math.max(gutterSize, Math.min(anchorBox.x, containerWidth - width - gutterSize)); 137 positionX = Math.max(gutterSize, Math.min(anchorBox.x, containerWidth - width - gutterSize));
138 width = Math.min(width, containerWidth - positionX - gutterSize); 138 width = Math.min(width, containerWidth - positionX - gutterSize);
139 if (behavior === UI.GlassPane.AnchorBehavior.PreferTop) { 139 if (behavior === UI.GlassPane.AnchorBehavior.PreferTop) {
140 positionY = Math.max(gutterSize, anchorBox.y - height); 140 positionY = Math.max(gutterSize, anchorBox.y - height);
141 height = Math.min(height, anchorBox.y - positionY); 141 height = Math.min(height, anchorBox.y - positionY);
142 } else { 142 } else {
143 positionY = anchorBox.y + anchorBox.height; 143 positionY = anchorBox.y + anchorBox.height;
144 height = Math.min(height, containerHeight - positionY - gutterSize); 144 height = Math.min(height, containerHeight - positionY - gutterSize);
145 } 145 }
146 } else { 146 } else {
147 var left = anchorBox.x - gutterSize; 147 var left = anchorBox.x - gutterSize;
148 var right = containerWidth - anchorBox.x - anchorBox.width - gutterSize; 148 var right = containerWidth - anchorBox.x - anchorBox.width - gutterSize;
149 if (behavior === UI.GlassPane.AnchorBehavior.PreferLeft && left < width && right >= width) 149 if (behavior === UI.GlassPane.AnchorBehavior.PreferLeft && left < width && right > left)
150 behavior = UI.GlassPane.AnchorBehavior.PreferRight; 150 behavior = UI.GlassPane.AnchorBehavior.PreferRight;
151 if (behavior === UI.GlassPane.AnchorBehavior.PreferRight && right < widt h && left >= width) 151 if (behavior === UI.GlassPane.AnchorBehavior.PreferRight && right < widt h && left > right)
152 behavior = UI.GlassPane.AnchorBehavior.PreferLeft; 152 behavior = UI.GlassPane.AnchorBehavior.PreferLeft;
153 153
154 positionY = Math.max(gutterSize, Math.min(anchorBox.y, containerHeight - height - gutterSize)); 154 positionY = Math.max(gutterSize, Math.min(anchorBox.y, containerHeight - height - gutterSize));
155 height = Math.min(height, containerHeight - positionY - gutterSize); 155 height = Math.min(height, containerHeight - positionY - gutterSize);
156 if (behavior === UI.GlassPane.AnchorBehavior.PreferLeft) { 156 if (behavior === UI.GlassPane.AnchorBehavior.PreferLeft) {
157 positionX = Math.max(gutterSize, anchorBox.x - width); 157 positionX = Math.max(gutterSize, anchorBox.x - width);
158 width = Math.min(width, anchorBox.x - positionX); 158 width = Math.min(width, anchorBox.x - positionX);
159 } else { 159 } else {
160 positionX = anchorBox.x + anchorBox.width; 160 positionX = anchorBox.x + anchorBox.width;
161 width = Math.min(width, containerWidth - positionX - gutterSize); 161 width = Math.min(width, containerWidth - positionX - gutterSize);
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 PreferTop: Symbol('PreferTop'), 210 PreferTop: Symbol('PreferTop'),
211 PreferBottom: Symbol('PreferBottom'), 211 PreferBottom: Symbol('PreferBottom'),
212 PreferLeft: Symbol('PreferLeft'), 212 PreferLeft: Symbol('PreferLeft'),
213 PreferRight: Symbol('PreferRight'), 213 PreferRight: Symbol('PreferRight'),
214 }; 214 };
215 215
216 /** @type {!Map<!Document, !Element>} */ 216 /** @type {!Map<!Document, !Element>} */
217 UI.GlassPane._containers = new Map(); 217 UI.GlassPane._containers = new Map();
218 /** @type {!Set<!UI.GlassPane>} */ 218 /** @type {!Set<!UI.GlassPane>} */
219 UI.GlassPane._panes = new Set(); 219 UI.GlassPane._panes = new Set();
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698