OLD | NEW |
---|---|
(Empty) | |
1 /* | |
2 * Copyright (C) 2014 Google Inc. All rights reserved. | |
3 * | |
4 * Redistribution and use in source and binary forms, with or without | |
5 * modification, are permitted provided that the following conditions are | |
6 * met: | |
7 * | |
8 * * Redistributions of source code must retain the above copyright | |
9 * notice, this list of conditions and the following disclaimer. | |
10 * * Redistributions in binary form must reproduce the above | |
11 * copyright notice, this list of conditions and the following disclaimer | |
12 * in the documentation and/or other materials provided with the | |
13 * distribution. | |
14 * * Neither the name of Google Inc. nor the names of its | |
15 * contributors may be used to endorse or promote products derived from | |
16 * this software without specific prior written permission. | |
17 * | |
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | |
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
29 */ | |
30 | |
31 #include "config.h" | |
32 #include "core/rendering/InvalidationTreeWalkState.h" | |
33 | |
34 #include "core/rendering/RenderInline.h" | |
35 #include "core/rendering/RenderLayer.h" | |
36 #include "core/rendering/RenderView.h" | |
37 #include "core/rendering/svg/RenderSVGModelObject.h" | |
38 #include "platform/Partitions.h" | |
39 | |
40 namespace WebCore { | |
41 | |
42 InvalidationTreeWalkState::InvalidationTreeWalkState(RenderObject& renderer) | |
43 : m_clipped(false) | |
44 , m_cachedOffsetsEnabled(true) | |
45 , m_paintInvalidationContainer(*renderer.containerForPaintInvalidation()) | |
46 , m_renderer(renderer) | |
47 { | |
48 bool establishesPaintInvalidationContainer = &m_renderer == &m_paintInvalida tionContainer; | |
49 if (!establishesPaintInvalidationContainer) { | |
50 if (!renderer.supportsLayoutStateCachedOffsets()) { | |
51 m_cachedOffsetsEnabled = false; | |
52 return; | |
53 } | |
54 bool invalidationContainerSkipped; | |
55 RenderObject* container = renderer.container(&m_paintInvalidationContain er, &invalidationContainerSkipped); | |
56 if (container && !invalidationContainerSkipped) { | |
57 // m_diabled = true; | |
58 FloatPoint point = container->localToContainerPoint(FloatPoint(), &m _paintInvalidationContainer); | |
59 if (container->isTableRow()) | |
60 point = FloatPoint(point.x() - toRenderBox(container)->x().toFlo at(), point.y() - toRenderBox(container)->y().toFloat()); | |
61 m_paintOffset = LayoutSize(point.x(), point.y()); | |
62 | |
63 applyClipIfNeeded(*container); | |
64 } | |
65 } else { | |
66 applyClipIfNeeded(m_renderer); | |
67 } | |
68 } | |
69 | |
70 InvalidationTreeWalkState::InvalidationTreeWalkState(const InvalidationTreeWalkS tate& next, RenderSVGModelObject& renderer, const RenderLayerModelObject& paintI nvalidationContainer) | |
71 : m_clipped(next.m_clipped) | |
72 , m_cachedOffsetsEnabled(false) | |
Julien - ping for review
2014/07/02 00:27:28
Disabling cachedOffset as part of the constructor
leviw_travelin_and_unemployed
2014/07/02 00:41:02
Fair enough. I'll add an assert that we never exit
| |
73 , m_paintInvalidationContainer(paintInvalidationContainer) | |
74 , m_renderer(renderer) | |
75 { } | |
Julien - ping for review
2014/07/02 00:27:28
Nit: 1 curly brace per line.
leviw_travelin_and_unemployed
2014/07/02 00:41:02
Really? We have over 1000 examples if this constru
Julien - ping for review
2014/07/07 22:09:59
Usually I would see that in header files (for inli
| |
76 | |
77 InvalidationTreeWalkState::InvalidationTreeWalkState(const InvalidationTreeWalkS tate& next, RenderInline& renderer, const RenderLayerModelObject& paintInvalidat ionContainer) | |
78 : m_clipped(next.m_clipped) | |
79 , m_cachedOffsetsEnabled(true) | |
80 , m_paintInvalidationContainer(paintInvalidationContainer) | |
81 , m_renderer(renderer) | |
82 { | |
83 bool establishesPaintInvalidationContainer = &m_renderer == &m_paintInvalida tionContainer; | |
84 if (!establishesPaintInvalidationContainer) { | |
85 if (!renderer.supportsLayoutStateCachedOffsets() || !next.m_cachedOffset sEnabled) { | |
86 m_cachedOffsetsEnabled = false; | |
87 } else if (m_cachedOffsetsEnabled) { | |
88 m_paintOffset = next.m_paintOffset; | |
89 // Handle relative positioned inline. | |
90 if (renderer.style()->hasInFlowPosition() && renderer.layer()) | |
91 m_paintOffset += renderer.layer()->offsetForInFlowPosition(); | |
92 | |
93 // RenderInline can't be out-of-flow positioned. | |
94 } | |
95 } | |
96 | |
97 // The following can't apply to RenderInline so we just propagate them. | |
98 m_clipped = next.m_clipped; | |
99 m_clipRect = next.m_clipRect; | |
100 } | |
101 | |
102 InvalidationTreeWalkState::InvalidationTreeWalkState(const InvalidationTreeWalkS tate& next, RenderBox& renderer, const RenderLayerModelObject& paintInvalidation Container) | |
103 : m_clipped(false) | |
104 , m_cachedOffsetsEnabled(true) | |
105 , m_paintInvalidationContainer(paintInvalidationContainer) | |
106 , m_renderer(renderer) | |
107 { | |
108 ASSERT(&m_paintInvalidationContainer == renderer.containerForPaintInvalidati on() || !next.m_cachedOffsetsEnabled); | |
109 bool establishesPaintInvalidationContainer = &m_renderer == &m_paintInvalida tionContainer; | |
110 bool fixed = m_renderer.isOutOfFlowPositioned() && m_renderer.style()->posit ion() == FixedPosition; | |
111 | |
112 if (!establishesPaintInvalidationContainer) { | |
113 if (!renderer.supportsLayoutStateCachedOffsets() || !next.m_cachedOffset sEnabled) { | |
114 m_cachedOffsetsEnabled = false; | |
115 } else { | |
116 LayoutSize offset = m_renderer.isTableRow() ? LayoutSize() : rendere r.locationOffset(); | |
117 if (fixed) { | |
118 // FIXME: This doesn't work correctly with transforms. | |
119 FloatPoint fixedOffset = m_renderer.view()->localToAbsolute(Floa tPoint(), IsFixed); | |
120 m_paintOffset = LayoutSize(fixedOffset.x(), fixedOffset.y()) + o ffset; | |
121 } else { | |
122 m_paintOffset = next.m_paintOffset + offset; | |
123 } | |
124 | |
125 if (m_renderer.isOutOfFlowPositioned() && !fixed) { | |
126 if (RenderObject* container = m_renderer.container()) { | |
127 if (container->style()->hasInFlowPosition() && container->is RenderInline()) | |
128 m_paintOffset += toRenderInline(container)->offsetForInF lowPositionedInline(renderer); | |
129 } | |
130 } | |
131 | |
132 if (m_renderer.style()->hasInFlowPosition() && renderer.hasLayer()) | |
133 m_paintOffset += renderer.layer()->offsetForInFlowPosition(); | |
134 } | |
135 } | |
136 | |
137 m_clipped = !fixed && next.m_clipped; | |
138 if (m_clipped) | |
139 m_clipRect = next.m_clipRect; | |
140 | |
141 applyClipIfNeeded(renderer); | |
142 | |
143 // FIXME: <http://bugs.webkit.org/show_bug.cgi?id=13443> Apply control clip if present. | |
144 } | |
145 | |
146 void InvalidationTreeWalkState::applyClipIfNeeded(const RenderObject& renderer) | |
147 { | |
148 if (renderer.hasOverflowClip()) { | |
149 const RenderBox* box = toRenderBox(&renderer); | |
150 LayoutRect clipRect(toPoint(m_paintOffset), box->cachedSizeForOverflowCl ip()); | |
151 if (m_clipped) { | |
152 m_clipRect.intersect(clipRect); | |
153 } else { | |
154 m_clipRect = clipRect; | |
155 m_clipped = true; | |
156 } | |
157 m_paintOffset -= box->scrolledContentOffset(); | |
158 } | |
159 } | |
160 | |
161 } // namespace WebCore | |
OLD | NEW |