Bug 1457110: Restore behavior of maintaining width/height when one of the two is exactly zero. r=jrmuizel

MozReview-Commit-ID: 5OpjfTnJQxe
This commit is contained in:
Bas Schouten 2018-05-25 18:16:52 +02:00
Родитель f00009e1f9
Коммит 2c20988af9
2 изменённых файлов: 28 добавлений и 7 удалений

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

@ -124,7 +124,9 @@ struct BaseRect {
result.y = std::max<T>(y, aRect.y);
result.width = std::min<T>(x - result.x + width, aRect.x - result.x + aRect.width);
result.height = std::min<T>(y - result.y + height, aRect.y - result.y + aRect.height);
if (result.width <= 0 || result.height <= 0) {
// See bug 1457110, this function expects to -only- size to 0,0 if the width/height
// is explicitly negative.
if (result.width < 0 || result.height < 0) {
result.SizeTo(0, 0);
}
return result;
@ -137,8 +139,17 @@ struct BaseRect {
// 'this' can be the same object as either aRect1 or aRect2
bool IntersectRect(const Sub& aRect1, const Sub& aRect2)
{
*static_cast<Sub*>(this) = aRect1.Intersect(aRect2);
return !IsEmpty();
T newX = std::max<T>(aRect1.x, aRect2.x);
T newY = std::max<T>(aRect1.y, aRect2.y);
width = std::min<T>(aRect1.x - newX + aRect1.width, aRect2.x - newX + aRect2.width);
height = std::min<T>(aRect1.y - newY + aRect1.height, aRect2.y - newY + aRect2.height);
x = newX;
y = newY;
if (width <= 0 || height <= 0) {
SizeTo(0, 0);
return false;
}
return true;
}
// Returns the smallest rectangle that contains both the area of both

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

@ -150,7 +150,7 @@ struct nsRect :
resultRect = _mm_blend_epi16(resultRect, widthheight, 0xF0); // xr, yr, wr, hr
if ((_mm_movemask_ps(_mm_castsi128_ps(_mm_cmpgt_epi32(resultRect, _mm_setzero_si128()))) & 0xC) != 0xC) {
if ((_mm_movemask_ps(_mm_castsi128_ps(_mm_cmplt_epi32(resultRect, _mm_setzero_si128()))) & 0xC) != 0) {
// It's potentially more efficient to store all 0s. But the non SSE4 code leaves x/y intact
// so let's do the same here.
resultRect = _mm_and_si128(resultRect, _mm_set_epi32(0, 0, 0xFFFFFFFF, 0xFFFFFFFF));
@ -165,7 +165,7 @@ struct nsRect :
result.y = std::max<int32_t>(y, aRect.y);
result.width = std::min<int32_t>(x - result.x + width, aRect.x - result.x + aRect.width);
result.height = std::min<int32_t>(y - result.y + height, aRect.y - result.y + aRect.height);
if (result.width <= 0 || result.height <= 0) {
if (result.width < 0 || result.height < 0) {
result.SizeTo(0, 0);
}
return result;
@ -198,8 +198,18 @@ struct nsRect :
return true;
}
*static_cast<nsRect*>(this) = aRect1.Intersect(aRect2);
return !IsEmpty();
int32_t newX = std::max<int32_t>(aRect1.x, aRect2.x);
int32_t newY = std::max<int32_t>(aRect1.y, aRect2.y);
width = std::min<int32_t>(aRect1.x - newX + aRect1.width, aRect2.x - newX + aRect2.width);
height = std::min<int32_t>(aRect1.y - newY + aRect1.height, aRect2.y - newY + aRect2.height);
x = newX;
y = newY;
if (width <= 0 || height <= 0) {
SizeTo(0, 0);
return false;
}
return true;
}
#endif
#endif