Skip to content

Commit

Permalink
Bug 1811489 - MacOS shows visibly the changes to layout if sizeToCont…
Browse files Browse the repository at this point in the history
…ent is called after AppWindow::OnChromeLoaded, r=emilio

Differential Revision: https://phabricator.services.mozilla.com/D167625
  • Loading branch information
Olli Pettay authored and Olli Pettay committed Jan 24, 2023
1 parent 42d9272 commit 0b15f88
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions toolkit/content/widgets/dialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -351,16 +351,23 @@
await this._translationReady;
}

let finalStep = () => {
this._sizeToPreferredSize();
this._snapCursorToDefaultButtonIfNeeded();
};
// As a hack to ensure Windows sizes the window correctly,
// _sizeToPreferredSize() needs to happen after
// AppWindow::OnChromeLoaded. That one is called right after the load
// event dispatch but within the same task. Using direct dispatch let's
// all this code run before the next task (which might be a task to
// paint the window).
Services.tm.dispatchDirectTaskToCurrentThread(() => {
this._sizeToPreferredSize();
this._snapCursorToDefaultButtonIfNeeded();
});
// But, MacOS doesn't like resizing after window/dialog becoming visible.
// Linux seems to be able to handle both cases.
if (Services.appinfo.OS == "Darwin") {
finalStep();
} else {
Services.tm.dispatchDirectTaskToCurrentThread(finalStep);
}
}

// This snaps the cursor to the default button rect on windows, when
Expand Down

0 comments on commit 0b15f88

Please sign in to comment.