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 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1526 rect.contract(layer()->scrollableArea()->verticalScrollbarWidth(relevancy),
layer()->scrollableArea()->horizontalScrollbarHeight(relevancy)); | 1530 rect.contract(layer()->scrollableArea()->verticalScrollbarWidth(relevancy),
layer()->scrollableArea()->horizontalScrollbarHeight(relevancy)); |
1527 } | 1531 } |
1528 | 1532 |
1529 LayoutRect LayoutBox::clipRect(const LayoutPoint& location) const | 1533 LayoutRect LayoutBox::clipRect(const LayoutPoint& location) const |
1530 { | 1534 { |
1531 LayoutRect borderBoxRect = this->borderBoxRect(); | 1535 LayoutRect borderBoxRect = this->borderBoxRect(); |
1532 LayoutRect clipRect = LayoutRect(borderBoxRect.location() + location, border
BoxRect.size()); | 1536 LayoutRect clipRect = LayoutRect(borderBoxRect.location() + location, border
BoxRect.size()); |
1533 | 1537 |
1534 if (!style()->clipLeft().isAuto()) { | 1538 if (!style()->clipLeft().isAuto()) { |
1535 LayoutUnit c = valueForLength(style()->clipLeft(), borderBoxRect.width()
); | 1539 LayoutUnit c = valueForLength(style()->clipLeft(), borderBoxRect.width()
); |
1536 clipRect.move(c, 0); | 1540 clipRect.move(c, LayoutUnit()); |
1537 clipRect.contract(c, 0); | 1541 clipRect.contract(c, LayoutUnit()); |
1538 } | 1542 } |
1539 | 1543 |
1540 if (!style()->clipRight().isAuto()) | 1544 if (!style()->clipRight().isAuto()) |
1541 clipRect.contract(size().width() - valueForLength(style()->clipRight(),
size().width()), 0); | 1545 clipRect.contract(size().width() - valueForLength(style()->clipRight(),
size().width()), LayoutUnit()); |
1542 | 1546 |
1543 if (!style()->clipTop().isAuto()) { | 1547 if (!style()->clipTop().isAuto()) { |
1544 LayoutUnit c = valueForLength(style()->clipTop(), borderBoxRect.height()
); | 1548 LayoutUnit c = valueForLength(style()->clipTop(), borderBoxRect.height()
); |
1545 clipRect.move(0, c); | 1549 clipRect.move(LayoutUnit(), c); |
1546 clipRect.contract(0, c); | 1550 clipRect.contract(LayoutUnit(), c); |
1547 } | 1551 } |
1548 | 1552 |
1549 if (!style()->clipBottom().isAuto()) | 1553 if (!style()->clipBottom().isAuto()) |
1550 clipRect.contract(0, size().height() - valueForLength(style()->clipBotto
m(), size().height())); | 1554 clipRect.contract(LayoutUnit(), size().height() - valueForLength(style()
->clipBottom(), size().height())); |
1551 | 1555 |
1552 return clipRect; | 1556 return clipRect; |
1553 } | 1557 } |
1554 | 1558 |
1555 static LayoutUnit portionOfMarginNotConsumedByFloat(LayoutUnit childMargin, Layo
utUnit contentSide, LayoutUnit offset) | 1559 static LayoutUnit portionOfMarginNotConsumedByFloat(LayoutUnit childMargin, Layo
utUnit contentSide, LayoutUnit offset) |
1556 { | 1560 { |
1557 if (childMargin <= 0) | 1561 if (childMargin <= 0) |
1558 return LayoutUnit(); | 1562 return LayoutUnit(); |
1559 LayoutUnit contentSideWithMargin = contentSide + childMargin; | 1563 LayoutUnit contentSideWithMargin = contentSide + childMargin; |
1560 if (offset > contentSideWithMargin) | 1564 if (offset > contentSideWithMargin) |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1633 | 1637 |
1634 LayoutBlock* cb = containingBlock(); | 1638 LayoutBlock* cb = containingBlock(); |
1635 if (cb->hasOverrideLogicalContentHeight()) | 1639 if (cb->hasOverrideLogicalContentHeight()) |
1636 return cb->overrideLogicalContentHeight(); | 1640 return cb->overrideLogicalContentHeight(); |
1637 | 1641 |
1638 const ComputedStyle& containingBlockStyle = cb->styleRef(); | 1642 const ComputedStyle& containingBlockStyle = cb->styleRef(); |
1639 Length logicalHeightLength = containingBlockStyle.logicalHeight(); | 1643 Length logicalHeightLength = containingBlockStyle.logicalHeight(); |
1640 | 1644 |
1641 // FIXME: For now just support fixed heights. Eventually should support per
centage heights as well. | 1645 // FIXME: For now just support fixed heights. Eventually should support per
centage heights as well. |
1642 if (!logicalHeightLength.isFixed()) { | 1646 if (!logicalHeightLength.isFixed()) { |
1643 LayoutUnit fillFallbackExtent = containingBlockStyle.isHorizontalWriting
Mode() | 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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2166 if (logicalWidthLength.type() == MaxContent) | 2170 if (logicalWidthLength.type() == MaxContent) |
2167 return maxLogicalWidth + borderAndPadding; | 2171 return maxLogicalWidth + borderAndPadding; |
2168 | 2172 |
2169 if (logicalWidthLength.type() == FitContent) { | 2173 if (logicalWidthLength.type() == FitContent) { |
2170 minLogicalWidth += borderAndPadding; | 2174 minLogicalWidth += borderAndPadding; |
2171 maxLogicalWidth += borderAndPadding; | 2175 maxLogicalWidth += borderAndPadding; |
2172 return std::max(minLogicalWidth, std::min(maxLogicalWidth, fillAvailable
Measure(availableLogicalWidth))); | 2176 return std::max(minLogicalWidth, std::min(maxLogicalWidth, fillAvailable
Measure(availableLogicalWidth))); |
2173 } | 2177 } |
2174 | 2178 |
2175 ASSERT_NOT_REACHED(); | 2179 ASSERT_NOT_REACHED(); |
2176 return 0; | 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(0); | 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. |
(...skipping 267 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 11 matching lines...) Expand all Loading... |
2486 computedValues.m_extent = std::max(computedValues.m_extent, visibleH
eight - marginsBordersPadding); | 2490 computedValues.m_extent = std::max(computedValues.m_extent, visibleH
eight - marginsBordersPadding); |
2487 } | 2491 } |
2488 } | 2492 } |
2489 } | 2493 } |
2490 | 2494 |
2491 LayoutUnit LayoutBox::computeLogicalHeightWithoutLayout() const | 2495 LayoutUnit LayoutBox::computeLogicalHeightWithoutLayout() const |
2492 { | 2496 { |
2493 // TODO(cbiesinger): We should probably return something other than just bor
der + padding, but for now | 2497 // TODO(cbiesinger): We should probably return something other than just bor
der + padding, but for now |
2494 // we have no good way to do anything else without layout, so we just use th
at. | 2498 // we have no good way to do anything else without layout, so we just use th
at. |
2495 LogicalExtentComputedValues computedValues; | 2499 LogicalExtentComputedValues computedValues; |
2496 computeLogicalHeight(borderAndPaddingLogicalHeight(), 0, computedValues); | 2500 computeLogicalHeight(borderAndPaddingLogicalHeight(), LayoutUnit(), computed
Values); |
2497 return computedValues.m_extent; | 2501 return computedValues.m_extent; |
2498 } | 2502 } |
2499 | 2503 |
2500 LayoutUnit LayoutBox::computeLogicalHeightUsing(SizeType heightType, const Lengt
h& height, LayoutUnit intrinsicContentHeight) const | 2504 LayoutUnit LayoutBox::computeLogicalHeightUsing(SizeType heightType, const Lengt
h& height, LayoutUnit intrinsicContentHeight) const |
2501 { | 2505 { |
2502 LayoutUnit logicalHeight = computeContentAndScrollbarLogicalHeightUsing(heig
htType, height, intrinsicContentHeight); | 2506 LayoutUnit logicalHeight = computeContentAndScrollbarLogicalHeightUsing(heig
htType, height, intrinsicContentHeight); |
2503 if (logicalHeight != -1) | 2507 if (logicalHeight != -1) |
2504 logicalHeight = adjustBorderBoxLogicalHeightForBoxSizing(logicalHeight); | 2508 logicalHeight = adjustBorderBoxLogicalHeightForBoxSizing(logicalHeight); |
2505 return logicalHeight; | 2509 return logicalHeight; |
2506 } | 2510 } |
2507 | 2511 |
2508 LayoutUnit LayoutBox::computeContentLogicalHeight(SizeType heightType, const Len
gth& height, LayoutUnit intrinsicContentHeight) const | 2512 LayoutUnit LayoutBox::computeContentLogicalHeight(SizeType heightType, const Len
gth& height, LayoutUnit intrinsicContentHeight) const |
2509 { | 2513 { |
2510 LayoutUnit heightIncludingScrollbar = computeContentAndScrollbarLogicalHeigh
tUsing(heightType, height, intrinsicContentHeight); | 2514 LayoutUnit heightIncludingScrollbar = computeContentAndScrollbarLogicalHeigh
tUsing(heightType, height, intrinsicContentHeight); |
2511 if (heightIncludingScrollbar == -1) | 2515 if (heightIncludingScrollbar == -1) |
2512 return -1; | 2516 return LayoutUnit(-1); |
2513 return std::max(LayoutUnit(), adjustContentBoxLogicalHeightForBoxSizing(heig
htIncludingScrollbar) - scrollbarLogicalHeight()); | 2517 return std::max(LayoutUnit(), adjustContentBoxLogicalHeightForBoxSizing(heig
htIncludingScrollbar) - scrollbarLogicalHeight()); |
2514 } | 2518 } |
2515 | 2519 |
2516 LayoutUnit LayoutBox::computeIntrinsicLogicalContentHeightUsing(const Length& lo
gicalHeightLength, LayoutUnit intrinsicContentHeight, LayoutUnit borderAndPaddin
g) const | 2520 LayoutUnit LayoutBox::computeIntrinsicLogicalContentHeightUsing(const Length& lo
gicalHeightLength, LayoutUnit intrinsicContentHeight, LayoutUnit borderAndPaddin
g) const |
2517 { | 2521 { |
2518 // FIXME(cbiesinger): The css-sizing spec is considering changing what min-c
ontent/max-content should resolve to. | 2522 // FIXME(cbiesinger): The css-sizing spec is considering changing what min-c
ontent/max-content should resolve to. |
2519 // If that happens, this code will have to change. | 2523 // If that happens, this code will have to change. |
2520 if (logicalHeightLength.isMinContent() || logicalHeightLength.isMaxContent()
|| logicalHeightLength.isFitContent()) { | 2524 if (logicalHeightLength.isMinContent() || logicalHeightLength.isMaxContent()
|| logicalHeightLength.isFitContent()) { |
2521 if (isAtomicInlineLevel()) | 2525 if (isAtomicInlineLevel()) |
2522 return intrinsicSize().height(); | 2526 return intrinsicSize().height(); |
2523 if (m_intrinsicContentLogicalHeight != -1) | 2527 if (m_intrinsicContentLogicalHeight != -1) |
2524 return m_intrinsicContentLogicalHeight; | 2528 return m_intrinsicContentLogicalHeight; |
2525 return intrinsicContentHeight; | 2529 return intrinsicContentHeight; |
2526 } | 2530 } |
2527 if (logicalHeightLength.isFillAvailable()) | 2531 if (logicalHeightLength.isFillAvailable()) |
2528 return containingBlock()->availableLogicalHeight(ExcludeMarginBorderPadd
ing) - borderAndPadding; | 2532 return containingBlock()->availableLogicalHeight(ExcludeMarginBorderPadd
ing) - borderAndPadding; |
2529 ASSERT_NOT_REACHED(); | 2533 ASSERT_NOT_REACHED(); |
2530 return 0; | 2534 return LayoutUnit(); |
2531 } | 2535 } |
2532 | 2536 |
2533 LayoutUnit LayoutBox::computeContentAndScrollbarLogicalHeightUsing(SizeType heig
htType, const Length& height, LayoutUnit intrinsicContentHeight) const | 2537 LayoutUnit LayoutBox::computeContentAndScrollbarLogicalHeightUsing(SizeType heig
htType, const Length& height, LayoutUnit intrinsicContentHeight) const |
2534 { | 2538 { |
2535 if (height.isAuto()) | 2539 if (height.isAuto()) |
2536 return heightType == MinSize ? 0 : -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 -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 -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(); |
2556 } | 2560 } |
2557 | 2561 |
2558 bool LayoutBox::skipContainingBlockForPercentHeightCalculation(const LayoutBox*
containingBlock) const | 2562 bool LayoutBox::skipContainingBlockForPercentHeightCalculation(const LayoutBox*
containingBlock) const |
(...skipping 12 matching lines...) Expand all Loading... |
2571 EDisplay display = containingBlock->styleRef().display(); | 2575 EDisplay display = containingBlock->styleRef().display(); |
2572 return display == BLOCK || display == INLINE_BLOCK; | 2576 return display == BLOCK || display == INLINE_BLOCK; |
2573 } | 2577 } |
2574 | 2578 |
2575 // For quirks mode, we skip most auto-height containing blocks when computin
g percentages. | 2579 // For quirks mode, we skip most auto-height containing blocks when computin
g percentages. |
2576 return document().inQuirksMode() && !containingBlock->isTableCell() && !cont
ainingBlock->isOutOfFlowPositioned() && !containingBlock->isLayoutGrid() && cont
ainingBlock->style()->logicalHeight().isAuto(); | 2580 return document().inQuirksMode() && !containingBlock->isTableCell() && !cont
ainingBlock->isOutOfFlowPositioned() && !containingBlock->isLayoutGrid() && cont
ainingBlock->style()->logicalHeight().isAuto(); |
2577 } | 2581 } |
2578 | 2582 |
2579 LayoutUnit LayoutBox::computePercentageLogicalHeight(const Length& height) const | 2583 LayoutUnit LayoutBox::computePercentageLogicalHeight(const Length& height) const |
2580 { | 2584 { |
2581 LayoutUnit availableHeight = -1; | 2585 LayoutUnit availableHeight(-1); |
2582 | 2586 |
2583 bool skippedAutoHeightContainingBlock = false; | 2587 bool skippedAutoHeightContainingBlock = false; |
2584 LayoutBlock* cb = containingBlock(); | 2588 LayoutBlock* cb = containingBlock(); |
2585 const LayoutBox* containingBlockChild = this; | 2589 const LayoutBox* containingBlockChild = this; |
2586 LayoutUnit rootMarginBorderPaddingHeight; | 2590 LayoutUnit rootMarginBorderPaddingHeight; |
2587 while (!cb->isLayoutView() && skipContainingBlockForPercentHeightCalculation
(cb)) { | 2591 while (!cb->isLayoutView() && skipContainingBlockForPercentHeightCalculation
(cb)) { |
2588 if (cb->isBody() || cb->isDocumentElement()) | 2592 if (cb->isBody() || cb->isDocumentElement()) |
2589 rootMarginBorderPaddingHeight += cb->marginBefore() + cb->marginAfte
r() + cb->borderAndPaddingLogicalHeight(); | 2593 rootMarginBorderPaddingHeight += cb->marginBefore() + cb->marginAfte
r() + cb->borderAndPaddingLogicalHeight(); |
2590 skippedAutoHeightContainingBlock = true; | 2594 skippedAutoHeightContainingBlock = true; |
2591 containingBlockChild = cb; | 2595 containingBlockChild = cb; |
(...skipping 26 matching lines...) Expand all Loading... |
2618 // Normally we would let the cell size intrinsically, but scroll
ing overflow has to be | 2622 // Normally we would let the cell size intrinsically, but scroll
ing overflow has to be |
2619 // treated differently, since WinIE lets scrolled overflow regio
ns shrink as needed. | 2623 // treated differently, since WinIE lets scrolled overflow regio
ns shrink as needed. |
2620 // While we can't get all cases right, we can at least detect wh
en the cell has a specified | 2624 // While we can't get all cases right, we can at least detect wh
en the cell has a specified |
2621 // height or when the table has a specified height. In these cas
es we want to initially have | 2625 // height or when the table has a specified height. In these cas
es we want to initially have |
2622 // no size and allow the flexing of the table or the cell to its
specified height to cause us | 2626 // no size and allow the flexing of the table or the cell to its
specified height to cause us |
2623 // to grow to fill the space. This could end up being wrong in s
ome cases, but it is | 2627 // to grow to fill the space. This could end up being wrong in s
ome cases, but it is |
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 -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(), -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. |
2645 LayoutUnit contentBoxHeight = cb->constrainContentBoxLogicalHeightBy
MinMax(contentBoxHeightWithScrollbar - cb->scrollbarLogicalHeight(), -1); | 2649 LayoutUnit contentBoxHeight = cb->constrainContentBoxLogicalHeightBy
MinMax(contentBoxHeightWithScrollbar - cb->scrollbarLogicalHeight(), LayoutUnit(
-1)); |
2646 availableHeight = std::max(LayoutUnit(), contentBoxHeight); | 2650 availableHeight = std::max(LayoutUnit(), contentBoxHeight); |
2647 } | 2651 } |
2648 } else if (isOutOfFlowPositionedWithSpecifiedHeight) { | 2652 } else if (isOutOfFlowPositionedWithSpecifiedHeight) { |
2649 // Don't allow this to affect the block' size() member variable, since t
his | 2653 // Don't allow this to affect the block' size() member variable, since t
his |
2650 // can get called while the block is still laying out its kids. | 2654 // can get called while the block is still laying out its kids. |
2651 LogicalExtentComputedValues computedValues; | 2655 LogicalExtentComputedValues computedValues; |
2652 cb->computeLogicalHeight(cb->logicalHeight(), 0, computedValues); | 2656 cb->computeLogicalHeight(cb->logicalHeight(), LayoutUnit(), computedValu
es); |
2653 availableHeight = computedValues.m_extent - cb->borderAndPaddingLogicalH
eight() - cb->scrollbarLogicalHeight(); | 2657 availableHeight = computedValues.m_extent - cb->borderAndPaddingLogicalH
eight() - cb->scrollbarLogicalHeight(); |
2654 } else if (cb->isLayoutView()) { | 2658 } else if (cb->isLayoutView()) { |
2655 availableHeight = view()->viewLogicalHeightForPercentages(); | 2659 availableHeight = view()->viewLogicalHeightForPercentages(); |
2656 } | 2660 } |
2657 | 2661 |
2658 if (availableHeight == -1) | 2662 if (availableHeight == -1) |
2659 return availableHeight; | 2663 return availableHeight; |
2660 | 2664 |
2661 availableHeight -= rootMarginBorderPaddingHeight; | 2665 availableHeight -= rootMarginBorderPaddingHeight; |
2662 | 2666 |
(...skipping 21 matching lines...) Expand all Loading... |
2684 { | 2688 { |
2685 LayoutUnit minLogicalWidth = (shouldComputePreferred == ComputePreferred &&
style()->logicalMinWidth().hasPercent()) ? logicalWidth : computeReplacedLogical
WidthUsing(MinSize, style()->logicalMinWidth()); | 2689 LayoutUnit minLogicalWidth = (shouldComputePreferred == ComputePreferred &&
style()->logicalMinWidth().hasPercent()) ? logicalWidth : computeReplacedLogical
WidthUsing(MinSize, style()->logicalMinWidth()); |
2686 LayoutUnit maxLogicalWidth = (shouldComputePreferred == ComputePreferred &&
style()->logicalMaxWidth().hasPercent()) || style()->logicalMaxWidth().isMaxSize
None() ? logicalWidth : computeReplacedLogicalWidthUsing(MaxSize, style()->logic
alMaxWidth()); | 2690 LayoutUnit maxLogicalWidth = (shouldComputePreferred == ComputePreferred &&
style()->logicalMaxWidth().hasPercent()) || style()->logicalMaxWidth().isMaxSize
None() ? logicalWidth : computeReplacedLogicalWidthUsing(MaxSize, style()->logic
alMaxWidth()); |
2687 return std::max(minLogicalWidth, std::min(logicalWidth, maxLogicalWidth)); | 2691 return std::max(minLogicalWidth, std::min(logicalWidth, maxLogicalWidth)); |
2688 } | 2692 } |
2689 | 2693 |
2690 LayoutUnit LayoutBox::computeReplacedLogicalWidthUsing(SizeType sizeType, const
Length& logicalWidth) const | 2694 LayoutUnit LayoutBox::computeReplacedLogicalWidthUsing(SizeType sizeType, const
Length& logicalWidth) const |
2691 { | 2695 { |
2692 ASSERT(sizeType == MinSize || sizeType == MainOrPreferredSize || !logicalWid
th.isAuto()); | 2696 ASSERT(sizeType == MinSize || sizeType == MainOrPreferredSize || !logicalWid
th.isAuto()); |
2693 if (sizeType == MinSize && logicalWidth.isAuto()) | 2697 if (sizeType == MinSize && logicalWidth.isAuto()) |
2694 return adjustContentBoxLogicalWidthForBoxSizing(0); | 2698 return adjustContentBoxLogicalWidthForBoxSizing(LayoutUnit()); |
2695 | 2699 |
2696 switch (logicalWidth.type()) { | 2700 switch (logicalWidth.type()) { |
2697 case Fixed: | 2701 case Fixed: |
2698 return adjustContentBoxLogicalWidthForBoxSizing(logicalWidth.value()); | 2702 return adjustContentBoxLogicalWidthForBoxSizing(logicalWidth.value()); |
2699 case MinContent: | 2703 case MinContent: |
2700 case MaxContent: { | 2704 case MaxContent: { |
2701 // MinContent/MaxContent don't need the availableLogicalWidth argument. | 2705 // MinContent/MaxContent don't need the availableLogicalWidth argument. |
2702 LayoutUnit availableLogicalWidth; | 2706 LayoutUnit availableLogicalWidth; |
2703 return computeIntrinsicLogicalWidthUsing(logicalWidth, availableLogicalW
idth, borderAndPaddingLogicalWidth()) - borderAndPaddingLogicalWidth(); | 2707 return computeIntrinsicLogicalWidthUsing(logicalWidth, availableLogicalW
idth, borderAndPaddingLogicalWidth()) - borderAndPaddingLogicalWidth(); |
2704 } | 2708 } |
(...skipping 17 matching lines...) Expand all Loading... |
2722 case Auto: | 2726 case Auto: |
2723 case MaxSizeNone: | 2727 case MaxSizeNone: |
2724 return intrinsicLogicalWidth(); | 2728 return intrinsicLogicalWidth(); |
2725 case ExtendToZoom: | 2729 case ExtendToZoom: |
2726 case DeviceWidth: | 2730 case DeviceWidth: |
2727 case DeviceHeight: | 2731 case DeviceHeight: |
2728 break; | 2732 break; |
2729 } | 2733 } |
2730 | 2734 |
2731 ASSERT_NOT_REACHED(); | 2735 ASSERT_NOT_REACHED(); |
2732 return 0; | 2736 return LayoutUnit(); |
2733 } | 2737 } |
2734 | 2738 |
2735 LayoutUnit LayoutBox::computeReplacedLogicalHeight() const | 2739 LayoutUnit LayoutBox::computeReplacedLogicalHeight() const |
2736 { | 2740 { |
2737 return computeReplacedLogicalHeightRespectingMinMaxHeight(computeReplacedLog
icalHeightUsing(MainOrPreferredSize, style()->logicalHeight())); | 2741 return computeReplacedLogicalHeightRespectingMinMaxHeight(computeReplacedLog
icalHeightUsing(MainOrPreferredSize, style()->logicalHeight())); |
2738 } | 2742 } |
2739 | 2743 |
2740 bool LayoutBox::logicalHeightComputesAsNone(SizeType sizeType) const | 2744 bool LayoutBox::logicalHeightComputesAsNone(SizeType sizeType) const |
2741 { | 2745 { |
2742 ASSERT(sizeType == MinSize || sizeType == MaxSize); | 2746 ASSERT(sizeType == MinSize || sizeType == MaxSize); |
(...skipping 18 matching lines...) Expand all Loading... |
2761 LayoutUnit maxLogicalHeight = logicalHeight; | 2765 LayoutUnit maxLogicalHeight = logicalHeight; |
2762 if (!logicalHeightComputesAsNone(MaxSize)) | 2766 if (!logicalHeightComputesAsNone(MaxSize)) |
2763 maxLogicalHeight = computeReplacedLogicalHeightUsing(MaxSize, style()->
logicalMaxHeight()); | 2767 maxLogicalHeight = computeReplacedLogicalHeightUsing(MaxSize, style()->
logicalMaxHeight()); |
2764 return std::max(minLogicalHeight, std::min(logicalHeight, maxLogicalHeight))
; | 2768 return std::max(minLogicalHeight, std::min(logicalHeight, maxLogicalHeight))
; |
2765 } | 2769 } |
2766 | 2770 |
2767 LayoutUnit LayoutBox::computeReplacedLogicalHeightUsing(SizeType sizeType, const
Length& logicalHeight) const | 2771 LayoutUnit LayoutBox::computeReplacedLogicalHeightUsing(SizeType sizeType, const
Length& logicalHeight) const |
2768 { | 2772 { |
2769 ASSERT(sizeType == MinSize || sizeType == MainOrPreferredSize || !logicalHei
ght.isAuto()); | 2773 ASSERT(sizeType == MinSize || sizeType == MainOrPreferredSize || !logicalHei
ght.isAuto()); |
2770 if (sizeType == MinSize && logicalHeight.isAuto()) | 2774 if (sizeType == MinSize && logicalHeight.isAuto()) |
2771 return adjustContentBoxLogicalHeightForBoxSizing(0); | 2775 return adjustContentBoxLogicalHeightForBoxSizing(LayoutUnit()); |
2772 | 2776 |
2773 switch (logicalHeight.type()) { | 2777 switch (logicalHeight.type()) { |
2774 case Fixed: | 2778 case Fixed: |
2775 return adjustContentBoxLogicalHeightForBoxSizing(logicalHeight.value()); | 2779 return adjustContentBoxLogicalHeightForBoxSizing(logicalHeight.value()); |
2776 case Percent: | 2780 case Percent: |
2777 case Calculated: | 2781 case Calculated: |
2778 { | 2782 { |
2779 LayoutObject* cb = isOutOfFlowPositioned() ? container() : containingBlo
ck(); | 2783 LayoutObject* cb = isOutOfFlowPositioned() ? container() : containingBlo
ck(); |
2780 while (cb->isAnonymous()) | 2784 while (cb->isAnonymous()) |
2781 cb = cb->containingBlock(); | 2785 cb = cb->containingBlock(); |
2782 if (cb->isLayoutBlock()) | 2786 if (cb->isLayoutBlock()) |
2783 toLayoutBlock(cb)->addPercentHeightDescendant(const_cast<LayoutBox*>
(this)); | 2787 toLayoutBlock(cb)->addPercentHeightDescendant(const_cast<LayoutBox*>
(this)); |
2784 | 2788 |
2785 if (cb->isOutOfFlowPositioned() && cb->style()->height().isAuto() && !(c
b->style()->top().isAuto() || cb->style()->bottom().isAuto())) { | 2789 if (cb->isOutOfFlowPositioned() && cb->style()->height().isAuto() && !(c
b->style()->top().isAuto() || cb->style()->bottom().isAuto())) { |
2786 ASSERT_WITH_SECURITY_IMPLICATION(cb->isLayoutBlock()); | 2790 ASSERT_WITH_SECURITY_IMPLICATION(cb->isLayoutBlock()); |
2787 LayoutBlock* block = toLayoutBlock(cb); | 2791 LayoutBlock* block = toLayoutBlock(cb); |
2788 LogicalExtentComputedValues computedValues; | 2792 LogicalExtentComputedValues computedValues; |
2789 block->computeLogicalHeight(block->logicalHeight(), 0, computedValue
s); | 2793 block->computeLogicalHeight(block->logicalHeight(), LayoutUnit(), co
mputedValues); |
2790 LayoutUnit newContentHeight = computedValues.m_extent - block->borde
rAndPaddingLogicalHeight() - block->scrollbarLogicalHeight(); | 2794 LayoutUnit newContentHeight = computedValues.m_extent - block->borde
rAndPaddingLogicalHeight() - block->scrollbarLogicalHeight(); |
2791 LayoutUnit newHeight = block->adjustContentBoxLogicalHeightForBoxSiz
ing(newContentHeight); | 2795 LayoutUnit newHeight = block->adjustContentBoxLogicalHeightForBoxSiz
ing(newContentHeight); |
2792 return adjustContentBoxLogicalHeightForBoxSizing(valueForLength(logi
calHeight, newHeight)); | 2796 return adjustContentBoxLogicalHeightForBoxSizing(valueForLength(logi
calHeight, newHeight)); |
2793 } | 2797 } |
2794 | 2798 |
2795 // FIXME: availableLogicalHeight() is wrong if the replaced element's wr
iting-mode is perpendicular to the | 2799 // FIXME: availableLogicalHeight() is wrong if the replaced element's wr
iting-mode is perpendicular to the |
2796 // containing block's writing-mode. | 2800 // containing block's writing-mode. |
2797 // https://bugs.webkit.org/show_bug.cgi?id=46496 | 2801 // https://bugs.webkit.org/show_bug.cgi?id=46496 |
2798 LayoutUnit availableHeight; | 2802 LayoutUnit availableHeight; |
2799 if (isOutOfFlowPositioned()) { | 2803 if (isOutOfFlowPositioned()) { |
(...skipping 24 matching lines...) Expand all Loading... |
2824 case FillAvailable: | 2828 case FillAvailable: |
2825 return adjustContentBoxLogicalHeightForBoxSizing(computeIntrinsicLogical
ContentHeightUsing(logicalHeight, intrinsicLogicalHeight(), borderAndPaddingHeig
ht())); | 2829 return adjustContentBoxLogicalHeightForBoxSizing(computeIntrinsicLogical
ContentHeightUsing(logicalHeight, intrinsicLogicalHeight(), borderAndPaddingHeig
ht())); |
2826 default: | 2830 default: |
2827 return intrinsicLogicalHeight(); | 2831 return intrinsicLogicalHeight(); |
2828 } | 2832 } |
2829 } | 2833 } |
2830 | 2834 |
2831 LayoutUnit LayoutBox::availableLogicalHeight(AvailableLogicalHeightType heightTy
pe) const | 2835 LayoutUnit LayoutBox::availableLogicalHeight(AvailableLogicalHeightType heightTy
pe) const |
2832 { | 2836 { |
2833 // http://www.w3.org/TR/CSS2/visudet.html#propdef-height - We are interested
in the content height. | 2837 // http://www.w3.org/TR/CSS2/visudet.html#propdef-height - We are interested
in the content height. |
2834 return constrainContentBoxLogicalHeightByMinMax(availableLogicalHeightUsing(
style()->logicalHeight(), heightType), -1); | 2838 return constrainContentBoxLogicalHeightByMinMax(availableLogicalHeightUsing(
style()->logicalHeight(), heightType), LayoutUnit(-1)); |
2835 } | 2839 } |
2836 | 2840 |
2837 LayoutUnit LayoutBox::availableLogicalHeightUsing(const Length& h, AvailableLogi
calHeightType heightType) const | 2841 LayoutUnit LayoutBox::availableLogicalHeightUsing(const Length& h, AvailableLogi
calHeightType heightType) const |
2838 { | 2842 { |
2839 if (isLayoutView()) | 2843 if (isLayoutView()) { |
2840 return isHorizontalWritingMode() ? toLayoutView(this)->frameView()->visi
bleContentSize().height() : toLayoutView(this)->frameView()->visibleContentSize(
).width(); | 2844 return LayoutUnit(isHorizontalWritingMode() |
| 2845 ? toLayoutView(this)->frameView()->visibleContentSize().height() |
| 2846 : toLayoutView(this)->frameView()->visibleContentSize().width()); |
| 2847 } |
2841 | 2848 |
2842 // We need to stop here, since we don't want to increase the height of the t
able | 2849 // We need to stop here, since we don't want to increase the height of the t
able |
2843 // artificially. We're going to rely on this cell getting expanded to some
new | 2850 // artificially. We're going to rely on this cell getting expanded to some
new |
2844 // height, and then when we lay out again we'll use the calculation below. | 2851 // height, and then when we lay out again we'll use the calculation below. |
2845 if (isTableCell() && (h.isAuto() || h.hasPercent())) { | 2852 if (isTableCell() && (h.isAuto() || h.hasPercent())) { |
2846 if (hasOverrideLogicalContentHeight()) | 2853 if (hasOverrideLogicalContentHeight()) |
2847 return overrideLogicalContentHeight(); | 2854 return overrideLogicalContentHeight(); |
2848 return logicalHeight() - borderAndPaddingLogicalHeight(); | 2855 return logicalHeight() - borderAndPaddingLogicalHeight(); |
2849 } | 2856 } |
2850 | 2857 |
2851 if (h.hasPercent() && isOutOfFlowPositioned()) { | 2858 if (h.hasPercent() && isOutOfFlowPositioned()) { |
2852 // FIXME: This is wrong if the containingBlock has a perpendicular writi
ng mode. | 2859 // FIXME: This is wrong if the containingBlock has a perpendicular writi
ng mode. |
2853 LayoutUnit availableHeight = containingBlockLogicalHeightForPositioned(c
ontainingBlock()); | 2860 LayoutUnit availableHeight = containingBlockLogicalHeightForPositioned(c
ontainingBlock()); |
2854 return adjustContentBoxLogicalHeightForBoxSizing(valueForLength(h, avail
ableHeight)); | 2861 return adjustContentBoxLogicalHeightForBoxSizing(valueForLength(h, avail
ableHeight)); |
2855 } | 2862 } |
2856 | 2863 |
2857 LayoutUnit heightIncludingScrollbar = computeContentAndScrollbarLogicalHeigh
tUsing(MainOrPreferredSize, h, -1); | 2864 LayoutUnit heightIncludingScrollbar = computeContentAndScrollbarLogicalHeigh
tUsing(MainOrPreferredSize, h, LayoutUnit(-1)); |
2858 if (heightIncludingScrollbar != -1) | 2865 if (heightIncludingScrollbar != -1) |
2859 return std::max(LayoutUnit(), adjustContentBoxLogicalHeightForBoxSizing(
heightIncludingScrollbar) - scrollbarLogicalHeight()); | 2866 return std::max(LayoutUnit(), adjustContentBoxLogicalHeightForBoxSizing(
heightIncludingScrollbar) - scrollbarLogicalHeight()); |
2860 | 2867 |
2861 // FIXME: Check logicalTop/logicalBottom here to correctly handle vertical w
riting-mode. | 2868 // FIXME: Check logicalTop/logicalBottom here to correctly handle vertical w
riting-mode. |
2862 // https://bugs.webkit.org/show_bug.cgi?id=46500 | 2869 // https://bugs.webkit.org/show_bug.cgi?id=46500 |
2863 if (isLayoutBlock() && isOutOfFlowPositioned() && style()->height().isAuto()
&& !(style()->top().isAuto() || style()->bottom().isAuto())) { | 2870 if (isLayoutBlock() && isOutOfFlowPositioned() && style()->height().isAuto()
&& !(style()->top().isAuto() || style()->bottom().isAuto())) { |
2864 LayoutBlock* block = const_cast<LayoutBlock*>(toLayoutBlock(this)); | 2871 LayoutBlock* block = const_cast<LayoutBlock*>(toLayoutBlock(this)); |
2865 LogicalExtentComputedValues computedValues; | 2872 LogicalExtentComputedValues computedValues; |
2866 block->computeLogicalHeight(block->logicalHeight(), 0, computedValues); | 2873 block->computeLogicalHeight(block->logicalHeight(), LayoutUnit(), comput
edValues); |
2867 LayoutUnit newContentHeight = computedValues.m_extent - block->borderAnd
PaddingLogicalHeight() - block->scrollbarLogicalHeight(); | 2874 LayoutUnit newContentHeight = computedValues.m_extent - block->borderAnd
PaddingLogicalHeight() - block->scrollbarLogicalHeight(); |
2868 return adjustContentBoxLogicalHeightForBoxSizing(newContentHeight); | 2875 return adjustContentBoxLogicalHeightForBoxSizing(newContentHeight); |
2869 } | 2876 } |
2870 | 2877 |
2871 // FIXME: This is wrong if the containingBlock has a perpendicular writing m
ode. | 2878 // FIXME: This is wrong if the containingBlock has a perpendicular writing m
ode. |
2872 LayoutUnit availableHeight = containingBlockLogicalHeightForContent(heightTy
pe); | 2879 LayoutUnit availableHeight = containingBlockLogicalHeightForContent(heightTy
pe); |
2873 if (heightType == ExcludeMarginBorderPadding) { | 2880 if (heightType == ExcludeMarginBorderPadding) { |
2874 // FIXME: Margin collapsing hasn't happened yet, so this incorrectly rem
oves collapsed margins. | 2881 // FIXME: Margin collapsing hasn't happened yet, so this incorrectly rem
oves collapsed margins. |
2875 availableHeight -= marginBefore() + marginAfter() + borderAndPaddingLogi
calHeight(); | 2882 availableHeight -= marginBefore() + marginAfter() + borderAndPaddingLogi
calHeight(); |
2876 } | 2883 } |
(...skipping 16 matching lines...) Expand all Loading... |
2893 LayoutUnit LayoutBox::containingBlockLogicalWidthForPositioned(const LayoutBoxMo
delObject* containingBlock, bool checkForPerpendicularWritingMode) const | 2900 LayoutUnit LayoutBox::containingBlockLogicalWidthForPositioned(const LayoutBoxMo
delObject* containingBlock, bool checkForPerpendicularWritingMode) const |
2894 { | 2901 { |
2895 if (checkForPerpendicularWritingMode && containingBlock->isHorizontalWriting
Mode() != isHorizontalWritingMode()) | 2902 if (checkForPerpendicularWritingMode && containingBlock->isHorizontalWriting
Mode() != isHorizontalWritingMode()) |
2896 return containingBlockLogicalHeightForPositioned(containingBlock, false)
; | 2903 return containingBlockLogicalHeightForPositioned(containingBlock, false)
; |
2897 | 2904 |
2898 // Use viewport as container for top-level fixed-position elements. | 2905 // Use viewport as container for top-level fixed-position elements. |
2899 if (style()->position() == FixedPosition && containingBlock->isLayoutView()
&& !document().printing()) { | 2906 if (style()->position() == FixedPosition && containingBlock->isLayoutView()
&& !document().printing()) { |
2900 const LayoutView* view = toLayoutView(containingBlock); | 2907 const LayoutView* view = toLayoutView(containingBlock); |
2901 if (FrameView* frameView = view->frameView()) { | 2908 if (FrameView* frameView = view->frameView()) { |
2902 // Don't use visibleContentRect since the PaintLayer's size has not
been set yet. | 2909 // Don't use visibleContentRect since the PaintLayer's size has not
been set yet. |
2903 IntSize viewportSize = frameView->layoutViewportScrollableArea()->ex
cludeScrollbars(frameView->frameRect().size()); | 2910 LayoutSize viewportSize(frameView->layoutViewportScrollableArea()->e
xcludeScrollbars(frameView->frameRect().size())); |
2904 return containingBlock->isHorizontalWritingMode() ? viewportSize.wid
th() : viewportSize.height(); | 2911 return LayoutUnit(containingBlock->isHorizontalWritingMode() ? viewp
ortSize.width() : viewportSize.height()); |
2905 } | 2912 } |
2906 } | 2913 } |
2907 | 2914 |
2908 if (hasOverrideContainingBlockLogicalWidth()) | 2915 if (hasOverrideContainingBlockLogicalWidth()) |
2909 return overrideContainingBlockContentLogicalWidth(); | 2916 return overrideContainingBlockContentLogicalWidth(); |
2910 | 2917 |
2911 // Ensure we compute our width based on the width of our rel-pos inline cont
ainer rather than any anonymous block | 2918 // Ensure we compute our width based on the width of our rel-pos inline cont
ainer rather than any anonymous block |
2912 // created to manage a block-flow ancestor of ours in the rel-pos inline's i
nline flow. | 2919 // created to manage a block-flow ancestor of ours in the rel-pos inline's i
nline flow. |
2913 if (containingBlock->isAnonymousBlock() && containingBlock->isRelPositioned(
)) | 2920 if (containingBlock->isAnonymousBlock() && containingBlock->isRelPositioned(
)) |
2914 containingBlock = toLayoutBox(containingBlock)->continuation(); | 2921 containingBlock = toLayoutBox(containingBlock)->continuation(); |
(...skipping 26 matching lines...) Expand all Loading... |
2941 LayoutUnit LayoutBox::containingBlockLogicalHeightForPositioned(const LayoutBoxM
odelObject* containingBlock, bool checkForPerpendicularWritingMode) const | 2948 LayoutUnit LayoutBox::containingBlockLogicalHeightForPositioned(const LayoutBoxM
odelObject* containingBlock, bool checkForPerpendicularWritingMode) const |
2942 { | 2949 { |
2943 if (checkForPerpendicularWritingMode && containingBlock->isHorizontalWriting
Mode() != isHorizontalWritingMode()) | 2950 if (checkForPerpendicularWritingMode && containingBlock->isHorizontalWriting
Mode() != isHorizontalWritingMode()) |
2944 return containingBlockLogicalWidthForPositioned(containingBlock, false); | 2951 return containingBlockLogicalWidthForPositioned(containingBlock, false); |
2945 | 2952 |
2946 // Use viewport as container for top-level fixed-position elements. | 2953 // Use viewport as container for top-level fixed-position elements. |
2947 if (style()->position() == FixedPosition && containingBlock->isLayoutView()
&& !document().printing()) { | 2954 if (style()->position() == FixedPosition && containingBlock->isLayoutView()
&& !document().printing()) { |
2948 const LayoutView* view = toLayoutView(containingBlock); | 2955 const LayoutView* view = toLayoutView(containingBlock); |
2949 if (FrameView* frameView = view->frameView()) { | 2956 if (FrameView* frameView = view->frameView()) { |
2950 // Don't use visibleContentRect since the PaintLayer's size has not
been set yet. | 2957 // Don't use visibleContentRect since the PaintLayer's size has not
been set yet. |
2951 IntSize viewportSize = frameView->layoutViewportScrollableArea()->ex
cludeScrollbars(frameView->frameRect().size()); | 2958 LayoutSize viewportSize(frameView->layoutViewportScrollableArea()->e
xcludeScrollbars(frameView->frameRect().size())); |
2952 return containingBlock->isHorizontalWritingMode() ? viewportSize.hei
ght() : viewportSize.width(); | 2959 return containingBlock->isHorizontalWritingMode() ? viewportSize.hei
ght() : viewportSize.width(); |
2953 } | 2960 } |
2954 } | 2961 } |
2955 | 2962 |
2956 if (hasOverrideContainingBlockLogicalHeight()) | 2963 if (hasOverrideContainingBlockLogicalHeight()) |
2957 return overrideContainingBlockContentLogicalHeight(); | 2964 return overrideContainingBlockContentLogicalHeight(); |
2958 | 2965 |
2959 if (containingBlock->isBox()) { | 2966 if (containingBlock->isBox()) { |
2960 const LayoutBlock* cb = containingBlock->isLayoutBlock() ? | 2967 const LayoutBlock* cb = containingBlock->isLayoutBlock() ? |
2961 toLayoutBlock(containingBlock) : containingBlock->containingBlock(); | 2968 toLayoutBlock(containingBlock) : containingBlock->containingBlock(); |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3211 // Margins are now the only unknown | 3218 // Margins are now the only unknown |
3212 if (marginLogicalLeft.isAuto() && marginLogicalRight.isAuto()) { | 3219 if (marginLogicalLeft.isAuto() && marginLogicalRight.isAuto()) { |
3213 // Both margins auto, solve for equality | 3220 // Both margins auto, solve for equality |
3214 if (availableSpace >= 0) { | 3221 if (availableSpace >= 0) { |
3215 marginLogicalLeftValue = availableSpace / 2; // split the differ
ence | 3222 marginLogicalLeftValue = availableSpace / 2; // split the differ
ence |
3216 marginLogicalRightValue = availableSpace - marginLogicalLeftValu
e; // account for odd valued differences | 3223 marginLogicalRightValue = availableSpace - marginLogicalLeftValu
e; // account for odd valued differences |
3217 } else { | 3224 } else { |
3218 // Use the containing block's direction rather than the parent b
lock's | 3225 // Use the containing block's direction rather than the parent b
lock's |
3219 // per CSS 2.1 reference test abspos-non-replaced-width-margin-0
00. | 3226 // per CSS 2.1 reference test abspos-non-replaced-width-margin-0
00. |
3220 if (containerDirection == LTR) { | 3227 if (containerDirection == LTR) { |
3221 marginLogicalLeftValue = 0; | 3228 marginLogicalLeftValue = LayoutUnit(); |
3222 marginLogicalRightValue = availableSpace; // will be negativ
e | 3229 marginLogicalRightValue = availableSpace; // will be negativ
e |
3223 } else { | 3230 } else { |
3224 marginLogicalLeftValue = availableSpace; // will be negative | 3231 marginLogicalLeftValue = availableSpace; // will be negative |
3225 marginLogicalRightValue = 0; | 3232 marginLogicalRightValue = LayoutUnit(); |
3226 } | 3233 } |
3227 } | 3234 } |
3228 } else if (marginLogicalLeft.isAuto()) { | 3235 } else if (marginLogicalLeft.isAuto()) { |
3229 // Solve for left margin | 3236 // Solve for left margin |
3230 marginLogicalRightValue = valueForLength(marginLogicalRight, contain
erRelativeLogicalWidth); | 3237 marginLogicalRightValue = valueForLength(marginLogicalRight, contain
erRelativeLogicalWidth); |
3231 marginLogicalLeftValue = availableSpace - marginLogicalRightValue; | 3238 marginLogicalLeftValue = availableSpace - marginLogicalRightValue; |
3232 } else if (marginLogicalRight.isAuto()) { | 3239 } else if (marginLogicalRight.isAuto()) { |
3233 // Solve for right margin | 3240 // Solve for right margin |
3234 marginLogicalLeftValue = valueForLength(marginLogicalLeft, container
RelativeLogicalWidth); | 3241 marginLogicalLeftValue = valueForLength(marginLogicalLeft, container
RelativeLogicalWidth); |
3235 marginLogicalRightValue = availableSpace - marginLogicalLeftValue; | 3242 marginLogicalRightValue = availableSpace - marginLogicalLeftValue; |
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3621 } | 3628 } |
3622 | 3629 |
3623 // If height of box is smaller than font height, use the latter one, | 3630 // If height of box is smaller than font height, use the latter one, |
3624 // otherwise the caret might become invisible. | 3631 // otherwise the caret might become invisible. |
3625 // | 3632 // |
3626 // Also, if the box is not an atomic inline-level element, always use the fo
nt height. | 3633 // Also, if the box is not an atomic inline-level element, always use the fo
nt height. |
3627 // This prevents the "big caret" bug described in: | 3634 // This prevents the "big caret" bug described in: |
3628 // <rdar://problem/3777804> Deleting all content in a document can result in
giant tall-as-window insertion point | 3635 // <rdar://problem/3777804> Deleting all content in a document can result in
giant tall-as-window insertion point |
3629 // | 3636 // |
3630 // FIXME: ignoring :first-line, missing good reason to take care of | 3637 // FIXME: ignoring :first-line, missing good reason to take care of |
3631 LayoutUnit fontHeight = style()->fontMetrics().height(); | 3638 LayoutUnit fontHeight = LayoutUnit(style()->fontMetrics().height()); |
3632 if (fontHeight > rect.height() || (!isAtomicInlineLevel() && !isTable())) | 3639 if (fontHeight > rect.height() || (!isAtomicInlineLevel() && !isTable())) |
3633 rect.setHeight(fontHeight); | 3640 rect.setHeight(fontHeight); |
3634 | 3641 |
3635 if (extraWidthToEndOfLine) | 3642 if (extraWidthToEndOfLine) |
3636 *extraWidthToEndOfLine = location().x() + size().width() - rect.maxX(); | 3643 *extraWidthToEndOfLine = location().x() + size().width() - rect.maxX(); |
3637 | 3644 |
3638 // Move to local coords | 3645 // Move to local coords |
3639 rect.moveBy(-location()); | 3646 rect.moveBy(-location()); |
3640 | 3647 |
3641 // FIXME: Border/padding should be added for all elements but this workaroun
d | 3648 // FIXME: Border/padding should be added for all elements but this workaroun
d |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3877 && oldBorderBoxSize == oldBounds.size() | 3884 && oldBorderBoxSize == oldBounds.size() |
3878 && newBorderBoxSize == newBounds.size()) | 3885 && newBorderBoxSize == newBounds.size()) |
3879 return; | 3886 return; |
3880 | 3887 |
3881 // 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. |
3882 LayoutUnit deltaWidth = absoluteValue(oldBorderBoxSize.width() - newBorderBo
xSize.width()); | 3889 LayoutUnit deltaWidth = absoluteValue(oldBorderBoxSize.width() - newBorderBo
xSize.width()); |
3883 if (deltaWidth) { | 3890 if (deltaWidth) { |
3884 LayoutUnit smallerWidth = std::min(oldBorderBoxSize.width(), newBorderBo
xSize.width()); | 3891 LayoutUnit smallerWidth = std::min(oldBorderBoxSize.width(), newBorderBo
xSize.width()); |
3885 LayoutUnit borderTopRightRadiusWidth = valueForLength(style()->borderTop
RightRadius().width(), smallerWidth); | 3892 LayoutUnit borderTopRightRadiusWidth = valueForLength(style()->borderTop
RightRadius().width(), smallerWidth); |
3886 LayoutUnit borderBottomRightRadiusWidth = valueForLength(style()->border
BottomRightRadius().width(), smallerWidth); | 3893 LayoutUnit borderBottomRightRadiusWidth = valueForLength(style()->border
BottomRightRadius().width(), smallerWidth); |
3887 LayoutUnit borderWidth = std::max<LayoutUnit>(borderRight(), std::max(bo
rderTopRightRadiusWidth, borderBottomRightRadiusWidth)); | 3894 LayoutUnit borderWidth = std::max(LayoutUnit(borderRight()), std::max(bo
rderTopRightRadiusWidth, borderBottomRightRadiusWidth)); |
3888 LayoutRect rightDeltaRect(positionFromPaintInvalidationBacking.x() + sma
llerWidth - borderWidth, | 3895 LayoutRect rightDeltaRect(positionFromPaintInvalidationBacking.x() + sma
llerWidth - borderWidth, |
3889 positionFromPaintInvalidationBacking.y(), | 3896 positionFromPaintInvalidationBacking.y(), |
3890 deltaWidth + borderWidth, | 3897 deltaWidth + borderWidth, |
3891 std::max(oldBorderBoxSize.height(), newBorderBoxSize.height())); | 3898 std::max(oldBorderBoxSize.height(), newBorderBoxSize.height())); |
3892 invalidatePaintRectClippedByOldAndNewBounds(paintInvalidationContainer,
rightDeltaRect, oldBounds, newBounds); | 3899 invalidatePaintRectClippedByOldAndNewBounds(paintInvalidationContainer,
rightDeltaRect, oldBounds, newBounds); |
3893 } | 3900 } |
3894 | 3901 |
3895 // 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. |
3896 LayoutUnit deltaHeight = absoluteValue(oldBorderBoxSize.height() - newBorder
BoxSize.height()); | 3903 LayoutUnit deltaHeight = absoluteValue(oldBorderBoxSize.height() - newBorder
BoxSize.height()); |
3897 if (deltaHeight) { | 3904 if (deltaHeight) { |
3898 LayoutUnit smallerHeight = std::min(oldBorderBoxSize.height(), newBorder
BoxSize.height()); | 3905 LayoutUnit smallerHeight = std::min(oldBorderBoxSize.height(), newBorder
BoxSize.height()); |
3899 LayoutUnit borderBottomLeftRadiusHeight = valueForLength(style()->border
BottomLeftRadius().height(), smallerHeight); | 3906 LayoutUnit borderBottomLeftRadiusHeight = valueForLength(style()->border
BottomLeftRadius().height(), smallerHeight); |
3900 LayoutUnit borderBottomRightRadiusHeight = valueForLength(style()->borde
rBottomRightRadius().height(), smallerHeight); | 3907 LayoutUnit borderBottomRightRadiusHeight = valueForLength(style()->borde
rBottomRightRadius().height(), smallerHeight); |
3901 LayoutUnit borderHeight = std::max<LayoutUnit>(borderBottom(), std::max(
borderBottomLeftRadiusHeight, borderBottomRightRadiusHeight)); | 3908 LayoutUnit borderHeight = std::max(LayoutUnit(borderBottom()), std::max(
borderBottomLeftRadiusHeight, borderBottomRightRadiusHeight)); |
3902 LayoutRect bottomDeltaRect(positionFromPaintInvalidationBacking.x(), | 3909 LayoutRect bottomDeltaRect(positionFromPaintInvalidationBacking.x(), |
3903 positionFromPaintInvalidationBacking.y() + smallerHeight - borderHei
ght, | 3910 positionFromPaintInvalidationBacking.y() + smallerHeight - borderHei
ght, |
3904 std::max(oldBorderBoxSize.width(), newBorderBoxSize.width()), | 3911 std::max(oldBorderBoxSize.width(), newBorderBoxSize.width()), |
3905 deltaHeight + borderHeight); | 3912 deltaHeight + borderHeight); |
3906 invalidatePaintRectClippedByOldAndNewBounds(paintInvalidationContainer,
bottomDeltaRect, oldBounds, newBounds); | 3913 invalidatePaintRectClippedByOldAndNewBounds(paintInvalidationContainer,
bottomDeltaRect, oldBounds, newBounds); |
3907 } | 3914 } |
3908 } | 3915 } |
3909 | 3916 |
3910 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) |
3911 { | 3918 { |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3950 ASSERT(style()->hasVisualOverflowingEffect()); | 3957 ASSERT(style()->hasVisualOverflowingEffect()); |
3951 | 3958 |
3952 LayoutUnit top; | 3959 LayoutUnit top; |
3953 LayoutUnit right; | 3960 LayoutUnit right; |
3954 LayoutUnit bottom; | 3961 LayoutUnit bottom; |
3955 LayoutUnit left; | 3962 LayoutUnit left; |
3956 | 3963 |
3957 if (const ShadowList* boxShadow = style()->boxShadow()) { | 3964 if (const ShadowList* boxShadow = style()->boxShadow()) { |
3958 // FIXME: Use LayoutUnit edge outsets, and then simplify this. | 3965 // FIXME: Use LayoutUnit edge outsets, and then simplify this. |
3959 FloatRectOutsets outsets = boxShadow->rectOutsetsIncludingOriginal(); | 3966 FloatRectOutsets outsets = boxShadow->rectOutsetsIncludingOriginal(); |
3960 top = outsets.top(); | 3967 top = LayoutUnit(outsets.top()); |
3961 right = outsets.right(); | 3968 right = LayoutUnit(outsets.right()); |
3962 bottom = outsets.bottom(); | 3969 bottom = LayoutUnit(outsets.bottom()); |
3963 left = outsets.left(); | 3970 left = LayoutUnit(outsets.left()); |
3964 } | 3971 } |
3965 | 3972 |
3966 if (style()->hasBorderImageOutsets()) { | 3973 if (style()->hasBorderImageOutsets()) { |
3967 LayoutRectOutsets borderOutsets = style()->borderImageOutsets(); | 3974 LayoutRectOutsets borderOutsets = style()->borderImageOutsets(); |
3968 top = std::max(top, borderOutsets.top()); | 3975 top = std::max(top, borderOutsets.top()); |
3969 right = std::max(right, borderOutsets.right()); | 3976 right = std::max(right, borderOutsets.right()); |
3970 bottom = std::max(bottom, borderOutsets.bottom()); | 3977 bottom = std::max(bottom, borderOutsets.bottom()); |
3971 left = std::max(left, borderOutsets.left()); | 3978 left = std::max(left, borderOutsets.left()); |
3972 } | 3979 } |
3973 | 3980 |
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4287 { | 4294 { |
4288 // 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 |
4289 // 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 |
4290 // 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 |
4291 // 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 |
4292 // 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 |
4293 // flipping, this method does the same as clientBoxRect(). | 4300 // flipping, this method does the same as clientBoxRect(). |
4294 | 4301 |
4295 const int scrollBarWidth = verticalScrollbarWidth(); | 4302 const int scrollBarWidth = verticalScrollbarWidth(); |
4296 const int scrollBarHeight = horizontalScrollbarHeight(); | 4303 const int scrollBarHeight = horizontalScrollbarHeight(); |
4297 LayoutUnit left = borderLeft() + (shouldPlaceBlockDirectionScrollbarOnLogica
lLeft() ? scrollBarWidth : 0); | 4304 LayoutUnit left(borderLeft() + (shouldPlaceBlockDirectionScrollbarOnLogicalL
eft() ? scrollBarWidth : 0)); |
4298 LayoutUnit top = borderTop(); | 4305 LayoutUnit top(borderTop()); |
4299 LayoutUnit right = borderRight(); | 4306 LayoutUnit right(borderRight()); |
4300 LayoutUnit bottom = borderBottom(); | 4307 LayoutUnit bottom(borderBottom()); |
4301 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); |
4302 flipForWritingMode(rect); | 4309 flipForWritingMode(rect); |
4303 // 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 |
4304 // 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 |
4305 // 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 |
4306 // 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 |
4307 // 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 |
4308 // related to https://bugs.webkit.org/show_bug.cgi?id=76129 | 4315 // related to https://bugs.webkit.org/show_bug.cgi?id=76129 |
4309 // 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 |
4310 // 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... |
4640 | 4647 |
4641 void LayoutBox::clearPercentHeightDescendants() | 4648 void LayoutBox::clearPercentHeightDescendants() |
4642 { | 4649 { |
4643 for (LayoutObject* curr = slowFirstChild(); curr; curr = curr->nextInPreOrde
r(this)) { | 4650 for (LayoutObject* curr = slowFirstChild(); curr; curr = curr->nextInPreOrde
r(this)) { |
4644 if (curr->isBox()) | 4651 if (curr->isBox()) |
4645 toLayoutBox(curr)->removeFromPercentHeightContainer(); | 4652 toLayoutBox(curr)->removeFromPercentHeightContainer(); |
4646 } | 4653 } |
4647 } | 4654 } |
4648 | 4655 |
4649 } // namespace blink | 4656 } // namespace blink |
OLD | NEW |