| 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 15 matching lines...) Expand all Loading... |
| 26 | 26 |
| 27 #include "core/layout/line/RootInlineBox.h" | 27 #include "core/layout/line/RootInlineBox.h" |
| 28 #include "platform/PODFreeListArena.h" | 28 #include "platform/PODFreeListArena.h" |
| 29 #include "platform/PODIntervalTree.h" | 29 #include "platform/PODIntervalTree.h" |
| 30 #include "wtf/ListHashSet.h" | 30 #include "wtf/ListHashSet.h" |
| 31 #include "wtf/OwnPtr.h" | 31 #include "wtf/OwnPtr.h" |
| 32 | 32 |
| 33 namespace blink { | 33 namespace blink { |
| 34 | 34 |
| 35 class RenderBlockFlow; | 35 class RenderBlockFlow; |
| 36 class RenderBox; | 36 class LayoutBox; |
| 37 | 37 |
| 38 // FIXME this should be removed once RenderBlockFlow::nextFloatLogicalBottomBelo
w doesn't need it anymore. (Bug 123931) | 38 // FIXME this should be removed once RenderBlockFlow::nextFloatLogicalBottomBelo
w doesn't need it anymore. (Bug 123931) |
| 39 enum ShapeOutsideFloatOffsetMode { ShapeOutsideFloatShapeOffset, ShapeOutsideFlo
atMarginBoxOffset }; | 39 enum ShapeOutsideFloatOffsetMode { ShapeOutsideFloatShapeOffset, ShapeOutsideFlo
atMarginBoxOffset }; |
| 40 | 40 |
| 41 class FloatingObject { | 41 class FloatingObject { |
| 42 WTF_MAKE_NONCOPYABLE(FloatingObject); WTF_MAKE_FAST_ALLOCATED; | 42 WTF_MAKE_NONCOPYABLE(FloatingObject); WTF_MAKE_FAST_ALLOCATED; |
| 43 public: | 43 public: |
| 44 #ifndef NDEBUG | 44 #ifndef NDEBUG |
| 45 // Used by the PODIntervalTree for debugging the FloatingObject. | 45 // Used by the PODIntervalTree for debugging the FloatingObject. |
| 46 template <class> friend struct ValueToString; | 46 template <class> friend struct ValueToString; |
| 47 #endif | 47 #endif |
| 48 | 48 |
| 49 // Note that Type uses bits so you can use FloatLeftRight as a mask to query
for both left and right. | 49 // Note that Type uses bits so you can use FloatLeftRight as a mask to query
for both left and right. |
| 50 enum Type { FloatLeft = 1, FloatRight = 2, FloatLeftRight = 3 }; | 50 enum Type { FloatLeft = 1, FloatRight = 2, FloatLeftRight = 3 }; |
| 51 | 51 |
| 52 static PassOwnPtr<FloatingObject> create(RenderBox*); | 52 static PassOwnPtr<FloatingObject> create(LayoutBox*); |
| 53 | 53 |
| 54 PassOwnPtr<FloatingObject> copyToNewContainer(LayoutSize, bool shouldPaint =
false, bool isDescendant = false) const; | 54 PassOwnPtr<FloatingObject> copyToNewContainer(LayoutSize, bool shouldPaint =
false, bool isDescendant = false) const; |
| 55 | 55 |
| 56 PassOwnPtr<FloatingObject> unsafeClone() const; | 56 PassOwnPtr<FloatingObject> unsafeClone() const; |
| 57 | 57 |
| 58 Type type() const { return static_cast<Type>(m_type); } | 58 Type type() const { return static_cast<Type>(m_type); } |
| 59 RenderBox* renderer() const { return m_renderer; } | 59 LayoutBox* renderer() const { return m_renderer; } |
| 60 | 60 |
| 61 bool isPlaced() const { return m_isPlaced; } | 61 bool isPlaced() const { return m_isPlaced; } |
| 62 void setIsPlaced(bool placed = true) { m_isPlaced = placed; } | 62 void setIsPlaced(bool placed = true) { m_isPlaced = placed; } |
| 63 | 63 |
| 64 LayoutUnit x() const { ASSERT(isPlaced()); return m_frameRect.x(); } | 64 LayoutUnit x() const { ASSERT(isPlaced()); return m_frameRect.x(); } |
| 65 LayoutUnit maxX() const { ASSERT(isPlaced()); return m_frameRect.maxX(); } | 65 LayoutUnit maxX() const { ASSERT(isPlaced()); return m_frameRect.maxX(); } |
| 66 LayoutUnit y() const { ASSERT(isPlaced()); return m_frameRect.y(); } | 66 LayoutUnit y() const { ASSERT(isPlaced()); return m_frameRect.y(); } |
| 67 LayoutUnit maxY() const { ASSERT(isPlaced()); return m_frameRect.maxY(); } | 67 LayoutUnit maxY() const { ASSERT(isPlaced()); return m_frameRect.maxY(); } |
| 68 LayoutUnit width() const { return m_frameRect.width(); } | 68 LayoutUnit width() const { return m_frameRect.width(); } |
| 69 LayoutUnit height() const { return m_frameRect.height(); } | 69 LayoutUnit height() const { return m_frameRect.height(); } |
| (...skipping 16 matching lines...) Expand all Loading... |
| 86 bool shouldPaint() const { return m_shouldPaint; } | 86 bool shouldPaint() const { return m_shouldPaint; } |
| 87 void setShouldPaint(bool shouldPaint) { m_shouldPaint = shouldPaint; } | 87 void setShouldPaint(bool shouldPaint) { m_shouldPaint = shouldPaint; } |
| 88 bool isDescendant() const { return m_isDescendant; } | 88 bool isDescendant() const { return m_isDescendant; } |
| 89 void setIsDescendant(bool isDescendant) { m_isDescendant = isDescendant; } | 89 void setIsDescendant(bool isDescendant) { m_isDescendant = isDescendant; } |
| 90 | 90 |
| 91 // FIXME: Callers of these methods are dangerous and should be whitelisted e
xplicitly or removed. | 91 // FIXME: Callers of these methods are dangerous and should be whitelisted e
xplicitly or removed. |
| 92 RootInlineBox* originatingLine() const { return m_originatingLine; } | 92 RootInlineBox* originatingLine() const { return m_originatingLine; } |
| 93 void setOriginatingLine(RootInlineBox* line) { m_originatingLine = line; } | 93 void setOriginatingLine(RootInlineBox* line) { m_originatingLine = line; } |
| 94 | 94 |
| 95 private: | 95 private: |
| 96 explicit FloatingObject(RenderBox*); | 96 explicit FloatingObject(LayoutBox*); |
| 97 FloatingObject(RenderBox*, Type, const LayoutRect&, bool shouldPaint, bool i
sDescendant); | 97 FloatingObject(LayoutBox*, Type, const LayoutRect&, bool shouldPaint, bool i
sDescendant); |
| 98 | 98 |
| 99 RenderBox* m_renderer; | 99 LayoutBox* m_renderer; |
| 100 RootInlineBox* m_originatingLine; | 100 RootInlineBox* m_originatingLine; |
| 101 LayoutRect m_frameRect; | 101 LayoutRect m_frameRect; |
| 102 int m_paginationStrut; // FIXME: Is this class size-sensitive? Does this nee
d 32-bits? | 102 int m_paginationStrut; // FIXME: Is this class size-sensitive? Does this nee
d 32-bits? |
| 103 | 103 |
| 104 unsigned m_type : 2; // Type (left or right aligned) | 104 unsigned m_type : 2; // Type (left or right aligned) |
| 105 unsigned m_shouldPaint : 1; | 105 unsigned m_shouldPaint : 1; |
| 106 unsigned m_isDescendant : 1; | 106 unsigned m_isDescendant : 1; |
| 107 unsigned m_isPlaced : 1; | 107 unsigned m_isPlaced : 1; |
| 108 #if ENABLE(ASSERT) | 108 #if ENABLE(ASSERT) |
| 109 unsigned m_isInPlacedTree : 1; | 109 unsigned m_isInPlacedTree : 1; |
| 110 #endif | 110 #endif |
| 111 }; | 111 }; |
| 112 | 112 |
| 113 struct FloatingObjectHashFunctions { | 113 struct FloatingObjectHashFunctions { |
| 114 static unsigned hash(FloatingObject* key) { return DefaultHash<RenderBox*>::
Hash::hash(key->renderer()); } | 114 static unsigned hash(FloatingObject* key) { return DefaultHash<LayoutBox*>::
Hash::hash(key->renderer()); } |
| 115 static unsigned hash(const OwnPtr<FloatingObject>& key) { return hash(key.ge
t()); } | 115 static unsigned hash(const OwnPtr<FloatingObject>& key) { return hash(key.ge
t()); } |
| 116 static unsigned hash(const PassOwnPtr<FloatingObject>& key) { return hash(ke
y.get()); } | 116 static unsigned hash(const PassOwnPtr<FloatingObject>& key) { return hash(ke
y.get()); } |
| 117 static bool equal(OwnPtr<FloatingObject>& a, FloatingObject* b) { return a->
renderer() == b->renderer(); } | 117 static bool equal(OwnPtr<FloatingObject>& a, FloatingObject* b) { return a->
renderer() == b->renderer(); } |
| 118 static bool equal(OwnPtr<FloatingObject>& a, const OwnPtr<FloatingObject>& b
) { return equal(a, b.get()); } | 118 static bool equal(OwnPtr<FloatingObject>& a, const OwnPtr<FloatingObject>& b
) { return equal(a, b.get()); } |
| 119 static bool equal(OwnPtr<FloatingObject>& a, const PassOwnPtr<FloatingObject
>& b) { return equal(a, b.get()); } | 119 static bool equal(OwnPtr<FloatingObject>& a, const PassOwnPtr<FloatingObject
>& b) { return equal(a, b.get()); } |
| 120 | 120 |
| 121 static const bool safeToCompareToEmptyOrDeleted = true; | 121 static const bool safeToCompareToEmptyOrDeleted = true; |
| 122 }; | 122 }; |
| 123 struct FloatingObjectHashTranslator { | 123 struct FloatingObjectHashTranslator { |
| 124 static unsigned hash(RenderBox* key) { return DefaultHash<RenderBox*>::Hash:
:hash(key); } | 124 static unsigned hash(LayoutBox* key) { return DefaultHash<LayoutBox*>::Hash:
:hash(key); } |
| 125 static bool equal(FloatingObject* a, RenderBox* b) { return a->renderer() ==
b; } | 125 static bool equal(FloatingObject* a, LayoutBox* b) { return a->renderer() ==
b; } |
| 126 static bool equal(const OwnPtr<FloatingObject>& a, RenderBox* b) { return a-
>renderer() == b; } | 126 static bool equal(const OwnPtr<FloatingObject>& a, LayoutBox* b) { return a-
>renderer() == b; } |
| 127 }; | 127 }; |
| 128 typedef ListHashSet<OwnPtr<FloatingObject>, 4, FloatingObjectHashFunctions> Floa
tingObjectSet; | 128 typedef ListHashSet<OwnPtr<FloatingObject>, 4, FloatingObjectHashFunctions> Floa
tingObjectSet; |
| 129 typedef FloatingObjectSet::const_iterator FloatingObjectSetIterator; | 129 typedef FloatingObjectSet::const_iterator FloatingObjectSetIterator; |
| 130 typedef PODInterval<int, FloatingObject*> FloatingObjectInterval; | 130 typedef PODInterval<int, FloatingObject*> FloatingObjectInterval; |
| 131 typedef PODIntervalTree<int, FloatingObject*> FloatingObjectTree; | 131 typedef PODIntervalTree<int, FloatingObject*> FloatingObjectTree; |
| 132 typedef PODFreeListArena<PODRedBlackTree<FloatingObjectInterval>::Node> Interval
Arena; | 132 typedef PODFreeListArena<PODRedBlackTree<FloatingObjectInterval>::Node> Interval
Arena; |
| 133 typedef HashMap<RenderBox*, OwnPtr<FloatingObject>> RendererToFloatInfoMap; | 133 typedef HashMap<LayoutBox*, OwnPtr<FloatingObject>> RendererToFloatInfoMap; |
| 134 | 134 |
| 135 class FloatingObjects { | 135 class FloatingObjects { |
| 136 WTF_MAKE_NONCOPYABLE(FloatingObjects); WTF_MAKE_FAST_ALLOCATED; | 136 WTF_MAKE_NONCOPYABLE(FloatingObjects); WTF_MAKE_FAST_ALLOCATED; |
| 137 public: | 137 public: |
| 138 FloatingObjects(const RenderBlockFlow*, bool horizontalWritingMode); | 138 FloatingObjects(const RenderBlockFlow*, bool horizontalWritingMode); |
| 139 ~FloatingObjects(); | 139 ~FloatingObjects(); |
| 140 | 140 |
| 141 void clear(); | 141 void clear(); |
| 142 void moveAllToFloatInfoMap(RendererToFloatInfoMap&); | 142 void moveAllToFloatInfoMap(RendererToFloatInfoMap&); |
| 143 FloatingObject* add(PassOwnPtr<FloatingObject>); | 143 FloatingObject* add(PassOwnPtr<FloatingObject>); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 static String string(const int value); | 198 static String string(const int value); |
| 199 }; | 199 }; |
| 200 template<> struct ValueToString<FloatingObject*> { | 200 template<> struct ValueToString<FloatingObject*> { |
| 201 static String string(const FloatingObject*); | 201 static String string(const FloatingObject*); |
| 202 }; | 202 }; |
| 203 #endif | 203 #endif |
| 204 | 204 |
| 205 } // namespace blink | 205 } // namespace blink |
| 206 | 206 |
| 207 #endif // FloatingObjects_h | 207 #endif // FloatingObjects_h |
| OLD | NEW |