| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) Research In Motion Limited 2009-2010. All rights reserved. | 2 * Copyright (C) Research In Motion Limited 2009-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 27 matching lines...) Expand all Loading... |
| 38 { | 38 { |
| 39 } | 39 } |
| 40 | 40 |
| 41 void RenderSVGResourceMasker::removeAllClientsFromCache(bool markForInvalidation
) | 41 void RenderSVGResourceMasker::removeAllClientsFromCache(bool markForInvalidation
) |
| 42 { | 42 { |
| 43 m_maskContentPicture.clear(); | 43 m_maskContentPicture.clear(); |
| 44 m_maskContentBoundaries = FloatRect(); | 44 m_maskContentBoundaries = FloatRect(); |
| 45 markAllClientsForInvalidation(markForInvalidation ? LayoutAndBoundariesInval
idation : ParentOnlyInvalidation); | 45 markAllClientsForInvalidation(markForInvalidation ? LayoutAndBoundariesInval
idation : ParentOnlyInvalidation); |
| 46 } | 46 } |
| 47 | 47 |
| 48 void RenderSVGResourceMasker::removeClientFromCache(RenderObject* client, bool m
arkForInvalidation) | 48 void RenderSVGResourceMasker::removeClientFromCache(LayoutObject* client, bool m
arkForInvalidation) |
| 49 { | 49 { |
| 50 ASSERT(client); | 50 ASSERT(client); |
| 51 markClientForInvalidation(client, markForInvalidation ? BoundariesInvalidati
on : ParentOnlyInvalidation); | 51 markClientForInvalidation(client, markForInvalidation ? BoundariesInvalidati
on : ParentOnlyInvalidation); |
| 52 } | 52 } |
| 53 | 53 |
| 54 bool RenderSVGResourceMasker::prepareEffect(RenderObject* object, GraphicsContex
t* context) | 54 bool RenderSVGResourceMasker::prepareEffect(LayoutObject* object, GraphicsContex
t* context) |
| 55 { | 55 { |
| 56 ASSERT(object); | 56 ASSERT(object); |
| 57 ASSERT(context); | 57 ASSERT(context); |
| 58 ASSERT(style()); | 58 ASSERT(style()); |
| 59 ASSERT_WITH_SECURITY_IMPLICATION(!needsLayout()); | 59 ASSERT_WITH_SECURITY_IMPLICATION(!needsLayout()); |
| 60 | 60 |
| 61 clearInvalidationMask(); | 61 clearInvalidationMask(); |
| 62 | 62 |
| 63 FloatRect paintInvalidationRect = object->paintInvalidationRectInLocalCoordi
nates(); | 63 FloatRect paintInvalidationRect = object->paintInvalidationRectInLocalCoordi
nates(); |
| 64 if (paintInvalidationRect.isEmpty() || !element()->hasChildren()) | 64 if (paintInvalidationRect.isEmpty() || !element()->hasChildren()) |
| 65 return false; | 65 return false; |
| 66 | 66 |
| 67 // Content layer start. | 67 // Content layer start. |
| 68 context->beginTransparencyLayer(1, &paintInvalidationRect); | 68 context->beginTransparencyLayer(1, &paintInvalidationRect); |
| 69 | 69 |
| 70 return true; | 70 return true; |
| 71 } | 71 } |
| 72 | 72 |
| 73 void RenderSVGResourceMasker::finishEffect(RenderObject* object, GraphicsContext
* context) | 73 void RenderSVGResourceMasker::finishEffect(LayoutObject* object, GraphicsContext
* context) |
| 74 { | 74 { |
| 75 ASSERT(object); | 75 ASSERT(object); |
| 76 ASSERT(context); | 76 ASSERT(context); |
| 77 ASSERT(style()); | 77 ASSERT(style()); |
| 78 ASSERT_WITH_SECURITY_IMPLICATION(!needsLayout()); | 78 ASSERT_WITH_SECURITY_IMPLICATION(!needsLayout()); |
| 79 | 79 |
| 80 FloatRect paintInvalidationRect = object->paintInvalidationRectInLocalCoordi
nates(); | 80 FloatRect paintInvalidationRect = object->paintInvalidationRectInLocalCoordi
nates(); |
| 81 | 81 |
| 82 const SVGRenderStyle& svgStyle = style()->svgStyle(); | 82 const SVGRenderStyle& svgStyle = style()->svgStyle(); |
| 83 ColorFilter maskLayerFilter = svgStyle.maskType() == MT_LUMINANCE | 83 ColorFilter maskLayerFilter = svgStyle.maskType() == MT_LUMINANCE |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 void RenderSVGResourceMasker::createPicture(GraphicsContext* context) | 124 void RenderSVGResourceMasker::createPicture(GraphicsContext* context) |
| 125 { | 125 { |
| 126 ASSERT(context); | 126 ASSERT(context); |
| 127 | 127 |
| 128 // Using strokeBoundingBox (instead of paintInvalidationRectInLocalCoordinat
es) to avoid the intersection | 128 // Using strokeBoundingBox (instead of paintInvalidationRectInLocalCoordinat
es) to avoid the intersection |
| 129 // with local clips/mask, which may yield incorrect results when mixing obje
ctBoundingBox and | 129 // with local clips/mask, which may yield incorrect results when mixing obje
ctBoundingBox and |
| 130 // userSpaceOnUse units (http://crbug.com/294900). | 130 // userSpaceOnUse units (http://crbug.com/294900). |
| 131 FloatRect bounds = strokeBoundingBox(); | 131 FloatRect bounds = strokeBoundingBox(); |
| 132 context->beginRecording(bounds); | 132 context->beginRecording(bounds); |
| 133 for (SVGElement* childElement = Traversal<SVGElement>::firstChild(*element()
); childElement; childElement = Traversal<SVGElement>::nextSibling(*childElement
)) { | 133 for (SVGElement* childElement = Traversal<SVGElement>::firstChild(*element()
); childElement; childElement = Traversal<SVGElement>::nextSibling(*childElement
)) { |
| 134 RenderObject* renderer = childElement->renderer(); | 134 LayoutObject* renderer = childElement->renderer(); |
| 135 if (!renderer) | 135 if (!renderer) |
| 136 continue; | 136 continue; |
| 137 RenderStyle* style = renderer->style(); | 137 RenderStyle* style = renderer->style(); |
| 138 if (!style || style->display() == NONE || style->visibility() != VISIBLE
) | 138 if (!style || style->display() == NONE || style->visibility() != VISIBLE
) |
| 139 continue; | 139 continue; |
| 140 | 140 |
| 141 SVGRenderingContext::renderSubtree(context, renderer); | 141 SVGRenderingContext::renderSubtree(context, renderer); |
| 142 } | 142 } |
| 143 m_maskContentPicture = context->endRecording(); | 143 m_maskContentPicture = context->endRecording(); |
| 144 } | 144 } |
| 145 | 145 |
| 146 void RenderSVGResourceMasker::calculateMaskContentPaintInvalidationRect() | 146 void RenderSVGResourceMasker::calculateMaskContentPaintInvalidationRect() |
| 147 { | 147 { |
| 148 for (SVGElement* childElement = Traversal<SVGElement>::firstChild(*element()
); childElement; childElement = Traversal<SVGElement>::nextSibling(*childElement
)) { | 148 for (SVGElement* childElement = Traversal<SVGElement>::firstChild(*element()
); childElement; childElement = Traversal<SVGElement>::nextSibling(*childElement
)) { |
| 149 RenderObject* renderer = childElement->renderer(); | 149 LayoutObject* renderer = childElement->renderer(); |
| 150 if (!renderer) | 150 if (!renderer) |
| 151 continue; | 151 continue; |
| 152 RenderStyle* style = renderer->style(); | 152 RenderStyle* style = renderer->style(); |
| 153 if (!style || style->display() == NONE || style->visibility() != VISIBLE
) | 153 if (!style || style->display() == NONE || style->visibility() != VISIBLE
) |
| 154 continue; | 154 continue; |
| 155 m_maskContentBoundaries.unite(renderer->localToParentTransform().mapRect
(renderer->paintInvalidationRectInLocalCoordinates())); | 155 m_maskContentBoundaries.unite(renderer->localToParentTransform().mapRect
(renderer->paintInvalidationRectInLocalCoordinates())); |
| 156 } | 156 } |
| 157 } | 157 } |
| 158 | 158 |
| 159 FloatRect RenderSVGResourceMasker::resourceBoundingBox(const RenderObject* objec
t) | 159 FloatRect RenderSVGResourceMasker::resourceBoundingBox(const LayoutObject* objec
t) |
| 160 { | 160 { |
| 161 SVGMaskElement* maskElement = toSVGMaskElement(element()); | 161 SVGMaskElement* maskElement = toSVGMaskElement(element()); |
| 162 ASSERT(maskElement); | 162 ASSERT(maskElement); |
| 163 | 163 |
| 164 FloatRect objectBoundingBox = object->objectBoundingBox(); | 164 FloatRect objectBoundingBox = object->objectBoundingBox(); |
| 165 FloatRect maskBoundaries = SVGLengthContext::resolveRectangle<SVGMaskElement
>(maskElement, maskElement->maskUnits()->currentValue()->enumValue(), objectBoun
dingBox); | 165 FloatRect maskBoundaries = SVGLengthContext::resolveRectangle<SVGMaskElement
>(maskElement, maskElement->maskUnits()->currentValue()->enumValue(), objectBoun
dingBox); |
| 166 | 166 |
| 167 // Resource was not layouted yet. Give back clipping rect of the mask. | 167 // Resource was not layouted yet. Give back clipping rect of the mask. |
| 168 if (selfNeedsLayout()) | 168 if (selfNeedsLayout()) |
| 169 return maskBoundaries; | 169 return maskBoundaries; |
| 170 | 170 |
| 171 if (m_maskContentBoundaries.isEmpty()) | 171 if (m_maskContentBoundaries.isEmpty()) |
| 172 calculateMaskContentPaintInvalidationRect(); | 172 calculateMaskContentPaintInvalidationRect(); |
| 173 | 173 |
| 174 FloatRect maskRect = m_maskContentBoundaries; | 174 FloatRect maskRect = m_maskContentBoundaries; |
| 175 if (maskElement->maskContentUnits()->currentValue()->value() == SVGUnitTypes
::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX) { | 175 if (maskElement->maskContentUnits()->currentValue()->value() == SVGUnitTypes
::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX) { |
| 176 AffineTransform transform; | 176 AffineTransform transform; |
| 177 transform.translate(objectBoundingBox.x(), objectBoundingBox.y()); | 177 transform.translate(objectBoundingBox.x(), objectBoundingBox.y()); |
| 178 transform.scaleNonUniform(objectBoundingBox.width(), objectBoundingBox.h
eight()); | 178 transform.scaleNonUniform(objectBoundingBox.width(), objectBoundingBox.h
eight()); |
| 179 maskRect = transform.mapRect(maskRect); | 179 maskRect = transform.mapRect(maskRect); |
| 180 } | 180 } |
| 181 | 181 |
| 182 maskRect.intersect(maskBoundaries); | 182 maskRect.intersect(maskBoundaries); |
| 183 return maskRect; | 183 return maskRect; |
| 184 } | 184 } |
| 185 | 185 |
| 186 } | 186 } |
| OLD | NEW |