| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
| 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
| 4 * (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com) | 4 * (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com) |
| 5 * (C) 2005, 2006 Samuel Weinig (sam.weinig@gmail.com) | 5 * (C) 2005, 2006 Samuel Weinig (sam.weinig@gmail.com) |
| 6 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserv
ed. | 6 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserv
ed. |
| 7 * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved. | 7 * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved. |
| 8 * | 8 * |
| 9 * This library is free software; you can redistribute it and/or | 9 * This library is free software; you can redistribute it and/or |
| 10 * modify it under the terms of the GNU Library General Public | 10 * modify it under the terms of the GNU Library General Public |
| (...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 444 { | 444 { |
| 445 if (hasOverflowClip()) | 445 if (hasOverflowClip()) |
| 446 return layer()->scrollableArea()->scrollHeight(); | 446 return layer()->scrollableArea()->scrollHeight(); |
| 447 // For objects with visible overflow, this matches IE. | 447 // For objects with visible overflow, this matches IE. |
| 448 // FIXME: Need to work right with writing modes. | 448 // FIXME: Need to work right with writing modes. |
| 449 return std::max(clientHeight(), layoutOverflowRect().maxY() - borderTop()); | 449 return std::max(clientHeight(), layoutOverflowRect().maxY() - borderTop()); |
| 450 } | 450 } |
| 451 | 451 |
| 452 LayoutUnit LayoutBox::scrollLeft() const | 452 LayoutUnit LayoutBox::scrollLeft() const |
| 453 { | 453 { |
| 454 return hasOverflowClip() ? layer()->scrollableArea()->scrollXOffset() : 0; | 454 return hasOverflowClip() ? LayoutUnit(layer()->scrollableArea()->scrollXOffs
et()) : LayoutUnit(); |
| 455 } | 455 } |
| 456 | 456 |
| 457 LayoutUnit LayoutBox::scrollTop() const | 457 LayoutUnit LayoutBox::scrollTop() const |
| 458 { | 458 { |
| 459 return hasOverflowClip() ? layer()->scrollableArea()->scrollYOffset() : 0; | 459 return hasOverflowClip() ? LayoutUnit(layer()->scrollableArea()->scrollYOffs
et()) : LayoutUnit(); |
| 460 } | 460 } |
| 461 | 461 |
| 462 int LayoutBox::pixelSnappedScrollWidth() const | 462 int LayoutBox::pixelSnappedScrollWidth() const |
| 463 { | 463 { |
| 464 return snapSizeToPixel(scrollWidth(), location().x() + clientLeft()); | 464 return snapSizeToPixel(scrollWidth(), location().x() + clientLeft()); |
| 465 } | 465 } |
| 466 | 466 |
| 467 int LayoutBox::pixelSnappedScrollHeight() const | 467 int LayoutBox::pixelSnappedScrollHeight() const |
| 468 { | 468 { |
| 469 if (hasOverflowClip()) | 469 if (hasOverflowClip()) |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 605 return std::max(logicalHeight, computeLogicalHeightUsing(MinSize, styleToUse
.logicalMinHeight(), intrinsicContentHeight)); | 605 return std::max(logicalHeight, computeLogicalHeightUsing(MinSize, styleToUse
.logicalMinHeight(), intrinsicContentHeight)); |
| 606 } | 606 } |
| 607 | 607 |
| 608 LayoutUnit LayoutBox::constrainContentBoxLogicalHeightByMinMax(LayoutUnit logica
lHeight, LayoutUnit intrinsicContentHeight) const | 608 LayoutUnit LayoutBox::constrainContentBoxLogicalHeightByMinMax(LayoutUnit logica
lHeight, LayoutUnit intrinsicContentHeight) const |
| 609 { | 609 { |
| 610 // If the min/max height and logical height are both percentages we take adv
antage of already knowing the current resolved percentage height | 610 // If the min/max height and logical height are both percentages we take adv
antage of already knowing the current resolved percentage height |
| 611 // to avoid recursing up through our containing blocks again to determine it
. | 611 // to avoid recursing up through our containing blocks again to determine it
. |
| 612 const ComputedStyle& styleToUse = styleRef(); | 612 const ComputedStyle& styleToUse = styleRef(); |
| 613 if (!styleToUse.logicalMaxHeight().isMaxSizeNone()) { | 613 if (!styleToUse.logicalMaxHeight().isMaxSizeNone()) { |
| 614 if (styleToUse.logicalMaxHeight().hasPercent() && styleToUse.logicalHeig
ht().hasPercent()) { | 614 if (styleToUse.logicalMaxHeight().hasPercent() && styleToUse.logicalHeig
ht().hasPercent()) { |
| 615 LayoutUnit availableLogicalHeight = logicalHeight / styleToUse.logic
alHeight().value() * 100; | 615 LayoutUnit availableLogicalHeight(logicalHeight / styleToUse.logical
Height().value() * 100); |
| 616 logicalHeight = std::min(logicalHeight, valueForLength(styleToUse.lo
gicalMaxHeight(), availableLogicalHeight)); | 616 logicalHeight = std::min(logicalHeight, valueForLength(styleToUse.lo
gicalMaxHeight(), availableLogicalHeight)); |
| 617 } else { | 617 } else { |
| 618 LayoutUnit maxHeight = computeContentLogicalHeight(MaxSize, styleToU
se.logicalMaxHeight(), LayoutUnit(-1)); | 618 LayoutUnit maxHeight(computeContentLogicalHeight(MaxSize, styleToUse
.logicalMaxHeight(), LayoutUnit(-1))); |
| 619 if (maxHeight != -1) | 619 if (maxHeight != -1) |
| 620 logicalHeight = std::min(logicalHeight, maxHeight); | 620 logicalHeight = std::min(logicalHeight, maxHeight); |
| 621 } | 621 } |
| 622 } | 622 } |
| 623 | 623 |
| 624 if (styleToUse.logicalMinHeight().hasPercent() && styleToUse.logicalHeight()
.hasPercent()) { | 624 if (styleToUse.logicalMinHeight().hasPercent() && styleToUse.logicalHeight()
.hasPercent()) { |
| 625 LayoutUnit availableLogicalHeight = logicalHeight / styleToUse.logicalHe
ight().value() * 100; | 625 LayoutUnit availableLogicalHeight(logicalHeight / styleToUse.logicalHeig
ht().value() * 100); |
| 626 logicalHeight = std::max(logicalHeight, valueForLength(styleToUse.logica
lMinHeight(), availableLogicalHeight)); | 626 logicalHeight = std::max(logicalHeight, valueForLength(styleToUse.logica
lMinHeight(), availableLogicalHeight)); |
| 627 } else { | 627 } else { |
| 628 logicalHeight = std::max(logicalHeight, computeContentLogicalHeight(MinS
ize, styleToUse.logicalMinHeight(), intrinsicContentHeight)); | 628 logicalHeight = std::max(logicalHeight, computeContentLogicalHeight(MinS
ize, styleToUse.logicalMinHeight(), intrinsicContentHeight)); |
| 629 } | 629 } |
| 630 | 630 |
| 631 return logicalHeight; | 631 return logicalHeight; |
| 632 } | 632 } |
| 633 | 633 |
| 634 void LayoutBox::setLocationAndUpdateOverflowControlsIfNeeded(const LayoutPoint&
location) | 634 void LayoutBox::setLocationAndUpdateOverflowControlsIfNeeded(const LayoutPoint&
location) |
| 635 { | 635 { |
| (...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1138 } | 1138 } |
| 1139 | 1139 |
| 1140 void LayoutBox::clearExtraInlineAndBlockOffests() | 1140 void LayoutBox::clearExtraInlineAndBlockOffests() |
| 1141 { | 1141 { |
| 1142 if (gExtraInlineOffsetMap) | 1142 if (gExtraInlineOffsetMap) |
| 1143 gExtraInlineOffsetMap->remove(this); | 1143 gExtraInlineOffsetMap->remove(this); |
| 1144 if (gExtraBlockOffsetMap) | 1144 if (gExtraBlockOffsetMap) |
| 1145 gExtraBlockOffsetMap->remove(this); | 1145 gExtraBlockOffsetMap->remove(this); |
| 1146 } | 1146 } |
| 1147 | 1147 |
| 1148 LayoutUnit LayoutBox::adjustBorderBoxLogicalWidthForBoxSizing(LayoutUnit width)
const | 1148 LayoutUnit LayoutBox::adjustBorderBoxLogicalWidthForBoxSizing(float width) const |
| 1149 { | 1149 { |
| 1150 LayoutUnit bordersPlusPadding = borderAndPaddingLogicalWidth(); | 1150 LayoutUnit bordersPlusPadding = borderAndPaddingLogicalWidth(); |
| 1151 LayoutUnit result(width); |
| 1151 if (style()->boxSizing() == CONTENT_BOX) | 1152 if (style()->boxSizing() == CONTENT_BOX) |
| 1152 return width + bordersPlusPadding; | 1153 return result + bordersPlusPadding; |
| 1153 return std::max(width, bordersPlusPadding); | 1154 return std::max(result, bordersPlusPadding); |
| 1154 } | 1155 } |
| 1155 | 1156 |
| 1156 LayoutUnit LayoutBox::adjustBorderBoxLogicalHeightForBoxSizing(LayoutUnit height
) const | 1157 LayoutUnit LayoutBox::adjustBorderBoxLogicalHeightForBoxSizing(float height) con
st |
| 1157 { | 1158 { |
| 1158 LayoutUnit bordersPlusPadding = borderAndPaddingLogicalHeight(); | 1159 LayoutUnit bordersPlusPadding = borderAndPaddingLogicalHeight(); |
| 1160 LayoutUnit result(height); |
| 1159 if (style()->boxSizing() == CONTENT_BOX) | 1161 if (style()->boxSizing() == CONTENT_BOX) |
| 1160 return height + bordersPlusPadding; | 1162 return result + bordersPlusPadding; |
| 1161 return std::max(height, bordersPlusPadding); | 1163 return std::max(result, bordersPlusPadding); |
| 1162 } | 1164 } |
| 1163 | 1165 |
| 1164 LayoutUnit LayoutBox::adjustContentBoxLogicalWidthForBoxSizing(LayoutUnit width)
const | 1166 LayoutUnit LayoutBox::adjustContentBoxLogicalWidthForBoxSizing(float width) cons
t |
| 1165 { | 1167 { |
| 1168 LayoutUnit result(width); |
| 1166 if (style()->boxSizing() == BORDER_BOX) | 1169 if (style()->boxSizing() == BORDER_BOX) |
| 1167 width -= borderAndPaddingLogicalWidth(); | 1170 result -= borderAndPaddingLogicalWidth(); |
| 1168 return std::max(LayoutUnit(), width); | 1171 return std::max(LayoutUnit(), result); |
| 1169 } | 1172 } |
| 1170 | 1173 |
| 1171 LayoutUnit LayoutBox::adjustContentBoxLogicalHeightForBoxSizing(LayoutUnit heigh
t) const | 1174 LayoutUnit LayoutBox::adjustContentBoxLogicalHeightForBoxSizing(float height) co
nst |
| 1172 { | 1175 { |
| 1176 LayoutUnit result(height); |
| 1173 if (style()->boxSizing() == BORDER_BOX) | 1177 if (style()->boxSizing() == BORDER_BOX) |
| 1174 height -= borderAndPaddingLogicalHeight(); | 1178 result -= borderAndPaddingLogicalHeight(); |
| 1175 return std::max(LayoutUnit(), height); | 1179 return std::max(LayoutUnit(), result); |
| 1176 } | 1180 } |
| 1177 | 1181 |
| 1178 // Hit Testing | 1182 // Hit Testing |
| 1179 bool LayoutBox::nodeAtPoint(HitTestResult& result, const HitTestLocation& locati
onInContainer, const LayoutPoint& accumulatedOffset, HitTestAction action) | 1183 bool LayoutBox::nodeAtPoint(HitTestResult& result, const HitTestLocation& locati
onInContainer, const LayoutPoint& accumulatedOffset, HitTestAction action) |
| 1180 { | 1184 { |
| 1181 LayoutPoint adjustedLocation = accumulatedOffset + location(); | 1185 LayoutPoint adjustedLocation = accumulatedOffset + location(); |
| 1182 | 1186 |
| 1183 // Exit early if no children can be hit. | 1187 // Exit early if no children can be hit. |
| 1184 LayoutRect overflowRect = visualOverflowRect(); | 1188 LayoutRect overflowRect = visualOverflowRect(); |
| 1185 overflowRect.moveBy(adjustedLocation); | 1189 overflowRect.moveBy(adjustedLocation); |
| (...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1643 LayoutUnit fillFallbackExtent = LayoutUnit(containingBlockStyle.isHorizo
ntalWritingMode() | 1647 LayoutUnit fillFallbackExtent = LayoutUnit(containingBlockStyle.isHorizo
ntalWritingMode() |
| 1644 ? view()->frameView()->visibleContentSize().height() | 1648 ? view()->frameView()->visibleContentSize().height() |
| 1645 : view()->frameView()->visibleContentSize().width()); | 1649 : view()->frameView()->visibleContentSize().width()); |
| 1646 LayoutUnit fillAvailableExtent = containingBlock()->availableLogicalHeig
ht(ExcludeMarginBorderPadding); | 1650 LayoutUnit fillAvailableExtent = containingBlock()->availableLogicalHeig
ht(ExcludeMarginBorderPadding); |
| 1647 if (fillAvailableExtent == -1) | 1651 if (fillAvailableExtent == -1) |
| 1648 return fillFallbackExtent; | 1652 return fillFallbackExtent; |
| 1649 return std::min(fillAvailableExtent, fillFallbackExtent); | 1653 return std::min(fillAvailableExtent, fillFallbackExtent); |
| 1650 } | 1654 } |
| 1651 | 1655 |
| 1652 // Use the content box logical height as specified by the style. | 1656 // Use the content box logical height as specified by the style. |
| 1653 return cb->adjustContentBoxLogicalHeightForBoxSizing(logicalHeightLength.val
ue()); | 1657 return cb->adjustContentBoxLogicalHeightForBoxSizing(LayoutUnit(logicalHeigh
tLength.value())); |
| 1654 } | 1658 } |
| 1655 | 1659 |
| 1656 void LayoutBox::mapLocalToAncestor(const LayoutBoxModelObject* ancestor, Transfo
rmState& transformState, MapCoordinatesFlags mode, bool* wasFixed, const PaintIn
validationState* paintInvalidationState) const | 1660 void LayoutBox::mapLocalToAncestor(const LayoutBoxModelObject* ancestor, Transfo
rmState& transformState, MapCoordinatesFlags mode, bool* wasFixed, const PaintIn
validationState* paintInvalidationState) const |
| 1657 { | 1661 { |
| 1658 if (ancestor == this) | 1662 if (ancestor == this) |
| 1659 return; | 1663 return; |
| 1660 | 1664 |
| 1661 if (paintInvalidationState && paintInvalidationState->canMapToContainer(ance
stor)) { | 1665 if (paintInvalidationState && paintInvalidationState->canMapToContainer(ance
stor)) { |
| 1662 LayoutSize offset = paintInvalidationState->paintOffset() + locationOffs
et(); | 1666 LayoutSize offset = paintInvalidationState->paintOffset() + locationOffs
et(); |
| 1663 if (style()->hasInFlowPosition() && layer()) | 1667 if (style()->hasInFlowPosition() && layer()) |
| (...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2080 | 2084 |
| 2081 LayoutBlock* cb = containingBlock(); | 2085 LayoutBlock* cb = containingBlock(); |
| 2082 LayoutUnit containerLogicalWidth = std::max(LayoutUnit(), containingBlockLog
icalWidthForContent()); | 2086 LayoutUnit containerLogicalWidth = std::max(LayoutUnit(), containingBlockLog
icalWidthForContent()); |
| 2083 bool hasPerpendicularContainingBlock = cb->isHorizontalWritingMode() != isHo
rizontalWritingMode(); | 2087 bool hasPerpendicularContainingBlock = cb->isHorizontalWritingMode() != isHo
rizontalWritingMode(); |
| 2084 | 2088 |
| 2085 if (isInline() && !isInlineBlockOrInlineTable()) { | 2089 if (isInline() && !isInlineBlockOrInlineTable()) { |
| 2086 // just calculate margins | 2090 // just calculate margins |
| 2087 computedValues.m_margins.m_start = minimumValueForLength(styleToUse.marg
inStart(), containerLogicalWidth); | 2091 computedValues.m_margins.m_start = minimumValueForLength(styleToUse.marg
inStart(), containerLogicalWidth); |
| 2088 computedValues.m_margins.m_end = minimumValueForLength(styleToUse.margin
End(), containerLogicalWidth); | 2092 computedValues.m_margins.m_end = minimumValueForLength(styleToUse.margin
End(), containerLogicalWidth); |
| 2089 if (treatAsReplaced) | 2093 if (treatAsReplaced) |
| 2090 computedValues.m_extent = std::max<LayoutUnit>(floatValueForLength(l
ogicalWidthLength, 0) + borderAndPaddingLogicalWidth(), minPreferredLogicalWidth
()); | 2094 computedValues.m_extent = std::max(LayoutUnit(floatValueForLength(lo
gicalWidthLength, 0)) + borderAndPaddingLogicalWidth(), minPreferredLogicalWidth
()); |
| 2091 return; | 2095 return; |
| 2092 } | 2096 } |
| 2093 | 2097 |
| 2094 // Width calculations | 2098 // Width calculations |
| 2095 if (treatAsReplaced) { | 2099 if (treatAsReplaced) { |
| 2096 computedValues.m_extent = logicalWidthLength.value() + borderAndPaddingL
ogicalWidth(); | 2100 computedValues.m_extent = LayoutUnit(logicalWidthLength.value()) + borde
rAndPaddingLogicalWidth(); |
| 2097 } else if (parent()->isLayoutGrid() && style()->logicalWidth().isAuto() && s
tyle()->logicalMinWidth().isAuto() && style()->overflowX() == OVISIBLE && contai
nerLogicalWidth < minPreferredLogicalWidth()) { | 2101 } else if (parent()->isLayoutGrid() && style()->logicalWidth().isAuto() && s
tyle()->logicalMinWidth().isAuto() && style()->overflowX() == OVISIBLE && contai
nerLogicalWidth < minPreferredLogicalWidth()) { |
| 2098 // TODO (lajava) Move this logic to the LayoutGrid class. | 2102 // TODO (lajava) Move this logic to the LayoutGrid class. |
| 2099 // Implied minimum size of Grid items. | 2103 // Implied minimum size of Grid items. |
| 2100 computedValues.m_extent = constrainLogicalWidthByMinMax(minPreferredLogi
calWidth(), containerLogicalWidth, cb); | 2104 computedValues.m_extent = constrainLogicalWidthByMinMax(minPreferredLogi
calWidth(), containerLogicalWidth, cb); |
| 2101 } else { | 2105 } else { |
| 2102 LayoutUnit containerWidthInInlineDirection = containerLogicalWidth; | 2106 LayoutUnit containerWidthInInlineDirection = containerLogicalWidth; |
| 2103 if (hasPerpendicularContainingBlock) | 2107 if (hasPerpendicularContainingBlock) |
| 2104 containerWidthInInlineDirection = perpendicularContainingBlockLogica
lHeight(); | 2108 containerWidthInInlineDirection = perpendicularContainingBlockLogica
lHeight(); |
| 2105 LayoutUnit preferredWidth = computeLogicalWidthUsing(MainOrPreferredSize
, styleToUse.logicalWidth(), containerWidthInInlineDirection, cb); | 2109 LayoutUnit preferredWidth = computeLogicalWidthUsing(MainOrPreferredSize
, styleToUse.logicalWidth(), containerWidthInInlineDirection, cb); |
| 2106 computedValues.m_extent = constrainLogicalWidthByMinMax(preferredWidth,
containerWidthInInlineDirection, cb); | 2110 computedValues.m_extent = constrainLogicalWidthByMinMax(preferredWidth,
containerWidthInInlineDirection, cb); |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2173 } | 2177 } |
| 2174 | 2178 |
| 2175 ASSERT_NOT_REACHED(); | 2179 ASSERT_NOT_REACHED(); |
| 2176 return LayoutUnit(); | 2180 return LayoutUnit(); |
| 2177 } | 2181 } |
| 2178 | 2182 |
| 2179 LayoutUnit LayoutBox::computeLogicalWidthUsing(SizeType widthType, const Length&
logicalWidth, LayoutUnit availableLogicalWidth, const LayoutBlock* cb) const | 2183 LayoutUnit LayoutBox::computeLogicalWidthUsing(SizeType widthType, const Length&
logicalWidth, LayoutUnit availableLogicalWidth, const LayoutBlock* cb) const |
| 2180 { | 2184 { |
| 2181 ASSERT(widthType == MinSize || widthType == MainOrPreferredSize || !logicalW
idth.isAuto()); | 2185 ASSERT(widthType == MinSize || widthType == MainOrPreferredSize || !logicalW
idth.isAuto()); |
| 2182 if (widthType == MinSize && logicalWidth.isAuto()) | 2186 if (widthType == MinSize && logicalWidth.isAuto()) |
| 2183 return adjustBorderBoxLogicalWidthForBoxSizing(LayoutUnit()); | 2187 return adjustBorderBoxLogicalWidthForBoxSizing(0); |
| 2184 | 2188 |
| 2185 if (!logicalWidth.isIntrinsicOrAuto()) { | 2189 if (!logicalWidth.isIntrinsicOrAuto()) { |
| 2186 // FIXME: If the containing block flow is perpendicular to our direction
we need to use the available logical height instead. | 2190 // FIXME: If the containing block flow is perpendicular to our direction
we need to use the available logical height instead. |
| 2187 return adjustBorderBoxLogicalWidthForBoxSizing(valueForLength(logicalWid
th, availableLogicalWidth)); | 2191 return adjustBorderBoxLogicalWidthForBoxSizing(valueForLength(logicalWid
th, availableLogicalWidth)); |
| 2188 } | 2192 } |
| 2189 | 2193 |
| 2190 if (logicalWidth.isIntrinsic()) | 2194 if (logicalWidth.isIntrinsic()) |
| 2191 return computeIntrinsicLogicalWidthUsing(logicalWidth, availableLogicalW
idth, borderAndPaddingLogicalWidth()); | 2195 return computeIntrinsicLogicalWidthUsing(logicalWidth, availableLogicalW
idth, borderAndPaddingLogicalWidth()); |
| 2192 | 2196 |
| 2193 LayoutUnit marginStart; | 2197 LayoutUnit marginStart; |
| (...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2454 if (checkMinMaxHeight) { | 2458 if (checkMinMaxHeight) { |
| 2455 heightResult = computeLogicalHeightUsing(MainOrPreferredSize, style(
)->logicalHeight(), computedValues.m_extent - borderAndPaddingLogicalHeight()); | 2459 heightResult = computeLogicalHeightUsing(MainOrPreferredSize, style(
)->logicalHeight(), computedValues.m_extent - borderAndPaddingLogicalHeight()); |
| 2456 if (heightResult == -1) | 2460 if (heightResult == -1) |
| 2457 heightResult = computedValues.m_extent; | 2461 heightResult = computedValues.m_extent; |
| 2458 heightResult = constrainLogicalHeightByMinMax(heightResult, computed
Values.m_extent - borderAndPaddingLogicalHeight()); | 2462 heightResult = constrainLogicalHeightByMinMax(heightResult, computed
Values.m_extent - borderAndPaddingLogicalHeight()); |
| 2459 } else { | 2463 } else { |
| 2460 // The only times we don't check min/max height are when a fixed len
gth has | 2464 // The only times we don't check min/max height are when a fixed len
gth has |
| 2461 // been given as an override. Just use that. The value has already
been adjusted | 2465 // been given as an override. Just use that. The value has already
been adjusted |
| 2462 // for box-sizing. | 2466 // for box-sizing. |
| 2463 ASSERT(h.isFixed()); | 2467 ASSERT(h.isFixed()); |
| 2464 heightResult = h.value() + borderAndPaddingLogicalHeight(); | 2468 heightResult = LayoutUnit(h.value()) + borderAndPaddingLogicalHeight
(); |
| 2465 } | 2469 } |
| 2466 | 2470 |
| 2467 computedValues.m_extent = heightResult; | 2471 computedValues.m_extent = heightResult; |
| 2468 computeMarginsForDirection(flowDirection, cb, containingBlockLogicalWidt
hForContent(), computedValues.m_extent, computedValues.m_margins.m_before, | 2472 computeMarginsForDirection(flowDirection, cb, containingBlockLogicalWidt
hForContent(), computedValues.m_extent, computedValues.m_margins.m_before, |
| 2469 computedValues.m_margins.m_after, style()->marginBefore(), style()->
marginAfter()); | 2473 computedValues.m_margins.m_after, style()->marginBefore(), style()->
marginAfter()); |
| 2470 } | 2474 } |
| 2471 | 2475 |
| 2472 // WinIE quirk: The <html> block always fills the entire canvas in quirks mo
de. The <body> always fills the | 2476 // WinIE quirk: The <html> block always fills the entire canvas in quirks mo
de. The <body> always fills the |
| 2473 // <html> block in quirks mode. Only apply this quirk if the block is norma
l flow and no height | 2477 // <html> block in quirks mode. Only apply this quirk if the block is norma
l flow and no height |
| 2474 // is specified. When we're printing, we also need this quirk if the body or
root has a percentage | 2478 // is specified. When we're printing, we also need this quirk if the body or
root has a percentage |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2535 if (height.isAuto()) | 2539 if (height.isAuto()) |
| 2536 return heightType == MinSize ? LayoutUnit() : LayoutUnit(-1); | 2540 return heightType == MinSize ? LayoutUnit() : LayoutUnit(-1); |
| 2537 // FIXME(cbiesinger): The css-sizing spec is considering changing what min-c
ontent/max-content should resolve to. | 2541 // FIXME(cbiesinger): The css-sizing spec is considering changing what min-c
ontent/max-content should resolve to. |
| 2538 // If that happens, this code will have to change. | 2542 // If that happens, this code will have to change. |
| 2539 if (height.isIntrinsic()) { | 2543 if (height.isIntrinsic()) { |
| 2540 if (intrinsicContentHeight == -1) | 2544 if (intrinsicContentHeight == -1) |
| 2541 return LayoutUnit(-1); // Intrinsic height isn't available. | 2545 return LayoutUnit(-1); // Intrinsic height isn't available. |
| 2542 return computeIntrinsicLogicalContentHeightUsing(height, intrinsicConten
tHeight, borderAndPaddingLogicalHeight()) + scrollbarLogicalHeight(); | 2546 return computeIntrinsicLogicalContentHeightUsing(height, intrinsicConten
tHeight, borderAndPaddingLogicalHeight()) + scrollbarLogicalHeight(); |
| 2543 } | 2547 } |
| 2544 if (height.isFixed()) | 2548 if (height.isFixed()) |
| 2545 return height.value(); | 2549 return LayoutUnit(height.value()); |
| 2546 if (height.hasPercent()) | 2550 if (height.hasPercent()) |
| 2547 return computePercentageLogicalHeight(height); | 2551 return computePercentageLogicalHeight(height); |
| 2548 return LayoutUnit(-1); | 2552 return LayoutUnit(-1); |
| 2549 } | 2553 } |
| 2550 | 2554 |
| 2551 bool LayoutBox::stretchesToViewportInQuirksMode() const | 2555 bool LayoutBox::stretchesToViewportInQuirksMode() const |
| 2552 { | 2556 { |
| 2553 if (!isDocumentElement() && !isBody()) | 2557 if (!isDocumentElement() && !isBody()) |
| 2554 return false; | 2558 return false; |
| 2555 return style()->logicalHeight().isAuto() && !isFloatingOrOutOfFlowPositioned
() && !isInline() && !flowThreadContainingBlock(); | 2559 return style()->logicalHeight().isAuto() && !isFloatingOrOutOfFlowPositioned
() && !isInline() && !flowThreadContainingBlock(); |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2624 // preferable to the alternative (sizing intrinsically and makin
g the row end up too big). | 2628 // preferable to the alternative (sizing intrinsically and makin
g the row end up too big). |
| 2625 LayoutTableCell* cell = toLayoutTableCell(cb); | 2629 LayoutTableCell* cell = toLayoutTableCell(cb); |
| 2626 if (scrollsOverflowY() && (!cell->style()->logicalHeight().isAut
o() || !cell->table()->style()->logicalHeight().isAuto())) | 2630 if (scrollsOverflowY() && (!cell->style()->logicalHeight().isAut
o() || !cell->table()->style()->logicalHeight().isAuto())) |
| 2627 return LayoutUnit(); | 2631 return LayoutUnit(); |
| 2628 return LayoutUnit(-1); | 2632 return LayoutUnit(-1); |
| 2629 } | 2633 } |
| 2630 availableHeight = cb->overrideLogicalContentHeight(); | 2634 availableHeight = cb->overrideLogicalContentHeight(); |
| 2631 includeBorderPadding = true; | 2635 includeBorderPadding = true; |
| 2632 } | 2636 } |
| 2633 } else if (cbstyle.logicalHeight().isFixed()) { | 2637 } else if (cbstyle.logicalHeight().isFixed()) { |
| 2634 LayoutUnit contentBoxHeight = cb->adjustContentBoxLogicalHeightForBoxSiz
ing(cbstyle.logicalHeight().value()); | 2638 LayoutUnit contentBoxHeight = cb->adjustContentBoxLogicalHeightForBoxSiz
ing(LayoutUnit(cbstyle.logicalHeight().value())); |
| 2635 availableHeight = std::max(LayoutUnit(), cb->constrainContentBoxLogicalH
eightByMinMax(contentBoxHeight - cb->scrollbarLogicalHeight(), LayoutUnit(-1))); | 2639 availableHeight = std::max(LayoutUnit(), cb->constrainContentBoxLogicalH
eightByMinMax(contentBoxHeight - cb->scrollbarLogicalHeight(), LayoutUnit(-1))); |
| 2636 } else if (cbstyle.logicalHeight().hasPercent() && !isOutOfFlowPositionedWit
hSpecifiedHeight) { | 2640 } else if (cbstyle.logicalHeight().hasPercent() && !isOutOfFlowPositionedWit
hSpecifiedHeight) { |
| 2637 // We need to recur and compute the percentage height for our containing
block. | 2641 // We need to recur and compute the percentage height for our containing
block. |
| 2638 LayoutUnit heightWithScrollbar = cb->computePercentageLogicalHeight(cbst
yle.logicalHeight()); | 2642 LayoutUnit heightWithScrollbar = cb->computePercentageLogicalHeight(cbst
yle.logicalHeight()); |
| 2639 if (heightWithScrollbar != -1) { | 2643 if (heightWithScrollbar != -1) { |
| 2640 LayoutUnit contentBoxHeightWithScrollbar = cb->adjustContentBoxLogic
alHeightForBoxSizing(heightWithScrollbar); | 2644 LayoutUnit contentBoxHeightWithScrollbar = cb->adjustContentBoxLogic
alHeightForBoxSizing(heightWithScrollbar); |
| 2641 // We need to adjust for min/max height because this method does not | 2645 // We need to adjust for min/max height because this method does not |
| 2642 // handle the min/max of the current block, its caller does. So the | 2646 // handle the min/max of the current block, its caller does. So the |
| 2643 // return value from the recursive call will not have been adjusted | 2647 // return value from the recursive call will not have been adjusted |
| 2644 // yet. | 2648 // yet. |
| (...skipping 1235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3880 && oldBorderBoxSize == oldBounds.size() | 3884 && oldBorderBoxSize == oldBounds.size() |
| 3881 && newBorderBoxSize == newBounds.size()) | 3885 && newBorderBoxSize == newBounds.size()) |
| 3882 return; | 3886 return; |
| 3883 | 3887 |
| 3884 // Invalidate the right delta part and the right border of the old or new bo
x which has smaller width. | 3888 // Invalidate the right delta part and the right border of the old or new bo
x which has smaller width. |
| 3885 LayoutUnit deltaWidth = absoluteValue(oldBorderBoxSize.width() - newBorderBo
xSize.width()); | 3889 LayoutUnit deltaWidth = absoluteValue(oldBorderBoxSize.width() - newBorderBo
xSize.width()); |
| 3886 if (deltaWidth) { | 3890 if (deltaWidth) { |
| 3887 LayoutUnit smallerWidth = std::min(oldBorderBoxSize.width(), newBorderBo
xSize.width()); | 3891 LayoutUnit smallerWidth = std::min(oldBorderBoxSize.width(), newBorderBo
xSize.width()); |
| 3888 LayoutUnit borderTopRightRadiusWidth = valueForLength(style()->borderTop
RightRadius().width(), smallerWidth); | 3892 LayoutUnit borderTopRightRadiusWidth = valueForLength(style()->borderTop
RightRadius().width(), smallerWidth); |
| 3889 LayoutUnit borderBottomRightRadiusWidth = valueForLength(style()->border
BottomRightRadius().width(), smallerWidth); | 3893 LayoutUnit borderBottomRightRadiusWidth = valueForLength(style()->border
BottomRightRadius().width(), smallerWidth); |
| 3890 LayoutUnit borderWidth = std::max<LayoutUnit>(borderRight(), std::max(bo
rderTopRightRadiusWidth, borderBottomRightRadiusWidth)); | 3894 LayoutUnit borderWidth = std::max(LayoutUnit(borderRight()), std::max(bo
rderTopRightRadiusWidth, borderBottomRightRadiusWidth)); |
| 3891 LayoutRect rightDeltaRect(positionFromPaintInvalidationBacking.x() + sma
llerWidth - borderWidth, | 3895 LayoutRect rightDeltaRect(positionFromPaintInvalidationBacking.x() + sma
llerWidth - borderWidth, |
| 3892 positionFromPaintInvalidationBacking.y(), | 3896 positionFromPaintInvalidationBacking.y(), |
| 3893 deltaWidth + borderWidth, | 3897 deltaWidth + borderWidth, |
| 3894 std::max(oldBorderBoxSize.height(), newBorderBoxSize.height())); | 3898 std::max(oldBorderBoxSize.height(), newBorderBoxSize.height())); |
| 3895 invalidatePaintRectClippedByOldAndNewBounds(paintInvalidationContainer,
rightDeltaRect, oldBounds, newBounds); | 3899 invalidatePaintRectClippedByOldAndNewBounds(paintInvalidationContainer,
rightDeltaRect, oldBounds, newBounds); |
| 3896 } | 3900 } |
| 3897 | 3901 |
| 3898 // Invalidate the bottom delta part and the bottom border of the old or new
box which has smaller height. | 3902 // Invalidate the bottom delta part and the bottom border of the old or new
box which has smaller height. |
| 3899 LayoutUnit deltaHeight = absoluteValue(oldBorderBoxSize.height() - newBorder
BoxSize.height()); | 3903 LayoutUnit deltaHeight = absoluteValue(oldBorderBoxSize.height() - newBorder
BoxSize.height()); |
| 3900 if (deltaHeight) { | 3904 if (deltaHeight) { |
| 3901 LayoutUnit smallerHeight = std::min(oldBorderBoxSize.height(), newBorder
BoxSize.height()); | 3905 LayoutUnit smallerHeight = std::min(oldBorderBoxSize.height(), newBorder
BoxSize.height()); |
| 3902 LayoutUnit borderBottomLeftRadiusHeight = valueForLength(style()->border
BottomLeftRadius().height(), smallerHeight); | 3906 LayoutUnit borderBottomLeftRadiusHeight = valueForLength(style()->border
BottomLeftRadius().height(), smallerHeight); |
| 3903 LayoutUnit borderBottomRightRadiusHeight = valueForLength(style()->borde
rBottomRightRadius().height(), smallerHeight); | 3907 LayoutUnit borderBottomRightRadiusHeight = valueForLength(style()->borde
rBottomRightRadius().height(), smallerHeight); |
| 3904 LayoutUnit borderHeight = std::max<LayoutUnit>(borderBottom(), std::max(
borderBottomLeftRadiusHeight, borderBottomRightRadiusHeight)); | 3908 LayoutUnit borderHeight = std::max(LayoutUnit(borderBottom()), std::max(
borderBottomLeftRadiusHeight, borderBottomRightRadiusHeight)); |
| 3905 LayoutRect bottomDeltaRect(positionFromPaintInvalidationBacking.x(), | 3909 LayoutRect bottomDeltaRect(positionFromPaintInvalidationBacking.x(), |
| 3906 positionFromPaintInvalidationBacking.y() + smallerHeight - borderHei
ght, | 3910 positionFromPaintInvalidationBacking.y() + smallerHeight - borderHei
ght, |
| 3907 std::max(oldBorderBoxSize.width(), newBorderBoxSize.width()), | 3911 std::max(oldBorderBoxSize.width(), newBorderBoxSize.width()), |
| 3908 deltaHeight + borderHeight); | 3912 deltaHeight + borderHeight); |
| 3909 invalidatePaintRectClippedByOldAndNewBounds(paintInvalidationContainer,
bottomDeltaRect, oldBounds, newBounds); | 3913 invalidatePaintRectClippedByOldAndNewBounds(paintInvalidationContainer,
bottomDeltaRect, oldBounds, newBounds); |
| 3910 } | 3914 } |
| 3911 } | 3915 } |
| 3912 | 3916 |
| 3913 void LayoutBox::invalidatePaintRectClippedByOldAndNewBounds(const LayoutBoxModel
Object& paintInvalidationContainer, const LayoutRect& rect, const LayoutRect& ol
dBounds, const LayoutRect& newBounds) | 3917 void LayoutBox::invalidatePaintRectClippedByOldAndNewBounds(const LayoutBoxModel
Object& paintInvalidationContainer, const LayoutRect& rect, const LayoutRect& ol
dBounds, const LayoutRect& newBounds) |
| 3914 { | 3918 { |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3953 ASSERT(style()->hasVisualOverflowingEffect()); | 3957 ASSERT(style()->hasVisualOverflowingEffect()); |
| 3954 | 3958 |
| 3955 LayoutUnit top; | 3959 LayoutUnit top; |
| 3956 LayoutUnit right; | 3960 LayoutUnit right; |
| 3957 LayoutUnit bottom; | 3961 LayoutUnit bottom; |
| 3958 LayoutUnit left; | 3962 LayoutUnit left; |
| 3959 | 3963 |
| 3960 if (const ShadowList* boxShadow = style()->boxShadow()) { | 3964 if (const ShadowList* boxShadow = style()->boxShadow()) { |
| 3961 // FIXME: Use LayoutUnit edge outsets, and then simplify this. | 3965 // FIXME: Use LayoutUnit edge outsets, and then simplify this. |
| 3962 FloatRectOutsets outsets = boxShadow->rectOutsetsIncludingOriginal(); | 3966 FloatRectOutsets outsets = boxShadow->rectOutsetsIncludingOriginal(); |
| 3963 top = outsets.top(); | 3967 top = LayoutUnit(outsets.top()); |
| 3964 right = outsets.right(); | 3968 right = LayoutUnit(outsets.right()); |
| 3965 bottom = outsets.bottom(); | 3969 bottom = LayoutUnit(outsets.bottom()); |
| 3966 left = outsets.left(); | 3970 left = LayoutUnit(outsets.left()); |
| 3967 } | 3971 } |
| 3968 | 3972 |
| 3969 if (style()->hasBorderImageOutsets()) { | 3973 if (style()->hasBorderImageOutsets()) { |
| 3970 LayoutRectOutsets borderOutsets = style()->borderImageOutsets(); | 3974 LayoutRectOutsets borderOutsets = style()->borderImageOutsets(); |
| 3971 top = std::max(top, borderOutsets.top()); | 3975 top = std::max(top, borderOutsets.top()); |
| 3972 right = std::max(right, borderOutsets.right()); | 3976 right = std::max(right, borderOutsets.right()); |
| 3973 bottom = std::max(bottom, borderOutsets.bottom()); | 3977 bottom = std::max(bottom, borderOutsets.bottom()); |
| 3974 left = std::max(left, borderOutsets.left()); | 3978 left = std::max(left, borderOutsets.left()); |
| 3975 } | 3979 } |
| 3976 | 3980 |
| (...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4290 { | 4294 { |
| 4291 // Because of the special coordinate system used for overflow rectangles and
many other | 4295 // Because of the special coordinate system used for overflow rectangles and
many other |
| 4292 // rectangles (not quite logical, not quite physical), we need to flip the b
lock progression | 4296 // rectangles (not quite logical, not quite physical), we need to flip the b
lock progression |
| 4293 // coordinate in vertical-rl and horizontal-bt writing modes. In other words
, the rectangle | 4297 // coordinate in vertical-rl and horizontal-bt writing modes. In other words
, the rectangle |
| 4294 // returned is physical, except for the block direction progression coordina
te (y in horizontal | 4298 // returned is physical, except for the block direction progression coordina
te (y in horizontal |
| 4295 // writing modes, x in vertical writing modes), which is always "logical top
". Apart from the | 4299 // writing modes, x in vertical writing modes), which is always "logical top
". Apart from the |
| 4296 // flipping, this method does the same as clientBoxRect(). | 4300 // flipping, this method does the same as clientBoxRect(). |
| 4297 | 4301 |
| 4298 const int scrollBarWidth = verticalScrollbarWidth(); | 4302 const int scrollBarWidth = verticalScrollbarWidth(); |
| 4299 const int scrollBarHeight = horizontalScrollbarHeight(); | 4303 const int scrollBarHeight = horizontalScrollbarHeight(); |
| 4300 LayoutUnit left = borderLeft() + (shouldPlaceBlockDirectionScrollbarOnLogica
lLeft() ? scrollBarWidth : 0); | 4304 LayoutUnit left(borderLeft() + (shouldPlaceBlockDirectionScrollbarOnLogicalL
eft() ? scrollBarWidth : 0)); |
| 4301 LayoutUnit top = borderTop(); | 4305 LayoutUnit top(borderTop()); |
| 4302 LayoutUnit right = borderRight(); | 4306 LayoutUnit right(borderRight()); |
| 4303 LayoutUnit bottom = borderBottom(); | 4307 LayoutUnit bottom(borderBottom()); |
| 4304 LayoutRect rect(left, top, size().width() - left - right, size().height() -
top - bottom); | 4308 LayoutRect rect(left, top, size().width() - left - right, size().height() -
top - bottom); |
| 4305 flipForWritingMode(rect); | 4309 flipForWritingMode(rect); |
| 4306 // Subtract space occupied by scrollbars. Order is important here: first fli
p, then subtract | 4310 // Subtract space occupied by scrollbars. Order is important here: first fli
p, then subtract |
| 4307 // scrollbars. This may seem backwards and weird, since one would think that
a horizontal | 4311 // scrollbars. This may seem backwards and weird, since one would think that
a horizontal |
| 4308 // scrollbar at the physical bottom in horizontal-bt ought to be at the logi
cal top (physical | 4312 // scrollbar at the physical bottom in horizontal-bt ought to be at the logi
cal top (physical |
| 4309 // bottom), between the logical top (physical bottom) border and the logical
top (physical | 4313 // bottom), between the logical top (physical bottom) border and the logical
top (physical |
| 4310 // bottom) padding. But this is how the rest of the code expects us to behav
e. This is highly | 4314 // bottom) padding. But this is how the rest of the code expects us to behav
e. This is highly |
| 4311 // related to https://bugs.webkit.org/show_bug.cgi?id=76129 | 4315 // related to https://bugs.webkit.org/show_bug.cgi?id=76129 |
| 4312 // FIXME: when the above mentioned bug is fixed, it should hopefully be poss
ible to call | 4316 // FIXME: when the above mentioned bug is fixed, it should hopefully be poss
ible to call |
| 4313 // clientBoxRect() or paddingBoxRect() in this method, rather than fiddling
with the edges on | 4317 // clientBoxRect() or paddingBoxRect() in this method, rather than fiddling
with the edges on |
| (...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4643 | 4647 |
| 4644 void LayoutBox::clearPercentHeightDescendants() | 4648 void LayoutBox::clearPercentHeightDescendants() |
| 4645 { | 4649 { |
| 4646 for (LayoutObject* curr = slowFirstChild(); curr; curr = curr->nextInPreOrde
r(this)) { | 4650 for (LayoutObject* curr = slowFirstChild(); curr; curr = curr->nextInPreOrde
r(this)) { |
| 4647 if (curr->isBox()) | 4651 if (curr->isBox()) |
| 4648 toLayoutBox(curr)->removeFromPercentHeightContainer(); | 4652 toLayoutBox(curr)->removeFromPercentHeightContainer(); |
| 4649 } | 4653 } |
| 4650 } | 4654 } |
| 4651 | 4655 |
| 4652 } // namespace blink | 4656 } // namespace blink |
| OLD | NEW |