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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 | 44 |
45 namespace blink { | 45 namespace blink { |
46 | 46 |
47 static inline LayoutRect enclosingIntRectIfNotEmpty(const FloatRect& rect) | 47 static inline LayoutRect enclosingIntRectIfNotEmpty(const FloatRect& rect) |
48 { | 48 { |
49 if (rect.isEmpty()) | 49 if (rect.isEmpty()) |
50 return LayoutRect(); | 50 return LayoutRect(); |
51 return LayoutRect(enclosingIntRect(rect)); | 51 return LayoutRect(enclosingIntRect(rect)); |
52 } | 52 } |
53 | 53 |
54 LayoutRect SVGLayoutSupport::clippedOverflowRectForPaintInvalidation(const Layou
tObject* object, const LayoutBoxModelObject* paintInvalidationContainer, const P
aintInvalidationState* paintInvalidationState) | 54 static void inflateWithOutlineIfNeeded(FloatRect& paintInvalidationRect, const C
omputedStyle& style) |
| 55 { |
| 56 if (!style.hasOutline()) |
| 57 return; |
| 58 int outlineSize = 0; |
| 59 if (style.outlineStyleIsAuto()) |
| 60 outlineSize = GraphicsContext::focusRingOutsetExtent(style.outlineOffset
(), style.outlineWidth()); |
| 61 else |
| 62 outlineSize = style.outlineSize(); |
| 63 paintInvalidationRect.inflate(outlineSize); |
| 64 } |
| 65 |
| 66 LayoutRect SVGLayoutSupport::clippedOverflowRectForPaintInvalidation(const Layou
tObject& object, const LayoutBoxModelObject* paintInvalidationContainer, const P
aintInvalidationState* paintInvalidationState) |
55 { | 67 { |
56 // Return early for any cases where we don't actually paint | 68 // Return early for any cases where we don't actually paint |
57 if (object->style()->visibility() != VISIBLE && !object->enclosingLayer()->h
asVisibleContent()) | 69 if (object.style()->visibility() != VISIBLE && !object.enclosingLayer()->has
VisibleContent()) |
58 return LayoutRect(); | 70 return LayoutRect(); |
59 | 71 |
60 // Pass our local paint rect to computeRectForPaintInvalidation() which will | 72 FloatRect paintInvalidationRect = object.paintInvalidationRectInLocalCoordin
ates(); |
61 // map to parent coords and recurse up the parent chain. | 73 inflateWithOutlineIfNeeded(paintInvalidationRect, object.styleRef()); |
62 FloatRect paintInvalidationRect = object->paintInvalidationRectInLocalCoordi
nates(); | |
63 paintInvalidationRect.inflate(object->style()->outlineWidth()); | |
64 | 74 |
65 if (paintInvalidationState && paintInvalidationState->canMapToContainer(pain
tInvalidationContainer)) { | 75 if (paintInvalidationState && paintInvalidationState->canMapToContainer(pain
tInvalidationContainer)) { |
66 // Compute accumulated SVG transform and apply to local paint rect. | 76 // Compute accumulated SVG transform and apply to local paint rect. |
67 AffineTransform transform = paintInvalidationState->svgTransform() * obj
ect->localToParentTransform(); | 77 AffineTransform transform = paintInvalidationState->svgTransform() * obj
ect.localToParentTransform(); |
68 paintInvalidationRect = transform.mapRect(paintInvalidationRect); | |
69 // FIXME: These are quirks carried forward from the old paint invalidati
on infrastructure. | 78 // FIXME: These are quirks carried forward from the old paint invalidati
on infrastructure. |
70 LayoutRect rect = enclosingIntRectIfNotEmpty(paintInvalidationRect); | 79 LayoutRect rect = enclosingIntRectIfNotEmpty(transform.mapRect(paintInva
lidationRect)); |
71 // Offset by SVG root paint offset and apply clipping as needed. | 80 // Offset by SVG root paint offset and apply clipping as needed. |
72 rect.move(paintInvalidationState->paintOffset()); | 81 rect.move(paintInvalidationState->paintOffset()); |
73 if (paintInvalidationState->isClipped()) | 82 if (paintInvalidationState->isClipped()) |
74 rect.intersect(paintInvalidationState->clipRect()); | 83 rect.intersect(paintInvalidationState->clipRect()); |
75 return rect; | 84 return rect; |
76 } | 85 } |
77 | 86 |
78 LayoutRect rect; | 87 LayoutRect rect; |
79 const LayoutSVGRoot& svgRoot = mapRectToSVGRootForPaintInvalidation(object,
paintInvalidationRect, rect); | 88 const LayoutSVGRoot& svgRoot = mapRectToSVGRootForPaintInvalidation(object,
paintInvalidationRect, rect); |
80 svgRoot.mapRectToPaintInvalidationBacking(paintInvalidationContainer, rect,
paintInvalidationState); | 89 svgRoot.mapRectToPaintInvalidationBacking(paintInvalidationContainer, rect,
paintInvalidationState); |
81 return rect; | 90 return rect; |
82 } | 91 } |
83 | 92 |
84 const LayoutSVGRoot& SVGLayoutSupport::mapRectToSVGRootForPaintInvalidation(cons
t LayoutObject* object, const FloatRect& localPaintInvalidationRect, LayoutRect&
rect) | 93 const LayoutSVGRoot& SVGLayoutSupport::mapRectToSVGRootForPaintInvalidation(cons
t LayoutObject& object, const FloatRect& localPaintInvalidationRect, LayoutRect&
rect) |
85 { | 94 { |
86 ASSERT(object && object->isSVG() && !object->isSVGRoot()); | 95 ASSERT(object.isSVG() && !object.isSVGRoot()); |
87 | 96 |
88 FloatRect paintInvalidationRect = localPaintInvalidationRect; | 97 FloatRect paintInvalidationRect = localPaintInvalidationRect; |
89 // FIXME: Building the transform to the SVG root border box and then doing | 98 // 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 | 99 // mapRect() with that would be slightly more efficient, but requires some |
91 // additions to AffineTransform (preMultiply, preTranslate) to avoid | 100 // additions to AffineTransform (preMultiply, preTranslate) to avoid |
92 // excessive copying and to get a similar fast-path for translations. | 101 // excessive copying and to get a similar fast-path for translations. |
93 const LayoutObject* parent = object; | 102 const LayoutObject* parent = &object; |
94 do { | 103 do { |
95 paintInvalidationRect = parent->localToParentTransform().mapRect(paintIn
validationRect); | 104 paintInvalidationRect = parent->localToParentTransform().mapRect(paintIn
validationRect); |
96 parent = parent->parent(); | 105 parent = parent->parent(); |
97 } while (!parent->isSVGRoot()); | 106 } while (!parent->isSVGRoot()); |
98 | 107 |
99 const LayoutSVGRoot& svgRoot = toLayoutSVGRoot(*parent); | 108 const LayoutSVGRoot& svgRoot = toLayoutSVGRoot(*parent); |
100 | 109 |
101 paintInvalidationRect = svgRoot.localToBorderBoxTransform().mapRect(paintInv
alidationRect); | 110 paintInvalidationRect = svgRoot.localToBorderBoxTransform().mapRect(paintInv
alidationRect); |
102 rect = enclosingIntRectIfNotEmpty(paintInvalidationRect); | 111 rect = enclosingIntRectIfNotEmpty(paintInvalidationRect); |
103 return svgRoot; | 112 return svgRoot; |
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
457 | 466 |
458 // FIXME: trying to compute a device space transform at record time is wrong
. All clients | 467 // FIXME: trying to compute a device space transform at record time is wrong
. All clients |
459 // should be updated to avoid relying on this information, and the method sh
ould be removed. | 468 // should be updated to avoid relying on this information, and the method sh
ould be removed. |
460 AffineTransform ctm = deprecatedCalculateTransformToLayer(layoutObject) * cu
rrentContentTransformation(); | 469 AffineTransform ctm = deprecatedCalculateTransformToLayer(layoutObject) * cu
rrentContentTransformation(); |
461 ctm.scale(layoutObject->document().frameHost()->deviceScaleFactor()); | 470 ctm.scale(layoutObject->document().frameHost()->deviceScaleFactor()); |
462 | 471 |
463 return narrowPrecisionToFloat(sqrt((pow(ctm.xScale(), 2) + pow(ctm.yScale(),
2)) / 2)); | 472 return narrowPrecisionToFloat(sqrt((pow(ctm.xScale(), 2) + pow(ctm.yScale(),
2)) / 2)); |
464 } | 473 } |
465 | 474 |
466 } | 475 } |
OLD | NEW |