| 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 28 matching lines...) Expand all Loading... |
| 39 #include "core/rendering/RenderLayer.h" | 39 #include "core/rendering/RenderLayer.h" |
| 40 #include "core/rendering/RenderTableCaption.h" | 40 #include "core/rendering/RenderTableCaption.h" |
| 41 #include "core/rendering/RenderTableCell.h" | 41 #include "core/rendering/RenderTableCell.h" |
| 42 #include "core/rendering/RenderTableCol.h" | 42 #include "core/rendering/RenderTableCol.h" |
| 43 #include "core/rendering/RenderTableSection.h" | 43 #include "core/rendering/RenderTableSection.h" |
| 44 #include "core/rendering/RenderView.h" | 44 #include "core/rendering/RenderView.h" |
| 45 #include "core/rendering/SubtreeLayoutScope.h" | 45 #include "core/rendering/SubtreeLayoutScope.h" |
| 46 #include "core/rendering/style/StyleInheritedData.h" | 46 #include "core/rendering/style/StyleInheritedData.h" |
| 47 #include "platform/graphics/GraphicsContextStateSaver.h" | 47 #include "platform/graphics/GraphicsContextStateSaver.h" |
| 48 | 48 |
| 49 using namespace std; | |
| 50 | |
| 51 namespace WebCore { | 49 namespace WebCore { |
| 52 | 50 |
| 53 using namespace HTMLNames; | 51 using namespace HTMLNames; |
| 54 | 52 |
| 55 RenderTable::RenderTable(Element* element) | 53 RenderTable::RenderTable(Element* element) |
| 56 : RenderBlock(element) | 54 : RenderBlock(element) |
| 57 , m_head(0) | 55 , m_head(0) |
| 58 , m_foot(0) | 56 , m_foot(0) |
| 59 , m_firstBody(0) | 57 , m_firstBody(0) |
| 60 , m_currentBorder(0) | 58 , m_currentBorder(0) |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 268 Length styleLogicalWidth = style()->logicalWidth(); | 266 Length styleLogicalWidth = style()->logicalWidth(); |
| 269 if ((styleLogicalWidth.isSpecified() && styleLogicalWidth.isPositive()) || s
tyleLogicalWidth.isIntrinsic()) | 267 if ((styleLogicalWidth.isSpecified() && styleLogicalWidth.isPositive()) || s
tyleLogicalWidth.isIntrinsic()) |
| 270 setLogicalWidth(convertStyleLogicalWidthToComputedWidth(styleLogicalWidt
h, containerWidthInInlineDirection)); | 268 setLogicalWidth(convertStyleLogicalWidthToComputedWidth(styleLogicalWidt
h, containerWidthInInlineDirection)); |
| 271 else { | 269 else { |
| 272 // Subtract out any fixed margins from our available width for auto widt
h tables. | 270 // Subtract out any fixed margins from our available width for auto widt
h tables. |
| 273 LayoutUnit marginStart = minimumValueForLength(style()->marginStart(), a
vailableLogicalWidth); | 271 LayoutUnit marginStart = minimumValueForLength(style()->marginStart(), a
vailableLogicalWidth); |
| 274 LayoutUnit marginEnd = minimumValueForLength(style()->marginEnd(), avail
ableLogicalWidth); | 272 LayoutUnit marginEnd = minimumValueForLength(style()->marginEnd(), avail
ableLogicalWidth); |
| 275 LayoutUnit marginTotal = marginStart + marginEnd; | 273 LayoutUnit marginTotal = marginStart + marginEnd; |
| 276 | 274 |
| 277 // Subtract out our margins to get the available content width. | 275 // Subtract out our margins to get the available content width. |
| 278 LayoutUnit availableContentLogicalWidth = max<LayoutUnit>(0, containerWi
dthInInlineDirection - marginTotal); | 276 LayoutUnit availableContentLogicalWidth = std::max<LayoutUnit>(0, contai
nerWidthInInlineDirection - marginTotal); |
| 279 if (shrinkToAvoidFloats() && cb->containsFloats() && !hasPerpendicularCo
ntainingBlock) | 277 if (shrinkToAvoidFloats() && cb->containsFloats() && !hasPerpendicularCo
ntainingBlock) |
| 280 availableContentLogicalWidth = shrinkLogicalWidthToAvoidFloats(margi
nStart, marginEnd, toRenderBlockFlow(cb)); | 278 availableContentLogicalWidth = shrinkLogicalWidthToAvoidFloats(margi
nStart, marginEnd, toRenderBlockFlow(cb)); |
| 281 | 279 |
| 282 // Ensure we aren't bigger than our available width. | 280 // Ensure we aren't bigger than our available width. |
| 283 setLogicalWidth(min<int>(availableContentLogicalWidth, maxPreferredLogic
alWidth())); | 281 setLogicalWidth(std::min<int>(availableContentLogicalWidth, maxPreferred
LogicalWidth())); |
| 284 } | 282 } |
| 285 | 283 |
| 286 // Ensure we aren't bigger than our max-width style. | 284 // Ensure we aren't bigger than our max-width style. |
| 287 Length styleMaxLogicalWidth = style()->logicalMaxWidth(); | 285 Length styleMaxLogicalWidth = style()->logicalMaxWidth(); |
| 288 if ((styleMaxLogicalWidth.isSpecified() && !styleMaxLogicalWidth.isNegative(
)) || styleMaxLogicalWidth.isIntrinsic()) { | 286 if ((styleMaxLogicalWidth.isSpecified() && !styleMaxLogicalWidth.isNegative(
)) || styleMaxLogicalWidth.isIntrinsic()) { |
| 289 LayoutUnit computedMaxLogicalWidth = convertStyleLogicalWidthToComputedW
idth(styleMaxLogicalWidth, availableLogicalWidth); | 287 LayoutUnit computedMaxLogicalWidth = convertStyleLogicalWidthToComputedW
idth(styleMaxLogicalWidth, availableLogicalWidth); |
| 290 setLogicalWidth(min<int>(logicalWidth(), computedMaxLogicalWidth)); | 288 setLogicalWidth(std::min<int>(logicalWidth(), computedMaxLogicalWidth)); |
| 291 } | 289 } |
| 292 | 290 |
| 293 // Ensure we aren't smaller than our min preferred width. This MUST be done
after 'max-width' as | 291 // Ensure we aren't smaller than our min preferred width. This MUST be done
after 'max-width' as |
| 294 // we ignore it if it means we wouldn't accomodate our content. | 292 // we ignore it if it means we wouldn't accomodate our content. |
| 295 setLogicalWidth(max<int>(logicalWidth(), minPreferredLogicalWidth())); | 293 setLogicalWidth(std::max<int>(logicalWidth(), minPreferredLogicalWidth())); |
| 296 | 294 |
| 297 // Ensure we aren't smaller than our min-width style. | 295 // Ensure we aren't smaller than our min-width style. |
| 298 Length styleMinLogicalWidth = style()->logicalMinWidth(); | 296 Length styleMinLogicalWidth = style()->logicalMinWidth(); |
| 299 if ((styleMinLogicalWidth.isSpecified() && !styleMinLogicalWidth.isNegative(
)) || styleMinLogicalWidth.isIntrinsic()) { | 297 if ((styleMinLogicalWidth.isSpecified() && !styleMinLogicalWidth.isNegative(
)) || styleMinLogicalWidth.isIntrinsic()) { |
| 300 LayoutUnit computedMinLogicalWidth = convertStyleLogicalWidthToComputedW
idth(styleMinLogicalWidth, availableLogicalWidth); | 298 LayoutUnit computedMinLogicalWidth = convertStyleLogicalWidthToComputedW
idth(styleMinLogicalWidth, availableLogicalWidth); |
| 301 setLogicalWidth(max<int>(logicalWidth(), computedMinLogicalWidth)); | 299 setLogicalWidth(std::max<int>(logicalWidth(), computedMinLogicalWidth)); |
| 302 } | 300 } |
| 303 | 301 |
| 304 // Finally, with our true width determined, compute our margins for real. | 302 // Finally, with our true width determined, compute our margins for real. |
| 305 ComputedMarginValues marginValues; | 303 ComputedMarginValues marginValues; |
| 306 computeMarginsForDirection(InlineDirection, cb, availableLogicalWidth, logic
alWidth(), marginValues.m_start, marginValues.m_end, style()->marginStart(), sty
le()->marginEnd()); | 304 computeMarginsForDirection(InlineDirection, cb, availableLogicalWidth, logic
alWidth(), marginValues.m_start, marginValues.m_end, style()->marginStart(), sty
le()->marginEnd()); |
| 307 setMarginStart(marginValues.m_start); | 305 setMarginStart(marginValues.m_start); |
| 308 setMarginEnd(marginValues.m_end); | 306 setMarginEnd(marginValues.m_end); |
| 309 | 307 |
| 310 // We should NEVER shrink the table below the min-content logical width, or
else the table can't accomodate | 308 // We should NEVER shrink the table below the min-content logical width, or
else the table can't accomodate |
| 311 // its own content which doesn't match CSS nor what authors expect. | 309 // its own content which doesn't match CSS nor what authors expect. |
| (...skipping 30 matching lines...) Expand all Loading... |
| 342 if (isHTMLTableElement(node()) || style()->boxSizing() == BORDER_BOX) { | 340 if (isHTMLTableElement(node()) || style()->boxSizing() == BORDER_BOX) { |
| 343 borders = borderAndPadding; | 341 borders = borderAndPadding; |
| 344 } | 342 } |
| 345 computedLogicalHeight = styleLogicalHeight.value() - borders; | 343 computedLogicalHeight = styleLogicalHeight.value() - borders; |
| 346 } else if (styleLogicalHeight.isPercent()) | 344 } else if (styleLogicalHeight.isPercent()) |
| 347 computedLogicalHeight = computePercentageLogicalHeight(styleLogicalHeigh
t); | 345 computedLogicalHeight = computePercentageLogicalHeight(styleLogicalHeigh
t); |
| 348 else if (styleLogicalHeight.isIntrinsic()) | 346 else if (styleLogicalHeight.isIntrinsic()) |
| 349 computedLogicalHeight = computeIntrinsicLogicalContentHeightUsing(styleL
ogicalHeight, logicalHeight() - borderAndPadding, borderAndPadding); | 347 computedLogicalHeight = computeIntrinsicLogicalContentHeightUsing(styleL
ogicalHeight, logicalHeight() - borderAndPadding, borderAndPadding); |
| 350 else | 348 else |
| 351 ASSERT_NOT_REACHED(); | 349 ASSERT_NOT_REACHED(); |
| 352 return max<LayoutUnit>(0, computedLogicalHeight); | 350 return std::max<LayoutUnit>(0, computedLogicalHeight); |
| 353 } | 351 } |
| 354 | 352 |
| 355 void RenderTable::layoutCaption(RenderTableCaption* caption) | 353 void RenderTable::layoutCaption(RenderTableCaption* caption) |
| 356 { | 354 { |
| 357 LayoutRect captionRect(caption->frameRect()); | 355 LayoutRect captionRect(caption->frameRect()); |
| 358 | 356 |
| 359 if (caption->needsLayout()) { | 357 if (caption->needsLayout()) { |
| 360 // The margins may not be available but ensure the caption is at least l
ocated beneath any previous sibling caption | 358 // The margins may not be available but ensure the caption is at least l
ocated beneath any previous sibling caption |
| 361 // so that it does not mistakenly think any floats in the previous capti
on intrude into it. | 359 // so that it does not mistakenly think any floats in the previous capti
on intrude into it. |
| 362 caption->setLogicalLocation(LayoutPoint(caption->marginStart(), collapse
dMarginBeforeForChild(caption) + logicalHeight())); | 360 caption->setLogicalLocation(LayoutPoint(caption->marginStart(), collapse
dMarginBeforeForChild(caption) + logicalHeight())); |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 473 | 471 |
| 474 // FIXME: Collapse caption margin. | 472 // FIXME: Collapse caption margin. |
| 475 if (!m_captions.isEmpty()) { | 473 if (!m_captions.isEmpty()) { |
| 476 for (unsigned i = 0; i < m_captions.size(); i++) { | 474 for (unsigned i = 0; i < m_captions.size(); i++) { |
| 477 if (m_captions[i]->style()->captionSide() == CAPBOTTOM) | 475 if (m_captions[i]->style()->captionSide() == CAPBOTTOM) |
| 478 continue; | 476 continue; |
| 479 layoutCaption(m_captions[i]); | 477 layoutCaption(m_captions[i]); |
| 480 } | 478 } |
| 481 if (logicalHeight() != oldTableLogicalTop) { | 479 if (logicalHeight() != oldTableLogicalTop) { |
| 482 sectionMoved = true; | 480 sectionMoved = true; |
| 483 movedSectionLogicalTop = min(logicalHeight(), oldTableLogicalTop
); | 481 movedSectionLogicalTop = std::min(logicalHeight(), oldTableLogic
alTop); |
| 484 } | 482 } |
| 485 } | 483 } |
| 486 | 484 |
| 487 LayoutUnit borderAndPaddingBefore = borderBefore() + (collapsing ? Layou
tUnit() : paddingBefore()); | 485 LayoutUnit borderAndPaddingBefore = borderBefore() + (collapsing ? Layou
tUnit() : paddingBefore()); |
| 488 LayoutUnit borderAndPaddingAfter = borderAfter() + (collapsing ? LayoutU
nit() : paddingAfter()); | 486 LayoutUnit borderAndPaddingAfter = borderAfter() + (collapsing ? LayoutU
nit() : paddingAfter()); |
| 489 | 487 |
| 490 setLogicalHeight(logicalHeight() + borderAndPaddingBefore); | 488 setLogicalHeight(logicalHeight() + borderAndPaddingBefore); |
| 491 | 489 |
| 492 if (!isOutOfFlowPositioned()) | 490 if (!isOutOfFlowPositioned()) |
| 493 updateLogicalHeight(); | 491 updateLogicalHeight(); |
| 494 | 492 |
| 495 LayoutUnit computedLogicalHeight = 0; | 493 LayoutUnit computedLogicalHeight = 0; |
| 496 | 494 |
| 497 Length logicalHeightLength = style()->logicalHeight(); | 495 Length logicalHeightLength = style()->logicalHeight(); |
| 498 if (logicalHeightLength.isIntrinsic() || (logicalHeightLength.isSpecifie
d() && logicalHeightLength.isPositive())) | 496 if (logicalHeightLength.isIntrinsic() || (logicalHeightLength.isSpecifie
d() && logicalHeightLength.isPositive())) |
| 499 computedLogicalHeight = convertStyleLogicalHeightToComputedHeight(lo
gicalHeightLength); | 497 computedLogicalHeight = convertStyleLogicalHeightToComputedHeight(lo
gicalHeightLength); |
| 500 | 498 |
| 501 Length logicalMaxHeightLength = style()->logicalMaxHeight(); | 499 Length logicalMaxHeightLength = style()->logicalMaxHeight(); |
| 502 if (logicalMaxHeightLength.isIntrinsic() || (logicalMaxHeightLength.isSp
ecified() && !logicalMaxHeightLength.isNegative())) { | 500 if (logicalMaxHeightLength.isIntrinsic() || (logicalMaxHeightLength.isSp
ecified() && !logicalMaxHeightLength.isNegative())) { |
| 503 LayoutUnit computedMaxLogicalHeight = convertStyleLogicalHeightToCom
putedHeight(logicalMaxHeightLength); | 501 LayoutUnit computedMaxLogicalHeight = convertStyleLogicalHeightToCom
putedHeight(logicalMaxHeightLength); |
| 504 computedLogicalHeight = min(computedLogicalHeight, computedMaxLogica
lHeight); | 502 computedLogicalHeight = std::min(computedLogicalHeight, computedMaxL
ogicalHeight); |
| 505 } | 503 } |
| 506 | 504 |
| 507 Length logicalMinHeightLength = style()->logicalMinHeight(); | 505 Length logicalMinHeightLength = style()->logicalMinHeight(); |
| 508 if (logicalMinHeightLength.isIntrinsic() || (logicalMinHeightLength.isSp
ecified() && !logicalMinHeightLength.isNegative())) { | 506 if (logicalMinHeightLength.isIntrinsic() || (logicalMinHeightLength.isSp
ecified() && !logicalMinHeightLength.isNegative())) { |
| 509 LayoutUnit computedMinLogicalHeight = convertStyleLogicalHeightToCom
putedHeight(logicalMinHeightLength); | 507 LayoutUnit computedMinLogicalHeight = convertStyleLogicalHeightToCom
putedHeight(logicalMinHeightLength); |
| 510 computedLogicalHeight = max(computedLogicalHeight, computedMinLogica
lHeight); | 508 computedLogicalHeight = std::max(computedLogicalHeight, computedMinL
ogicalHeight); |
| 511 } | 509 } |
| 512 | 510 |
| 513 distributeExtraLogicalHeight(floorToInt(computedLogicalHeight - totalSec
tionLogicalHeight)); | 511 distributeExtraLogicalHeight(floorToInt(computedLogicalHeight - totalSec
tionLogicalHeight)); |
| 514 | 512 |
| 515 for (RenderTableSection* section = topSection(); section; section = sect
ionBelow(section)) | 513 for (RenderTableSection* section = topSection(); section; section = sect
ionBelow(section)) |
| 516 section->layoutRows(); | 514 section->layoutRows(); |
| 517 | 515 |
| 518 if (!topSection() && computedLogicalHeight > totalSectionLogicalHeight &
& !document().inQuirksMode()) { | 516 if (!topSection() && computedLogicalHeight > totalSectionLogicalHeight &
& !document().inQuirksMode()) { |
| 519 // Completely empty tables (with no sections or anything) should at
least honor specified height | 517 // Completely empty tables (with no sections or anything) should at
least honor specified height |
| 520 // in strict mode. | 518 // in strict mode. |
| 521 setLogicalHeight(logicalHeight() + computedLogicalHeight); | 519 setLogicalHeight(logicalHeight() + computedLogicalHeight); |
| 522 } | 520 } |
| 523 | 521 |
| 524 LayoutUnit sectionLogicalLeft = style()->isLeftToRightDirection() ? bord
erStart() : borderEnd(); | 522 LayoutUnit sectionLogicalLeft = style()->isLeftToRightDirection() ? bord
erStart() : borderEnd(); |
| 525 if (!collapsing) | 523 if (!collapsing) |
| 526 sectionLogicalLeft += style()->isLeftToRightDirection() ? paddingSta
rt() : paddingEnd(); | 524 sectionLogicalLeft += style()->isLeftToRightDirection() ? paddingSta
rt() : paddingEnd(); |
| 527 | 525 |
| 528 // position the table sections | 526 // position the table sections |
| 529 RenderTableSection* section = topSection(); | 527 RenderTableSection* section = topSection(); |
| 530 while (section) { | 528 while (section) { |
| 531 if (!sectionMoved && section->logicalTop() != logicalHeight()) { | 529 if (!sectionMoved && section->logicalTop() != logicalHeight()) { |
| 532 sectionMoved = true; | 530 sectionMoved = true; |
| 533 movedSectionLogicalTop = min(logicalHeight(), section->logicalTo
p()) + (style()->isHorizontalWritingMode() ? section->visualOverflowRect().y() :
section->visualOverflowRect().x()); | 531 movedSectionLogicalTop = std::min(logicalHeight(), section->logi
calTop()) + (style()->isHorizontalWritingMode() ? section->visualOverflowRect().
y() : section->visualOverflowRect().x()); |
| 534 } | 532 } |
| 535 section->setLogicalLocation(LayoutPoint(sectionLogicalLeft, logicalH
eight())); | 533 section->setLogicalLocation(LayoutPoint(sectionLogicalLeft, logicalH
eight())); |
| 536 | 534 |
| 537 setLogicalHeight(logicalHeight() + section->logicalHeight()); | 535 setLogicalHeight(logicalHeight() + section->logicalHeight()); |
| 538 section = sectionBelow(section); | 536 section = sectionBelow(section); |
| 539 } | 537 } |
| 540 | 538 |
| 541 setLogicalHeight(logicalHeight() + borderAndPaddingAfter); | 539 setLogicalHeight(logicalHeight() + borderAndPaddingAfter); |
| 542 | 540 |
| 543 for (unsigned i = 0; i < m_captions.size(); i++) { | 541 for (unsigned i = 0; i < m_captions.size(); i++) { |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 759 | 757 |
| 760 computeIntrinsicLogicalWidths(m_minPreferredLogicalWidth, m_maxPreferredLogi
calWidth); | 758 computeIntrinsicLogicalWidths(m_minPreferredLogicalWidth, m_maxPreferredLogi
calWidth); |
| 761 | 759 |
| 762 int bordersPaddingAndSpacing = bordersPaddingAndSpacingInRowDirection(); | 760 int bordersPaddingAndSpacing = bordersPaddingAndSpacingInRowDirection(); |
| 763 m_minPreferredLogicalWidth += bordersPaddingAndSpacing; | 761 m_minPreferredLogicalWidth += bordersPaddingAndSpacing; |
| 764 m_maxPreferredLogicalWidth += bordersPaddingAndSpacing; | 762 m_maxPreferredLogicalWidth += bordersPaddingAndSpacing; |
| 765 | 763 |
| 766 m_tableLayout->applyPreferredLogicalWidthQuirks(m_minPreferredLogicalWidth,
m_maxPreferredLogicalWidth); | 764 m_tableLayout->applyPreferredLogicalWidthQuirks(m_minPreferredLogicalWidth,
m_maxPreferredLogicalWidth); |
| 767 | 765 |
| 768 for (unsigned i = 0; i < m_captions.size(); i++) | 766 for (unsigned i = 0; i < m_captions.size(); i++) |
| 769 m_minPreferredLogicalWidth = max(m_minPreferredLogicalWidth, m_captions[
i]->minPreferredLogicalWidth()); | 767 m_minPreferredLogicalWidth = std::max(m_minPreferredLogicalWidth, m_capt
ions[i]->minPreferredLogicalWidth()); |
| 770 | 768 |
| 771 RenderStyle* styleToUse = style(); | 769 RenderStyle* styleToUse = style(); |
| 772 // FIXME: This should probably be checking for isSpecified since you should
be able to use percentage or calc values for min-width. | 770 // FIXME: This should probably be checking for isSpecified since you should
be able to use percentage or calc values for min-width. |
| 773 if (styleToUse->logicalMinWidth().isFixed() && styleToUse->logicalMinWidth()
.value() > 0) { | 771 if (styleToUse->logicalMinWidth().isFixed() && styleToUse->logicalMinWidth()
.value() > 0) { |
| 774 m_maxPreferredLogicalWidth = std::max(m_maxPreferredLogicalWidth, adjust
ContentBoxLogicalWidthForBoxSizing(styleToUse->logicalMinWidth().value())); | 772 m_maxPreferredLogicalWidth = std::max(m_maxPreferredLogicalWidth, adjust
ContentBoxLogicalWidthForBoxSizing(styleToUse->logicalMinWidth().value())); |
| 775 m_minPreferredLogicalWidth = std::max(m_minPreferredLogicalWidth, adjust
ContentBoxLogicalWidthForBoxSizing(styleToUse->logicalMinWidth().value())); | 773 m_minPreferredLogicalWidth = std::max(m_minPreferredLogicalWidth, adjust
ContentBoxLogicalWidthForBoxSizing(styleToUse->logicalMinWidth().value())); |
| 776 } | 774 } |
| 777 | 775 |
| 778 // FIXME: This should probably be checking for isSpecified since you should
be able to use percentage or calc values for maxWidth. | 776 // FIXME: This should probably be checking for isSpecified since you should
be able to use percentage or calc values for maxWidth. |
| 779 if (styleToUse->logicalMaxWidth().isFixed()) { | 777 if (styleToUse->logicalMaxWidth().isFixed()) { |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 980 return 0; | 978 return 0; |
| 981 if (tableStartBorder.style() > BHIDDEN) | 979 if (tableStartBorder.style() > BHIDDEN) |
| 982 borderWidth = tableStartBorder.width(); | 980 borderWidth = tableStartBorder.width(); |
| 983 | 981 |
| 984 if (RenderTableCol* column = colElement(0)) { | 982 if (RenderTableCol* column = colElement(0)) { |
| 985 // FIXME: We don't account for direction on columns and column groups. | 983 // FIXME: We don't account for direction on columns and column groups. |
| 986 const BorderValue& columnAdjoiningBorder = column->style()->borderStart(
); | 984 const BorderValue& columnAdjoiningBorder = column->style()->borderStart(
); |
| 987 if (columnAdjoiningBorder.style() == BHIDDEN) | 985 if (columnAdjoiningBorder.style() == BHIDDEN) |
| 988 return 0; | 986 return 0; |
| 989 if (columnAdjoiningBorder.style() > BHIDDEN) | 987 if (columnAdjoiningBorder.style() > BHIDDEN) |
| 990 borderWidth = max(borderWidth, columnAdjoiningBorder.width()); | 988 borderWidth = std::max(borderWidth, columnAdjoiningBorder.width()); |
| 991 // FIXME: This logic doesn't properly account for the first column in th
e first column-group case. | 989 // FIXME: This logic doesn't properly account for the first column in th
e first column-group case. |
| 992 } | 990 } |
| 993 | 991 |
| 994 if (const RenderTableSection* topNonEmptySection = this->topNonEmptySection(
)) { | 992 if (const RenderTableSection* topNonEmptySection = this->topNonEmptySection(
)) { |
| 995 const BorderValue& sectionAdjoiningBorder = topNonEmptySection->borderAd
joiningTableStart(); | 993 const BorderValue& sectionAdjoiningBorder = topNonEmptySection->borderAd
joiningTableStart(); |
| 996 if (sectionAdjoiningBorder.style() == BHIDDEN) | 994 if (sectionAdjoiningBorder.style() == BHIDDEN) |
| 997 return 0; | 995 return 0; |
| 998 | 996 |
| 999 if (sectionAdjoiningBorder.style() > BHIDDEN) | 997 if (sectionAdjoiningBorder.style() > BHIDDEN) |
| 1000 borderWidth = max(borderWidth, sectionAdjoiningBorder.width()); | 998 borderWidth = std::max(borderWidth, sectionAdjoiningBorder.width()); |
| 1001 | 999 |
| 1002 if (const RenderTableCell* adjoiningStartCell = topNonEmptySection->firs
tRowCellAdjoiningTableStart()) { | 1000 if (const RenderTableCell* adjoiningStartCell = topNonEmptySection->firs
tRowCellAdjoiningTableStart()) { |
| 1003 // FIXME: Make this work with perpendicular and flipped cells. | 1001 // FIXME: Make this work with perpendicular and flipped cells. |
| 1004 const BorderValue& startCellAdjoiningBorder = adjoiningStartCell->bo
rderAdjoiningTableStart(); | 1002 const BorderValue& startCellAdjoiningBorder = adjoiningStartCell->bo
rderAdjoiningTableStart(); |
| 1005 if (startCellAdjoiningBorder.style() == BHIDDEN) | 1003 if (startCellAdjoiningBorder.style() == BHIDDEN) |
| 1006 return 0; | 1004 return 0; |
| 1007 | 1005 |
| 1008 const BorderValue& firstRowAdjoiningBorder = adjoiningStartCell->row
()->borderAdjoiningTableStart(); | 1006 const BorderValue& firstRowAdjoiningBorder = adjoiningStartCell->row
()->borderAdjoiningTableStart(); |
| 1009 if (firstRowAdjoiningBorder.style() == BHIDDEN) | 1007 if (firstRowAdjoiningBorder.style() == BHIDDEN) |
| 1010 return 0; | 1008 return 0; |
| 1011 | 1009 |
| 1012 if (startCellAdjoiningBorder.style() > BHIDDEN) | 1010 if (startCellAdjoiningBorder.style() > BHIDDEN) |
| 1013 borderWidth = max(borderWidth, startCellAdjoiningBorder.width())
; | 1011 borderWidth = std::max(borderWidth, startCellAdjoiningBorder.wid
th()); |
| 1014 if (firstRowAdjoiningBorder.style() > BHIDDEN) | 1012 if (firstRowAdjoiningBorder.style() > BHIDDEN) |
| 1015 borderWidth = max(borderWidth, firstRowAdjoiningBorder.width()); | 1013 borderWidth = std::max(borderWidth, firstRowAdjoiningBorder.widt
h()); |
| 1016 } | 1014 } |
| 1017 } | 1015 } |
| 1018 return (borderWidth + (style()->isLeftToRightDirection() ? 0 : 1)) / 2; | 1016 return (borderWidth + (style()->isLeftToRightDirection() ? 0 : 1)) / 2; |
| 1019 } | 1017 } |
| 1020 | 1018 |
| 1021 int RenderTable::calcBorderEnd() const | 1019 int RenderTable::calcBorderEnd() const |
| 1022 { | 1020 { |
| 1023 if (!collapseBorders()) | 1021 if (!collapseBorders()) |
| 1024 return RenderBlock::borderEnd(); | 1022 return RenderBlock::borderEnd(); |
| 1025 | 1023 |
| 1026 // Determined by the last cell of the first row. See the CSS 2.1 spec, secti
on 17.6.2. | 1024 // Determined by the last cell of the first row. See the CSS 2.1 spec, secti
on 17.6.2. |
| 1027 if (!numEffCols()) | 1025 if (!numEffCols()) |
| 1028 return 0; | 1026 return 0; |
| 1029 | 1027 |
| 1030 unsigned borderWidth = 0; | 1028 unsigned borderWidth = 0; |
| 1031 | 1029 |
| 1032 const BorderValue& tableEndBorder = style()->borderEnd(); | 1030 const BorderValue& tableEndBorder = style()->borderEnd(); |
| 1033 if (tableEndBorder.style() == BHIDDEN) | 1031 if (tableEndBorder.style() == BHIDDEN) |
| 1034 return 0; | 1032 return 0; |
| 1035 if (tableEndBorder.style() > BHIDDEN) | 1033 if (tableEndBorder.style() > BHIDDEN) |
| 1036 borderWidth = tableEndBorder.width(); | 1034 borderWidth = tableEndBorder.width(); |
| 1037 | 1035 |
| 1038 unsigned endColumn = numEffCols() - 1; | 1036 unsigned endColumn = numEffCols() - 1; |
| 1039 if (RenderTableCol* column = colElement(endColumn)) { | 1037 if (RenderTableCol* column = colElement(endColumn)) { |
| 1040 // FIXME: We don't account for direction on columns and column groups. | 1038 // FIXME: We don't account for direction on columns and column groups. |
| 1041 const BorderValue& columnAdjoiningBorder = column->style()->borderEnd(); | 1039 const BorderValue& columnAdjoiningBorder = column->style()->borderEnd(); |
| 1042 if (columnAdjoiningBorder.style() == BHIDDEN) | 1040 if (columnAdjoiningBorder.style() == BHIDDEN) |
| 1043 return 0; | 1041 return 0; |
| 1044 if (columnAdjoiningBorder.style() > BHIDDEN) | 1042 if (columnAdjoiningBorder.style() > BHIDDEN) |
| 1045 borderWidth = max(borderWidth, columnAdjoiningBorder.width()); | 1043 borderWidth = std::max(borderWidth, columnAdjoiningBorder.width()); |
| 1046 // FIXME: This logic doesn't properly account for the last column in the
last column-group case. | 1044 // FIXME: This logic doesn't properly account for the last column in the
last column-group case. |
| 1047 } | 1045 } |
| 1048 | 1046 |
| 1049 if (const RenderTableSection* topNonEmptySection = this->topNonEmptySection(
)) { | 1047 if (const RenderTableSection* topNonEmptySection = this->topNonEmptySection(
)) { |
| 1050 const BorderValue& sectionAdjoiningBorder = topNonEmptySection->borderAd
joiningTableEnd(); | 1048 const BorderValue& sectionAdjoiningBorder = topNonEmptySection->borderAd
joiningTableEnd(); |
| 1051 if (sectionAdjoiningBorder.style() == BHIDDEN) | 1049 if (sectionAdjoiningBorder.style() == BHIDDEN) |
| 1052 return 0; | 1050 return 0; |
| 1053 | 1051 |
| 1054 if (sectionAdjoiningBorder.style() > BHIDDEN) | 1052 if (sectionAdjoiningBorder.style() > BHIDDEN) |
| 1055 borderWidth = max(borderWidth, sectionAdjoiningBorder.width()); | 1053 borderWidth = std::max(borderWidth, sectionAdjoiningBorder.width()); |
| 1056 | 1054 |
| 1057 if (const RenderTableCell* adjoiningEndCell = topNonEmptySection->firstR
owCellAdjoiningTableEnd()) { | 1055 if (const RenderTableCell* adjoiningEndCell = topNonEmptySection->firstR
owCellAdjoiningTableEnd()) { |
| 1058 // FIXME: Make this work with perpendicular and flipped cells. | 1056 // FIXME: Make this work with perpendicular and flipped cells. |
| 1059 const BorderValue& endCellAdjoiningBorder = adjoiningEndCell->border
AdjoiningTableEnd(); | 1057 const BorderValue& endCellAdjoiningBorder = adjoiningEndCell->border
AdjoiningTableEnd(); |
| 1060 if (endCellAdjoiningBorder.style() == BHIDDEN) | 1058 if (endCellAdjoiningBorder.style() == BHIDDEN) |
| 1061 return 0; | 1059 return 0; |
| 1062 | 1060 |
| 1063 const BorderValue& firstRowAdjoiningBorder = adjoiningEndCell->row()
->borderAdjoiningTableEnd(); | 1061 const BorderValue& firstRowAdjoiningBorder = adjoiningEndCell->row()
->borderAdjoiningTableEnd(); |
| 1064 if (firstRowAdjoiningBorder.style() == BHIDDEN) | 1062 if (firstRowAdjoiningBorder.style() == BHIDDEN) |
| 1065 return 0; | 1063 return 0; |
| 1066 | 1064 |
| 1067 if (endCellAdjoiningBorder.style() > BHIDDEN) | 1065 if (endCellAdjoiningBorder.style() > BHIDDEN) |
| 1068 borderWidth = max(borderWidth, endCellAdjoiningBorder.width()); | 1066 borderWidth = std::max(borderWidth, endCellAdjoiningBorder.width
()); |
| 1069 if (firstRowAdjoiningBorder.style() > BHIDDEN) | 1067 if (firstRowAdjoiningBorder.style() > BHIDDEN) |
| 1070 borderWidth = max(borderWidth, firstRowAdjoiningBorder.width()); | 1068 borderWidth = std::max(borderWidth, firstRowAdjoiningBorder.widt
h()); |
| 1071 } | 1069 } |
| 1072 } | 1070 } |
| 1073 return (borderWidth + (style()->isLeftToRightDirection() ? 1 : 0)) / 2; | 1071 return (borderWidth + (style()->isLeftToRightDirection() ? 1 : 0)) / 2; |
| 1074 } | 1072 } |
| 1075 | 1073 |
| 1076 void RenderTable::recalcBordersInRowDirection() | 1074 void RenderTable::recalcBordersInRowDirection() |
| 1077 { | 1075 { |
| 1078 // FIXME: We need to compute the collapsed before / after borders in the sam
e fashion. | 1076 // FIXME: We need to compute the collapsed before / after borders in the sam
e fashion. |
| 1079 m_borderStart = calcBorderStart(); | 1077 m_borderStart = calcBorderStart(); |
| 1080 m_borderEnd = calcBorderEnd(); | 1078 m_borderEnd = calcBorderEnd(); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 1105 int borderWidth = 0; | 1103 int borderWidth = 0; |
| 1106 if (RenderTableSection* topSection = this->topSection()) { | 1104 if (RenderTableSection* topSection = this->topSection()) { |
| 1107 borderWidth = topSection->outerBorderBefore(); | 1105 borderWidth = topSection->outerBorderBefore(); |
| 1108 if (borderWidth < 0) | 1106 if (borderWidth < 0) |
| 1109 return 0; // Overridden by hidden | 1107 return 0; // Overridden by hidden |
| 1110 } | 1108 } |
| 1111 const BorderValue& tb = style()->borderBefore(); | 1109 const BorderValue& tb = style()->borderBefore(); |
| 1112 if (tb.style() == BHIDDEN) | 1110 if (tb.style() == BHIDDEN) |
| 1113 return 0; | 1111 return 0; |
| 1114 if (tb.style() > BHIDDEN) | 1112 if (tb.style() > BHIDDEN) |
| 1115 borderWidth = max<int>(borderWidth, tb.width() / 2); | 1113 borderWidth = std::max<int>(borderWidth, tb.width() / 2); |
| 1116 return borderWidth; | 1114 return borderWidth; |
| 1117 } | 1115 } |
| 1118 | 1116 |
| 1119 int RenderTable::outerBorderAfter() const | 1117 int RenderTable::outerBorderAfter() const |
| 1120 { | 1118 { |
| 1121 if (!collapseBorders()) | 1119 if (!collapseBorders()) |
| 1122 return 0; | 1120 return 0; |
| 1123 int borderWidth = 0; | 1121 int borderWidth = 0; |
| 1124 | 1122 |
| 1125 if (RenderTableSection* section = bottomSection()) { | 1123 if (RenderTableSection* section = bottomSection()) { |
| 1126 borderWidth = section->outerBorderAfter(); | 1124 borderWidth = section->outerBorderAfter(); |
| 1127 if (borderWidth < 0) | 1125 if (borderWidth < 0) |
| 1128 return 0; // Overridden by hidden | 1126 return 0; // Overridden by hidden |
| 1129 } | 1127 } |
| 1130 const BorderValue& tb = style()->borderAfter(); | 1128 const BorderValue& tb = style()->borderAfter(); |
| 1131 if (tb.style() == BHIDDEN) | 1129 if (tb.style() == BHIDDEN) |
| 1132 return 0; | 1130 return 0; |
| 1133 if (tb.style() > BHIDDEN) | 1131 if (tb.style() > BHIDDEN) |
| 1134 borderWidth = max<int>(borderWidth, (tb.width() + 1) / 2); | 1132 borderWidth = std::max<int>(borderWidth, (tb.width() + 1) / 2); |
| 1135 return borderWidth; | 1133 return borderWidth; |
| 1136 } | 1134 } |
| 1137 | 1135 |
| 1138 int RenderTable::outerBorderStart() const | 1136 int RenderTable::outerBorderStart() const |
| 1139 { | 1137 { |
| 1140 if (!collapseBorders()) | 1138 if (!collapseBorders()) |
| 1141 return 0; | 1139 return 0; |
| 1142 | 1140 |
| 1143 int borderWidth = 0; | 1141 int borderWidth = 0; |
| 1144 | 1142 |
| 1145 const BorderValue& tb = style()->borderStart(); | 1143 const BorderValue& tb = style()->borderStart(); |
| 1146 if (tb.style() == BHIDDEN) | 1144 if (tb.style() == BHIDDEN) |
| 1147 return 0; | 1145 return 0; |
| 1148 if (tb.style() > BHIDDEN) | 1146 if (tb.style() > BHIDDEN) |
| 1149 borderWidth = (tb.width() + (style()->isLeftToRightDirection() ? 0 : 1))
/ 2; | 1147 borderWidth = (tb.width() + (style()->isLeftToRightDirection() ? 0 : 1))
/ 2; |
| 1150 | 1148 |
| 1151 bool allHidden = true; | 1149 bool allHidden = true; |
| 1152 for (RenderTableSection* section = topSection(); section; section = sectionB
elow(section)) { | 1150 for (RenderTableSection* section = topSection(); section; section = sectionB
elow(section)) { |
| 1153 int sw = section->outerBorderStart(); | 1151 int sw = section->outerBorderStart(); |
| 1154 if (sw < 0) | 1152 if (sw < 0) |
| 1155 continue; | 1153 continue; |
| 1156 allHidden = false; | 1154 allHidden = false; |
| 1157 borderWidth = max(borderWidth, sw); | 1155 borderWidth = std::max(borderWidth, sw); |
| 1158 } | 1156 } |
| 1159 if (allHidden) | 1157 if (allHidden) |
| 1160 return 0; | 1158 return 0; |
| 1161 | 1159 |
| 1162 return borderWidth; | 1160 return borderWidth; |
| 1163 } | 1161 } |
| 1164 | 1162 |
| 1165 int RenderTable::outerBorderEnd() const | 1163 int RenderTable::outerBorderEnd() const |
| 1166 { | 1164 { |
| 1167 if (!collapseBorders()) | 1165 if (!collapseBorders()) |
| 1168 return 0; | 1166 return 0; |
| 1169 | 1167 |
| 1170 int borderWidth = 0; | 1168 int borderWidth = 0; |
| 1171 | 1169 |
| 1172 const BorderValue& tb = style()->borderEnd(); | 1170 const BorderValue& tb = style()->borderEnd(); |
| 1173 if (tb.style() == BHIDDEN) | 1171 if (tb.style() == BHIDDEN) |
| 1174 return 0; | 1172 return 0; |
| 1175 if (tb.style() > BHIDDEN) | 1173 if (tb.style() > BHIDDEN) |
| 1176 borderWidth = (tb.width() + (style()->isLeftToRightDirection() ? 1 : 0))
/ 2; | 1174 borderWidth = (tb.width() + (style()->isLeftToRightDirection() ? 1 : 0))
/ 2; |
| 1177 | 1175 |
| 1178 bool allHidden = true; | 1176 bool allHidden = true; |
| 1179 for (RenderTableSection* section = topSection(); section; section = sectionB
elow(section)) { | 1177 for (RenderTableSection* section = topSection(); section; section = sectionB
elow(section)) { |
| 1180 int sw = section->outerBorderEnd(); | 1178 int sw = section->outerBorderEnd(); |
| 1181 if (sw < 0) | 1179 if (sw < 0) |
| 1182 continue; | 1180 continue; |
| 1183 allHidden = false; | 1181 allHidden = false; |
| 1184 borderWidth = max(borderWidth, sw); | 1182 borderWidth = std::max(borderWidth, sw); |
| 1185 } | 1183 } |
| 1186 if (allHidden) | 1184 if (allHidden) |
| 1187 return 0; | 1185 return 0; |
| 1188 | 1186 |
| 1189 return borderWidth; | 1187 return borderWidth; |
| 1190 } | 1188 } |
| 1191 | 1189 |
| 1192 RenderTableSection* RenderTable::sectionAbove(const RenderTableSection* section,
SkipEmptySectionsValue skipEmptySections) const | 1190 RenderTableSection* RenderTable::sectionAbove(const RenderTableSection* section,
SkipEmptySectionsValue skipEmptySections) const |
| 1193 { | 1191 { |
| 1194 recalcSectionsIfNeeded(); | 1192 recalcSectionsIfNeeded(); |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1443 const BorderValue& RenderTable::tableEndBorderAdjoiningCell(const RenderTableCel
l* cell) const | 1441 const BorderValue& RenderTable::tableEndBorderAdjoiningCell(const RenderTableCel
l* cell) const |
| 1444 { | 1442 { |
| 1445 ASSERT(cell->isFirstOrLastCellInRow()); | 1443 ASSERT(cell->isFirstOrLastCellInRow()); |
| 1446 if (hasSameDirectionAs(cell->row())) | 1444 if (hasSameDirectionAs(cell->row())) |
| 1447 return style()->borderEnd(); | 1445 return style()->borderEnd(); |
| 1448 | 1446 |
| 1449 return style()->borderStart(); | 1447 return style()->borderStart(); |
| 1450 } | 1448 } |
| 1451 | 1449 |
| 1452 } | 1450 } |
| OLD | NEW |