Bug 1710533 - Apply the widget size constraints to newBounds r=mstange,gfx-reviewers

When nsView::CalcWidgetBounds() size might be applied to widget with modification. And next widget->GetClientBounds() could be different than nsView::CalcWidgetBounds() again with several reasons. But it seems OK to apply widget->ConstrainSize() in nsView::DoResetWidgetBounds(). It could remove repaint because of widget->ConstrainSize() call in the Resize().

Differential Revision: https://phabricator.services.mozilla.com/D114814
This commit is contained in:
sotaro 2021-05-13 09:34:26 +00:00
Родитель ba272367cd
Коммит c94f215c05
4 изменённых файлов: 13 добавлений и 2 удалений

Просмотреть файл

@ -204,7 +204,7 @@ var tests = [
is(screenRect.top, 210, testname + " screen top");
}
ok(screenRect.width >= 120 && screenRect.width <= 140, testname + " screen width");
ok(screenRect.height >= 40 && screenRect.height <= 80, testname + " screen height");
ok(screenRect.height >= 40 && screenRect.height <= 118, testname + " screen height");
var gotMouseEvent = false;
function mouseMoved(event)

Просмотреть файл

@ -332,6 +332,9 @@ void nsView::DoResetWidgetBounds(bool aMoveOnly, bool aInvalidateChangedSize) {
return;
}
// Apply the widget size constraints to newBounds.
widget->ConstrainSize(&newBounds.width, &newBounds.height);
bool changedPos = curBounds.TopLeft() != newBounds.TopLeft();
bool changedSize = curBounds.Size() != newBounds.Size();

Просмотреть файл

@ -578,7 +578,7 @@ class nsBaseWidget : public nsIWidget, public nsSupportsWeakReference {
* @param aWidth width to constrain
* @param aHeight height to constrain
*/
void ConstrainSize(int32_t* aWidth, int32_t* aHeight) {
void ConstrainSize(int32_t* aWidth, int32_t* aHeight) override {
SizeConstraints c = GetSizeConstraints();
*aWidth = std::max(c.mMinSize.width, std::min(c.mMaxSize.width, *aWidth));
*aHeight =

Просмотреть файл

@ -2079,6 +2079,14 @@ class nsIWidget : public nsISupports {
*/
virtual const SizeConstraints GetSizeConstraints() = 0;
/**
* Apply the current size constraints to the given size.
*
* @param aWidth width to constrain
* @param aHeight height to constrain
*/
virtual void ConstrainSize(int32_t* aWidth, int32_t* aHeight) = 0;
/**
* If this is owned by a BrowserChild, return that. Otherwise return
* null.