1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
6 #include "core/paint/ScrollRecorder.h"
8 #include "platform/graphics/GraphicsContext.h"
9 #include "platform/graphics/paint/DisplayItemList.h"
10 #include "platform/graphics/paint/ScrollDisplayItem.h"
14 ScrollRecorder::ScrollRecorder(GraphicsContext
& context
, const DisplayItemClientWrapper
& client
, PaintPhase phase
, const IntSize
& currentOffset
)
16 , m_beginItemType(DisplayItem::paintPhaseToScrollType(phase
))
19 ASSERT(m_context
.displayItemList());
20 if (m_context
.displayItemList()->displayItemConstructionIsDisabled())
22 m_context
.displayItemList()->createAndAppend
<BeginScrollDisplayItem
>(m_client
, m_beginItemType
, currentOffset
);
25 ScrollRecorder::~ScrollRecorder()
27 ASSERT(m_context
.displayItemList());
28 if (!m_context
.displayItemList()->displayItemConstructionIsDisabled()) {
29 if (m_context
.displayItemList()->lastDisplayItemIsNoopBegin())
30 m_context
.displayItemList()->removeLastDisplayItem();
32 m_context
.displayItemList()->createAndAppend
<EndScrollDisplayItem
>(m_client
, DisplayItem::scrollTypeToEndScrollType(m_beginItemType
));