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

Side by Side Diff: Source/core/rendering/shapes/ShapeInterval.h

Issue 212223006: [CSS Shapes] Simplify RasterShape implementation (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fix style errors 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/Shape.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 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 200
201 if (aNext != a.end()) { 201 if (aNext != a.end()) {
202 result.append(aValue); 202 result.append(aValue);
203 result.appendRange(++aNext, a.end()); 203 result.appendRange(++aNext, a.end());
204 } 204 }
205 } 205 }
206 206
207 bool operator==(const ShapeInterval<T>& other) const { return x1() == other. x1() && x2() == other.x2(); } 207 bool operator==(const ShapeInterval<T>& other) const { return x1() == other. x1() && x2() == other.x2(); }
208 bool operator!=(const ShapeInterval<T>& other) const { return !operator==(ot her); } 208 bool operator!=(const ShapeInterval<T>& other) const { return !operator==(ot her); }
209 209
210 void unite(const ShapeInterval<T>& interval)
211 {
212 if (interval.isEmpty())
213 return;
214 if (isEmpty())
215 set(interval.x1(), interval.x2());
216 else
217 set(std::min<T>(x1(), interval.x1()), std::max<T>(x2(), interval.x2( )));
218 }
219
210 private: 220 private:
211 T m_x1; 221 T m_x1;
212 T m_x2; 222 T m_x2;
213 223
214 static bool shapeIntervalsAreSortedAndDisjoint(const ShapeIntervals& interva ls) 224 static bool shapeIntervalsAreSortedAndDisjoint(const ShapeIntervals& interva ls)
215 { 225 {
216 for (unsigned i = 1; i < intervals.size(); i++) { 226 for (unsigned i = 1; i < intervals.size(); i++) {
217 if (intervals[i - 1].x2() > intervals[i].x1()) 227 if (intervals[i - 1].x2() > intervals[i].x1())
218 return false; 228 return false;
219 } 229 }
220 230
221 return true; 231 return true;
222 } 232 }
223 }; 233 };
224 234
225 typedef ShapeInterval<int> IntShapeInterval; 235 typedef ShapeInterval<int> IntShapeInterval;
226 typedef ShapeInterval<float> FloatShapeInterval; 236 typedef ShapeInterval<float> FloatShapeInterval;
227 237
228 typedef Vector<IntShapeInterval> IntShapeIntervals; 238 typedef Vector<IntShapeInterval> IntShapeIntervals;
229 typedef Vector<FloatShapeInterval> FloatShapeIntervals; 239 typedef Vector<FloatShapeInterval> FloatShapeIntervals;
230 240
231 } // namespace WebCore 241 } // namespace WebCore
232 242
233 #endif // ShapeInterval_h 243 #endif // ShapeInterval_h
OLDNEW
« no previous file with comments | « Source/core/rendering/shapes/Shape.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698