Chromium Code Reviews| 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 26 matching lines...) Expand all Loading... | |
| 37 #include "core/rendering/svg/RenderSVGShape.h" | 37 #include "core/rendering/svg/RenderSVGShape.h" |
| 38 #include "core/rendering/svg/RenderSVGText.h" | 38 #include "core/rendering/svg/RenderSVGText.h" |
| 39 #include "core/rendering/svg/RenderSVGViewportContainer.h" | 39 #include "core/rendering/svg/RenderSVGViewportContainer.h" |
| 40 #include "core/rendering/svg/SVGResources.h" | 40 #include "core/rendering/svg/SVGResources.h" |
| 41 #include "core/rendering/svg/SVGResourcesCache.h" | 41 #include "core/rendering/svg/SVGResourcesCache.h" |
| 42 #include "core/svg/SVGElement.h" | 42 #include "core/svg/SVGElement.h" |
| 43 #include "platform/geometry/TransformState.h" | 43 #include "platform/geometry/TransformState.h" |
| 44 | 44 |
| 45 namespace blink { | 45 namespace blink { |
| 46 | 46 |
| 47 static inline LayoutRect enclosingIntRectIfNotEmpty(const FloatRect& rect) | |
| 48 { | |
| 49 if (rect.isEmpty()) | |
| 50 return LayoutRect(); | |
| 51 return enclosingIntRect(rect); | |
| 52 } | |
| 53 | |
| 47 LayoutRect SVGRenderSupport::clippedOverflowRectForPaintInvalidation(const Rende rObject* object, const RenderLayerModelObject* paintInvalidationContainer, const PaintInvalidationState* paintInvalidationState) | 54 LayoutRect SVGRenderSupport::clippedOverflowRectForPaintInvalidation(const Rende rObject* object, const RenderLayerModelObject* paintInvalidationContainer, const PaintInvalidationState* paintInvalidationState) |
| 48 { | 55 { |
| 49 // Return early for any cases where we don't actually paint | 56 // Return early for any cases where we don't actually paint |
| 50 if (object->style()->visibility() != VISIBLE && !object->enclosingLayer()->h asVisibleContent()) | 57 if (object->style()->visibility() != VISIBLE && !object->enclosingLayer()->h asVisibleContent()) |
| 51 return LayoutRect(); | 58 return LayoutRect(); |
| 52 | 59 |
| 53 // Pass our local paint rect to computeRectForPaintInvalidation() which will | 60 // Pass our local paint rect to computeRectForPaintInvalidation() which will |
| 54 // map to parent coords and recurse up the parent chain. | 61 // map to parent coords and recurse up the parent chain. |
| 55 FloatRect paintInvalidationRect = object->paintInvalidationRectInLocalCoordi nates(); | 62 FloatRect paintInvalidationRect = object->paintInvalidationRectInLocalCoordi nates(); |
| 56 paintInvalidationRect.inflate(object->style()->outlineWidth()); | 63 paintInvalidationRect.inflate(object->style()->outlineWidth()); |
| 57 | 64 |
| 58 if (paintInvalidationState && paintInvalidationState->canMapToContainer(pain tInvalidationContainer)) { | 65 if (paintInvalidationState && paintInvalidationState->canMapToContainer(pain tInvalidationContainer)) { |
| 59 // Compute accumulated SVG transform and apply to local paint rect. | 66 // Compute accumulated SVG transform and apply to local paint rect. |
| 60 AffineTransform transform = paintInvalidationState->svgTransform() * obj ect->localToParentTransform(); | 67 AffineTransform transform = paintInvalidationState->svgTransform() * obj ect->localToParentTransform(); |
| 61 paintInvalidationRect = transform.mapRect(paintInvalidationRect); | 68 paintInvalidationRect = transform.mapRect(paintInvalidationRect); |
| 62 // FIXME: These are quirks carried forward from RenderSVGRoot::computeFl oatRectForPaintInvalidation. | 69 // FIXME: These are quirks carried forward from RenderSVGRoot::computeFl oatRectForPaintInvalidation. |
|
pdr.
2014/11/21 08:32:05
This comment is no longer valid (similarly RenderS
fs
2014/11/21 11:23:15
Right. Updated.
| |
| 63 LayoutRect rect; | 70 LayoutRect rect = enclosingIntRectIfNotEmpty(paintInvalidationRect); |
| 64 if (!paintInvalidationRect.isEmpty()) | |
| 65 rect = enclosingIntRect(paintInvalidationRect); | |
| 66 // Offset by SVG root paint offset and apply clipping as needed. | 71 // Offset by SVG root paint offset and apply clipping as needed. |
| 67 rect.move(paintInvalidationState->paintOffset()); | 72 rect.move(paintInvalidationState->paintOffset()); |
| 68 if (paintInvalidationState->isClipped()) | 73 if (paintInvalidationState->isClipped()) |
| 69 rect.intersect(paintInvalidationState->clipRect()); | 74 rect.intersect(paintInvalidationState->clipRect()); |
| 70 return rect; | 75 return rect; |
| 71 } | 76 } |
| 72 | 77 |
| 73 object->computeFloatRectForPaintInvalidation(paintInvalidationContainer, pai ntInvalidationRect, paintInvalidationState); | 78 LayoutRect rect; |
| 74 return enclosingLayoutRect(paintInvalidationRect); | 79 const RenderSVGRoot* svgRoot = mapRectToSVGRootForPaintInvalidation(object, paintInvalidationRect, rect); |
| 80 svgRoot->mapRectToPaintInvalidationBacking(paintInvalidationContainer, rect, paintInvalidationState); | |
| 81 return rect; | |
| 75 } | 82 } |
| 76 | 83 |
| 77 void SVGRenderSupport::computeFloatRectForPaintInvalidation(const RenderObject* object, const RenderLayerModelObject* paintInvalidationContainer, FloatRect& pai ntInvalidationRect, const PaintInvalidationState* paintInvalidationState) | 84 const RenderSVGRoot* SVGRenderSupport::mapRectToSVGRootForPaintInvalidation(cons t RenderObject* object, const FloatRect& localPaintInvalidationRect, LayoutRect& rect) |
| 78 { | 85 { |
| 79 // Translate to coords in our parent renderer, and then call computeFloatRec tForPaintInvalidation() on our parent. | 86 ASSERT(object && object->isSVG() && !object->isSVGRoot()); |
| 80 paintInvalidationRect = object->localToParentTransform().mapRect(paintInvali dationRect); | 87 |
| 81 object->parent()->computeFloatRectForPaintInvalidation(paintInvalidationCont ainer, paintInvalidationRect, paintInvalidationState); | 88 FloatRect paintInvalidationRect = localPaintInvalidationRect; |
| 89 // FIXME: Building the transform to the SVG root border box and then doing | |
| 90 // mapRect() with that would be slightly more efficient, but requires some | |
| 91 // additions to AffineTransform (preMultiply, preTranslate) to avoid | |
| 92 // excessive copying and to get a similar fast-path for translations. | |
| 93 const RenderObject* parent = object; | |
| 94 do { | |
| 95 paintInvalidationRect = parent->localToParentTransform().mapRect(paintIn validationRect); | |
| 96 parent = parent->parent(); | |
| 97 } while (!parent->isSVGRoot()); | |
| 98 | |
| 99 const RenderSVGRoot* svgRoot = toRenderSVGRoot(parent); | |
| 100 | |
| 101 paintInvalidationRect = svgRoot->localToBorderBoxTransform().mapRect(paintIn validationRect); | |
| 102 rect = enclosingIntRectIfNotEmpty(paintInvalidationRect); | |
| 103 return svgRoot; | |
| 82 } | 104 } |
| 83 | 105 |
| 84 void SVGRenderSupport::mapLocalToContainer(const RenderObject* object, const Ren derLayerModelObject* paintInvalidationContainer, TransformState& transformState, bool* wasFixed, const PaintInvalidationState* paintInvalidationState) | 106 void SVGRenderSupport::mapLocalToContainer(const RenderObject* object, const Ren derLayerModelObject* paintInvalidationContainer, TransformState& transformState, bool* wasFixed, const PaintInvalidationState* paintInvalidationState) |
| 85 { | 107 { |
| 86 transformState.applyTransform(object->localToParentTransform()); | 108 transformState.applyTransform(object->localToParentTransform()); |
| 87 | 109 |
| 88 if (paintInvalidationState && paintInvalidationState->canMapToContainer(pain tInvalidationContainer)) { | 110 if (paintInvalidationState && paintInvalidationState->canMapToContainer(pain tInvalidationContainer)) { |
| 89 // |svgTransform| contains localToBorderBoxTransform mentioned below. | 111 // |svgTransform| contains localToBorderBoxTransform mentioned below. |
| 90 transformState.applyTransform(paintInvalidationState->svgTransform()); | 112 transformState.applyTransform(paintInvalidationState->svgTransform()); |
| 91 transformState.move(paintInvalidationState->paintOffset()); | 113 transformState.move(paintInvalidationState->paintOffset()); |
| (...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 422 } | 444 } |
| 423 | 445 |
| 424 bool SVGRenderSupport::isRenderableTextNode(const RenderObject* object) | 446 bool SVGRenderSupport::isRenderableTextNode(const RenderObject* object) |
| 425 { | 447 { |
| 426 ASSERT(object->isText()); | 448 ASSERT(object->isText()); |
| 427 // <br> is marked as text, but is not handled by the SVG rendering code-path . | 449 // <br> is marked as text, but is not handled by the SVG rendering code-path . |
| 428 return object->isSVGInlineText() && !toRenderSVGInlineText(object)->hasEmpty Text(); | 450 return object->isSVGInlineText() && !toRenderSVGInlineText(object)->hasEmpty Text(); |
| 429 } | 451 } |
| 430 | 452 |
| 431 } | 453 } |
| OLD | NEW |