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

Side by Side Diff: Source/core/layout/svg/LayoutSVGRect.cpp

Issue 966923003: Make SVGLengthMode an enum class (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 9 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 | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011 University of Szeged 2 * Copyright (C) 2011 University of Szeged
3 * Copyright (C) 2011 Renata Hodovan <reni@webkit.org> 3 * Copyright (C) 2011 Renata Hodovan <reni@webkit.org>
4 * All rights reserved. 4 * All rights reserved.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 FloatSize boundingBoxSize(rect->width()->currentValue()->value(lengthContext ), rect->height()->currentValue()->value(lengthContext)); 57 FloatSize boundingBoxSize(rect->width()->currentValue()->value(lengthContext ), rect->height()->currentValue()->value(lengthContext));
58 58
59 // Spec: "A negative value is an error." 59 // Spec: "A negative value is an error."
60 if (boundingBoxSize.width() < 0 || boundingBoxSize.height() < 0) 60 if (boundingBoxSize.width() < 0 || boundingBoxSize.height() < 0)
61 return; 61 return;
62 62
63 // Spec: "A value of zero disables rendering of the element." 63 // Spec: "A value of zero disables rendering of the element."
64 if (!boundingBoxSize.isEmpty()) { 64 if (!boundingBoxSize.isEmpty()) {
65 // Fallback to LayoutSVGShape and path-based hit detection if the rect 65 // Fallback to LayoutSVGShape and path-based hit detection if the rect
66 // has rounded corners or a non-scaling or non-simple stroke. 66 // has rounded corners or a non-scaling or non-simple stroke.
67 if (lengthContext.valueForLength(style()->svgStyle().rx(), styleRef(), L engthModeWidth) > 0 67 if (lengthContext.valueForLength(style()->svgStyle().rx(), styleRef(), S VGLengthMode::Width) > 0
68 || lengthContext.valueForLength(style()->svgStyle().ry(), styleRef() , LengthModeHeight) > 0 68 || lengthContext.valueForLength(style()->svgStyle().ry(), styleRef() , SVGLengthMode::Height) > 0
69 || hasNonScalingStroke() 69 || hasNonScalingStroke()
70 || !definitelyHasSimpleStroke()) { 70 || !definitelyHasSimpleStroke()) {
71 LayoutSVGShape::updateShapeFromElement(); 71 LayoutSVGShape::updateShapeFromElement();
72 m_usePathFallback = true; 72 m_usePathFallback = true;
73 return; 73 return;
74 } 74 }
75 } 75 }
76 76
77 m_fillBoundingBox = FloatRect( 77 m_fillBoundingBox = FloatRect(
78 FloatPoint( 78 FloatPoint(
79 lengthContext.valueForLength(styleRef().svgStyle().x(), styleRef(), LengthModeWidth), 79 lengthContext.valueForLength(styleRef().svgStyle().x(), styleRef(), SVGLengthMode::Width),
80 lengthContext.valueForLength(styleRef().svgStyle().y(), styleRef(), LengthModeHeight)), 80 lengthContext.valueForLength(styleRef().svgStyle().y(), styleRef(), SVGLengthMode::Height)),
81 boundingBoxSize); 81 boundingBoxSize);
82 82
83 // To decide if the stroke contains a point we create two rects which repres ent the inner and 83 // To decide if the stroke contains a point we create two rects which repres ent the inner and
84 // the outer stroke borders. A stroke contains the point, if the point is be tween them. 84 // the outer stroke borders. A stroke contains the point, if the point is be tween them.
85 m_innerStrokeRect = m_fillBoundingBox; 85 m_innerStrokeRect = m_fillBoundingBox;
86 m_outerStrokeRect = m_fillBoundingBox; 86 m_outerStrokeRect = m_fillBoundingBox;
87 87
88 if (style()->svgStyle().hasStroke()) { 88 if (style()->svgStyle().hasStroke()) {
89 float strokeWidth = this->strokeWidth(); 89 float strokeWidth = this->strokeWidth();
90 m_innerStrokeRect.inflate(-strokeWidth / 2); 90 m_innerStrokeRect.inflate(-strokeWidth / 2);
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 // An approximation of sqrt(2) is used here because at certain precise 134 // An approximation of sqrt(2) is used here because at certain precise
135 // miterlimits, the join style used might not be correct (e.g. a miterlimit 135 // miterlimits, the join style used might not be correct (e.g. a miterlimit
136 // of 1.4142135 should result in bevel joins, but may be drawn using miter 136 // of 1.4142135 should result in bevel joins, but may be drawn using miter
137 // joins). 137 // joins).
138 return svgStyle.strokeDashArray()->isEmpty() 138 return svgStyle.strokeDashArray()->isEmpty()
139 && svgStyle.joinStyle() == MiterJoin 139 && svgStyle.joinStyle() == MiterJoin
140 && svgStyle.strokeMiterLimit() >= 1.5; 140 && svgStyle.strokeMiterLimit() >= 1.5;
141 } 141 }
142 142
143 } 143 }
OLDNEW
« no previous file with comments | « Source/core/animation/animatable/AnimatableValueTestHelperTest.cpp ('k') | Source/core/layout/svg/SVGPathData.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698