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

Side by Side Diff: third_party/WebKit/Source/core/layout/LayoutBlockFlow.h

Issue 1856373002: Only allow forced fragmentainer breaks at class A break points. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Woho! LayoutTests/printing/css2.1/page-break-after-003.html now passes. Created 4 years, 8 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 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 void determineLogicalLeftPositionForChild(LayoutBox& child); 314 void determineLogicalLeftPositionForChild(LayoutBox& child);
315 315
316 PaintInvalidationReason invalidatePaintIfNeeded(const PaintInvalidationState &) override; 316 PaintInvalidationReason invalidatePaintIfNeeded(const PaintInvalidationState &) override;
317 317
318 private: 318 private:
319 bool layoutBlockFlow(bool relayoutChildren, LayoutUnit& pageLogicalHeight, S ubtreeLayoutScope&); 319 bool layoutBlockFlow(bool relayoutChildren, LayoutUnit& pageLogicalHeight, S ubtreeLayoutScope&);
320 void layoutBlockChildren(bool relayoutChildren, SubtreeLayoutScope&, LayoutU nit beforeEdge, LayoutUnit afterEdge); 320 void layoutBlockChildren(bool relayoutChildren, SubtreeLayoutScope&, LayoutU nit beforeEdge, LayoutUnit afterEdge);
321 321
322 void markDescendantsWithFloatsForLayoutIfNeeded(LayoutBlockFlow& child, Layo utUnit newLogicalTop, LayoutUnit previousFloatLogicalBottom); 322 void markDescendantsWithFloatsForLayoutIfNeeded(LayoutBlockFlow& child, Layo utUnit newLogicalTop, LayoutUnit previousFloatLogicalBottom);
323 bool positionAndLayoutOnceIfNeeded(LayoutBox& child, LayoutUnit newLogicalTo p, BlockChildrenLayoutInfo&); 323 bool positionAndLayoutOnceIfNeeded(LayoutBox& child, LayoutUnit newLogicalTo p, BlockChildrenLayoutInfo&);
324
325 // Handle breaking policy before the child, and insert a forced break in fro nt of it if needed.
326 // Returns true if a forced break was inserted.
327 bool insertForcedBreakBeforeChildIfNeeded(LayoutBox& child, BlockChildrenLay outInfo&);
328
324 void layoutBlockChild(LayoutBox& child, BlockChildrenLayoutInfo&); 329 void layoutBlockChild(LayoutBox& child, BlockChildrenLayoutInfo&);
325 void adjustPositionedBlock(LayoutBox& child, const MarginInfo&); 330 void adjustPositionedBlock(LayoutBox& child, const BlockChildrenLayoutInfo&) ;
326 void adjustFloatingBlock(const MarginInfo&); 331 void adjustFloatingBlock(const MarginInfo&);
327 332
328 LayoutPoint computeLogicalLocationForFloat(const FloatingObject&, LayoutUnit logicalTopOffset) const; 333 LayoutPoint computeLogicalLocationForFloat(const FloatingObject&, LayoutUnit logicalTopOffset) const;
329 334
330 void removeFloatingObject(LayoutBox*); 335 void removeFloatingObject(LayoutBox*);
331 void removeFloatingObjectsBelow(FloatingObject*, int logicalOffset); 336 void removeFloatingObjectsBelow(FloatingObject*, int logicalOffset);
332 337
333 LayoutUnit getClearDelta(LayoutBox* child, LayoutUnit yPos); 338 LayoutUnit getClearDelta(LayoutBox* child, LayoutUnit yPos);
334 339
335 bool hasOverhangingFloats() { return parent() && containsFloats() && lowestF loatLogicalBottom() > logicalHeight(); } 340 bool hasOverhangingFloats() { return parent() && containsFloats() && lowestF loatLogicalBottom() > logicalHeight(); }
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
437 }; 442 };
438 MarginValues marginValuesForChild(LayoutBox& child) const; 443 MarginValues marginValuesForChild(LayoutBox& child) const;
439 444
440 // Allocated only when some of these fields have non-default values 445 // Allocated only when some of these fields have non-default values
441 struct LayoutBlockFlowRareData { 446 struct LayoutBlockFlowRareData {
442 WTF_MAKE_NONCOPYABLE(LayoutBlockFlowRareData); USING_FAST_MALLOC(LayoutB lockFlowRareData); 447 WTF_MAKE_NONCOPYABLE(LayoutBlockFlowRareData); USING_FAST_MALLOC(LayoutB lockFlowRareData);
443 public: 448 public:
444 LayoutBlockFlowRareData(const LayoutBlockFlow* block) 449 LayoutBlockFlowRareData(const LayoutBlockFlow* block)
445 : m_margins(positiveMarginBeforeDefault(block), negativeMarginBefore Default(block), positiveMarginAfterDefault(block), negativeMarginAfterDefault(bl ock)) 450 : m_margins(positiveMarginBeforeDefault(block), negativeMarginBefore Default(block), positiveMarginAfterDefault(block), negativeMarginAfterDefault(bl ock))
446 , m_multiColumnFlowThread(nullptr) 451 , m_multiColumnFlowThread(nullptr)
452 , m_breakBefore(BreakAuto)
453 , m_breakAfter(BreakAuto)
447 , m_lineBreakToAvoidWidow(-1) 454 , m_lineBreakToAvoidWidow(-1)
448 , m_didBreakAtLineToAvoidWidow(false) 455 , m_didBreakAtLineToAvoidWidow(false)
449 , m_discardMarginBefore(false) 456 , m_discardMarginBefore(false)
450 , m_discardMarginAfter(false) 457 , m_discardMarginAfter(false)
451 { 458 {
452 } 459 }
453 460
454 static LayoutUnit positiveMarginBeforeDefault(const LayoutBlockFlow* blo ck) 461 static LayoutUnit positiveMarginBeforeDefault(const LayoutBlockFlow* blo ck)
455 { 462 {
456 return block->marginBefore().clampNegativeToZero(); 463 return block->marginBefore().clampNegativeToZero();
457 } 464 }
458 static LayoutUnit negativeMarginBeforeDefault(const LayoutBlockFlow* blo ck) 465 static LayoutUnit negativeMarginBeforeDefault(const LayoutBlockFlow* blo ck)
459 { 466 {
460 return (-block->marginBefore()).clampNegativeToZero(); 467 return (-block->marginBefore()).clampNegativeToZero();
461 } 468 }
462 static LayoutUnit positiveMarginAfterDefault(const LayoutBlockFlow* bloc k) 469 static LayoutUnit positiveMarginAfterDefault(const LayoutBlockFlow* bloc k)
463 { 470 {
464 return block->marginAfter().clampNegativeToZero(); 471 return block->marginAfter().clampNegativeToZero();
465 } 472 }
466 static LayoutUnit negativeMarginAfterDefault(const LayoutBlockFlow* bloc k) 473 static LayoutUnit negativeMarginAfterDefault(const LayoutBlockFlow* bloc k)
467 { 474 {
468 return (-block->marginAfter()).clampNegativeToZero(); 475 return (-block->marginAfter()).clampNegativeToZero();
469 } 476 }
470 477
471 MarginValues m_margins; 478 MarginValues m_margins;
472 LayoutUnit m_paginationStrutPropagatedFromChild; 479 LayoutUnit m_paginationStrutPropagatedFromChild;
473 480
474 LayoutMultiColumnFlowThread* m_multiColumnFlowThread; 481 LayoutMultiColumnFlowThread* m_multiColumnFlowThread;
475 482
483 unsigned m_breakBefore : 4;
484 unsigned m_breakAfter : 4;
476 int m_lineBreakToAvoidWidow; 485 int m_lineBreakToAvoidWidow;
477 bool m_didBreakAtLineToAvoidWidow : 1; 486 bool m_didBreakAtLineToAvoidWidow : 1;
478 bool m_discardMarginBefore : 1; 487 bool m_discardMarginBefore : 1;
479 bool m_discardMarginAfter : 1; 488 bool m_discardMarginAfter : 1;
480 }; 489 };
481 490
482 const FloatingObjects* floatingObjects() const { return m_floatingObjects.ge t(); } 491 const FloatingObjects* floatingObjects() const { return m_floatingObjects.ge t(); }
483 492
484 static void setAncestorShouldPaintFloatingObject(const LayoutBox& floatBox, bool shouldPaint); 493 static void setAncestorShouldPaintFloatingObject(const LayoutBox& floatBox, bool shouldPaint);
485 494
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
519 private: 528 private:
520 LayoutUnit collapsedMarginBefore() const final { return maxPositiveMarginBef ore() - maxNegativeMarginBefore(); } 529 LayoutUnit collapsedMarginBefore() const final { return maxPositiveMarginBef ore() - maxNegativeMarginBefore(); }
521 LayoutUnit collapsedMarginAfter() const final { return maxPositiveMarginAfte r() - maxNegativeMarginAfter(); } 530 LayoutUnit collapsedMarginAfter() const final { return maxPositiveMarginAfte r() - maxNegativeMarginAfter(); }
522 531
523 // Floats' margins do not collapse with page or column boundaries, and we th erefore need to 532 // Floats' margins do not collapse with page or column boundaries, and we th erefore need to
524 // treat them specially in some cases. 533 // treat them specially in some cases.
525 LayoutUnit marginBeforeIfFloating() const { return isFloating() ? marginBefo re() : LayoutUnit(); } 534 LayoutUnit marginBeforeIfFloating() const { return isFloating() ? marginBefo re() : LayoutUnit(); }
526 535
527 LayoutUnit collapseMargins(LayoutBox& child, MarginInfo&, bool childIsSelfCo llapsing, bool childDiscardMarginBefore, bool childDiscardMarginAfter); 536 LayoutUnit collapseMargins(LayoutBox& child, MarginInfo&, bool childIsSelfCo llapsing, bool childDiscardMarginBefore, bool childDiscardMarginAfter);
528 LayoutUnit clearFloatsIfNeeded(LayoutBox& child, MarginInfo&, LayoutUnit old TopPosMargin, LayoutUnit oldTopNegMargin, LayoutUnit yPos, bool childIsSelfColla psing, bool childDiscardMargin); 537 LayoutUnit clearFloatsIfNeeded(LayoutBox& child, MarginInfo&, LayoutUnit old TopPosMargin, LayoutUnit oldTopNegMargin, LayoutUnit yPos, bool childIsSelfColla psing, bool childDiscardMargin);
529 LayoutUnit estimateLogicalTopPosition(LayoutBox& child, const MarginInfo&, L ayoutUnit& estimateWithoutPagination); 538 LayoutUnit estimateLogicalTopPosition(LayoutBox& child, const BlockChildrenL ayoutInfo&, LayoutUnit& estimateWithoutPagination);
530 void marginBeforeEstimateForChild(LayoutBox&, LayoutUnit&, LayoutUnit&, bool &) const; 539 void marginBeforeEstimateForChild(LayoutBox&, LayoutUnit&, LayoutUnit&, bool &) const;
531 void handleAfterSideOfBlock(LayoutBox* lastChild, LayoutUnit top, LayoutUnit bottom, MarginInfo&); 540 void handleAfterSideOfBlock(LayoutBox* lastChild, LayoutUnit top, LayoutUnit bottom, MarginInfo&);
532 void setCollapsedBottomMargin(const MarginInfo&); 541 void setCollapsedBottomMargin(const MarginInfo&);
533 542
534 LayoutUnit applyBeforeBreak(LayoutBox& 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. 543 // Apply any forced fragmentainer break that's set on the current class A br eak point.
535 LayoutUnit applyAfterBreak(LayoutBox& 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. 544 LayoutUnit applyForcedBreak(LayoutUnit logicalOffset, EBreak);
545
546 void setBreakBefore(EBreak);
547 void setBreakAfter(EBreak);
548 EBreak breakBefore() const override;
549 EBreak breakAfter() const override;
536 550
537 LayoutUnit adjustBlockChildForPagination(LayoutUnit logicalTop, LayoutBox& c hild, BlockChildrenLayoutInfo&, bool atBeforeSideOfBlock); 551 LayoutUnit adjustBlockChildForPagination(LayoutUnit logicalTop, LayoutBox& c hild, BlockChildrenLayoutInfo&, bool atBeforeSideOfBlock);
538 // Computes a deltaOffset value that put a line at the top of the next page if it doesn't fit on the current page. 552 // Computes a deltaOffset value that put a line at the top of the next page if it doesn't fit on the current page.
539 void adjustLinePositionForPagination(RootInlineBox&, LayoutUnit& deltaOffset ); 553 void adjustLinePositionForPagination(RootInlineBox&, LayoutUnit& deltaOffset );
540 // If the child is unsplittable and can't fit on the current page, return th e top of the next page/column. 554 // If the child is unsplittable and can't fit on the current page, return th e top of the next page/column.
541 LayoutUnit adjustForUnsplittableChild(LayoutBox&, LayoutUnit logicalOffset) const; 555 LayoutUnit adjustForUnsplittableChild(LayoutBox&, LayoutUnit logicalOffset) const;
542 556
543 // Used to store state between styleWillChange and styleDidChange 557 // Used to store state between styleWillChange and styleDidChange
544 static bool s_canPropagateFloatIntoSibling; 558 static bool s_canPropagateFloatIntoSibling;
545 559
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
593 607
594 // END METHODS DEFINED IN LayoutBlockFlowLine 608 // END METHODS DEFINED IN LayoutBlockFlowLine
595 609
596 }; 610 };
597 611
598 DEFINE_LAYOUT_OBJECT_TYPE_CASTS(LayoutBlockFlow, isLayoutBlockFlow()); 612 DEFINE_LAYOUT_OBJECT_TYPE_CASTS(LayoutBlockFlow, isLayoutBlockFlow());
599 613
600 } // namespace blink 614 } // namespace blink
601 615
602 #endif // LayoutBlockFlow_h 616 #endif // LayoutBlockFlow_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/layout/ColumnBalancer.cpp ('k') | third_party/WebKit/Source/core/layout/LayoutBlockFlow.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698