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

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

Issue 2701993002: DO NOT COMMIT: Results of running new (proposed) clang-format on Blink (Closed)
Patch Set: Created 3 years, 10 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) 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 352 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 for (LayoutBlock* cb = containingBlock(); !cb->isLayoutView(); 363 for (LayoutBlock* cb = containingBlock(); !cb->isLayoutView();
364 cb = cb->containingBlock()) { 364 cb = cb->containingBlock()) {
365 if (cb->style()->logicalHeight().isFixed() || cb->isTableCell()) 365 if (cb->style()->logicalHeight().isFixed() || cb->isTableCell())
366 hasAutoHeight = false; 366 hasAutoHeight = false;
367 } 367 }
368 } 368 }
369 369
370 // If the height is 0 or auto, then whether or not we are a self-collapsing 370 // If the height is 0 or auto, then whether or not we are a self-collapsing
371 // block depends on whether we have content that is all self-collapsing. 371 // block depends on whether we have content that is all self-collapsing.
372 // TODO(alancutter): Make this work correctly for calc lengths. 372 // TODO(alancutter): Make this work correctly for calc lengths.
373 if (hasAutoHeight || ((logicalHeightLength.isFixed() || 373 if (hasAutoHeight ||
374 logicalHeightLength.isPercentOrCalc()) && 374 ((logicalHeightLength.isFixed() ||
375 logicalHeightLength.isZero())) { 375 logicalHeightLength.isPercentOrCalc()) &&
376 logicalHeightLength.isZero())) {
376 // If the block has inline children, see if we generated any line boxes. 377 // If the block has inline children, see if we generated any line boxes.
377 // If we have any line boxes, then we can't be self-collapsing, since we 378 // If we have any line boxes, then we can't be self-collapsing, since we
378 // have content. 379 // have content.
379 if (childrenInline()) 380 if (childrenInline())
380 return !firstLineBox(); 381 return !firstLineBox();
381 382
382 // Whether or not we collapse is dependent on whether all our normal flow 383 // Whether or not we collapse is dependent on whether all our normal flow
383 // children are also self-collapsing. 384 // children are also self-collapsing.
384 for (LayoutBox* child = firstChildBox(); child; 385 for (LayoutBox* child = firstChildBox(); child;
385 child = child->nextSiblingBox()) { 386 child = child->nextSiblingBox()) {
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
634 // If the child is being centred then the margin calculated to do that has 635 // If the child is being centred then the margin calculated to do that has
635 // factored in any offset required to avoid floats, so use it if necessary. 636 // factored in any offset required to avoid floats, so use it if necessary.
636 if (style()->textAlign() == ETextAlign::kWebkitCenter || 637 if (style()->textAlign() == ETextAlign::kWebkitCenter ||
637 child.style()->marginStartUsing(style()).isAuto()) 638 child.style()->marginStartUsing(style()).isAuto())
638 newPosition = 639 newPosition =
639 std::max(newPosition, positionToAvoidFloats + childMarginStart); 640 std::max(newPosition, positionToAvoidFloats + childMarginStart);
640 else if (positionToAvoidFloats > initialStartPosition) 641 else if (positionToAvoidFloats > initialStartPosition)
641 newPosition = std::max(newPosition, positionToAvoidFloats); 642 newPosition = std::max(newPosition, positionToAvoidFloats);
642 } 643 }
643 644
644 setLogicalLeftForChild(child, style()->isLeftToRightDirection() 645 setLogicalLeftForChild(child,
645 ? newPosition 646 style()->isLeftToRightDirection()
646 : totalAvailableLogicalWidth - newPosition - 647 ? newPosition
647 logicalWidthForChild(child)); 648 : totalAvailableLogicalWidth - newPosition -
649 logicalWidthForChild(child));
648 } 650 }
649 651
650 void LayoutBlockFlow::setLogicalLeftForChild(LayoutBox& child, 652 void LayoutBlockFlow::setLogicalLeftForChild(LayoutBox& child,
651 LayoutUnit logicalLeft) { 653 LayoutUnit logicalLeft) {
652 if (isHorizontalWritingMode()) { 654 if (isHorizontalWritingMode()) {
653 child.setX(logicalLeft); 655 child.setX(logicalLeft);
654 } else { 656 } else {
655 child.setY(logicalLeft); 657 child.setY(logicalLeft);
656 } 658 }
657 } 659 }
(...skipping 638 matching lines...) Expand 10 before | Expand all | Expand 10 after
1296 if (!parent() || !parent()->isLayoutBlockFlow()) 1298 if (!parent() || !parent()->isLayoutBlockFlow())
1297 return; 1299 return;
1298 1300
1299 // Attempt to locate a previous sibling with overhanging floats. We skip any 1301 // Attempt to locate a previous sibling with overhanging floats. We skip any
1300 // elements that may have shifted to avoid floats, and any objects whose 1302 // elements that may have shifted to avoid floats, and any objects whose
1301 // floats cannot interact with objects outside it (i.e. objects that create a 1303 // floats cannot interact with objects outside it (i.e. objects that create a
1302 // new block formatting context). 1304 // new block formatting context).
1303 LayoutBlockFlow* parentBlockFlow = toLayoutBlockFlow(parent()); 1305 LayoutBlockFlow* parentBlockFlow = toLayoutBlockFlow(parent());
1304 bool siblingFloatMayIntrude = false; 1306 bool siblingFloatMayIntrude = false;
1305 LayoutObject* prev = previousSibling(); 1307 LayoutObject* prev = previousSibling();
1306 while (prev && (!prev->isBox() || !prev->isLayoutBlock() || 1308 while (prev &&
1307 toLayoutBlock(prev)->avoidsFloats() || 1309 (!prev->isBox() || !prev->isLayoutBlock() ||
1308 toLayoutBlock(prev)->createsNewFormattingContext())) { 1310 toLayoutBlock(prev)->avoidsFloats() ||
1311 toLayoutBlock(prev)->createsNewFormattingContext())) {
1309 if (prev->isFloating()) 1312 if (prev->isFloating())
1310 siblingFloatMayIntrude = true; 1313 siblingFloatMayIntrude = true;
1311 prev = prev->previousSibling(); 1314 prev = prev->previousSibling();
1312 } 1315 }
1313 1316
1314 // First add in floats from the parent. Self-collapsing blocks let their 1317 // First add in floats from the parent. Self-collapsing blocks let their
1315 // parent track any floats that intrude into them (as opposed to floats they 1318 // parent track any floats that intrude into them (as opposed to floats they
1316 // contain themselves) so check for those here too. If margin collapsing has 1319 // contain themselves) so check for those here too. If margin collapsing has
1317 // moved us up past the top a previous sibling then we need to check for 1320 // moved us up past the top a previous sibling then we need to check for
1318 // floats from the parent too. 1321 // floats from the parent too.
(...skipping 1350 matching lines...) Expand 10 before | Expand all | Expand 10 after
2669 void LayoutBlockFlow::markSiblingsWithFloatsForLayout( 2672 void LayoutBlockFlow::markSiblingsWithFloatsForLayout(
2670 LayoutBox* floatToRemove) { 2673 LayoutBox* floatToRemove) {
2671 if (!m_floatingObjects) 2674 if (!m_floatingObjects)
2672 return; 2675 return;
2673 2676
2674 const FloatingObjectSet& floatingObjectSet = m_floatingObjects->set(); 2677 const FloatingObjectSet& floatingObjectSet = m_floatingObjects->set();
2675 FloatingObjectSetIterator end = floatingObjectSet.end(); 2678 FloatingObjectSetIterator end = floatingObjectSet.end();
2676 2679
2677 for (LayoutObject* next = nextSibling(); next; next = next->nextSibling()) { 2680 for (LayoutObject* next = nextSibling(); next; next = next->nextSibling()) {
2678 if (!next->isLayoutBlockFlow() || 2681 if (!next->isLayoutBlockFlow() ||
2679 (!floatToRemove && (next->isFloatingOrOutOfFlowPositioned() || 2682 (!floatToRemove &&
2680 toLayoutBlockFlow(next)->avoidsFloats()))) 2683 (next->isFloatingOrOutOfFlowPositioned() ||
2684 toLayoutBlockFlow(next)->avoidsFloats())))
2681 continue; 2685 continue;
2682 2686
2683 LayoutBlockFlow* nextBlock = toLayoutBlockFlow(next); 2687 LayoutBlockFlow* nextBlock = toLayoutBlockFlow(next);
2684 for (FloatingObjectSetIterator it = floatingObjectSet.begin(); it != end; 2688 for (FloatingObjectSetIterator it = floatingObjectSet.begin(); it != end;
2685 ++it) { 2689 ++it) {
2686 LayoutBox* floatingBox = (*it)->layoutObject(); 2690 LayoutBox* floatingBox = (*it)->layoutObject();
2687 if (floatToRemove && floatingBox != floatToRemove) 2691 if (floatToRemove && floatingBox != floatToRemove)
2688 continue; 2692 continue;
2689 if (nextBlock->containsFloat(floatingBox)) 2693 if (nextBlock->containsFloat(floatingBox))
2690 nextBlock->markAllDescendantsWithFloatsForLayout(floatingBox); 2694 nextBlock->markAllDescendantsWithFloatsForLayout(floatingBox);
(...skipping 1068 matching lines...) Expand 10 before | Expand all | Expand 10 after
3759 child.layoutIfNeeded(); 3763 child.layoutIfNeeded();
3760 } 3764 }
3761 } 3765 }
3762 3766
3763 LayoutUnit childLogicalLeftMargin = 3767 LayoutUnit childLogicalLeftMargin =
3764 style()->isLeftToRightDirection() ? marginStart : marginEnd; 3768 style()->isLeftToRightDirection() ? marginStart : marginEnd;
3765 setLogicalLeftForChild(child, 3769 setLogicalLeftForChild(child,
3766 floatLogicalLocation.x() + childLogicalLeftMargin); 3770 floatLogicalLocation.x() + childLogicalLeftMargin);
3767 setLogicalLeftForFloat(floatingObject, floatLogicalLocation.x()); 3771 setLogicalLeftForFloat(floatingObject, floatLogicalLocation.x());
3768 setLogicalTopForFloat(floatingObject, logicalTopMarginEdge); 3772 setLogicalTopForFloat(floatingObject, logicalTopMarginEdge);
3769 setLogicalHeightForFloat(floatingObject, logicalHeightForChild(child) + 3773 setLogicalHeightForFloat(
3770 marginBefore + marginAfter); 3774 floatingObject,
3775 logicalHeightForChild(child) + marginBefore + marginAfter);
3771 3776
3772 if (ShapeOutsideInfo* shapeOutside = child.shapeOutsideInfo()) 3777 if (ShapeOutsideInfo* shapeOutside = child.shapeOutsideInfo())
3773 shapeOutside->setReferenceBoxLogicalSize(logicalSizeForChild(child)); 3778 shapeOutside->setReferenceBoxLogicalSize(logicalSizeForChild(child));
3774 3779
3775 return logicalTopMarginEdge; 3780 return logicalTopMarginEdge;
3776 } 3781 }
3777 3782
3778 bool LayoutBlockFlow::hasOverhangingFloat(LayoutBox* layoutBox) { 3783 bool LayoutBlockFlow::hasOverhangingFloat(LayoutBox* layoutBox) {
3779 if (!m_floatingObjects || !parent()) 3784 if (!m_floatingObjects || !parent())
3780 return false; 3785 return false;
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
3818 createFloatingObjects(); 3823 createFloatingObjects();
3819 3824
3820 // Applying the child's margin makes no sense in the case where the 3825 // Applying the child's margin makes no sense in the case where the
3821 // child was passed in since this margin was added already through the 3826 // child was passed in since this margin was added already through the
3822 // modification of the |logicalLeftOffset| variable above. 3827 // modification of the |logicalLeftOffset| variable above.
3823 // |logicalLeftOffset| will equal the margin in this case, so it's 3828 // |logicalLeftOffset| will equal the margin in this case, so it's
3824 // already been taken into account. Only apply this code if prev is the 3829 // already been taken into account. Only apply this code if prev is the
3825 // parent, since otherwise the left margin will get applied twice. 3830 // parent, since otherwise the left margin will get applied twice.
3826 LayoutSize offset = 3831 LayoutSize offset =
3827 isHorizontalWritingMode() 3832 isHorizontalWritingMode()
3828 ? LayoutSize( 3833 ? LayoutSize(logicalLeftOffset -
3829 logicalLeftOffset - (prev != parent() ? prev->marginLeft() 3834 (prev != parent() ? prev->marginLeft()
3830 : LayoutUnit()), 3835 : LayoutUnit()),
3831 logicalTopOffset) 3836 logicalTopOffset)
3832 : LayoutSize( 3837 : LayoutSize(logicalTopOffset,
3833 logicalTopOffset, 3838 logicalLeftOffset -
3834 logicalLeftOffset - (prev != parent() ? prev->marginTop() 3839 (prev != parent() ? prev->marginTop()
3835 : LayoutUnit())); 3840 : LayoutUnit()));
3836 3841
3837 m_floatingObjects->add(floatingObject.copyToNewContainer(offset)); 3842 m_floatingObjects->add(floatingObject.copyToNewContainer(offset));
3838 } 3843 }
3839 } 3844 }
3840 } 3845 }
3841 } 3846 }
3842 3847
3843 void LayoutBlockFlow::addOverhangingFloats(LayoutBlockFlow* child, 3848 void LayoutBlockFlow::addOverhangingFloats(LayoutBlockFlow* child,
3844 bool makeChildPaintOtherFloats) { 3849 bool makeChildPaintOtherFloats) {
3845 // Prevent floats from being added to the canvas by the root element, e.g., 3850 // Prevent floats from being added to the canvas by the root element, e.g.,
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
3967 3972
3968 if (hitTestAction == HitTestFloat && 3973 if (hitTestAction == HitTestFloat &&
3969 hitTestFloats(result, locationInContainer, scrolledOffset)) 3974 hitTestFloats(result, locationInContainer, scrolledOffset))
3970 return true; 3975 return true;
3971 3976
3972 if (childrenInline()) { 3977 if (childrenInline()) {
3973 if (m_lineBoxes.hitTest(LineLayoutBoxModel(this), result, 3978 if (m_lineBoxes.hitTest(LineLayoutBoxModel(this), result,
3974 locationInContainer, scrolledOffset, 3979 locationInContainer, scrolledOffset,
3975 hitTestAction)) { 3980 hitTestAction)) {
3976 updateHitTestResult( 3981 updateHitTestResult(
3977 result, flipForWritingMode(toLayoutPoint(locationInContainer.point() - 3982 result,
3978 accumulatedOffset))); 3983 flipForWritingMode(
3984 toLayoutPoint(locationInContainer.point() - accumulatedOffset)));
3979 return true; 3985 return true;
3980 } 3986 }
3981 } else if (LayoutBlock::hitTestChildren(result, locationInContainer, 3987 } else if (LayoutBlock::hitTestChildren(result, locationInContainer,
3982 accumulatedOffset, hitTestAction)) { 3988 accumulatedOffset, hitTestAction)) {
3983 return true; 3989 return true;
3984 } 3990 }
3985 3991
3986 return false; 3992 return false;
3987 } 3993 }
3988 3994
(...skipping 595 matching lines...) Expand 10 before | Expand all | Expand 10 after
4584 std::min<LayoutUnit>(curr->lineBottom(), curr->y() + curr->height()); 4590 std::min<LayoutUnit>(curr->lineBottom(), curr->y() + curr->height());
4585 LayoutRect rect(additionalOffset.x() + curr->x(), 4591 LayoutRect rect(additionalOffset.x() + curr->x(),
4586 additionalOffset.y() + top, curr->width(), bottom - top); 4592 additionalOffset.y() + top, curr->width(), bottom - top);
4587 if (!rect.isEmpty()) 4593 if (!rect.isEmpty())
4588 rects.push_back(rect); 4594 rects.push_back(rect);
4589 } 4595 }
4590 } 4596 }
4591 4597
4592 if (inlineElementContinuation) 4598 if (inlineElementContinuation)
4593 inlineElementContinuation->addOutlineRects( 4599 inlineElementContinuation->addOutlineRects(
4594 rects, additionalOffset + 4600 rects,
4595 (inlineElementContinuation->containingBlock()->location() - 4601 additionalOffset +
4596 location()), 4602 (inlineElementContinuation->containingBlock()->location() -
4603 location()),
4597 includeBlockOverflows); 4604 includeBlockOverflows);
4598 } 4605 }
4599 4606
4600 PaintInvalidationReason LayoutBlockFlow::invalidatePaintIfNeeded( 4607 PaintInvalidationReason LayoutBlockFlow::invalidatePaintIfNeeded(
4601 const PaintInvalidationState& paintInvalidationState) { 4608 const PaintInvalidationState& paintInvalidationState) {
4602 if (containsFloats()) 4609 if (containsFloats())
4603 paintInvalidationState.paintingLayer().setNeedsPaintPhaseFloat(); 4610 paintInvalidationState.paintingLayer().setNeedsPaintPhaseFloat();
4604 4611
4605 return LayoutBlock::invalidatePaintIfNeeded(paintInvalidationState); 4612 return LayoutBlock::invalidatePaintIfNeeded(paintInvalidationState);
4606 } 4613 }
4607 4614
4608 void LayoutBlockFlow::invalidateDisplayItemClients( 4615 void LayoutBlockFlow::invalidateDisplayItemClients(
4609 PaintInvalidationReason invalidationReason) const { 4616 PaintInvalidationReason invalidationReason) const {
4610 BlockFlowPaintInvalidator(*this).invalidateDisplayItemClients( 4617 BlockFlowPaintInvalidator(*this).invalidateDisplayItemClients(
4611 invalidationReason); 4618 invalidationReason);
4612 } 4619 }
4613 4620
4614 } // namespace blink 4621 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutBlockFlow.h ('k') | third_party/WebKit/Source/core/layout/LayoutBlockFlowLine.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698