Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(135)

Side by Side Diff: Source/core/rendering/shapes/Shape.cpp

Issue 237123002: Fix off-by-one error in RasterShape of CSS shapes (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Address review comment and rename variable for consistency Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Source/core/rendering/shapes/RasterShape.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved. 2 * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above 8 * 1. Redistributions of source code must retain the above
9 * copyright notice, this list of conditions and the following 9 * copyright notice, this list of conditions and the following
10 * disclaimer. 10 * disclaimer.
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 int maxBufferY = std::min(imageRect.height(), marginRect.maxY() - imageR ect.y()); 195 int maxBufferY = std::min(imageRect.height(), marginRect.maxY() - imageR ect.y());
196 196
197 for (int y = minBufferY; y < maxBufferY; ++y) { 197 for (int y = minBufferY; y < maxBufferY; ++y) {
198 int startX = -1; 198 int startX = -1;
199 for (int x = 0; x < imageRect.width(); ++x, pixelArrayOffset += 4) { 199 for (int x = 0; x < imageRect.width(); ++x, pixelArrayOffset += 4) {
200 uint8_t alpha = pixelArray->item(pixelArrayOffset); 200 uint8_t alpha = pixelArray->item(pixelArrayOffset);
201 bool alphaAboveThreshold = alpha > alphaPixelThreshold; 201 bool alphaAboveThreshold = alpha > alphaPixelThreshold;
202 if (startX == -1 && alphaAboveThreshold) { 202 if (startX == -1 && alphaAboveThreshold) {
203 startX = x; 203 startX = x;
204 } else if (startX != -1 && (!alphaAboveThreshold || x == imageRe ct.width() - 1)) { 204 } else if (startX != -1 && (!alphaAboveThreshold || x == imageRe ct.width() - 1)) {
205 intervals->intervalAt(y + imageRect.y()).unite(IntShapeInter val(startX + imageRect.x(), x + imageRect.x())); 205 int endX = alphaAboveThreshold ? x + 1: x;
philipj_slow 2014/04/15 11:37:07 missing space before :
davve 2014/04/15 11:41:27 Done.
206 intervals->intervalAt(y + imageRect.y()).unite(IntShapeInter val(startX + imageRect.x(), endX + imageRect.x()));
206 startX = -1; 207 startX = -1;
207 } 208 }
208 } 209 }
209 } 210 }
210 } 211 }
211 212
212 OwnPtr<RasterShape> rasterShape = adoptPtr(new RasterShape(intervals.release (), marginRect.size())); 213 OwnPtr<RasterShape> rasterShape = adoptPtr(new RasterShape(intervals.release (), marginRect.size()));
213 rasterShape->m_writingMode = writingMode; 214 rasterShape->m_writingMode = writingMode;
214 rasterShape->m_margin = margin; 215 rasterShape->m_margin = margin;
215 return rasterShape.release(); 216 return rasterShape.release();
216 } 217 }
217 218
218 PassOwnPtr<Shape> Shape::createLayoutBoxShape(const RoundedRect& roundedRect, Wr itingMode writingMode, float margin) 219 PassOwnPtr<Shape> Shape::createLayoutBoxShape(const RoundedRect& roundedRect, Wr itingMode writingMode, float margin)
219 { 220 {
220 FloatRect rect(0, 0, roundedRect.rect().width(), roundedRect.rect().height() ); 221 FloatRect rect(0, 0, roundedRect.rect().width(), roundedRect.rect().height() );
221 FloatRoundedRect bounds(rect, roundedRect.radii()); 222 FloatRoundedRect bounds(rect, roundedRect.radii());
222 OwnPtr<Shape> shape = createInsetShape(bounds); 223 OwnPtr<Shape> shape = createInsetShape(bounds);
223 shape->m_writingMode = writingMode; 224 shape->m_writingMode = writingMode;
224 shape->m_margin = margin; 225 shape->m_margin = margin;
225 226
226 return shape.release(); 227 return shape.release();
227 } 228 }
228 229
229 } // namespace WebCore 230 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/rendering/shapes/RasterShape.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698