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

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

Issue 510513002: [CSS Shapes] Import and fix polygon shapes reftests (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Remove webkit prefixes Created 6 years, 3 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 | « LayoutTests/fast/shapes/shape-outside-floats/shape-outside-polygon-015-expected.html ('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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 } 93 }
94 94
95 static float circleXIntercept(float y, float radius) 95 static float circleXIntercept(float y, float radius)
96 { 96 {
97 ASSERT(radius > 0); 97 ASSERT(radius > 0);
98 return radius * sqrt(1 - (y * y) / (radius * radius)); 98 return radius * sqrt(1 - (y * y) / (radius * radius));
99 } 99 }
100 100
101 static FloatShapeInterval clippedCircleXRange(const FloatPoint& center, float ra dius, float y1, float y2) 101 static FloatShapeInterval clippedCircleXRange(const FloatPoint& center, float ra dius, float y1, float y2)
102 { 102 {
103 if (y1 > center.y() + radius || y2 < center.y() - radius) 103 if (y1 >= center.y() + radius || y2 <= center.y() - radius)
104 return FloatShapeInterval(); 104 return FloatShapeInterval();
105 105
106 if (center.y() >= y1 && center.y() <= y2) 106 if (center.y() >= y1 && center.y() <= y2)
107 return FloatShapeInterval(center.x() - radius, center.x() + radius); 107 return FloatShapeInterval(center.x() - radius, center.x() + radius);
108 108
109 // Clip the circle to the vertical range y1,y2 and return the extent of the clipped circle's 109 // Clip the circle to the vertical range y1,y2 and return the extent of the clipped circle's
110 // projection on the X axis 110 // projection on the X axis
111 111
112 float xi = circleXIntercept((y2 < center.y() ? y2 : y1) - center.y(), radiu s); 112 float xi = circleXIntercept((y2 < center.y() ? y2 : y1) - center.y(), radiu s);
113 return FloatShapeInterval(center.x() - xi, center.x() + xi); 113 return FloatShapeInterval(center.x() - xi, center.x() + xi);
(...skipping 22 matching lines...) Expand all
136 for (unsigned i = 0; i < overlappingEdges.size(); i++) { 136 for (unsigned i = 0; i < overlappingEdges.size(); i++) {
137 const FloatPolygonEdge& edge = *(overlappingEdges[i]); 137 const FloatPolygonEdge& edge = *(overlappingEdges[i]);
138 if (edge.maxY() == edge.minY()) 138 if (edge.maxY() == edge.minY())
139 continue; 139 continue;
140 if (!shapeMargin()) { 140 if (!shapeMargin()) {
141 excludedInterval.unite(OffsetPolygonEdge(edge, FloatSize()).clippedE dgeXRange(y1, y2)); 141 excludedInterval.unite(OffsetPolygonEdge(edge, FloatSize()).clippedE dgeXRange(y1, y2));
142 } else { 142 } else {
143 excludedInterval.unite(OffsetPolygonEdge(edge, outwardEdgeNormal(edg e) * shapeMargin()).clippedEdgeXRange(y1, y2)); 143 excludedInterval.unite(OffsetPolygonEdge(edge, outwardEdgeNormal(edg e) * shapeMargin()).clippedEdgeXRange(y1, y2));
144 excludedInterval.unite(OffsetPolygonEdge(edge, inwardEdgeNormal(edge ) * shapeMargin()).clippedEdgeXRange(y1, y2)); 144 excludedInterval.unite(OffsetPolygonEdge(edge, inwardEdgeNormal(edge ) * shapeMargin()).clippedEdgeXRange(y1, y2));
145 excludedInterval.unite(clippedCircleXRange(edge.vertex1(), shapeMarg in(), y1, y2)); 145 excludedInterval.unite(clippedCircleXRange(edge.vertex1(), shapeMarg in(), y1, y2));
146 excludedInterval.unite(clippedCircleXRange(edge.vertex2(), shapeMarg in(), y1, y2));
146 } 147 }
147 } 148 }
148 149
149 if (excludedInterval.isEmpty()) 150 if (excludedInterval.isEmpty())
150 return LineSegment(); 151 return LineSegment();
151 152
152 return LineSegment(excludedInterval.x1(), excludedInterval.x2()); 153 return LineSegment(excludedInterval.x1(), excludedInterval.x2());
153 } 154 }
154 155
155 void PolygonShape::buildDisplayPaths(DisplayPaths& paths) const 156 void PolygonShape::buildDisplayPaths(DisplayPaths& paths) const
156 { 157 {
157 if (!m_polygon.numberOfVertices()) 158 if (!m_polygon.numberOfVertices())
158 return; 159 return;
159 paths.shape.moveTo(m_polygon.vertexAt(0)); 160 paths.shape.moveTo(m_polygon.vertexAt(0));
160 for (size_t i = 1; i < m_polygon.numberOfVertices(); ++i) 161 for (size_t i = 1; i < m_polygon.numberOfVertices(); ++i)
161 paths.shape.addLineTo(m_polygon.vertexAt(i)); 162 paths.shape.addLineTo(m_polygon.vertexAt(i));
162 paths.shape.closeSubpath(); 163 paths.shape.closeSubpath();
163 } 164 }
164 165
165 } // namespace blink 166 } // namespace blink
OLDNEW
« no previous file with comments | « LayoutTests/fast/shapes/shape-outside-floats/shape-outside-polygon-015-expected.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698