зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1158340 - Refactor RedistributeDisplayPortExcess. r=kats
This commit is contained in:
Родитель
1266c84e30
Коммит
476a1225bf
|
@ -2347,19 +2347,14 @@ static void
|
|||
RedistributeDisplayPortExcess(CSSSize& aDisplayPortSize,
|
||||
const CSSRect& aScrollableRect)
|
||||
{
|
||||
float xSlack = std::max(0.0f, aDisplayPortSize.width - aScrollableRect.width);
|
||||
float ySlack = std::max(0.0f, aDisplayPortSize.height - aScrollableRect.height);
|
||||
|
||||
if (ySlack > 0) {
|
||||
// Reassign wasted y-axis displayport to the x-axis
|
||||
aDisplayPortSize.height -= ySlack;
|
||||
float xExtra = ySlack * aDisplayPortSize.width / aDisplayPortSize.height;
|
||||
aDisplayPortSize.width += xExtra;
|
||||
} else if (xSlack > 0) {
|
||||
// Reassign wasted x-axis displayport to the y-axis
|
||||
aDisplayPortSize.width -= xSlack;
|
||||
float yExtra = xSlack * aDisplayPortSize.height / aDisplayPortSize.width;
|
||||
aDisplayPortSize.height += yExtra;
|
||||
// As aDisplayPortSize.height * aDisplayPortSize.width does not change,
|
||||
// we are just scaling by the ratio and its inverse.
|
||||
if (aDisplayPortSize.height > aScrollableRect.height) {
|
||||
aDisplayPortSize.width *= (aDisplayPortSize.height / aScrollableRect.height);
|
||||
aDisplayPortSize.height = aScrollableRect.height;
|
||||
} else if (aDisplayPortSize.width > aScrollableRect.width) {
|
||||
aDisplayPortSize.height *= (aDisplayPortSize.width / aScrollableRect.width);
|
||||
aDisplayPortSize.width = aScrollableRect.width;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче