| OLD | NEW |
| 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 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 412 if (!child->needsLayout()) | 412 if (!child->needsLayout()) |
| 413 child->markForPaginationRelayoutIfNeeded(layoutScope); | 413 child->markForPaginationRelayoutIfNeeded(layoutScope); |
| 414 | 414 |
| 415 child->layoutIfNeeded(); | 415 child->layoutIfNeeded(); |
| 416 | 416 |
| 417 // We can place the child now, using our value of box-align. | 417 // We can place the child now, using our value of box-align. |
| 418 xPos += child->marginLeft(); | 418 xPos += child->marginLeft(); |
| 419 LayoutUnit childY = yPos; | 419 LayoutUnit childY = yPos; |
| 420 switch (style()->boxAlign()) { | 420 switch (style()->boxAlign()) { |
| 421 case BCENTER: | 421 case BCENTER: |
| 422 childY += child->marginTop() + std::max<LayoutUnit>(0, (contentH
eight() - (child->size().height() + child->marginHeight())) / 2); | 422 childY += child->marginTop() + ((contentHeight() - (child->size(
).height() + child->marginHeight())) / 2).clampToZero(); |
| 423 break; | 423 break; |
| 424 case BBASELINE: { | 424 case BBASELINE: { |
| 425 LayoutUnit ascent = child->firstLineBoxBaseline(); | 425 LayoutUnit ascent = child->firstLineBoxBaseline(); |
| 426 if (ascent == -1) | 426 if (ascent == -1) |
| 427 ascent = child->size().height() + child->marginBottom(); | 427 ascent = child->size().height() + child->marginBottom(); |
| 428 ascent += child->marginTop(); | 428 ascent += child->marginTop(); |
| 429 childY += child->marginTop() + (maxAscent - ascent); | 429 childY += child->marginTop() + (maxAscent - ascent); |
| 430 break; | 430 break; |
| 431 } | 431 } |
| 432 case BEND: | 432 case BEND: |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 556 | 556 |
| 557 if (firstChild) { | 557 if (firstChild) { |
| 558 firstChild = false; | 558 firstChild = false; |
| 559 continue; | 559 continue; |
| 560 } | 560 } |
| 561 | 561 |
| 562 offset += remainingSpace / totalChildren; | 562 offset += remainingSpace / totalChildren; |
| 563 remainingSpace -= (remainingSpace / totalChildren); | 563 remainingSpace -= (remainingSpace / totalChildren); |
| 564 --totalChildren; | 564 --totalChildren; |
| 565 | 565 |
| 566 placeChild(child, child->location() + LayoutSize(offset, 0))
; | 566 placeChild(child, child->location() + LayoutSize(offset, Lay
outUnit())); |
| 567 } | 567 } |
| 568 } | 568 } |
| 569 } else { | 569 } else { |
| 570 if (style()->boxPack() == Center) | 570 if (style()->boxPack() == Center) |
| 571 offset += remainingSpace / 2; | 571 offset += remainingSpace / 2; |
| 572 else // END for LTR, START for RTL | 572 else // END for LTR, START for RTL |
| 573 offset += remainingSpace; | 573 offset += remainingSpace; |
| 574 for (LayoutBox* child = iterator.first(); child; child = iterator.ne
xt()) { | 574 for (LayoutBox* child = iterator.first(); child; child = iterator.ne
xt()) { |
| 575 if (childDoesNotAffectWidthOrFlexing(child)) | 575 if (childDoesNotAffectWidthOrFlexing(child)) |
| 576 continue; | 576 continue; |
| 577 | 577 |
| 578 placeChild(child, child->location() + LayoutSize(offset, 0)); | 578 placeChild(child, child->location() + LayoutSize(offset, LayoutU
nit())); |
| 579 } | 579 } |
| 580 } | 580 } |
| 581 } | 581 } |
| 582 | 582 |
| 583 // So that the computeLogicalHeight in layoutBlock() knows to relayout posit
ioned objects because of | 583 // So that the computeLogicalHeight in layoutBlock() knows to relayout posit
ioned objects because of |
| 584 // a height change, we revert our height back to the intrinsic height before
returning. | 584 // a height change, we revert our height back to the intrinsic height before
returning. |
| 585 if (heightSpecified) | 585 if (heightSpecified) |
| 586 setHeight(oldHeight); | 586 setHeight(oldHeight); |
| 587 } | 587 } |
| 588 | 588 |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 651 child->markForPaginationRelayoutIfNeeded(layoutScope); | 651 child->markForPaginationRelayoutIfNeeded(layoutScope); |
| 652 | 652 |
| 653 // Now do a layout. | 653 // Now do a layout. |
| 654 child->layoutIfNeeded(); | 654 child->layoutIfNeeded(); |
| 655 | 655 |
| 656 // We can place the child now, using our value of box-align. | 656 // We can place the child now, using our value of box-align. |
| 657 LayoutUnit childX = borderLeft() + paddingLeft(); | 657 LayoutUnit childX = borderLeft() + paddingLeft(); |
| 658 switch (style()->boxAlign()) { | 658 switch (style()->boxAlign()) { |
| 659 case BCENTER: | 659 case BCENTER: |
| 660 case BBASELINE: // Baseline just maps to center for vertical boxes | 660 case BBASELINE: // Baseline just maps to center for vertical boxes |
| 661 childX += child->marginLeft() + std::max<LayoutUnit>(0, (content
Width() - (child->size().width() + child->marginWidth())) / 2); | 661 childX += child->marginLeft() + std::max<LayoutUnit>(LayoutUnit(
), (contentWidth() - (child->size().width() + child->marginWidth())) / 2); |
| 662 break; | 662 break; |
| 663 case BEND: | 663 case BEND: |
| 664 if (!style()->isLeftToRightDirection()) | 664 if (!style()->isLeftToRightDirection()) |
| 665 childX += child->marginLeft(); | 665 childX += child->marginLeft(); |
| 666 else | 666 else |
| 667 childX += contentWidth() - child->marginRight() - child->siz
e().width(); | 667 childX += contentWidth() - child->marginRight() - child->siz
e().width(); |
| 668 break; | 668 break; |
| 669 default: // BSTART/BSTRETCH | 669 default: // BSTART/BSTRETCH |
| 670 if (style()->isLeftToRightDirection()) | 670 if (style()->isLeftToRightDirection()) |
| 671 childX += child->marginLeft(); | 671 childX += child->marginLeft(); |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 806 continue; | 806 continue; |
| 807 | 807 |
| 808 if (firstChild) { | 808 if (firstChild) { |
| 809 firstChild = false; | 809 firstChild = false; |
| 810 continue; | 810 continue; |
| 811 } | 811 } |
| 812 | 812 |
| 813 offset += remainingSpace / totalChildren; | 813 offset += remainingSpace / totalChildren; |
| 814 remainingSpace -= (remainingSpace / totalChildren); | 814 remainingSpace -= (remainingSpace / totalChildren); |
| 815 --totalChildren; | 815 --totalChildren; |
| 816 placeChild(child, child->location() + LayoutSize(0, offset))
; | 816 placeChild(child, child->location() + LayoutSize(LayoutUnit(
), offset)); |
| 817 } | 817 } |
| 818 } | 818 } |
| 819 } else { | 819 } else { |
| 820 if (style()->boxPack() == Center) | 820 if (style()->boxPack() == Center) |
| 821 offset += remainingSpace / 2; | 821 offset += remainingSpace / 2; |
| 822 else // END | 822 else // END |
| 823 offset += remainingSpace; | 823 offset += remainingSpace; |
| 824 for (LayoutBox* child = iterator.first(); child; child = iterator.ne
xt()) { | 824 for (LayoutBox* child = iterator.first(); child; child = iterator.ne
xt()) { |
| 825 if (childDoesNotAffectWidthOrFlexing(child)) | 825 if (childDoesNotAffectWidthOrFlexing(child)) |
| 826 continue; | 826 continue; |
| 827 placeChild(child, child->location() + LayoutSize(0, offset)); | 827 placeChild(child, child->location() + LayoutSize(LayoutUnit(), o
ffset)); |
| 828 } | 828 } |
| 829 } | 829 } |
| 830 } | 830 } |
| 831 | 831 |
| 832 // So that the computeLogicalHeight in layoutBlock() knows to relayout posit
ioned objects because of | 832 // So that the computeLogicalHeight in layoutBlock() knows to relayout posit
ioned objects because of |
| 833 // a height change, we revert our height back to the intrinsic height before
returning. | 833 // a height change, we revert our height back to the intrinsic height before
returning. |
| 834 if (heightSpecified) | 834 if (heightSpecified) |
| 835 setHeight(oldHeight); | 835 setHeight(oldHeight); |
| 836 } | 836 } |
| 837 | 837 |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 995 if (minHeight.isFixed() || minHeight.isAuto()) { | 995 if (minHeight.isFixed() || minHeight.isAuto()) { |
| 996 LayoutUnit minHeight = child->style()->minHeight().value(); | 996 LayoutUnit minHeight = child->style()->minHeight().value(); |
| 997 LayoutUnit height = contentHeightForChild(child); | 997 LayoutUnit height = contentHeightForChild(child); |
| 998 LayoutUnit allowedShrinkage = std::min<LayoutUnit>(0, minHeight - height
); | 998 LayoutUnit allowedShrinkage = std::min<LayoutUnit>(0, minHeight - height
); |
| 999 return allowedShrinkage; | 999 return allowedShrinkage; |
| 1000 } | 1000 } |
| 1001 return 0; | 1001 return 0; |
| 1002 } | 1002 } |
| 1003 | 1003 |
| 1004 } // namespace blink | 1004 } // namespace blink |
| OLD | NEW |