| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) Research In Motion Limited 2010. All rights reserved. | 2 * Copyright (C) Research In Motion Limited 2010. All rights reserved. |
| 3 * | 3 * |
| 4 * This library is free software; you can redistribute it and/or | 4 * This library is free software; you can redistribute it and/or |
| 5 * modify it under the terms of the GNU Library General Public | 5 * modify it under the terms of the GNU Library General Public |
| 6 * License as published by the Free Software Foundation; either | 6 * License as published by the Free Software Foundation; either |
| 7 * version 2 of the License, or (at your option) any later version. | 7 * version 2 of the License, or (at your option) any later version. |
| 8 * | 8 * |
| 9 * This library is distributed in the hope that it will be useful, | 9 * This library is distributed in the hope that it will be useful, |
| 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 228 if (!renderer) | 228 if (!renderer) |
| 229 continue; | 229 continue; |
| 230 | 230 |
| 231 StyleDifference diff; | 231 StyleDifference diff; |
| 232 diff.setNeedsFullLayout(); | 232 diff.setNeedsFullLayout(); |
| 233 SVGResourcesCache::clientStyleChanged(renderer, diff, renderer->style())
; | 233 SVGResourcesCache::clientStyleChanged(renderer, diff, renderer->style())
; |
| 234 renderer->setNeedsLayout(); | 234 renderer->setNeedsLayout(); |
| 235 } | 235 } |
| 236 } | 236 } |
| 237 | 237 |
| 238 static bool shouldTransformOnTextPainting(RenderObject* object, AffineTransform&
resourceTransform) |
| 239 { |
| 240 ASSERT(object); |
| 241 |
| 242 // This method should only be called for RenderObjects that deal with text r
endering. Cmp. RenderObject.h's is*() methods. |
| 243 ASSERT(object->isSVGText() || object->isSVGTextPath() || object->isSVGInline
()); |
| 244 |
| 245 // In text drawing, the scaling part of the graphics context CTM is removed,
compare SVGInlineTextBox::paintTextWithShadows. |
| 246 // So, we use that scaling factor here, too, and then push it down to patter
n or gradient space |
| 247 // in order to keep the pattern or gradient correctly scaled. |
| 248 float scalingFactor = SVGRenderingContext::calculateScreenFontSizeScalingFac
tor(object); |
| 249 if (scalingFactor == 1) |
| 250 return false; |
| 251 resourceTransform.scale(scalingFactor); |
| 252 return true; |
| 253 } |
| 254 |
| 238 AffineTransform RenderSVGResourceContainer::computeResourceSpaceTransform(Render
Object* object, const AffineTransform& baseTransform, const SVGRenderStyle* svgS
tyle, unsigned short resourceMode) | 255 AffineTransform RenderSVGResourceContainer::computeResourceSpaceTransform(Render
Object* object, const AffineTransform& baseTransform, const SVGRenderStyle* svgS
tyle, unsigned short resourceMode) |
| 239 { | 256 { |
| 240 AffineTransform computedSpaceTransform = baseTransform; | 257 AffineTransform computedSpaceTransform = baseTransform; |
| 241 if (resourceMode & ApplyToTextMode) { | 258 if (resourceMode & ApplyToTextMode) { |
| 242 // Depending on the font scaling factor, we may need to apply an | 259 // Depending on the font scaling factor, we may need to apply an |
| 243 // additional transform (scale-factor) the paintserver, since text | 260 // additional transform (scale-factor) the paintserver, since text |
| 244 // painting removes the scale factor from the context. (See | 261 // painting removes the scale factor from the context. (See |
| 245 // SVGInlineTextBox::paintTextWithShadows.) | 262 // SVGInlineTextBox::paintTextWithShadows.) |
| 246 AffineTransform additionalTextTransformation; | 263 AffineTransform additionalTextTransformation; |
| 247 if (shouldTransformOnTextPainting(object, additionalTextTransformation)) | 264 if (shouldTransformOnTextPainting(object, additionalTextTransformation)) |
| 248 computedSpaceTransform = additionalTextTransformation * computedSpac
eTransform; | 265 computedSpaceTransform = additionalTextTransformation * computedSpac
eTransform; |
| 249 } | 266 } |
| 250 if (resourceMode & ApplyToStrokeMode) { | 267 if (resourceMode & ApplyToStrokeMode) { |
| 251 // Non-scaling stroke needs to reset the transform back to the host tran
sform. | 268 // Non-scaling stroke needs to reset the transform back to the host tran
sform. |
| 252 if (svgStyle->vectorEffect() == VE_NON_SCALING_STROKE) | 269 if (svgStyle->vectorEffect() == VE_NON_SCALING_STROKE) |
| 253 computedSpaceTransform = transformOnNonScalingStroke(object, compute
dSpaceTransform); | 270 computedSpaceTransform = transformOnNonScalingStroke(object, compute
dSpaceTransform); |
| 254 } | 271 } |
| 255 return computedSpaceTransform; | 272 return computedSpaceTransform; |
| 256 } | 273 } |
| 257 | 274 |
| 258 bool RenderSVGResourceContainer::shouldTransformOnTextPainting(RenderObject* obj
ect, AffineTransform& resourceTransform) | |
| 259 { | |
| 260 ASSERT(object); | |
| 261 | |
| 262 // This method should only be called for RenderObjects that deal with text r
endering. Cmp. RenderObject.h's is*() methods. | |
| 263 ASSERT(object->isSVGText() || object->isSVGTextPath() || object->isSVGInline
()); | |
| 264 | |
| 265 // In text drawing, the scaling part of the graphics context CTM is removed,
compare SVGInlineTextBox::paintTextWithShadows. | |
| 266 // So, we use that scaling factor here, too, and then push it down to patter
n or gradient space | |
| 267 // in order to keep the pattern or gradient correctly scaled. | |
| 268 float scalingFactor = SVGRenderingContext::calculateScreenFontSizeScalingFac
tor(object); | |
| 269 if (scalingFactor == 1) | |
| 270 return false; | |
| 271 resourceTransform.scale(scalingFactor); | |
| 272 return true; | |
| 273 } | |
| 274 | |
| 275 // FIXME: This does not belong here. | 275 // FIXME: This does not belong here. |
| 276 AffineTransform RenderSVGResourceContainer::transformOnNonScalingStroke(RenderOb
ject* object, const AffineTransform& resourceTransform) | 276 AffineTransform RenderSVGResourceContainer::transformOnNonScalingStroke(RenderOb
ject* object, const AffineTransform& resourceTransform) |
| 277 { | 277 { |
| 278 if (!object->isSVGShape()) | 278 if (!object->isSVGShape()) |
| 279 return resourceTransform; | 279 return resourceTransform; |
| 280 | 280 |
| 281 SVGGraphicsElement* element = toSVGGraphicsElement(object->node()); | 281 SVGGraphicsElement* element = toSVGGraphicsElement(object->node()); |
| 282 AffineTransform transform = element->getScreenCTM(SVGGraphicsElement::Disall
owStyleUpdate); | 282 AffineTransform transform = element->getScreenCTM(SVGGraphicsElement::Disall
owStyleUpdate); |
| 283 transform *= resourceTransform; | 283 transform *= resourceTransform; |
| 284 return transform; | 284 return transform; |
| 285 } | 285 } |
| 286 | 286 |
| 287 } | 287 } |
| OLD | NEW |