| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "config.h" | 5 #include "config.h" |
| 6 #include "core/rendering/PaintInvalidationState.h" | 6 #include "core/rendering/PaintInvalidationState.h" |
| 7 | 7 |
| 8 #include "core/rendering/RenderInline.h" | 8 #include "core/rendering/RenderInline.h" |
| 9 #include "core/rendering/RenderLayer.h" | 9 #include "core/rendering/RenderLayer.h" |
| 10 #include "core/rendering/RenderView.h" | 10 #include "core/rendering/RenderView.h" |
| 11 #include "core/rendering/svg/RenderSVGModelObject.h" | 11 #include "core/rendering/svg/RenderSVGModelObject.h" |
| 12 #include "platform/Partitions.h" | 12 #include "platform/Partitions.h" |
| 13 | 13 |
| 14 namespace blink { | 14 namespace blink { |
| 15 | 15 |
| 16 PaintInvalidationState::PaintInvalidationState(RenderObject& renderer) | 16 PaintInvalidationState::PaintInvalidationState(RenderObject& renderer) |
| 17 : m_clipped(false) | 17 : m_clipped(false) |
| 18 , m_cachedOffsetsEnabled(true) | 18 , m_cachedOffsetsEnabled(true) |
| 19 , m_forceCheckForPaintInvalidation(false) |
| 19 , m_paintInvalidationContainer(*renderer.containerForPaintInvalidation()) | 20 , m_paintInvalidationContainer(*renderer.containerForPaintInvalidation()) |
| 20 , m_renderer(renderer) | 21 , m_renderer(renderer) |
| 21 { | 22 { |
| 22 bool establishesPaintInvalidationContainer = &m_renderer == &m_paintInvalida
tionContainer; | 23 bool establishesPaintInvalidationContainer = &m_renderer == &m_paintInvalida
tionContainer; |
| 23 if (!establishesPaintInvalidationContainer) { | 24 if (!establishesPaintInvalidationContainer) { |
| 24 if (!renderer.supportsLayoutStateCachedOffsets()) { | 25 if (!renderer.supportsLayoutStateCachedOffsets()) { |
| 25 m_cachedOffsetsEnabled = false; | 26 m_cachedOffsetsEnabled = false; |
| 26 return; | 27 return; |
| 27 } | 28 } |
| 28 bool invalidationContainerSkipped; | 29 bool invalidationContainerSkipped; |
| 29 RenderObject* container = renderer.container(&m_paintInvalidationContain
er, &invalidationContainerSkipped); | 30 RenderObject* container = renderer.container(&m_paintInvalidationContain
er, &invalidationContainerSkipped); |
| 30 if (container && !invalidationContainerSkipped) { | 31 if (container && !invalidationContainerSkipped) { |
| 31 FloatPoint point = container->localToContainerPoint(FloatPoint(), &m
_paintInvalidationContainer); | 32 FloatPoint point = container->localToContainerPoint(FloatPoint(), &m
_paintInvalidationContainer); |
| 32 if (container->isTableRow()) | 33 if (container->isTableRow()) |
| 33 point = FloatPoint(point.x() - toRenderBox(container)->x().toFlo
at(), point.y() - toRenderBox(container)->y().toFloat()); | 34 point = FloatPoint(point.x() - toRenderBox(container)->x().toFlo
at(), point.y() - toRenderBox(container)->y().toFloat()); |
| 34 m_paintOffset = LayoutSize(point.x(), point.y()); | 35 m_paintOffset = LayoutSize(point.x(), point.y()); |
| 35 | 36 |
| 36 applyClipIfNeeded(*container); | 37 applyClipIfNeeded(*container); |
| 37 } | 38 } |
| 38 } else { | 39 } else { |
| 39 applyClipIfNeeded(m_renderer); | 40 applyClipIfNeeded(m_renderer); |
| 40 } | 41 } |
| 41 } | 42 } |
| 42 | 43 |
| 43 PaintInvalidationState::PaintInvalidationState(const PaintInvalidationState& nex
t, RenderSVGModelObject& renderer, const RenderLayerModelObject& paintInvalidati
onContainer) | 44 PaintInvalidationState::PaintInvalidationState(const PaintInvalidationState& nex
t, RenderSVGModelObject& renderer, const RenderLayerModelObject& paintInvalidati
onContainer) |
| 44 : m_clipped(next.m_clipped) | 45 : m_clipped(next.m_clipped) |
| 45 , m_cachedOffsetsEnabled(next.m_cachedOffsetsEnabled) | 46 , m_cachedOffsetsEnabled(next.m_cachedOffsetsEnabled) |
| 47 , m_forceCheckForPaintInvalidation(next.m_forceCheckForPaintInvalidation) |
| 46 , m_paintInvalidationContainer(paintInvalidationContainer) | 48 , m_paintInvalidationContainer(paintInvalidationContainer) |
| 47 , m_renderer(renderer) | 49 , m_renderer(renderer) |
| 48 { | 50 { |
| 49 // FIXME: SVG could probably benefit from a stack-based optimization like ht
ml does. crbug.com/391054 | 51 // FIXME: SVG could probably benefit from a stack-based optimization like ht
ml does. crbug.com/391054 |
| 50 ASSERT(!m_cachedOffsetsEnabled); | 52 ASSERT(!m_cachedOffsetsEnabled); |
| 51 } | 53 } |
| 52 | 54 |
| 53 PaintInvalidationState::PaintInvalidationState(const PaintInvalidationState& nex
t, RenderInline& renderer, const RenderLayerModelObject& paintInvalidationContai
ner) | 55 PaintInvalidationState::PaintInvalidationState(const PaintInvalidationState& nex
t, RenderInline& renderer, const RenderLayerModelObject& paintInvalidationContai
ner) |
| 54 : m_clipped(false) | 56 : m_clipped(false) |
| 55 , m_cachedOffsetsEnabled(true) | 57 , m_cachedOffsetsEnabled(true) |
| 58 , m_forceCheckForPaintInvalidation(next.m_forceCheckForPaintInvalidation) |
| 56 , m_paintInvalidationContainer(paintInvalidationContainer) | 59 , m_paintInvalidationContainer(paintInvalidationContainer) |
| 57 , m_renderer(renderer) | 60 , m_renderer(renderer) |
| 58 { | 61 { |
| 59 bool establishesPaintInvalidationContainer = &m_renderer == &m_paintInvalida
tionContainer; | 62 bool establishesPaintInvalidationContainer = &m_renderer == &m_paintInvalida
tionContainer; |
| 60 if (!establishesPaintInvalidationContainer) { | 63 if (establishesPaintInvalidationContainer) { |
| 64 // When we hit a new paint invalidation container, we don't need to |
| 65 // continue forcing a check for paint invalidation because movement |
| 66 // from our parents will just move the whole invalidation container. |
| 67 m_forceCheckForPaintInvalidation = false; |
| 68 } else { |
| 61 if (!renderer.supportsLayoutStateCachedOffsets() || !next.m_cachedOffset
sEnabled) { | 69 if (!renderer.supportsLayoutStateCachedOffsets() || !next.m_cachedOffset
sEnabled) { |
| 62 m_cachedOffsetsEnabled = false; | 70 m_cachedOffsetsEnabled = false; |
| 63 } else if (m_cachedOffsetsEnabled) { | 71 } else if (m_cachedOffsetsEnabled) { |
| 64 m_paintOffset = next.m_paintOffset; | 72 m_paintOffset = next.m_paintOffset; |
| 65 // Handle relative positioned inline. | 73 // Handle relative positioned inline. |
| 66 if (renderer.style()->hasInFlowPosition() && renderer.layer()) | 74 if (renderer.style()->hasInFlowPosition() && renderer.layer()) |
| 67 m_paintOffset += renderer.layer()->offsetForInFlowPosition(); | 75 m_paintOffset += renderer.layer()->offsetForInFlowPosition(); |
| 68 | 76 |
| 69 // RenderInline can't be out-of-flow positioned. | 77 // RenderInline can't be out-of-flow positioned. |
| 70 } | 78 } |
| 71 | 79 |
| 72 // The following can't apply to RenderInline so we just propagate them. | 80 // The following can't apply to RenderInline so we just propagate them. |
| 73 m_clipped = next.m_clipped; | 81 m_clipped = next.m_clipped; |
| 74 m_clipRect = next.m_clipRect; | 82 m_clipRect = next.m_clipRect; |
| 75 } | 83 } |
| 76 } | 84 } |
| 77 | 85 |
| 78 PaintInvalidationState::PaintInvalidationState(const PaintInvalidationState& nex
t, RenderBox& renderer, const RenderLayerModelObject& paintInvalidationContainer
) | 86 PaintInvalidationState::PaintInvalidationState(const PaintInvalidationState& nex
t, RenderBox& renderer, const RenderLayerModelObject& paintInvalidationContainer
) |
| 79 : m_clipped(false) | 87 : m_clipped(false) |
| 80 , m_cachedOffsetsEnabled(true) | 88 , m_cachedOffsetsEnabled(true) |
| 89 , m_forceCheckForPaintInvalidation(next.m_forceCheckForPaintInvalidation) |
| 81 , m_paintInvalidationContainer(paintInvalidationContainer) | 90 , m_paintInvalidationContainer(paintInvalidationContainer) |
| 82 , m_renderer(renderer) | 91 , m_renderer(renderer) |
| 83 { | 92 { |
| 84 bool establishesPaintInvalidationContainer = &m_renderer == &m_paintInvalida
tionContainer; | 93 bool establishesPaintInvalidationContainer = &m_renderer == &m_paintInvalida
tionContainer; |
| 85 bool fixed = m_renderer.isOutOfFlowPositioned() && m_renderer.style()->posit
ion() == FixedPosition; | 94 bool fixed = m_renderer.isOutOfFlowPositioned() && m_renderer.style()->posit
ion() == FixedPosition; |
| 86 | 95 |
| 87 if (!establishesPaintInvalidationContainer) { | 96 if (establishesPaintInvalidationContainer) { |
| 97 // When we hit a new paint invalidation container, we don't need to |
| 98 // continue forcing a check for paint invalidation because movement |
| 99 // from our parents will just move the whole invalidation container. |
| 100 m_forceCheckForPaintInvalidation = false; |
| 101 } else { |
| 88 if (!renderer.supportsLayoutStateCachedOffsets() || !next.m_cachedOffset
sEnabled) { | 102 if (!renderer.supportsLayoutStateCachedOffsets() || !next.m_cachedOffset
sEnabled) { |
| 89 m_cachedOffsetsEnabled = false; | 103 m_cachedOffsetsEnabled = false; |
| 90 } else { | 104 } else { |
| 91 LayoutSize offset = m_renderer.isTableRow() ? LayoutSize() : rendere
r.locationOffset(); | 105 LayoutSize offset = m_renderer.isTableRow() ? LayoutSize() : rendere
r.locationOffset(); |
| 92 if (fixed) { | 106 if (fixed) { |
| 93 // FIXME: This doesn't work correctly with transforms. | 107 // FIXME: This doesn't work correctly with transforms. |
| 94 FloatPoint fixedOffset = m_renderer.view()->localToAbsolute(Floa
tPoint(), IsFixed); | 108 FloatPoint fixedOffset = m_renderer.view()->localToAbsolute(Floa
tPoint(), IsFixed); |
| 95 m_paintOffset = LayoutSize(fixedOffset.x(), fixedOffset.y()) + o
ffset; | 109 m_paintOffset = LayoutSize(fixedOffset.x(), fixedOffset.y()) + o
ffset; |
| 96 } else { | 110 } else { |
| 97 m_paintOffset = next.m_paintOffset + offset; | 111 m_paintOffset = next.m_paintOffset + offset; |
| (...skipping 30 matching lines...) Expand all Loading... |
| 128 if (m_clipped) { | 142 if (m_clipped) { |
| 129 m_clipRect.intersect(clipRect); | 143 m_clipRect.intersect(clipRect); |
| 130 } else { | 144 } else { |
| 131 m_clipRect = clipRect; | 145 m_clipRect = clipRect; |
| 132 m_clipped = true; | 146 m_clipped = true; |
| 133 } | 147 } |
| 134 m_paintOffset -= box.scrolledContentOffset(); | 148 m_paintOffset -= box.scrolledContentOffset(); |
| 135 } | 149 } |
| 136 | 150 |
| 137 } // namespace blink | 151 } // namespace blink |
| OLD | NEW |