[layout] Process pairs in coord list in PolyArea.

Range -1 assures the array is even with a step size of 2, avoiding lone
value processing.
This commit is contained in:
Eitan Isaacson 2024-02-22 20:36:30 +01:00 committed by roytam1
commit 2eea07fc65

View file

@ -529,7 +529,7 @@ void PolyArea::Draw(nsIFrame* aFrame, DrawTarget& aDrawTarget,
Point p1(pc->CSSPixelsToDevPixels(mCoords[0]),
pc->CSSPixelsToDevPixels(mCoords[1]));
Point p2, p1snapped, p2snapped;
for (int32_t i = 2; i < mNumCoords; i += 2) {
for (int32_t i = 2; i < mNumCoords - 1; i += 2) {
p2.x = pc->CSSPixelsToDevPixels(mCoords[i]);
p2.y = pc->CSSPixelsToDevPixels(mCoords[i+1]);
p1snapped = p1;
@ -556,7 +556,7 @@ void PolyArea::GetRect(nsIFrame* aFrame, nsRect& aRect)
nscoord x1, x2, y1, y2, xtmp, ytmp;
x1 = x2 = nsPresContext::CSSPixelsToAppUnits(mCoords[0]);
y1 = y2 = nsPresContext::CSSPixelsToAppUnits(mCoords[1]);
for (int32_t i = 2; i < mNumCoords; i += 2) {
for (int32_t i = 2; i < mNumCoords - 1; i += 2) {
xtmp = nsPresContext::CSSPixelsToAppUnits(mCoords[i]);
ytmp = nsPresContext::CSSPixelsToAppUnits(mCoords[i+1]);
x1 = x1 < xtmp ? x1 : xtmp;