Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(50)

Side by Side Diff: Source/core/rendering/LayoutState.cpp

Issue 335963002: Change LayoutState to be stack-allocated (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fix assert Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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.setLayoutState(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 {
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
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* o = &renderer;
142 while (o) {
143 if (o->supportsLayoutStateCachedOffsets())
144 return true;
145 o = o->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))
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?
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);
esprehn 2014/06/13 23:25:25 Why does this sometimes push and sometimes set in
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 ASSERT(!m_renderer.view()->layoutState() || m_renderer.view()->layoutState() == this);
152 } 187 m_renderer.view()->popLayoutState();
153
154 void LayoutState::operator delete(void* ptr)
155 {
156 partitionFree(ptr);
157 } 188 }
158 189
159 void LayoutState::clearPaginationInformation() 190 void LayoutState::clearPaginationInformation()
160 { 191 {
161 m_pageLogicalHeight = m_next->m_pageLogicalHeight; 192 m_pageLogicalHeight = m_next->m_pageLogicalHeight;
162 m_pageOffset = m_next->m_pageOffset; 193 m_pageOffset = m_next->m_pageOffset;
163 m_columnInfo = m_next->m_columnInfo; 194 m_columnInfo = m_next->m_columnInfo;
164 } 195 }
165 196
166 LayoutUnit LayoutState::pageLogicalOffset(const RenderBox& child, const LayoutUn it& childLogicalOffset) const 197 LayoutUnit LayoutState::pageLogicalOffset(const RenderBox& child, const LayoutUn it& childLogicalOffset) const
167 { 198 {
168 if (child.isHorizontalWritingMode()) 199 if (child.isHorizontalWritingMode())
169 return m_layoutOffset.height() + childLogicalOffset - m_pageOffset.heigh t(); 200 return m_layoutOffset.height() + childLogicalOffset - m_pageOffset.heigh t();
170 return m_layoutOffset.width() + childLogicalOffset - m_pageOffset.width(); 201 return m_layoutOffset.width() + childLogicalOffset - m_pageOffset.width();
171 } 202 }
172 203
173 void LayoutState::addForcedColumnBreak(const RenderBox& child, const LayoutUnit& childLogicalOffset) 204 void LayoutState::addForcedColumnBreak(const RenderBox& child, const LayoutUnit& childLogicalOffset)
174 { 205 {
175 if (!m_columnInfo || m_columnInfo->columnHeight()) 206 if (!m_columnInfo || m_columnInfo->columnHeight())
176 return; 207 return;
177 m_columnInfo->addForcedBreak(pageLogicalOffset(child, childLogicalOffset)); 208 m_columnInfo->addForcedBreak(pageLogicalOffset(child, childLogicalOffset));
178 } 209 }
179 210
180 } // namespace WebCore 211 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698