| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2007, 2008 Rob Buis <buis@kde.org> | 2 * Copyright (C) 2007, 2008 Rob Buis <buis@kde.org> |
| 3 * Copyright (C) 2007 Nikolas Zimmermann <zimmermann@kde.org> | 3 * Copyright (C) 2007 Nikolas Zimmermann <zimmermann@kde.org> |
| 4 * Copyright (C) 2007 Eric Seidel <eric@webkit.org> | 4 * Copyright (C) 2007 Eric Seidel <eric@webkit.org> |
| 5 * Copyright (C) 2009 Google, Inc. All rights reserved. | 5 * Copyright (C) 2009 Google, Inc. All rights reserved. |
| 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 2009-2010. All rights reserved. | 7 * Copyright (C) Research In Motion Limited 2009-2010. All rights reserved. |
| 8 * | 8 * |
| 9 * This library is free software; you can redistribute it and/or | 9 * This library is free software; you can redistribute it and/or |
| 10 * modify it under the terms of the GNU Library General Public | 10 * modify it under the terms of the GNU Library General Public |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 | 27 |
| 28 #include "core/frame/FrameHost.h" | 28 #include "core/frame/FrameHost.h" |
| 29 #include "core/layout/Layer.h" | 29 #include "core/layout/Layer.h" |
| 30 #include "core/layout/LayoutGeometryMap.h" | 30 #include "core/layout/LayoutGeometryMap.h" |
| 31 #include "core/layout/PaintInfo.h" | 31 #include "core/layout/PaintInfo.h" |
| 32 #include "core/layout/SubtreeLayoutScope.h" | 32 #include "core/layout/SubtreeLayoutScope.h" |
| 33 #include "core/layout/svg/LayoutSVGInlineText.h" | 33 #include "core/layout/svg/LayoutSVGInlineText.h" |
| 34 #include "core/layout/svg/LayoutSVGResourceClipper.h" | 34 #include "core/layout/svg/LayoutSVGResourceClipper.h" |
| 35 #include "core/layout/svg/LayoutSVGResourceFilter.h" | 35 #include "core/layout/svg/LayoutSVGResourceFilter.h" |
| 36 #include "core/layout/svg/LayoutSVGResourceMasker.h" | 36 #include "core/layout/svg/LayoutSVGResourceMasker.h" |
| 37 #include "core/layout/svg/LayoutSVGRoot.h" |
| 37 #include "core/layout/svg/LayoutSVGShape.h" | 38 #include "core/layout/svg/LayoutSVGShape.h" |
| 38 #include "core/layout/svg/LayoutSVGText.h" | 39 #include "core/layout/svg/LayoutSVGText.h" |
| 39 #include "core/layout/svg/LayoutSVGViewportContainer.h" | 40 #include "core/layout/svg/LayoutSVGViewportContainer.h" |
| 40 #include "core/layout/svg/SVGResources.h" | 41 #include "core/layout/svg/SVGResources.h" |
| 41 #include "core/layout/svg/SVGResourcesCache.h" | 42 #include "core/layout/svg/SVGResourcesCache.h" |
| 42 #include "core/rendering/svg/RenderSVGRoot.h" | |
| 43 #include "core/svg/SVGElement.h" | 43 #include "core/svg/SVGElement.h" |
| 44 #include "platform/geometry/TransformState.h" | 44 #include "platform/geometry/TransformState.h" |
| 45 | 45 |
| 46 namespace blink { | 46 namespace blink { |
| 47 | 47 |
| 48 static inline LayoutRect enclosingIntRectIfNotEmpty(const FloatRect& rect) | 48 static inline LayoutRect enclosingIntRectIfNotEmpty(const FloatRect& rect) |
| 49 { | 49 { |
| 50 if (rect.isEmpty()) | 50 if (rect.isEmpty()) |
| 51 return LayoutRect(); | 51 return LayoutRect(); |
| 52 return enclosingIntRect(rect); | 52 return enclosingIntRect(rect); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 70 // FIXME: These are quirks carried forward from the old paint invalidati
on infrastructure. | 70 // FIXME: These are quirks carried forward from the old paint invalidati
on infrastructure. |
| 71 LayoutRect rect = enclosingIntRectIfNotEmpty(paintInvalidationRect); | 71 LayoutRect rect = enclosingIntRectIfNotEmpty(paintInvalidationRect); |
| 72 // Offset by SVG root paint offset and apply clipping as needed. | 72 // Offset by SVG root paint offset and apply clipping as needed. |
| 73 rect.move(paintInvalidationState->paintOffset()); | 73 rect.move(paintInvalidationState->paintOffset()); |
| 74 if (paintInvalidationState->isClipped()) | 74 if (paintInvalidationState->isClipped()) |
| 75 rect.intersect(paintInvalidationState->clipRect()); | 75 rect.intersect(paintInvalidationState->clipRect()); |
| 76 return rect; | 76 return rect; |
| 77 } | 77 } |
| 78 | 78 |
| 79 LayoutRect rect; | 79 LayoutRect rect; |
| 80 const RenderSVGRoot& svgRoot = mapRectToSVGRootForPaintInvalidation(object,
paintInvalidationRect, rect); | 80 const LayoutSVGRoot& svgRoot = mapRectToSVGRootForPaintInvalidation(object,
paintInvalidationRect, rect); |
| 81 svgRoot.mapRectToPaintInvalidationBacking(paintInvalidationContainer, rect,
paintInvalidationState); | 81 svgRoot.mapRectToPaintInvalidationBacking(paintInvalidationContainer, rect,
paintInvalidationState); |
| 82 return rect; | 82 return rect; |
| 83 } | 83 } |
| 84 | 84 |
| 85 const RenderSVGRoot& SVGLayoutSupport::mapRectToSVGRootForPaintInvalidation(cons
t LayoutObject* object, const FloatRect& localPaintInvalidationRect, LayoutRect&
rect) | 85 const LayoutSVGRoot& SVGLayoutSupport::mapRectToSVGRootForPaintInvalidation(cons
t LayoutObject* object, const FloatRect& localPaintInvalidationRect, LayoutRect&
rect) |
| 86 { | 86 { |
| 87 ASSERT(object && object->isSVG() && !object->isSVGRoot()); | 87 ASSERT(object && object->isSVG() && !object->isSVGRoot()); |
| 88 | 88 |
| 89 FloatRect paintInvalidationRect = localPaintInvalidationRect; | 89 FloatRect paintInvalidationRect = localPaintInvalidationRect; |
| 90 // FIXME: Building the transform to the SVG root border box and then doing | 90 // FIXME: Building the transform to the SVG root border box and then doing |
| 91 // mapRect() with that would be slightly more efficient, but requires some | 91 // mapRect() with that would be slightly more efficient, but requires some |
| 92 // additions to AffineTransform (preMultiply, preTranslate) to avoid | 92 // additions to AffineTransform (preMultiply, preTranslate) to avoid |
| 93 // excessive copying and to get a similar fast-path for translations. | 93 // excessive copying and to get a similar fast-path for translations. |
| 94 const LayoutObject* parent = object; | 94 const LayoutObject* parent = object; |
| 95 do { | 95 do { |
| 96 paintInvalidationRect = parent->localToParentTransform().mapRect(paintIn
validationRect); | 96 paintInvalidationRect = parent->localToParentTransform().mapRect(paintIn
validationRect); |
| 97 parent = parent->parent(); | 97 parent = parent->parent(); |
| 98 } while (!parent->isSVGRoot()); | 98 } while (!parent->isSVGRoot()); |
| 99 | 99 |
| 100 const RenderSVGRoot& svgRoot = toRenderSVGRoot(*parent); | 100 const LayoutSVGRoot& svgRoot = toLayoutSVGRoot(*parent); |
| 101 | 101 |
| 102 paintInvalidationRect = svgRoot.localToBorderBoxTransform().mapRect(paintInv
alidationRect); | 102 paintInvalidationRect = svgRoot.localToBorderBoxTransform().mapRect(paintInv
alidationRect); |
| 103 rect = enclosingIntRectIfNotEmpty(paintInvalidationRect); | 103 rect = enclosingIntRectIfNotEmpty(paintInvalidationRect); |
| 104 return svgRoot; | 104 return svgRoot; |
| 105 } | 105 } |
| 106 | 106 |
| 107 void SVGLayoutSupport::mapLocalToContainer(const LayoutObject* object, const Lay
outLayerModelObject* paintInvalidationContainer, TransformState& transformState,
bool* wasFixed, const PaintInvalidationState* paintInvalidationState) | 107 void SVGLayoutSupport::mapLocalToContainer(const LayoutObject* object, const Lay
outLayerModelObject* paintInvalidationContainer, TransformState& transformState,
bool* wasFixed, const PaintInvalidationState* paintInvalidationState) |
| 108 { | 108 { |
| 109 transformState.applyTransform(object->localToParentTransform()); | 109 transformState.applyTransform(object->localToParentTransform()); |
| 110 | 110 |
| 111 if (paintInvalidationState && paintInvalidationState->canMapToContainer(pain
tInvalidationContainer)) { | 111 if (paintInvalidationState && paintInvalidationState->canMapToContainer(pain
tInvalidationContainer)) { |
| 112 // |svgTransform| contains localToBorderBoxTransform mentioned below. | 112 // |svgTransform| contains localToBorderBoxTransform mentioned below. |
| 113 transformState.applyTransform(paintInvalidationState->svgTransform()); | 113 transformState.applyTransform(paintInvalidationState->svgTransform()); |
| 114 transformState.move(paintInvalidationState->paintOffset()); | 114 transformState.move(paintInvalidationState->paintOffset()); |
| 115 return; | 115 return; |
| 116 } | 116 } |
| 117 | 117 |
| 118 LayoutObject* parent = object->parent(); | 118 LayoutObject* parent = object->parent(); |
| 119 | 119 |
| 120 // At the SVG/HTML boundary (aka RenderSVGRoot), we apply the localToBorderB
oxTransform | 120 // At the SVG/HTML boundary (aka LayoutSVGRoot), we apply the localToBorderB
oxTransform |
| 121 // to map an element from SVG viewport coordinates to CSS box coordinates. | 121 // to map an element from SVG viewport coordinates to CSS box coordinates. |
| 122 // RenderSVGRoot's mapLocalToContainer method expects CSS box coordinates. | 122 // LayoutSVGRoot's mapLocalToContainer method expects CSS box coordinates. |
| 123 if (parent->isSVGRoot()) | 123 if (parent->isSVGRoot()) |
| 124 transformState.applyTransform(toRenderSVGRoot(parent)->localToBorderBoxT
ransform()); | 124 transformState.applyTransform(toLayoutSVGRoot(parent)->localToBorderBoxT
ransform()); |
| 125 | 125 |
| 126 MapCoordinatesFlags mode = UseTransforms; | 126 MapCoordinatesFlags mode = UseTransforms; |
| 127 parent->mapLocalToContainer(paintInvalidationContainer, transformState, mode
, wasFixed, paintInvalidationState); | 127 parent->mapLocalToContainer(paintInvalidationContainer, transformState, mode
, wasFixed, paintInvalidationState); |
| 128 } | 128 } |
| 129 | 129 |
| 130 const LayoutObject* SVGLayoutSupport::pushMappingToContainer(const LayoutObject*
object, const LayoutLayerModelObject* ancestorToStopAt, LayoutGeometryMap& geom
etryMap) | 130 const LayoutObject* SVGLayoutSupport::pushMappingToContainer(const LayoutObject*
object, const LayoutLayerModelObject* ancestorToStopAt, LayoutGeometryMap& geom
etryMap) |
| 131 { | 131 { |
| 132 ASSERT_UNUSED(ancestorToStopAt, ancestorToStopAt != object); | 132 ASSERT_UNUSED(ancestorToStopAt, ancestorToStopAt != object); |
| 133 | 133 |
| 134 LayoutObject* parent = object->parent(); | 134 LayoutObject* parent = object->parent(); |
| 135 | 135 |
| 136 // At the SVG/HTML boundary (aka RenderSVGRoot), we apply the localToBorderB
oxTransform | 136 // At the SVG/HTML boundary (aka LayoutSVGRoot), we apply the localToBorderB
oxTransform |
| 137 // to map an element from SVG viewport coordinates to CSS box coordinates. | 137 // to map an element from SVG viewport coordinates to CSS box coordinates. |
| 138 // RenderSVGRoot's mapLocalToContainer method expects CSS box coordinates. | 138 // LayoutSVGRoot's mapLocalToContainer method expects CSS box coordinates. |
| 139 if (parent->isSVGRoot()) { | 139 if (parent->isSVGRoot()) { |
| 140 TransformationMatrix matrix(object->localToParentTransform()); | 140 TransformationMatrix matrix(object->localToParentTransform()); |
| 141 matrix.multiply(toRenderSVGRoot(parent)->localToBorderBoxTransform()); | 141 matrix.multiply(toLayoutSVGRoot(parent)->localToBorderBoxTransform()); |
| 142 geometryMap.push(object, matrix); | 142 geometryMap.push(object, matrix); |
| 143 } else { | 143 } else { |
| 144 geometryMap.push(object, object->localToParentTransform()); | 144 geometryMap.push(object, object->localToParentTransform()); |
| 145 } | 145 } |
| 146 | 146 |
| 147 return parent; | 147 return parent; |
| 148 } | 148 } |
| 149 | 149 |
| 150 // Update a bounding box taking into account the validity of the other bounding
box. | 150 // Update a bounding box taking into account the validity of the other bounding
box. |
| 151 inline void SVGLayoutSupport::updateObjectBoundingBox(FloatRect& objectBoundingB
ox, bool& objectBoundingBoxValid, LayoutObject* other, FloatRect otherBoundingBo
x) | 151 inline void SVGLayoutSupport::updateObjectBoundingBox(FloatRect& objectBoundingB
ox, bool& objectBoundingBoxValid, LayoutObject* other, FloatRect otherBoundingBo
x) |
| (...skipping 30 matching lines...) Expand all Loading... |
| 182 | 182 |
| 183 const AffineTransform& transform = current->localToParentTransform(); | 183 const AffineTransform& transform = current->localToParentTransform(); |
| 184 updateObjectBoundingBox(objectBoundingBox, objectBoundingBoxValid, curre
nt, | 184 updateObjectBoundingBox(objectBoundingBox, objectBoundingBoxValid, curre
nt, |
| 185 transform.mapRect(current->objectBoundingBox())); | 185 transform.mapRect(current->objectBoundingBox())); |
| 186 strokeBoundingBox.unite(transform.mapRect(current->paintInvalidationRect
InLocalCoordinates())); | 186 strokeBoundingBox.unite(transform.mapRect(current->paintInvalidationRect
InLocalCoordinates())); |
| 187 } | 187 } |
| 188 | 188 |
| 189 paintInvalidationBoundingBox = strokeBoundingBox; | 189 paintInvalidationBoundingBox = strokeBoundingBox; |
| 190 } | 190 } |
| 191 | 191 |
| 192 const RenderSVGRoot* SVGLayoutSupport::findTreeRootObject(const LayoutObject* st
art) | 192 const LayoutSVGRoot* SVGLayoutSupport::findTreeRootObject(const LayoutObject* st
art) |
| 193 { | 193 { |
| 194 while (start && !start->isSVGRoot()) | 194 while (start && !start->isSVGRoot()) |
| 195 start = start->parent(); | 195 start = start->parent(); |
| 196 | 196 |
| 197 ASSERT(start); | 197 ASSERT(start); |
| 198 ASSERT(start->isSVGRoot()); | 198 ASSERT(start->isSVGRoot()); |
| 199 return toRenderSVGRoot(start); | 199 return toLayoutSVGRoot(start); |
| 200 } | 200 } |
| 201 | 201 |
| 202 inline bool SVGLayoutSupport::layoutSizeOfNearestViewportChanged(const LayoutObj
ect* start) | 202 inline bool SVGLayoutSupport::layoutSizeOfNearestViewportChanged(const LayoutObj
ect* start) |
| 203 { | 203 { |
| 204 while (start && !start->isSVGRoot() && !start->isSVGViewportContainer()) | 204 while (start && !start->isSVGRoot() && !start->isSVGViewportContainer()) |
| 205 start = start->parent(); | 205 start = start->parent(); |
| 206 | 206 |
| 207 ASSERT(start); | 207 ASSERT(start); |
| 208 ASSERT(start->isSVGRoot() || start->isSVGViewportContainer()); | 208 ASSERT(start->isSVGRoot() || start->isSVGViewportContainer()); |
| 209 if (start->isSVGViewportContainer()) | 209 if (start->isSVGViewportContainer()) |
| 210 return toLayoutSVGViewportContainer(start)->isLayoutSizeChanged(); | 210 return toLayoutSVGViewportContainer(start)->isLayoutSizeChanged(); |
| 211 | 211 |
| 212 return toRenderSVGRoot(start)->isLayoutSizeChanged(); | 212 return toLayoutSVGRoot(start)->isLayoutSizeChanged(); |
| 213 } | 213 } |
| 214 | 214 |
| 215 bool SVGLayoutSupport::transformToRootChanged(LayoutObject* ancestor) | 215 bool SVGLayoutSupport::transformToRootChanged(LayoutObject* ancestor) |
| 216 { | 216 { |
| 217 while (ancestor && !ancestor->isSVGRoot()) { | 217 while (ancestor && !ancestor->isSVGRoot()) { |
| 218 if (ancestor->isSVGTransformableContainer()) | 218 if (ancestor->isSVGTransformableContainer()) |
| 219 return toLayoutSVGContainer(ancestor)->didTransformToRootUpdate(); | 219 return toLayoutSVGContainer(ancestor)->didTransformToRootUpdate(); |
| 220 if (ancestor->isSVGViewportContainer()) | 220 if (ancestor->isSVGViewportContainer()) |
| 221 return toLayoutSVGViewportContainer(ancestor)->didTransformToRootUpd
ate(); | 221 return toLayoutSVGViewportContainer(ancestor)->didTransformToRootUpd
ate(); |
| 222 ancestor = ancestor->parent(); | 222 ancestor = ancestor->parent(); |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 { | 279 { |
| 280 ASSERT(object); | 280 ASSERT(object); |
| 281 | 281 |
| 282 SVGResources* resources = SVGResourcesCache::cachedResourcesForLayoutObject(
object); | 282 SVGResources* resources = SVGResourcesCache::cachedResourcesForLayoutObject(
object); |
| 283 if (resources) | 283 if (resources) |
| 284 resources->layoutIfNeeded(); | 284 resources->layoutIfNeeded(); |
| 285 } | 285 } |
| 286 | 286 |
| 287 bool SVGLayoutSupport::isOverflowHidden(const LayoutObject* object) | 287 bool SVGLayoutSupport::isOverflowHidden(const LayoutObject* object) |
| 288 { | 288 { |
| 289 // RenderSVGRoot should never query for overflow state - it should always cl
ip itself to the initial viewport size. | 289 // LayoutSVGRoot should never query for overflow state - it should always cl
ip itself to the initial viewport size. |
| 290 ASSERT(!object->isDocumentElement()); | 290 ASSERT(!object->isDocumentElement()); |
| 291 | 291 |
| 292 return object->style()->overflowX() == OHIDDEN || object->style()->overflowX
() == OSCROLL; | 292 return object->style()->overflowX() == OHIDDEN || object->style()->overflowX
() == OSCROLL; |
| 293 } | 293 } |
| 294 | 294 |
| 295 void SVGLayoutSupport::intersectPaintInvalidationRectWithResources(const LayoutO
bject* renderer, FloatRect& paintInvalidationRect) | 295 void SVGLayoutSupport::intersectPaintInvalidationRectWithResources(const LayoutO
bject* renderer, FloatRect& paintInvalidationRect) |
| 296 { | 296 { |
| 297 ASSERT(renderer); | 297 ASSERT(renderer); |
| 298 | 298 |
| 299 SVGResources* resources = SVGResourcesCache::cachedResourcesForLayoutObject(
renderer); | 299 SVGResources* resources = SVGResourcesCache::cachedResourcesForLayoutObject(
renderer); |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 510 | 510 |
| 511 layer = layer->parent(); | 511 layer = layer->parent(); |
| 512 } | 512 } |
| 513 | 513 |
| 514 ctm.scale(deviceScaleFactor); | 514 ctm.scale(deviceScaleFactor); |
| 515 | 515 |
| 516 return narrowPrecisionToFloat(sqrt((pow(ctm.xScale(), 2) + pow(ctm.yScale(),
2)) / 2)); | 516 return narrowPrecisionToFloat(sqrt((pow(ctm.xScale(), 2) + pow(ctm.yScale(),
2)) / 2)); |
| 517 } | 517 } |
| 518 | 518 |
| 519 } | 519 } |
| OLD | NEW |