OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 1997 Martin Jones (mjones@kde.org) | 2 * Copyright (C) 1997 Martin Jones (mjones@kde.org) |
3 * (C) 1997 Torben Weis (weis@kde.org) | 3 * (C) 1997 Torben Weis (weis@kde.org) |
4 * (C) 1998 Waldo Bastian (bastian@kde.org) | 4 * (C) 1998 Waldo Bastian (bastian@kde.org) |
5 * (C) 1999 Lars Knoll (knoll@kde.org) | 5 * (C) 1999 Lars Knoll (knoll@kde.org) |
6 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 6 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
7 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2013 Apple Inc. | 7 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2013 Apple Inc. |
8 * All rights reserved. | 8 * All rights reserved. |
9 * Copyright (C) 2006 Alexey Proskuryakov (ap@nypop.com) | 9 * Copyright (C) 2006 Alexey Proskuryakov (ap@nypop.com) |
10 * | 10 * |
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
354 // nor what authors expect. | 354 // nor what authors expect. |
355 // FIXME: When we convert to sub-pixel layout for tables we can remove the int | 355 // FIXME: When we convert to sub-pixel layout for tables we can remove the int |
356 // conversion. http://crbug.com/241198 | 356 // conversion. http://crbug.com/241198 |
357 ASSERT(logicalWidth().floor() >= minPreferredLogicalWidth().floor()); | 357 ASSERT(logicalWidth().floor() >= minPreferredLogicalWidth().floor()); |
358 } | 358 } |
359 | 359 |
360 // This method takes a ComputedStyle's logical width, min-width, or max-width | 360 // This method takes a ComputedStyle's logical width, min-width, or max-width |
361 // length and computes its actual value. | 361 // length and computes its actual value. |
362 LayoutUnit LayoutTable::convertStyleLogicalWidthToComputedWidth( | 362 LayoutUnit LayoutTable::convertStyleLogicalWidthToComputedWidth( |
363 const Length& styleLogicalWidth, | 363 const Length& styleLogicalWidth, |
364 LayoutUnit availableWidth) { | 364 LayoutUnit availableWidth) const { |
365 if (styleLogicalWidth.isIntrinsic()) | 365 if (styleLogicalWidth.isIntrinsic()) |
366 return computeIntrinsicLogicalWidthUsing( | 366 return computeIntrinsicLogicalWidthUsing( |
367 styleLogicalWidth, availableWidth, | 367 styleLogicalWidth, availableWidth, |
368 bordersPaddingAndSpacingInRowDirection()); | 368 bordersPaddingAndSpacingInRowDirection()); |
369 | 369 |
370 // HTML tables' width styles already include borders and paddings, but CSS | 370 // HTML tables' width styles already include borders and paddings, but CSS |
371 // tables' width styles do not. | 371 // tables' width styles do not. |
372 LayoutUnit borders; | 372 LayoutUnit borders; |
373 bool isCSSTable = !isHTMLTableElement(node()); | 373 bool isCSSTable = !isHTMLTableElement(node()); |
374 if (isCSSTable && styleLogicalWidth.isSpecified() && | 374 if (isCSSTable && styleLogicalWidth.isSpecified() && |
375 styleLogicalWidth.isPositive() && | 375 styleLogicalWidth.isPositive() && |
376 style()->boxSizing() == BoxSizingContentBox) | 376 style()->boxSizing() == BoxSizingContentBox) |
377 borders = | 377 borders = |
378 borderStart() + borderEnd() + | 378 borderStart() + borderEnd() + |
379 (collapseBorders() ? LayoutUnit() : paddingStart() + paddingEnd()); | 379 (collapseBorders() ? LayoutUnit() : paddingStart() + paddingEnd()); |
380 | 380 |
381 return minimumValueForLength(styleLogicalWidth, availableWidth) + borders; | 381 return minimumValueForLength(styleLogicalWidth, availableWidth) + borders; |
382 } | 382 } |
383 | 383 |
384 LayoutUnit LayoutTable::convertStyleLogicalHeightToComputedHeight( | 384 LayoutUnit LayoutTable::convertStyleLogicalHeightToComputedHeight( |
385 const Length& styleLogicalHeight) { | 385 const Length& styleLogicalHeight) const { |
386 LayoutUnit borderAndPaddingBefore = | 386 LayoutUnit borderAndPaddingBefore = |
387 borderBefore() + (collapseBorders() ? LayoutUnit() : paddingBefore()); | 387 borderBefore() + (collapseBorders() ? LayoutUnit() : paddingBefore()); |
388 LayoutUnit borderAndPaddingAfter = | 388 LayoutUnit borderAndPaddingAfter = |
389 borderAfter() + (collapseBorders() ? LayoutUnit() : paddingAfter()); | 389 borderAfter() + (collapseBorders() ? LayoutUnit() : paddingAfter()); |
390 LayoutUnit borderAndPadding = borderAndPaddingBefore + borderAndPaddingAfter; | 390 LayoutUnit borderAndPadding = borderAndPaddingBefore + borderAndPaddingAfter; |
391 LayoutUnit computedLogicalHeight; | 391 LayoutUnit computedLogicalHeight; |
392 if (styleLogicalHeight.isFixed()) { | 392 if (styleLogicalHeight.isFixed()) { |
393 // HTML tables size as though CSS height includes border/padding, CSS tables | 393 // HTML tables size as though CSS height includes border/padding, CSS tables |
394 // do not. | 394 // do not. |
395 LayoutUnit borders = LayoutUnit(); | 395 LayoutUnit borders = LayoutUnit(); |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
448 if (m_columnLogicalWidthChanged) | 448 if (m_columnLogicalWidthChanged) |
449 layouter.setChildNeedsLayout(§ion); | 449 layouter.setChildNeedsLayout(§ion); |
450 if (!section.needsLayout()) | 450 if (!section.needsLayout()) |
451 markChildForPaginationRelayoutIfNeeded(section, layouter); | 451 markChildForPaginationRelayoutIfNeeded(section, layouter); |
452 section.layoutIfNeeded(); | 452 section.layoutIfNeeded(); |
453 int sectionLogicalHeight = section.calcRowLogicalHeight(); | 453 int sectionLogicalHeight = section.calcRowLogicalHeight(); |
454 section.setLogicalHeight(LayoutUnit(sectionLogicalHeight)); | 454 section.setLogicalHeight(LayoutUnit(sectionLogicalHeight)); |
455 setLogicalHeight(logicalHeight() + sectionLogicalHeight); | 455 setLogicalHeight(logicalHeight() + sectionLogicalHeight); |
456 } | 456 } |
457 | 457 |
| 458 LayoutUnit LayoutTable::logicalHeightFromStyle() const { |
| 459 LayoutUnit computedLogicalHeight; |
| 460 Length logicalHeightLength = style()->logicalHeight(); |
| 461 if (logicalHeightLength.isIntrinsic() || |
| 462 (logicalHeightLength.isSpecified() && logicalHeightLength.isPositive())) { |
| 463 computedLogicalHeight = |
| 464 convertStyleLogicalHeightToComputedHeight(logicalHeightLength); |
| 465 } |
| 466 |
| 467 Length logicalMaxHeightLength = style()->logicalMaxHeight(); |
| 468 if (logicalMaxHeightLength.isIntrinsic() || |
| 469 (logicalMaxHeightLength.isSpecified() && |
| 470 !logicalMaxHeightLength.isNegative())) { |
| 471 LayoutUnit computedMaxLogicalHeight = |
| 472 convertStyleLogicalHeightToComputedHeight(logicalMaxHeightLength); |
| 473 computedLogicalHeight = |
| 474 std::min(computedLogicalHeight, computedMaxLogicalHeight); |
| 475 } |
| 476 |
| 477 Length logicalMinHeightLength = style()->logicalMinHeight(); |
| 478 if (logicalMinHeightLength.isIntrinsic() || |
| 479 (logicalMinHeightLength.isSpecified() && |
| 480 !logicalMinHeightLength.isNegative())) { |
| 481 LayoutUnit computedMinLogicalHeight = |
| 482 convertStyleLogicalHeightToComputedHeight(logicalMinHeightLength); |
| 483 computedLogicalHeight = |
| 484 std::max(computedLogicalHeight, computedMinLogicalHeight); |
| 485 } |
| 486 |
| 487 return computedLogicalHeight; |
| 488 } |
| 489 |
458 void LayoutTable::distributeExtraLogicalHeight(int extraLogicalHeight) { | 490 void LayoutTable::distributeExtraLogicalHeight(int extraLogicalHeight) { |
459 if (extraLogicalHeight <= 0) | 491 if (extraLogicalHeight <= 0) |
460 return; | 492 return; |
461 | 493 |
462 // FIXME: Distribute the extra logical height between all table sections | 494 // FIXME: Distribute the extra logical height between all table sections |
463 // instead of giving it all to the first one. | 495 // instead of giving it all to the first one. |
464 if (LayoutTableSection* section = firstBody()) | 496 if (LayoutTableSection* section = firstBody()) |
465 extraLogicalHeight -= | 497 extraLogicalHeight -= |
466 section->distributeExtraLogicalHeightToRows(extraLogicalHeight); | 498 section->distributeExtraLogicalHeightToRows(extraLogicalHeight); |
467 | 499 |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
606 DCHECK(child->isTableCaption()); | 638 DCHECK(child->isTableCaption()); |
607 } | 639 } |
608 } | 640 } |
609 | 641 |
610 // Lay out table footer. | 642 // Lay out table footer. |
611 if (LayoutTableSection* section = footer()) | 643 if (LayoutTableSection* section = footer()) |
612 layoutSection(*section, layouter, sectionLogicalLeft); | 644 layoutSection(*section, layouter, sectionLogicalLeft); |
613 | 645 |
614 setLogicalHeight(tableBoxLogicalTop + borderAndPaddingBefore); | 646 setLogicalHeight(tableBoxLogicalTop + borderAndPaddingBefore); |
615 | 647 |
616 LayoutUnit computedLogicalHeight; | 648 LayoutUnit computedLogicalHeight = logicalHeightFromStyle(); |
617 | |
618 Length logicalHeightLength = style()->logicalHeight(); | |
619 if (logicalHeightLength.isIntrinsic() || | |
620 (logicalHeightLength.isSpecified() && logicalHeightLength.isPositive())) | |
621 computedLogicalHeight = | |
622 convertStyleLogicalHeightToComputedHeight(logicalHeightLength); | |
623 | |
624 Length logicalMaxHeightLength = style()->logicalMaxHeight(); | |
625 if (logicalMaxHeightLength.isIntrinsic() || | |
626 (logicalMaxHeightLength.isSpecified() && | |
627 !logicalMaxHeightLength.isNegative())) { | |
628 LayoutUnit computedMaxLogicalHeight = | |
629 convertStyleLogicalHeightToComputedHeight(logicalMaxHeightLength); | |
630 computedLogicalHeight = | |
631 std::min(computedLogicalHeight, computedMaxLogicalHeight); | |
632 } | |
633 | |
634 Length logicalMinHeightLength = style()->logicalMinHeight(); | |
635 if (logicalMinHeightLength.isIntrinsic() || | |
636 (logicalMinHeightLength.isSpecified() && | |
637 !logicalMinHeightLength.isNegative())) { | |
638 LayoutUnit computedMinLogicalHeight = | |
639 convertStyleLogicalHeightToComputedHeight(logicalMinHeightLength); | |
640 computedLogicalHeight = | |
641 std::max(computedLogicalHeight, computedMinLogicalHeight); | |
642 } | |
643 | |
644 LayoutUnit totalSectionLogicalHeight; | 649 LayoutUnit totalSectionLogicalHeight; |
645 if (topSection) { | 650 if (topSection) { |
646 totalSectionLogicalHeight = | 651 totalSectionLogicalHeight = |
647 bottomSection->logicalBottom() - topSection->logicalTop(); | 652 bottomSection->logicalBottom() - topSection->logicalTop(); |
648 } | 653 } |
649 | 654 |
650 distributeExtraLogicalHeight( | 655 distributeExtraLogicalHeight( |
651 floorToInt(computedLogicalHeight - totalSectionLogicalHeight)); | 656 floorToInt(computedLogicalHeight - totalSectionLogicalHeight)); |
652 | 657 |
653 bool isPaginated = view()->layoutState()->isPaginated(); | 658 bool isPaginated = view()->layoutState()->isPaginated(); |
(...skipping 1024 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1678 } | 1683 } |
1679 | 1684 |
1680 LayoutUnit LayoutTable::paddingRight() const { | 1685 LayoutUnit LayoutTable::paddingRight() const { |
1681 if (collapseBorders()) | 1686 if (collapseBorders()) |
1682 return LayoutUnit(); | 1687 return LayoutUnit(); |
1683 | 1688 |
1684 return LayoutBlock::paddingRight(); | 1689 return LayoutBlock::paddingRight(); |
1685 } | 1690 } |
1686 | 1691 |
1687 } // namespace blink | 1692 } // namespace blink |
OLD | NEW |