| 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 transform.scale(markerScale); |
| 116 |
| 117 // The 'origin' coordinate maps to SVGs refX/refY, given in coordinates |
| 118 // relative to the viewport established by the marker. |
| 119 FloatPoint mappedReferencePoint = viewportTransform().mapPoint(referencePoin
t()); |
| 120 transform.translate(-mappedReferencePoint.x(), -mappedReferencePoint.y()); |
| 114 return transform; | 121 return transform; |
| 115 } | 122 } |
| 116 | 123 |
| 117 AffineTransform LayoutSVGResourceMarker::markerContentTransformation(const Affin
eTransform& contentTransformation, const FloatPoint& origin, float strokeWidth)
const | 124 bool LayoutSVGResourceMarker::shouldPaint() const |
| 118 { | 125 { |
| 119 // The 'origin' coordinate maps to SVGs refX/refY, given in coordinates rela
tive to the viewport established by the marker | 126 // An empty viewBox disables rendering. |
| 120 FloatPoint mappedOrigin = viewportTransform().mapPoint(origin); | 127 SVGMarkerElement* marker = toSVGMarkerElement(element()); |
| 121 | 128 ASSERT(marker); |
| 122 AffineTransform transformation = contentTransformation; | 129 return !marker->viewBox()->isSpecified() |
| 123 if (strokeWidth != -1) | 130 || !marker->viewBox()->currentValue()->isValid() |
| 124 transformation.scaleNonUniform(strokeWidth, strokeWidth); | 131 || !marker->viewBox()->currentValue()->value().isEmpty(); |
| 125 | |
| 126 transformation.translate(-mappedOrigin.x(), -mappedOrigin.y()); | |
| 127 return transformation; | |
| 128 } | 132 } |
| 129 | 133 |
| 130 AffineTransform LayoutSVGResourceMarker::viewportTransform() const | 134 AffineTransform LayoutSVGResourceMarker::viewportTransform() const |
| 131 { | 135 { |
| 132 SVGMarkerElement* marker = toSVGMarkerElement(element()); | 136 SVGMarkerElement* marker = toSVGMarkerElement(element()); |
| 133 ASSERT(marker); | 137 ASSERT(marker); |
| 134 | 138 |
| 135 return marker->viewBoxToViewTransform(m_viewport.width(), m_viewport.height(
)); | 139 return marker->viewBoxToViewTransform(m_viewport.width(), m_viewport.height(
)); |
| 136 } | 140 } |
| 137 | 141 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 151 | 155 |
| 152 bool LayoutSVGResourceMarker::calculateLocalTransform() | 156 bool LayoutSVGResourceMarker::calculateLocalTransform() |
| 153 { | 157 { |
| 154 // TODO(fs): Temporarily, needing a layout implies that the local transform | 158 // 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 | 159 // has changed. This should be updated to be more precise and factor in the |
| 156 // actual (relevant) changes to the computed user-space transform. | 160 // actual (relevant) changes to the computed user-space transform. |
| 157 return selfNeedsLayout(); | 161 return selfNeedsLayout(); |
| 158 } | 162 } |
| 159 | 163 |
| 160 } // namespace blink | 164 } // namespace blink |
| OLD | NEW |