Bug 1158340 - Refactor RedistributeDisplayPortExcess. r=kats

This commit is contained in:
Milan Sreckovic 2015-04-27 12:06:11 -04:00
Родитель 1266c84e30
Коммит 476a1225bf
1 изменённых файлов: 8 добавлений и 13 удалений

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

@ -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;
}
}