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(const RenderView& renderView) | 16 PaintInvalidationState::PaintInvalidationState(const RenderView& renderView) |
17 : m_clipped(false) | 17 : m_clipped(false) |
18 , m_cachedOffsetsEnabled(true) | 18 , m_cachedOffsetsEnabled(true) |
19 , m_forceCheckForPaintInvalidation(false) | 19 , m_forceCheckForPaintInvalidation(false) |
20 , m_paintInvalidationContainer(*renderView.containerForPaintInvalidation()) | 20 , m_paintInvalidationContainer(*renderView.containerForPaintInvalidation()) |
21 , m_renderer(renderView) | |
22 { | 21 { |
23 bool establishesPaintInvalidationContainer = &m_renderer == &m_paintInvalida
tionContainer; | 22 bool establishesPaintInvalidationContainer = renderView == m_paintInvalidati
onContainer; |
24 if (!establishesPaintInvalidationContainer) { | 23 if (!establishesPaintInvalidationContainer) { |
25 if (!renderView.supportsPaintInvalidationStateCachedOffsets()) { | 24 if (!renderView.supportsPaintInvalidationStateCachedOffsets()) { |
26 m_cachedOffsetsEnabled = false; | 25 m_cachedOffsetsEnabled = false; |
27 return; | 26 return; |
28 } | 27 } |
29 FloatPoint point = renderView.localToContainerPoint(FloatPoint(), &m_pai
ntInvalidationContainer, TraverseDocumentBoundaries); | 28 FloatPoint point = renderView.localToContainerPoint(FloatPoint(), &m_pai
ntInvalidationContainer, TraverseDocumentBoundaries); |
30 m_paintOffset = LayoutSize(point.x(), point.y()); | 29 m_paintOffset = LayoutSize(point.x(), point.y()); |
31 } | 30 } |
32 m_clipRect = renderView.viewRect(); | 31 m_clipRect = renderView.viewRect(); |
33 m_clipRect.move(m_paintOffset); | 32 m_clipRect.move(m_paintOffset); |
34 m_clipped = true; | 33 m_clipped = true; |
35 } | 34 } |
36 | 35 |
37 PaintInvalidationState::PaintInvalidationState(const PaintInvalidationState& nex
t, RenderLayerModelObject& renderer, const RenderLayerModelObject& paintInvalida
tionContainer) | 36 PaintInvalidationState::PaintInvalidationState(const PaintInvalidationState& nex
t, RenderLayerModelObject& renderer, const RenderLayerModelObject& paintInvalida
tionContainer) |
38 : m_clipped(false) | 37 : m_clipped(false) |
39 , m_cachedOffsetsEnabled(true) | 38 , m_cachedOffsetsEnabled(true) |
40 , m_forceCheckForPaintInvalidation(next.m_forceCheckForPaintInvalidation) | 39 , m_forceCheckForPaintInvalidation(next.m_forceCheckForPaintInvalidation) |
41 , m_paintInvalidationContainer(paintInvalidationContainer) | 40 , m_paintInvalidationContainer(paintInvalidationContainer) |
42 , m_renderer(renderer) | |
43 { | 41 { |
44 // FIXME: SVG could probably benefit from a stack-based optimization like ht
ml does. crbug.com/391054 | 42 // FIXME: SVG could probably benefit from a stack-based optimization like ht
ml does. crbug.com/391054 |
45 bool establishesPaintInvalidationContainer = &m_renderer == &m_paintInvalida
tionContainer; | 43 bool establishesPaintInvalidationContainer = renderer == m_paintInvalidation
Container; |
46 bool fixed = m_renderer.style()->position() == FixedPosition; | 44 bool fixed = renderer.style()->position() == FixedPosition; |
47 | 45 |
48 if (establishesPaintInvalidationContainer) { | 46 if (establishesPaintInvalidationContainer) { |
49 // When we hit a new paint invalidation container, we don't need to | 47 // When we hit a new paint invalidation container, we don't need to |
50 // continue forcing a check for paint invalidation because movement | 48 // continue forcing a check for paint invalidation because movement |
51 // from our parents will just move the whole invalidation container. | 49 // from our parents will just move the whole invalidation container. |
52 m_forceCheckForPaintInvalidation = false; | 50 m_forceCheckForPaintInvalidation = false; |
53 } else { | 51 } else { |
54 if (!renderer.supportsPaintInvalidationStateCachedOffsets() || !next.m_c
achedOffsetsEnabled) { | 52 if (!renderer.supportsPaintInvalidationStateCachedOffsets() || !next.m_c
achedOffsetsEnabled) { |
55 m_cachedOffsetsEnabled = false; | 53 m_cachedOffsetsEnabled = false; |
56 } else { | 54 } else { |
57 if (fixed) { | 55 if (fixed) { |
58 FloatPoint fixedOffset = m_renderer.localToContainerPoint(FloatP
oint(), &m_paintInvalidationContainer, TraverseDocumentBoundaries); | 56 FloatPoint fixedOffset = renderer.localToContainerPoint(FloatPoi
nt(), &m_paintInvalidationContainer, TraverseDocumentBoundaries); |
59 m_paintOffset = LayoutSize(fixedOffset.x(), fixedOffset.y()); | 57 m_paintOffset = LayoutSize(fixedOffset.x(), fixedOffset.y()); |
60 } else { | 58 } else { |
61 LayoutSize offset = m_renderer.isBox() && !m_renderer.isTableRow
() ? toRenderBox(renderer).locationOffset() : LayoutSize(); | 59 LayoutSize offset = renderer.isBox() && !renderer.isTableRow() ?
toRenderBox(renderer).locationOffset() : LayoutSize(); |
62 m_paintOffset = next.m_paintOffset + offset; | 60 m_paintOffset = next.m_paintOffset + offset; |
63 } | 61 } |
64 | 62 |
65 if (m_renderer.isOutOfFlowPositioned() && !fixed) { | 63 if (renderer.isOutOfFlowPositioned() && !fixed) { |
66 if (RenderObject* container = m_renderer.container()) { | 64 if (RenderObject* container = renderer.container()) { |
67 if (container->style()->hasInFlowPosition() && container->is
RenderInline()) | 65 if (container->style()->hasInFlowPosition() && container->is
RenderInline()) |
68 m_paintOffset += toRenderInline(container)->offsetForInF
lowPositionedInline(toRenderBox(renderer)); | 66 m_paintOffset += toRenderInline(container)->offsetForInF
lowPositionedInline(toRenderBox(renderer)); |
69 } | 67 } |
70 } | 68 } |
71 | 69 |
72 if (m_renderer.style()->hasInFlowPosition() && renderer.hasLayer()) | 70 if (renderer.style()->hasInFlowPosition() && renderer.hasLayer()) |
73 m_paintOffset += renderer.layer()->offsetForInFlowPosition(); | 71 m_paintOffset += renderer.layer()->offsetForInFlowPosition(); |
74 } | 72 } |
75 | 73 |
76 m_clipped = !fixed && next.m_clipped; | 74 m_clipped = !fixed && next.m_clipped; |
77 if (m_clipped) | 75 if (m_clipped) |
78 m_clipRect = next.m_clipRect; | 76 m_clipRect = next.m_clipRect; |
79 } | 77 } |
80 | 78 |
81 applyClipIfNeeded(renderer); | 79 applyClipIfNeeded(renderer); |
82 | 80 |
(...skipping 10 matching lines...) Expand all Loading... |
93 if (m_clipped) { | 91 if (m_clipped) { |
94 m_clipRect.intersect(clipRect); | 92 m_clipRect.intersect(clipRect); |
95 } else { | 93 } else { |
96 m_clipRect = clipRect; | 94 m_clipRect = clipRect; |
97 m_clipped = true; | 95 m_clipped = true; |
98 } | 96 } |
99 m_paintOffset -= box.scrolledContentOffset(); | 97 m_paintOffset -= box.scrolledContentOffset(); |
100 } | 98 } |
101 | 99 |
102 } // namespace blink | 100 } // namespace blink |
OLD | NEW |