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

Side by Side Diff: Source/core/rendering/svg/SVGRenderTreeAsText.cpp

Issue 856533002: Fix problems with flakes in SVG LayoutTests. Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebased to newer master. Created 5 years, 11 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 | « no previous file | 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) 2004, 2005, 2007, 2009 Apple Inc. All rights reserved. 2 * Copyright (C) 2004, 2005, 2007, 2009 Apple Inc. All rights reserved.
3 * (C) 2005 Rob Buis <buis@kde.org> 3 * (C) 2005 Rob Buis <buis@kde.org>
4 * (C) 2006 Alexander Kellett <lypanov@kde.org> 4 * (C) 2006 Alexander Kellett <lypanov@kde.org>
5 * Copyright (C) Research In Motion Limited 2010. All rights reserved. 5 * Copyright (C) Research In Motion Limited 2010. All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 ts << "}]"; 320 ts << "}]";
321 } 321 }
322 writeIfNotDefault(ts, "clip rule", svgStyle.clipRule(), RULE_NONZERO); 322 writeIfNotDefault(ts, "clip rule", svgStyle.clipRule(), RULE_NONZERO);
323 } 323 }
324 324
325 writeIfNotEmpty(ts, "start marker", svgStyle.markerStartResource()); 325 writeIfNotEmpty(ts, "start marker", svgStyle.markerStartResource());
326 writeIfNotEmpty(ts, "middle marker", svgStyle.markerMidResource()); 326 writeIfNotEmpty(ts, "middle marker", svgStyle.markerMidResource());
327 writeIfNotEmpty(ts, "end marker", svgStyle.markerEndResource()); 327 writeIfNotEmpty(ts, "end marker", svgStyle.markerEndResource());
328 } 328 }
329 329
330 static float snapToCloseInteger(float value)
331 {
332 // Due to floating point arithmetic uncertainties we may sometimes end up at
333 // something like 4.99999952 when pure arithmetic would have given 5.
334 // To give predictable results in debug ouput, snap numbers very close to
335 // integers to integers. This matters because sometimes numbers are truncate d
336 // rather than rounded before being viewed as integers.
337 const double epsilon = 0.00001;
338 if (fabs(value - round(value)) < epsilon)
339 return static_cast<float>(round(value));
340 return value;
341 }
342
343 static FloatPoint snapToCloseInteger(FloatPoint point)
344 {
345 return FloatPoint(snapToCloseInteger(point.x()), snapToCloseInteger(point.y( )));
346 }
347
348 static FloatRect snapToCloseInteger(FloatRect rect)
349 {
350 FloatPoint bottomRight = snapToCloseInteger(rect.maxXMaxYCorner());
351 FloatPoint topLeft = snapToCloseInteger(rect.minXMinYCorner());
352 return FloatRect(topLeft, bottomRight - topLeft);
353 }
354
330 static TextStream& writePositionAndStyle(TextStream& ts, const RenderObject& obj ect) 355 static TextStream& writePositionAndStyle(TextStream& ts, const RenderObject& obj ect)
331 { 356 {
332 ts << " " << enclosingIntRect(const_cast<RenderObject&>(object).absoluteClip pedOverflowRect()); 357 FloatRect rect = snapToCloseInteger(object.absoluteClippedOverflowRect());
Daniel Bratell 2015/01/22 09:21:40 This is too late. It's in the conversion from floa
358 ts << " " << enclosingIntRect(rect);
333 writeStyle(ts, object); 359 writeStyle(ts, object);
334 return ts; 360 return ts;
335 } 361 }
336 362
337 static TextStream& operator<<(TextStream& ts, const RenderSVGShape& shape) 363 static TextStream& operator<<(TextStream& ts, const RenderSVGShape& shape)
338 { 364 {
339 writePositionAndStyle(ts, shape); 365 writePositionAndStyle(ts, shape);
340 366
341 SVGElement* svgElement = shape.element(); 367 SVGElement* svgElement = shape.element();
342 ASSERT(svgElement); 368 ASSERT(svgElement);
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
674 ts << " "; 700 ts << " ";
675 writeNameAndQuotedValue(ts, "filter", svgStyle.filterResource()); 701 writeNameAndQuotedValue(ts, "filter", svgStyle.filterResource());
676 ts << " "; 702 ts << " ";
677 writeStandardPrefix(ts, *filter, 0); 703 writeStandardPrefix(ts, *filter, 0);
678 ts << " " << filter->resourceBoundingBox(&renderer) << "\n"; 704 ts << " " << filter->resourceBoundingBox(&renderer) << "\n";
679 } 705 }
680 } 706 }
681 } 707 }
682 708
683 } // namespace blink 709 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698