OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved. | 2 * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above | 8 * 1. Redistributions of source code must retain the above |
9 * copyright notice, this list of conditions and the following | 9 * copyright notice, this list of conditions and the following |
10 * disclaimer. | 10 * disclaimer. |
(...skipping 25 matching lines...) Expand all Loading... |
36 #include "platform/geometry/FloatRect.h" | 36 #include "platform/geometry/FloatRect.h" |
37 #include "platform/geometry/LayoutSize.h" | 37 #include "platform/geometry/LayoutSize.h" |
38 #include "wtf/OwnPtr.h" | 38 #include "wtf/OwnPtr.h" |
39 | 39 |
40 namespace blink { | 40 namespace blink { |
41 | 41 |
42 class RenderBlockFlow; | 42 class RenderBlockFlow; |
43 class RenderBox; | 43 class RenderBox; |
44 class FloatingObject; | 44 class FloatingObject; |
45 | 45 |
| 46 class ShapeOutsideDeltas FINAL { |
| 47 public: |
| 48 ShapeOutsideDeltas() |
| 49 : m_lineOverlapsShape(false) |
| 50 , m_isValid(false) |
| 51 { |
| 52 } |
| 53 |
| 54 ShapeOutsideDeltas(LayoutUnit leftMarginBoxDelta, LayoutUnit rightMarginBoxD
elta, bool lineOverlapsShape, LayoutUnit borderBoxLineTop, LayoutUnit lineHeight
) |
| 55 : m_leftMarginBoxDelta(leftMarginBoxDelta) |
| 56 , m_rightMarginBoxDelta(rightMarginBoxDelta) |
| 57 , m_borderBoxLineTop(borderBoxLineTop) |
| 58 , m_lineHeight(lineHeight) |
| 59 , m_lineOverlapsShape(lineOverlapsShape) |
| 60 , m_isValid(true) |
| 61 { |
| 62 } |
| 63 |
| 64 bool isForLine(LayoutUnit borderBoxLineTop, LayoutUnit lineHeight) |
| 65 { |
| 66 return m_isValid && m_borderBoxLineTop == borderBoxLineTop && m_lineHeig
ht == lineHeight; |
| 67 } |
| 68 |
| 69 bool isValid() { return m_isValid; } |
| 70 LayoutUnit leftMarginBoxDelta() { ASSERT(m_isValid); return m_leftMarginBoxD
elta; } |
| 71 LayoutUnit rightMarginBoxDelta() { ASSERT(m_isValid); return m_rightMarginBo
xDelta; } |
| 72 bool lineOverlapsShape() { ASSERT(m_isValid); return m_lineOverlapsShape; } |
| 73 |
| 74 private: |
| 75 LayoutUnit m_leftMarginBoxDelta; |
| 76 LayoutUnit m_rightMarginBoxDelta; |
| 77 LayoutUnit m_borderBoxLineTop; |
| 78 LayoutUnit m_lineHeight; |
| 79 bool m_lineOverlapsShape : 1; |
| 80 bool m_isValid : 1; |
| 81 }; |
| 82 |
46 class ShapeOutsideInfo FINAL { | 83 class ShapeOutsideInfo FINAL { |
47 WTF_MAKE_FAST_ALLOCATED; | 84 WTF_MAKE_FAST_ALLOCATED; |
48 public: | 85 public: |
49 void setReferenceBoxLogicalSize(LayoutSize); | 86 void setReferenceBoxLogicalSize(LayoutSize); |
50 | 87 |
51 LayoutUnit shapeLogicalTop() const { return computedShape().shapeMarginLogic
alBoundingBox().y() + logicalTopOffset(); } | 88 LayoutUnit shapeLogicalTop() const { return computedShape().shapeMarginLogic
alBoundingBox().y() + logicalTopOffset(); } |
52 LayoutUnit shapeLogicalBottom() const { return computedShape().shapeMarginLo
gicalBoundingBox().maxY() + logicalTopOffset(); } | 89 LayoutUnit shapeLogicalBottom() const { return computedShape().shapeMarginLo
gicalBoundingBox().maxY() + logicalTopOffset(); } |
53 LayoutUnit shapeLogicalLeft() const { return computedShape().shapeMarginLogi
calBoundingBox().x() + logicalLeftOffset(); } | 90 LayoutUnit shapeLogicalLeft() const { return computedShape().shapeMarginLogi
calBoundingBox().x() + logicalLeftOffset(); } |
54 LayoutUnit shapeLogicalRight() const { return computedShape().shapeMarginLog
icalBoundingBox().maxX() + logicalLeftOffset(); } | 91 LayoutUnit shapeLogicalRight() const { return computedShape().shapeMarginLog
icalBoundingBox().maxX() + logicalLeftOffset(); } |
55 LayoutUnit shapeLogicalWidth() const { return computedShape().shapeMarginLog
icalBoundingBox().width(); } | 92 LayoutUnit shapeLogicalWidth() const { return computedShape().shapeMarginLog
icalBoundingBox().width(); } |
56 LayoutUnit shapeLogicalHeight() const { return computedShape().shapeMarginLo
gicalBoundingBox().height(); } | 93 LayoutUnit shapeLogicalHeight() const { return computedShape().shapeMarginLo
gicalBoundingBox().height(); } |
57 | 94 |
58 LayoutUnit logicalLineTop() const { return m_referenceBoxLineTop + logicalTo
pOffset(); } | |
59 LayoutUnit logicalLineBottom() const { return m_referenceBoxLineTop + m_line
Height + logicalTopOffset(); } | |
60 | |
61 LayoutUnit leftMarginBoxDelta() const { return m_leftMarginBoxDelta; } | |
62 LayoutUnit rightMarginBoxDelta() const { return m_rightMarginBoxDelta; } | |
63 bool lineOverlapsShape() const { return m_lineOverlapsShape; } | |
64 | |
65 static PassOwnPtr<ShapeOutsideInfo> createInfo(const RenderBox& renderer) {
return adoptPtr(new ShapeOutsideInfo(renderer)); } | 95 static PassOwnPtr<ShapeOutsideInfo> createInfo(const RenderBox& renderer) {
return adoptPtr(new ShapeOutsideInfo(renderer)); } |
66 static bool isEnabledFor(const RenderBox&); | 96 static bool isEnabledFor(const RenderBox&); |
67 void updateDeltasForContainingBlockLine(const RenderBlockFlow&, const Floati
ngObject&, LayoutUnit lineTop, LayoutUnit lineHeight); | |
68 | 97 |
69 bool lineOverlapsShapeBounds() const | 98 ShapeOutsideDeltas computeDeltasForContainingBlockLine(const RenderBlockFlow
&, const FloatingObject&, LayoutUnit lineTop, LayoutUnit lineHeight); |
70 { | |
71 return computedShape().lineOverlapsShapeMarginBounds(m_referenceBoxLineT
op, m_lineHeight); | |
72 } | |
73 | 99 |
74 static ShapeOutsideInfo& ensureInfo(const RenderBox& key) | 100 static ShapeOutsideInfo& ensureInfo(const RenderBox& key) |
75 { | 101 { |
76 InfoMap& infoMap = ShapeOutsideInfo::infoMap(); | 102 InfoMap& infoMap = ShapeOutsideInfo::infoMap(); |
77 if (ShapeOutsideInfo* info = infoMap.get(&key)) | 103 if (ShapeOutsideInfo* info = infoMap.get(&key)) |
78 return *info; | 104 return *info; |
79 InfoMap::AddResult result = infoMap.add(&key, ShapeOutsideInfo::createIn
fo(key)); | 105 InfoMap::AddResult result = infoMap.add(&key, ShapeOutsideInfo::createIn
fo(key)); |
80 return *result.storedValue->value; | 106 return *result.storedValue->value; |
81 } | 107 } |
82 static void removeInfo(const RenderBox& key) { infoMap().remove(&key); } | 108 static void removeInfo(const RenderBox& key) { infoMap().remove(&key); } |
83 static ShapeOutsideInfo* info(const RenderBox& key) { return infoMap().get(&
key); } | 109 static ShapeOutsideInfo* info(const RenderBox& key) { return infoMap().get(&
key); } |
84 | 110 |
85 void markShapeAsDirty() { m_shape.clear(); } | 111 void markShapeAsDirty() { m_shape.clear(); } |
86 bool isShapeDirty() { return !m_shape.get(); } | 112 bool isShapeDirty() { return !m_shape.get(); } |
87 LayoutSize shapeSize() const { return m_referenceBoxLogicalSize; } | 113 LayoutSize shapeSize() const { return m_referenceBoxLogicalSize; } |
88 | 114 |
89 LayoutRect computedShapePhysicalBoundingBox() const; | 115 LayoutRect computedShapePhysicalBoundingBox() const; |
90 FloatPoint shapeToRendererPoint(FloatPoint) const; | 116 FloatPoint shapeToRendererPoint(FloatPoint) const; |
91 FloatSize shapeToRendererSize(FloatSize) const; | 117 FloatSize shapeToRendererSize(FloatSize) const; |
92 const Shape& computedShape() const; | 118 const Shape& computedShape() const; |
93 | 119 |
94 protected: | 120 protected: |
95 ShapeOutsideInfo(const RenderBox& renderer) | 121 ShapeOutsideInfo(const RenderBox& renderer) |
96 : m_renderer(renderer) | 122 : m_renderer(renderer) |
97 , m_lineOverlapsShape(false) | |
98 { } | 123 { } |
99 | 124 |
100 private: | 125 private: |
101 PassOwnPtr<Shape> createShapeForImage(StyleImage*, float shapeImageThreshold
, WritingMode, float margin) const; | 126 PassOwnPtr<Shape> createShapeForImage(StyleImage*, float shapeImageThreshold
, WritingMode, float margin) const; |
102 | 127 |
103 LayoutUnit logicalTopOffset() const; | 128 LayoutUnit logicalTopOffset() const; |
104 LayoutUnit logicalLeftOffset() const; | 129 LayoutUnit logicalLeftOffset() const; |
105 | 130 |
106 typedef HashMap<const RenderBox*, OwnPtr<ShapeOutsideInfo> > InfoMap; | 131 typedef HashMap<const RenderBox*, OwnPtr<ShapeOutsideInfo> > InfoMap; |
107 static InfoMap& infoMap() | 132 static InfoMap& infoMap() |
108 { | 133 { |
109 DEFINE_STATIC_LOCAL(InfoMap, staticInfoMap, ()); | 134 DEFINE_STATIC_LOCAL(InfoMap, staticInfoMap, ()); |
110 return staticInfoMap; | 135 return staticInfoMap; |
111 } | 136 } |
112 | 137 |
113 LayoutUnit m_referenceBoxLineTop; | |
114 LayoutUnit m_lineHeight; | |
115 | |
116 const RenderBox& m_renderer; | 138 const RenderBox& m_renderer; |
117 mutable OwnPtr<Shape> m_shape; | 139 mutable OwnPtr<Shape> m_shape; |
118 LayoutSize m_referenceBoxLogicalSize; | 140 LayoutSize m_referenceBoxLogicalSize; |
119 LayoutUnit m_leftMarginBoxDelta; | 141 ShapeOutsideDeltas m_shapeOutsideDeltas; |
120 LayoutUnit m_rightMarginBoxDelta; | |
121 LayoutUnit m_borderBoxLineTop; | |
122 bool m_lineOverlapsShape; | |
123 }; | 142 }; |
124 | 143 |
125 } | 144 } |
126 #endif | 145 #endif |
OLD | NEW |