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

Side by Side Diff: Source/WebCore/rendering/RenderDeprecatedFlexibleBox.cpp

Issue 8477022: Merge 98033 (Closed) Base URL: http://svn.webkit.org/repository/webkit/branches/chromium/874/
Patch Set: Created 9 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 | « LayoutTests/platform/qt/fast/flexbox/021-expected.txt ('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 * This file is part of the render object implementation for KHTML. 2 * This file is part of the render 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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 m_currentOrdinal = m_forward ? m_sortedOrdinalValues[m_ordin alIteration - 1] : m_sortedOrdinalValues[m_sortedOrdinalValues.size() - m_ordina lIteration]; 90 m_currentOrdinal = m_forward ? m_sortedOrdinalValues[m_ordin alIteration - 1] : m_sortedOrdinalValues[m_sortedOrdinalValues.size() - m_ordina lIteration];
91 } 91 }
92 92
93 m_currentChild = m_forward ? m_box->firstChildBox() : m_box->las tChildBox(); 93 m_currentChild = m_forward ? m_box->firstChildBox() : m_box->las tChildBox();
94 } else 94 } else
95 m_currentChild = m_forward ? m_currentChild->nextSiblingBox() : m_currentChild->previousSiblingBox(); 95 m_currentChild = m_forward ? m_currentChild->nextSiblingBox() : m_currentChild->previousSiblingBox();
96 96
97 if (m_currentChild && notFirstOrdinalValue()) 97 if (m_currentChild && notFirstOrdinalValue())
98 m_ordinalValues.add(m_currentChild->style()->boxOrdinalGroup()); 98 m_ordinalValues.add(m_currentChild->style()->boxOrdinalGroup());
99 } while (!m_currentChild || (!m_currentChild->isAnonymous() 99 } while (!m_currentChild || (!m_currentChild->isAnonymous()
100 && (m_currentChild->style()->boxOrdinalGroup() != m_currentOrdi nal || m_currentChild->style()->visibility() == COLLAPSE))); 100 && m_currentChild->style()->boxOrdinalGroup() != m_currentOrdin al));
101 return m_currentChild; 101 return m_currentChild;
102 } 102 }
103 103
104 private: 104 private:
105 bool notFirstOrdinalValue() 105 bool notFirstOrdinalValue()
106 { 106 {
107 unsigned int firstOrdinalValue = m_forward ? 1 : m_largestOrdinal; 107 unsigned int firstOrdinalValue = m_forward ? 1 : m_largestOrdinal;
108 return m_currentOrdinal == firstOrdinalValue && m_currentChild->style()- >boxOrdinalGroup() != firstOrdinalValue; 108 return m_currentOrdinal == firstOrdinalValue && m_currentChild->style()- >boxOrdinalGroup() != firstOrdinalValue;
109 } 109 }
110 110
(...skipping 26 matching lines...) Expand all
137 Length marginLeft = child->style()->marginLeft(); 137 Length marginLeft = child->style()->marginLeft();
138 Length marginRight = child->style()->marginRight(); 138 Length marginRight = child->style()->marginRight();
139 int margin = 0; 139 int margin = 0;
140 if (marginLeft.isFixed()) 140 if (marginLeft.isFixed())
141 margin += marginLeft.value(); 141 margin += marginLeft.value();
142 if (marginRight.isFixed()) 142 if (marginRight.isFixed())
143 margin += marginRight.value(); 143 margin += marginRight.value();
144 return margin; 144 return margin;
145 } 145 }
146 146
147 static bool childDoesNotAffectWidthOrFlexing(RenderObject* child)
148 {
149 // Positioned children and collapsed children don't affect the min/max width .
150 return child->isPositioned() || child->style()->visibility() == COLLAPSE;
151 }
152
147 void RenderDeprecatedFlexibleBox::calcHorizontalPrefWidths() 153 void RenderDeprecatedFlexibleBox::calcHorizontalPrefWidths()
148 { 154 {
149 for (RenderBox* child = firstChildBox(); child; child = child->nextSiblingBo x()) { 155 for (RenderBox* child = firstChildBox(); child; child = child->nextSiblingBo x()) {
150 // Positioned children and collapsed children don't affect the min/max w idth. 156 if (childDoesNotAffectWidthOrFlexing(child))
151 if (child->isPositioned() || child->style()->visibility() == COLLAPSE)
152 continue; 157 continue;
153 158
154 LayoutUnit margin = marginWidthForChild(child); 159 LayoutUnit margin = marginWidthForChild(child);
155 m_minPreferredLogicalWidth += child->minPreferredLogicalWidth() + margin ; 160 m_minPreferredLogicalWidth += child->minPreferredLogicalWidth() + margin ;
156 m_maxPreferredLogicalWidth += child->maxPreferredLogicalWidth() + margin ; 161 m_maxPreferredLogicalWidth += child->maxPreferredLogicalWidth() + margin ;
157 } 162 }
158 } 163 }
159 164
160 void RenderDeprecatedFlexibleBox::calcVerticalPrefWidths() 165 void RenderDeprecatedFlexibleBox::calcVerticalPrefWidths()
161 { 166 {
162 for (RenderBox* child = firstChildBox(); child; child = child->nextSiblingBo x()) { 167 for (RenderBox* child = firstChildBox(); child; child = child->nextSiblingBo x()) {
163 // Positioned children and collapsed children don't affect the min/max w idth. 168 if (childDoesNotAffectWidthOrFlexing(child))
164 if (child->isPositioned() || child->style()->visibility() == COLLAPSE)
165 continue; 169 continue;
166 170
167 LayoutUnit margin = marginWidthForChild(child); 171 LayoutUnit margin = marginWidthForChild(child);
168 LayoutUnit width = child->minPreferredLogicalWidth() + margin; 172 LayoutUnit width = child->minPreferredLogicalWidth() + margin;
169 m_minPreferredLogicalWidth = max(width, m_minPreferredLogicalWidth); 173 m_minPreferredLogicalWidth = max(width, m_minPreferredLogicalWidth);
170 174
171 width = child->maxPreferredLogicalWidth() + margin; 175 width = child->maxPreferredLogicalWidth() + margin;
172 m_maxPreferredLogicalWidth = max(width, m_maxPreferredLogicalWidth); 176 m_maxPreferredLogicalWidth = max(width, m_maxPreferredLogicalWidth);
173 } 177 }
174 } 178 }
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 layoutBlock(false, pageLogicalHeight); 307 layoutBlock(false, pageLogicalHeight);
304 } else 308 } else
305 setNeedsLayout(false); 309 setNeedsLayout(false);
306 } 310 }
307 311
308 // The first walk over our kids is to find out if we have any flexible children. 312 // The first walk over our kids is to find out if we have any flexible children.
309 static void gatherFlexChildrenInfo(FlexBoxIterator& iterator, bool relayoutChild ren, unsigned int& highestFlexGroup, unsigned int& lowestFlexGroup, bool& haveFl ex) 313 static void gatherFlexChildrenInfo(FlexBoxIterator& iterator, bool relayoutChild ren, unsigned int& highestFlexGroup, unsigned int& lowestFlexGroup, bool& haveFl ex)
310 { 314 {
311 for (RenderBox* child = iterator.first(); child; child = iterator.next()) { 315 for (RenderBox* child = iterator.first(); child; child = iterator.next()) {
312 // Check to see if this child flexes. 316 // Check to see if this child flexes.
313 if (!child->isPositioned() && child->style()->boxFlex() > 0.0f) { 317 if (!childDoesNotAffectWidthOrFlexing(child) && child->style()->boxFlex( ) > 0.0f) {
314 // We always have to lay out flexible objects again, since the flex distribution 318 // We always have to lay out flexible objects again, since the flex distribution
315 // may have changed, and we need to reallocate space. 319 // may have changed, and we need to reallocate space.
316 child->clearOverrideSize(); 320 child->clearOverrideSize();
317 if (!relayoutChildren) 321 if (!relayoutChildren)
318 child->setChildNeedsLayout(true, false); 322 child->setChildNeedsLayout(true, false);
319 haveFlex = true; 323 haveFlex = true;
320 unsigned int flexGroup = child->style()->boxFlexGroup(); 324 unsigned int flexGroup = child->style()->boxFlexGroup();
321 if (lowestFlexGroup == 0) 325 if (lowestFlexGroup == 0)
322 lowestFlexGroup = flexGroup; 326 lowestFlexGroup = flexGroup;
323 if (flexGroup < lowestFlexGroup) 327 if (flexGroup < lowestFlexGroup)
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 if (child->isPositioned()) { 419 if (child->isPositioned()) {
416 child->containingBlock()->insertPositionedObject(child); 420 child->containingBlock()->insertPositionedObject(child);
417 RenderLayer* childLayer = child->layer(); 421 RenderLayer* childLayer = child->layer();
418 childLayer->setStaticInlinePosition(xPos); 422 childLayer->setStaticInlinePosition(xPos);
419 if (childLayer->staticBlockPosition() != yPos) { 423 if (childLayer->staticBlockPosition() != yPos) {
420 childLayer->setStaticBlockPosition(yPos); 424 childLayer->setStaticBlockPosition(yPos);
421 if (child->style()->hasStaticBlockPosition(style()->isHorizo ntalWritingMode())) 425 if (child->style()->hasStaticBlockPosition(style()->isHorizo ntalWritingMode()))
422 child->setChildNeedsLayout(true, false); 426 child->setChildNeedsLayout(true, false);
423 } 427 }
424 continue; 428 continue;
429 } else if (child->style()->visibility() == COLLAPSE) {
430 // visibility: collapsed children do not participate in our posi tioning.
431 // But we need to lay them down.
432 child->layoutIfNeeded();
433 continue;
425 } 434 }
426 435
436
427 // We need to see if this child's height has changed, since we make block elements 437 // We need to see if this child's height has changed, since we make block elements
428 // fill the height of a containing box by default. 438 // fill the height of a containing box by default.
429 // Now do a layout. 439 // Now do a layout.
430 LayoutUnit oldChildHeight = child->height(); 440 LayoutUnit oldChildHeight = child->height();
431 child->computeLogicalHeight(); 441 child->computeLogicalHeight();
432 if (oldChildHeight != child->height()) 442 if (oldChildHeight != child->height())
433 child->setChildNeedsLayout(true, false); 443 child->setChildNeedsLayout(true, false);
434 444
435 if (!child->needsLayout()) 445 if (!child->needsLayout())
436 child->markForPaginationRelayoutIfNeeded(); 446 child->markForPaginationRelayoutIfNeeded();
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
506 516
507 // The flex groups may not have any flexible objects this ti me around. 517 // The flex groups may not have any flexible objects this ti me around.
508 if (!spaceAvailableThisPass || totalFlex == 0.0f) { 518 if (!spaceAvailableThisPass || totalFlex == 0.0f) {
509 // If we just couldn't grow/shrink any more, then it's t ime to transition to the next flex group. 519 // If we just couldn't grow/shrink any more, then it's t ime to transition to the next flex group.
510 groupRemainingSpace = 0; 520 groupRemainingSpace = 0;
511 continue; 521 continue;
512 } 522 }
513 523
514 // Now distribute the space to objects. 524 // Now distribute the space to objects.
515 for (RenderBox* child = iterator.first(); child && spaceAvai lableThisPass && totalFlex; child = iterator.next()) { 525 for (RenderBox* child = iterator.first(); child && spaceAvai lableThisPass && totalFlex; child = iterator.next()) {
526 if (child->style()->visibility() == COLLAPSE)
527 continue;
528
516 if (allowedChildFlex(child, expanding, i)) { 529 if (allowedChildFlex(child, expanding, i)) {
517 LayoutUnit spaceAdd = static_cast<LayoutUnit>(spaceA vailableThisPass * (child->style()->boxFlex() / totalFlex)); 530 LayoutUnit spaceAdd = static_cast<LayoutUnit>(spaceA vailableThisPass * (child->style()->boxFlex() / totalFlex));
518 if (spaceAdd) { 531 if (spaceAdd) {
519 child->setOverrideSize(LayoutSize(child->overrid eWidth() + spaceAdd, 0)); 532 child->setOverrideSize(LayoutSize(child->overrid eWidth() + spaceAdd, 0));
520 m_flexingChildren = true; 533 m_flexingChildren = true;
521 relayoutChildren = true; 534 relayoutChildren = true;
522 } 535 }
523 536
524 spaceAvailableThisPass -= spaceAdd; 537 spaceAvailableThisPass -= spaceAdd;
525 remainingSpace -= spaceAdd; 538 remainingSpace -= spaceAdd;
(...skipping 29 matching lines...) Expand all
555 RenderBlock::finishDelayUpdateScrollInfo(); 568 RenderBlock::finishDelayUpdateScrollInfo();
556 569
557 if (remainingSpace > 0 && ((style()->isLeftToRightDirection() && style()->bo xPack() != BSTART) 570 if (remainingSpace > 0 && ((style()->isLeftToRightDirection() && style()->bo xPack() != BSTART)
558 || (!style()->isLeftToRightDirection() && style()->boxPack() != BEND))) { 571 || (!style()->isLeftToRightDirection() && style()->boxPack() != BEND))) {
559 // Children must be repositioned. 572 // Children must be repositioned.
560 LayoutUnit offset = 0; 573 LayoutUnit offset = 0;
561 if (style()->boxPack() == BJUSTIFY) { 574 if (style()->boxPack() == BJUSTIFY) {
562 // Determine the total number of children. 575 // Determine the total number of children.
563 int totalChildren = 0; 576 int totalChildren = 0;
564 for (RenderBox* child = iterator.first(); child; child = iterator.ne xt()) { 577 for (RenderBox* child = iterator.first(); child; child = iterator.ne xt()) {
565 if (child->isPositioned()) 578 if (childDoesNotAffectWidthOrFlexing(child))
566 continue; 579 continue;
567 ++totalChildren; 580 ++totalChildren;
568 } 581 }
569 582
570 // Iterate over the children and space them out according to the 583 // Iterate over the children and space them out according to the
571 // justification level. 584 // justification level.
572 if (totalChildren > 1) { 585 if (totalChildren > 1) {
573 --totalChildren; 586 --totalChildren;
574 bool firstChild = true; 587 bool firstChild = true;
575 for (RenderBox* child = iterator.first(); child; child = iterato r.next()) { 588 for (RenderBox* child = iterator.first(); child; child = iterato r.next()) {
576 if (child->isPositioned()) 589 if (childDoesNotAffectWidthOrFlexing(child))
577 continue; 590 continue;
578 591
579 if (firstChild) { 592 if (firstChild) {
580 firstChild = false; 593 firstChild = false;
581 continue; 594 continue;
582 } 595 }
583 596
584 offset += remainingSpace/totalChildren; 597 offset += remainingSpace/totalChildren;
585 remainingSpace -= (remainingSpace/totalChildren); 598 remainingSpace -= (remainingSpace/totalChildren);
586 --totalChildren; 599 --totalChildren;
587 600
588 placeChild(child, child->location() + LayoutSize(offset, 0)) ; 601 placeChild(child, child->location() + LayoutSize(offset, 0)) ;
589 } 602 }
590 } 603 }
591 } else { 604 } else {
592 if (style()->boxPack() == BCENTER) 605 if (style()->boxPack() == BCENTER)
593 offset += remainingSpace / 2; 606 offset += remainingSpace / 2;
594 else // END for LTR, START for RTL 607 else // END for LTR, START for RTL
595 offset += remainingSpace; 608 offset += remainingSpace;
596 for (RenderBox* child = iterator.first(); child; child = iterator.ne xt()) { 609 for (RenderBox* child = iterator.first(); child; child = iterator.ne xt()) {
597 if (child->isPositioned()) 610 if (childDoesNotAffectWidthOrFlexing(child))
598 continue; 611 continue;
599 612
600 placeChild(child, child->location() + LayoutSize(offset, 0)); 613 placeChild(child, child->location() + LayoutSize(offset, 0));
601 } 614 }
602 } 615 }
603 } 616 }
604 617
605 // So that the computeLogicalHeight in layoutBlock() knows to relayout posit ioned objects because of 618 // So that the computeLogicalHeight in layoutBlock() knows to relayout posit ioned objects because of
606 // a height change, we revert our height back to the intrinsic height before returning. 619 // a height change, we revert our height back to the intrinsic height before returning.
607 if (heightSpecified) 620 if (heightSpecified)
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
647 if (child->isPositioned()) { 660 if (child->isPositioned()) {
648 child->containingBlock()->insertPositionedObject(child); 661 child->containingBlock()->insertPositionedObject(child);
649 RenderLayer* childLayer = child->layer(); 662 RenderLayer* childLayer = child->layer();
650 childLayer->setStaticInlinePosition(borderStart() + paddingStart ()); 663 childLayer->setStaticInlinePosition(borderStart() + paddingStart ());
651 if (childLayer->staticBlockPosition() != height()) { 664 if (childLayer->staticBlockPosition() != height()) {
652 childLayer->setStaticBlockPosition(height()); 665 childLayer->setStaticBlockPosition(height());
653 if (child->style()->hasStaticBlockPosition(style()->isHorizo ntalWritingMode())) 666 if (child->style()->hasStaticBlockPosition(style()->isHorizo ntalWritingMode()))
654 child->setChildNeedsLayout(true, false); 667 child->setChildNeedsLayout(true, false);
655 } 668 }
656 continue; 669 continue;
670 } else if (child->style()->visibility() == COLLAPSE) {
671 // visibility: collapsed children do not participate in our posi tioning.
672 // But we need to lay them down.
673 child->layoutIfNeeded();
674 continue;
657 } 675 }
658 676
659 // Compute the child's vertical margins. 677 // Compute the child's vertical margins.
660 child->computeBlockDirectionMargins(this); 678 child->computeBlockDirectionMargins(this);
661 679
662 // Add in the child's marginTop to our height. 680 // Add in the child's marginTop to our height.
663 setHeight(height() + child->marginTop()); 681 setHeight(height() + child->marginTop());
664 682
665 if (!child->needsLayout()) 683 if (!child->needsLayout())
666 child->markForPaginationRelayoutIfNeeded(); 684 child->markForPaginationRelayoutIfNeeded();
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
798 816
799 RenderBlock::finishDelayUpdateScrollInfo(); 817 RenderBlock::finishDelayUpdateScrollInfo();
800 818
801 if (style()->boxPack() != BSTART && remainingSpace > 0) { 819 if (style()->boxPack() != BSTART && remainingSpace > 0) {
802 // Children must be repositioned. 820 // Children must be repositioned.
803 LayoutUnit offset = 0; 821 LayoutUnit offset = 0;
804 if (style()->boxPack() == BJUSTIFY) { 822 if (style()->boxPack() == BJUSTIFY) {
805 // Determine the total number of children. 823 // Determine the total number of children.
806 int totalChildren = 0; 824 int totalChildren = 0;
807 for (RenderBox* child = iterator.first(); child; child = iterator.ne xt()) { 825 for (RenderBox* child = iterator.first(); child; child = iterator.ne xt()) {
808 if (child->isPositioned()) 826 if (childDoesNotAffectWidthOrFlexing(child))
809 continue; 827 continue;
810 828
811 ++totalChildren; 829 ++totalChildren;
812 } 830 }
813 831
814 // Iterate over the children and space them out according to the 832 // Iterate over the children and space them out according to the
815 // justification level. 833 // justification level.
816 if (totalChildren > 1) { 834 if (totalChildren > 1) {
817 --totalChildren; 835 --totalChildren;
818 bool firstChild = true; 836 bool firstChild = true;
819 for (RenderBox* child = iterator.first(); child; child = iterato r.next()) { 837 for (RenderBox* child = iterator.first(); child; child = iterato r.next()) {
820 if (child->isPositioned()) 838 if (childDoesNotAffectWidthOrFlexing(child))
821 continue; 839 continue;
822 840
823 if (firstChild) { 841 if (firstChild) {
824 firstChild = false; 842 firstChild = false;
825 continue; 843 continue;
826 } 844 }
827 845
828 offset += remainingSpace/totalChildren; 846 offset += remainingSpace/totalChildren;
829 remainingSpace -= (remainingSpace/totalChildren); 847 remainingSpace -= (remainingSpace/totalChildren);
830 --totalChildren; 848 --totalChildren;
831 placeChild(child, child->location() + LayoutSize(0, offset)) ; 849 placeChild(child, child->location() + LayoutSize(0, offset)) ;
832 } 850 }
833 } 851 }
834 } else { 852 } else {
835 if (style()->boxPack() == BCENTER) 853 if (style()->boxPack() == BCENTER)
836 offset += remainingSpace / 2; 854 offset += remainingSpace / 2;
837 else // END 855 else // END
838 offset += remainingSpace; 856 offset += remainingSpace;
839 for (RenderBox* child = iterator.first(); child; child = iterator.ne xt()) { 857 for (RenderBox* child = iterator.first(); child; child = iterator.ne xt()) {
840 if (child->isPositioned()) 858 if (childDoesNotAffectWidthOrFlexing(child))
841 continue; 859 continue;
842 placeChild(child, child->location() + LayoutSize(0, offset)); 860 placeChild(child, child->location() + LayoutSize(0, offset));
843 } 861 }
844 } 862 }
845 } 863 }
846 864
847 // So that the computeLogicalHeight in layoutBlock() knows to relayout posit ioned objects because of 865 // So that the computeLogicalHeight in layoutBlock() knows to relayout posit ioned objects because of
848 // a height change, we revert our height back to the intrinsic height before returning. 866 // a height change, we revert our height back to the intrinsic height before returning.
849 if (heightSpecified) 867 if (heightSpecified)
850 setHeight(oldHeight); 868 setHeight(oldHeight);
851 } 869 }
852 870
853 void RenderDeprecatedFlexibleBox::applyLineClamp(FlexBoxIterator& iterator, bool relayoutChildren) 871 void RenderDeprecatedFlexibleBox::applyLineClamp(FlexBoxIterator& iterator, bool relayoutChildren)
854 { 872 {
855 int maxLineCount = 0; 873 int maxLineCount = 0;
856 for (RenderBox* child = iterator.first(); child; child = iterator.next()) { 874 for (RenderBox* child = iterator.first(); child; child = iterator.next()) {
857 if (child->isPositioned()) 875 if (childDoesNotAffectWidthOrFlexing(child))
858 continue; 876 continue;
859 877
860 if (relayoutChildren || (child->isReplaced() && (child->style()->width() .isPercent() || child->style()->height().isPercent())) 878 if (relayoutChildren || (child->isReplaced() && (child->style()->width() .isPercent() || child->style()->height().isPercent()))
861 || (child->style()->height().isAuto() && child->isBlockFlow())) { 879 || (child->style()->height().isAuto() && child->isBlockFlow())) {
862 child->setChildNeedsLayout(true, false); 880 child->setChildNeedsLayout(true, false);
863 881
864 // Dirty all the positioned objects. 882 // Dirty all the positioned objects.
865 if (child->isRenderBlock()) { 883 if (child->isRenderBlock()) {
866 toRenderBlock(child)->markPositionedObjectsForLayout(); 884 toRenderBlock(child)->markPositionedObjectsForLayout();
867 toRenderBlock(child)->clearTruncation(); 885 toRenderBlock(child)->clearTruncation();
868 } 886 }
869 } 887 }
870 child->layoutIfNeeded(); 888 child->layoutIfNeeded();
871 if (child->style()->height().isAuto() && child->isBlockFlow()) 889 if (child->style()->height().isAuto() && child->isBlockFlow())
872 maxLineCount = max(maxLineCount, toRenderBlock(child)->lineCount()); 890 maxLineCount = max(maxLineCount, toRenderBlock(child)->lineCount());
873 } 891 }
874 892
875 // Get the number of lines and then alter all block flow children with auto height to use the 893 // Get the number of lines and then alter all block flow children with auto height to use the
876 // specified height. We always try to leave room for at least one line. 894 // specified height. We always try to leave room for at least one line.
877 LineClampValue lineClamp = style()->lineClamp(); 895 LineClampValue lineClamp = style()->lineClamp();
878 int numVisibleLines = lineClamp.isPercentage() ? max(1, (maxLineCount + 1) * lineClamp.value() / 100) : lineClamp.value(); 896 int numVisibleLines = lineClamp.isPercentage() ? max(1, (maxLineCount + 1) * lineClamp.value() / 100) : lineClamp.value();
879 if (numVisibleLines >= maxLineCount) 897 if (numVisibleLines >= maxLineCount)
880 return; 898 return;
881 899
882 for (RenderBox* child = iterator.first(); child; child = iterator.next()) { 900 for (RenderBox* child = iterator.first(); child; child = iterator.next()) {
883 if (child->isPositioned() || !child->style()->height().isAuto() || !chil d->isBlockFlow()) 901 if (childDoesNotAffectWidthOrFlexing(child) || !child->style()->height() .isAuto() || !child->isBlockFlow())
884 continue; 902 continue;
885 903
886 RenderBlock* blockChild = toRenderBlock(child); 904 RenderBlock* blockChild = toRenderBlock(child);
887 int lineCount = blockChild->lineCount(); 905 int lineCount = blockChild->lineCount();
888 if (lineCount <= numVisibleLines) 906 if (lineCount <= numVisibleLines)
889 continue; 907 continue;
890 908
891 int newHeight = blockChild->heightForLineCount(numVisibleLines); 909 int newHeight = blockChild->heightForLineCount(numVisibleLines);
892 if (newHeight == child->height()) 910 if (newHeight == child->height())
893 continue; 911 continue;
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
961 979
962 // If the child moved, we have to repaint it as well as any floating/positio ned 980 // If the child moved, we have to repaint it as well as any floating/positio ned
963 // descendants. An exception is if we need a layout. In this case, we know we're going to 981 // descendants. An exception is if we need a layout. In this case, we know we're going to
964 // repaint ourselves (and the child) anyway. 982 // repaint ourselves (and the child) anyway.
965 if (!selfNeedsLayout() && child->checkForRepaintDuringLayout()) 983 if (!selfNeedsLayout() && child->checkForRepaintDuringLayout())
966 child->repaintDuringLayoutIfMoved(oldRect); 984 child->repaintDuringLayoutIfMoved(oldRect);
967 } 985 }
968 986
969 LayoutUnit RenderDeprecatedFlexibleBox::allowedChildFlex(RenderBox* child, bool expanding, unsigned int group) 987 LayoutUnit RenderDeprecatedFlexibleBox::allowedChildFlex(RenderBox* child, bool expanding, unsigned int group)
970 { 988 {
971 if (child->isPositioned() || child->style()->boxFlex() == 0.0f || child->sty le()->boxFlexGroup() != group) 989 if (childDoesNotAffectWidthOrFlexing(child) || child->style()->boxFlex() == 0.0f || child->style()->boxFlexGroup() != group)
972 return 0; 990 return 0;
973 991
974 if (expanding) { 992 if (expanding) {
975 if (isHorizontal()) { 993 if (isHorizontal()) {
976 // FIXME: For now just handle fixed values. 994 // FIXME: For now just handle fixed values.
977 LayoutUnit maxWidth = numeric_limits<LayoutUnit>::max(); 995 LayoutUnit maxWidth = numeric_limits<LayoutUnit>::max();
978 LayoutUnit width = child->overrideWidth() - child->borderAndPaddingW idth(); 996 LayoutUnit width = child->overrideWidth() - child->borderAndPaddingW idth();
979 if (!child->style()->maxWidth().isUndefined() && child->style()->max Width().isFixed()) 997 if (!child->style()->maxWidth().isUndefined() && child->style()->max Width().isFixed())
980 maxWidth = child->style()->maxWidth().value(); 998 maxWidth = child->style()->maxWidth().value();
981 else if (child->style()->maxWidth().type() == Intrinsic) 999 else if (child->style()->maxWidth().type() == Intrinsic)
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
1029 if (isPositioned()) 1047 if (isPositioned())
1030 return "RenderDeprecatedFlexibleBox (positioned)"; 1048 return "RenderDeprecatedFlexibleBox (positioned)";
1031 if (isAnonymous()) 1049 if (isAnonymous())
1032 return "RenderDeprecatedFlexibleBox (generated)"; 1050 return "RenderDeprecatedFlexibleBox (generated)";
1033 if (isRelPositioned()) 1051 if (isRelPositioned())
1034 return "RenderDeprecatedFlexibleBox (relative positioned)"; 1052 return "RenderDeprecatedFlexibleBox (relative positioned)";
1035 return "RenderDeprecatedFlexibleBox"; 1053 return "RenderDeprecatedFlexibleBox";
1036 } 1054 }
1037 1055
1038 } // namespace WebCore 1056 } // namespace WebCore
OLDNEW
« no previous file with comments | « LayoutTests/platform/qt/fast/flexbox/021-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698