| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
| 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
| 4 * (C) 2007 David Smith (catfish.man@gmail.com) | 4 * (C) 2007 David Smith (catfish.man@gmail.com) |
| 5 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. | 5 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. |
| 6 * All rights reserved. | 6 * All rights reserved. |
| 7 * Copyright (C) Research In Motion Limited 2010. All rights reserved. | 7 * Copyright (C) Research In Motion Limited 2010. All rights reserved. |
| 8 * | 8 * |
| 9 * This library is free software; you can redistribute it and/or | 9 * This library is free software; you can redistribute it and/or |
| 10 * modify it under the terms of the GNU Library General Public | 10 * modify it under the terms of the GNU Library General Public |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 * Boston, MA 02110-1301, USA. | 22 * Boston, MA 02110-1301, USA. |
| 23 */ | 23 */ |
| 24 | 24 |
| 25 #include "core/layout/FloatingObjects.h" | 25 #include "core/layout/FloatingObjects.h" |
| 26 | 26 |
| 27 #include "core/layout/LayoutBlockFlow.h" | 27 #include "core/layout/LayoutBlockFlow.h" |
| 28 #include "core/layout/LayoutBox.h" | 28 #include "core/layout/LayoutBox.h" |
| 29 #include "core/layout/LayoutView.h" | 29 #include "core/layout/LayoutView.h" |
| 30 #include "core/layout/api/LineLayoutBlockFlow.h" | 30 #include "core/layout/api/LineLayoutBlockFlow.h" |
| 31 #include "core/layout/shapes/ShapeOutsideInfo.h" | 31 #include "core/layout/shapes/ShapeOutsideInfo.h" |
| 32 #include "core/paint/PaintLayer.h" | |
| 33 #include "platform/RuntimeEnabledFeatures.h" | |
| 34 #include "wtf/PtrUtil.h" | 32 #include "wtf/PtrUtil.h" |
| 35 #include <algorithm> | 33 #include <algorithm> |
| 36 #include <memory> | 34 #include <memory> |
| 37 | 35 |
| 38 using namespace WTF; | 36 using namespace WTF; |
| 39 | 37 |
| 40 namespace blink { | 38 namespace blink { |
| 41 | 39 |
| 42 struct SameSizeAsFloatingObject { | 40 struct SameSizeAsFloatingObject { |
| 43 void* pointers[2]; | 41 void* pointers[2]; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 71 FloatingObject::FloatingObject(LayoutBox* layoutObject, | 69 FloatingObject::FloatingObject(LayoutBox* layoutObject, |
| 72 Type type, | 70 Type type, |
| 73 const LayoutRect& frameRect, | 71 const LayoutRect& frameRect, |
| 74 bool shouldPaint, | 72 bool shouldPaint, |
| 75 bool isDescendant, | 73 bool isDescendant, |
| 76 bool isLowestNonOverhangingFloatInChild) | 74 bool isLowestNonOverhangingFloatInChild) |
| 77 : m_layoutObject(layoutObject), | 75 : m_layoutObject(layoutObject), |
| 78 m_originatingLine(nullptr), | 76 m_originatingLine(nullptr), |
| 79 m_frameRect(frameRect), | 77 m_frameRect(frameRect), |
| 80 m_type(type), | 78 m_type(type), |
| 79 m_shouldPaint(shouldPaint), |
| 81 m_isDescendant(isDescendant), | 80 m_isDescendant(isDescendant), |
| 82 m_isPlaced(true), | 81 m_isPlaced(true), |
| 83 m_isLowestNonOverhangingFloatInChild(isLowestNonOverhangingFloatInChild) | 82 m_isLowestNonOverhangingFloatInChild(isLowestNonOverhangingFloatInChild) |
| 84 #if DCHECK_IS_ON() | 83 #if DCHECK_IS_ON() |
| 85 , | 84 , |
| 86 m_isInPlacedTree(false) | 85 m_isInPlacedTree(false) |
| 87 #endif | 86 #endif |
| 88 { | 87 { |
| 89 m_shouldPaint = shouldPaint || shouldPaintForCompositedLayoutPart(); | |
| 90 } | |
| 91 | |
| 92 bool FloatingObject::shouldPaintForCompositedLayoutPart() { | |
| 93 // HACK: only non-self-painting floats should paint. However, due to the | |
| 94 // fundamental compositing bug, some LayoutPart objects may become | |
| 95 // self-painting due to being composited. This leads to a chicken-egg issue | |
| 96 // because layout may not depend on compositing. | |
| 97 // If this is the case, set shouldPaint() to true even if the layer is | |
| 98 // technically self-painting. This lets the float which contains a LayoutPart | |
| 99 // start painting as soon as it stops being composited, without having to | |
| 100 // re-layout the float. | |
| 101 // This hack can be removed after SPv2. | |
| 102 return m_layoutObject->layer() && | |
| 103 m_layoutObject->layer()->isSelfPaintingOnlyBecauseIsCompositedPart() && | |
| 104 !RuntimeEnabledFeatures::slimmingPaintV2Enabled(); | |
| 105 } | 88 } |
| 106 | 89 |
| 107 std::unique_ptr<FloatingObject> FloatingObject::create( | 90 std::unique_ptr<FloatingObject> FloatingObject::create( |
| 108 LayoutBox* layoutObject) { | 91 LayoutBox* layoutObject) { |
| 109 std::unique_ptr<FloatingObject> newObj = | 92 std::unique_ptr<FloatingObject> newObj = |
| 110 WTF::wrapUnique(new FloatingObject(layoutObject)); | 93 WTF::wrapUnique(new FloatingObject(layoutObject)); |
| 111 | 94 |
| 112 // If a layer exists, the float will paint itself. Otherwise someone else | 95 // If a layer exists, the float will paint itself. Otherwise someone else |
| 113 // will. | 96 // will. |
| 114 newObj->setShouldPaint(!layoutObject->hasSelfPaintingLayer() || | 97 newObj->setShouldPaint(!layoutObject->hasSelfPaintingLayer()); |
| 115 newObj->shouldPaintForCompositedLayoutPart()); | |
| 116 | 98 |
| 117 newObj->setIsDescendant(true); | 99 newObj->setIsDescendant(true); |
| 118 | 100 |
| 119 return newObj; | 101 return newObj; |
| 120 } | 102 } |
| 121 | 103 |
| 122 bool FloatingObject::shouldPaint() const { | |
| 123 return m_shouldPaint && !m_layoutObject->hasSelfPaintingLayer(); | |
| 124 } | |
| 125 | |
| 126 std::unique_ptr<FloatingObject> FloatingObject::copyToNewContainer( | 104 std::unique_ptr<FloatingObject> FloatingObject::copyToNewContainer( |
| 127 LayoutSize offset, | 105 LayoutSize offset, |
| 128 bool shouldPaint, | 106 bool shouldPaint, |
| 129 bool isDescendant) const { | 107 bool isDescendant) const { |
| 130 return WTF::wrapUnique(new FloatingObject( | 108 return WTF::wrapUnique(new FloatingObject( |
| 131 layoutObject(), getType(), | 109 layoutObject(), getType(), |
| 132 LayoutRect(frameRect().location() - offset, frameRect().size()), | 110 LayoutRect(frameRect().location() - offset, frameRect().size()), |
| 133 shouldPaint, isDescendant, isLowestNonOverhangingFloatInChild())); | 111 shouldPaint, isDescendant, isLowestNonOverhangingFloatInChild())); |
| 134 } | 112 } |
| 135 | 113 |
| (...skipping 612 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 748 const FloatingObject* floatingObject) { | 726 const FloatingObject* floatingObject) { |
| 749 return String::format("%p (%gx%g %gx%g)", floatingObject, | 727 return String::format("%p (%gx%g %gx%g)", floatingObject, |
| 750 floatingObject->frameRect().x().toFloat(), | 728 floatingObject->frameRect().x().toFloat(), |
| 751 floatingObject->frameRect().y().toFloat(), | 729 floatingObject->frameRect().y().toFloat(), |
| 752 floatingObject->frameRect().maxX().toFloat(), | 730 floatingObject->frameRect().maxX().toFloat(), |
| 753 floatingObject->frameRect().maxY().toFloat()); | 731 floatingObject->frameRect().maxY().toFloat()); |
| 754 } | 732 } |
| 755 #endif | 733 #endif |
| 756 | 734 |
| 757 } // namespace blink | 735 } // namespace blink |
| OLD | NEW |