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" |
(...skipping 23 matching lines...) Expand all Loading... |
34 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()); |
35 m_paintOffset = LayoutSize(point.x(), point.y()); | 35 m_paintOffset = LayoutSize(point.x(), point.y()); |
36 | 36 |
37 applyClipIfNeeded(*container); | 37 applyClipIfNeeded(*container); |
38 } | 38 } |
39 } else { | 39 } else { |
40 applyClipIfNeeded(m_renderer); | 40 applyClipIfNeeded(m_renderer); |
41 } | 41 } |
42 } | 42 } |
43 | 43 |
44 PaintInvalidationState::PaintInvalidationState(const PaintInvalidationState& nex
t, RenderSVGModelObject& renderer, const RenderLayerModelObject& paintInvalidati
onContainer) | 44 PaintInvalidationState::PaintInvalidationState(const PaintInvalidationState& nex
t, RenderLayerModelObject& renderer, const RenderLayerModelObject& paintInvalida
tionContainer) |
45 : m_clipped(next.m_clipped) | |
46 , m_cachedOffsetsEnabled(next.m_cachedOffsetsEnabled) | |
47 , m_forceCheckForPaintInvalidation(next.m_forceCheckForPaintInvalidation) | |
48 , m_paintInvalidationContainer(paintInvalidationContainer) | |
49 , m_renderer(renderer) | |
50 { | |
51 // FIXME: SVG could probably benefit from a stack-based optimization like ht
ml does. crbug.com/391054 | |
52 ASSERT(!m_cachedOffsetsEnabled); | |
53 } | |
54 | |
55 PaintInvalidationState::PaintInvalidationState(const PaintInvalidationState& nex
t, RenderInline& renderer, const RenderLayerModelObject& paintInvalidationContai
ner) | |
56 : m_clipped(false) | 45 : m_clipped(false) |
57 , m_cachedOffsetsEnabled(true) | 46 , m_cachedOffsetsEnabled(true) |
58 , m_forceCheckForPaintInvalidation(next.m_forceCheckForPaintInvalidation) | 47 , m_forceCheckForPaintInvalidation(next.m_forceCheckForPaintInvalidation) |
59 , m_paintInvalidationContainer(paintInvalidationContainer) | 48 , m_paintInvalidationContainer(paintInvalidationContainer) |
60 , m_renderer(renderer) | 49 , m_renderer(renderer) |
61 { | 50 { |
62 bool establishesPaintInvalidationContainer = &m_renderer == &m_paintInvalida
tionContainer; | 51 // FIXME: SVG could probably benefit from a stack-based optimization like ht
ml does. crbug.com/391054 |
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 { | |
69 if (!renderer.supportsPaintInvalidationStateCachedOffsets() || !next.m_c
achedOffsetsEnabled) { | |
70 m_cachedOffsetsEnabled = false; | |
71 } else if (m_cachedOffsetsEnabled) { | |
72 m_paintOffset = next.m_paintOffset; | |
73 // Handle relative positioned inline. | |
74 if (renderer.style()->hasInFlowPosition() && renderer.layer()) | |
75 m_paintOffset += renderer.layer()->offsetForInFlowPosition(); | |
76 | |
77 // RenderInline can't be out-of-flow positioned. | |
78 } | |
79 | |
80 // The following can't apply to RenderInline so we just propagate them. | |
81 m_clipped = next.m_clipped; | |
82 m_clipRect = next.m_clipRect; | |
83 } | |
84 } | |
85 | |
86 PaintInvalidationState::PaintInvalidationState(const PaintInvalidationState& nex
t, RenderBox& renderer, const RenderLayerModelObject& paintInvalidationContainer
) | |
87 : m_clipped(false) | |
88 , m_cachedOffsetsEnabled(true) | |
89 , m_forceCheckForPaintInvalidation(next.m_forceCheckForPaintInvalidation) | |
90 , m_paintInvalidationContainer(paintInvalidationContainer) | |
91 , m_renderer(renderer) | |
92 { | |
93 bool establishesPaintInvalidationContainer = &m_renderer == &m_paintInvalida
tionContainer; | 52 bool establishesPaintInvalidationContainer = &m_renderer == &m_paintInvalida
tionContainer; |
94 bool fixed = m_renderer.isOutOfFlowPositioned() && m_renderer.style()->posit
ion() == FixedPosition; | 53 bool fixed = m_renderer.isOutOfFlowPositioned() && m_renderer.style()->posit
ion() == FixedPosition; |
95 | 54 |
96 if (establishesPaintInvalidationContainer) { | 55 if (establishesPaintInvalidationContainer) { |
97 // When we hit a new paint invalidation container, we don't need to | 56 // When we hit a new paint invalidation container, we don't need to |
98 // continue forcing a check for paint invalidation because movement | 57 // continue forcing a check for paint invalidation because movement |
99 // from our parents will just move the whole invalidation container. | 58 // from our parents will just move the whole invalidation container. |
100 m_forceCheckForPaintInvalidation = false; | 59 m_forceCheckForPaintInvalidation = false; |
101 } else { | 60 } else { |
102 if (!renderer.supportsPaintInvalidationStateCachedOffsets() || !next.m_c
achedOffsetsEnabled) { | 61 if (!renderer.supportsPaintInvalidationStateCachedOffsets() || !next.m_c
achedOffsetsEnabled) { |
103 m_cachedOffsetsEnabled = false; | 62 m_cachedOffsetsEnabled = false; |
104 } else { | 63 } else { |
105 LayoutSize offset = m_renderer.isTableRow() ? LayoutSize() : rendere
r.locationOffset(); | 64 LayoutSize offset = m_renderer.isBox() && !m_renderer.isTableRow() ?
toRenderBox(renderer).locationOffset() : LayoutSize(); |
106 if (fixed) { | 65 if (fixed) { |
107 // FIXME: This doesn't work correctly with transforms. | 66 // FIXME: This doesn't work correctly with transforms. |
108 FloatPoint fixedOffset = m_renderer.view()->localToAbsolute(Floa
tPoint(), IsFixed); | 67 FloatPoint fixedOffset = m_renderer.view()->localToAbsolute(Floa
tPoint(), IsFixed); |
109 m_paintOffset = LayoutSize(fixedOffset.x(), fixedOffset.y()) + o
ffset; | 68 m_paintOffset = LayoutSize(fixedOffset.x(), fixedOffset.y()) + o
ffset; |
110 } else { | 69 } else { |
111 m_paintOffset = next.m_paintOffset + offset; | 70 m_paintOffset = next.m_paintOffset + offset; |
112 } | 71 } |
113 | 72 |
114 if (m_renderer.isOutOfFlowPositioned() && !fixed) { | 73 if (m_renderer.isOutOfFlowPositioned() && !fixed) { |
115 if (RenderObject* container = m_renderer.container()) { | 74 if (RenderObject* container = m_renderer.container()) { |
116 if (container->style()->hasInFlowPosition() && container->is
RenderInline()) | 75 if (container->style()->hasInFlowPosition() && container->is
RenderInline()) |
117 m_paintOffset += toRenderInline(container)->offsetForInF
lowPositionedInline(renderer); | 76 m_paintOffset += toRenderInline(container)->offsetForInF
lowPositionedInline(toRenderBox(renderer)); |
118 } | 77 } |
119 } | 78 } |
120 | 79 |
121 if (m_renderer.style()->hasInFlowPosition() && renderer.hasLayer()) | 80 if (m_renderer.style()->hasInFlowPosition() && renderer.hasLayer()) |
122 m_paintOffset += renderer.layer()->offsetForInFlowPosition(); | 81 m_paintOffset += renderer.layer()->offsetForInFlowPosition(); |
123 } | 82 } |
124 | 83 |
125 m_clipped = !fixed && next.m_clipped; | 84 m_clipped = !fixed && next.m_clipped; |
126 if (m_clipped) | 85 if (m_clipped) |
127 m_clipRect = next.m_clipRect; | 86 m_clipRect = next.m_clipRect; |
(...skipping 14 matching lines...) Expand all Loading... |
142 if (m_clipped) { | 101 if (m_clipped) { |
143 m_clipRect.intersect(clipRect); | 102 m_clipRect.intersect(clipRect); |
144 } else { | 103 } else { |
145 m_clipRect = clipRect; | 104 m_clipRect = clipRect; |
146 m_clipped = true; | 105 m_clipped = true; |
147 } | 106 } |
148 m_paintOffset -= box.scrolledContentOffset(); | 107 m_paintOffset -= box.scrolledContentOffset(); |
149 } | 108 } |
150 | 109 |
151 } // namespace blink | 110 } // namespace blink |
OLD | NEW |