| OLD | NEW |
| (Empty) |
| 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. | |
| 4 | |
| 5 #include "config.h" | |
| 6 #include "core/paint/LayerFixedPositionRecorder.h" | |
| 7 | |
| 8 #include "core/layout/LayoutBoxModelObject.h" | |
| 9 #include "platform/RuntimeEnabledFeatures.h" | |
| 10 #include "platform/graphics/GraphicsContext.h" | |
| 11 #include "platform/graphics/paint/DisplayItemList.h" | |
| 12 #include "platform/graphics/paint/FixedPositionContainerDisplayItem.h" | |
| 13 #include "platform/graphics/paint/FixedPositionDisplayItem.h" | |
| 14 | |
| 15 namespace blink { | |
| 16 | |
| 17 LayerFixedPositionRecorder::LayerFixedPositionRecorder(GraphicsContext& graphics
Context, const LayoutBoxModelObject& layoutObject) | |
| 18 : m_graphicsContext(graphicsContext) | |
| 19 , m_layoutObject(layoutObject) | |
| 20 , m_isFixedPosition(layoutObject.style()->position() == FixedPosition) | |
| 21 , m_isFixedPositionContainer(layoutObject.canContainFixedPositionObjects()) | |
| 22 { | |
| 23 if (!RuntimeEnabledFeatures::slimmingPaintCompositorLayerizationEnabled()) | |
| 24 return; | |
| 25 | |
| 26 if (m_graphicsContext.displayItemList()->displayItemConstructionIsDisabled()
) | |
| 27 return; | |
| 28 | |
| 29 if (m_isFixedPosition) | |
| 30 m_graphicsContext.displayItemList()->add(BeginFixedPositionDisplayItem::
create(m_layoutObject)); | |
| 31 | |
| 32 // TODO(trchen): Adding a pair of display items on every transformed | |
| 33 // element can be expensive. Investigate whether we can optimize out some | |
| 34 // of them if applicable. | |
| 35 if (m_isFixedPositionContainer) | |
| 36 m_graphicsContext.displayItemList()->add(BeginFixedPositionContainerDisp
layItem::create(m_layoutObject)); | |
| 37 } | |
| 38 | |
| 39 LayerFixedPositionRecorder::~LayerFixedPositionRecorder() | |
| 40 { | |
| 41 if (!RuntimeEnabledFeatures::slimmingPaintCompositorLayerizationEnabled()) | |
| 42 return; | |
| 43 | |
| 44 if (m_graphicsContext.displayItemList()->displayItemConstructionIsDisabled()
) | |
| 45 return; | |
| 46 | |
| 47 if (m_isFixedPositionContainer) | |
| 48 m_graphicsContext.displayItemList()->add(EndFixedPositionContainerDispla
yItem::create(m_layoutObject)); | |
| 49 | |
| 50 if (m_isFixedPosition) | |
| 51 m_graphicsContext.displayItemList()->add(EndFixedPositionDisplayItem::cr
eate(m_layoutObject)); | |
| 52 } | |
| 53 | |
| 54 } // namespace blink | |
| OLD | NEW |