| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "config.h" | 5 #include "config.h" |
| 6 #include "core/paint/LayerFixedPositionRecorder.h" | 6 #include "core/paint/LayerFixedPositionRecorder.h" |
| 7 | 7 |
| 8 #include "core/layout/LayoutBoxModelObject.h" | 8 #include "core/layout/LayoutBoxModelObject.h" |
| 9 #include "platform/RuntimeEnabledFeatures.h" | 9 #include "platform/RuntimeEnabledFeatures.h" |
| 10 #include "platform/graphics/GraphicsContext.h" | 10 #include "platform/graphics/GraphicsContext.h" |
| 11 #include "platform/graphics/paint/DisplayItemList.h" | 11 #include "platform/graphics/paint/DisplayItemList.h" |
| 12 #include "platform/graphics/paint/FixedPositionContainerDisplayItem.h" | |
| 13 #include "platform/graphics/paint/FixedPositionDisplayItem.h" | 12 #include "platform/graphics/paint/FixedPositionDisplayItem.h" |
| 14 | 13 |
| 15 namespace blink { | 14 namespace blink { |
| 16 | 15 |
| 17 LayerFixedPositionRecorder::LayerFixedPositionRecorder(GraphicsContext& graphics
Context, const LayoutBoxModelObject& layoutObject) | 16 LayerFixedPositionRecorder::LayerFixedPositionRecorder(GraphicsContext& graphics
Context, const LayoutBoxModelObject& layoutObject, const LayoutBoxModelObject& a
nchor) |
| 18 : m_graphicsContext(graphicsContext) | 17 : m_graphicsContext(graphicsContext) |
| 19 , m_layoutObject(layoutObject) | 18 , m_layoutObject(layoutObject) |
| 20 , m_isFixedPosition(layoutObject.style()->position() == FixedPosition) | |
| 21 , m_isFixedPositionContainer(layoutObject.canContainFixedPositionObjects()) | |
| 22 { | 19 { |
| 20 ASSERT(layoutObject.style()->position() == FixedPosition); |
| 21 |
| 23 if (!RuntimeEnabledFeatures::slimmingPaintV2Enabled()) | 22 if (!RuntimeEnabledFeatures::slimmingPaintV2Enabled()) |
| 24 return; | 23 return; |
| 25 | 24 |
| 26 if (m_graphicsContext.displayItemList()->displayItemConstructionIsDisabled()
) | 25 if (m_graphicsContext.displayItemList()->displayItemConstructionIsDisabled()
) |
| 27 return; | 26 return; |
| 28 | 27 |
| 29 if (m_isFixedPosition) | 28 m_graphicsContext.displayItemList()->createAndAppend<BeginFixedPositionDispl
ayItem>(m_layoutObject, anchor); |
| 30 m_graphicsContext.displayItemList()->createAndAppend<BeginFixedPositionD
isplayItem>(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()->createAndAppend<BeginFixedPositionC
ontainerDisplayItem>(m_layoutObject); | |
| 37 } | 29 } |
| 38 | 30 |
| 39 LayerFixedPositionRecorder::~LayerFixedPositionRecorder() | 31 LayerFixedPositionRecorder::~LayerFixedPositionRecorder() |
| 40 { | 32 { |
| 41 if (!RuntimeEnabledFeatures::slimmingPaintV2Enabled()) | 33 if (!RuntimeEnabledFeatures::slimmingPaintV2Enabled()) |
| 42 return; | 34 return; |
| 43 | 35 |
| 44 if (m_graphicsContext.displayItemList()->displayItemConstructionIsDisabled()
) | 36 if (m_graphicsContext.displayItemList()->displayItemConstructionIsDisabled()
) |
| 45 return; | 37 return; |
| 46 | 38 |
| 47 if (m_isFixedPositionContainer) { | 39 if (m_graphicsContext.displayItemList()->lastDisplayItemIsNoopBegin()) |
| 48 if (m_graphicsContext.displayItemList()->lastDisplayItemIsNoopBegin()) | 40 m_graphicsContext.displayItemList()->removeLastDisplayItem(); |
| 49 m_graphicsContext.displayItemList()->removeLastDisplayItem(); | 41 else |
| 50 else | 42 m_graphicsContext.displayItemList()->createAndAppend<EndFixedPositionDis
playItem>(m_layoutObject); |
| 51 m_graphicsContext.displayItemList()->createAndAppend<EndFixedPositio
nDisplayItem>(m_layoutObject); | |
| 52 } | |
| 53 | |
| 54 if (m_isFixedPosition) { | |
| 55 if (m_graphicsContext.displayItemList()->lastDisplayItemIsNoopBegin()) | |
| 56 m_graphicsContext.displayItemList()->removeLastDisplayItem(); | |
| 57 else | |
| 58 m_graphicsContext.displayItemList()->createAndAppend<EndFixedPositio
nDisplayItem>(m_layoutObject); | |
| 59 } | |
| 60 } | 43 } |
| 61 | 44 |
| 62 } // namespace blink | 45 } // namespace blink |
| OLD | NEW |