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

Side by Side Diff: third_party/WebKit/Source/core/layout/LayoutDeprecatedFlexibleBox.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 * This file is part of the layout object implementation for KHTML. 2 * This file is part of the layout object implementation for KHTML.
3 * 3 *
4 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 4 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
5 * (C) 1999 Antti Koivisto (koivisto@kde.org) 5 * (C) 1999 Antti Koivisto (koivisto@kde.org)
6 * Copyright (C) 2003 Apple Computer, Inc. 6 * Copyright (C) 2003 Apple Computer, Inc.
7 * 7 *
8 * This library is free software; you can redistribute it and/or 8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public 9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
(...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after
469 LayoutUnit maxAscent; 469 LayoutUnit maxAscent;
470 LayoutUnit maxDescent; 470 LayoutUnit maxDescent;
471 for (LayoutBox* child = iterator.first(); child; child = iterator.next()) { 471 for (LayoutBox* child = iterator.first(); child; child = iterator.next()) {
472 if (child->isOutOfFlowPositioned()) 472 if (child->isOutOfFlowPositioned())
473 continue; 473 continue;
474 474
475 SubtreeLayoutScope layoutScope(*child); 475 SubtreeLayoutScope layoutScope(*child);
476 // TODO(jchaffraix): It seems incorrect to check isAtomicInlineLevel in 476 // TODO(jchaffraix): It seems incorrect to check isAtomicInlineLevel in
477 // this file. 477 // this file.
478 // We probably want to check if the element is replaced. 478 // We probably want to check if the element is replaced.
479 if (relayoutChildren || (child->isAtomicInlineLevel() && 479 if (relayoutChildren ||
480 (child->style()->width().isPercentOrCalc() || 480 (child->isAtomicInlineLevel() &&
481 child->style()->height().isPercentOrCalc()))) 481 (child->style()->width().isPercentOrCalc() ||
482 child->style()->height().isPercentOrCalc())))
482 layoutScope.setChildNeedsLayout(child); 483 layoutScope.setChildNeedsLayout(child);
483 484
484 // Compute the child's vertical margins. 485 // Compute the child's vertical margins.
485 child->computeAndSetBlockDirectionMargins(this); 486 child->computeAndSetBlockDirectionMargins(this);
486 487
487 if (!child->needsLayout()) 488 if (!child->needsLayout())
488 markChildForPaginationRelayoutIfNeeded(*child, layoutScope); 489 markChildForPaginationRelayoutIfNeeded(*child, layoutScope);
489 490
490 // Now do the layout. 491 // Now do the layout.
491 child->layoutIfNeeded(); 492 child->layoutIfNeeded();
492 493
493 // Update our height and overflow height. 494 // Update our height and overflow height.
494 if (style()->boxAlign() == BBASELINE) { 495 if (style()->boxAlign() == BBASELINE) {
495 LayoutUnit ascent(child->firstLineBoxBaseline()); 496 LayoutUnit ascent(child->firstLineBoxBaseline());
496 if (ascent == -1) 497 if (ascent == -1)
497 ascent = child->size().height() + child->marginBottom(); 498 ascent = child->size().height() + child->marginBottom();
498 ascent += child->marginTop(); 499 ascent += child->marginTop();
499 LayoutUnit descent = 500 LayoutUnit descent =
500 (child->size().height() + child->marginHeight()) - ascent; 501 (child->size().height() + child->marginHeight()) - ascent;
501 502
502 // Update our maximum ascent. 503 // Update our maximum ascent.
503 maxAscent = std::max(maxAscent, ascent); 504 maxAscent = std::max(maxAscent, ascent);
504 505
505 // Update our maximum descent. 506 // Update our maximum descent.
506 maxDescent = std::max(maxDescent, descent); 507 maxDescent = std::max(maxDescent, descent);
507 508
508 // Now update our height. 509 // Now update our height.
509 setHeight(std::max(yPos + maxAscent + maxDescent, size().height())); 510 setHeight(std::max(yPos + maxAscent + maxDescent, size().height()));
510 } else { 511 } else {
511 setHeight(std::max(size().height(), yPos + child->size().height() + 512 setHeight(
512 child->marginHeight())); 513 std::max(size().height(),
514 yPos + child->size().height() + child->marginHeight()));
513 } 515 }
514 516
515 if (paginated) 517 if (paginated)
516 updateFragmentationInfoForChild(*child); 518 updateFragmentationInfoForChild(*child);
517 } 519 }
518 520
519 if (!iterator.first() && hasLineIfEmpty()) 521 if (!iterator.first() && hasLineIfEmpty())
520 setHeight(size().height() + lineHeight(true, 522 setHeight(size().height() +
521 style()->isHorizontalWritingMode() 523 lineHeight(true,
522 ? HorizontalLine 524 style()->isHorizontalWritingMode() ? HorizontalLine
523 : VerticalLine, 525 : VerticalLine,
524 PositionOfInteriorLineBoxes)); 526 PositionOfInteriorLineBoxes));
525 527
526 setHeight(size().height() + toAdd); 528 setHeight(size().height() + toAdd);
527 529
528 oldHeight = size().height(); 530 oldHeight = size().height();
529 updateLogicalHeight(); 531 updateLogicalHeight();
530 532
531 relayoutChildren = false; 533 relayoutChildren = false;
532 if (oldHeight != size().height()) 534 if (oldHeight != size().height())
533 heightSpecified = true; 535 heightSpecified = true;
534 536
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
576 child->layoutIfNeeded(); 578 child->layoutIfNeeded();
577 579
578 // We can place the child now, using our value of box-align. 580 // We can place the child now, using our value of box-align.
579 xPos += child->marginLeft(); 581 xPos += child->marginLeft();
580 LayoutUnit childY = yPos; 582 LayoutUnit childY = yPos;
581 switch (style()->boxAlign()) { 583 switch (style()->boxAlign()) {
582 case BCENTER: 584 case BCENTER:
583 childY += child->marginTop() + 585 childY += child->marginTop() +
584 ((contentHeight() - 586 ((contentHeight() -
585 (child->size().height() + child->marginHeight())) / 587 (child->size().height() + child->marginHeight())) /
586 2).clampNegativeToZero(); 588 2)
589 .clampNegativeToZero();
587 break; 590 break;
588 case BBASELINE: { 591 case BBASELINE: {
589 LayoutUnit ascent(child->firstLineBoxBaseline()); 592 LayoutUnit ascent(child->firstLineBoxBaseline());
590 if (ascent == -1) 593 if (ascent == -1)
591 ascent = child->size().height() + child->marginBottom(); 594 ascent = child->size().height() + child->marginBottom();
592 ascent += child->marginTop(); 595 ascent += child->marginTop();
593 childY += child->marginTop() + (maxAscent - ascent); 596 childY += child->marginTop() + (maxAscent - ascent);
594 break; 597 break;
595 } 598 }
596 case BEND: 599 case BEND:
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
711 } 714 }
712 } while (absoluteValue(groupRemainingSpace) >= 1); 715 } while (absoluteValue(groupRemainingSpace) >= 1);
713 } 716 }
714 717
715 // We didn't find any children that could grow. 718 // We didn't find any children that could grow.
716 if (haveFlex && !flexingChildren) 719 if (haveFlex && !flexingChildren)
717 haveFlex = false; 720 haveFlex = false;
718 } 721 }
719 } while (haveFlex); 722 } while (haveFlex);
720 723
721 if (remainingSpace > 0 && ((style()->isLeftToRightDirection() && 724 if (remainingSpace > 0 &&
722 style()->boxPack() != BoxPackStart) || 725 ((style()->isLeftToRightDirection() &&
723 (!style()->isLeftToRightDirection() && 726 style()->boxPack() != BoxPackStart) ||
724 style()->boxPack() != BoxPackEnd))) { 727 (!style()->isLeftToRightDirection() &&
728 style()->boxPack() != BoxPackEnd))) {
725 // Children must be repositioned. 729 // Children must be repositioned.
726 LayoutUnit offset; 730 LayoutUnit offset;
727 if (style()->boxPack() == BoxPackJustify) { 731 if (style()->boxPack() == BoxPackJustify) {
728 // Determine the total number of children. 732 // Determine the total number of children.
729 int totalChildren = 0; 733 int totalChildren = 0;
730 for (LayoutBox* child = iterator.first(); child; 734 for (LayoutBox* child = iterator.first(); child;
731 child = iterator.next()) { 735 child = iterator.next()) {
732 if (childDoesNotAffectWidthOrFlexing(child)) 736 if (childDoesNotAffectWidthOrFlexing(child))
733 continue; 737 continue;
734 ++totalChildren; 738 ++totalChildren;
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
822 childLayer->setStaticBlockPosition(size().height()); 826 childLayer->setStaticBlockPosition(size().height());
823 if (child->style()->hasStaticBlockPosition( 827 if (child->style()->hasStaticBlockPosition(
824 style()->isHorizontalWritingMode())) 828 style()->isHorizontalWritingMode()))
825 child->setChildNeedsLayout(MarkOnlyThis); 829 child->setChildNeedsLayout(MarkOnlyThis);
826 } 830 }
827 continue; 831 continue;
828 } 832 }
829 833
830 SubtreeLayoutScope layoutScope(*child); 834 SubtreeLayoutScope layoutScope(*child);
831 if (!haveLineClamp && 835 if (!haveLineClamp &&
832 (relayoutChildren || (child->isAtomicInlineLevel() && 836 (relayoutChildren ||
833 (child->style()->width().isPercentOrCalc() || 837 (child->isAtomicInlineLevel() &&
834 child->style()->height().isPercentOrCalc())))) 838 (child->style()->width().isPercentOrCalc() ||
839 child->style()->height().isPercentOrCalc()))))
835 layoutScope.setChildNeedsLayout(child); 840 layoutScope.setChildNeedsLayout(child);
836 841
837 if (child->style()->visibility() == EVisibility::kCollapse) { 842 if (child->style()->visibility() == EVisibility::kCollapse) {
838 // visibility: collapsed children do not participate in our positioning. 843 // visibility: collapsed children do not participate in our positioning.
839 // But we need to lay them down. 844 // But we need to lay them down.
840 child->layoutIfNeeded(); 845 child->layoutIfNeeded();
841 continue; 846 continue;
842 } 847 }
843 848
844 // Compute the child's vertical margins. 849 // Compute the child's vertical margins.
845 child->computeAndSetBlockDirectionMargins(this); 850 child->computeAndSetBlockDirectionMargins(this);
846 851
847 // Add in the child's marginTop to our height. 852 // Add in the child's marginTop to our height.
848 setHeight(size().height() + child->marginTop()); 853 setHeight(size().height() + child->marginTop());
849 854
850 if (!child->needsLayout()) 855 if (!child->needsLayout())
851 markChildForPaginationRelayoutIfNeeded(*child, layoutScope); 856 markChildForPaginationRelayoutIfNeeded(*child, layoutScope);
852 857
853 // Now do a layout. 858 // Now do a layout.
854 child->layoutIfNeeded(); 859 child->layoutIfNeeded();
855 860
856 // We can place the child now, using our value of box-align. 861 // We can place the child now, using our value of box-align.
857 LayoutUnit childX = borderLeft() + paddingLeft(); 862 LayoutUnit childX = borderLeft() + paddingLeft();
858 switch (style()->boxAlign()) { 863 switch (style()->boxAlign()) {
859 case BCENTER: 864 case BCENTER:
860 case BBASELINE: // Baseline just maps to center for vertical boxes 865 case BBASELINE: // Baseline just maps to center for vertical boxes
861 childX += child->marginLeft() + 866 childX += child->marginLeft() +
862 ((contentWidth() - 867 ((contentWidth() -
863 (child->size().width() + child->marginWidth())) / 868 (child->size().width() + child->marginWidth())) /
864 2).clampNegativeToZero(); 869 2)
870 .clampNegativeToZero();
865 break; 871 break;
866 case BEND: 872 case BEND:
867 if (!style()->isLeftToRightDirection()) 873 if (!style()->isLeftToRightDirection())
868 childX += child->marginLeft(); 874 childX += child->marginLeft();
869 else 875 else
870 childX += 876 childX +=
871 contentWidth() - child->marginRight() - child->size().width(); 877 contentWidth() - child->marginRight() - child->size().width();
872 break; 878 break;
873 default: // BSTART/BSTRETCH 879 default: // BSTART/BSTRETCH
874 if (style()->isLeftToRightDirection()) 880 if (style()->isLeftToRightDirection())
875 childX += child->marginLeft(); 881 childX += child->marginLeft();
876 else 882 else
877 childX += 883 childX +=
878 contentWidth() - child->marginRight() - child->size().width(); 884 contentWidth() - child->marginRight() - child->size().width();
879 break; 885 break;
880 } 886 }
881 887
882 // Place the child. 888 // Place the child.
883 placeChild(child, LayoutPoint(childX, size().height())); 889 placeChild(child, LayoutPoint(childX, size().height()));
884 setHeight(size().height() + child->size().height() + 890 setHeight(size().height() + child->size().height() +
885 child->marginBottom()); 891 child->marginBottom());
886 892
887 if (paginated) 893 if (paginated)
888 updateFragmentationInfoForChild(*child); 894 updateFragmentationInfoForChild(*child);
889 } 895 }
890 896
891 yPos = size().height(); 897 yPos = size().height();
892 898
893 if (!iterator.first() && hasLineIfEmpty()) 899 if (!iterator.first() && hasLineIfEmpty())
894 setHeight(size().height() + lineHeight(true, 900 setHeight(size().height() +
895 style()->isHorizontalWritingMode() 901 lineHeight(true,
896 ? HorizontalLine 902 style()->isHorizontalWritingMode() ? HorizontalLine
897 : VerticalLine, 903 : VerticalLine,
898 PositionOfInteriorLineBoxes)); 904 PositionOfInteriorLineBoxes));
899 905
900 setHeight(size().height() + toAdd); 906 setHeight(size().height() + toAdd);
901 907
902 // Negative margins can cause our height to shrink below our minimal height 908 // Negative margins can cause our height to shrink below our minimal height
903 // (border/padding). If this happens, ensure that the computed height is 909 // (border/padding). If this happens, ensure that the computed height is
904 // increased to the minimal height. 910 // increased to the minimal height.
905 if (size().height() < minHeight) 911 if (size().height() < minHeight)
906 setHeight(minHeight); 912 setHeight(minHeight);
907 913
908 // Now we have to calc our height, so we know how much space we have 914 // Now we have to calc our height, so we know how much space we have
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
1080 void LayoutDeprecatedFlexibleBox::applyLineClamp(FlexBoxIterator& iterator, 1086 void LayoutDeprecatedFlexibleBox::applyLineClamp(FlexBoxIterator& iterator,
1081 bool relayoutChildren) { 1087 bool relayoutChildren) {
1082 UseCounter::count(document(), UseCounter::LineClamp); 1088 UseCounter::count(document(), UseCounter::LineClamp);
1083 1089
1084 int maxLineCount = 0; 1090 int maxLineCount = 0;
1085 for (LayoutBox* child = iterator.first(); child; child = iterator.next()) { 1091 for (LayoutBox* child = iterator.first(); child; child = iterator.next()) {
1086 if (childDoesNotAffectWidthOrFlexing(child)) 1092 if (childDoesNotAffectWidthOrFlexing(child))
1087 continue; 1093 continue;
1088 1094
1089 child->clearOverrideSize(); 1095 child->clearOverrideSize();
1090 if (relayoutChildren || (child->isAtomicInlineLevel() && 1096 if (relayoutChildren ||
1091 (child->style()->width().isPercentOrCalc() || 1097 (child->isAtomicInlineLevel() &&
1092 child->style()->height().isPercentOrCalc())) || 1098 (child->style()->width().isPercentOrCalc() ||
1099 child->style()->height().isPercentOrCalc())) ||
1093 (child->style()->height().isAuto() && child->isLayoutBlock())) { 1100 (child->style()->height().isAuto() && child->isLayoutBlock())) {
1094 child->setChildNeedsLayout(MarkOnlyThis); 1101 child->setChildNeedsLayout(MarkOnlyThis);
1095 1102
1096 // Dirty all the positioned objects. 1103 // Dirty all the positioned objects.
1097 if (child->isLayoutBlockFlow()) { 1104 if (child->isLayoutBlockFlow()) {
1098 toLayoutBlockFlow(child)->markPositionedObjectsForLayout(); 1105 toLayoutBlockFlow(child)->markPositionedObjectsForLayout();
1099 clearTruncation(toLayoutBlockFlow(child)); 1106 clearTruncation(toLayoutBlockFlow(child));
1100 } 1107 }
1101 } 1108 }
1102 child->layoutIfNeeded(); 1109 child->layoutIfNeeded();
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
1265 if (minHeight.isFixed() || minHeight.isAuto()) { 1272 if (minHeight.isFixed() || minHeight.isAuto()) {
1266 LayoutUnit minHeight(child->style()->minHeight().value()); 1273 LayoutUnit minHeight(child->style()->minHeight().value());
1267 LayoutUnit height = contentHeightForChild(child); 1274 LayoutUnit height = contentHeightForChild(child);
1268 LayoutUnit allowedShrinkage = (minHeight - height).clampPositiveToZero(); 1275 LayoutUnit allowedShrinkage = (minHeight - height).clampPositiveToZero();
1269 return allowedShrinkage; 1276 return allowedShrinkage;
1270 } 1277 }
1271 return LayoutUnit(); 1278 return LayoutUnit();
1272 } 1279 }
1273 1280
1274 } // namespace blink 1281 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutCounter.cpp ('k') | third_party/WebKit/Source/core/layout/LayoutFieldset.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698