Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org> | 2 * Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org> |
| 3 * Copyright (C) 2004, 2005, 2008 Rob Buis <buis@kde.org> | 3 * Copyright (C) 2004, 2005, 2008 Rob Buis <buis@kde.org> |
| 4 * Copyright (C) 2005, 2007 Eric Seidel <eric@webkit.org> | 4 * Copyright (C) 2005, 2007 Eric Seidel <eric@webkit.org> |
| 5 * Copyright (C) 2009 Google, Inc. | 5 * Copyright (C) 2009 Google, Inc. |
| 6 * Copyright (C) 2009 Dirk Schulze <krit@webkit.org> | 6 * Copyright (C) 2009 Dirk Schulze <krit@webkit.org> |
| 7 * Copyright (C) Research In Motion Limited 2010. All rights reserved. | 7 * Copyright (C) Research In Motion Limited 2010. All rights reserved. |
| 8 * Copyright (C) 2009 Jeff Schiller <codedread@gmail.com> | 8 * Copyright (C) 2009 Jeff Schiller <codedread@gmail.com> |
| 9 * Copyright (C) 2011 Renata Hodovan <reni@webkit.org> | 9 * Copyright (C) 2011 Renata Hodovan <reni@webkit.org> |
| 10 * Copyright (C) 2011 University of Szeged | 10 * Copyright (C) 2011 University of Szeged |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 57 void RenderSVGShape::updateShapeFromElement() | 57 void RenderSVGShape::updateShapeFromElement() |
| 58 { | 58 { |
| 59 m_path.clear(); | 59 m_path.clear(); |
| 60 m_path = adoptPtr(new Path); | 60 m_path = adoptPtr(new Path); |
| 61 ASSERT(RenderSVGShape::isShapeEmpty()); | 61 ASSERT(RenderSVGShape::isShapeEmpty()); |
| 62 | 62 |
| 63 updatePathFromGraphicsElement(toSVGGraphicsElement(element()), path()); | 63 updatePathFromGraphicsElement(toSVGGraphicsElement(element()), path()); |
| 64 processMarkerPositions(); | 64 processMarkerPositions(); |
| 65 | 65 |
| 66 m_fillBoundingBox = calculateObjectBoundingBox(); | 66 m_fillBoundingBox = calculateObjectBoundingBox(); |
| 67 m_strokeBoundingBox = calculateStrokeBoundingBox(); | 67 m_hitTestStrokeBoundingBox = calculateHitTestStrokeBoundingBox(); |
| 68 m_strokeBoundingBox = style()->svgStyle().hasStroke() ? m_hitTestStrokeBound ingBox : m_fillBoundingBox; | |
| 68 } | 69 } |
| 69 | 70 |
| 70 bool RenderSVGShape::shapeDependentStrokeContains(const FloatPoint& point) | 71 bool RenderSVGShape::shapeDependentStrokeContains(const FloatPoint& point) |
| 71 { | 72 { |
| 72 ASSERT(m_path); | 73 ASSERT(m_path); |
| 73 StrokeData strokeData; | 74 StrokeData strokeData; |
| 74 SVGRenderSupport::applyStrokeStyleToStrokeData(&strokeData, style(), this); | 75 SVGRenderSupport::applyStrokeStyleToStrokeData(&strokeData, style(), this); |
| 75 | 76 |
| 76 if (hasNonScalingStroke()) { | 77 if (hasNonScalingStroke()) { |
| 77 AffineTransform nonScalingTransform = nonScalingStrokeTransform(); | 78 AffineTransform nonScalingTransform = nonScalingStrokeTransform(); |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 94 return false; | 95 return false; |
| 95 | 96 |
| 96 if (requiresFill && !SVGPaintServer::existsForRenderer(*this, style(), Apply ToFillMode)) | 97 if (requiresFill && !SVGPaintServer::existsForRenderer(*this, style(), Apply ToFillMode)) |
| 97 return false; | 98 return false; |
| 98 | 99 |
| 99 return shapeDependentFillContains(point, fillRule); | 100 return shapeDependentFillContains(point, fillRule); |
| 100 } | 101 } |
| 101 | 102 |
| 102 bool RenderSVGShape::strokeContains(const FloatPoint& point, bool requiresStroke ) | 103 bool RenderSVGShape::strokeContains(const FloatPoint& point, bool requiresStroke ) |
| 103 { | 104 { |
| 104 if (!strokeBoundingBox().contains(point)) | 105 if (requiresStroke) { |
| 105 return false; | 106 if (!strokeBoundingBox().contains(point)) |
| 107 return false; | |
| 108 } else { | |
| 109 if (!hitTestStrokeBoundingBox().contains(point)) | |
| 110 return false; | |
| 111 } | |
| 106 | 112 |
| 107 if (requiresStroke && !SVGPaintServer::existsForRenderer(*this, style(), App lyToStrokeMode)) | 113 if (requiresStroke && !SVGPaintServer::existsForRenderer(*this, style(), App lyToStrokeMode)) |
|
fs
2015/01/22 12:15:58
Suggest you move this into the commonly predicated
| |
| 108 return false; | 114 return false; |
| 109 | 115 |
| 110 return shapeDependentStrokeContains(point); | 116 return shapeDependentStrokeContains(point); |
| 111 } | 117 } |
| 112 | 118 |
| 113 void RenderSVGShape::updateLocalTransform() | 119 void RenderSVGShape::updateLocalTransform() |
| 114 { | 120 { |
| 115 SVGGraphicsElement* graphicsElement = toSVGGraphicsElement(element()); | 121 SVGGraphicsElement* graphicsElement = toSVGGraphicsElement(element()); |
| 116 if (graphicsElement->hasAnimatedLocalTransform()) { | 122 if (graphicsElement->hasAnimatedLocalTransform()) { |
| 117 if (m_localTransform) | 123 if (m_localTransform) |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 214 return true; | 220 return true; |
| 215 } | 221 } |
| 216 return false; | 222 return false; |
| 217 } | 223 } |
| 218 | 224 |
| 219 FloatRect RenderSVGShape::calculateObjectBoundingBox() const | 225 FloatRect RenderSVGShape::calculateObjectBoundingBox() const |
| 220 { | 226 { |
| 221 return path().boundingRect(); | 227 return path().boundingRect(); |
| 222 } | 228 } |
| 223 | 229 |
| 224 FloatRect RenderSVGShape::calculateStrokeBoundingBox() const | 230 FloatRect RenderSVGShape::calculateHitTestStrokeBoundingBox() const |
| 225 { | 231 { |
| 226 ASSERT(m_path); | 232 ASSERT(m_path); |
| 227 FloatRect strokeBoundingBox = m_fillBoundingBox; | 233 FloatRect strokeBoundingBox = m_fillBoundingBox; |
| 228 | 234 |
| 229 if (style()->svgStyle().hasStroke()) { | 235 StrokeData strokeData; |
| 230 StrokeData strokeData; | 236 SVGRenderSupport::applyStrokeStyleToStrokeData(&strokeData, style(), this); |
| 231 SVGRenderSupport::applyStrokeStyleToStrokeData(&strokeData, style(), thi s); | 237 if (hasNonScalingStroke()) { |
| 232 if (hasNonScalingStroke()) { | 238 AffineTransform nonScalingTransform = nonScalingStrokeTransform(); |
| 233 AffineTransform nonScalingTransform = nonScalingStrokeTransform(); | 239 if (nonScalingTransform.isInvertible()) { |
| 234 if (nonScalingTransform.isInvertible()) { | 240 Path* usePath = nonScalingStrokePath(m_path.get(), nonScalingTransfo rm); |
| 235 Path* usePath = nonScalingStrokePath(m_path.get(), nonScalingTra nsform); | 241 FloatRect strokeBoundingRect = usePath->strokeBoundingRect(strokeDat a); |
| 236 FloatRect strokeBoundingRect = usePath->strokeBoundingRect(strok eData); | 242 strokeBoundingRect = nonScalingTransform.inverse().mapRect(strokeBou ndingRect); |
| 237 strokeBoundingRect = nonScalingTransform.inverse().mapRect(strok eBoundingRect); | 243 strokeBoundingBox.unite(strokeBoundingRect); |
| 238 strokeBoundingBox.unite(strokeBoundingRect); | |
| 239 } | |
| 240 } else { | |
| 241 strokeBoundingBox.unite(path().strokeBoundingRect(strokeData)); | |
| 242 } | 244 } |
| 245 } else { | |
| 246 strokeBoundingBox.unite(path().strokeBoundingRect(strokeData)); | |
| 243 } | 247 } |
| 244 | 248 |
| 245 return strokeBoundingBox; | 249 return strokeBoundingBox; |
| 246 } | 250 } |
| 247 | 251 |
| 248 void RenderSVGShape::updatePaintInvalidationBoundingBox() | 252 void RenderSVGShape::updatePaintInvalidationBoundingBox() |
| 249 { | 253 { |
| 250 m_paintInvalidationBoundingBox = strokeBoundingBox(); | 254 m_paintInvalidationBoundingBox = strokeBoundingBox(); |
| 251 if (strokeWidth() < 1.0f && !m_paintInvalidationBoundingBox.isEmpty()) | 255 if (strokeWidth() < 1.0f && !m_paintInvalidationBoundingBox.isEmpty()) |
| 252 m_paintInvalidationBoundingBox.inflate(1); | 256 m_paintInvalidationBoundingBox.inflate(1); |
| 253 SVGRenderSupport::intersectPaintInvalidationRectWithResources(this, m_paintI nvalidationBoundingBox); | 257 SVGRenderSupport::intersectPaintInvalidationRectWithResources(this, m_paintI nvalidationBoundingBox); |
| 254 } | 258 } |
| 255 | 259 |
| 256 float RenderSVGShape::strokeWidth() const | 260 float RenderSVGShape::strokeWidth() const |
| 257 { | 261 { |
| 258 SVGLengthContext lengthContext(element()); | 262 SVGLengthContext lengthContext(element()); |
| 259 return style()->svgStyle().strokeWidth()->value(lengthContext); | 263 return style()->svgStyle().strokeWidth()->value(lengthContext); |
| 260 } | 264 } |
| 261 | 265 |
| 262 } | 266 } |
| OLD | NEW |