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

Side by Side Diff: Source/core/rendering/ExclusionPolygon.cpp

Issue 14289003: [CSS Exclusions] Zoom causes shape-inside to fail when shape-padding is specified (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 7 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 | « LayoutTests/fast/exclusions/shape-inside/shape-inside-polygon-zoom-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 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 float angle5 = ((padding) ? -angle : twoPI - angle) / arcSegmentCount; 122 float angle5 = ((padding) ? -angle : twoPI - angle) / arcSegmentCount;
123 123
124 vertices.append(startArcVertex); 124 vertices.append(startArcVertex);
125 for (unsigned i = 1; i < arcSegmentCount; ++i) { 125 for (unsigned i = 1; i < arcSegmentCount; ++i) {
126 float angle = startAngle + angle5 * i; 126 float angle = startAngle + angle5 * i;
127 vertices.append(arcCenter + FloatPoint(cos(angle) * arcRadius, sin(angle ) * arcRadius)); 127 vertices.append(arcCenter + FloatPoint(cos(angle) * arcRadius, sin(angle ) * arcRadius));
128 } 128 }
129 vertices.append(endArcVertex); 129 vertices.append(endArcVertex);
130 } 130 }
131 131
132 static inline void snapVerticesToLayoutUnitGrid(Vector<FloatPoint>& vertices)
Julien - ping for review 2013/04/23 17:09:04 Wouldn't it make more sense to have your vertices
leviw_travelin_and_unemployed 2013/04/23 18:27:20 For the record, I agree that since this issue show
133 {
134 for (unsigned i = 0; i < vertices.size(); ++i)
135 vertices[i].set(LayoutUnit(vertices[i].x()).toFloat(), LayoutUnit(vertic es[i].y()).toFloat());
Julien - ping for review 2013/04/23 17:09:04 Note that this could (and will) yield to big round
136 }
137
132 static inline FloatPolygon* computeShapePaddingBounds(const FloatPolygon& polygo n, float padding, WindRule fillRule) 138 static inline FloatPolygon* computeShapePaddingBounds(const FloatPolygon& polygo n, float padding, WindRule fillRule)
133 { 139 {
134 Vector<FloatPoint>* paddedVertices = new Vector<FloatPoint>(); 140 Vector<FloatPoint>* paddedVertices = new Vector<FloatPoint>();
135 FloatPoint intersection; 141 FloatPoint intersection;
136 142
137 for (unsigned i = 0; i < polygon.numberOfEdges(); ++i) { 143 for (unsigned i = 0; i < polygon.numberOfEdges(); ++i) {
138 const FloatPolygonEdge& thisEdge = polygon.edgeAt(i); 144 const FloatPolygonEdge& thisEdge = polygon.edgeAt(i);
139 const FloatPolygonEdge& prevEdge = thisEdge.previousEdge(); 145 const FloatPolygonEdge& prevEdge = thisEdge.previousEdge();
140 OffsetPolygonEdge thisOffsetEdge(thisEdge, inwardEdgeNormal(thisEdge) * padding); 146 OffsetPolygonEdge thisOffsetEdge(thisEdge, inwardEdgeNormal(thisEdge) * padding);
141 OffsetPolygonEdge prevOffsetEdge(prevEdge, inwardEdgeNormal(prevEdge) * padding); 147 OffsetPolygonEdge prevOffsetEdge(prevEdge, inwardEdgeNormal(prevEdge) * padding);
142 148
143 if (prevOffsetEdge.intersection(thisOffsetEdge, intersection)) 149 if (prevOffsetEdge.intersection(thisOffsetEdge, intersection))
144 paddedVertices->append(intersection); 150 paddedVertices->append(intersection);
145 else if (isReflexVertex(prevEdge.vertex1(), thisEdge.vertex1(), thisEdge .vertex2())) 151 else if (isReflexVertex(prevEdge.vertex1(), thisEdge.vertex1(), thisEdge .vertex2()))
146 appendArc(*paddedVertices, thisEdge.vertex1(), padding, prevOffsetEd ge.vertex2(), thisOffsetEdge.vertex1(), true); 152 appendArc(*paddedVertices, thisEdge.vertex1(), padding, prevOffsetEd ge.vertex2(), thisOffsetEdge.vertex1(), true);
147 } 153 }
148 154
155 snapVerticesToLayoutUnitGrid(*paddedVertices);
149 return new FloatPolygon(adoptPtr(paddedVertices), fillRule); 156 return new FloatPolygon(adoptPtr(paddedVertices), fillRule);
150 } 157 }
151 158
152 static inline FloatPolygon* computeShapeMarginBounds(const FloatPolygon& polygon , float margin, WindRule fillRule) 159 static inline FloatPolygon* computeShapeMarginBounds(const FloatPolygon& polygon , float margin, WindRule fillRule)
153 { 160 {
154 Vector<FloatPoint>* marginVertices = new Vector<FloatPoint>(); 161 Vector<FloatPoint>* marginVertices = new Vector<FloatPoint>();
155 FloatPoint intersection; 162 FloatPoint intersection;
156 163
157 for (unsigned i = 0; i < polygon.numberOfEdges(); ++i) { 164 for (unsigned i = 0; i < polygon.numberOfEdges(); ++i) {
158 const FloatPolygonEdge& thisEdge = polygon.edgeAt(i); 165 const FloatPolygonEdge& thisEdge = polygon.edgeAt(i);
159 const FloatPolygonEdge& prevEdge = thisEdge.previousEdge(); 166 const FloatPolygonEdge& prevEdge = thisEdge.previousEdge();
160 OffsetPolygonEdge thisOffsetEdge(thisEdge, outwardEdgeNormal(thisEdge) * margin); 167 OffsetPolygonEdge thisOffsetEdge(thisEdge, outwardEdgeNormal(thisEdge) * margin);
161 OffsetPolygonEdge prevOffsetEdge(prevEdge, outwardEdgeNormal(prevEdge) * margin); 168 OffsetPolygonEdge prevOffsetEdge(prevEdge, outwardEdgeNormal(prevEdge) * margin);
162 169
163 if (prevOffsetEdge.intersection(thisOffsetEdge, intersection)) 170 if (prevOffsetEdge.intersection(thisOffsetEdge, intersection))
164 marginVertices->append(intersection); 171 marginVertices->append(intersection);
165 else 172 else
166 appendArc(*marginVertices, thisEdge.vertex1(), margin, prevOffsetEdg e.vertex2(), thisOffsetEdge.vertex1(), false); 173 appendArc(*marginVertices, thisEdge.vertex1(), margin, prevOffsetEdg e.vertex2(), thisOffsetEdge.vertex1(), false);
167 } 174 }
168 175
176 snapVerticesToLayoutUnitGrid(*marginVertices);
169 return new FloatPolygon(adoptPtr(marginVertices), fillRule); 177 return new FloatPolygon(adoptPtr(marginVertices), fillRule);
170 } 178 }
171 179
172 const FloatPolygon& ExclusionPolygon::shapePaddingBounds() const 180 const FloatPolygon& ExclusionPolygon::shapePaddingBounds() const
173 { 181 {
174 ASSERT(shapePadding() >= 0); 182 ASSERT(shapePadding() >= 0);
175 if (!shapePadding()) 183 if (!shapePadding())
176 return m_polygon; 184 return m_polygon;
177 185
178 if (!m_paddingBounds) 186 if (!m_paddingBounds)
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
489 } 497 }
490 } 498 }
491 } 499 }
492 500
493 if (firstFitFound) 501 if (firstFitFound)
494 result = firstFitRect.y(); 502 result = firstFitRect.y();
495 return firstFitFound; 503 return firstFitFound;
496 } 504 }
497 505
498 } // namespace WebCore 506 } // namespace WebCore
OLDNEW
« no previous file with comments | « LayoutTests/fast/exclusions/shape-inside/shape-inside-polygon-zoom-expected.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698