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.
All rights reserved. | 5 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc.
All rights reserved. |
6 * Copyright (C) Research In Motion Limited 2010. All rights reserved. | 6 * Copyright (C) Research In Motion Limited 2010. All rights reserved. |
7 * | 7 * |
8 * This library is free software; you can redistribute it and/or | 8 * This library is free software; you can redistribute it and/or |
9 * modify it under the terms of the GNU Library General Public | 9 * modify it under the terms of the GNU Library General Public |
10 * License as published by the Free Software Foundation; either | 10 * License as published by the Free Software Foundation; either |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 #endif | 57 #endif |
58 { | 58 { |
59 EFloat type = layoutObject->style()->floating(); | 59 EFloat type = layoutObject->style()->floating(); |
60 ASSERT(type != NoFloat); | 60 ASSERT(type != NoFloat); |
61 if (type == LeftFloat) | 61 if (type == LeftFloat) |
62 m_type = FloatLeft; | 62 m_type = FloatLeft; |
63 else if (type == RightFloat) | 63 else if (type == RightFloat) |
64 m_type = FloatRight; | 64 m_type = FloatRight; |
65 } | 65 } |
66 | 66 |
67 FloatingObject::FloatingObject(LayoutBox* layoutObject, Type type, const LayoutR
ect& frameRect, bool shouldPaint, bool isDescendant, bool isLowestNonOverhanging
FloatInChild, bool performingUnsafeClone) | 67 FloatingObject::FloatingObject(LayoutBox* layoutObject, Type type, const LayoutR
ect& frameRect, bool shouldPaint, bool isDescendant, bool isLowestNonOverhanging
FloatInChild) |
68 : m_layoutObject(layoutObject) | 68 : m_layoutObject(layoutObject) |
69 , m_originatingLine(nullptr) | 69 , m_originatingLine(nullptr) |
70 , m_frameRect(frameRect) | 70 , m_frameRect(frameRect) |
71 , m_type(type) | 71 , m_type(type) |
72 , m_isDescendant(isDescendant) | 72 , m_isDescendant(isDescendant) |
73 , m_isPlaced(true) | 73 , m_isPlaced(true) |
74 , m_isLowestNonOverhangingFloatInChild(isLowestNonOverhangingFloatInChild) | 74 , m_isLowestNonOverhangingFloatInChild(isLowestNonOverhangingFloatInChild) |
75 #if ENABLE(ASSERT) | 75 #if ENABLE(ASSERT) |
76 , m_isInPlacedTree(false) | 76 , m_isInPlacedTree(false) |
77 #endif | 77 #endif |
78 { | 78 { |
79 m_shouldPaint = shouldPaint; | 79 m_shouldPaint = shouldPaint || shouldPaintForCompositedLayoutPart(); |
80 // TODO(chrishtr): Avoid the following hack when performing an unsafe clone. | |
81 // This avoids a use-after-free bug due to the fact that we sometimes fail t
o remove | |
82 // floats from their container when detaching (crbug.com/619380). This is ac
tually a bug in the | |
83 // floats detach machinery, which needs to be fixed, in which case this work
around can be removed. | |
84 // In any case, it should be safe because moving floats from one owner to an
other should cause layout, | |
85 // which will in turn update the m_shouldPaint property. | |
86 if (!performingUnsafeClone) | |
87 m_shouldPaint = m_shouldPaint || shouldPaintForCompositedLayoutPart(); | |
88 } | 80 } |
89 | 81 |
90 bool FloatingObject::shouldPaintForCompositedLayoutPart() | 82 bool FloatingObject::shouldPaintForCompositedLayoutPart() |
91 { | 83 { |
92 // HACK: only non-self-painting floats should paint. However, due to the fun
damental compositing bug, some LayoutPart objects | 84 // HACK: only non-self-painting floats should paint. However, due to the fun
damental compositing bug, some LayoutPart objects |
93 // may become self-painting due to being composited. This leads to a chicken
-egg issue because layout may not depend on compositing. | 85 // may become self-painting due to being composited. This leads to a chicken
-egg issue because layout may not depend on compositing. |
94 // If this is the case, set shouldPaint() to true even if the layer is techn
ically self-painting. This lets the float which contains | 86 // If this is the case, set shouldPaint() to true even if the layer is techn
ically self-painting. This lets the float which contains |
95 // a LayoutPart start painting as soon as it stops being composited, without
having to re-layout the float. | 87 // a LayoutPart start painting as soon as it stops being composited, without
having to re-layout the float. |
96 // This hack can be removed after SPv2. | 88 // This hack can be removed after SPv2. |
97 return m_layoutObject->layer() && m_layoutObject->layer()->isSelfPaintingOnl
yBecauseIsCompositedPart() && !RuntimeEnabledFeatures::slimmingPaintV2Enabled(); | 89 return m_layoutObject->layer() && m_layoutObject->layer()->isSelfPaintingOnl
yBecauseIsCompositedPart() && !RuntimeEnabledFeatures::slimmingPaintV2Enabled(); |
(...skipping 16 matching lines...) Expand all Loading... |
114 return m_shouldPaint && !m_layoutObject->hasSelfPaintingLayer(); | 106 return m_shouldPaint && !m_layoutObject->hasSelfPaintingLayer(); |
115 } | 107 } |
116 | 108 |
117 std::unique_ptr<FloatingObject> FloatingObject::copyToNewContainer(LayoutSize of
fset, bool shouldPaint, bool isDescendant) const | 109 std::unique_ptr<FloatingObject> FloatingObject::copyToNewContainer(LayoutSize of
fset, bool shouldPaint, bool isDescendant) const |
118 { | 110 { |
119 return wrapUnique(new FloatingObject(layoutObject(), getType(), LayoutRect(f
rameRect().location() - offset, frameRect().size()), shouldPaint, isDescendant,
isLowestNonOverhangingFloatInChild())); | 111 return wrapUnique(new FloatingObject(layoutObject(), getType(), LayoutRect(f
rameRect().location() - offset, frameRect().size()), shouldPaint, isDescendant,
isLowestNonOverhangingFloatInChild())); |
120 } | 112 } |
121 | 113 |
122 std::unique_ptr<FloatingObject> FloatingObject::unsafeClone() const | 114 std::unique_ptr<FloatingObject> FloatingObject::unsafeClone() const |
123 { | 115 { |
124 std::unique_ptr<FloatingObject> cloneObject = wrapUnique(new FloatingObject(
layoutObject(), getType(), m_frameRect, m_shouldPaint, m_isDescendant, false, tr
ue)); | 116 std::unique_ptr<FloatingObject> cloneObject = wrapUnique(new FloatingObject(
layoutObject(), getType(), m_frameRect, m_shouldPaint, m_isDescendant, false)); |
125 cloneObject->m_isPlaced = m_isPlaced; | 117 cloneObject->m_isPlaced = m_isPlaced; |
126 return cloneObject; | 118 return cloneObject; |
127 } | 119 } |
128 | 120 |
129 template <FloatingObject::Type FloatTypeValue> | 121 template <FloatingObject::Type FloatTypeValue> |
130 class ComputeFloatOffsetAdapter { | 122 class ComputeFloatOffsetAdapter { |
131 public: | 123 public: |
132 typedef FloatingObjectInterval IntervalType; | 124 typedef FloatingObjectInterval IntervalType; |
133 | 125 |
134 ComputeFloatOffsetAdapter(const LayoutBlockFlow* layoutObject, LayoutUnit li
neTop, LayoutUnit lineBottom, LayoutUnit offset) | 126 ComputeFloatOffsetAdapter(const LayoutBlockFlow* layoutObject, LayoutUnit li
neTop, LayoutUnit lineBottom, LayoutUnit offset) |
(...skipping 512 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
647 } | 639 } |
648 | 640 |
649 String ValueToString<FloatingObject*>::toString(const FloatingObject* floatingOb
ject) | 641 String ValueToString<FloatingObject*>::toString(const FloatingObject* floatingOb
ject) |
650 { | 642 { |
651 return String::format("%p (%gx%g %gx%g)", floatingObject, floatingObject->fr
ameRect().x().toFloat(), floatingObject->frameRect().y().toFloat(), floatingObje
ct->frameRect().maxX().toFloat(), floatingObject->frameRect().maxY().toFloat()); | 643 return String::format("%p (%gx%g %gx%g)", floatingObject, floatingObject->fr
ameRect().x().toFloat(), floatingObject->frameRect().y().toFloat(), floatingObje
ct->frameRect().maxX().toFloat(), floatingObject->frameRect().maxY().toFloat()); |
652 } | 644 } |
653 #endif | 645 #endif |
654 | 646 |
655 | 647 |
656 } // namespace blink | 648 } // namespace blink |
OLD | NEW |