Commit 8cd1d176 authored by Joel Einbinder's avatar Joel Einbinder Committed by Commit Bot

DevTools: Fix a scrollbar incorrectly appearing in some glasspanes

This measures the content inside a glasspane with getBoundingClientRect
instead of offsetHeight. When the content had a non-integer height,
offsetHeight could be rounded down from the real height. This would
cause a scrollbar to appear.

Change-Id: Ib9b4067e74c41e1649e35be2827147d2e2f23f3f
Reviewed-on: https://chromium-review.googlesource.com/1167652Reviewed-by: default avatarErik Luo <luoe@chromium.org>
Commit-Queue: Joel Einbinder <einbinder@chromium.org>
Cr-Commit-Position: refs/heads/master@{#590426}
parent a7e92432
......@@ -192,12 +192,11 @@ UI.GlassPane = class {
}
if (this._sizeBehavior === UI.GlassPane.SizeBehavior.MeasureContent) {
const measuredWidth = this.contentElement.offsetWidth;
const measuredHeight = this.contentElement.offsetHeight;
const widthOverflow = height < measuredHeight ? scrollbarSize : 0;
const heightOverflow = width < measuredWidth ? scrollbarSize : 0;
width = Math.min(width, measuredWidth + widthOverflow);
height = Math.min(height, measuredHeight + heightOverflow);
const measuredRect = this.contentElement.getBoundingClientRect();
const widthOverflow = height < measuredRect.height ? scrollbarSize : 0;
const heightOverflow = width < measuredRect.width ? scrollbarSize : 0;
width = Math.min(width, measuredRect.width + widthOverflow);
height = Math.min(height, measuredRect.height + heightOverflow);
}
if (this._anchorBox) {
......
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