| 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.
All rights reserved. | 7 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2013 Apple Inc.
All rights reserved. |
| 8 * Copyright (C) 2006 Alexey Proskuryakov (ap@nypop.com) | 8 * Copyright (C) 2006 Alexey Proskuryakov (ap@nypop.com) |
| 9 * | 9 * |
| 10 * This library is free software; you can redistribute it and/or | 10 * This library is free software; you can redistribute it and/or |
| (...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 320 ASSERT(logicalWidth().toInt() >= minPreferredLogicalWidth().toInt()); | 320 ASSERT(logicalWidth().toInt() >= minPreferredLogicalWidth().toInt()); |
| 321 } | 321 } |
| 322 | 322 |
| 323 // This method takes a ComputedStyle's logical width, min-width, or max-width le
ngth and computes its actual value. | 323 // This method takes a ComputedStyle's logical width, min-width, or max-width le
ngth and computes its actual value. |
| 324 LayoutUnit LayoutTable::convertStyleLogicalWidthToComputedWidth(const Length& st
yleLogicalWidth, LayoutUnit availableWidth) | 324 LayoutUnit LayoutTable::convertStyleLogicalWidthToComputedWidth(const Length& st
yleLogicalWidth, LayoutUnit availableWidth) |
| 325 { | 325 { |
| 326 if (styleLogicalWidth.isIntrinsic()) | 326 if (styleLogicalWidth.isIntrinsic()) |
| 327 return computeIntrinsicLogicalWidthUsing(styleLogicalWidth, availableWid
th, bordersPaddingAndSpacingInRowDirection()); | 327 return computeIntrinsicLogicalWidthUsing(styleLogicalWidth, availableWid
th, bordersPaddingAndSpacingInRowDirection()); |
| 328 | 328 |
| 329 // HTML tables' width styles already include borders and paddings, but CSS t
ables' width styles do not. | 329 // HTML tables' width styles already include borders and paddings, but CSS t
ables' width styles do not. |
| 330 LayoutUnit borders = 0; | 330 LayoutUnit borders; |
| 331 bool isCSSTable = !isHTMLTableElement(node()); | 331 bool isCSSTable = !isHTMLTableElement(node()); |
| 332 if (isCSSTable && styleLogicalWidth.isSpecified() && styleLogicalWidth.isPos
itive() && style()->boxSizing() == CONTENT_BOX) | 332 if (isCSSTable && styleLogicalWidth.isSpecified() && styleLogicalWidth.isPos
itive() && style()->boxSizing() == CONTENT_BOX) |
| 333 borders = borderStart() + borderEnd() + (collapseBorders() ? LayoutUnit(
) : paddingStart() + paddingEnd()); | 333 borders = borderStart() + borderEnd() + (collapseBorders() ? LayoutUnit(
) : paddingStart() + paddingEnd()); |
| 334 | 334 |
| 335 return minimumValueForLength(styleLogicalWidth, availableWidth) + borders; | 335 return minimumValueForLength(styleLogicalWidth, availableWidth) + borders; |
| 336 } | 336 } |
| 337 | 337 |
| 338 LayoutUnit LayoutTable::convertStyleLogicalHeightToComputedHeight(const Length&
styleLogicalHeight) | 338 LayoutUnit LayoutTable::convertStyleLogicalHeightToComputedHeight(const Length&
styleLogicalHeight) |
| 339 { | 339 { |
| 340 LayoutUnit borderAndPaddingBefore = borderBefore() + (collapseBorders() ? La
youtUnit() : paddingBefore()); | 340 LayoutUnit borderAndPaddingBefore = borderBefore() + (collapseBorders() ? La
youtUnit() : paddingBefore()); |
| 341 LayoutUnit borderAndPaddingAfter = borderAfter() + (collapseBorders() ? Layo
utUnit() : paddingAfter()); | 341 LayoutUnit borderAndPaddingAfter = borderAfter() + (collapseBorders() ? Layo
utUnit() : paddingAfter()); |
| 342 LayoutUnit borderAndPadding = borderAndPaddingBefore + borderAndPaddingAfter
; | 342 LayoutUnit borderAndPadding = borderAndPaddingBefore + borderAndPaddingAfter
; |
| 343 LayoutUnit computedLogicalHeight = 0; | 343 LayoutUnit computedLogicalHeight; |
| 344 if (styleLogicalHeight.isFixed()) { | 344 if (styleLogicalHeight.isFixed()) { |
| 345 // HTML tables size as though CSS height includes border/padding, CSS ta
bles do not. | 345 // HTML tables size as though CSS height includes border/padding, CSS ta
bles do not. |
| 346 LayoutUnit borders = LayoutUnit(); | 346 LayoutUnit borders = LayoutUnit(); |
| 347 // FIXME: We cannot apply box-sizing: content-box on <table> which other
browsers allow. | 347 // FIXME: We cannot apply box-sizing: content-box on <table> which other
browsers allow. |
| 348 if (isHTMLTableElement(node()) || style()->boxSizing() == BORDER_BOX) { | 348 if (isHTMLTableElement(node()) || style()->boxSizing() == BORDER_BOX) { |
| 349 borders = borderAndPadding; | 349 borders = borderAndPadding; |
| 350 } | 350 } |
| 351 computedLogicalHeight = styleLogicalHeight.value() - borders; | 351 computedLogicalHeight = styleLogicalHeight.value() - borders; |
| 352 } else if (styleLogicalHeight.hasPercent()) { | 352 } else if (styleLogicalHeight.hasPercent()) { |
| 353 computedLogicalHeight = computePercentageLogicalHeight(styleLogicalHeigh
t); | 353 computedLogicalHeight = computePercentageLogicalHeight(styleLogicalHeigh
t); |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 443 for (unsigned i = 0; i < m_captions.size(); i++) | 443 for (unsigned i = 0; i < m_captions.size(); i++) |
| 444 layouter.setNeedsLayout(m_captions[i], LayoutInvalidationReason:
:TableChanged); | 444 layouter.setNeedsLayout(m_captions[i], LayoutInvalidationReason:
:TableChanged); |
| 445 } | 445 } |
| 446 // FIXME: The optimisation below doesn't work since the internal table | 446 // FIXME: The optimisation below doesn't work since the internal table |
| 447 // layout could have changed. We need to add a flag to the table | 447 // layout could have changed. We need to add a flag to the table |
| 448 // layout that tells us if something has changed in the min max | 448 // layout that tells us if something has changed in the min max |
| 449 // calculations to do it correctly. | 449 // calculations to do it correctly. |
| 450 // if ( oldWidth != width() || columns.size() + 1 != columnPos.size() ) | 450 // if ( oldWidth != width() || columns.size() + 1 != columnPos.size() ) |
| 451 m_tableLayout->layout(); | 451 m_tableLayout->layout(); |
| 452 | 452 |
| 453 LayoutUnit totalSectionLogicalHeight = 0; | 453 LayoutUnit totalSectionLogicalHeight; |
| 454 LayoutUnit oldTableLogicalTop = 0; | 454 LayoutUnit oldTableLogicalTop; |
| 455 for (unsigned i = 0; i < m_captions.size(); i++) | 455 for (unsigned i = 0; i < m_captions.size(); i++) |
| 456 oldTableLogicalTop += m_captions[i]->logicalHeight() + m_captions[i]
->marginBefore() + m_captions[i]->marginAfter(); | 456 oldTableLogicalTop += m_captions[i]->logicalHeight() + m_captions[i]
->marginBefore() + m_captions[i]->marginAfter(); |
| 457 | 457 |
| 458 bool collapsing = collapseBorders(); | 458 bool collapsing = collapseBorders(); |
| 459 | 459 |
| 460 for (LayoutObject* child = firstChild(); child; child = child->nextSibli
ng()) { | 460 for (LayoutObject* child = firstChild(); child; child = child->nextSibli
ng()) { |
| 461 if (!child->needsLayout() && child->isBox()) | 461 if (!child->needsLayout() && child->isBox()) |
| 462 toLayoutBox(child)->markForPaginationRelayoutIfNeeded(layouter); | 462 toLayoutBox(child)->markForPaginationRelayoutIfNeeded(layouter); |
| 463 if (child->isTableSection()) { | 463 if (child->isTableSection()) { |
| 464 LayoutTableSection* section = toLayoutTableSection(child); | 464 LayoutTableSection* section = toLayoutTableSection(child); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 488 layoutCaption(*m_captions[i]); | 488 layoutCaption(*m_captions[i]); |
| 489 } | 489 } |
| 490 sectionMoved = logicalHeight() != oldTableLogicalTop; | 490 sectionMoved = logicalHeight() != oldTableLogicalTop; |
| 491 } | 491 } |
| 492 | 492 |
| 493 LayoutUnit borderAndPaddingBefore = borderBefore() + (collapsing ? Layou
tUnit() : paddingBefore()); | 493 LayoutUnit borderAndPaddingBefore = borderBefore() + (collapsing ? Layou
tUnit() : paddingBefore()); |
| 494 LayoutUnit borderAndPaddingAfter = borderAfter() + (collapsing ? LayoutU
nit() : paddingAfter()); | 494 LayoutUnit borderAndPaddingAfter = borderAfter() + (collapsing ? LayoutU
nit() : paddingAfter()); |
| 495 | 495 |
| 496 setLogicalHeight(logicalHeight() + borderAndPaddingBefore); | 496 setLogicalHeight(logicalHeight() + borderAndPaddingBefore); |
| 497 | 497 |
| 498 LayoutUnit computedLogicalHeight = 0; | 498 LayoutUnit computedLogicalHeight; |
| 499 | 499 |
| 500 Length logicalHeightLength = style()->logicalHeight(); | 500 Length logicalHeightLength = style()->logicalHeight(); |
| 501 if (logicalHeightLength.isIntrinsic() || (logicalHeightLength.isSpecifie
d() && logicalHeightLength.isPositive())) | 501 if (logicalHeightLength.isIntrinsic() || (logicalHeightLength.isSpecifie
d() && logicalHeightLength.isPositive())) |
| 502 computedLogicalHeight = convertStyleLogicalHeightToComputedHeight(lo
gicalHeightLength); | 502 computedLogicalHeight = convertStyleLogicalHeightToComputedHeight(lo
gicalHeightLength); |
| 503 | 503 |
| 504 Length logicalMaxHeightLength = style()->logicalMaxHeight(); | 504 Length logicalMaxHeightLength = style()->logicalMaxHeight(); |
| 505 if (logicalMaxHeightLength.isIntrinsic() || (logicalMaxHeightLength.isSp
ecified() && !logicalMaxHeightLength.isNegative())) { | 505 if (logicalMaxHeightLength.isIntrinsic() || (logicalMaxHeightLength.isSp
ecified() && !logicalMaxHeightLength.isNegative())) { |
| 506 LayoutUnit computedMaxLogicalHeight = convertStyleLogicalHeightToCom
putedHeight(logicalMaxHeightLength); | 506 LayoutUnit computedMaxLogicalHeight = convertStyleLogicalHeightToCom
putedHeight(logicalMaxHeightLength); |
| 507 computedLogicalHeight = std::min(computedLogicalHeight, computedMaxL
ogicalHeight); | 507 computedLogicalHeight = std::min(computedLogicalHeight, computedMaxL
ogicalHeight); |
| 508 } | 508 } |
| (...skipping 946 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1455 | 1455 |
| 1456 LayoutUnit LayoutTable::paddingRight() const | 1456 LayoutUnit LayoutTable::paddingRight() const |
| 1457 { | 1457 { |
| 1458 if (collapseBorders()) | 1458 if (collapseBorders()) |
| 1459 return LayoutUnit(); | 1459 return LayoutUnit(); |
| 1460 | 1460 |
| 1461 return LayoutBlock::paddingRight(); | 1461 return LayoutBlock::paddingRight(); |
| 1462 } | 1462 } |
| 1463 | 1463 |
| 1464 } // namespace blink | 1464 } // namespace blink |
| OLD | NEW |