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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 virtual bool isRenderFlowThread() const OVERRIDE FINAL { return true; } | 60 virtual bool isRenderFlowThread() const OVERRIDE FINAL { return true; } |
61 | 61 |
62 virtual void layout() OVERRIDE FINAL; | 62 virtual void layout() OVERRIDE FINAL; |
63 | 63 |
64 // Always create a RenderLayer for the RenderFlowThread so that we | 64 // Always create a RenderLayer for the RenderFlowThread so that we |
65 // can easily avoid drawing the children directly. | 65 // can easily avoid drawing the children directly. |
66 virtual LayerType layerTypeRequired() const OVERRIDE FINAL { return NormalLa
yer; } | 66 virtual LayerType layerTypeRequired() const OVERRIDE FINAL { return NormalLa
yer; } |
67 | 67 |
68 virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, const HitTes
tLocation& locationInContainer, const LayoutPoint& accumulatedOffset, HitTestAct
ion) OVERRIDE FINAL; | 68 virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, const HitTes
tLocation& locationInContainer, const LayoutPoint& accumulatedOffset, HitTestAct
ion) OVERRIDE FINAL; |
69 | 69 |
70 void removeFlowChildInfo(RenderObject*); | |
71 #ifndef NDEBUG | |
72 bool hasChildInfo(RenderObject* child) const { return child && child->isBox(
) && m_regionRangeMap.contains(toRenderBox(child)); } | |
73 #endif | |
74 | |
75 virtual void addRegionToThread(RenderRegion*); | 70 virtual void addRegionToThread(RenderRegion*); |
76 virtual void removeRegionFromThread(RenderRegion*); | 71 virtual void removeRegionFromThread(RenderRegion*); |
77 const RenderRegionList& renderRegionList() const { return m_regionList; } | 72 const RenderRegionList& renderRegionList() const { return m_regionList; } |
78 | 73 |
79 virtual void updateLogicalWidth() OVERRIDE FINAL; | 74 virtual void updateLogicalWidth() OVERRIDE FINAL; |
80 virtual void computeLogicalHeight(LayoutUnit logicalHeight, LayoutUnit logic
alTop, LogicalExtentComputedValues&) const OVERRIDE; | 75 virtual void computeLogicalHeight(LayoutUnit logicalHeight, LayoutUnit logic
alTop, LogicalExtentComputedValues&) const OVERRIDE; |
81 | 76 |
82 void paintFlowThreadPortionInRegion(PaintInfo&, RenderRegion*, const LayoutR
ect& flowThreadPortionRect, const LayoutRect& flowThreadPortionOverflowRect, con
st LayoutPoint&) const; | |
83 bool hitTestFlowThreadPortionInRegion(RenderRegion*, const LayoutRect& flowT
hreadPortionRect, const LayoutRect& flowThreadPortionOverflowRect, const HitTest
Request&, HitTestResult&, const HitTestLocation& locationInContainer, const Layo
utPoint& accumulatedOffset) const; | |
84 | |
85 bool hasRegions() const { return m_regionList.size(); } | 77 bool hasRegions() const { return m_regionList.size(); } |
86 // Check if the content is flown into at least a region with region styling
rules. | |
87 bool hasRegionsWithStyling() const { return m_hasRegionsWithStyling; } | |
88 void checkRegionsWithStyling(); | |
89 virtual void regionChangedWritingMode(RenderRegion*) { } | |
90 | 78 |
91 void validateRegions(); | 79 void validateRegions(); |
92 void invalidateRegions(); | 80 void invalidateRegions(); |
93 bool hasValidRegionInfo() const { return !m_regionsInvalidated && !m_regionL
ist.isEmpty(); } | 81 bool hasValidRegionInfo() const { return !m_regionsInvalidated && !m_regionL
ist.isEmpty(); } |
94 | 82 |
95 static PassRefPtr<RenderStyle> createFlowThreadStyle(RenderStyle* parentStyl
e); | 83 static PassRefPtr<RenderStyle> createFlowThreadStyle(RenderStyle* parentStyl
e); |
96 | 84 |
97 virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle) OV
ERRIDE; | |
98 | |
99 void repaintRectangleInRegions(const LayoutRect&) const; | 85 void repaintRectangleInRegions(const LayoutRect&) const; |
100 | 86 |
101 LayoutPoint adjustedPositionRelativeToOffsetParent(const RenderBoxModelObjec
t&, const LayoutPoint&); | 87 LayoutPoint adjustedPositionRelativeToOffsetParent(const RenderBoxModelObjec
t&, const LayoutPoint&); |
102 | 88 |
103 LayoutUnit pageLogicalTopForOffset(LayoutUnit); | 89 LayoutUnit pageLogicalTopForOffset(LayoutUnit); |
104 LayoutUnit pageLogicalWidthForOffset(LayoutUnit); | 90 LayoutUnit pageLogicalWidthForOffset(LayoutUnit); |
105 LayoutUnit pageLogicalHeightForOffset(LayoutUnit); | 91 LayoutUnit pageLogicalHeightForOffset(LayoutUnit); |
106 LayoutUnit pageRemainingLogicalHeightForOffset(LayoutUnit, PageBoundaryRule
= IncludePageBoundary); | 92 LayoutUnit pageRemainingLogicalHeightForOffset(LayoutUnit, PageBoundaryRule
= IncludePageBoundary); |
107 | 93 |
108 virtual void setPageBreak(LayoutUnit /*offset*/, LayoutUnit /*spaceShortage*
/) { } | 94 virtual void setPageBreak(LayoutUnit /*offset*/, LayoutUnit /*spaceShortage*
/) { } |
109 virtual void updateMinimumPageHeight(LayoutUnit /*offset*/, LayoutUnit /*min
Height*/) { } | 95 virtual void updateMinimumPageHeight(LayoutUnit /*offset*/, LayoutUnit /*min
Height*/) { } |
110 | 96 |
111 enum RegionAutoGenerationPolicy { | 97 enum RegionAutoGenerationPolicy { |
112 AllowRegionAutoGeneration, | 98 AllowRegionAutoGeneration, |
113 DisallowRegionAutoGeneration, | 99 DisallowRegionAutoGeneration, |
114 }; | 100 }; |
115 RenderRegion* regionAtBlockOffset(LayoutUnit, bool extendLastRegion = false,
RegionAutoGenerationPolicy = AllowRegionAutoGeneration); | 101 RenderRegion* regionAtBlockOffset(LayoutUnit, bool extendLastRegion = false,
RegionAutoGenerationPolicy = AllowRegionAutoGeneration); |
116 | 102 |
117 RenderRegion* regionFromAbsolutePointAndBox(IntPoint, const RenderBox* flowe
dBox); | 103 RenderRegion* regionFromAbsolutePointAndBox(IntPoint, const RenderBox* flowe
dBox); |
118 | 104 |
119 bool regionsHaveUniformLogicalWidth() const { return m_regionsHaveUniformLog
icalWidth; } | |
120 bool regionsHaveUniformLogicalHeight() const { return m_regionsHaveUniformLo
gicalHeight; } | 105 bool regionsHaveUniformLogicalHeight() const { return m_regionsHaveUniformLo
gicalHeight; } |
121 | 106 |
122 RenderRegion* mapFromFlowToRegion(TransformState&) const; | 107 RenderRegion* mapFromFlowToRegion(TransformState&) const; |
123 | 108 |
124 void removeRenderBoxRegionInfo(RenderBox*); | |
125 bool logicalWidthChangedInRegionsForBlock(const RenderBlock*); | |
126 | |
127 LayoutUnit contentLogicalWidthOfFirstRegion() const; | |
128 LayoutUnit contentLogicalHeightOfFirstRegion() const; | |
129 LayoutUnit contentLogicalLeftOfFirstRegion() const; | |
130 | |
131 RenderRegion* firstRegion() const; | 109 RenderRegion* firstRegion() const; |
132 RenderRegion* lastRegion() const; | 110 RenderRegion* lastRegion() const; |
133 | 111 |
134 bool previousRegionCountChanged() const { return m_previousRegionCount != m_
regionList.size(); } | 112 bool previousRegionCountChanged() const { return m_previousRegionCount != m_
regionList.size(); } |
135 void updatePreviousRegionCount() { m_previousRegionCount = m_regionList.size
(); } | 113 void updatePreviousRegionCount() { m_previousRegionCount = m_regionList.size
(); } |
136 | 114 |
137 void setRegionRangeForBox(const RenderBox*, LayoutUnit offsetFromLogicalTopO
fFirstPage); | 115 void setRegionRangeForBox(const RenderBox*, LayoutUnit offsetFromLogicalTopO
fFirstPage); |
138 void getRegionRangeForBox(const RenderBox*, RenderRegion*& startRegion, Rend
erRegion*& endRegion) const; | 116 void getRegionRangeForBox(const RenderBox*, RenderRegion*& startRegion, Rend
erRegion*& endRegion) const; |
139 | 117 |
140 void clearRenderObjectCustomStyle(const RenderObject*, | 118 virtual bool addForcedRegionBreak(LayoutUnit, RenderObject* breakChild, bool
isBefore, LayoutUnit* offsetBreakAdjustment = 0) { return false; } // FIXME: mu
lticol needs to implement this. |
141 const RenderRegion* oldStartRegion = 0, const RenderRegion* oldEndRegion
= 0, | |
142 const RenderRegion* newStartRegion = 0, const RenderRegion* newEndRegion
= 0); | |
143 | |
144 // Check if the object is in region and the region is part of this flow thre
ad. | |
145 bool objectInFlowRegion(const RenderObject*, const RenderRegion*) const; | |
146 | |
147 void markAutoLogicalHeightRegionsForLayout(); | |
148 | |
149 bool addForcedRegionBreak(LayoutUnit, RenderObject* breakChild, bool isBefor
e, LayoutUnit* offsetBreakAdjustment = 0); | |
150 void applyBreakAfterContent(LayoutUnit); | 119 void applyBreakAfterContent(LayoutUnit); |
151 | 120 |
152 bool pageLogicalSizeChanged() const { return m_pageLogicalSizeChanged; } | 121 bool pageLogicalSizeChanged() const { return m_pageLogicalSizeChanged; } |
153 | 122 |
154 bool hasAutoLogicalHeightRegions() const { ASSERT(isAutoLogicalHeightRegions
CountConsistent()); return m_autoLogicalHeightRegionsCount; } | |
155 void incrementAutoLogicalHeightRegions(); | |
156 void decrementAutoLogicalHeightRegions(); | |
157 | |
158 #ifndef NDEBUG | |
159 bool isAutoLogicalHeightRegionsCountConsistent() const; | |
160 #endif | |
161 | |
162 void collectLayerFragments(LayerFragments&, const LayoutRect& layerBoundingB
ox, const LayoutRect& dirtyRect); | 123 void collectLayerFragments(LayerFragments&, const LayoutRect& layerBoundingB
ox, const LayoutRect& dirtyRect); |
163 LayoutRect fragmentsBoundingBox(const LayoutRect& layerBoundingBox); | 124 LayoutRect fragmentsBoundingBox(const LayoutRect& layerBoundingBox); |
164 | 125 |
165 void setInConstrainedLayoutPhase(bool value) { m_inConstrainedLayoutPhase =
value; } | |
166 bool inConstrainedLayoutPhase() const { return m_inConstrainedLayoutPhase; } | |
167 | |
168 bool needsTwoPhasesLayout() const { return m_needsTwoPhasesLayout; } | |
169 void clearNeedsTwoPhasesLayout() { m_needsTwoPhasesLayout = false; } | |
170 | |
171 void pushFlowThreadLayoutState(const RenderObject*); | 126 void pushFlowThreadLayoutState(const RenderObject*); |
172 void popFlowThreadLayoutState(); | 127 void popFlowThreadLayoutState(); |
173 LayoutUnit offsetFromLogicalTopOfFirstRegion(const RenderBlock*) const; | 128 LayoutUnit offsetFromLogicalTopOfFirstRegion(const RenderBlock*) const; |
174 | 129 |
175 // Used to estimate the maximum height of the flow thread. | 130 // Used to estimate the maximum height of the flow thread. |
176 static LayoutUnit maxLogicalHeight() { return LayoutUnit::max() / 2; } | 131 static LayoutUnit maxLogicalHeight() { return LayoutUnit::max() / 2; } |
177 | 132 |
178 protected: | 133 protected: |
179 virtual const char* renderName() const = 0; | 134 virtual const char* renderName() const = 0; |
180 | 135 |
181 // Overridden by columns/pages to set up an initial logical width of the pag
e width even when | 136 // Overridden by columns/pages to set up an initial logical width of the pag
e width even when |
182 // no regions have been generated yet. | 137 // no regions have been generated yet. |
183 virtual LayoutUnit initialLogicalWidth() const { return 0; }; | 138 virtual LayoutUnit initialLogicalWidth() const { return 0; }; |
184 | 139 |
185 virtual void mapLocalToContainer(const RenderLayerModelObject* repaintContai
ner, TransformState&, MapCoordinatesFlags = ApplyContainerFlip, bool* wasFixed =
0) const OVERRIDE FINAL; | 140 virtual void mapLocalToContainer(const RenderLayerModelObject* repaintContai
ner, TransformState&, MapCoordinatesFlags = ApplyContainerFlip, bool* wasFixed =
0) const OVERRIDE FINAL; |
186 | 141 |
187 void updateRegionsFlowThreadPortionRect(const RenderRegion* = 0); | 142 void updateRegionsFlowThreadPortionRect(); |
188 bool shouldRepaint(const LayoutRect&) const; | 143 bool shouldRepaint(const LayoutRect&) const; |
189 bool regionInRange(const RenderRegion* targetRegion, const RenderRegion* sta
rtRegion, const RenderRegion* endRegion) const; | 144 bool regionInRange(const RenderRegion* targetRegion, const RenderRegion* sta
rtRegion, const RenderRegion* endRegion) const; |
190 | 145 |
191 LayoutRect computeRegionClippingRect(const LayoutPoint&, const LayoutRect&,
const LayoutRect&) const; | 146 LayoutRect computeRegionClippingRect(const LayoutPoint&, const LayoutRect&,
const LayoutRect&) const; |
192 | 147 |
193 void setDispatchRegionLayoutUpdateEvent(bool value) { m_dispatchRegionLayout
UpdateEvent = value; } | |
194 bool shouldDispatchRegionLayoutUpdateEvent() { return m_dispatchRegionLayout
UpdateEvent; } | |
195 | |
196 void setDispatchRegionOversetChangeEvent(bool value) { m_dispatchRegionOvers
etChangeEvent = value; } | |
197 bool shouldDispatchRegionOversetChangeEvent() const { return m_dispatchRegio
nOversetChangeEvent; } | |
198 | |
199 // Override if the flow thread implementation supports dispatching events wh
en the flow layout is updated (e.g. for named flows) | |
200 virtual void dispatchRegionLayoutUpdateEvent() { m_dispatchRegionLayoutUpdat
eEvent = false; } | |
201 virtual void dispatchRegionOversetChangeEvent() { m_dispatchRegionOversetCha
ngeEvent = false; } | |
202 | |
203 void initializeRegionsComputedAutoHeight(RenderRegion* = 0); | |
204 | |
205 virtual void autoGenerateRegionsToBlockOffset(LayoutUnit) { }; | 148 virtual void autoGenerateRegionsToBlockOffset(LayoutUnit) { }; |
206 | 149 |
207 bool cachedOffsetFromLogicalTopOfFirstRegion(const RenderBox*, LayoutUnit&)
const; | 150 bool cachedOffsetFromLogicalTopOfFirstRegion(const RenderBox*, LayoutUnit&)
const; |
208 void setOffsetFromLogicalTopOfFirstRegion(const RenderBox*, LayoutUnit); | 151 void setOffsetFromLogicalTopOfFirstRegion(const RenderBox*, LayoutUnit); |
209 void clearOffsetFromLogicalTopOfFirstRegion(const RenderBox*); | 152 void clearOffsetFromLogicalTopOfFirstRegion(const RenderBox*); |
210 | 153 |
211 const RenderBox* currentStatePusherRenderBox() const; | 154 const RenderBox* currentStatePusherRenderBox() const; |
212 | 155 |
213 RenderRegionList m_regionList; | 156 RenderRegionList m_regionList; |
214 unsigned short m_previousRegionCount; | 157 unsigned short m_previousRegionCount; |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 | 201 |
259 private: | 202 private: |
260 LayoutUnit m_offset; | 203 LayoutUnit m_offset; |
261 RenderRegion* m_result; | 204 RenderRegion* m_result; |
262 }; | 205 }; |
263 | 206 |
264 // A maps from RenderBox | 207 // A maps from RenderBox |
265 typedef HashMap<const RenderBox*, RenderRegionRange> RenderRegionRangeMap; | 208 typedef HashMap<const RenderBox*, RenderRegionRange> RenderRegionRangeMap; |
266 RenderRegionRangeMap m_regionRangeMap; | 209 RenderRegionRangeMap m_regionRangeMap; |
267 | 210 |
268 typedef HashMap<RenderObject*, RenderRegion*> RenderObjectToRegionMap; | |
269 RenderObjectToRegionMap m_breakBeforeToRegionMap; | |
270 RenderObjectToRegionMap m_breakAfterToRegionMap; | |
271 | |
272 // Stack of objects that pushed a LayoutState object on the RenderView. The | 211 // Stack of objects that pushed a LayoutState object on the RenderView. The |
273 // objects on the stack are the ones that are curently in the process of bei
ng | 212 // objects on the stack are the ones that are curently in the process of bei
ng |
274 // laid out. | 213 // laid out. |
275 ListHashSet<const RenderObject*> m_statePusherObjectsStack; | 214 ListHashSet<const RenderObject*> m_statePusherObjectsStack; |
276 typedef HashMap<const RenderBox*, LayoutUnit> RenderBoxToOffsetMap; | 215 typedef HashMap<const RenderBox*, LayoutUnit> RenderBoxToOffsetMap; |
277 RenderBoxToOffsetMap m_boxesToOffsetMap; | 216 RenderBoxToOffsetMap m_boxesToOffsetMap; |
278 | 217 |
279 unsigned m_autoLogicalHeightRegionsCount; | |
280 | |
281 RegionIntervalTree m_regionIntervalTree; | 218 RegionIntervalTree m_regionIntervalTree; |
282 | 219 |
283 bool m_regionsInvalidated : 1; | 220 bool m_regionsInvalidated : 1; |
284 bool m_regionsHaveUniformLogicalWidth : 1; | |
285 bool m_regionsHaveUniformLogicalHeight : 1; | 221 bool m_regionsHaveUniformLogicalHeight : 1; |
286 bool m_hasRegionsWithStyling : 1; | |
287 bool m_dispatchRegionLayoutUpdateEvent : 1; | |
288 bool m_dispatchRegionOversetChangeEvent : 1; | |
289 bool m_pageLogicalSizeChanged : 1; | 222 bool m_pageLogicalSizeChanged : 1; |
290 bool m_inConstrainedLayoutPhase : 1; | |
291 bool m_needsTwoPhasesLayout : 1; | |
292 | 223 |
293 private: | 224 private: |
294 virtual bool supportsPartialLayout() const OVERRIDE FINAL { return false; } | 225 virtual bool supportsPartialLayout() const OVERRIDE FINAL { return false; } |
295 | 226 |
296 }; | 227 }; |
297 | 228 |
298 DEFINE_RENDER_OBJECT_TYPE_CASTS(RenderFlowThread, isRenderFlowThread()); | 229 DEFINE_RENDER_OBJECT_TYPE_CASTS(RenderFlowThread, isRenderFlowThread()); |
299 | 230 |
300 class CurrentRenderFlowThreadMaintainer { | 231 class CurrentRenderFlowThreadMaintainer { |
301 WTF_MAKE_NONCOPYABLE(CurrentRenderFlowThreadMaintainer); | 232 WTF_MAKE_NONCOPYABLE(CurrentRenderFlowThreadMaintainer); |
(...skipping 12 matching lines...) Expand all Loading... |
314 }; | 245 }; |
315 | 246 |
316 template <> struct ValueToString<RenderRegion*> { | 247 template <> struct ValueToString<RenderRegion*> { |
317 static String string(const RenderRegion* value) { return String::format("%p"
, value); } | 248 static String string(const RenderRegion* value) { return String::format("%p"
, value); } |
318 }; | 249 }; |
319 #endif | 250 #endif |
320 | 251 |
321 } // namespace WebCore | 252 } // namespace WebCore |
322 | 253 |
323 #endif // RenderFlowThread_h | 254 #endif // RenderFlowThread_h |
OLD | NEW |