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

Unified 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 push function to match old behavior... 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 side-by-side diff with in-line comments
Download patch
Index: Source/core/rendering/LayoutState.cpp
diff --git a/Source/core/rendering/LayoutState.cpp b/Source/core/rendering/LayoutState.cpp
index 49e59d09c4dfcc1d6320a6f98237dade3fc716b0..45c0d76f1accc00b7710159e49404018a85a24ce 100644
--- a/Source/core/rendering/LayoutState.cpp
+++ b/Source/core/rendering/LayoutState.cpp
@@ -33,22 +33,39 @@
namespace WebCore {
-LayoutState::LayoutState(LayoutState* prev, RenderBox& renderer, const LayoutSize& offset, LayoutUnit pageLogicalHeight, bool pageLogicalHeightChanged, ColumnInfo* columnInfo)
- : m_columnInfo(columnInfo)
- , m_next(prev)
-#ifndef NDEBUG
- , m_renderer(&renderer)
+LayoutState::LayoutState(LayoutUnit pageLogicalHeight, bool pageLogicalHeightChanged, RenderView& view)
+ : m_clipped(false)
+ , m_isPaginated(pageLogicalHeight)
+ , m_pageLogicalHeightChanged(pageLogicalHeightChanged)
+ , m_cachedOffsetsEnabled(true)
+#if ASSERT_ENABLED
+ , m_layoutDeltaXSaturated(false)
+ , m_layoutDeltaYSaturated(false)
#endif
+ , m_columnInfo(0)
+ , m_next(0)
+ , m_pageLogicalHeight(pageLogicalHeight)
+ , m_renderer(view)
{
- ASSERT(m_next);
+ ASSERT(!view.layoutState());
+ view.pushLayoutState(*this);
+}
+LayoutState::LayoutState(RenderBox& renderer, const LayoutSize& offset, LayoutUnit pageLogicalHeight, bool pageLogicalHeightChanged, ColumnInfo* columnInfo)
+ : m_columnInfo(columnInfo)
+ , m_next(renderer.view()->layoutState())
+ , m_renderer(renderer)
+{
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.
+ renderer.view()->pushLayoutState(*this);
+ m_cachedOffsetsEnabled = m_next->m_cachedOffsetsEnabled && renderer.supportsLayoutStateCachedOffsets();
bool fixed = renderer.isOutOfFlowPositioned() && renderer.style()->position() == FixedPosition;
if (fixed) {
// FIXME: This doesn't work correctly with transforms.
FloatPoint fixedOffset = renderer.view()->localToAbsolute(FloatPoint(), IsFixed);
m_paintOffset = LayoutSize(fixedOffset.x(), fixedOffset.y()) + offset;
- } else
- m_paintOffset = prev->m_paintOffset + offset;
+ } else {
+ m_paintOffset = m_next->m_paintOffset + offset;
+ }
if (renderer.isOutOfFlowPositioned() && !fixed) {
if (RenderObject* container = renderer.container()) {
@@ -62,9 +79,9 @@ LayoutState::LayoutState(LayoutState* prev, RenderBox& renderer, const LayoutSiz
if (renderer.isInFlowPositioned() && renderer.hasLayer())
m_paintOffset += renderer.layer()->offsetForInFlowPosition();
- m_clipped = !fixed && prev->m_clipped;
+ m_clipped = !fixed && m_next->m_clipped;
if (m_clipped)
- m_clipRect = prev->m_clipRect;
+ m_clipRect = m_next->m_clipRect;
if (renderer.hasOverflowClip()) {
LayoutSize deltaSize = RuntimeEnabledFeatures::repaintAfterLayoutEnabled() ? LayoutSize() : renderer.view()->layoutDelta();
@@ -119,21 +136,39 @@ LayoutState::LayoutState(LayoutState* prev, RenderBox& renderer, const LayoutSiz
// FIXME: <http://bugs.webkit.org/show_bug.cgi?id=13443> Apply control clip if present.
}
+inline static bool shouldDisableLayoutStateForSubtree(RenderObject& renderer)
+{
+ RenderObject* object = &renderer;
+ while (object) {
+ if (object->supportsLayoutStateCachedOffsets())
+ return true;
+ object = object->container();
+ }
+ return false;
+}
+
LayoutState::LayoutState(RenderObject& root)
: m_clipped(false)
, m_isPaginated(false)
, m_pageLogicalHeightChanged(false)
+ , 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
#if ASSERT_ENABLED
, m_layoutDeltaXSaturated(false)
, m_layoutDeltaYSaturated(false)
#endif
, m_columnInfo(0)
- , m_next(0)
+ , m_next(root.view()->layoutState())
, m_pageLogicalHeight(0)
-#ifndef NDEBUG
- , m_renderer(&root)
-#endif
+ , m_renderer(root)
{
+ // FIXME: Why does RenderTableSection create this wonky LayoutState?
Julien - ping for review 2014/06/17 23:34:26 RenderTableSections are definitely not special in
+ ASSERT(!m_next || root.isTableSection());
+ // We'll end up pushing in RenderView itself, so don't bother adding it.
+ if (root.isRenderView())
+ return;
+
+ root.view()->pushLayoutState(*this);
+
RenderObject* container = root.container();
FloatPoint absContentPoint = container->localToAbsolute(FloatPoint(), UseTransforms);
m_paintOffset = LayoutSize(absContentPoint.x(), absContentPoint.y());
@@ -146,14 +181,12 @@ LayoutState::LayoutState(RenderObject& root)
}
}
-void* LayoutState::operator new(size_t sz)
-{
- return partitionAlloc(Partitions::getRenderingPartition(), sz);
-}
-
-void LayoutState::operator delete(void* ptr)
+LayoutState::~LayoutState()
{
- partitionFree(ptr);
+ if (m_renderer.view()->layoutState()) {
Julien - ping for review 2014/06/17 23:34:25 Nit: if (LayoutState* currentLayoutState = m_rend
+ ASSERT(m_renderer.view()->layoutState() == this);
+ m_renderer.view()->popLayoutState();
+ }
}
void LayoutState::clearPaginationInformation()

Powered by Google App Engine
This is Rietveld 408576698