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 m_forceCheckForPaintInvalidation = false; | |
Julien - ping for review
2014/08/01 21:20:01
Let's add a comment about why we clear the flag as
abarth-chromium
2014/08/01 21:22:51
Ok.
| |
65 } else { | |
61 if (!renderer.supportsLayoutStateCachedOffsets() || !next.m_cachedOffset sEnabled) { | 66 if (!renderer.supportsLayoutStateCachedOffsets() || !next.m_cachedOffset sEnabled) { |
62 m_cachedOffsetsEnabled = false; | 67 m_cachedOffsetsEnabled = false; |
63 } else if (m_cachedOffsetsEnabled) { | 68 } else if (m_cachedOffsetsEnabled) { |
64 m_paintOffset = next.m_paintOffset; | 69 m_paintOffset = next.m_paintOffset; |
65 // Handle relative positioned inline. | 70 // Handle relative positioned inline. |
66 if (renderer.style()->hasInFlowPosition() && renderer.layer()) | 71 if (renderer.style()->hasInFlowPosition() && renderer.layer()) |
67 m_paintOffset += renderer.layer()->offsetForInFlowPosition(); | 72 m_paintOffset += renderer.layer()->offsetForInFlowPosition(); |
68 | 73 |
69 // RenderInline can't be out-of-flow positioned. | 74 // RenderInline can't be out-of-flow positioned. |
70 } | 75 } |
71 | 76 |
72 // The following can't apply to RenderInline so we just propagate them. | 77 // The following can't apply to RenderInline so we just propagate them. |
73 m_clipped = next.m_clipped; | 78 m_clipped = next.m_clipped; |
74 m_clipRect = next.m_clipRect; | 79 m_clipRect = next.m_clipRect; |
75 } | 80 } |
76 } | 81 } |
77 | 82 |
78 PaintInvalidationState::PaintInvalidationState(const PaintInvalidationState& nex t, RenderBox& renderer, const RenderLayerModelObject& paintInvalidationContainer ) | 83 PaintInvalidationState::PaintInvalidationState(const PaintInvalidationState& nex t, RenderBox& renderer, const RenderLayerModelObject& paintInvalidationContainer ) |
79 : m_clipped(false) | 84 : m_clipped(false) |
80 , m_cachedOffsetsEnabled(true) | 85 , m_cachedOffsetsEnabled(true) |
86 , m_forceCheckForPaintInvalidation(next.m_forceCheckForPaintInvalidation) | |
81 , m_paintInvalidationContainer(paintInvalidationContainer) | 87 , m_paintInvalidationContainer(paintInvalidationContainer) |
82 , m_renderer(renderer) | 88 , m_renderer(renderer) |
83 { | 89 { |
84 bool establishesPaintInvalidationContainer = &m_renderer == &m_paintInvalida tionContainer; | 90 bool establishesPaintInvalidationContainer = &m_renderer == &m_paintInvalida tionContainer; |
85 bool fixed = m_renderer.isOutOfFlowPositioned() && m_renderer.style()->posit ion() == FixedPosition; | 91 bool fixed = m_renderer.isOutOfFlowPositioned() && m_renderer.style()->posit ion() == FixedPosition; |
86 | 92 |
87 if (!establishesPaintInvalidationContainer) { | 93 if (establishesPaintInvalidationContainer) { |
94 m_forceCheckForPaintInvalidation = false; | |
Julien - ping for review
2014/08/01 21:20:01
Ditto.
| |
95 } else { | |
88 if (!renderer.supportsLayoutStateCachedOffsets() || !next.m_cachedOffset sEnabled) { | 96 if (!renderer.supportsLayoutStateCachedOffsets() || !next.m_cachedOffset sEnabled) { |
89 m_cachedOffsetsEnabled = false; | 97 m_cachedOffsetsEnabled = false; |
90 } else { | 98 } else { |
91 LayoutSize offset = m_renderer.isTableRow() ? LayoutSize() : rendere r.locationOffset(); | 99 LayoutSize offset = m_renderer.isTableRow() ? LayoutSize() : rendere r.locationOffset(); |
92 if (fixed) { | 100 if (fixed) { |
93 // FIXME: This doesn't work correctly with transforms. | 101 // FIXME: This doesn't work correctly with transforms. |
94 FloatPoint fixedOffset = m_renderer.view()->localToAbsolute(Floa tPoint(), IsFixed); | 102 FloatPoint fixedOffset = m_renderer.view()->localToAbsolute(Floa tPoint(), IsFixed); |
95 m_paintOffset = LayoutSize(fixedOffset.x(), fixedOffset.y()) + o ffset; | 103 m_paintOffset = LayoutSize(fixedOffset.x(), fixedOffset.y()) + o ffset; |
96 } else { | 104 } else { |
97 m_paintOffset = next.m_paintOffset + offset; | 105 m_paintOffset = next.m_paintOffset + offset; |
(...skipping 30 matching lines...) Expand all Loading... | |
128 if (m_clipped) { | 136 if (m_clipped) { |
129 m_clipRect.intersect(clipRect); | 137 m_clipRect.intersect(clipRect); |
130 } else { | 138 } else { |
131 m_clipRect = clipRect; | 139 m_clipRect = clipRect; |
132 m_clipped = true; | 140 m_clipped = true; |
133 } | 141 } |
134 m_paintOffset -= box.scrolledContentOffset(); | 142 m_paintOffset -= box.scrolledContentOffset(); |
135 } | 143 } |
136 | 144 |
137 } // namespace blink | 145 } // namespace blink |
OLD | NEW |