fx140: Work around grid layout bug in item box

And don't use hiddenDOMWindow, since it's no longer available on all
platforms.
This commit is contained in:
Abe Jellinek 2025-07-02 15:35:51 -04:00 • committed by Dan Stillman
parent 4ecac12cc6
commit e52b1993f4
2 changed files with 19 additions and 9 deletions

View file

@ -60,18 +60,11 @@
];
static get _textMeasurementSpan() {
// Create our hidden span in the hiddenDOMWindow, because any calls to
// getBoundingClientRect(), offsetWidth, scrollWidth, etc. on an element
// in this document from sizeToContent() will, bizarrely, cause things
// in the metadata table to overlap
// TEMP: fx140: Use document
// TODO: Check if this bug is still present and restore hiddenDOMWindow if necessary
let doc = document; // Services.appShell.hiddenDOMWindow.document;
let span = doc.createElement('span');
let span = document.createElement('span');
span.style.position = 'absolute';
span.style.visibility = 'hidden';
span.style.whiteSpace = 'pre';
doc.documentElement.append(span);
document.documentElement.append(span);
window.addEventListener('unload', () => {
span.remove();

View file

@ -417,6 +417,23 @@
if (this._isAlreadyRendered()) return;
try {
// Firefox's grid layout implementation has a bug that causes rows
// to overlap due to bad layout invalidation after some synchronous
// modifications of the DOM, like the ones made by editable-text's
// _getContentWidth() method.
// Build our table as a normal block element and then revert to
// grid layout at the end to force a single layout recalculation
// after everything is stable.
this._infoTable.style.display = 'block';
this._renderInternal();
}
finally {
this._infoTable.style.display = '';
}
}
_renderInternal() {
this._saveFieldFocus();
delete this._linkMenu.dataset.link;