Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(807)

Side by Side Diff: Source/core/rendering/RenderBlockFlow.h

Issue 179993006: [New multicol] Eliminate the need for RenderMultiColumnBlock. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Code review Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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-2013 Apple Inc. All rights reserved. 5 * Copyright (C) 2003-2013 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 * Copyright (C) 2013 Google Inc. All rights reserved. 7 * Copyright (C) 2013 Google Inc. All rights reserved.
8 * 8 *
9 * Redistribution and use in source and binary forms, with or without 9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions are 10 * modification, are permitted provided that the following conditions are
(...skipping 28 matching lines...) Expand all
39 #include "core/rendering/FloatingObjects.h" 39 #include "core/rendering/FloatingObjects.h"
40 #include "core/rendering/RenderBlock.h" 40 #include "core/rendering/RenderBlock.h"
41 #include "core/rendering/line/TrailingObjects.h" 41 #include "core/rendering/line/TrailingObjects.h"
42 #include "core/rendering/style/RenderStyleConstants.h" 42 #include "core/rendering/style/RenderStyleConstants.h"
43 43
44 namespace WebCore { 44 namespace WebCore {
45 45
46 class MarginInfo; 46 class MarginInfo;
47 class LineBreaker; 47 class LineBreaker;
48 class LineWidth; 48 class LineWidth;
49 class RenderMultiColumnFlowThread;
49 50
50 class RenderBlockFlow : public RenderBlock { 51 class RenderBlockFlow : public RenderBlock {
51 public: 52 public:
52 explicit RenderBlockFlow(ContainerNode*); 53 explicit RenderBlockFlow(ContainerNode*);
53 virtual ~RenderBlockFlow(); 54 virtual ~RenderBlockFlow();
54 55
55 static RenderBlockFlow* createAnonymous(Document*); 56 static RenderBlockFlow* createAnonymous(Document*);
56 RenderBlockFlow* createAnonymousBlockFlow() const; 57 RenderBlockFlow* createAnonymousBlockFlow() const;
57 58
58 virtual bool isRenderBlockFlow() const OVERRIDE FINAL { return true; } 59 virtual bool isRenderBlockFlow() const OVERRIDE FINAL { return true; }
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 RootInlineBox* createAndAppendRootInlineBox(); 106 RootInlineBox* createAndAppendRootInlineBox();
106 107
107 void markAllDescendantsWithFloatsForLayout(RenderBox* floatToRemove = 0, boo l inLayout = true); 108 void markAllDescendantsWithFloatsForLayout(RenderBox* floatToRemove = 0, boo l inLayout = true);
108 void markSiblingsWithFloatsForLayout(RenderBox* floatToRemove = 0); 109 void markSiblingsWithFloatsForLayout(RenderBox* floatToRemove = 0);
109 110
110 virtual bool containsFloats() const OVERRIDE FINAL { return m_floatingObject s && !m_floatingObjects->set().isEmpty(); } 111 virtual bool containsFloats() const OVERRIDE FINAL { return m_floatingObject s && !m_floatingObjects->set().isEmpty(); }
111 bool containsFloat(RenderBox*) const; 112 bool containsFloat(RenderBox*) const;
112 113
113 void removeFloatingObjects(); 114 void removeFloatingObjects();
114 115
116 virtual void addChild(RenderObject* newChild, RenderObject* beforeChild = 0) OVERRIDE;
117
115 void moveAllChildrenIncludingFloatsTo(RenderBlock* toBlock, bool fullRemoveI nsert); 118 void moveAllChildrenIncludingFloatsTo(RenderBlock* toBlock, bool fullRemoveI nsert);
116 119
117 bool generatesLineBoxesForInlineChild(RenderObject*); 120 bool generatesLineBoxesForInlineChild(RenderObject*);
118 121
119 LayoutUnit logicalTopForFloat(const FloatingObject* floatingObject) const { return isHorizontalWritingMode() ? floatingObject->y() : floatingObject->x(); } 122 LayoutUnit logicalTopForFloat(const FloatingObject* floatingObject) const { return isHorizontalWritingMode() ? floatingObject->y() : floatingObject->x(); }
120 LayoutUnit logicalBottomForFloat(const FloatingObject* floatingObject) const { return isHorizontalWritingMode() ? floatingObject->maxY() : floatingObject->m axX(); } 123 LayoutUnit logicalBottomForFloat(const FloatingObject* floatingObject) const { return isHorizontalWritingMode() ? floatingObject->maxY() : floatingObject->m axX(); }
121 LayoutUnit logicalLeftForFloat(const FloatingObject* floatingObject) const { return isHorizontalWritingMode() ? floatingObject->x() : floatingObject->y(); } 124 LayoutUnit logicalLeftForFloat(const FloatingObject* floatingObject) const { return isHorizontalWritingMode() ? floatingObject->x() : floatingObject->y(); }
122 LayoutUnit logicalRightForFloat(const FloatingObject* floatingObject) const { return isHorizontalWritingMode() ? floatingObject->maxX() : floatingObject->ma xY(); } 125 LayoutUnit logicalRightForFloat(const FloatingObject* floatingObject) const { return isHorizontalWritingMode() ? floatingObject->maxX() : floatingObject->ma xY(); }
123 LayoutUnit logicalWidthForFloat(const FloatingObject* floatingObject) const { return isHorizontalWritingMode() ? floatingObject->width() : floatingObject->h eight(); } 126 LayoutUnit logicalWidthForFloat(const FloatingObject* floatingObject) const { return isHorizontalWritingMode() ? floatingObject->width() : floatingObject->h eight(); }
124 LayoutUnit logicalHeightForFloat(const FloatingObject* floatingObject) const { return isHorizontalWritingMode() ? floatingObject->height() : floatingObject- >width(); } 127 LayoutUnit logicalHeightForFloat(const FloatingObject* floatingObject) const { return isHorizontalWritingMode() ? floatingObject->height() : floatingObject- >width(); }
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 187
185 static TextRun constructTextRun(RenderObject* context, const Font&, const Re nderText*, unsigned offset, RenderStyle*, 188 static TextRun constructTextRun(RenderObject* context, const Font&, const Re nderText*, unsigned offset, RenderStyle*,
186 TextRun::ExpansionBehavior = TextRun::AllowTrailingExpansion | TextRun:: ForbidLeadingExpansion); 189 TextRun::ExpansionBehavior = TextRun::AllowTrailingExpansion | TextRun:: ForbidLeadingExpansion);
187 190
188 static TextRun constructTextRun(RenderObject* context, const Font&, const LC har* characters, int length, RenderStyle*, TextDirection, 191 static TextRun constructTextRun(RenderObject* context, const Font&, const LC har* characters, int length, RenderStyle*, TextDirection,
189 TextRun::ExpansionBehavior = TextRun::AllowTrailingExpansion | TextRun:: ForbidLeadingExpansion); 192 TextRun::ExpansionBehavior = TextRun::AllowTrailingExpansion | TextRun:: ForbidLeadingExpansion);
190 193
191 static TextRun constructTextRun(RenderObject* context, const Font&, const UC har* characters, int length, RenderStyle*, TextDirection, 194 static TextRun constructTextRun(RenderObject* context, const Font&, const UC har* characters, int length, RenderStyle*, TextDirection,
192 TextRun::ExpansionBehavior = TextRun::AllowTrailingExpansion | TextRun:: ForbidLeadingExpansion); 195 TextRun::ExpansionBehavior = TextRun::AllowTrailingExpansion | TextRun:: ForbidLeadingExpansion);
193 196
197 RenderMultiColumnFlowThread* multiColumnFlowThread() const { return m_rareDa ta ? m_rareData->m_multiColumnFlowThread : 0; }
198
194 void addOverflowFromInlineChildren(); 199 void addOverflowFromInlineChildren();
195 200
196 GapRects inlineSelectionGaps(RenderBlock* rootBlock, const LayoutPoint& root BlockPhysicalPosition, const LayoutSize& offsetFromRootBlock, 201 GapRects inlineSelectionGaps(RenderBlock* rootBlock, const LayoutPoint& root BlockPhysicalPosition, const LayoutSize& offsetFromRootBlock,
197 LayoutUnit& lastLogicalTop, LayoutUnit& lastLogicalLeft, LayoutUnit& las tLogicalRight, const PaintInfo*); 202 LayoutUnit& lastLogicalTop, LayoutUnit& lastLogicalLeft, LayoutUnit& las tLogicalRight, const PaintInfo*);
198 protected: 203 protected:
199 void rebuildFloatsFromIntruding(); 204 void rebuildFloatsFromIntruding();
200 void layoutInlineChildren(bool relayoutChildren, LayoutUnit& repaintLogicalT op, LayoutUnit& repaintLogicalBottom, LayoutUnit afterEdge); 205 void layoutInlineChildren(bool relayoutChildren, LayoutUnit& repaintLogicalT op, LayoutUnit& repaintLogicalBottom, LayoutUnit afterEdge);
201 206
202 void createFloatingObjects(); 207 void createFloatingObjects();
203 208
204 virtual void styleWillChange(StyleDifference, const RenderStyle* newStyle) O VERRIDE; 209 virtual void styleWillChange(StyleDifference, const RenderStyle* newStyle) O VERRIDE;
205 virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle) OV ERRIDE; 210 virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle) OV ERRIDE;
206 211
207 void addOverflowFromFloats(); 212 void addOverflowFromFloats();
208 213
209 LayoutUnit logicalRightOffsetForLine(LayoutUnit logicalTop, LayoutUnit fixed Offset, bool applyTextIndent, LayoutUnit logicalHeight = 0) const 214 LayoutUnit logicalRightOffsetForLine(LayoutUnit logicalTop, LayoutUnit fixed Offset, bool applyTextIndent, LayoutUnit logicalHeight = 0) const
210 { 215 {
211 return adjustLogicalRightOffsetForLine(logicalRightFloatOffsetForLine(lo gicalTop, fixedOffset, logicalHeight), applyTextIndent); 216 return adjustLogicalRightOffsetForLine(logicalRightFloatOffsetForLine(lo gicalTop, fixedOffset, logicalHeight), applyTextIndent);
212 } 217 }
213 LayoutUnit logicalLeftOffsetForLine(LayoutUnit logicalTop, LayoutUnit fixedO ffset, bool applyTextIndent, LayoutUnit logicalHeight = 0) const 218 LayoutUnit logicalLeftOffsetForLine(LayoutUnit logicalTop, LayoutUnit fixedO ffset, bool applyTextIndent, LayoutUnit logicalHeight = 0) const
214 { 219 {
215 return adjustLogicalLeftOffsetForLine(logicalLeftFloatOffsetForLine(logi calTop, fixedOffset, logicalHeight), applyTextIndent); 220 return adjustLogicalLeftOffsetForLine(logicalLeftFloatOffsetForLine(logi calTop, fixedOffset, logicalHeight), applyTextIndent);
216 } 221 }
217 222
223 virtual RenderObject* layoutSpecialExcludedChild(bool /*relayoutChildren*/, SubtreeLayoutScope&);
224 virtual bool updateLogicalWidthAndColumnWidth() OVERRIDE;
225
218 private: 226 private:
219 bool layoutBlockFlow(bool relayoutChildren, LayoutUnit& pageLogicalHeight, S ubtreeLayoutScope&); 227 bool layoutBlockFlow(bool relayoutChildren, LayoutUnit& pageLogicalHeight, S ubtreeLayoutScope&);
220 void layoutBlockChildren(bool relayoutChildren, LayoutUnit& maxFloatLogicalB ottom, SubtreeLayoutScope&, LayoutUnit beforeEdge, LayoutUnit afterEdge); 228 void layoutBlockChildren(bool relayoutChildren, LayoutUnit& maxFloatLogicalB ottom, SubtreeLayoutScope&, LayoutUnit beforeEdge, LayoutUnit afterEdge);
221 229
222 void layoutBlockChild(RenderBox* child, MarginInfo&, LayoutUnit& previousFlo atLogicalBottom, LayoutUnit& maxFloatLogicalBottom); 230 void layoutBlockChild(RenderBox* child, MarginInfo&, LayoutUnit& previousFlo atLogicalBottom, LayoutUnit& maxFloatLogicalBottom);
223 void adjustPositionedBlock(RenderBox* child, const MarginInfo&); 231 void adjustPositionedBlock(RenderBox* child, const MarginInfo&);
224 void adjustFloatingBlock(const MarginInfo&); 232 void adjustFloatingBlock(const MarginInfo&);
225 233
226 LayoutPoint flipFloatForWritingModeForChild(const FloatingObject*, const Lay outPoint&) const; 234 LayoutPoint flipFloatForWritingModeForChild(const FloatingObject*, const Lay outPoint&) const;
227 235
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 LayoutUnit logicalRightOffsetForPositioningFloat(LayoutUnit logicalTop, Layo utUnit fixedOffset, bool applyTextIndent, LayoutUnit* heightRemaining) const; 283 LayoutUnit logicalRightOffsetForPositioningFloat(LayoutUnit logicalTop, Layo utUnit fixedOffset, bool applyTextIndent, LayoutUnit* heightRemaining) const;
276 LayoutUnit logicalLeftOffsetForPositioningFloat(LayoutUnit logicalTop, Layou tUnit fixedOffset, bool applyTextIndent, LayoutUnit* heightRemaining) const; 284 LayoutUnit logicalLeftOffsetForPositioningFloat(LayoutUnit logicalTop, Layou tUnit fixedOffset, bool applyTextIndent, LayoutUnit* heightRemaining) const;
277 285
278 LayoutUnit adjustLogicalRightOffsetForLine(LayoutUnit offsetFromFloats, bool applyTextIndent) const; 286 LayoutUnit adjustLogicalRightOffsetForLine(LayoutUnit offsetFromFloats, bool applyTextIndent) const;
279 LayoutUnit adjustLogicalLeftOffsetForLine(LayoutUnit offsetFromFloats, bool applyTextIndent) const; 287 LayoutUnit adjustLogicalLeftOffsetForLine(LayoutUnit offsetFromFloats, bool applyTextIndent) const;
280 288
281 virtual void adjustForBorderFit(LayoutUnit x, LayoutUnit& left, LayoutUnit& right) const OVERRIDE; // Helper function for borderFitAdjust 289 virtual void adjustForBorderFit(LayoutUnit x, LayoutUnit& left, LayoutUnit& right) const OVERRIDE; // Helper function for borderFitAdjust
282 290
283 virtual RootInlineBox* createRootInlineBox(); // Subclassed by SVG 291 virtual RootInlineBox* createRootInlineBox(); // Subclassed by SVG
284 292
293 void createMultiColumnFlowThreadIfNeeded();
294
285 void updateLogicalWidthForAlignment(const ETextAlign&, const RootInlineBox*, BidiRun* trailingSpaceRun, float& logicalLeft, float& totalLogicalWidth, float& availableLogicalWidth, int expansionOpportunityCount); 295 void updateLogicalWidthForAlignment(const ETextAlign&, const RootInlineBox*, BidiRun* trailingSpaceRun, float& logicalLeft, float& totalLogicalWidth, float& availableLogicalWidth, int expansionOpportunityCount);
286 virtual void checkForPaginationLogicalHeightChange(LayoutUnit& pageLogicalHe ight, bool& pageLogicalHeightChanged, bool& hasSpecifiedPageLogicalHeight); 296 void checkForPaginationLogicalHeightChange(LayoutUnit& pageLogicalHeight, bo ol& pageLogicalHeightChanged, bool& hasSpecifiedPageLogicalHeight);
287 bool shouldRelayoutForPagination(LayoutUnit& pageLogicalHeight, LayoutUnit l ayoutOverflowLogicalBottom) const; 297 bool shouldRelayoutForPagination(LayoutUnit& pageLogicalHeight, LayoutUnit l ayoutOverflowLogicalBottom) const;
288 void setColumnCountAndHeight(unsigned count, LayoutUnit pageLogicalHeight); 298 void setColumnCountAndHeight(unsigned count, LayoutUnit pageLogicalHeight);
289 299
290 public: 300 public:
291 struct FloatWithRect { 301 struct FloatWithRect {
292 FloatWithRect(RenderBox* f) 302 FloatWithRect(RenderBox* f)
293 : object(f) 303 : object(f)
294 , rect(LayoutRect(f->x() - f->marginLeft(), f->y() - f->marginTop(), f->width() + f->marginWidth(), f->height() + f->marginHeight())) 304 , rect(LayoutRect(f->x() - f->marginLeft(), f->y() - f->marginTop(), f->width() + f->marginWidth(), f->height() + f->marginHeight()))
295 , everHadLayout(f->everHadLayout()) 305 , everHadLayout(f->everHadLayout())
296 { 306 {
(...skipping 30 matching lines...) Expand all
327 LayoutUnit m_negativeMarginAfter; 337 LayoutUnit m_negativeMarginAfter;
328 }; 338 };
329 MarginValues marginValuesForChild(RenderBox* child) const; 339 MarginValues marginValuesForChild(RenderBox* child) const;
330 340
331 // Allocated only when some of these fields have non-default values 341 // Allocated only when some of these fields have non-default values
332 struct RenderBlockFlowRareData { 342 struct RenderBlockFlowRareData {
333 WTF_MAKE_NONCOPYABLE(RenderBlockFlowRareData); WTF_MAKE_FAST_ALLOCATED; 343 WTF_MAKE_NONCOPYABLE(RenderBlockFlowRareData); WTF_MAKE_FAST_ALLOCATED;
334 public: 344 public:
335 RenderBlockFlowRareData(const RenderBlockFlow* block) 345 RenderBlockFlowRareData(const RenderBlockFlow* block)
336 : m_margins(positiveMarginBeforeDefault(block), negativeMarginBefore Default(block), positiveMarginAfterDefault(block), negativeMarginAfterDefault(bl ock)) 346 : m_margins(positiveMarginBeforeDefault(block), negativeMarginBefore Default(block), positiveMarginAfterDefault(block), negativeMarginAfterDefault(bl ock))
347 , m_multiColumnFlowThread(0)
337 , m_discardMarginBefore(false) 348 , m_discardMarginBefore(false)
338 , m_discardMarginAfter(false) 349 , m_discardMarginAfter(false)
339 { 350 {
340 } 351 }
341 352
342 static LayoutUnit positiveMarginBeforeDefault(const RenderBlockFlow* blo ck) 353 static LayoutUnit positiveMarginBeforeDefault(const RenderBlockFlow* blo ck)
343 { 354 {
344 return std::max<LayoutUnit>(block->marginBefore(), 0); 355 return std::max<LayoutUnit>(block->marginBefore(), 0);
345 } 356 }
346 static LayoutUnit negativeMarginBeforeDefault(const RenderBlockFlow* blo ck) 357 static LayoutUnit negativeMarginBeforeDefault(const RenderBlockFlow* blo ck)
347 { 358 {
348 return std::max<LayoutUnit>(-block->marginBefore(), 0); 359 return std::max<LayoutUnit>(-block->marginBefore(), 0);
349 } 360 }
350 static LayoutUnit positiveMarginAfterDefault(const RenderBlockFlow* bloc k) 361 static LayoutUnit positiveMarginAfterDefault(const RenderBlockFlow* bloc k)
351 { 362 {
352 return std::max<LayoutUnit>(block->marginAfter(), 0); 363 return std::max<LayoutUnit>(block->marginAfter(), 0);
353 } 364 }
354 static LayoutUnit negativeMarginAfterDefault(const RenderBlockFlow* bloc k) 365 static LayoutUnit negativeMarginAfterDefault(const RenderBlockFlow* bloc k)
355 { 366 {
356 return std::max<LayoutUnit>(-block->marginAfter(), 0); 367 return std::max<LayoutUnit>(-block->marginAfter(), 0);
357 } 368 }
358 369
359 MarginValues m_margins; 370 MarginValues m_margins;
360 371
372 RenderMultiColumnFlowThread* m_multiColumnFlowThread;
373
361 bool m_discardMarginBefore : 1; 374 bool m_discardMarginBefore : 1;
362 bool m_discardMarginAfter : 1; 375 bool m_discardMarginAfter : 1;
363 }; 376 };
364 LayoutUnit marginOffsetForSelfCollapsingBlock(); 377 LayoutUnit marginOffsetForSelfCollapsingBlock();
365 378
366 protected: 379 protected:
367 LayoutUnit maxPositiveMarginBefore() const { return m_rareData ? m_rareData- >m_margins.positiveMarginBefore() : RenderBlockFlowRareData::positiveMarginBefor eDefault(this); } 380 LayoutUnit maxPositiveMarginBefore() const { return m_rareData ? m_rareData- >m_margins.positiveMarginBefore() : RenderBlockFlowRareData::positiveMarginBefor eDefault(this); }
368 LayoutUnit maxNegativeMarginBefore() const { return m_rareData ? m_rareData- >m_margins.negativeMarginBefore() : RenderBlockFlowRareData::negativeMarginBefor eDefault(this); } 381 LayoutUnit maxNegativeMarginBefore() const { return m_rareData ? m_rareData- >m_margins.negativeMarginBefore() : RenderBlockFlowRareData::negativeMarginBefor eDefault(this); }
369 LayoutUnit maxPositiveMarginAfter() const { return m_rareData ? m_rareData-> m_margins.positiveMarginAfter() : RenderBlockFlowRareData::positiveMarginAfterDe fault(this); } 382 LayoutUnit maxPositiveMarginAfter() const { return m_rareData ? m_rareData-> m_margins.positiveMarginAfter() : RenderBlockFlowRareData::positiveMarginAfterDe fault(this); }
370 LayoutUnit maxNegativeMarginAfter() const { return m_rareData ? m_rareData-> m_margins.negativeMarginAfter() : RenderBlockFlowRareData::negativeMarginAfterDe fault(this); } 383 LayoutUnit maxNegativeMarginAfter() const { return m_rareData ? m_rareData-> m_margins.negativeMarginAfter() : RenderBlockFlowRareData::negativeMarginAfterDe fault(this); }
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
468 481
469 // END METHODS DEFINED IN RenderBlockLineLayout 482 // END METHODS DEFINED IN RenderBlockLineLayout
470 483
471 }; 484 };
472 485
473 DEFINE_RENDER_OBJECT_TYPE_CASTS(RenderBlockFlow, isRenderBlockFlow()); 486 DEFINE_RENDER_OBJECT_TYPE_CASTS(RenderBlockFlow, isRenderBlockFlow());
474 487
475 } // namespace WebCore 488 } // namespace WebCore
476 489
477 #endif // RenderBlockFlow_h 490 #endif // RenderBlockFlow_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698