Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2004, 2005, 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org> | 2 * Copyright (C) 2004, 2005, 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org> |
| 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Rob Buis <buis@kde.org> | 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Rob Buis <buis@kde.org> |
| 4 * Copyright (C) Research In Motion Limited 2009-2010. All rights reserved. | 4 * Copyright (C) Research In Motion Limited 2009-2010. All rights reserved. |
| 5 * | 5 * |
| 6 * This library is free software; you can redistribute it and/or | 6 * This library is free software; you can redistribute it and/or |
| 7 * modify it under the terms of the GNU Library General Public | 7 * modify it under the terms of the GNU Library General Public |
| 8 * License as published by the Free Software Foundation; either | 8 * License as published by the Free Software Foundation; either |
| 9 * version 2 of the License, or (at your option) any later version. | 9 * version 2 of the License, or (at your option) any later version. |
| 10 * | 10 * |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 58 void LayoutSVGResourceMarker::removeClientFromCache(LayoutObject* client, bool m arkForInvalidation) | 58 void LayoutSVGResourceMarker::removeClientFromCache(LayoutObject* client, bool m arkForInvalidation) |
| 59 { | 59 { |
| 60 ASSERT(client); | 60 ASSERT(client); |
| 61 markClientForInvalidation(client, markForInvalidation ? BoundariesInvalidati on : ParentOnlyInvalidation); | 61 markClientForInvalidation(client, markForInvalidation ? BoundariesInvalidati on : ParentOnlyInvalidation); |
| 62 } | 62 } |
| 63 | 63 |
| 64 FloatRect LayoutSVGResourceMarker::markerBoundaries(const AffineTransform& marke rTransformation) const | 64 FloatRect LayoutSVGResourceMarker::markerBoundaries(const AffineTransform& marke rTransformation) const |
| 65 { | 65 { |
| 66 FloatRect coordinates = LayoutSVGContainer::paintInvalidationRectInLocalSVGC oordinates(); | 66 FloatRect coordinates = LayoutSVGContainer::paintInvalidationRectInLocalSVGC oordinates(); |
| 67 | 67 |
| 68 // Map paint invalidation rect into parent coordinate space, in which the ma rker boundaries have to be evaluated | 68 // Map paint invalidation rect into parent coordinate space, in which the |
| 69 // marker boundaries have to be evaluated. | |
| 69 coordinates = localToSVGParentTransform().mapRect(coordinates); | 70 coordinates = localToSVGParentTransform().mapRect(coordinates); |
| 70 | 71 |
| 71 return markerTransformation.mapRect(coordinates); | 72 return markerTransformation.mapRect(coordinates); |
| 72 } | 73 } |
| 73 | 74 |
| 74 const AffineTransform& LayoutSVGResourceMarker::localToSVGParentTransform() cons t | 75 const AffineTransform& LayoutSVGResourceMarker::localToSVGParentTransform() cons t |
| 75 { | 76 { |
| 76 m_localToParentTransform = AffineTransform::translation(m_viewport.x(), m_vi ewport.y()) * viewportTransform(); | 77 m_localToParentTransform = AffineTransform::translation(m_viewport.x(), m_vi ewport.y()) * viewportTransform(); |
| 77 return m_localToParentTransform; | 78 return m_localToParentTransform; |
| 78 // If this class were ever given a localTransform(), then the above would re ad: | 79 // If this class were ever given a localTransform(), then the above would re ad: |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 98 return toSVGMarkerElement(element())->markerUnits()->currentValue()->enumVal ue(); | 99 return toSVGMarkerElement(element())->markerUnits()->currentValue()->enumVal ue(); |
| 99 } | 100 } |
| 100 | 101 |
| 101 SVGMarkerOrientType LayoutSVGResourceMarker::orientType() const | 102 SVGMarkerOrientType LayoutSVGResourceMarker::orientType() const |
| 102 { | 103 { |
| 103 return toSVGMarkerElement(element())->orientType()->currentValue()->enumValu e(); | 104 return toSVGMarkerElement(element())->orientType()->currentValue()->enumValu e(); |
| 104 } | 105 } |
| 105 | 106 |
| 106 AffineTransform LayoutSVGResourceMarker::markerTransformation(const FloatPoint& origin, float autoAngle, float strokeWidth) const | 107 AffineTransform LayoutSVGResourceMarker::markerTransformation(const FloatPoint& origin, float autoAngle, float strokeWidth) const |
| 107 { | 108 { |
| 108 bool useStrokeWidth = markerUnits() == SVGMarkerUnitsStrokeWidth; | 109 // Apply scaling according to markerUnits ('strokeWidth' or 'userSpaceOnUse' .) |
| 110 float markerScale = markerUnits() == SVGMarkerUnitsStrokeWidth ? strokeWidth : 1; | |
| 109 | 111 |
| 110 AffineTransform transform; | 112 AffineTransform transform; |
| 111 transform.translate(origin.x(), origin.y()); | 113 transform.translate(origin.x(), origin.y()); |
| 112 transform.rotate(orientType() == SVGMarkerOrientAngle ? angle() : autoAngle) ; | 114 transform.rotate(orientType() == SVGMarkerOrientAngle ? angle() : autoAngle) ; |
| 113 transform = markerContentTransformation(transform, referencePoint(), useStro keWidth ? strokeWidth : -1); | 115 return markerContentTransformation(transform, referencePoint(), markerScale) ; |
|
f(malita)
2016/04/27 14:15:17
nit: markerContentTransformation concats scale(mar
fs
2016/04/27 14:27:01
Yeah, folding it makes sense. Done.
| |
| 114 return transform; | |
| 115 } | 116 } |
| 116 | 117 |
| 117 AffineTransform LayoutSVGResourceMarker::markerContentTransformation(const Affin eTransform& contentTransformation, const FloatPoint& origin, float strokeWidth) const | 118 bool LayoutSVGResourceMarker::shouldPaint() const |
| 118 { | 119 { |
| 119 // The 'origin' coordinate maps to SVGs refX/refY, given in coordinates rela tive to the viewport established by the marker | 120 // An empty viewBox disables rendering. |
| 121 SVGMarkerElement* marker = toSVGMarkerElement(element()); | |
| 122 ASSERT(marker); | |
| 123 return !marker->viewBox()->isSpecified() | |
| 124 || !marker->viewBox()->currentValue()->isValid() | |
| 125 || !marker->viewBox()->currentValue()->value().isEmpty(); | |
| 126 } | |
| 127 | |
| 128 AffineTransform LayoutSVGResourceMarker::markerContentTransformation( | |
| 129 const AffineTransform& contentTransformation, const FloatPoint& origin, floa t markerScale) const | |
| 130 { | |
| 131 // The 'origin' coordinate maps to SVGs refX/refY, given in coordinates | |
| 132 // relative to the viewport established by the marker. | |
| 120 FloatPoint mappedOrigin = viewportTransform().mapPoint(origin); | 133 FloatPoint mappedOrigin = viewportTransform().mapPoint(origin); |
| 121 | 134 |
| 122 AffineTransform transformation = contentTransformation; | 135 AffineTransform transformation = contentTransformation; |
| 123 if (strokeWidth != -1) | 136 transformation.scale(markerScale); |
| 124 transformation.scaleNonUniform(strokeWidth, strokeWidth); | |
| 125 | |
| 126 transformation.translate(-mappedOrigin.x(), -mappedOrigin.y()); | 137 transformation.translate(-mappedOrigin.x(), -mappedOrigin.y()); |
| 127 return transformation; | 138 return transformation; |
| 128 } | 139 } |
| 129 | 140 |
| 130 AffineTransform LayoutSVGResourceMarker::viewportTransform() const | 141 AffineTransform LayoutSVGResourceMarker::viewportTransform() const |
| 131 { | 142 { |
| 132 SVGMarkerElement* marker = toSVGMarkerElement(element()); | 143 SVGMarkerElement* marker = toSVGMarkerElement(element()); |
| 133 ASSERT(marker); | 144 ASSERT(marker); |
| 134 | 145 |
| 135 return marker->viewBoxToViewTransform(m_viewport.width(), m_viewport.height( )); | 146 return marker->viewBoxToViewTransform(m_viewport.width(), m_viewport.height( )); |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 151 | 162 |
| 152 bool LayoutSVGResourceMarker::calculateLocalTransform() | 163 bool LayoutSVGResourceMarker::calculateLocalTransform() |
| 153 { | 164 { |
| 154 // TODO(fs): Temporarily, needing a layout implies that the local transform | 165 // TODO(fs): Temporarily, needing a layout implies that the local transform |
| 155 // has changed. This should be updated to be more precise and factor in the | 166 // has changed. This should be updated to be more precise and factor in the |
| 156 // actual (relevant) changes to the computed user-space transform. | 167 // actual (relevant) changes to the computed user-space transform. |
| 157 return selfNeedsLayout(); | 168 return selfNeedsLayout(); |
| 158 } | 169 } |
| 159 | 170 |
| 160 } // namespace blink | 171 } // namespace blink |
| OLD | NEW |