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_leftMarginBoxDelta(0) | |
leviw_travelin_and_unemployed
2014/08/15 22:42:10
These constructors taking zeros aren't necessary,
| |
50 , m_rightMarginBoxDelta(0) | |
51 , m_borderBoxLineTop(0) | |
52 , m_lineHeight(0) | |
53 , m_lineOverlapsShape(false) | |
54 , m_isValid(false) | |
55 { | |
56 } | |
57 | |
58 ShapeOutsideDeltas(LayoutUnit leftMarginBoxDelta, LayoutUnit rightMarginBoxD elta, bool lineOverlapsShape, LayoutUnit borderBoxLineTop, LayoutUnit lineHeight ) | |
59 : m_leftMarginBoxDelta(leftMarginBoxDelta) | |
60 , m_rightMarginBoxDelta(rightMarginBoxDelta) | |
61 , m_borderBoxLineTop(borderBoxLineTop) | |
62 , m_lineHeight(lineHeight) | |
63 , m_lineOverlapsShape(lineOverlapsShape) | |
64 , m_isValid(true) | |
65 { | |
66 } | |
67 | |
68 bool isForLine(LayoutUnit borderBoxLineTop, LayoutUnit lineHeight) | |
69 { | |
70 return m_isValid && m_borderBoxLineTop == borderBoxLineTop && m_lineHeig ht == lineHeight; | |
71 } | |
72 | |
73 bool isValid() { return m_isValid; } | |
74 LayoutUnit leftMarginBoxDelta() { ASSERT(m_isValid); return m_leftMarginBoxD elta; } | |
75 LayoutUnit rightMarginBoxDelta() { ASSERT(m_isValid); return m_rightMarginBo xDelta; } | |
76 bool lineOverlapsShape() { ASSERT(m_isValid); return m_lineOverlapsShape; } | |
77 | |
78 private: | |
79 LayoutUnit m_leftMarginBoxDelta; | |
80 LayoutUnit m_rightMarginBoxDelta; | |
81 LayoutUnit m_borderBoxLineTop; | |
82 LayoutUnit m_lineHeight; | |
83 bool m_lineOverlapsShape; | |
leviw_travelin_and_unemployed
2014/08/15 22:42:10
Nit: you could pack these by explicitly sizing the
| |
84 bool m_isValid; | |
85 }; | |
86 | |
46 class ShapeOutsideInfo FINAL { | 87 class ShapeOutsideInfo FINAL { |
47 WTF_MAKE_FAST_ALLOCATED; | 88 WTF_MAKE_FAST_ALLOCATED; |
48 public: | 89 public: |
49 void setReferenceBoxLogicalSize(LayoutSize); | 90 void setReferenceBoxLogicalSize(LayoutSize); |
50 | 91 |
51 LayoutUnit shapeLogicalTop() const { return computedShape().shapeMarginLogic alBoundingBox().y() + logicalTopOffset(); } | 92 LayoutUnit shapeLogicalTop() const { return computedShape().shapeMarginLogic alBoundingBox().y() + logicalTopOffset(); } |
52 LayoutUnit shapeLogicalBottom() const { return computedShape().shapeMarginLo gicalBoundingBox().maxY() + logicalTopOffset(); } | 93 LayoutUnit shapeLogicalBottom() const { return computedShape().shapeMarginLo gicalBoundingBox().maxY() + logicalTopOffset(); } |
53 LayoutUnit shapeLogicalLeft() const { return computedShape().shapeMarginLogi calBoundingBox().x() + logicalLeftOffset(); } | 94 LayoutUnit shapeLogicalLeft() const { return computedShape().shapeMarginLogi calBoundingBox().x() + logicalLeftOffset(); } |
54 LayoutUnit shapeLogicalRight() const { return computedShape().shapeMarginLog icalBoundingBox().maxX() + logicalLeftOffset(); } | 95 LayoutUnit shapeLogicalRight() const { return computedShape().shapeMarginLog icalBoundingBox().maxX() + logicalLeftOffset(); } |
55 LayoutUnit shapeLogicalWidth() const { return computedShape().shapeMarginLog icalBoundingBox().width(); } | 96 LayoutUnit shapeLogicalWidth() const { return computedShape().shapeMarginLog icalBoundingBox().width(); } |
56 LayoutUnit shapeLogicalHeight() const { return computedShape().shapeMarginLo gicalBoundingBox().height(); } | 97 LayoutUnit shapeLogicalHeight() const { return computedShape().shapeMarginLo gicalBoundingBox().height(); } |
57 | 98 |
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)); } | 99 static PassOwnPtr<ShapeOutsideInfo> createInfo(const RenderBox& renderer) { return adoptPtr(new ShapeOutsideInfo(renderer)); } |
66 static bool isEnabledFor(const RenderBox&); | 100 static bool isEnabledFor(const RenderBox&); |
67 void updateDeltasForContainingBlockLine(const RenderBlockFlow&, const Floati ngObject&, LayoutUnit lineTop, LayoutUnit lineHeight); | |
68 | 101 |
69 bool lineOverlapsShapeBounds() const | 102 ShapeOutsideDeltas computeDeltasForContainingBlockLine(const RenderBlockFlow &, const FloatingObject&, LayoutUnit lineTop, LayoutUnit lineHeight); |
70 { | |
71 return computedShape().lineOverlapsShapeMarginBounds(m_referenceBoxLineT op, m_lineHeight); | |
72 } | |
73 | 103 |
74 static ShapeOutsideInfo& ensureInfo(const RenderBox& key) | 104 static ShapeOutsideInfo& ensureInfo(const RenderBox& key) |
75 { | 105 { |
76 InfoMap& infoMap = ShapeOutsideInfo::infoMap(); | 106 InfoMap& infoMap = ShapeOutsideInfo::infoMap(); |
77 if (ShapeOutsideInfo* info = infoMap.get(&key)) | 107 if (ShapeOutsideInfo* info = infoMap.get(&key)) |
78 return *info; | 108 return *info; |
79 InfoMap::AddResult result = infoMap.add(&key, ShapeOutsideInfo::createIn fo(key)); | 109 InfoMap::AddResult result = infoMap.add(&key, ShapeOutsideInfo::createIn fo(key)); |
80 return *result.storedValue->value; | 110 return *result.storedValue->value; |
81 } | 111 } |
82 static void removeInfo(const RenderBox& key) { infoMap().remove(&key); } | 112 static void removeInfo(const RenderBox& key) { infoMap().remove(&key); } |
83 static ShapeOutsideInfo* info(const RenderBox& key) { return infoMap().get(& key); } | 113 static ShapeOutsideInfo* info(const RenderBox& key) { return infoMap().get(& key); } |
84 | 114 |
85 void markShapeAsDirty() { m_shape.clear(); } | 115 void markShapeAsDirty() { m_shape.clear(); } |
86 bool isShapeDirty() { return !m_shape.get(); } | 116 bool isShapeDirty() { return !m_shape.get(); } |
87 LayoutSize shapeSize() const { return m_referenceBoxLogicalSize; } | 117 LayoutSize shapeSize() const { return m_referenceBoxLogicalSize; } |
88 | 118 |
89 LayoutRect computedShapePhysicalBoundingBox() const; | 119 LayoutRect computedShapePhysicalBoundingBox() const; |
90 FloatPoint shapeToRendererPoint(FloatPoint) const; | 120 FloatPoint shapeToRendererPoint(FloatPoint) const; |
91 FloatSize shapeToRendererSize(FloatSize) const; | 121 FloatSize shapeToRendererSize(FloatSize) const; |
92 const Shape& computedShape() const; | 122 const Shape& computedShape() const; |
93 | 123 |
94 protected: | 124 protected: |
95 ShapeOutsideInfo(const RenderBox& renderer) | 125 ShapeOutsideInfo(const RenderBox& renderer) |
96 : m_renderer(renderer) | 126 : m_renderer(renderer) |
97 , m_lineOverlapsShape(false) | |
98 { } | 127 { } |
99 | 128 |
100 private: | 129 private: |
101 PassOwnPtr<Shape> createShapeForImage(StyleImage*, float shapeImageThreshold , WritingMode, float margin) const; | 130 PassOwnPtr<Shape> createShapeForImage(StyleImage*, float shapeImageThreshold , WritingMode, float margin) const; |
102 | 131 |
103 LayoutUnit logicalTopOffset() const; | 132 LayoutUnit logicalTopOffset() const; |
104 LayoutUnit logicalLeftOffset() const; | 133 LayoutUnit logicalLeftOffset() const; |
105 | 134 |
106 typedef HashMap<const RenderBox*, OwnPtr<ShapeOutsideInfo> > InfoMap; | 135 typedef HashMap<const RenderBox*, OwnPtr<ShapeOutsideInfo> > InfoMap; |
107 static InfoMap& infoMap() | 136 static InfoMap& infoMap() |
108 { | 137 { |
109 DEFINE_STATIC_LOCAL(InfoMap, staticInfoMap, ()); | 138 DEFINE_STATIC_LOCAL(InfoMap, staticInfoMap, ()); |
110 return staticInfoMap; | 139 return staticInfoMap; |
111 } | 140 } |
112 | 141 |
113 LayoutUnit m_referenceBoxLineTop; | |
114 LayoutUnit m_lineHeight; | |
115 | |
116 const RenderBox& m_renderer; | 142 const RenderBox& m_renderer; |
117 mutable OwnPtr<Shape> m_shape; | 143 mutable OwnPtr<Shape> m_shape; |
118 LayoutSize m_referenceBoxLogicalSize; | 144 LayoutSize m_referenceBoxLogicalSize; |
119 LayoutUnit m_leftMarginBoxDelta; | 145 ShapeOutsideDeltas m_shapeOutsideDeltas; |
120 LayoutUnit m_rightMarginBoxDelta; | |
121 LayoutUnit m_borderBoxLineTop; | |
122 bool m_lineOverlapsShape; | |
123 }; | 146 }; |
124 | 147 |
125 } | 148 } |
126 #endif | 149 #endif |
OLD | NEW |