Skip to content

Commit 4d70ca2

Browse files
stephanwleecaisq
authored andcommitted
perf: apply layout/layer bound where possible (#3642)
This is a CSS/layout optimization for areas that renders a lot of DOM Nodes including the scrollable area. - `will-change`: transform <- hints browser to put the DOM in different GPU layer - `contain` <- hints browser that certain operations can be done by reasoning children only. For instance, when `size` is present, browser can calculate size/bounds by only reasoning with the child nodes. For more information, refer to the [doc](https://developer.mozilla.org/en-US/docs/Web/CSS/contain).
1 parent d335d17 commit 4d70ca2

File tree

5 files changed

+19
-4
lines changed

5 files changed

+19
-4
lines changed

tensorboard/components/tf_dashboard_common/tf-dashboard-layout.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
}
5757

5858
::slotted([slot='center']) {
59+
contain: strict;
5960
height: 100%;
6061
overflow-x: hidden;
6162
overflow-y: auto;

tensorboard/components/tf_dashboard_common/tf-multi-checkbox.html

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,14 +98,17 @@
9898
overflow: hidden;
9999
}
100100
#outer-container {
101-
overflow-y: auto;
102-
overflow-x: hidden;
103-
width: 100%;
101+
contain: content;
104102
flex-grow: 1;
105103
flex-shrink: 1;
104+
overflow-x: hidden;
105+
overflow-y: auto;
106+
width: 100%;
107+
will-change: transform;
106108
word-wrap: break-word;
107109
}
108110
.name-row {
111+
contain: content;
109112
padding-top: 5px;
110113
padding-bottom: 5px;
111114
display: flex;

tensorboard/components/tf_paginated_view/tf-category-paginated-view.html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,11 @@
262262
flex-wrap: wrap;
263263
}
264264

265+
::slotted([slot='items']) {
266+
/* Tooltip for descriptions and others break with more strict ones. */
267+
contain: style;
268+
}
269+
265270
#page-input {
266271
display: inline-block;
267272
width: var(--tf-category-paginated-view-page-input-width, 100%);

tensorboard/components/vz_chart_helpers/vz-chart-tooltip.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ namespace vz_chart_helper {
158158
}
159159

160160
const newStyle = {
161+
contain: 'content',
161162
opacity: 1,
162163
left: left ? `${left}px` : null,
163164
right: right ? `${right}px` : null,

tensorboard/components/vz_line_chart2/vz-line-chart2.html

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
}
6363

6464
#chartdiv .main {
65+
contain: strict;
6566
cursor: crosshair;
6667
}
6768

@@ -75,11 +76,15 @@
7576
cursor: grabbing;
7677
}
7778

79+
#chartdiv {
80+
contain: strict;
81+
}
82+
7883
#chartdiv line.guide-line {
7984
stroke: #999;
8085
stroke-width: 1.5px;
8186
}
82-
#chartdiv:hover {
87+
#chartdiv:hover .main {
8388
will-change: transform;
8489
}
8590

0 commit comments

Comments
 (0)