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 10 matching lines...) Expand all Loading... |
21 * Boston, MA 02110-1301, USA. | 21 * Boston, MA 02110-1301, USA. |
22 */ | 22 */ |
23 | 23 |
24 #ifndef FloatingObjects_h | 24 #ifndef FloatingObjects_h |
25 #define FloatingObjects_h | 25 #define FloatingObjects_h |
26 | 26 |
27 #include "platform/PODFreeListArena.h" | 27 #include "platform/PODFreeListArena.h" |
28 #include "platform/PODIntervalTree.h" | 28 #include "platform/PODIntervalTree.h" |
29 #include "platform/geometry/LayoutRect.h" | 29 #include "platform/geometry/LayoutRect.h" |
30 #include "wtf/ListHashSet.h" | 30 #include "wtf/ListHashSet.h" |
31 #include <memory> | 31 #include "wtf/OwnPtr.h" |
32 | 32 |
33 namespace blink { | 33 namespace blink { |
34 | 34 |
35 class LayoutBlockFlow; | 35 class LayoutBlockFlow; |
36 class LayoutBox; | 36 class LayoutBox; |
37 class RootInlineBox; | 37 class RootInlineBox; |
38 | 38 |
39 class FloatingObject { | 39 class FloatingObject { |
40 WTF_MAKE_NONCOPYABLE(FloatingObject); USING_FAST_MALLOC(FloatingObject); | 40 WTF_MAKE_NONCOPYABLE(FloatingObject); USING_FAST_MALLOC(FloatingObject); |
41 public: | 41 public: |
42 #ifndef NDEBUG | 42 #ifndef NDEBUG |
43 // Used by the PODIntervalTree for debugging the FloatingObject. | 43 // Used by the PODIntervalTree for debugging the FloatingObject. |
44 template <class> friend struct ValueToString; | 44 template <class> friend struct ValueToString; |
45 #endif | 45 #endif |
46 | 46 |
47 // Note that Type uses bits so you can use FloatLeftRight as a mask to query
for both left and right. | 47 // Note that Type uses bits so you can use FloatLeftRight as a mask to query
for both left and right. |
48 enum Type { FloatLeft = 1, FloatRight = 2, FloatLeftRight = 3 }; | 48 enum Type { FloatLeft = 1, FloatRight = 2, FloatLeftRight = 3 }; |
49 | 49 |
50 static std::unique_ptr<FloatingObject> create(LayoutBox*); | 50 static PassOwnPtr<FloatingObject> create(LayoutBox*); |
51 | 51 |
52 std::unique_ptr<FloatingObject> copyToNewContainer(LayoutSize, bool shouldPa
int = false, bool isDescendant = false) const; | 52 PassOwnPtr<FloatingObject> copyToNewContainer(LayoutSize, bool shouldPaint =
false, bool isDescendant = false) const; |
53 | 53 |
54 std::unique_ptr<FloatingObject> unsafeClone() const; | 54 PassOwnPtr<FloatingObject> unsafeClone() const; |
55 | 55 |
56 Type getType() const { return static_cast<Type>(m_type); } | 56 Type getType() const { return static_cast<Type>(m_type); } |
57 LayoutBox* layoutObject() const { return m_layoutObject; } | 57 LayoutBox* layoutObject() const { return m_layoutObject; } |
58 | 58 |
59 bool isPlaced() const { return m_isPlaced; } | 59 bool isPlaced() const { return m_isPlaced; } |
60 void setIsPlaced(bool placed = true) { m_isPlaced = placed; } | 60 void setIsPlaced(bool placed = true) { m_isPlaced = placed; } |
61 | 61 |
62 LayoutUnit x() const { ASSERT(isPlaced()); return m_frameRect.x(); } | 62 LayoutUnit x() const { ASSERT(isPlaced()); return m_frameRect.x(); } |
63 LayoutUnit maxX() const { ASSERT(isPlaced()); return m_frameRect.maxX(); } | 63 LayoutUnit maxX() const { ASSERT(isPlaced()); return m_frameRect.maxX(); } |
64 LayoutUnit y() const { ASSERT(isPlaced()); return m_frameRect.y(); } | 64 LayoutUnit y() const { ASSERT(isPlaced()); return m_frameRect.y(); } |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 unsigned m_isPlaced : 1; | 105 unsigned m_isPlaced : 1; |
106 unsigned m_isLowestNonOverhangingFloatInChild : 1; | 106 unsigned m_isLowestNonOverhangingFloatInChild : 1; |
107 #if ENABLE(ASSERT) | 107 #if ENABLE(ASSERT) |
108 unsigned m_isInPlacedTree : 1; | 108 unsigned m_isInPlacedTree : 1; |
109 #endif | 109 #endif |
110 }; | 110 }; |
111 | 111 |
112 struct FloatingObjectHashFunctions { | 112 struct FloatingObjectHashFunctions { |
113 STATIC_ONLY(FloatingObjectHashFunctions); | 113 STATIC_ONLY(FloatingObjectHashFunctions); |
114 static unsigned hash(FloatingObject* key) { return DefaultHash<LayoutBox*>::
Hash::hash(key->layoutObject()); } | 114 static unsigned hash(FloatingObject* key) { return DefaultHash<LayoutBox*>::
Hash::hash(key->layoutObject()); } |
115 static unsigned hash(const std::unique_ptr<FloatingObject>& key) { return ha
sh(key.get()); } | 115 static unsigned hash(const OwnPtr<FloatingObject>& key) { return hash(key.ge
t()); } |
116 static bool equal(std::unique_ptr<FloatingObject>& a, FloatingObject* b) { r
eturn a->layoutObject() == b->layoutObject(); } | 116 static bool equal(OwnPtr<FloatingObject>& a, FloatingObject* b) { return a->
layoutObject() == b->layoutObject(); } |
117 static bool equal(std::unique_ptr<FloatingObject>& a, const std::unique_ptr<
FloatingObject>& b) { return equal(a, b.get()); } | 117 static bool equal(OwnPtr<FloatingObject>& a, const OwnPtr<FloatingObject>& b
) { return equal(a, b.get()); } |
118 | 118 |
119 static const bool safeToCompareToEmptyOrDeleted = true; | 119 static const bool safeToCompareToEmptyOrDeleted = true; |
120 }; | 120 }; |
121 struct FloatingObjectHashTranslator { | 121 struct FloatingObjectHashTranslator { |
122 STATIC_ONLY(FloatingObjectHashTranslator); | 122 STATIC_ONLY(FloatingObjectHashTranslator); |
123 static unsigned hash(LayoutBox* key) { return DefaultHash<LayoutBox*>::Hash:
:hash(key); } | 123 static unsigned hash(LayoutBox* key) { return DefaultHash<LayoutBox*>::Hash:
:hash(key); } |
124 static bool equal(FloatingObject* a, LayoutBox* b) { return a->layoutObject(
) == b; } | 124 static bool equal(FloatingObject* a, LayoutBox* b) { return a->layoutObject(
) == b; } |
125 static bool equal(const std::unique_ptr<FloatingObject>& a, LayoutBox* b) {
return a->layoutObject() == b; } | 125 static bool equal(const OwnPtr<FloatingObject>& a, LayoutBox* b) { return a-
>layoutObject() == b; } |
126 }; | 126 }; |
127 typedef ListHashSet<std::unique_ptr<FloatingObject>, 4, FloatingObjectHashFuncti
ons> FloatingObjectSet; | 127 typedef ListHashSet<OwnPtr<FloatingObject>, 4, FloatingObjectHashFunctions> Floa
tingObjectSet; |
128 typedef FloatingObjectSet::const_iterator FloatingObjectSetIterator; | 128 typedef FloatingObjectSet::const_iterator FloatingObjectSetIterator; |
129 typedef PODInterval<LayoutUnit, FloatingObject*> FloatingObjectInterval; | 129 typedef PODInterval<LayoutUnit, FloatingObject*> FloatingObjectInterval; |
130 typedef PODIntervalTree<LayoutUnit, FloatingObject*> FloatingObjectTree; | 130 typedef PODIntervalTree<LayoutUnit, FloatingObject*> FloatingObjectTree; |
131 typedef PODFreeListArena<PODRedBlackTree<FloatingObjectInterval>::Node> Interval
Arena; | 131 typedef PODFreeListArena<PODRedBlackTree<FloatingObjectInterval>::Node> Interval
Arena; |
132 typedef HashMap<LayoutBox*, std::unique_ptr<FloatingObject>> LayoutBoxToFloatInf
oMap; | 132 typedef HashMap<LayoutBox*, OwnPtr<FloatingObject>> LayoutBoxToFloatInfoMap; |
133 | 133 |
134 class FloatingObjects { | 134 class FloatingObjects { |
135 WTF_MAKE_NONCOPYABLE(FloatingObjects); USING_FAST_MALLOC(FloatingObjects); | 135 WTF_MAKE_NONCOPYABLE(FloatingObjects); USING_FAST_MALLOC(FloatingObjects); |
136 public: | 136 public: |
137 FloatingObjects(const LayoutBlockFlow*, bool horizontalWritingMode); | 137 FloatingObjects(const LayoutBlockFlow*, bool horizontalWritingMode); |
138 ~FloatingObjects(); | 138 ~FloatingObjects(); |
139 | 139 |
140 void clear(); | 140 void clear(); |
141 void moveAllToFloatInfoMap(LayoutBoxToFloatInfoMap&); | 141 void moveAllToFloatInfoMap(LayoutBoxToFloatInfoMap&); |
142 FloatingObject* add(std::unique_ptr<FloatingObject>); | 142 FloatingObject* add(PassOwnPtr<FloatingObject>); |
143 void remove(FloatingObject*); | 143 void remove(FloatingObject*); |
144 void addPlacedObject(FloatingObject&); | 144 void addPlacedObject(FloatingObject&); |
145 void removePlacedObject(FloatingObject&); | 145 void removePlacedObject(FloatingObject&); |
146 void setHorizontalWritingMode(bool b = true) { m_horizontalWritingMode = b;
} | 146 void setHorizontalWritingMode(bool b = true) { m_horizontalWritingMode = b;
} |
147 | 147 |
148 bool hasLeftObjects() const { return m_leftObjectsCount > 0; } | 148 bool hasLeftObjects() const { return m_leftObjectsCount > 0; } |
149 bool hasRightObjects() const { return m_rightObjectsCount > 0; } | 149 bool hasRightObjects() const { return m_rightObjectsCount > 0; } |
150 const FloatingObjectSet& set() const { return m_set; } | 150 const FloatingObjectSet& set() const { return m_set; } |
151 FloatingObjectSet& mutableSet() { return m_set; } | 151 FloatingObjectSet& mutableSet() { return m_set; } |
152 void clearLineBoxTreePointers(); | 152 void clearLineBoxTreePointers(); |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 static String toString(const LayoutUnit value); | 201 static String toString(const LayoutUnit value); |
202 }; | 202 }; |
203 template<> struct ValueToString<FloatingObject*> { | 203 template<> struct ValueToString<FloatingObject*> { |
204 static String toString(const FloatingObject*); | 204 static String toString(const FloatingObject*); |
205 }; | 205 }; |
206 #endif | 206 #endif |
207 | 207 |
208 } // namespace blink | 208 } // namespace blink |
209 | 209 |
210 #endif // FloatingObjects_h | 210 #endif // FloatingObjects_h |
OLD | NEW |