OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2011 Adobe Systems Incorporated. All rights reserved. | 2 * Copyright (C) 2011 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 20 matching lines...) Expand all Loading... |
31 #define RenderRegion_h | 31 #define RenderRegion_h |
32 | 32 |
33 #include "core/rendering/RenderBlockFlow.h" | 33 #include "core/rendering/RenderBlockFlow.h" |
34 #include "core/rendering/style/StyleInheritedData.h" | 34 #include "core/rendering/style/StyleInheritedData.h" |
35 | 35 |
36 namespace WebCore { | 36 namespace WebCore { |
37 | 37 |
38 struct LayerFragment; | 38 struct LayerFragment; |
39 typedef Vector<LayerFragment, 1> LayerFragments; | 39 typedef Vector<LayerFragment, 1> LayerFragments; |
40 class RenderBox; | 40 class RenderBox; |
41 class RenderBoxRegionInfo; | |
42 class RenderFlowThread; | 41 class RenderFlowThread; |
43 class RenderNamedFlowThread; | |
44 | 42 |
45 class RenderRegion : public RenderBlockFlow { | 43 class RenderRegion : public RenderBlockFlow { |
46 public: | 44 public: |
47 explicit RenderRegion(Element*, RenderFlowThread*); | 45 explicit RenderRegion(Element*, RenderFlowThread*); |
48 | 46 |
49 virtual bool isRenderRegion() const OVERRIDE FINAL { return true; } | 47 virtual bool isRenderRegion() const OVERRIDE FINAL { return true; } |
50 | 48 |
51 bool hitTestFlowThreadContents(const HitTestRequest&, HitTestResult&, const
HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset, HitT
estAction); | |
52 | |
53 virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle) OV
ERRIDE; | |
54 | |
55 void setFlowThreadPortionRect(const LayoutRect& rect) { m_flowThreadPortionR
ect = rect; } | 49 void setFlowThreadPortionRect(const LayoutRect& rect) { m_flowThreadPortionR
ect = rect; } |
56 LayoutRect flowThreadPortionRect() const { return m_flowThreadPortionRect; } | 50 LayoutRect flowThreadPortionRect() const { return m_flowThreadPortionRect; } |
57 LayoutRect flowThreadPortionOverflowRect() const; | 51 LayoutRect flowThreadPortionOverflowRect() const; |
58 | 52 |
59 void attachRegion(); | 53 void attachRegion(); |
60 void detachRegion(); | 54 void detachRegion(); |
61 | 55 |
62 RenderNamedFlowThread* parentNamedFlowThread() const { return m_parentNamedF
lowThread; } | |
63 RenderFlowThread* flowThread() const { return m_flowThread; } | 56 RenderFlowThread* flowThread() const { return m_flowThread; } |
64 | 57 |
65 // Valid regions do not create circular dependencies with other flows. | 58 // Valid regions do not create circular dependencies with other flows. |
66 bool isValid() const { return m_isValid; } | 59 bool isValid() const { return m_isValid; } |
67 void setIsValid(bool valid) { m_isValid = valid; } | 60 void setIsValid(bool valid) { m_isValid = valid; } |
68 | 61 |
69 bool hasCustomRegionStyle() const { return m_hasCustomRegionStyle; } | |
70 void setHasCustomRegionStyle(bool hasCustomRegionStyle) { m_hasCustomRegionS
tyle = hasCustomRegionStyle; } | |
71 | |
72 RenderBoxRegionInfo* renderBoxRegionInfo(const RenderBox*) const; | |
73 RenderBoxRegionInfo* setRenderBoxRegionInfo(const RenderBox*, LayoutUnit log
icalLeftInset, LayoutUnit logicalRightInset, | |
74 bool containingBlockChainIsInset); | |
75 PassOwnPtr<RenderBoxRegionInfo> takeRenderBoxRegionInfo(const RenderBox*); | |
76 void removeRenderBoxRegionInfo(const RenderBox*); | |
77 | |
78 void deleteAllRenderBoxRegionInfo(); | |
79 | |
80 bool isFirstRegion() const; | 62 bool isFirstRegion() const; |
81 bool isLastRegion() const; | 63 bool isLastRegion() const; |
82 | 64 |
83 void clearObjectStyleInRegion(const RenderObject*); | |
84 | |
85 RegionOversetState regionOversetState() const; | |
86 void setRegionOversetState(RegionOversetState); | |
87 | |
88 // These methods represent the width and height of a "page" and for a Render
Region they are just the | 65 // These methods represent the width and height of a "page" and for a Render
Region they are just the |
89 // content width and content height of a region. For RenderRegionSets, howev
er, they will be the width and | 66 // content width and content height of a region. For RenderRegionSets, howev
er, they will be the width and |
90 // height of a single column or page in the set. | 67 // height of a single column or page in the set. |
91 virtual LayoutUnit pageLogicalWidth() const; | 68 virtual LayoutUnit pageLogicalWidth() const; |
92 virtual LayoutUnit pageLogicalHeight() const; | 69 virtual LayoutUnit pageLogicalHeight() const; |
93 virtual LayoutUnit maxPageLogicalHeight() const; | |
94 | 70 |
95 LayoutUnit logicalTopOfFlowThreadContentRect(const LayoutRect&) const; | 71 LayoutUnit logicalTopOfFlowThreadContentRect(const LayoutRect&) const; |
96 LayoutUnit logicalBottomOfFlowThreadContentRect(const LayoutRect&) const; | 72 LayoutUnit logicalBottomOfFlowThreadContentRect(const LayoutRect&) const; |
97 LayoutUnit logicalTopForFlowThreadContent() const { return logicalTopOfFlowT
hreadContentRect(flowThreadPortionRect()); }; | 73 LayoutUnit logicalTopForFlowThreadContent() const { return logicalTopOfFlowT
hreadContentRect(flowThreadPortionRect()); }; |
98 LayoutUnit logicalBottomForFlowThreadContent() const { return logicalBottomO
fFlowThreadContentRect(flowThreadPortionRect()); }; | 74 LayoutUnit logicalBottomForFlowThreadContent() const { return logicalBottomO
fFlowThreadContentRect(flowThreadPortionRect()); }; |
99 | 75 |
100 void getRanges(Vector<RefPtr<Range> >&) const; | |
101 | |
102 // This method represents the logical height of the entire flow thread porti
on used by the region or set. | 76 // This method represents the logical height of the entire flow thread porti
on used by the region or set. |
103 // For RenderRegions it matches logicalPaginationHeight(), but for sets it i
s the height of all the pages | 77 // For RenderRegions it matches logicalPaginationHeight(), but for sets it i
s the height of all the pages |
104 // or columns added together. | 78 // or columns added together. |
105 virtual LayoutUnit logicalHeightOfAllFlowThreadContent() const; | 79 virtual LayoutUnit logicalHeightOfAllFlowThreadContent() const; |
106 | 80 |
107 bool hasAutoLogicalHeight() const { return m_hasAutoLogicalHeight; } | |
108 | |
109 const LayoutUnit& computedAutoHeight() const | |
110 { | |
111 ASSERT(hasComputedAutoHeight()); | |
112 return m_computedAutoHeight; | |
113 } | |
114 | |
115 void setComputedAutoHeight(LayoutUnit computedAutoHeight) | |
116 { | |
117 ASSERT(computedAutoHeight >= 0); | |
118 m_computedAutoHeight = computedAutoHeight; | |
119 } | |
120 | |
121 void clearComputedAutoHeight() | |
122 { | |
123 m_computedAutoHeight = -1; | |
124 } | |
125 | |
126 bool hasComputedAutoHeight() const { return (m_computedAutoHeight >= 0); } | |
127 | |
128 // The top of the nearest page inside the region. For RenderRegions, this is
just the logical top of the | 81 // The top of the nearest page inside the region. For RenderRegions, this is
just the logical top of the |
129 // flow thread portion we contain. For sets, we have to figure out the top o
f the nearest column or | 82 // flow thread portion we contain. For sets, we have to figure out the top o
f the nearest column or |
130 // page. | 83 // page. |
131 virtual LayoutUnit pageLogicalTopForOffset(LayoutUnit offset) const; | 84 virtual LayoutUnit pageLogicalTopForOffset(LayoutUnit offset) const; |
132 | 85 |
133 virtual void expandToEncompassFlowThreadContentsIfNeeded() { }; | 86 virtual void expandToEncompassFlowThreadContentsIfNeeded() { }; |
134 | 87 |
135 // Whether or not this region is a set. | |
136 virtual bool isRenderRegionSet() const { return false; } | |
137 | |
138 virtual void repaintFlowThreadContent(const LayoutRect& repaintRect) const; | 88 virtual void repaintFlowThreadContent(const LayoutRect& repaintRect) const; |
139 | 89 |
140 virtual void collectLayerFragments(LayerFragments&, const LayoutRect&, const
LayoutRect&) { } | 90 virtual void collectLayerFragments(LayerFragments&, const LayoutRect&, const
LayoutRect&) { } |
141 | 91 |
142 virtual bool canHaveChildren() const OVERRIDE FINAL { return false; } | 92 virtual bool canHaveChildren() const OVERRIDE FINAL { return false; } |
143 virtual bool canHaveGeneratedChildren() const OVERRIDE FINAL { return true;
} | 93 virtual bool canHaveGeneratedChildren() const OVERRIDE FINAL { return true;
} |
144 | 94 |
145 bool isElementBasedRegion() const; | |
146 | |
147 Node* nodeForRegion() const; | |
148 Node* generatingNodeForRegion() const; | |
149 | |
150 virtual const char* renderName() const OVERRIDE { return "RenderRegion"; } | 95 virtual const char* renderName() const OVERRIDE { return "RenderRegion"; } |
151 | 96 |
152 protected: | 97 protected: |
153 void setRegionObjectsRegionStyle(); | |
154 void restoreRegionObjectsOriginalStyle(); | |
155 | |
156 virtual void computeIntrinsicLogicalWidths(LayoutUnit& minLogicalWidth, Layo
utUnit& maxLogicalWidth) const OVERRIDE FINAL; | 98 virtual void computeIntrinsicLogicalWidths(LayoutUnit& minLogicalWidth, Layo
utUnit& maxLogicalWidth) const OVERRIDE FINAL; |
157 | 99 |
158 LayoutRect overflowRectForFlowThreadPortion(const LayoutRect& flowThreadPort
ionRect, bool isFirstPortion, bool isLastPortion) const; | 100 LayoutRect overflowRectForFlowThreadPortion(const LayoutRect& flowThreadPort
ionRect, bool isFirstPortion, bool isLastPortion) const; |
159 void repaintFlowThreadContentRectangle(const LayoutRect& repaintRect, const
LayoutRect& flowThreadPortionRect, | 101 void repaintFlowThreadContentRectangle(const LayoutRect& repaintRect, const
LayoutRect& flowThreadPortionRect, |
160 const LayoutRect& flowThreadPortionOverflowRect, const LayoutPoint& regi
onLocation) const; | 102 const LayoutRect& flowThreadPortionOverflowRect, const LayoutPoint& regi
onLocation) const; |
161 | 103 |
162 virtual bool shouldHaveAutoLogicalHeight() const; | |
163 | |
164 private: | 104 private: |
165 virtual void insertedIntoTree() OVERRIDE FINAL; | 105 virtual void insertedIntoTree() OVERRIDE FINAL; |
166 virtual void willBeRemovedFromTree() OVERRIDE FINAL; | 106 virtual void willBeRemovedFromTree() OVERRIDE FINAL; |
167 | 107 |
168 virtual void layoutBlock(bool relayoutChildren) OVERRIDE FINAL; | 108 virtual void layoutBlock(bool relayoutChildren) OVERRIDE FINAL; |
169 virtual bool supportsPartialLayout() const OVERRIDE FINAL { return false; } | 109 virtual bool supportsPartialLayout() const OVERRIDE FINAL { return false; } |
170 virtual void paintObject(PaintInfo&, const LayoutPoint&) OVERRIDE; | |
171 | |
172 virtual void updateLogicalHeight() OVERRIDE FINAL; | |
173 | |
174 virtual void installFlowThread(); | |
175 | |
176 PassRefPtr<RenderStyle> computeStyleInRegion(const RenderObject*); | |
177 void computeChildrenStyleInRegion(const RenderObject*); | |
178 void setObjectStyleInRegion(RenderObject*, PassRefPtr<RenderStyle>, bool obj
ectRegionStyleCached); | |
179 | |
180 void checkRegionStyle(); | |
181 void updateRegionHasAutoLogicalHeightFlag(); | |
182 | |
183 void incrementAutoLogicalHeightCount(); | |
184 void decrementAutoLogicalHeightCount(); | |
185 | |
186 Element* element() const; | |
187 | 110 |
188 protected: | 111 protected: |
189 RenderFlowThread* m_flowThread; | 112 RenderFlowThread* m_flowThread; |
190 | 113 |
191 private: | 114 private: |
192 // If this RenderRegion is displayed as part of another named flow, | |
193 // we need to create a dependency tree, so that layout of the | |
194 // regions is always done before the regions themselves. | |
195 RenderNamedFlowThread* m_parentNamedFlowThread; | |
196 LayoutRect m_flowThreadPortionRect; | 115 LayoutRect m_flowThreadPortionRect; |
197 | |
198 // This map holds unique information about a block that is split across regi
ons. | |
199 // A RenderBoxRegionInfo* tells us about any layout information for a Render
Box that | |
200 // is unique to the region. For now it just holds logical width information
for RenderBlocks, but eventually | |
201 // it will also hold a custom style for any box (for region styling). | |
202 typedef HashMap<const RenderBox*, OwnPtr<RenderBoxRegionInfo> > RenderBoxReg
ionInfoMap; | |
203 RenderBoxRegionInfoMap m_renderBoxRegionInfo; | |
204 | |
205 struct ObjectRegionStyleInfo { | |
206 // Used to store the original style of the object in region | |
207 // so that the original style is properly restored after paint. | |
208 // Also used to store computed style of the object in region between | |
209 // region paintings, so that the style in region is computed only | |
210 // when necessary. | |
211 RefPtr<RenderStyle> style; | |
212 // True if the computed style in region is cached. | |
213 bool cached; | |
214 }; | |
215 typedef HashMap<const RenderObject*, ObjectRegionStyleInfo > RenderObjectReg
ionStyleMap; | |
216 RenderObjectRegionStyleMap m_renderObjectRegionStyle; | |
217 | |
218 LayoutUnit m_computedAutoHeight; | |
219 | |
220 bool m_isValid : 1; | 116 bool m_isValid : 1; |
221 bool m_hasCustomRegionStyle : 1; | |
222 bool m_hasAutoLogicalHeight : 1; | |
223 }; | 117 }; |
224 | 118 |
225 DEFINE_RENDER_OBJECT_TYPE_CASTS(RenderRegion, isRenderRegion()); | 119 DEFINE_RENDER_OBJECT_TYPE_CASTS(RenderRegion, isRenderRegion()); |
226 | 120 |
227 } // namespace WebCore | 121 } // namespace WebCore |
228 | 122 |
229 #endif // RenderRegion_h | 123 #endif // RenderRegion_h |
OLD | NEW |