OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2007 Apple Inc. All rights reserved. | 2 * Copyright (C) 2007 Apple Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 15 matching lines...) Expand all Loading... | |
26 #include "config.h" | 26 #include "config.h" |
27 #include "core/rendering/LayoutState.h" | 27 #include "core/rendering/LayoutState.h" |
28 | 28 |
29 #include "core/rendering/RenderInline.h" | 29 #include "core/rendering/RenderInline.h" |
30 #include "core/rendering/RenderLayer.h" | 30 #include "core/rendering/RenderLayer.h" |
31 #include "core/rendering/RenderView.h" | 31 #include "core/rendering/RenderView.h" |
32 #include "platform/Partitions.h" | 32 #include "platform/Partitions.h" |
33 | 33 |
34 namespace WebCore { | 34 namespace WebCore { |
35 | 35 |
36 LayoutState::LayoutState(LayoutState* prev, RenderBox& renderer, const LayoutSiz e& offset, LayoutUnit pageLogicalHeight, bool pageLogicalHeightChanged, ColumnIn fo* columnInfo) | 36 LayoutState::LayoutState(LayoutUnit pageLogicalHeight, bool pageLogicalHeightCha nged, RenderView& view) |
37 : m_clipped(false) | |
38 , m_isPaginated(pageLogicalHeight) | |
39 , m_pageLogicalHeightChanged(pageLogicalHeightChanged) | |
40 , m_cachedOffsetsEnabled(true) | |
41 #if ASSERT_ENABLED | |
42 , m_layoutDeltaXSaturated(false) | |
43 , m_layoutDeltaYSaturated(false) | |
44 #endif | |
45 , m_columnInfo(0) | |
46 , m_next(0) | |
47 , m_pageLogicalHeight(pageLogicalHeight) | |
48 , m_renderer(view) | |
49 { | |
50 ASSERT(!view.layoutState()); | |
51 view.pushLayoutState(*this); | |
52 } | |
53 | |
54 LayoutState::LayoutState(RenderBox& renderer, const LayoutSize& offset, LayoutUn it pageLogicalHeight, bool pageLogicalHeightChanged, ColumnInfo* columnInfo) | |
37 : m_columnInfo(columnInfo) | 55 : m_columnInfo(columnInfo) |
38 , m_next(prev) | 56 , m_next(renderer.view()->layoutState()) |
39 #ifndef NDEBUG | 57 , m_renderer(renderer) |
40 , m_renderer(&renderer) | |
41 #endif | |
42 { | 58 { |
Julien - ping for review
2014/06/17 23:34:25
Should we add ASSERT(m_renderer.view()->layoutStat
leviw_travelin_and_unemployed
2014/06/17 23:37:04
Sure.
| |
43 ASSERT(m_next); | 59 renderer.view()->pushLayoutState(*this); |
44 | 60 m_cachedOffsetsEnabled = m_next->m_cachedOffsetsEnabled && renderer.supports LayoutStateCachedOffsets(); |
45 bool fixed = renderer.isOutOfFlowPositioned() && renderer.style()->position( ) == FixedPosition; | 61 bool fixed = renderer.isOutOfFlowPositioned() && renderer.style()->position( ) == FixedPosition; |
46 if (fixed) { | 62 if (fixed) { |
47 // FIXME: This doesn't work correctly with transforms. | 63 // FIXME: This doesn't work correctly with transforms. |
48 FloatPoint fixedOffset = renderer.view()->localToAbsolute(FloatPoint(), IsFixed); | 64 FloatPoint fixedOffset = renderer.view()->localToAbsolute(FloatPoint(), IsFixed); |
49 m_paintOffset = LayoutSize(fixedOffset.x(), fixedOffset.y()) + offset; | 65 m_paintOffset = LayoutSize(fixedOffset.x(), fixedOffset.y()) + offset; |
50 } else | 66 } else { |
51 m_paintOffset = prev->m_paintOffset + offset; | 67 m_paintOffset = m_next->m_paintOffset + offset; |
68 } | |
52 | 69 |
53 if (renderer.isOutOfFlowPositioned() && !fixed) { | 70 if (renderer.isOutOfFlowPositioned() && !fixed) { |
54 if (RenderObject* container = renderer.container()) { | 71 if (RenderObject* container = renderer.container()) { |
55 if (container->isInFlowPositioned() && container->isRenderInline()) | 72 if (container->isInFlowPositioned() && container->isRenderInline()) |
56 m_paintOffset += toRenderInline(container)->offsetForInFlowPosit ionedInline(renderer); | 73 m_paintOffset += toRenderInline(container)->offsetForInFlowPosit ionedInline(renderer); |
57 } | 74 } |
58 } | 75 } |
59 | 76 |
60 m_layoutOffset = m_paintOffset; | 77 m_layoutOffset = m_paintOffset; |
61 | 78 |
62 if (renderer.isInFlowPositioned() && renderer.hasLayer()) | 79 if (renderer.isInFlowPositioned() && renderer.hasLayer()) |
63 m_paintOffset += renderer.layer()->offsetForInFlowPosition(); | 80 m_paintOffset += renderer.layer()->offsetForInFlowPosition(); |
64 | 81 |
65 m_clipped = !fixed && prev->m_clipped; | 82 m_clipped = !fixed && m_next->m_clipped; |
66 if (m_clipped) | 83 if (m_clipped) |
67 m_clipRect = prev->m_clipRect; | 84 m_clipRect = m_next->m_clipRect; |
68 | 85 |
69 if (renderer.hasOverflowClip()) { | 86 if (renderer.hasOverflowClip()) { |
70 LayoutSize deltaSize = RuntimeEnabledFeatures::repaintAfterLayoutEnabled () ? LayoutSize() : renderer.view()->layoutDelta(); | 87 LayoutSize deltaSize = RuntimeEnabledFeatures::repaintAfterLayoutEnabled () ? LayoutSize() : renderer.view()->layoutDelta(); |
71 | 88 |
72 LayoutRect clipRect(toPoint(m_paintOffset) + deltaSize, renderer.cachedS izeForOverflowClip()); | 89 LayoutRect clipRect(toPoint(m_paintOffset) + deltaSize, renderer.cachedS izeForOverflowClip()); |
73 if (m_clipped) | 90 if (m_clipped) |
74 m_clipRect.intersect(clipRect); | 91 m_clipRect.intersect(clipRect); |
75 else { | 92 else { |
76 m_clipRect = clipRect; | 93 m_clipRect = clipRect; |
77 m_clipped = true; | 94 m_clipped = true; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
112 m_layoutDelta = m_next->m_layoutDelta; | 129 m_layoutDelta = m_next->m_layoutDelta; |
113 #if ASSERT_ENABLED | 130 #if ASSERT_ENABLED |
114 m_layoutDeltaXSaturated = m_next->m_layoutDeltaXSaturated; | 131 m_layoutDeltaXSaturated = m_next->m_layoutDeltaXSaturated; |
115 m_layoutDeltaYSaturated = m_next->m_layoutDeltaYSaturated; | 132 m_layoutDeltaYSaturated = m_next->m_layoutDeltaYSaturated; |
116 #endif | 133 #endif |
117 } | 134 } |
118 | 135 |
119 // FIXME: <http://bugs.webkit.org/show_bug.cgi?id=13443> Apply control clip if present. | 136 // FIXME: <http://bugs.webkit.org/show_bug.cgi?id=13443> Apply control clip if present. |
120 } | 137 } |
121 | 138 |
139 inline static bool shouldDisableLayoutStateForSubtree(RenderObject& renderer) | |
140 { | |
141 RenderObject* object = &renderer; | |
142 while (object) { | |
143 if (object->supportsLayoutStateCachedOffsets()) | |
144 return true; | |
145 object = object->container(); | |
146 } | |
147 return false; | |
148 } | |
149 | |
122 LayoutState::LayoutState(RenderObject& root) | 150 LayoutState::LayoutState(RenderObject& root) |
123 : m_clipped(false) | 151 : m_clipped(false) |
124 , m_isPaginated(false) | 152 , m_isPaginated(false) |
125 , m_pageLogicalHeightChanged(false) | 153 , m_pageLogicalHeightChanged(false) |
154 , m_cachedOffsetsEnabled(shouldDisableLayoutStateForSubtree(root)) | |
Julien - ping for review
2014/06/17 23:34:26
That potentially makes the code O(depth_of_tree^2)
leviw_travelin_and_unemployed
2014/06/17 23:37:04
This is only created in FrameView for a sub-tree r
| |
126 #if ASSERT_ENABLED | 155 #if ASSERT_ENABLED |
127 , m_layoutDeltaXSaturated(false) | 156 , m_layoutDeltaXSaturated(false) |
128 , m_layoutDeltaYSaturated(false) | 157 , m_layoutDeltaYSaturated(false) |
129 #endif | 158 #endif |
130 , m_columnInfo(0) | 159 , m_columnInfo(0) |
131 , m_next(0) | 160 , m_next(root.view()->layoutState()) |
132 , m_pageLogicalHeight(0) | 161 , m_pageLogicalHeight(0) |
133 #ifndef NDEBUG | 162 , m_renderer(root) |
134 , m_renderer(&root) | |
135 #endif | |
136 { | 163 { |
164 // FIXME: Why does RenderTableSection create this wonky LayoutState? | |
Julien - ping for review
2014/06/17 23:34:26
RenderTableSections are definitely not special in
| |
165 ASSERT(!m_next || root.isTableSection()); | |
166 // We'll end up pushing in RenderView itself, so don't bother adding it. | |
167 if (root.isRenderView()) | |
168 return; | |
169 | |
170 root.view()->pushLayoutState(*this); | |
171 | |
137 RenderObject* container = root.container(); | 172 RenderObject* container = root.container(); |
138 FloatPoint absContentPoint = container->localToAbsolute(FloatPoint(), UseTra nsforms); | 173 FloatPoint absContentPoint = container->localToAbsolute(FloatPoint(), UseTra nsforms); |
139 m_paintOffset = LayoutSize(absContentPoint.x(), absContentPoint.y()); | 174 m_paintOffset = LayoutSize(absContentPoint.x(), absContentPoint.y()); |
140 | 175 |
141 if (container->hasOverflowClip()) { | 176 if (container->hasOverflowClip()) { |
142 m_clipped = true; | 177 m_clipped = true; |
143 RenderBox* containerBox = toRenderBox(container); | 178 RenderBox* containerBox = toRenderBox(container); |
144 m_clipRect = LayoutRect(toPoint(m_paintOffset), containerBox->cachedSize ForOverflowClip()); | 179 m_clipRect = LayoutRect(toPoint(m_paintOffset), containerBox->cachedSize ForOverflowClip()); |
145 m_paintOffset -= containerBox->scrolledContentOffset(); | 180 m_paintOffset -= containerBox->scrolledContentOffset(); |
146 } | 181 } |
147 } | 182 } |
148 | 183 |
149 void* LayoutState::operator new(size_t sz) | 184 LayoutState::~LayoutState() |
150 { | 185 { |
151 return partitionAlloc(Partitions::getRenderingPartition(), sz); | 186 if (m_renderer.view()->layoutState()) { |
Julien - ping for review
2014/06/17 23:34:25
Nit:
if (LayoutState* currentLayoutState = m_rend
| |
152 } | 187 ASSERT(m_renderer.view()->layoutState() == this); |
153 | 188 m_renderer.view()->popLayoutState(); |
154 void LayoutState::operator delete(void* ptr) | 189 } |
155 { | |
156 partitionFree(ptr); | |
157 } | 190 } |
158 | 191 |
159 void LayoutState::clearPaginationInformation() | 192 void LayoutState::clearPaginationInformation() |
160 { | 193 { |
161 m_pageLogicalHeight = m_next->m_pageLogicalHeight; | 194 m_pageLogicalHeight = m_next->m_pageLogicalHeight; |
162 m_pageOffset = m_next->m_pageOffset; | 195 m_pageOffset = m_next->m_pageOffset; |
163 m_columnInfo = m_next->m_columnInfo; | 196 m_columnInfo = m_next->m_columnInfo; |
164 } | 197 } |
165 | 198 |
166 LayoutUnit LayoutState::pageLogicalOffset(const RenderBox& child, const LayoutUn it& childLogicalOffset) const | 199 LayoutUnit LayoutState::pageLogicalOffset(const RenderBox& child, const LayoutUn it& childLogicalOffset) const |
167 { | 200 { |
168 if (child.isHorizontalWritingMode()) | 201 if (child.isHorizontalWritingMode()) |
169 return m_layoutOffset.height() + childLogicalOffset - m_pageOffset.heigh t(); | 202 return m_layoutOffset.height() + childLogicalOffset - m_pageOffset.heigh t(); |
170 return m_layoutOffset.width() + childLogicalOffset - m_pageOffset.width(); | 203 return m_layoutOffset.width() + childLogicalOffset - m_pageOffset.width(); |
171 } | 204 } |
172 | 205 |
173 void LayoutState::addForcedColumnBreak(const RenderBox& child, const LayoutUnit& childLogicalOffset) | 206 void LayoutState::addForcedColumnBreak(const RenderBox& child, const LayoutUnit& childLogicalOffset) |
174 { | 207 { |
175 if (!m_columnInfo || m_columnInfo->columnHeight()) | 208 if (!m_columnInfo || m_columnInfo->columnHeight()) |
176 return; | 209 return; |
177 m_columnInfo->addForcedBreak(pageLogicalOffset(child, childLogicalOffset)); | 210 m_columnInfo->addForcedBreak(pageLogicalOffset(child, childLogicalOffset)); |
178 } | 211 } |
179 | 212 |
180 } // namespace WebCore | 213 } // namespace WebCore |
OLD | NEW |