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

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

Issue 752723004: Use references in RenderBlock and RenderBlockFlow methods (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: cover RenderBlockFlow class as well Created 6 years 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
« no previous file with comments | « Source/core/rendering/RenderBlock.cpp ('k') | Source/core/rendering/RenderBlockFlow.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 void setLogicalWidthForFloat(FloatingObject* floatingObject, LayoutUnit logi calWidth) 154 void setLogicalWidthForFloat(FloatingObject* floatingObject, LayoutUnit logi calWidth)
155 { 155 {
156 if (isHorizontalWritingMode()) 156 if (isHorizontalWritingMode())
157 floatingObject->setWidth(logicalWidth); 157 floatingObject->setWidth(logicalWidth);
158 else 158 else
159 floatingObject->setHeight(logicalWidth); 159 floatingObject->setHeight(logicalWidth);
160 } 160 }
161 161
162 LayoutUnit startAlignedOffsetForLine(LayoutUnit position, bool shouldIndentT ext); 162 LayoutUnit startAlignedOffsetForLine(LayoutUnit position, bool shouldIndentT ext);
163 163
164 void setStaticInlinePositionForChild(RenderBox*, LayoutUnit inlinePosition); 164 void setStaticInlinePositionForChild(RenderBox&, LayoutUnit inlinePosition);
165 void updateStaticInlinePositionForChild(RenderBox*, LayoutUnit logicalTop); 165 void updateStaticInlinePositionForChild(RenderBox&, LayoutUnit logicalTop);
166 166
167 static bool shouldSkipCreatingRunsForObject(RenderObject* obj) 167 static bool shouldSkipCreatingRunsForObject(RenderObject* obj)
168 { 168 {
169 return obj->isFloating() || (obj->isOutOfFlowPositioned() && !obj->style ()->isOriginalDisplayInlineType() && !obj->container()->isRenderInline()); 169 return obj->isFloating() || (obj->isOutOfFlowPositioned() && !obj->style ()->isOriginalDisplayInlineType() && !obj->container()->isRenderInline());
170 } 170 }
171 171
172 RenderMultiColumnFlowThread* multiColumnFlowThread() const { return m_rareDa ta ? m_rareData->m_multiColumnFlowThread.get() : 0; } 172 RenderMultiColumnFlowThread* multiColumnFlowThread() const { return m_rareDa ta ? m_rareData->m_multiColumnFlowThread.get() : 0; }
173 void resetMultiColumnFlowThread() 173 void resetMultiColumnFlowThread()
174 { 174 {
175 if (m_rareData) 175 if (m_rareData)
(...skipping 29 matching lines...) Expand all
205 virtual bool avoidsFloats() const override; 205 virtual bool avoidsFloats() const override;
206 206
207 using RenderBoxModelObject::moveChildrenTo; 207 using RenderBoxModelObject::moveChildrenTo;
208 virtual void moveChildrenTo(RenderBoxModelObject* toBoxModelObject, RenderOb ject* startChild, RenderObject* endChild, RenderObject* beforeChild, bool fullRe moveInsert = false) override; 208 virtual void moveChildrenTo(RenderBoxModelObject* toBoxModelObject, RenderOb ject* startChild, RenderObject* endChild, RenderObject* beforeChild, bool fullRe moveInsert = false) override;
209 209
210 LayoutUnit xPositionForFloatIncludingMargin(const FloatingObject* child) con st 210 LayoutUnit xPositionForFloatIncludingMargin(const FloatingObject* child) con st
211 { 211 {
212 if (isHorizontalWritingMode()) 212 if (isHorizontalWritingMode())
213 return child->x() + child->renderer()->marginLeft(); 213 return child->x() + child->renderer()->marginLeft();
214 214
215 return child->x() + marginBeforeForChild(child->renderer()); 215 return child->x() + marginBeforeForChild(*(child->renderer()));
216 } 216 }
217 217
218 LayoutUnit yPositionForFloatIncludingMargin(const FloatingObject* child) con st 218 LayoutUnit yPositionForFloatIncludingMargin(const FloatingObject* child) con st
219 { 219 {
220 if (isHorizontalWritingMode()) 220 if (isHorizontalWritingMode())
221 return child->y() + marginBeforeForChild(child->renderer()); 221 return child->y() + marginBeforeForChild(*(child->renderer()));
222 222
223 return child->y() + child->renderer()->marginTop(); 223 return child->y() + child->renderer()->marginTop();
224 } 224 }
225 225
226 LayoutPoint flipFloatForWritingModeForChild(const FloatingObject*, const Lay outPoint&) const; 226 LayoutPoint flipFloatForWritingModeForChild(const FloatingObject*, const Lay outPoint&) const;
227 227
228 protected: 228 protected:
229 void rebuildFloatsFromIntruding(); 229 void rebuildFloatsFromIntruding();
230 void layoutInlineChildren(bool relayoutChildren, LayoutUnit& paintInvalidati onLogicalTop, LayoutUnit& paintInvalidationLogicalBottom, LayoutUnit afterEdge); 230 void layoutInlineChildren(bool relayoutChildren, LayoutUnit& paintInvalidati onLogicalTop, LayoutUnit& paintInvalidationLogicalBottom, LayoutUnit afterEdge);
231 231
232 void createFloatingObjects(); 232 void createFloatingObjects();
233 233
234 virtual void styleWillChange(StyleDifference, const RenderStyle& newStyle) o verride; 234 virtual void styleWillChange(StyleDifference, const RenderStyle& newStyle) o verride;
235 virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle) ov erride; 235 virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle) ov erride;
236 236
237 void addOverflowFromFloats(); 237 void addOverflowFromFloats();
238 238
239 LayoutUnit logicalRightOffsetForLine(LayoutUnit logicalTop, LayoutUnit fixed Offset, bool applyTextIndent, LayoutUnit logicalHeight = 0) const 239 LayoutUnit logicalRightOffsetForLine(LayoutUnit logicalTop, LayoutUnit fixed Offset, bool applyTextIndent, LayoutUnit logicalHeight = 0) const
240 { 240 {
241 return adjustLogicalRightOffsetForLine(logicalRightFloatOffsetForLine(lo gicalTop, fixedOffset, logicalHeight), applyTextIndent); 241 return adjustLogicalRightOffsetForLine(logicalRightFloatOffsetForLine(lo gicalTop, fixedOffset, logicalHeight), applyTextIndent);
242 } 242 }
243 LayoutUnit logicalLeftOffsetForLine(LayoutUnit logicalTop, LayoutUnit fixedO ffset, bool applyTextIndent, LayoutUnit logicalHeight = 0) const 243 LayoutUnit logicalLeftOffsetForLine(LayoutUnit logicalTop, LayoutUnit fixedO ffset, bool applyTextIndent, LayoutUnit logicalHeight = 0) const
244 { 244 {
245 return adjustLogicalLeftOffsetForLine(logicalLeftFloatOffsetForLine(logi calTop, fixedOffset, logicalHeight), applyTextIndent); 245 return adjustLogicalLeftOffsetForLine(logicalLeftFloatOffsetForLine(logi calTop, fixedOffset, logicalHeight), applyTextIndent);
246 } 246 }
247 247
248 virtual RenderObject* layoutSpecialExcludedChild(bool /*relayoutChildren*/, SubtreeLayoutScope&); 248 virtual RenderObject* layoutSpecialExcludedChild(bool /*relayoutChildren*/, SubtreeLayoutScope&);
249 virtual bool updateLogicalWidthAndColumnWidth() override; 249 virtual bool updateLogicalWidthAndColumnWidth() override;
250 250
251 void setLogicalLeftForChild(RenderBox* child, LayoutUnit logicalLeft); 251 void setLogicalLeftForChild(RenderBox& child, LayoutUnit logicalLeft);
252 void setLogicalTopForChild(RenderBox* child, LayoutUnit logicalTop); 252 void setLogicalTopForChild(RenderBox& child, LayoutUnit logicalTop);
253 void determineLogicalLeftPositionForChild(RenderBox* child); 253 void determineLogicalLeftPositionForChild(RenderBox& child);
254 254
255 private: 255 private:
256 bool layoutBlockFlow(bool relayoutChildren, LayoutUnit& pageLogicalHeight, S ubtreeLayoutScope&); 256 bool layoutBlockFlow(bool relayoutChildren, LayoutUnit& pageLogicalHeight, S ubtreeLayoutScope&);
257 void layoutBlockChildren(bool relayoutChildren, SubtreeLayoutScope&, LayoutU nit beforeEdge, LayoutUnit afterEdge); 257 void layoutBlockChildren(bool relayoutChildren, SubtreeLayoutScope&, LayoutU nit beforeEdge, LayoutUnit afterEdge);
258 258
259 void layoutBlockChild(RenderBox* child, MarginInfo&, LayoutUnit& previousFlo atLogicalBottom); 259 void layoutBlockChild(RenderBox& child, MarginInfo&, LayoutUnit& previousFlo atLogicalBottom);
260 void adjustPositionedBlock(RenderBox* child, const MarginInfo&); 260 void adjustPositionedBlock(RenderBox& child, const MarginInfo&);
261 void adjustFloatingBlock(const MarginInfo&); 261 void adjustFloatingBlock(const MarginInfo&);
262 262
263 LayoutPoint computeLogicalLocationForFloat(const FloatingObject*, LayoutUnit logicalTopOffset) const; 263 LayoutPoint computeLogicalLocationForFloat(const FloatingObject*, LayoutUnit logicalTopOffset) const;
264 264
265 FloatingObject* insertFloatingObject(RenderBox*); 265 FloatingObject* insertFloatingObject(RenderBox&);
266 void removeFloatingObject(RenderBox*); 266 void removeFloatingObject(RenderBox*);
267 void removeFloatingObjectsBelow(FloatingObject*, int logicalOffset); 267 void removeFloatingObjectsBelow(FloatingObject*, int logicalOffset);
268 268
269 // Called from lineWidth, to position the floats added in the last line. 269 // Called from lineWidth, to position the floats added in the last line.
270 // Returns true if and only if it has positioned any floats. 270 // Returns true if and only if it has positioned any floats.
271 bool positionNewFloats(); 271 bool positionNewFloats();
272 272
273 LayoutUnit getClearDelta(RenderBox* child, LayoutUnit yPos); 273 LayoutUnit getClearDelta(RenderBox* child, LayoutUnit yPos);
274 274
275 bool hasOverhangingFloats() { return parent() && !hasColumns() && containsFl oats() && lowestFloatLogicalBottom() > logicalHeight(); } 275 bool hasOverhangingFloats() { return parent() && !hasColumns() && containsFl oats() && lowestFloatLogicalBottom() > logicalHeight(); }
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
358 void setNegativeMarginBefore(LayoutUnit neg) { m_negativeMarginBefore = neg; } 358 void setNegativeMarginBefore(LayoutUnit neg) { m_negativeMarginBefore = neg; }
359 void setPositiveMarginAfter(LayoutUnit pos) { m_positiveMarginAfter = po s; } 359 void setPositiveMarginAfter(LayoutUnit pos) { m_positiveMarginAfter = po s; }
360 void setNegativeMarginAfter(LayoutUnit neg) { m_negativeMarginAfter = ne g; } 360 void setNegativeMarginAfter(LayoutUnit neg) { m_negativeMarginAfter = ne g; }
361 361
362 private: 362 private:
363 LayoutUnit m_positiveMarginBefore; 363 LayoutUnit m_positiveMarginBefore;
364 LayoutUnit m_negativeMarginBefore; 364 LayoutUnit m_negativeMarginBefore;
365 LayoutUnit m_positiveMarginAfter; 365 LayoutUnit m_positiveMarginAfter;
366 LayoutUnit m_negativeMarginAfter; 366 LayoutUnit m_negativeMarginAfter;
367 }; 367 };
368 MarginValues marginValuesForChild(RenderBox* child) const; 368 MarginValues marginValuesForChild(RenderBox& child) const;
369 369
370 // Allocated only when some of these fields have non-default values 370 // Allocated only when some of these fields have non-default values
371 struct RenderBlockFlowRareData : public NoBaseWillBeGarbageCollected<RenderB lockFlowRareData> { 371 struct RenderBlockFlowRareData : public NoBaseWillBeGarbageCollected<RenderB lockFlowRareData> {
372 WTF_MAKE_NONCOPYABLE(RenderBlockFlowRareData); WTF_MAKE_FAST_ALLOCATED_W ILL_BE_REMOVED; 372 WTF_MAKE_NONCOPYABLE(RenderBlockFlowRareData); WTF_MAKE_FAST_ALLOCATED_W ILL_BE_REMOVED;
373 public: 373 public:
374 RenderBlockFlowRareData(const RenderBlockFlow* block) 374 RenderBlockFlowRareData(const RenderBlockFlow* block)
375 : m_margins(positiveMarginBeforeDefault(block), negativeMarginBefore Default(block), positiveMarginAfterDefault(block), negativeMarginAfterDefault(bl ock)) 375 : m_margins(positiveMarginBeforeDefault(block), negativeMarginBefore Default(block), positiveMarginAfterDefault(block), negativeMarginAfterDefault(bl ock))
376 , m_paginationStrut(0) 376 , m_paginationStrut(0)
377 , m_multiColumnFlowThread(nullptr) 377 , m_multiColumnFlowThread(nullptr)
378 , m_lineBreakToAvoidWidow(-1) 378 , m_lineBreakToAvoidWidow(-1)
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
423 423
424 void setMaxMarginBeforeValues(LayoutUnit pos, LayoutUnit neg); 424 void setMaxMarginBeforeValues(LayoutUnit pos, LayoutUnit neg);
425 void setMaxMarginAfterValues(LayoutUnit pos, LayoutUnit neg); 425 void setMaxMarginAfterValues(LayoutUnit pos, LayoutUnit neg);
426 426
427 void setMustDiscardMarginBefore(bool = true); 427 void setMustDiscardMarginBefore(bool = true);
428 void setMustDiscardMarginAfter(bool = true); 428 void setMustDiscardMarginAfter(bool = true);
429 429
430 bool mustDiscardMarginBefore() const; 430 bool mustDiscardMarginBefore() const;
431 bool mustDiscardMarginAfter() const; 431 bool mustDiscardMarginAfter() const;
432 432
433 bool mustDiscardMarginBeforeForChild(const RenderBox*) const; 433 bool mustDiscardMarginBeforeForChild(const RenderBox&) const;
434 bool mustDiscardMarginAfterForChild(const RenderBox*) const; 434 bool mustDiscardMarginAfterForChild(const RenderBox&) const;
435 435
436 bool mustSeparateMarginBeforeForChild(const RenderBox*) const; 436 bool mustSeparateMarginBeforeForChild(const RenderBox&) const;
437 bool mustSeparateMarginAfterForChild(const RenderBox*) const; 437 bool mustSeparateMarginAfterForChild(const RenderBox&) const;
438 438
439 void initMaxMarginValues() 439 void initMaxMarginValues()
440 { 440 {
441 if (m_rareData) { 441 if (m_rareData) {
442 m_rareData->m_margins = MarginValues(RenderBlockFlowRareData::positi veMarginBeforeDefault(this) , RenderBlockFlowRareData::negativeMarginBeforeDefau lt(this), 442 m_rareData->m_margins = MarginValues(RenderBlockFlowRareData::positi veMarginBeforeDefault(this) , RenderBlockFlowRareData::negativeMarginBeforeDefau lt(this),
443 RenderBlockFlowRareData::positiveMarginAfterDefault(this), Rende rBlockFlowRareData::negativeMarginAfterDefault(this)); 443 RenderBlockFlowRareData::positiveMarginAfterDefault(this), Rende rBlockFlowRareData::negativeMarginAfterDefault(this));
444 444
445 m_rareData->m_discardMarginBefore = false; 445 m_rareData->m_discardMarginBefore = false;
446 m_rareData->m_discardMarginAfter = false; 446 m_rareData->m_discardMarginAfter = false;
447 } 447 }
448 } 448 }
449 449
450 virtual ETextAlign textAlignmentForLine(bool endsWithSoftBreak) const; 450 virtual ETextAlign textAlignmentForLine(bool endsWithSoftBreak) const;
451 private: 451 private:
452 virtual LayoutUnit collapsedMarginBefore() const override final { return max PositiveMarginBefore() - maxNegativeMarginBefore(); } 452 virtual LayoutUnit collapsedMarginBefore() const override final { return max PositiveMarginBefore() - maxNegativeMarginBefore(); }
453 virtual LayoutUnit collapsedMarginAfter() const override final { return maxP ositiveMarginAfter() - maxNegativeMarginAfter(); } 453 virtual LayoutUnit collapsedMarginAfter() const override final { return maxP ositiveMarginAfter() - maxNegativeMarginAfter(); }
454 454
455 LayoutUnit collapseMargins(RenderBox* child, MarginInfo&, bool childIsSelfCo llapsing); 455 LayoutUnit collapseMargins(RenderBox& child, MarginInfo&, bool childIsSelfCo llapsing);
456 LayoutUnit clearFloatsIfNeeded(RenderBox* child, MarginInfo&, LayoutUnit old TopPosMargin, LayoutUnit oldTopNegMargin, LayoutUnit yPos, bool childIsSelfColla psing); 456 LayoutUnit clearFloatsIfNeeded(RenderBox& child, MarginInfo&, LayoutUnit old TopPosMargin, LayoutUnit oldTopNegMargin, LayoutUnit yPos, bool childIsSelfColla psing);
457 LayoutUnit estimateLogicalTopPosition(RenderBox* child, const MarginInfo&, L ayoutUnit& estimateWithoutPagination); 457 LayoutUnit estimateLogicalTopPosition(RenderBox& child, const MarginInfo&, L ayoutUnit& estimateWithoutPagination);
458 void marginBeforeEstimateForChild(RenderBox*, LayoutUnit&, LayoutUnit&, bool &) const; 458 void marginBeforeEstimateForChild(RenderBox&, LayoutUnit&, LayoutUnit&, bool &) const;
459 void handleAfterSideOfBlock(RenderBox* lastChild, LayoutUnit top, LayoutUnit bottom, MarginInfo&); 459 void handleAfterSideOfBlock(RenderBox* lastChild, LayoutUnit top, LayoutUnit bottom, MarginInfo&);
460 void setCollapsedBottomMargin(const MarginInfo&); 460 void setCollapsedBottomMargin(const MarginInfo&);
461 461
462 LayoutUnit applyBeforeBreak(RenderBox* child, LayoutUnit logicalOffset); // If the child has a before break, then return a new yPos that shifts to the top o f the next page/column. 462 LayoutUnit applyBeforeBreak(RenderBox& child, LayoutUnit logicalOffset); // If the child has a before break, then return a new yPos that shifts to the top o f the next page/column.
463 LayoutUnit applyAfterBreak(RenderBox* child, LayoutUnit logicalOffset, Margi nInfo&); // If the child has an after break, then return a new offset that shift s to the top of the next page/column. 463 LayoutUnit applyAfterBreak(RenderBox& child, LayoutUnit logicalOffset, Margi nInfo&); // If the child has an after break, then return a new offset that shift s to the top of the next page/column.
464 464
465 LayoutUnit adjustBlockChildForPagination(LayoutUnit logicalTopAfterClear, La youtUnit estimateWithoutPagination, RenderBox* child, bool atBeforeSideOfBlock); 465 LayoutUnit adjustBlockChildForPagination(LayoutUnit logicalTopAfterClear, La youtUnit estimateWithoutPagination, RenderBox& child, bool atBeforeSideOfBlock);
466 // Computes a deltaOffset value that put a line at the top of the next page if it doesn't fit on the current page. 466 // Computes a deltaOffset value that put a line at the top of the next page if it doesn't fit on the current page.
467 void adjustLinePositionForPagination(RootInlineBox*, LayoutUnit& deltaOffset , RenderFlowThread*); 467 void adjustLinePositionForPagination(RootInlineBox&, LayoutUnit& deltaOffset , RenderFlowThread*);
468 // If the child is unsplittable and can't fit on the current page, return th e top of the next page/column. 468 // If the child is unsplittable and can't fit on the current page, return th e top of the next page/column.
469 LayoutUnit adjustForUnsplittableChild(RenderBox*, LayoutUnit logicalOffset, bool includeMargins = false); 469 LayoutUnit adjustForUnsplittableChild(RenderBox&, LayoutUnit logicalOffset, bool includeMargins = false);
470 470
471 // Used to store state between styleWillChange and styleDidChange 471 // Used to store state between styleWillChange and styleDidChange
472 static bool s_canPropagateFloatIntoSibling; 472 static bool s_canPropagateFloatIntoSibling;
473 473
474 RenderBlockFlowRareData& ensureRareData(); 474 RenderBlockFlowRareData& ensureRareData();
475 475
476 LayoutUnit m_paintInvalidationLogicalTop; 476 LayoutUnit m_paintInvalidationLogicalTop;
477 LayoutUnit m_paintInvalidationLogicalBottom; 477 LayoutUnit m_paintInvalidationLogicalBottom;
478 478
479 virtual bool isSelfCollapsingBlock() const override; 479 virtual bool isSelfCollapsingBlock() const override;
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
522 522
523 // END METHODS DEFINED IN RenderBlockLineLayout 523 // END METHODS DEFINED IN RenderBlockLineLayout
524 524
525 }; 525 };
526 526
527 DEFINE_RENDER_OBJECT_TYPE_CASTS(RenderBlockFlow, isRenderBlockFlow()); 527 DEFINE_RENDER_OBJECT_TYPE_CASTS(RenderBlockFlow, isRenderBlockFlow());
528 528
529 } // namespace blink 529 } // namespace blink
530 530
531 #endif // RenderBlockFlow_h 531 #endif // RenderBlockFlow_h
OLDNEW
« no previous file with comments | « Source/core/rendering/RenderBlock.cpp ('k') | Source/core/rendering/RenderBlockFlow.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698