| 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 Apple Inc. All r
ights reserved. | 7 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All r
ights 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 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 246 if (isOutOfFlowPositioned()) { | 246 if (isOutOfFlowPositioned()) { |
| 247 LogicalExtentComputedValues computedValues; | 247 LogicalExtentComputedValues computedValues; |
| 248 computePositionedLogicalWidth(computedValues); | 248 computePositionedLogicalWidth(computedValues); |
| 249 setLogicalWidth(computedValues.m_extent); | 249 setLogicalWidth(computedValues.m_extent); |
| 250 setLogicalLeft(computedValues.m_position); | 250 setLogicalLeft(computedValues.m_position); |
| 251 setMarginStart(computedValues.m_margins.m_start); | 251 setMarginStart(computedValues.m_margins.m_start); |
| 252 setMarginEnd(computedValues.m_margins.m_end); | 252 setMarginEnd(computedValues.m_margins.m_end); |
| 253 } | 253 } |
| 254 | 254 |
| 255 RenderBlock* cb = containingBlock(); | 255 RenderBlock* cb = containingBlock(); |
| 256 RenderView* renderView = view(); | |
| 257 | 256 |
| 258 LayoutUnit availableLogicalWidth = containingBlockLogicalWidthForContent(); | 257 LayoutUnit availableLogicalWidth = containingBlockLogicalWidthForContent(); |
| 259 bool hasPerpendicularContainingBlock = cb->style()->isHorizontalWritingMode(
) != style()->isHorizontalWritingMode(); | 258 bool hasPerpendicularContainingBlock = cb->style()->isHorizontalWritingMode(
) != style()->isHorizontalWritingMode(); |
| 260 LayoutUnit containerWidthInInlineDirection = hasPerpendicularContainingBlock
? perpendicularContainingBlockLogicalHeight() : availableLogicalWidth; | 259 LayoutUnit containerWidthInInlineDirection = hasPerpendicularContainingBlock
? perpendicularContainingBlockLogicalHeight() : availableLogicalWidth; |
| 261 | 260 |
| 262 Length styleLogicalWidth = style()->logicalWidth(); | 261 Length styleLogicalWidth = style()->logicalWidth(); |
| 263 if ((styleLogicalWidth.isSpecified() && styleLogicalWidth.isPositive()) || s
tyleLogicalWidth.isIntrinsic()) | 262 if ((styleLogicalWidth.isSpecified() && styleLogicalWidth.isPositive()) || s
tyleLogicalWidth.isIntrinsic()) |
| 264 setLogicalWidth(convertStyleLogicalWidthToComputedWidth(styleLogicalWidt
h, containerWidthInInlineDirection)); | 263 setLogicalWidth(convertStyleLogicalWidthToComputedWidth(styleLogicalWidt
h, containerWidthInInlineDirection)); |
| 265 else { | 264 else { |
| 266 // Subtract out any fixed margins from our available width for auto widt
h tables. | 265 // Subtract out any fixed margins from our available width for auto widt
h tables. |
| 267 LayoutUnit marginStart = minimumValueForLength(style()->marginStart(), a
vailableLogicalWidth, renderView); | 266 LayoutUnit marginStart = minimumValueForLength(style()->marginStart(), a
vailableLogicalWidth); |
| 268 LayoutUnit marginEnd = minimumValueForLength(style()->marginEnd(), avail
ableLogicalWidth, renderView); | 267 LayoutUnit marginEnd = minimumValueForLength(style()->marginEnd(), avail
ableLogicalWidth); |
| 269 LayoutUnit marginTotal = marginStart + marginEnd; | 268 LayoutUnit marginTotal = marginStart + marginEnd; |
| 270 | 269 |
| 271 // Subtract out our margins to get the available content width. | 270 // Subtract out our margins to get the available content width. |
| 272 LayoutUnit availableContentLogicalWidth = max<LayoutUnit>(0, containerWi
dthInInlineDirection - marginTotal); | 271 LayoutUnit availableContentLogicalWidth = max<LayoutUnit>(0, containerWi
dthInInlineDirection - marginTotal); |
| 273 if (shrinkToAvoidFloats() && cb->containsFloats() && !hasPerpendicularCo
ntainingBlock) { | 272 if (shrinkToAvoidFloats() && cb->containsFloats() && !hasPerpendicularCo
ntainingBlock) { |
| 274 // FIXME: Work with regions someday. | 273 // FIXME: Work with regions someday. |
| 275 availableContentLogicalWidth = shrinkLogicalWidthToAvoidFloats(margi
nStart, marginEnd, toRenderBlockFlow(cb), 0); | 274 availableContentLogicalWidth = shrinkLogicalWidthToAvoidFloats(margi
nStart, marginEnd, toRenderBlockFlow(cb), 0); |
| 276 } | 275 } |
| 277 | 276 |
| 278 // Ensure we aren't bigger than our available width. | 277 // Ensure we aren't bigger than our available width. |
| (...skipping 26 matching lines...) Expand all Loading... |
| 305 if (avoidsFloats() && cb->containsFloats()) | 304 if (avoidsFloats() && cb->containsFloats()) |
| 306 containerLogicalWidthForAutoMargins = containingBlockAvailableLineWi
dthInRegion(0); // FIXME: Work with regions someday. | 305 containerLogicalWidthForAutoMargins = containingBlockAvailableLineWi
dthInRegion(0); // FIXME: Work with regions someday. |
| 307 ComputedMarginValues marginValues; | 306 ComputedMarginValues marginValues; |
| 308 bool hasInvertedDirection = cb->style()->isLeftToRightDirection() == st
yle()->isLeftToRightDirection(); | 307 bool hasInvertedDirection = cb->style()->isLeftToRightDirection() == st
yle()->isLeftToRightDirection(); |
| 309 computeInlineDirectionMargins(cb, containerLogicalWidthForAutoMargins, l
ogicalWidth(), | 308 computeInlineDirectionMargins(cb, containerLogicalWidthForAutoMargins, l
ogicalWidth(), |
| 310 hasInvertedDirection ? marginValues.m_start : marginValues.m_end, | 309 hasInvertedDirection ? marginValues.m_start : marginValues.m_end, |
| 311 hasInvertedDirection ? marginValues.m_end : marginValues.m_start); | 310 hasInvertedDirection ? marginValues.m_end : marginValues.m_start); |
| 312 setMarginStart(marginValues.m_start); | 311 setMarginStart(marginValues.m_start); |
| 313 setMarginEnd(marginValues.m_end); | 312 setMarginEnd(marginValues.m_end); |
| 314 } else { | 313 } else { |
| 315 setMarginStart(minimumValueForLength(style()->marginStart(), availableLo
gicalWidth, renderView)); | 314 setMarginStart(minimumValueForLength(style()->marginStart(), availableLo
gicalWidth)); |
| 316 setMarginEnd(minimumValueForLength(style()->marginEnd(), availableLogica
lWidth, renderView)); | 315 setMarginEnd(minimumValueForLength(style()->marginEnd(), availableLogica
lWidth)); |
| 317 } | 316 } |
| 318 | 317 |
| 319 // We should NEVER shrink the table below the min-content logical width, or
else the table can't accomodate | 318 // We should NEVER shrink the table below the min-content logical width, or
else the table can't accomodate |
| 320 // its own content which doesn't match CSS nor what authors expect. | 319 // its own content which doesn't match CSS nor what authors expect. |
| 321 // FIXME: When we convert to sub-pixel layout for tables we can remove the i
nt conversion | 320 // FIXME: When we convert to sub-pixel layout for tables we can remove the i
nt conversion |
| 322 // https://code.google.com/p/chromium/issues/detail?id=241198 | 321 // https://code.google.com/p/chromium/issues/detail?id=241198 |
| 323 ASSERT(logicalWidth().toInt() >= minPreferredLogicalWidth().toInt()); | 322 ASSERT(logicalWidth().toInt() >= minPreferredLogicalWidth().toInt()); |
| 324 } | 323 } |
| 325 | 324 |
| 326 // This method takes a RenderStyle's logical width, min-width, or max-width leng
th and computes its actual value. | 325 // This method takes a RenderStyle's logical width, min-width, or max-width leng
th and computes its actual value. |
| 327 LayoutUnit RenderTable::convertStyleLogicalWidthToComputedWidth(const Length& st
yleLogicalWidth, LayoutUnit availableWidth) | 326 LayoutUnit RenderTable::convertStyleLogicalWidthToComputedWidth(const Length& st
yleLogicalWidth, LayoutUnit availableWidth) |
| 328 { | 327 { |
| 329 if (styleLogicalWidth.isIntrinsic()) | 328 if (styleLogicalWidth.isIntrinsic()) |
| 330 return computeIntrinsicLogicalWidthUsing(styleLogicalWidth, availableWid
th, bordersPaddingAndSpacingInRowDirection()); | 329 return computeIntrinsicLogicalWidthUsing(styleLogicalWidth, availableWid
th, bordersPaddingAndSpacingInRowDirection()); |
| 331 | 330 |
| 332 // HTML tables' width styles already include borders and paddings, but CSS t
ables' width styles do not. | 331 // HTML tables' width styles already include borders and paddings, but CSS t
ables' width styles do not. |
| 333 LayoutUnit borders = 0; | 332 LayoutUnit borders = 0; |
| 334 bool isCSSTable = !node() || !isHTMLTableElement(node()); | 333 bool isCSSTable = !node() || !isHTMLTableElement(node()); |
| 335 if (isCSSTable && styleLogicalWidth.isSpecified() && styleLogicalWidth.isPos
itive() && style()->boxSizing() == CONTENT_BOX) | 334 if (isCSSTable && styleLogicalWidth.isSpecified() && styleLogicalWidth.isPos
itive() && style()->boxSizing() == CONTENT_BOX) |
| 336 borders = borderStart() + borderEnd() + (collapseBorders() ? LayoutUnit(
) : paddingStart() + paddingEnd()); | 335 borders = borderStart() + borderEnd() + (collapseBorders() ? LayoutUnit(
) : paddingStart() + paddingEnd()); |
| 337 | 336 |
| 338 return minimumValueForLength(styleLogicalWidth, availableWidth, view()) + bo
rders; | 337 return minimumValueForLength(styleLogicalWidth, availableWidth) + borders; |
| 339 } | 338 } |
| 340 | 339 |
| 341 LayoutUnit RenderTable::convertStyleLogicalHeightToComputedHeight(const Length&
styleLogicalHeight) | 340 LayoutUnit RenderTable::convertStyleLogicalHeightToComputedHeight(const Length&
styleLogicalHeight) |
| 342 { | 341 { |
| 343 LayoutUnit borderAndPaddingBefore = borderBefore() + (collapseBorders() ? La
youtUnit() : paddingBefore()); | 342 LayoutUnit borderAndPaddingBefore = borderBefore() + (collapseBorders() ? La
youtUnit() : paddingBefore()); |
| 344 LayoutUnit borderAndPaddingAfter = borderAfter() + (collapseBorders() ? Layo
utUnit() : paddingAfter()); | 343 LayoutUnit borderAndPaddingAfter = borderAfter() + (collapseBorders() ? Layo
utUnit() : paddingAfter()); |
| 345 LayoutUnit borderAndPadding = borderAndPaddingBefore + borderAndPaddingAfter
; | 344 LayoutUnit borderAndPadding = borderAndPaddingBefore + borderAndPaddingAfter
; |
| 346 LayoutUnit computedLogicalHeight = 0; | 345 LayoutUnit computedLogicalHeight = 0; |
| 347 if (styleLogicalHeight.isFixed()) { | 346 if (styleLogicalHeight.isFixed()) { |
| 348 // HTML tables size as though CSS height includes border/padding, CSS ta
bles do not. | 347 // HTML tables size as though CSS height includes border/padding, CSS ta
bles do not. |
| 349 LayoutUnit borders = LayoutUnit(); | 348 LayoutUnit borders = LayoutUnit(); |
| 350 // FIXME: We cannot apply box-sizing: content-box on <table> which other
browsers allow. | 349 // FIXME: We cannot apply box-sizing: content-box on <table> which other
browsers allow. |
| 351 if ((node() && isHTMLTableElement(node())) || style()->boxSizing() == BO
RDER_BOX) { | 350 if ((node() && isHTMLTableElement(node())) || style()->boxSizing() == BO
RDER_BOX) { |
| 352 borders = borderAndPadding; | 351 borders = borderAndPadding; |
| 353 } | 352 } |
| 354 computedLogicalHeight = styleLogicalHeight.value() - borders; | 353 computedLogicalHeight = styleLogicalHeight.value() - borders; |
| 355 } else if (styleLogicalHeight.isPercent()) | 354 } else if (styleLogicalHeight.isPercent()) |
| 356 computedLogicalHeight = computePercentageLogicalHeight(styleLogicalHeigh
t); | 355 computedLogicalHeight = computePercentageLogicalHeight(styleLogicalHeigh
t); |
| 357 else if (styleLogicalHeight.isViewportPercentage()) | |
| 358 computedLogicalHeight = minimumValueForLength(styleLogicalHeight, 0, vie
w()); | |
| 359 else if (styleLogicalHeight.isIntrinsic()) | 356 else if (styleLogicalHeight.isIntrinsic()) |
| 360 computedLogicalHeight = computeIntrinsicLogicalContentHeightUsing(styleL
ogicalHeight, logicalHeight() - borderAndPadding, borderAndPadding); | 357 computedLogicalHeight = computeIntrinsicLogicalContentHeightUsing(styleL
ogicalHeight, logicalHeight() - borderAndPadding, borderAndPadding); |
| 361 else | 358 else |
| 362 ASSERT_NOT_REACHED(); | 359 ASSERT_NOT_REACHED(); |
| 363 return max<LayoutUnit>(0, computedLogicalHeight); | 360 return max<LayoutUnit>(0, computedLogicalHeight); |
| 364 } | 361 } |
| 365 | 362 |
| 366 void RenderTable::layoutCaption(RenderTableCaption* caption) | 363 void RenderTable::layoutCaption(RenderTableCaption* caption) |
| 367 { | 364 { |
| 368 LayoutRect captionRect(caption->frameRect()); | 365 LayoutRect captionRect(caption->frameRect()); |
| (...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 766 int bordersPaddingAndSpacing = bordersPaddingAndSpacingInRowDirection(); | 763 int bordersPaddingAndSpacing = bordersPaddingAndSpacingInRowDirection(); |
| 767 m_minPreferredLogicalWidth += bordersPaddingAndSpacing; | 764 m_minPreferredLogicalWidth += bordersPaddingAndSpacing; |
| 768 m_maxPreferredLogicalWidth += bordersPaddingAndSpacing; | 765 m_maxPreferredLogicalWidth += bordersPaddingAndSpacing; |
| 769 | 766 |
| 770 m_tableLayout->applyPreferredLogicalWidthQuirks(m_minPreferredLogicalWidth,
m_maxPreferredLogicalWidth); | 767 m_tableLayout->applyPreferredLogicalWidthQuirks(m_minPreferredLogicalWidth,
m_maxPreferredLogicalWidth); |
| 771 | 768 |
| 772 for (unsigned i = 0; i < m_captions.size(); i++) | 769 for (unsigned i = 0; i < m_captions.size(); i++) |
| 773 m_minPreferredLogicalWidth = max(m_minPreferredLogicalWidth, m_captions[
i]->minPreferredLogicalWidth()); | 770 m_minPreferredLogicalWidth = max(m_minPreferredLogicalWidth, m_captions[
i]->minPreferredLogicalWidth()); |
| 774 | 771 |
| 775 RenderStyle* styleToUse = style(); | 772 RenderStyle* styleToUse = style(); |
| 776 // FIXME: This should probably be checking for isSpecified since you should
be able to use percentage, calc or viewport relative values for min-width. | 773 // FIXME: This should probably be checking for isSpecified since you should
be able to use percentage or calc values for min-width. |
| 777 if (styleToUse->logicalMinWidth().isFixed() && styleToUse->logicalMinWidth()
.value() > 0) { | 774 if (styleToUse->logicalMinWidth().isFixed() && styleToUse->logicalMinWidth()
.value() > 0) { |
| 778 m_maxPreferredLogicalWidth = std::max(m_maxPreferredLogicalWidth, adjust
ContentBoxLogicalWidthForBoxSizing(styleToUse->logicalMinWidth().value())); | 775 m_maxPreferredLogicalWidth = std::max(m_maxPreferredLogicalWidth, adjust
ContentBoxLogicalWidthForBoxSizing(styleToUse->logicalMinWidth().value())); |
| 779 m_minPreferredLogicalWidth = std::max(m_minPreferredLogicalWidth, adjust
ContentBoxLogicalWidthForBoxSizing(styleToUse->logicalMinWidth().value())); | 776 m_minPreferredLogicalWidth = std::max(m_minPreferredLogicalWidth, adjust
ContentBoxLogicalWidthForBoxSizing(styleToUse->logicalMinWidth().value())); |
| 780 } | 777 } |
| 781 | 778 |
| 782 // FIXME: This should probably be checking for isSpecified since you should
be able to use percentage, calc or viewport relative values for maxWidth. | 779 // FIXME: This should probably be checking for isSpecified since you should
be able to use percentage or calc values for maxWidth. |
| 783 if (styleToUse->logicalMaxWidth().isFixed()) { | 780 if (styleToUse->logicalMaxWidth().isFixed()) { |
| 784 // We don't constrain m_minPreferredLogicalWidth as the table should be
at least the size of its min-content, regardless of 'max-width'. | 781 // We don't constrain m_minPreferredLogicalWidth as the table should be
at least the size of its min-content, regardless of 'max-width'. |
| 785 m_maxPreferredLogicalWidth = std::min(m_maxPreferredLogicalWidth, adjust
ContentBoxLogicalWidthForBoxSizing(styleToUse->logicalMaxWidth().value())); | 782 m_maxPreferredLogicalWidth = std::min(m_maxPreferredLogicalWidth, adjust
ContentBoxLogicalWidthForBoxSizing(styleToUse->logicalMaxWidth().value())); |
| 786 m_maxPreferredLogicalWidth = std::max(m_minPreferredLogicalWidth, m_maxP
referredLogicalWidth); | 783 m_maxPreferredLogicalWidth = std::max(m_minPreferredLogicalWidth, m_maxP
referredLogicalWidth); |
| 787 } | 784 } |
| 788 | 785 |
| 789 // FIXME: We should be adding borderAndPaddingLogicalWidth here, but m_table
Layout->computePreferredLogicalWidths already does, | 786 // FIXME: We should be adding borderAndPaddingLogicalWidth here, but m_table
Layout->computePreferredLogicalWidths already does, |
| 790 // so a bunch of tests break doing this naively. | 787 // so a bunch of tests break doing this naively. |
| 791 clearPreferredLogicalWidthsDirty(); | 788 clearPreferredLogicalWidthsDirty(); |
| 792 } | 789 } |
| (...skipping 646 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1439 const BorderValue& RenderTable::tableEndBorderAdjoiningCell(const RenderTableCel
l* cell) const | 1436 const BorderValue& RenderTable::tableEndBorderAdjoiningCell(const RenderTableCel
l* cell) const |
| 1440 { | 1437 { |
| 1441 ASSERT(cell->isFirstOrLastCellInRow()); | 1438 ASSERT(cell->isFirstOrLastCellInRow()); |
| 1442 if (hasSameDirectionAs(cell->row())) | 1439 if (hasSameDirectionAs(cell->row())) |
| 1443 return style()->borderEnd(); | 1440 return style()->borderEnd(); |
| 1444 | 1441 |
| 1445 return style()->borderStart(); | 1442 return style()->borderStart(); |
| 1446 } | 1443 } |
| 1447 | 1444 |
| 1448 } | 1445 } |
| OLD | NEW |