Skip to content

Commit 4ec6841

Browse files
Kateryna ProkopenkoDevtools-frontend LUCI CQ
authored andcommitted
[GM3Restyling] Update GlassPane tooltip styles
Screenshot: https://imgur.com/a/rhQmTVl Bug: 406466030 Change-Id: I0444c3f8bd029b277ba17a0e8c445d5fc3827754 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6403633 Reviewed-by: Kim-Anh Tran <[email protected]> Auto-Submit: Kateryna Prokopenko <[email protected]> Commit-Queue: Kateryna Prokopenko <[email protected]>
1 parent 3fd2e5f commit 4ec6841

File tree

3 files changed

+11
-88
lines changed

3 files changed

+11
-88
lines changed

front_end/ui/legacy/GlassPane.ts

Lines changed: 8 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
// Copyright 2017 The Chromium Authors. All rights reserved.
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
4-
5-
import * as Platform from '../../core/platform/platform.js';
6-
74
import type {Size} from './Geometry.js';
85
import glassPaneStyles from './glassPane.css.js';
96
import {deepElementFromEvent, measuredScrollbarWidth} from './UIUtils.js';
@@ -14,7 +11,6 @@ export class GlassPane {
1411

1512
element: typeof Widget.prototype.element;
1613
contentElement: typeof Widget.prototype.contentElement;
17-
private readonly arrowElement: HTMLSpanElement;
1814
private readonly onMouseDownBound: (event: Event) => void;
1915
private onClickOutsideCallback: ((arg0: Event) => void)|null = null;
2016
private maxSize: Size|null = null;
@@ -33,11 +29,6 @@ export class GlassPane {
3329
if (jslog) {
3430
this.contentElement.setAttribute('jslog', jslog);
3531
}
36-
this.arrowElement = document.createElement('span');
37-
this.arrowElement.classList.add('arrow', 'hidden');
38-
if (this.element.shadowRoot) {
39-
this.element.shadowRoot.appendChild(this.arrowElement);
40-
}
4132

4233
this.registerRequiredCSS(glassPaneStyles);
4334
this.setPointerEventsBehavior(PointerEventsBehavior.PIERCE_GLASS_PANE);
@@ -103,7 +94,6 @@ export class GlassPane {
10394

10495
setMarginBehavior(behavior: MarginBehavior): void {
10596
this.marginBehavior = behavior;
106-
this.arrowElement.classList.toggle('hidden', behavior !== MarginBehavior.ARROW);
10797
}
10898

10999
setIgnoreLeftMargin(ignore: boolean): void {
@@ -151,10 +141,9 @@ export class GlassPane {
151141
return;
152142
}
153143

154-
const showArrow = this.marginBehavior === MarginBehavior.ARROW;
155-
const gutterSize = showArrow ? 8 : (this.marginBehavior === MarginBehavior.NO_MARGIN ? 0 : 3);
144+
const gutterSize = this.marginBehavior === MarginBehavior.NO_MARGIN ? 0 : 3;
156145
const scrollbarSize = measuredScrollbarWidth(this.element.ownerDocument);
157-
const arrowSize = 10;
146+
const offsetSize = 10;
158147

159148
const container = (containers.get((this.element.ownerDocument))) as HTMLElement;
160149
if (this.sizeBehavior === SizeBehavior.MEASURE_CONTENT) {
@@ -190,7 +179,6 @@ export class GlassPane {
190179
const anchorBox = this.anchorBox.relativeToElement(container);
191180
let behavior: AnchorBehavior.PREFER_BOTTOM|AnchorBehavior.PREFER_TOP|AnchorBehavior.PREFER_RIGHT|
192181
AnchorBehavior.PREFER_LEFT|AnchorBehavior = this.anchorBehavior;
193-
this.arrowElement.classList.remove('arrow-none', 'arrow-top', 'arrow-bottom', 'arrow-left', 'arrow-right');
194182

195183
if (behavior === AnchorBehavior.PREFER_TOP || behavior === AnchorBehavior.PREFER_BOTTOM) {
196184
const top = anchorBox.y - 2 * gutterSize;
@@ -202,35 +190,28 @@ export class GlassPane {
202190
behavior = AnchorBehavior.PREFER_TOP;
203191
}
204192

205-
let arrowY;
206193
let enoughHeight = true;
207194
if (behavior === AnchorBehavior.PREFER_TOP) {
208195
positionY = Math.max(gutterSize, anchorBox.y - height - gutterSize);
209196
const spaceTop = anchorBox.y - positionY - gutterSize;
210197
if (this.sizeBehavior === SizeBehavior.MEASURE_CONTENT) {
211198
if (height > spaceTop) {
212-
this.arrowElement.classList.add('arrow-none');
213199
enoughHeight = false;
214200
}
215201
} else {
216202
height = Math.min(height, spaceTop);
217203
}
218-
this.arrowElement.classList.add('arrow-bottom');
219-
arrowY = anchorBox.y - gutterSize;
220204
} else {
221205
positionY = anchorBox.y + anchorBox.height + gutterSize;
222206
const spaceBottom = containerHeight - positionY - gutterSize;
223207
if (this.sizeBehavior === SizeBehavior.MEASURE_CONTENT) {
224208
if (height > spaceBottom) {
225-
this.arrowElement.classList.add('arrow-none');
226209
positionY = containerHeight - gutterSize - height;
227210
enoughHeight = false;
228211
}
229212
} else {
230213
height = Math.min(height, spaceBottom);
231214
}
232-
this.arrowElement.classList.add('arrow-top');
233-
arrowY = anchorBox.y + anchorBox.height + gutterSize;
234215
}
235216

236217
const naturalPositionX = Math.min(anchorBox.x, containerWidth - width - gutterSize);
@@ -240,18 +221,11 @@ export class GlassPane {
240221
}
241222

242223
if (!enoughHeight) {
243-
positionX = Math.min(positionX + arrowSize, containerWidth - width - gutterSize);
244-
} else if (showArrow && positionX - arrowSize >= gutterSize) {
245-
positionX -= arrowSize;
224+
positionX = Math.min(positionX + offsetSize, containerWidth - width - gutterSize);
225+
} else if (positionX - offsetSize >= gutterSize) {
226+
positionX -= offsetSize;
246227
}
247228
width = Math.min(width, containerWidth - positionX - gutterSize);
248-
if (2 * arrowSize >= width) {
249-
this.arrowElement.classList.add('arrow-none');
250-
} else {
251-
let arrowX: number = anchorBox.x + Math.min(50, Math.floor(anchorBox.width / 2));
252-
arrowX = Platform.NumberUtilities.clamp(arrowX, positionX + arrowSize, positionX + width - arrowSize);
253-
this.arrowElement.positionAt(arrowX, arrowY, container);
254-
}
255229
} else {
256230
const left = anchorBox.x - 2 * gutterSize;
257231
const right = containerWidth - anchorBox.x - anchorBox.width - 2 * gutterSize;
@@ -262,58 +236,43 @@ export class GlassPane {
262236
behavior = AnchorBehavior.PREFER_LEFT;
263237
}
264238

265-
let arrowX;
266239
let enoughWidth = true;
267240
if (behavior === AnchorBehavior.PREFER_LEFT) {
268241
positionX = Math.max(gutterSize, anchorBox.x - width - gutterSize);
269242
const spaceLeft = anchorBox.x - positionX - gutterSize;
270243
if (this.sizeBehavior === SizeBehavior.MEASURE_CONTENT) {
271244
if (width > spaceLeft) {
272-
this.arrowElement.classList.add('arrow-none');
273245
enoughWidth = false;
274246
}
275247
} else {
276248
width = Math.min(width, spaceLeft);
277249
}
278-
this.arrowElement.classList.add('arrow-right');
279-
arrowX = anchorBox.x - gutterSize;
280250
} else {
281251
positionX = anchorBox.x + anchorBox.width + gutterSize;
282252
const spaceRight = containerWidth - positionX - gutterSize;
283253
if (this.sizeBehavior === SizeBehavior.MEASURE_CONTENT) {
284254
if (width > spaceRight) {
285-
this.arrowElement.classList.add('arrow-none');
286255
positionX = containerWidth - gutterSize - width;
287256
enoughWidth = false;
288257
}
289258
} else {
290259
width = Math.min(width, spaceRight);
291260
}
292-
this.arrowElement.classList.add('arrow-left');
293-
arrowX = anchorBox.x + anchorBox.width + gutterSize;
294261
}
295262

296263
positionY = Math.max(gutterSize, Math.min(anchorBox.y, containerHeight - height - gutterSize));
297264
if (!enoughWidth) {
298-
positionY = Math.min(positionY + arrowSize, containerHeight - height - gutterSize);
299-
} else if (showArrow && positionY - arrowSize >= gutterSize) {
300-
positionY -= arrowSize;
265+
positionY = Math.min(positionY + offsetSize, containerHeight - height - gutterSize);
266+
} else if (positionY - offsetSize >= gutterSize) {
267+
positionY -= offsetSize;
301268
}
302269
height = Math.min(height, containerHeight - positionY - gutterSize);
303-
if (2 * arrowSize >= height) {
304-
this.arrowElement.classList.add('arrow-none');
305-
} else {
306-
let arrowY: number = anchorBox.y + Math.min(50, Math.floor(anchorBox.height / 2));
307-
arrowY = Platform.NumberUtilities.clamp(arrowY, positionY + arrowSize, positionY + height - arrowSize);
308-
this.arrowElement.positionAt(arrowX, arrowY, container);
309-
}
310270
}
311271
} else {
312272
positionX = this.positionX !== null ? this.positionX : (containerWidth - width) / 2;
313273
positionY = this.positionY !== null ? this.positionY : (containerHeight - height) / 2;
314274
width = Math.min(width, containerWidth - positionX - gutterSize);
315275
height = Math.min(height, containerHeight - positionY - gutterSize);
316-
this.arrowElement.classList.add('arrow-none');
317276
}
318277

319278
this.contentElement.style.width = width + 'px';

front_end/ui/legacy/components/perf_ui/timelineOverviewInfo.css

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@
77
.overview-info:not(:empty) {
88
display: flex;
99
background: var(--sys-color-cdt-base-container);
10-
box-shadow: var(--drop-shadow);
11-
padding: 3px;
10+
box-shadow: var(--sys-elevation-level2);
11+
padding: var(--sys-size-6) var(--sys-size-8);
12+
border-radius: var(--sys-shape-corner-small);
1213
}
1314

1415
.overview-info .frame .time {

front_end/ui/legacy/glassPane.css

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -30,40 +30,3 @@
3030
.no-pointer-events {
3131
pointer-events: none;
3232
}
33-
34-
.arrow {
35-
/* stylelint-disable-next-line custom-property-pattern */
36-
background-image: var(--image-file-popoverArrows);
37-
width: 19px;
38-
height: 19px;
39-
}
40-
41-
.arrow-top {
42-
background-position: 0 76px;
43-
margin-top: -19px;
44-
margin-left: -9px;
45-
}
46-
47-
.arrow-bottom {
48-
background-position: 0 57px;
49-
margin-left: -9px;
50-
}
51-
52-
.arrow-left {
53-
background-position: 0 38px;
54-
margin-left: -19px;
55-
margin-top: -9px;
56-
}
57-
58-
.arrow-right {
59-
background-position: 0 19px;
60-
margin-top: -9px;
61-
}
62-
63-
.arrow-none {
64-
display: none;
65-
}
66-
67-
:host-context(.theme-with-dark-background) .arrow {
68-
filter: invert(80%);
69-
}

0 commit comments

Comments
 (0)