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

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

Issue 2505853004: Let lowestFloatLogicalBottom() take EClear instead of FloatingObject::Type (Closed)
Patch Set: Code review. Created 4 years, 1 month 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 | « third_party/WebKit/Source/core/layout/LayoutBlockFlow.h ('k') | no next file » | 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) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. 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 are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 2631 matching lines...) Expand 10 before | Expand all | Expand 10 after
2642 } 2642 }
2643 2643
2644 LayoutUnit LayoutBlockFlow::getClearDelta(LayoutBox* child, 2644 LayoutUnit LayoutBlockFlow::getClearDelta(LayoutBox* child,
2645 LayoutUnit logicalTop) { 2645 LayoutUnit logicalTop) {
2646 // There is no need to compute clearance if we have no floats. 2646 // There is no need to compute clearance if we have no floats.
2647 if (!containsFloats()) 2647 if (!containsFloats())
2648 return LayoutUnit(); 2648 return LayoutUnit();
2649 2649
2650 // At least one float is present. We need to perform the clearance 2650 // At least one float is present. We need to perform the clearance
2651 // computation. 2651 // computation.
2652 bool clearSet = child->style()->clear() != ClearNone; 2652 EClear clear = child->style()->clear();
2653 LayoutUnit logicalBottom; 2653 LayoutUnit logicalBottom = lowestFloatLogicalBottom(clear);
2654 switch (child->style()->clear()) {
2655 case ClearNone:
2656 break;
2657 case ClearLeft:
2658 logicalBottom = lowestFloatLogicalBottom(FloatingObject::FloatLeft);
2659 break;
2660 case ClearRight:
2661 logicalBottom = lowestFloatLogicalBottom(FloatingObject::FloatRight);
2662 break;
2663 case ClearBoth:
2664 logicalBottom = lowestFloatLogicalBottom();
2665 break;
2666 }
2667 2654
2668 // We also clear floats if we are too big to sit on the same line as a float 2655 // We also clear floats if we are too big to sit on the same line as a float
2669 // (and wish to avoid floats by default). 2656 // (and wish to avoid floats by default).
2670 LayoutUnit result = clearSet 2657 LayoutUnit result = clear != ClearNone
2671 ? (logicalBottom - logicalTop).clampNegativeToZero() 2658 ? (logicalBottom - logicalTop).clampNegativeToZero()
2672 : LayoutUnit(); 2659 : LayoutUnit();
2673 if (!result && child->avoidsFloats()) { 2660 if (!result && child->avoidsFloats()) {
2674 LayoutUnit newLogicalTop = logicalTop; 2661 LayoutUnit newLogicalTop = logicalTop;
2675 LayoutRect borderBox = child->borderBoxRect(); 2662 LayoutRect borderBox = child->borderBoxRect();
2676 LayoutUnit childLogicalWidthAtOldLogicalTopOffset = 2663 LayoutUnit childLogicalWidthAtOldLogicalTopOffset =
2677 isHorizontalWritingMode() ? borderBox.width() : borderBox.height(); 2664 isHorizontalWritingMode() ? borderBox.width() : borderBox.height();
2678 while (true) { 2665 while (true) {
2679 LayoutUnit availableLogicalWidthAtNewLogicalTopOffset = 2666 LayoutUnit availableLogicalWidthAtNewLogicalTopOffset =
2680 availableLogicalWidthForLine(newLogicalTop, DoNotIndentText, 2667 availableLogicalWidthForLine(newLogicalTop, DoNotIndentText,
(...skipping 652 matching lines...) Expand 10 before | Expand all | Expand 10 after
3333 void LayoutBlockFlow::childBecameNonInline(LayoutObject*) { 3320 void LayoutBlockFlow::childBecameNonInline(LayoutObject*) {
3334 makeChildrenNonInline(); 3321 makeChildrenNonInline();
3335 if (isAnonymousBlock() && parent() && parent()->isLayoutBlock()) 3322 if (isAnonymousBlock() && parent() && parent()->isLayoutBlock())
3336 toLayoutBlock(parent())->removeLeftoverAnonymousBlock(this); 3323 toLayoutBlock(parent())->removeLeftoverAnonymousBlock(this);
3337 // |this| may be dead here 3324 // |this| may be dead here
3338 } 3325 }
3339 3326
3340 void LayoutBlockFlow::clearFloats(EClear clear) { 3327 void LayoutBlockFlow::clearFloats(EClear clear) {
3341 positionNewFloats(logicalHeight()); 3328 positionNewFloats(logicalHeight());
3342 // set y position 3329 // set y position
3343 LayoutUnit newY; 3330 LayoutUnit newY = lowestFloatLogicalBottom(clear);
3344 switch (clear) {
3345 case ClearLeft:
3346 newY = lowestFloatLogicalBottom(FloatingObject::FloatLeft);
3347 break;
3348 case ClearRight:
3349 newY = lowestFloatLogicalBottom(FloatingObject::FloatRight);
3350 break;
3351 case ClearBoth:
3352 newY = lowestFloatLogicalBottom();
3353 default:
3354 break;
3355 }
3356 if (size().height() < newY) 3331 if (size().height() < newY)
3357 setLogicalHeight(newY); 3332 setLogicalHeight(newY);
3358 } 3333 }
3359 3334
3360 bool LayoutBlockFlow::containsFloat(LayoutBox* layoutBox) const { 3335 bool LayoutBlockFlow::containsFloat(LayoutBox* layoutBox) const {
3361 return m_floatingObjects && 3336 return m_floatingObjects &&
3362 m_floatingObjects->set().contains<FloatingObjectHashTranslator>( 3337 m_floatingObjects->set().contains<FloatingObjectHashTranslator>(
3363 layoutBox); 3338 layoutBox);
3364 } 3339 }
3365 3340
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
3646 FloatingObject& floatingObject, 3621 FloatingObject& floatingObject,
3647 LayoutUnit logicalTop) { 3622 LayoutUnit logicalTop) {
3648 LayoutBox& childBox = *floatingObject.layoutObject(); 3623 LayoutBox& childBox = *floatingObject.layoutObject();
3649 3624
3650 // FIXME Investigate if this can be removed. crbug.com/370006 3625 // FIXME Investigate if this can be removed. crbug.com/370006
3651 childBox.setMayNeedPaintInvalidation(); 3626 childBox.setMayNeedPaintInvalidation();
3652 3627
3653 LayoutUnit childLogicalLeftMargin = style()->isLeftToRightDirection() 3628 LayoutUnit childLogicalLeftMargin = style()->isLeftToRightDirection()
3654 ? marginStartForChild(childBox) 3629 ? marginStartForChild(childBox)
3655 : marginEndForChild(childBox); 3630 : marginEndForChild(childBox);
3656 if (childBox.style()->clear() & ClearLeft) { 3631 logicalTop =
3657 logicalTop = std::max(lowestFloatLogicalBottom(FloatingObject::FloatLeft), 3632 std::max(logicalTop, lowestFloatLogicalBottom(childBox.style()->clear()));
3658 logicalTop);
3659 }
3660 if (childBox.style()->clear() & ClearRight) {
3661 logicalTop = std::max(lowestFloatLogicalBottom(FloatingObject::FloatRight),
3662 logicalTop);
3663 }
3664 3633
3665 bool isPaginated = view()->layoutState()->isPaginated(); 3634 bool isPaginated = view()->layoutState()->isPaginated();
3666 if (isPaginated && !childrenInline()) { 3635 if (isPaginated && !childrenInline()) {
3667 // Forced breaks are inserted at class A break points. Floats may be 3636 // Forced breaks are inserted at class A break points. Floats may be
3668 // affected by a break-after value on the previous in-flow sibling. 3637 // affected by a break-after value on the previous in-flow sibling.
3669 if (LayoutBox* previousInFlowBox = childBox.previousInFlowSiblingBox()) { 3638 if (LayoutBox* previousInFlowBox = childBox.previousInFlowSiblingBox()) {
3670 logicalTop = 3639 logicalTop =
3671 applyForcedBreak(logicalTop, previousInFlowBox->breakAfter()); 3640 applyForcedBreak(logicalTop, previousInFlowBox->breakAfter());
3672 } 3641 }
3673 } 3642 }
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
3889 // need to go ahead and add its overflow in to the child now. 3858 // need to go ahead and add its overflow in to the child now.
3890 if (floatingObject.isDescendant()) 3859 if (floatingObject.isDescendant())
3891 child->addOverflowFromChild( 3860 child->addOverflowFromChild(
3892 floatingObject.layoutObject(), 3861 floatingObject.layoutObject(),
3893 LayoutSize(xPositionForFloatIncludingMargin(floatingObject), 3862 LayoutSize(xPositionForFloatIncludingMargin(floatingObject),
3894 yPositionForFloatIncludingMargin(floatingObject))); 3863 yPositionForFloatIncludingMargin(floatingObject)));
3895 } 3864 }
3896 } 3865 }
3897 } 3866 }
3898 3867
3899 LayoutUnit LayoutBlockFlow::lowestFloatLogicalBottom( 3868 LayoutUnit LayoutBlockFlow::lowestFloatLogicalBottom(EClear clear) const {
3900 FloatingObject::Type floatType) const { 3869 if (clear == ClearNone || !m_floatingObjects)
3901 if (!m_floatingObjects)
3902 return LayoutUnit(); 3870 return LayoutUnit();
3903 3871
3872 FloatingObject::Type floatType =
3873 clear == ClearLeft ? FloatingObject::FloatLeft
3874 : clear == ClearRight ? FloatingObject::FloatRight
3875 : FloatingObject::FloatLeftRight;
3904 return m_floatingObjects->lowestFloatLogicalBottom(floatType); 3876 return m_floatingObjects->lowestFloatLogicalBottom(floatType);
3905 } 3877 }
3906 3878
3907 LayoutUnit LayoutBlockFlow::nextFloatLogicalBottomBelow( 3879 LayoutUnit LayoutBlockFlow::nextFloatLogicalBottomBelow(
3908 LayoutUnit logicalHeight) const { 3880 LayoutUnit logicalHeight) const {
3909 if (!m_floatingObjects) 3881 if (!m_floatingObjects)
3910 return logicalHeight; 3882 return logicalHeight;
3911 return m_floatingObjects->findNextFloatLogicalBottomBelow(logicalHeight); 3883 return m_floatingObjects->findNextFloatLogicalBottomBelow(logicalHeight);
3912 } 3884 }
3913 3885
(...skipping 656 matching lines...) Expand 10 before | Expand all | Expand 10 after
4570 return LayoutBlock::invalidatePaintIfNeeded(paintInvalidationState); 4542 return LayoutBlock::invalidatePaintIfNeeded(paintInvalidationState);
4571 } 4543 }
4572 4544
4573 void LayoutBlockFlow::invalidateDisplayItemClients( 4545 void LayoutBlockFlow::invalidateDisplayItemClients(
4574 PaintInvalidationReason invalidationReason) const { 4546 PaintInvalidationReason invalidationReason) const {
4575 BlockFlowPaintInvalidator(*this).invalidateDisplayItemClients( 4547 BlockFlowPaintInvalidator(*this).invalidateDisplayItemClients(
4576 invalidationReason); 4548 invalidationReason);
4577 } 4549 }
4578 4550
4579 } // namespace blink 4551 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutBlockFlow.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698