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

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

Issue 264453009: [CSS Shapes] shape-outside polygon can fail when line-top intersects a vertex (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Remove -webkit-font-smoothing Created 6 years, 7 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
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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 if (y == minY()) 62 if (y == minY())
63 return vertex1().y() < vertex2().y() ? vertex1().x() : vertex2().x(); 63 return vertex1().y() < vertex2().y() ? vertex1().x() : vertex2().x();
64 if (y == maxY()) 64 if (y == maxY())
65 return vertex1().y() > vertex2().y() ? vertex1().x() : vertex2().x(); 65 return vertex1().y() > vertex2().y() ? vertex1().x() : vertex2().x();
66 66
67 return vertex1().x() + ((y - vertex1().y()) * (vertex2().x() - vertex1().x() ) / (vertex2().y() - vertex1().y())); 67 return vertex1().x() + ((y - vertex1().y()) * (vertex2().x() - vertex1().x() ) / (vertex2().y() - vertex1().y()));
68 } 68 }
69 69
70 FloatShapeInterval OffsetPolygonEdge::clippedEdgeXRange(float y1, float y2) cons t 70 FloatShapeInterval OffsetPolygonEdge::clippedEdgeXRange(float y1, float y2) cons t
71 { 71 {
72 if (!overlapsYRange(y1, y2)) 72 if (!overlapsYRange(y1, y2) || (y1 == maxY() && vertex2().y() < vertex1().y( )))
73 return FloatShapeInterval(); 73 return FloatShapeInterval();
74 74
75 if (isWithinYRange(y1, y2)) 75 if (isWithinYRange(y1, y2))
76 return FloatShapeInterval(minX(), maxX()); 76 return FloatShapeInterval(minX(), maxX());
77 77
78 // Clip the edge line segment to the vertical range y1,y2 and then return 78 // Clip the edge line segment to the vertical range y1,y2 and then return
79 // the clipped line segment's horizontal range. 79 // the clipped line segment's horizontal range.
80 80
81 FloatPoint minYVertex; 81 FloatPoint minYVertex;
82 FloatPoint maxYVertex; 82 FloatPoint maxYVertex;
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 if (m_polygon.isEmpty() || !overlapsYRange(m_polygon.boundingBox(), y1 - sha peMargin(), y2 + shapeMargin())) 128 if (m_polygon.isEmpty() || !overlapsYRange(m_polygon.boundingBox(), y1 - sha peMargin(), y2 + shapeMargin()))
129 return; 129 return;
130 130
131 Vector<const FloatPolygonEdge*> overlappingEdges; 131 Vector<const FloatPolygonEdge*> overlappingEdges;
132 if (!m_polygon.overlappingEdges(y1 - shapeMargin(), y2 + shapeMargin(), over lappingEdges)) 132 if (!m_polygon.overlappingEdges(y1 - shapeMargin(), y2 + shapeMargin(), over lappingEdges))
133 return; 133 return;
134 134
135 FloatShapeInterval excludedInterval; 135 FloatShapeInterval excludedInterval;
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())
139 continue;
138 if (!shapeMargin()) { 140 if (!shapeMargin()) {
139 excludedInterval.unite(OffsetPolygonEdge(edge, FloatSize()).clippedE dgeXRange(y1, y2)); 141 excludedInterval.unite(OffsetPolygonEdge(edge, FloatSize()).clippedE dgeXRange(y1, y2));
140 } else { 142 } else {
141 excludedInterval.unite(OffsetPolygonEdge(edge, outwardEdgeNormal(edg e) * shapeMargin()).clippedEdgeXRange(y1, y2)); 143 excludedInterval.unite(OffsetPolygonEdge(edge, outwardEdgeNormal(edg e) * shapeMargin()).clippedEdgeXRange(y1, y2));
142 excludedInterval.unite(OffsetPolygonEdge(edge, inwardEdgeNormal(edge ) * shapeMargin()).clippedEdgeXRange(y1, y2)); 144 excludedInterval.unite(OffsetPolygonEdge(edge, inwardEdgeNormal(edge ) * shapeMargin()).clippedEdgeXRange(y1, y2));
143 excludedInterval.unite(clippedCircleXRange(edge.vertex1(), shapeMarg in(), y1, y2)); 145 excludedInterval.unite(clippedCircleXRange(edge.vertex1(), shapeMarg in(), y1, y2));
144 } 146 }
145 } 147 }
146 148
147 if (!excludedInterval.isEmpty()) 149 if (!excludedInterval.isEmpty())
148 result.append(LineSegment(excludedInterval.x1(), excludedInterval.x2())) ; 150 result.append(LineSegment(excludedInterval.x1(), excludedInterval.x2())) ;
149 } 151 }
150 152
151 } // namespace WebCore 153 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698