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

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

Issue 22877029: Introduce toSVGEllipseElement(), and use it (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 7 years, 4 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 | Source/core/rendering/svg/SVGPathData.cpp » ('j') | 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 Google, Inc. 2 * Copyright (C) 2012 Google, Inc.
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 80
81 SVGCircleElement* circle = static_cast<SVGCircleElement*>(node()); 81 SVGCircleElement* circle = static_cast<SVGCircleElement*>(node());
82 82
83 SVGLengthContext lengthContext(circle); 83 SVGLengthContext lengthContext(circle);
84 float radius = circle->rCurrentValue().value(lengthContext); 84 float radius = circle->rCurrentValue().value(lengthContext);
85 m_radii = FloatSize(radius, radius); 85 m_radii = FloatSize(radius, radius);
86 m_center = FloatPoint(circle->cxCurrentValue().value(lengthContext), cir cle->cyCurrentValue().value(lengthContext)); 86 m_center = FloatPoint(circle->cxCurrentValue().value(lengthContext), cir cle->cyCurrentValue().value(lengthContext));
87 return; 87 return;
88 } 88 }
89 89
90 ASSERT(node()->hasTagName(SVGNames::ellipseTag)); 90 SVGEllipseElement* ellipse = toSVGEllipseElement(node());
91 SVGEllipseElement* ellipse = static_cast<SVGEllipseElement*>(node());
92 91
93 SVGLengthContext lengthContext(ellipse); 92 SVGLengthContext lengthContext(ellipse);
94 m_radii = FloatSize(ellipse->rxCurrentValue().value(lengthContext), ellipse- >ryCurrentValue().value(lengthContext)); 93 m_radii = FloatSize(ellipse->rxCurrentValue().value(lengthContext), ellipse- >ryCurrentValue().value(lengthContext));
95 m_center = FloatPoint(ellipse->cxCurrentValue().value(lengthContext), ellips e->cyCurrentValue().value(lengthContext)); 94 m_center = FloatPoint(ellipse->cxCurrentValue().value(lengthContext), ellips e->cyCurrentValue().value(lengthContext));
96 } 95 }
97 96
98 void RenderSVGEllipse::fillShape(GraphicsContext* context) const 97 void RenderSVGEllipse::fillShape(GraphicsContext* context) const
99 { 98 {
100 if (m_usePathFallback) { 99 if (m_usePathFallback) {
101 RenderSVGShape::fillShape(context); 100 RenderSVGShape::fillShape(context);
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 FloatPoint center = FloatPoint(m_center.x() - point.x(), m_center.y() - poin t.y()); 147 FloatPoint center = FloatPoint(m_center.x() - point.x(), m_center.y() - poin t.y());
149 148
150 // This works by checking if the point satisfies the ellipse equation. 149 // This works by checking if the point satisfies the ellipse equation.
151 // (x/rX)^2 + (y/rY)^2 <= 1 150 // (x/rX)^2 + (y/rY)^2 <= 1
152 float xrX = center.x() / m_radii.width(); 151 float xrX = center.x() / m_radii.width();
153 float yrY = center.y() / m_radii.height(); 152 float yrY = center.y() / m_radii.height();
154 return xrX * xrX + yrY * yrY <= 1.0; 153 return xrX * xrX + yrY * yrY <= 1.0;
155 } 154 }
156 155
157 } 156 }
OLDNEW
« no previous file with comments | « no previous file | Source/core/rendering/svg/SVGPathData.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698