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.
All rights reserved. |
6 * All rights reserved. | |
7 * Copyright (C) Research In Motion Limited 2010. All rights reserved. | 6 * Copyright (C) Research In Motion Limited 2010. All rights reserved. |
8 * | 7 * |
9 * This library is free software; you can redistribute it and/or | 8 * This library is free software; you can redistribute it and/or |
10 * modify it under the terms of the GNU Library General Public | 9 * modify it under the terms of the GNU Library General Public |
11 * License as published by the Free Software Foundation; either | 10 * License as published by the Free Software Foundation; either |
12 * version 2 of the License, or (at your option) any later version. | 11 * version 2 of the License, or (at your option) any later version. |
13 * | 12 * |
14 * This library is distributed in the hope that it will be useful, | 13 * This library is distributed in the hope that it will be useful, |
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 m_isDescendant(isDescendant), | 81 m_isDescendant(isDescendant), |
83 m_isPlaced(true), | 82 m_isPlaced(true), |
84 m_isLowestNonOverhangingFloatInChild(isLowestNonOverhangingFloatInChild) | 83 m_isLowestNonOverhangingFloatInChild(isLowestNonOverhangingFloatInChild) |
85 #if ENABLE(ASSERT) | 84 #if ENABLE(ASSERT) |
86 , | 85 , |
87 m_isInPlacedTree(false) | 86 m_isInPlacedTree(false) |
88 #endif | 87 #endif |
89 { | 88 { |
90 m_shouldPaint = shouldPaint; | 89 m_shouldPaint = shouldPaint; |
91 // TODO(chrishtr): Avoid the following hack when performing an unsafe clone. | 90 // TODO(chrishtr): Avoid the following hack when performing an unsafe clone. |
92 // This avoids a use-after-free bug due to the fact that we sometimes fail to | 91 // This avoids a use-after-free bug due to the fact that we sometimes fail to
remove |
93 // remove floats from their container when detaching (crbug.com/619380). | 92 // floats from their container when detaching (crbug.com/619380). This is actu
ally a bug in the |
94 // This is actually a bug in the floats detach machinery, which needs to be | 93 // floats detach machinery, which needs to be fixed, in which case this workar
ound can be removed. |
95 // fixed, in which case this workaround can be removed. In any case, it should | 94 // In any case, it should be safe because moving floats from one owner to anot
her should cause layout, |
96 // be safe because moving floats from one owner to another should cause | 95 // which will in turn update the m_shouldPaint property. |
97 // layout, which will in turn update the m_shouldPaint property. | |
98 if (!performingUnsafeClone) | 96 if (!performingUnsafeClone) |
99 m_shouldPaint = m_shouldPaint || shouldPaintForCompositedLayoutPart(); | 97 m_shouldPaint = m_shouldPaint || shouldPaintForCompositedLayoutPart(); |
100 } | 98 } |
101 | 99 |
102 bool FloatingObject::shouldPaintForCompositedLayoutPart() { | 100 bool FloatingObject::shouldPaintForCompositedLayoutPart() { |
103 // HACK: only non-self-painting floats should paint. However, due to the | 101 // HACK: only non-self-painting floats should paint. However, due to the funda
mental compositing bug, some LayoutPart objects |
104 // fundamental compositing bug, some LayoutPart objects may become | 102 // may become self-painting due to being composited. This leads to a chicken-e
gg issue because layout may not depend on compositing. |
105 // self-painting due to being composited. This leads to a chicken-egg issue | 103 // If this is the case, set shouldPaint() to true even if the layer is technic
ally self-painting. This lets the float which contains |
106 // because layout may not depend on compositing. | 104 // a LayoutPart start painting as soon as it stops being composited, without h
aving to re-layout the float. |
107 // If this is the case, set shouldPaint() to true even if the layer is | |
108 // technically self-painting. This lets the float which contains a LayoutPart | |
109 // start painting as soon as it stops being composited, without having to | |
110 // re-layout the float. | |
111 // This hack can be removed after SPv2. | 105 // This hack can be removed after SPv2. |
112 return m_layoutObject->layer() && | 106 return m_layoutObject->layer() && |
113 m_layoutObject->layer()->isSelfPaintingOnlyBecauseIsCompositedPart() && | 107 m_layoutObject->layer()->isSelfPaintingOnlyBecauseIsCompositedPart() && |
114 !RuntimeEnabledFeatures::slimmingPaintV2Enabled(); | 108 !RuntimeEnabledFeatures::slimmingPaintV2Enabled(); |
115 } | 109 } |
116 | 110 |
117 std::unique_ptr<FloatingObject> FloatingObject::create( | 111 std::unique_ptr<FloatingObject> FloatingObject::create( |
118 LayoutBox* layoutObject) { | 112 LayoutBox* layoutObject) { |
119 std::unique_ptr<FloatingObject> newObj = | 113 std::unique_ptr<FloatingObject> newObj = |
120 wrapUnique(new FloatingObject(layoutObject)); | 114 wrapUnique(new FloatingObject(layoutObject)); |
121 | 115 |
122 // If a layer exists, the float will paint itself. Otherwise someone else | 116 // If a layer exists, the float will paint itself. Otherwise someone else will
. |
123 // will. | |
124 newObj->setShouldPaint(!layoutObject->hasSelfPaintingLayer() || | 117 newObj->setShouldPaint(!layoutObject->hasSelfPaintingLayer() || |
125 newObj->shouldPaintForCompositedLayoutPart()); | 118 newObj->shouldPaintForCompositedLayoutPart()); |
126 | 119 |
127 newObj->setIsDescendant(true); | 120 newObj->setIsDescendant(true); |
128 | 121 |
129 return newObj; | 122 return newObj; |
130 } | 123 } |
131 | 124 |
132 bool FloatingObject::shouldPaint() const { | 125 bool FloatingObject::shouldPaint() const { |
133 return m_shouldPaint && !m_layoutObject->hasSelfPaintingLayer(); | 126 return m_shouldPaint && !m_layoutObject->hasSelfPaintingLayer(); |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
288 m_belowLogicalHeight, m_aboveLogicalHeight)); | 281 m_belowLogicalHeight, m_aboveLogicalHeight)); |
289 | 282 |
290 LayoutUnit floatBottom = m_layoutObject.logicalBottomForFloat(floatingObject); | 283 LayoutUnit floatBottom = m_layoutObject.logicalBottomForFloat(floatingObject); |
291 | 284 |
292 if (ShapeOutsideInfo* shapeOutside = | 285 if (ShapeOutsideInfo* shapeOutside = |
293 floatingObject.layoutObject()->shapeOutsideInfo()) { | 286 floatingObject.layoutObject()->shapeOutsideInfo()) { |
294 LayoutUnit shapeBottom = | 287 LayoutUnit shapeBottom = |
295 m_layoutObject.logicalTopForFloat(floatingObject) + | 288 m_layoutObject.logicalTopForFloat(floatingObject) + |
296 m_layoutObject.marginBeforeForChild(*floatingObject.layoutObject()) + | 289 m_layoutObject.marginBeforeForChild(*floatingObject.layoutObject()) + |
297 shapeOutside->shapeLogicalBottom(); | 290 shapeOutside->shapeLogicalBottom(); |
298 // Use the shapeBottom unless it extends outside of the margin box, in which | 291 // Use the shapeBottom unless it extends outside of the margin box, in which
case it is clipped. |
299 // case it is clipped. | |
300 m_nextShapeLogicalBottom = m_nextShapeLogicalBottom | 292 m_nextShapeLogicalBottom = m_nextShapeLogicalBottom |
301 ? std::min(shapeBottom, floatBottom) | 293 ? std::min(shapeBottom, floatBottom) |
302 : shapeBottom; | 294 : shapeBottom; |
303 } else { | 295 } else { |
304 m_nextShapeLogicalBottom = | 296 m_nextShapeLogicalBottom = |
305 m_nextShapeLogicalBottom | 297 m_nextShapeLogicalBottom |
306 ? std::min(m_nextShapeLogicalBottom, floatBottom) | 298 ? std::min(m_nextShapeLogicalBottom, floatBottom) |
307 : floatBottom; | 299 : floatBottom; |
308 } | 300 } |
309 | 301 |
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
682 template <FloatingObject::Type FloatTypeValue> | 674 template <FloatingObject::Type FloatTypeValue> |
683 DISABLE_CFI_PERF inline void | 675 DISABLE_CFI_PERF inline void |
684 ComputeFloatOffsetAdapter<FloatTypeValue>::collectIfNeeded( | 676 ComputeFloatOffsetAdapter<FloatTypeValue>::collectIfNeeded( |
685 const IntervalType& interval) { | 677 const IntervalType& interval) { |
686 const FloatingObject& floatingObject = *(interval.data()); | 678 const FloatingObject& floatingObject = *(interval.data()); |
687 if (floatingObject.getType() != FloatTypeValue || | 679 if (floatingObject.getType() != FloatTypeValue || |
688 !rangesIntersect(interval.low(), interval.high(), m_lineTop, | 680 !rangesIntersect(interval.low(), interval.high(), m_lineTop, |
689 m_lineBottom)) | 681 m_lineBottom)) |
690 return; | 682 return; |
691 | 683 |
692 // Make sure the float hasn't changed since it was added to the placed floats | 684 // Make sure the float hasn't changed since it was added to the placed floats
tree. |
693 // tree. | |
694 ASSERT(floatingObject.isPlaced()); | 685 ASSERT(floatingObject.isPlaced()); |
695 ASSERT(interval.low() == m_layoutObject->logicalTopForFloat(floatingObject)); | 686 ASSERT(interval.low() == m_layoutObject->logicalTopForFloat(floatingObject)); |
696 ASSERT(interval.high() == | 687 ASSERT(interval.high() == |
697 m_layoutObject->logicalBottomForFloat(floatingObject)); | 688 m_layoutObject->logicalBottomForFloat(floatingObject)); |
698 | 689 |
699 bool floatIsNewExtreme = updateOffsetIfNeeded(floatingObject); | 690 bool floatIsNewExtreme = updateOffsetIfNeeded(floatingObject); |
700 if (floatIsNewExtreme) | 691 if (floatIsNewExtreme) |
701 m_outermostFloat = &floatingObject; | 692 m_outermostFloat = &floatingObject; |
702 } | 693 } |
703 | 694 |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
758 const FloatingObject* floatingObject) { | 749 const FloatingObject* floatingObject) { |
759 return String::format("%p (%gx%g %gx%g)", floatingObject, | 750 return String::format("%p (%gx%g %gx%g)", floatingObject, |
760 floatingObject->frameRect().x().toFloat(), | 751 floatingObject->frameRect().x().toFloat(), |
761 floatingObject->frameRect().y().toFloat(), | 752 floatingObject->frameRect().y().toFloat(), |
762 floatingObject->frameRect().maxX().toFloat(), | 753 floatingObject->frameRect().maxX().toFloat(), |
763 floatingObject->frameRect().maxY().toFloat()); | 754 floatingObject->frameRect().maxY().toFloat()); |
764 } | 755 } |
765 #endif | 756 #endif |
766 | 757 |
767 } // namespace blink | 758 } // namespace blink |
OLD | NEW |