| 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 24 matching lines...) Expand all Loading... |
| 35 #include "core/html/HTMLFrameElementBase.h" | 35 #include "core/html/HTMLFrameElementBase.h" |
| 36 #include "core/html/HTMLFrameOwnerElement.h" | 36 #include "core/html/HTMLFrameOwnerElement.h" |
| 37 #include "core/frame/Frame.h" | 37 #include "core/frame/Frame.h" |
| 38 #include "core/frame/FrameView.h" | 38 #include "core/frame/FrameView.h" |
| 39 #include "core/page/AutoscrollController.h" | 39 #include "core/page/AutoscrollController.h" |
| 40 #include "core/page/EventHandler.h" | 40 #include "core/page/EventHandler.h" |
| 41 #include "core/page/Page.h" | 41 #include "core/page/Page.h" |
| 42 #include "core/rendering/HitTestResult.h" | 42 #include "core/rendering/HitTestResult.h" |
| 43 #include "core/rendering/LayoutRectRecorder.h" | 43 #include "core/rendering/LayoutRectRecorder.h" |
| 44 #include "core/rendering/PaintInfo.h" | 44 #include "core/rendering/PaintInfo.h" |
| 45 #include "core/rendering/RenderBoxRegionInfo.h" | |
| 46 #include "core/rendering/RenderDeprecatedFlexibleBox.h" | 45 #include "core/rendering/RenderDeprecatedFlexibleBox.h" |
| 47 #include "core/rendering/RenderFlexibleBox.h" | 46 #include "core/rendering/RenderFlexibleBox.h" |
| 48 #include "core/rendering/RenderFlowThread.h" | |
| 49 #include "core/rendering/RenderGeometryMap.h" | 47 #include "core/rendering/RenderGeometryMap.h" |
| 50 #include "core/rendering/RenderGrid.h" | 48 #include "core/rendering/RenderGrid.h" |
| 51 #include "core/rendering/RenderInline.h" | 49 #include "core/rendering/RenderInline.h" |
| 52 #include "core/rendering/RenderLayer.h" | 50 #include "core/rendering/RenderLayer.h" |
| 53 #include "core/rendering/RenderLayerCompositor.h" | 51 #include "core/rendering/RenderLayerCompositor.h" |
| 54 #include "core/rendering/RenderListMarker.h" | 52 #include "core/rendering/RenderListMarker.h" |
| 55 #include "core/rendering/RenderRegion.h" | |
| 56 #include "core/rendering/RenderTableCell.h" | 53 #include "core/rendering/RenderTableCell.h" |
| 57 #include "core/rendering/RenderTheme.h" | 54 #include "core/rendering/RenderTheme.h" |
| 58 #include "core/rendering/RenderView.h" | 55 #include "core/rendering/RenderView.h" |
| 59 #include "platform/LengthFunctions.h" | 56 #include "platform/LengthFunctions.h" |
| 60 #include "platform/geometry/FloatQuad.h" | 57 #include "platform/geometry/FloatQuad.h" |
| 61 #include "platform/geometry/TransformState.h" | 58 #include "platform/geometry/TransformState.h" |
| 62 #include "platform/graphics/GraphicsContextStateSaver.h" | 59 #include "platform/graphics/GraphicsContextStateSaver.h" |
| 63 | 60 |
| 64 using namespace std; | 61 using namespace std; |
| 65 | 62 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 94 | 91 |
| 95 RenderBox::RenderBox(ContainerNode* node) | 92 RenderBox::RenderBox(ContainerNode* node) |
| 96 : RenderBoxModelObject(node) | 93 : RenderBoxModelObject(node) |
| 97 , m_intrinsicContentLogicalHeight(-1) | 94 , m_intrinsicContentLogicalHeight(-1) |
| 98 , m_minPreferredLogicalWidth(-1) | 95 , m_minPreferredLogicalWidth(-1) |
| 99 , m_maxPreferredLogicalWidth(-1) | 96 , m_maxPreferredLogicalWidth(-1) |
| 100 { | 97 { |
| 101 setIsBox(); | 98 setIsBox(); |
| 102 } | 99 } |
| 103 | 100 |
| 104 RenderBox::~RenderBox() | |
| 105 { | |
| 106 } | |
| 107 | |
| 108 LayoutRect RenderBox::borderBoxRectInRegion(RenderRegion* region, RenderBoxRegio
nInfoFlags cacheFlag) const | |
| 109 { | |
| 110 if (!region) | |
| 111 return borderBoxRect(); | |
| 112 | |
| 113 // Compute the logical width and placement in this region. | |
| 114 RenderBoxRegionInfo* boxInfo = renderBoxRegionInfo(region, cacheFlag); | |
| 115 if (!boxInfo) | |
| 116 return borderBoxRect(); | |
| 117 | |
| 118 // We have cached insets. | |
| 119 LayoutUnit logicalWidth = boxInfo->logicalWidth(); | |
| 120 LayoutUnit logicalLeft = boxInfo->logicalLeft(); | |
| 121 | |
| 122 // Now apply the parent inset since it is cumulative whenever anything in th
e containing block chain shifts. | |
| 123 // FIXME: Doesn't work right with perpendicular writing modes. | |
| 124 const RenderBlock* currentBox = containingBlock(); | |
| 125 RenderBoxRegionInfo* currentBoxInfo = currentBox->renderBoxRegionInfo(region
); | |
| 126 while (currentBoxInfo && currentBoxInfo->isShifted()) { | |
| 127 if (currentBox->style()->direction() == LTR) | |
| 128 logicalLeft += currentBoxInfo->logicalLeft(); | |
| 129 else | |
| 130 logicalLeft -= (currentBox->logicalWidth() - currentBoxInfo->logical
Width()) - currentBoxInfo->logicalLeft(); | |
| 131 currentBox = currentBox->containingBlock(); | |
| 132 region = currentBox->clampToStartAndEndRegions(region); | |
| 133 currentBoxInfo = currentBox->renderBoxRegionInfo(region); | |
| 134 } | |
| 135 | |
| 136 if (cacheFlag == DoNotCacheRenderBoxRegionInfo) | |
| 137 delete boxInfo; | |
| 138 | |
| 139 if (isHorizontalWritingMode()) | |
| 140 return LayoutRect(logicalLeft, 0, logicalWidth, height()); | |
| 141 return LayoutRect(0, logicalLeft, width(), logicalWidth); | |
| 142 } | |
| 143 | |
| 144 void RenderBox::clearRenderBoxRegionInfo() | |
| 145 { | |
| 146 if (isRenderFlowThread()) | |
| 147 return; | |
| 148 | |
| 149 RenderFlowThread* flowThread = flowThreadContainingBlock(); | |
| 150 if (flowThread) | |
| 151 flowThread->removeRenderBoxRegionInfo(this); | |
| 152 } | |
| 153 | |
| 154 void RenderBox::willBeDestroyed() | 101 void RenderBox::willBeDestroyed() |
| 155 { | 102 { |
| 156 clearOverrideSize(); | 103 clearOverrideSize(); |
| 157 clearContainingBlockOverrideSize(); | 104 clearContainingBlockOverrideSize(); |
| 158 | 105 |
| 159 RenderBlock::removePercentHeightDescendantIfNeeded(this); | 106 RenderBlock::removePercentHeightDescendantIfNeeded(this); |
| 160 | 107 |
| 161 ShapeOutsideInfo::removeInfo(this); | 108 ShapeOutsideInfo::removeInfo(this); |
| 162 | 109 |
| 163 RenderBoxModelObject::willBeDestroyed(); | 110 RenderBoxModelObject::willBeDestroyed(); |
| (...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 585 quads.append(localToAbsoluteQuad(FloatRect(0, 0, width(), height()), 0 /* mo
de */, wasFixed)); | 532 quads.append(localToAbsoluteQuad(FloatRect(0, 0, width(), height()), 0 /* mo
de */, wasFixed)); |
| 586 } | 533 } |
| 587 | 534 |
| 588 void RenderBox::updateLayerTransform() | 535 void RenderBox::updateLayerTransform() |
| 589 { | 536 { |
| 590 // Transform-origin depends on box size, so we need to update the layer tran
sform after layout. | 537 // Transform-origin depends on box size, so we need to update the layer tran
sform after layout. |
| 591 if (hasLayer()) | 538 if (hasLayer()) |
| 592 layer()->updateTransform(); | 539 layer()->updateTransform(); |
| 593 } | 540 } |
| 594 | 541 |
| 595 LayoutUnit RenderBox::constrainLogicalWidthInRegionByMinMax(LayoutUnit logicalWi
dth, LayoutUnit availableWidth, RenderBlock* cb, RenderRegion* region) const | 542 LayoutUnit RenderBox::constrainLogicalWidthByMinMax(LayoutUnit logicalWidth, Lay
outUnit availableWidth, RenderBlock* cb) const |
| 596 { | 543 { |
| 597 RenderStyle* styleToUse = style(); | 544 RenderStyle* styleToUse = style(); |
| 598 if (!styleToUse->logicalMaxWidth().isUndefined()) | 545 if (!styleToUse->logicalMaxWidth().isUndefined()) |
| 599 logicalWidth = min(logicalWidth, computeLogicalWidthInRegionUsing(MaxSiz
e, styleToUse->logicalMaxWidth(), availableWidth, cb, region)); | 546 logicalWidth = min(logicalWidth, computeLogicalWidthUsing(MaxSize, style
ToUse->logicalMaxWidth(), availableWidth, cb)); |
| 600 return max(logicalWidth, computeLogicalWidthInRegionUsing(MinSize, styleToUs
e->logicalMinWidth(), availableWidth, cb, region)); | 547 return max(logicalWidth, computeLogicalWidthUsing(MinSize, styleToUse->logic
alMinWidth(), availableWidth, cb)); |
| 601 } | 548 } |
| 602 | 549 |
| 603 LayoutUnit RenderBox::constrainLogicalHeightByMinMax(LayoutUnit logicalHeight, L
ayoutUnit intrinsicContentHeight) const | 550 LayoutUnit RenderBox::constrainLogicalHeightByMinMax(LayoutUnit logicalHeight, L
ayoutUnit intrinsicContentHeight) const |
| 604 { | 551 { |
| 605 RenderStyle* styleToUse = style(); | 552 RenderStyle* styleToUse = style(); |
| 606 if (!styleToUse->logicalMaxHeight().isUndefined()) { | 553 if (!styleToUse->logicalMaxHeight().isUndefined()) { |
| 607 LayoutUnit maxH = computeLogicalHeightUsing(styleToUse->logicalMaxHeight
(), intrinsicContentHeight); | 554 LayoutUnit maxH = computeLogicalHeightUsing(styleToUse->logicalMaxHeight
(), intrinsicContentHeight); |
| 608 if (maxH != -1) | 555 if (maxH != -1) |
| 609 logicalHeight = min(logicalHeight, maxH); | 556 logicalHeight = min(logicalHeight, maxH); |
| 610 } | 557 } |
| (...skipping 560 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1171 // Check kids first. | 1118 // Check kids first. |
| 1172 for (RenderObject* child = lastChild(); child; child = child->previousSiblin
g()) { | 1119 for (RenderObject* child = lastChild(); child; child = child->previousSiblin
g()) { |
| 1173 if (!child->hasLayer() && child->nodeAtPoint(request, result, locationIn
Container, adjustedLocation, action)) { | 1120 if (!child->hasLayer() && child->nodeAtPoint(request, result, locationIn
Container, adjustedLocation, action)) { |
| 1174 updateHitTestResult(result, locationInContainer.point() - toLayoutSi
ze(adjustedLocation)); | 1121 updateHitTestResult(result, locationInContainer.point() - toLayoutSi
ze(adjustedLocation)); |
| 1175 return true; | 1122 return true; |
| 1176 } | 1123 } |
| 1177 } | 1124 } |
| 1178 | 1125 |
| 1179 // Check our bounds next. For this purpose always assume that we can only be
hit in the | 1126 // Check our bounds next. For this purpose always assume that we can only be
hit in the |
| 1180 // foreground phase (which is true for replaced elements like images). | 1127 // foreground phase (which is true for replaced elements like images). |
| 1181 LayoutRect boundsRect = borderBoxRectInRegion(locationInContainer.region()); | 1128 LayoutRect boundsRect = borderBoxRect(); |
| 1182 boundsRect.moveBy(adjustedLocation); | 1129 boundsRect.moveBy(adjustedLocation); |
| 1183 if (visibleToHitTestRequest(request) && action == HitTestForeground && locat
ionInContainer.intersects(boundsRect)) { | 1130 if (visibleToHitTestRequest(request) && action == HitTestForeground && locat
ionInContainer.intersects(boundsRect)) { |
| 1184 updateHitTestResult(result, locationInContainer.point() - toLayoutSize(a
djustedLocation)); | 1131 updateHitTestResult(result, locationInContainer.point() - toLayoutSize(a
djustedLocation)); |
| 1185 if (!result.addNodeToRectBasedTestResult(node(), request, locationInCont
ainer, boundsRect)) | 1132 if (!result.addNodeToRectBasedTestResult(node(), request, locationInCont
ainer, boundsRect)) |
| 1186 return true; | 1133 return true; |
| 1187 } | 1134 } |
| 1188 | 1135 |
| 1189 return false; | 1136 return false; |
| 1190 } | 1137 } |
| 1191 | 1138 |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1247 return BackgroundBleedBackgroundOverBorder; | 1194 return BackgroundBleedBackgroundOverBorder; |
| 1248 | 1195 |
| 1249 return BackgroundBleedUseTransparencyLayer; | 1196 return BackgroundBleedUseTransparencyLayer; |
| 1250 } | 1197 } |
| 1251 | 1198 |
| 1252 void RenderBox::paintBoxDecorations(PaintInfo& paintInfo, const LayoutPoint& pai
ntOffset) | 1199 void RenderBox::paintBoxDecorations(PaintInfo& paintInfo, const LayoutPoint& pai
ntOffset) |
| 1253 { | 1200 { |
| 1254 if (!paintInfo.shouldPaintWithinRoot(this)) | 1201 if (!paintInfo.shouldPaintWithinRoot(this)) |
| 1255 return; | 1202 return; |
| 1256 | 1203 |
| 1257 LayoutRect paintRect = borderBoxRectInRegion(paintInfo.renderRegion); | 1204 LayoutRect paintRect = borderBoxRect(); |
| 1258 paintRect.moveBy(paintOffset); | 1205 paintRect.moveBy(paintOffset); |
| 1259 paintBoxDecorationsWithRect(paintInfo, paintOffset, paintRect); | 1206 paintBoxDecorationsWithRect(paintInfo, paintOffset, paintRect); |
| 1260 } | 1207 } |
| 1261 | 1208 |
| 1262 void RenderBox::paintBoxDecorationsWithRect(PaintInfo& paintInfo, const LayoutPo
int& paintOffset, const LayoutRect& paintRect) | 1209 void RenderBox::paintBoxDecorationsWithRect(PaintInfo& paintInfo, const LayoutPo
int& paintOffset, const LayoutRect& paintRect) |
| 1263 { | 1210 { |
| 1264 BackgroundBleedAvoidance bleedAvoidance = determineBackgroundBleedAvoidance(
paintInfo.context); | 1211 BackgroundBleedAvoidance bleedAvoidance = determineBackgroundBleedAvoidance(
paintInfo.context); |
| 1265 | 1212 |
| 1266 // FIXME: Should eventually give the theme control over whether the box shad
ow should paint, since controls could have | 1213 // FIXME: Should eventually give the theme control over whether the box shad
ow should paint, since controls could have |
| 1267 // custom shadows of their own. | 1214 // custom shadows of their own. |
| (...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1676 { | 1623 { |
| 1677 if (paintInfo.phase == PaintPhaseBlockBackground || paintInfo.phase == Paint
PhaseSelfOutline || paintInfo.phase == PaintPhaseMask) | 1624 if (paintInfo.phase == PaintPhaseBlockBackground || paintInfo.phase == Paint
PhaseSelfOutline || paintInfo.phase == PaintPhaseMask) |
| 1678 return false; | 1625 return false; |
| 1679 | 1626 |
| 1680 bool isControlClip = hasControlClip(); | 1627 bool isControlClip = hasControlClip(); |
| 1681 bool isOverflowClip = hasOverflowClip() && !layer()->isSelfPaintingLayer(); | 1628 bool isOverflowClip = hasOverflowClip() && !layer()->isSelfPaintingLayer(); |
| 1682 | 1629 |
| 1683 if (!isControlClip && !isOverflowClip) | 1630 if (!isControlClip && !isOverflowClip) |
| 1684 return false; | 1631 return false; |
| 1685 | 1632 |
| 1686 LayoutRect clipRect = isControlClip ? controlClipRect(accumulatedOffset) : o
verflowClipRect(accumulatedOffset, paintInfo.renderRegion); | 1633 LayoutRect clipRect = isControlClip ? controlClipRect(accumulatedOffset) : o
verflowClipRect(accumulatedOffset); |
| 1687 RoundedRect clipRoundedRect(0, 0, 0, 0); | 1634 RoundedRect clipRoundedRect(0, 0, 0, 0); |
| 1688 bool hasBorderRadius = style()->hasBorderRadius(); | 1635 bool hasBorderRadius = style()->hasBorderRadius(); |
| 1689 if (hasBorderRadius) | 1636 if (hasBorderRadius) |
| 1690 clipRoundedRect = style()->getRoundedInnerBorderFor(LayoutRect(accumulat
edOffset, size())); | 1637 clipRoundedRect = style()->getRoundedInnerBorderFor(LayoutRect(accumulat
edOffset, size())); |
| 1691 | 1638 |
| 1692 if (contentsClipBehavior == SkipContentsClipIfPossible) { | 1639 if (contentsClipBehavior == SkipContentsClipIfPossible) { |
| 1693 LayoutRect contentsVisualOverflow = contentsVisualOverflowRect(); | 1640 LayoutRect contentsVisualOverflow = contentsVisualOverflowRect(); |
| 1694 if (contentsVisualOverflow.isEmpty()) | 1641 if (contentsVisualOverflow.isEmpty()) |
| 1695 return false; | 1642 return false; |
| 1696 | 1643 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1729 | 1676 |
| 1730 paintInfo.context->restore(); | 1677 paintInfo.context->restore(); |
| 1731 if (originalPhase == PaintPhaseOutline) { | 1678 if (originalPhase == PaintPhaseOutline) { |
| 1732 paintInfo.phase = PaintPhaseSelfOutline; | 1679 paintInfo.phase = PaintPhaseSelfOutline; |
| 1733 paintObject(paintInfo, accumulatedOffset); | 1680 paintObject(paintInfo, accumulatedOffset); |
| 1734 paintInfo.phase = originalPhase; | 1681 paintInfo.phase = originalPhase; |
| 1735 } else if (originalPhase == PaintPhaseChildBlockBackground) | 1682 } else if (originalPhase == PaintPhaseChildBlockBackground) |
| 1736 paintInfo.phase = originalPhase; | 1683 paintInfo.phase = originalPhase; |
| 1737 } | 1684 } |
| 1738 | 1685 |
| 1739 LayoutRect RenderBox::overflowClipRect(const LayoutPoint& location, RenderRegion
* region, OverlayScrollbarSizeRelevancy relevancy) | 1686 LayoutRect RenderBox::overflowClipRect(const LayoutPoint& location, OverlayScrol
lbarSizeRelevancy relevancy) |
| 1740 { | 1687 { |
| 1741 // FIXME: When overflow-clip (CSS3) is implemented, we'll obtain the propert
y | 1688 // FIXME: When overflow-clip (CSS3) is implemented, we'll obtain the propert
y |
| 1742 // here. | 1689 // here. |
| 1743 LayoutRect clipRect = borderBoxRectInRegion(region); | 1690 LayoutRect clipRect = borderBoxRect(); |
| 1744 clipRect.setLocation(location + clipRect.location() + LayoutSize(borderLeft(
), borderTop())); | 1691 clipRect.setLocation(location + clipRect.location() + LayoutSize(borderLeft(
), borderTop())); |
| 1745 clipRect.setSize(clipRect.size() - LayoutSize(borderLeft() + borderRight(),
borderTop() + borderBottom())); | 1692 clipRect.setSize(clipRect.size() - LayoutSize(borderLeft() + borderRight(),
borderTop() + borderBottom())); |
| 1746 | 1693 |
| 1747 if (!hasOverflowClip()) | 1694 if (!hasOverflowClip()) |
| 1748 return clipRect; | 1695 return clipRect; |
| 1749 | 1696 |
| 1750 // Subtract out scrollbars if we have them. | 1697 // Subtract out scrollbars if we have them. |
| 1751 if (style()->shouldPlaceBlockDirectionScrollbarOnLogicalLeft()) | 1698 if (style()->shouldPlaceBlockDirectionScrollbarOnLogicalLeft()) |
| 1752 clipRect.move(layer()->scrollableArea()->verticalScrollbarWidth(relevanc
y), 0); | 1699 clipRect.move(layer()->scrollableArea()->verticalScrollbarWidth(relevanc
y), 0); |
| 1753 clipRect.contract(layer()->scrollableArea()->verticalScrollbarWidth(relevanc
y), layer()->scrollableArea()->horizontalScrollbarHeight(relevancy)); | 1700 clipRect.contract(layer()->scrollableArea()->verticalScrollbarWidth(relevanc
y), layer()->scrollableArea()->horizontalScrollbarHeight(relevancy)); |
| 1754 | 1701 |
| 1755 return clipRect; | 1702 return clipRect; |
| 1756 } | 1703 } |
| 1757 | 1704 |
| 1758 LayoutRect RenderBox::clipRect(const LayoutPoint& location, RenderRegion* region
) | 1705 LayoutRect RenderBox::clipRect(const LayoutPoint& location) |
| 1759 { | 1706 { |
| 1760 LayoutRect borderBoxRect = borderBoxRectInRegion(region); | 1707 LayoutRect borderBoxRect = this->borderBoxRect(); |
| 1761 LayoutRect clipRect = LayoutRect(borderBoxRect.location() + location, border
BoxRect.size()); | 1708 LayoutRect clipRect = LayoutRect(borderBoxRect.location() + location, border
BoxRect.size()); |
| 1762 | 1709 |
| 1763 if (!style()->clipLeft().isAuto()) { | 1710 if (!style()->clipLeft().isAuto()) { |
| 1764 LayoutUnit c = valueForLength(style()->clipLeft(), borderBoxRect.width()
); | 1711 LayoutUnit c = valueForLength(style()->clipLeft(), borderBoxRect.width()
); |
| 1765 clipRect.move(c, 0); | 1712 clipRect.move(c, 0); |
| 1766 clipRect.contract(c, 0); | 1713 clipRect.contract(c, 0); |
| 1767 } | 1714 } |
| 1768 | 1715 |
| 1769 // We don't use the region-specific border box's width and height since clip
offsets are (stupidly) specified | |
| 1770 // from the left and top edges. Therefore it's better to avoid constraining
to smaller widths and heights. | |
| 1771 | |
| 1772 if (!style()->clipRight().isAuto()) | 1716 if (!style()->clipRight().isAuto()) |
| 1773 clipRect.contract(width() - valueForLength(style()->clipRight(), width()
), 0); | 1717 clipRect.contract(width() - valueForLength(style()->clipRight(), width()
), 0); |
| 1774 | 1718 |
| 1775 if (!style()->clipTop().isAuto()) { | 1719 if (!style()->clipTop().isAuto()) { |
| 1776 LayoutUnit c = valueForLength(style()->clipTop(), borderBoxRect.height()
); | 1720 LayoutUnit c = valueForLength(style()->clipTop(), borderBoxRect.height()
); |
| 1777 clipRect.move(0, c); | 1721 clipRect.move(0, c); |
| 1778 clipRect.contract(0, c); | 1722 clipRect.contract(0, c); |
| 1779 } | 1723 } |
| 1780 | 1724 |
| 1781 if (!style()->clipBottom().isAuto()) | 1725 if (!style()->clipBottom().isAuto()) |
| 1782 clipRect.contract(0, height() - valueForLength(style()->clipBottom(), he
ight())); | 1726 clipRect.contract(0, height() - valueForLength(style()->clipBottom(), he
ight())); |
| 1783 | 1727 |
| 1784 return clipRect; | 1728 return clipRect; |
| 1785 } | 1729 } |
| 1786 | 1730 |
| 1787 LayoutUnit RenderBox::shrinkLogicalWidthToAvoidFloats(LayoutUnit childMarginStar
t, LayoutUnit childMarginEnd, const RenderBlockFlow* cb, RenderRegion* region) c
onst | 1731 LayoutUnit RenderBox::shrinkLogicalWidthToAvoidFloats(LayoutUnit childMarginStar
t, LayoutUnit childMarginEnd, const RenderBlockFlow* cb) const |
| 1788 { | 1732 { |
| 1789 RenderRegion* containingBlockRegion = 0; | |
| 1790 LayoutUnit logicalTopPosition = logicalTop(); | 1733 LayoutUnit logicalTopPosition = logicalTop(); |
| 1791 if (region) { | 1734 LayoutUnit result = cb->availableLogicalWidthForLine(logicalTopPosition, fal
se) - childMarginStart - childMarginEnd; |
| 1792 LayoutUnit offsetFromLogicalTopOfRegion = region ? region->logicalTopFor
FlowThreadContent() - offsetFromLogicalTopOfFirstPage() : LayoutUnit(); | |
| 1793 logicalTopPosition = max(logicalTopPosition, logicalTopPosition + offset
FromLogicalTopOfRegion); | |
| 1794 containingBlockRegion = cb->clampToStartAndEndRegions(region); | |
| 1795 } | |
| 1796 | |
| 1797 LayoutUnit result = cb->availableLogicalWidthForLineInRegion(logicalTopPosit
ion, false, containingBlockRegion) - childMarginStart - childMarginEnd; | |
| 1798 | 1735 |
| 1799 // We need to see if margins on either the start side or the end side can co
ntain the floats in question. If they can, | 1736 // We need to see if margins on either the start side or the end side can co
ntain the floats in question. If they can, |
| 1800 // then just using the line width is inaccurate. In the case where a float c
ompletely fits, we don't need to use the line | 1737 // then just using the line width is inaccurate. In the case where a float c
ompletely fits, we don't need to use the line |
| 1801 // offset at all, but can instead push all the way to the content edge of th
e containing block. In the case where the float | 1738 // offset at all, but can instead push all the way to the content edge of th
e containing block. In the case where the float |
| 1802 // doesn't fit, we can use the line offset, but we need to grow it by the ma
rgin to reflect the fact that the margin was | 1739 // doesn't fit, we can use the line offset, but we need to grow it by the ma
rgin to reflect the fact that the margin was |
| 1803 // "consumed" by the float. Negative margins aren't consumed by the float, a
nd so we ignore them. | 1740 // "consumed" by the float. Negative margins aren't consumed by the float, a
nd so we ignore them. |
| 1804 if (childMarginStart > 0) { | 1741 if (childMarginStart > 0) { |
| 1805 LayoutUnit startContentSide = cb->startOffsetForContent(containingBlockR
egion); | 1742 LayoutUnit startContentSide = cb->startOffsetForContent(); |
| 1806 LayoutUnit startContentSideWithMargin = startContentSide + childMarginSt
art; | 1743 LayoutUnit startContentSideWithMargin = startContentSide + childMarginSt
art; |
| 1807 LayoutUnit startOffset = cb->startOffsetForLineInRegion(logicalTopPositi
on, false, containingBlockRegion); | 1744 LayoutUnit startOffset = cb->startOffsetForLine(logicalTopPosition, fals
e); |
| 1808 if (startOffset > startContentSideWithMargin) | 1745 if (startOffset > startContentSideWithMargin) |
| 1809 result += childMarginStart; | 1746 result += childMarginStart; |
| 1810 else | 1747 else |
| 1811 result += startOffset - startContentSide; | 1748 result += startOffset - startContentSide; |
| 1812 } | 1749 } |
| 1813 | 1750 |
| 1814 if (childMarginEnd > 0) { | 1751 if (childMarginEnd > 0) { |
| 1815 LayoutUnit endContentSide = cb->endOffsetForContent(containingBlockRegio
n); | 1752 LayoutUnit endContentSide = cb->endOffsetForContent(); |
| 1816 LayoutUnit endContentSideWithMargin = endContentSide + childMarginEnd; | 1753 LayoutUnit endContentSideWithMargin = endContentSide + childMarginEnd; |
| 1817 LayoutUnit endOffset = cb->endOffsetForLineInRegion(logicalTopPosition,
false, containingBlockRegion); | 1754 LayoutUnit endOffset = cb->endOffsetForLine(logicalTopPosition, false); |
| 1818 if (endOffset > endContentSideWithMargin) | 1755 if (endOffset > endContentSideWithMargin) |
| 1819 result += childMarginEnd; | 1756 result += childMarginEnd; |
| 1820 else | 1757 else |
| 1821 result += endOffset - endContentSide; | 1758 result += endOffset - endContentSide; |
| 1822 } | 1759 } |
| 1823 | 1760 |
| 1824 return result; | 1761 return result; |
| 1825 } | 1762 } |
| 1826 | 1763 |
| 1827 LayoutUnit RenderBox::containingBlockLogicalWidthForContent() const | 1764 LayoutUnit RenderBox::containingBlockLogicalWidthForContent() const |
| 1828 { | 1765 { |
| 1829 if (hasOverrideContainingBlockLogicalWidth()) | 1766 if (hasOverrideContainingBlockLogicalWidth()) |
| 1830 return overrideContainingBlockContentLogicalWidth(); | 1767 return overrideContainingBlockContentLogicalWidth(); |
| 1831 | 1768 |
| 1832 RenderBlock* cb = containingBlock(); | 1769 RenderBlock* cb = containingBlock(); |
| 1833 return cb->availableLogicalWidth(); | 1770 return cb->availableLogicalWidth(); |
| 1834 } | 1771 } |
| 1835 | 1772 |
| 1836 LayoutUnit RenderBox::containingBlockLogicalHeightForContent(AvailableLogicalHei
ghtType heightType) const | 1773 LayoutUnit RenderBox::containingBlockLogicalHeightForContent(AvailableLogicalHei
ghtType heightType) const |
| 1837 { | 1774 { |
| 1838 if (hasOverrideContainingBlockLogicalHeight()) | 1775 if (hasOverrideContainingBlockLogicalHeight()) |
| 1839 return overrideContainingBlockContentLogicalHeight(); | 1776 return overrideContainingBlockContentLogicalHeight(); |
| 1840 | 1777 |
| 1841 RenderBlock* cb = containingBlock(); | 1778 RenderBlock* cb = containingBlock(); |
| 1842 return cb->availableLogicalHeight(heightType); | 1779 return cb->availableLogicalHeight(heightType); |
| 1843 } | 1780 } |
| 1844 | 1781 |
| 1845 LayoutUnit RenderBox::containingBlockLogicalWidthForContentInRegion(RenderRegion
* region) const | 1782 LayoutUnit RenderBox::containingBlockAvailableLineWidth() const |
| 1846 { | |
| 1847 if (!region) | |
| 1848 return containingBlockLogicalWidthForContent(); | |
| 1849 | |
| 1850 RenderBlock* cb = containingBlock(); | |
| 1851 RenderRegion* containingBlockRegion = cb->clampToStartAndEndRegions(region); | |
| 1852 // FIXME: It's unclear if a region's content should use the containing block
's override logical width. | |
| 1853 // If it should, the following line should call containingBlockLogicalWidthF
orContent. | |
| 1854 LayoutUnit result = cb->availableLogicalWidth(); | |
| 1855 RenderBoxRegionInfo* boxInfo = cb->renderBoxRegionInfo(containingBlockRegion
); | |
| 1856 if (!boxInfo) | |
| 1857 return result; | |
| 1858 return max<LayoutUnit>(0, result - (cb->logicalWidth() - boxInfo->logicalWid
th())); | |
| 1859 } | |
| 1860 | |
| 1861 LayoutUnit RenderBox::containingBlockAvailableLineWidthInRegion(RenderRegion* re
gion) const | |
| 1862 { | 1783 { |
| 1863 RenderBlock* cb = containingBlock(); | 1784 RenderBlock* cb = containingBlock(); |
| 1864 RenderRegion* containingBlockRegion = 0; | |
| 1865 LayoutUnit logicalTopPosition = logicalTop(); | |
| 1866 if (region) { | |
| 1867 LayoutUnit offsetFromLogicalTopOfRegion = region ? region->logicalTopFor
FlowThreadContent() - offsetFromLogicalTopOfFirstPage() : LayoutUnit(); | |
| 1868 logicalTopPosition = max(logicalTopPosition, logicalTopPosition + offset
FromLogicalTopOfRegion); | |
| 1869 containingBlockRegion = cb->clampToStartAndEndRegions(region); | |
| 1870 } | |
| 1871 if (cb->isRenderBlockFlow()) | 1785 if (cb->isRenderBlockFlow()) |
| 1872 return toRenderBlockFlow(cb)->availableLogicalWidthForLineInRegion(logic
alTopPosition, false, containingBlockRegion, availableLogicalHeight(IncludeMargi
nBorderPadding)); | 1786 return toRenderBlockFlow(cb)->availableLogicalWidthForLine(logicalTop(),
false, availableLogicalHeight(IncludeMarginBorderPadding)); |
| 1873 return 0; | 1787 return 0; |
| 1874 } | 1788 } |
| 1875 | 1789 |
| 1876 LayoutUnit RenderBox::perpendicularContainingBlockLogicalHeight() const | 1790 LayoutUnit RenderBox::perpendicularContainingBlockLogicalHeight() const |
| 1877 { | 1791 { |
| 1878 if (hasOverrideContainingBlockLogicalHeight()) | 1792 if (hasOverrideContainingBlockLogicalHeight()) |
| 1879 return overrideContainingBlockContentLogicalHeight(); | 1793 return overrideContainingBlockContentLogicalHeight(); |
| 1880 | 1794 |
| 1881 RenderBlock* cb = containingBlock(); | 1795 RenderBlock* cb = containingBlock(); |
| 1882 if (cb->hasOverrideHeight()) | 1796 if (cb->hasOverrideHeight()) |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1964 // and may itself also be fixed position. So propagate 'fixed' up only i
f this box is fixed position. | 1878 // and may itself also be fixed position. So propagate 'fixed' up only i
f this box is fixed position. |
| 1965 mode &= ~IsFixed; | 1879 mode &= ~IsFixed; |
| 1966 } else if (isFixedPos) | 1880 } else if (isFixedPos) |
| 1967 mode |= IsFixed; | 1881 mode |= IsFixed; |
| 1968 | 1882 |
| 1969 RenderBoxModelObject::mapAbsoluteToLocalPoint(mode, transformState); | 1883 RenderBoxModelObject::mapAbsoluteToLocalPoint(mode, transformState); |
| 1970 } | 1884 } |
| 1971 | 1885 |
| 1972 LayoutSize RenderBox::offsetFromContainer(RenderObject* o, const LayoutPoint& po
int, bool* offsetDependsOnPoint) const | 1886 LayoutSize RenderBox::offsetFromContainer(RenderObject* o, const LayoutPoint& po
int, bool* offsetDependsOnPoint) const |
| 1973 { | 1887 { |
| 1974 // A region "has" boxes inside it without being their container. | 1888 ASSERT(o == container()); |
| 1975 // FIXME: change container() / containingBlock() to count for boxes being po
sitioned relative to the region, not the | |
| 1976 // FlowThread. This requires a separate patch as a simple test with such a c
hange in container() causes 129 out of | |
| 1977 // 337 regions tests to fail. | |
| 1978 ASSERT(o == container() || o->isRenderRegion()); | |
| 1979 | 1889 |
| 1980 LayoutSize offset; | 1890 LayoutSize offset; |
| 1981 if (isInFlowPositioned()) | 1891 if (isInFlowPositioned()) |
| 1982 offset += offsetForInFlowPosition(); | 1892 offset += offsetForInFlowPosition(); |
| 1983 | 1893 |
| 1984 if (!isInline() || isReplaced()) { | 1894 if (!isInline() || isReplaced()) { |
| 1985 if (!style()->hasOutOfFlowPosition() && o->hasColumns()) { | 1895 if (!style()->hasOutOfFlowPosition() && o->hasColumns()) { |
| 1986 RenderBlock* block = toRenderBlock(o); | 1896 RenderBlock* block = toRenderBlock(o); |
| 1987 LayoutRect columnRect(frameRect()); | 1897 LayoutRect columnRect(frameRect()); |
| 1988 block->adjustStartEdgeForWritingModeIncludingColumns(columnRect); | 1898 block->adjustStartEdgeForWritingModeIncludingColumns(columnRect); |
| (...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2213 } | 2123 } |
| 2214 } | 2124 } |
| 2215 | 2125 |
| 2216 void RenderBox::repaintOverhangingFloats(bool) | 2126 void RenderBox::repaintOverhangingFloats(bool) |
| 2217 { | 2127 { |
| 2218 } | 2128 } |
| 2219 | 2129 |
| 2220 void RenderBox::updateLogicalWidth() | 2130 void RenderBox::updateLogicalWidth() |
| 2221 { | 2131 { |
| 2222 LogicalExtentComputedValues computedValues; | 2132 LogicalExtentComputedValues computedValues; |
| 2223 computeLogicalWidthInRegion(computedValues); | 2133 computeLogicalWidth(computedValues); |
| 2224 | 2134 |
| 2225 setLogicalWidth(computedValues.m_extent); | 2135 setLogicalWidth(computedValues.m_extent); |
| 2226 setLogicalLeft(computedValues.m_position); | 2136 setLogicalLeft(computedValues.m_position); |
| 2227 setMarginStart(computedValues.m_margins.m_start); | 2137 setMarginStart(computedValues.m_margins.m_start); |
| 2228 setMarginEnd(computedValues.m_margins.m_end); | 2138 setMarginEnd(computedValues.m_margins.m_end); |
| 2229 } | 2139 } |
| 2230 | 2140 |
| 2231 static float getMaxWidthListMarker(const RenderBox* renderer) | 2141 static float getMaxWidthListMarker(const RenderBox* renderer) |
| 2232 { | 2142 { |
| 2233 #ifndef NDEBUG | 2143 #ifndef NDEBUG |
| (...skipping 19 matching lines...) Expand all Loading... |
| 2253 // Make sure to compute the autosized width. | 2163 // Make sure to compute the autosized width. |
| 2254 itemMarker->layout(); | 2164 itemMarker->layout(); |
| 2255 } | 2165 } |
| 2256 maxWidth = max<float>(maxWidth, toRenderListMarker(itemMarker)->logi
calWidth().toFloat()); | 2166 maxWidth = max<float>(maxWidth, toRenderListMarker(itemMarker)->logi
calWidth().toFloat()); |
| 2257 break; | 2167 break; |
| 2258 } | 2168 } |
| 2259 } | 2169 } |
| 2260 return maxWidth; | 2170 return maxWidth; |
| 2261 } | 2171 } |
| 2262 | 2172 |
| 2263 void RenderBox::computeLogicalWidthInRegion(LogicalExtentComputedValues& compute
dValues, RenderRegion* region) const | 2173 void RenderBox::computeLogicalWidth(LogicalExtentComputedValues& computedValues)
const |
| 2264 { | 2174 { |
| 2265 computedValues.m_extent = logicalWidth(); | 2175 computedValues.m_extent = logicalWidth(); |
| 2266 computedValues.m_position = logicalLeft(); | 2176 computedValues.m_position = logicalLeft(); |
| 2267 computedValues.m_margins.m_start = marginStart(); | 2177 computedValues.m_margins.m_start = marginStart(); |
| 2268 computedValues.m_margins.m_end = marginEnd(); | 2178 computedValues.m_margins.m_end = marginEnd(); |
| 2269 | 2179 |
| 2270 if (isOutOfFlowPositioned()) { | 2180 if (isOutOfFlowPositioned()) { |
| 2271 // FIXME: This calculation is not patched for block-flow yet. | 2181 // FIXME: This calculation is not patched for block-flow yet. |
| 2272 // https://bugs.webkit.org/show_bug.cgi?id=46500 | 2182 // https://bugs.webkit.org/show_bug.cgi?id=46500 |
| 2273 computePositionedLogicalWidth(computedValues, region); | 2183 computePositionedLogicalWidth(computedValues); |
| 2274 return; | 2184 return; |
| 2275 } | 2185 } |
| 2276 | 2186 |
| 2277 // If layout is limited to a subtree, the subtree root's logical width does
not change. | 2187 // If layout is limited to a subtree, the subtree root's logical width does
not change. |
| 2278 if (node() && view()->frameView() && view()->frameView()->layoutRoot(true) =
= this) | 2188 if (node() && view()->frameView() && view()->frameView()->layoutRoot(true) =
= this) |
| 2279 return; | 2189 return; |
| 2280 | 2190 |
| 2281 // The parent box is flexing us, so it has increased or decreased our | 2191 // The parent box is flexing us, so it has increased or decreased our |
| 2282 // width. Use the width from the style context. | 2192 // width. Use the width from the style context. |
| 2283 // FIXME: Account for block-flow in flexible boxes. | 2193 // FIXME: Account for block-flow in flexible boxes. |
| 2284 // https://bugs.webkit.org/show_bug.cgi?id=46418 | 2194 // https://bugs.webkit.org/show_bug.cgi?id=46418 |
| 2285 if (hasOverrideWidth() && (style()->borderFit() == BorderFitLines || parent(
)->isFlexibleBoxIncludingDeprecated())) { | 2195 if (hasOverrideWidth() && (style()->borderFit() == BorderFitLines || parent(
)->isFlexibleBoxIncludingDeprecated())) { |
| 2286 computedValues.m_extent = overrideLogicalContentWidth() + borderAndPaddi
ngLogicalWidth(); | 2196 computedValues.m_extent = overrideLogicalContentWidth() + borderAndPaddi
ngLogicalWidth(); |
| 2287 return; | 2197 return; |
| 2288 } | 2198 } |
| 2289 | 2199 |
| 2290 // FIXME: Account for block-flow in flexible boxes. | 2200 // FIXME: Account for block-flow in flexible boxes. |
| 2291 // https://bugs.webkit.org/show_bug.cgi?id=46418 | 2201 // https://bugs.webkit.org/show_bug.cgi?id=46418 |
| 2292 bool inVerticalBox = parent()->isDeprecatedFlexibleBox() && (parent()->style
()->boxOrient() == VERTICAL); | 2202 bool inVerticalBox = parent()->isDeprecatedFlexibleBox() && (parent()->style
()->boxOrient() == VERTICAL); |
| 2293 bool stretching = (parent()->style()->boxAlign() == BSTRETCH); | 2203 bool stretching = (parent()->style()->boxAlign() == BSTRETCH); |
| 2294 bool treatAsReplaced = shouldComputeSizeAsReplaced() && (!inVerticalBox || !
stretching); | 2204 bool treatAsReplaced = shouldComputeSizeAsReplaced() && (!inVerticalBox || !
stretching); |
| 2295 | 2205 |
| 2296 RenderStyle* styleToUse = style(); | 2206 RenderStyle* styleToUse = style(); |
| 2297 Length logicalWidthLength = treatAsReplaced ? Length(computeReplacedLogicalW
idth(), Fixed) : styleToUse->logicalWidth(); | 2207 Length logicalWidthLength = treatAsReplaced ? Length(computeReplacedLogicalW
idth(), Fixed) : styleToUse->logicalWidth(); |
| 2298 | 2208 |
| 2299 RenderBlock* cb = containingBlock(); | 2209 RenderBlock* cb = containingBlock(); |
| 2300 LayoutUnit containerLogicalWidth = max<LayoutUnit>(0, containingBlockLogical
WidthForContentInRegion(region)); | 2210 LayoutUnit containerLogicalWidth = max<LayoutUnit>(0, containingBlockLogical
WidthForContent()); |
| 2301 bool hasPerpendicularContainingBlock = cb->isHorizontalWritingMode() != isHo
rizontalWritingMode(); | 2211 bool hasPerpendicularContainingBlock = cb->isHorizontalWritingMode() != isHo
rizontalWritingMode(); |
| 2302 | 2212 |
| 2303 if (isInline() && !isInlineBlockOrInlineTable()) { | 2213 if (isInline() && !isInlineBlockOrInlineTable()) { |
| 2304 // just calculate margins | 2214 // just calculate margins |
| 2305 computedValues.m_margins.m_start = minimumValueForLength(styleToUse->mar
ginStart(), containerLogicalWidth); | 2215 computedValues.m_margins.m_start = minimumValueForLength(styleToUse->mar
ginStart(), containerLogicalWidth); |
| 2306 computedValues.m_margins.m_end = minimumValueForLength(styleToUse->margi
nEnd(), containerLogicalWidth); | 2216 computedValues.m_margins.m_end = minimumValueForLength(styleToUse->margi
nEnd(), containerLogicalWidth); |
| 2307 if (treatAsReplaced) | 2217 if (treatAsReplaced) |
| 2308 computedValues.m_extent = max<LayoutUnit>(floatValueForLength(logica
lWidthLength, 0) + borderAndPaddingLogicalWidth(), minPreferredLogicalWidth()); | 2218 computedValues.m_extent = max<LayoutUnit>(floatValueForLength(logica
lWidthLength, 0) + borderAndPaddingLogicalWidth(), minPreferredLogicalWidth()); |
| 2309 return; | 2219 return; |
| 2310 } | 2220 } |
| 2311 | 2221 |
| 2312 // Width calculations | 2222 // Width calculations |
| 2313 if (treatAsReplaced) | 2223 if (treatAsReplaced) |
| 2314 computedValues.m_extent = logicalWidthLength.value() + borderAndPaddingL
ogicalWidth(); | 2224 computedValues.m_extent = logicalWidthLength.value() + borderAndPaddingL
ogicalWidth(); |
| 2315 else { | 2225 else { |
| 2316 LayoutUnit containerWidthInInlineDirection = containerLogicalWidth; | 2226 LayoutUnit containerWidthInInlineDirection = containerLogicalWidth; |
| 2317 if (hasPerpendicularContainingBlock) | 2227 if (hasPerpendicularContainingBlock) |
| 2318 containerWidthInInlineDirection = perpendicularContainingBlockLogica
lHeight(); | 2228 containerWidthInInlineDirection = perpendicularContainingBlockLogica
lHeight(); |
| 2319 LayoutUnit preferredWidth = computeLogicalWidthInRegionUsing(MainOrPrefe
rredSize, styleToUse->logicalWidth(), containerWidthInInlineDirection, cb, regio
n); | 2229 LayoutUnit preferredWidth = computeLogicalWidthUsing(MainOrPreferredSize
, styleToUse->logicalWidth(), containerWidthInInlineDirection, cb); |
| 2320 computedValues.m_extent = constrainLogicalWidthInRegionByMinMax(preferre
dWidth, containerWidthInInlineDirection, cb, region); | 2230 computedValues.m_extent = constrainLogicalWidthByMinMax(preferredWidth,
containerWidthInInlineDirection, cb); |
| 2321 } | 2231 } |
| 2322 | 2232 |
| 2323 // Margin calculations. | 2233 // Margin calculations. |
| 2324 if (hasPerpendicularContainingBlock || isFloating() || isInline()) { | 2234 if (hasPerpendicularContainingBlock || isFloating() || isInline()) { |
| 2325 computedValues.m_margins.m_start = minimumValueForLength(styleToUse->mar
ginStart(), containerLogicalWidth); | 2235 computedValues.m_margins.m_start = minimumValueForLength(styleToUse->mar
ginStart(), containerLogicalWidth); |
| 2326 computedValues.m_margins.m_end = minimumValueForLength(styleToUse->margi
nEnd(), containerLogicalWidth); | 2236 computedValues.m_margins.m_end = minimumValueForLength(styleToUse->margi
nEnd(), containerLogicalWidth); |
| 2327 } else { | 2237 } else { |
| 2328 LayoutUnit containerLogicalWidthForAutoMargins = containerLogicalWidth; | 2238 LayoutUnit containerLogicalWidthForAutoMargins = containerLogicalWidth; |
| 2329 if (avoidsFloats() && cb->containsFloats()) | 2239 if (avoidsFloats() && cb->containsFloats()) |
| 2330 containerLogicalWidthForAutoMargins = containingBlockAvailableLineWi
dthInRegion(region); | 2240 containerLogicalWidthForAutoMargins = containingBlockAvailableLineWi
dth(); |
| 2331 bool hasInvertedDirection = cb->style()->isLeftToRightDirection() != sty
le()->isLeftToRightDirection(); | 2241 bool hasInvertedDirection = cb->style()->isLeftToRightDirection() != sty
le()->isLeftToRightDirection(); |
| 2332 computeInlineDirectionMargins(cb, containerLogicalWidthForAutoMargins, c
omputedValues.m_extent, | 2242 computeInlineDirectionMargins(cb, containerLogicalWidthForAutoMargins, c
omputedValues.m_extent, |
| 2333 hasInvertedDirection ? computedValues.m_margins.m_end : computedValu
es.m_margins.m_start, | 2243 hasInvertedDirection ? computedValues.m_margins.m_end : computedValu
es.m_margins.m_start, |
| 2334 hasInvertedDirection ? computedValues.m_margins.m_start : computedVa
lues.m_margins.m_end); | 2244 hasInvertedDirection ? computedValues.m_margins.m_start : computedVa
lues.m_margins.m_end); |
| 2335 } | 2245 } |
| 2336 | 2246 |
| 2337 if (!hasPerpendicularContainingBlock && containerLogicalWidth && containerLo
gicalWidth != (computedValues.m_extent + computedValues.m_margins.m_start + comp
utedValues.m_margins.m_end) | 2247 if (!hasPerpendicularContainingBlock && containerLogicalWidth && containerLo
gicalWidth != (computedValues.m_extent + computedValues.m_margins.m_start + comp
utedValues.m_margins.m_end) |
| 2338 && !isFloating() && !isInline() && !cb->isFlexibleBoxIncludingDeprecated
() && !cb->isRenderGrid()) { | 2248 && !isFloating() && !isInline() && !cb->isFlexibleBoxIncludingDeprecated
() && !cb->isRenderGrid()) { |
| 2339 LayoutUnit newMargin = containerLogicalWidth - computedValues.m_extent -
cb->marginStartForChild(this); | 2249 LayoutUnit newMargin = containerLogicalWidth - computedValues.m_extent -
cb->marginStartForChild(this); |
| 2340 bool hasInvertedDirection = cb->style()->isLeftToRightDirection() != sty
le()->isLeftToRightDirection(); | 2250 bool hasInvertedDirection = cb->style()->isLeftToRightDirection() != sty
le()->isLeftToRightDirection(); |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2390 if (logicalWidthLength.type() == FitContent) { | 2300 if (logicalWidthLength.type() == FitContent) { |
| 2391 minLogicalWidth += borderAndPadding; | 2301 minLogicalWidth += borderAndPadding; |
| 2392 maxLogicalWidth += borderAndPadding; | 2302 maxLogicalWidth += borderAndPadding; |
| 2393 return max(minLogicalWidth, min(maxLogicalWidth, fillAvailableMeasure(av
ailableLogicalWidth))); | 2303 return max(minLogicalWidth, min(maxLogicalWidth, fillAvailableMeasure(av
ailableLogicalWidth))); |
| 2394 } | 2304 } |
| 2395 | 2305 |
| 2396 ASSERT_NOT_REACHED(); | 2306 ASSERT_NOT_REACHED(); |
| 2397 return 0; | 2307 return 0; |
| 2398 } | 2308 } |
| 2399 | 2309 |
| 2400 LayoutUnit RenderBox::computeLogicalWidthInRegionUsing(SizeType widthType, Lengt
h logicalWidth, LayoutUnit availableLogicalWidth, | 2310 LayoutUnit RenderBox::computeLogicalWidthUsing(SizeType widthType, Length logica
lWidth, LayoutUnit availableLogicalWidth, const RenderBlock* cb) const |
| 2401 const RenderBlock* cb, RenderRegion* region) const | |
| 2402 { | 2311 { |
| 2403 if (!logicalWidth.isIntrinsicOrAuto()) { | 2312 if (!logicalWidth.isIntrinsicOrAuto()) { |
| 2404 // FIXME: If the containing block flow is perpendicular to our direction
we need to use the available logical height instead. | 2313 // FIXME: If the containing block flow is perpendicular to our direction
we need to use the available logical height instead. |
| 2405 return adjustBorderBoxLogicalWidthForBoxSizing(valueForLength(logicalWid
th, availableLogicalWidth)); | 2314 return adjustBorderBoxLogicalWidthForBoxSizing(valueForLength(logicalWid
th, availableLogicalWidth)); |
| 2406 } | 2315 } |
| 2407 | 2316 |
| 2408 if (logicalWidth.isIntrinsic()) | 2317 if (logicalWidth.isIntrinsic()) |
| 2409 return computeIntrinsicLogicalWidthUsing(logicalWidth, availableLogicalW
idth, borderAndPaddingLogicalWidth()); | 2318 return computeIntrinsicLogicalWidthUsing(logicalWidth, availableLogicalW
idth, borderAndPaddingLogicalWidth()); |
| 2410 | 2319 |
| 2411 LayoutUnit marginStart = 0; | 2320 LayoutUnit marginStart = 0; |
| 2412 LayoutUnit marginEnd = 0; | 2321 LayoutUnit marginEnd = 0; |
| 2413 LayoutUnit logicalWidthResult = fillAvailableMeasure(availableLogicalWidth,
marginStart, marginEnd); | 2322 LayoutUnit logicalWidthResult = fillAvailableMeasure(availableLogicalWidth,
marginStart, marginEnd); |
| 2414 | 2323 |
| 2415 if (shrinkToAvoidFloats() && cb->containsFloats()) | 2324 if (shrinkToAvoidFloats() && cb->containsFloats()) |
| 2416 logicalWidthResult = min(logicalWidthResult, shrinkLogicalWidthToAvoidFl
oats(marginStart, marginEnd, toRenderBlockFlow(cb), region)); | 2325 logicalWidthResult = min(logicalWidthResult, shrinkLogicalWidthToAvoidFl
oats(marginStart, marginEnd, toRenderBlockFlow(cb))); |
| 2417 | 2326 |
| 2418 if (widthType == MainOrPreferredSize && sizesLogicalWidthToFitContent(widthT
ype)) | 2327 if (widthType == MainOrPreferredSize && sizesLogicalWidthToFitContent(widthT
ype)) |
| 2419 return max(minPreferredLogicalWidth(), min(maxPreferredLogicalWidth(), l
ogicalWidthResult)); | 2328 return max(minPreferredLogicalWidth(), min(maxPreferredLogicalWidth(), l
ogicalWidthResult)); |
| 2420 return logicalWidthResult; | 2329 return logicalWidthResult; |
| 2421 } | 2330 } |
| 2422 | 2331 |
| 2423 static bool columnFlexItemHasStretchAlignment(const RenderObject* flexitem) | 2332 static bool columnFlexItemHasStretchAlignment(const RenderObject* flexitem) |
| 2424 { | 2333 { |
| 2425 RenderObject* parent = flexitem->parent(); | 2334 RenderObject* parent = flexitem->parent(); |
| 2426 // auto margins mean we don't stretch. Note that this function will only be
used for | 2335 // auto margins mean we don't stretch. Note that this function will only be
used for |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2554 marginStart = containerWidth - childWidth - marginEnd; | 2463 marginStart = containerWidth - childWidth - marginEnd; |
| 2555 return; | 2464 return; |
| 2556 } | 2465 } |
| 2557 | 2466 |
| 2558 // Case Four: Either no auto margins, or our width is >= the container width
(css2.1, 10.3.3). In that case | 2467 // Case Four: Either no auto margins, or our width is >= the container width
(css2.1, 10.3.3). In that case |
| 2559 // auto margins will just turn into 0. | 2468 // auto margins will just turn into 0. |
| 2560 marginStart = minimumValueForLength(marginStartLength, containerWidth); | 2469 marginStart = minimumValueForLength(marginStartLength, containerWidth); |
| 2561 marginEnd = minimumValueForLength(marginEndLength, containerWidth); | 2470 marginEnd = minimumValueForLength(marginEndLength, containerWidth); |
| 2562 } | 2471 } |
| 2563 | 2472 |
| 2564 RenderBoxRegionInfo* RenderBox::renderBoxRegionInfo(RenderRegion* region, Render
BoxRegionInfoFlags cacheFlag) const | |
| 2565 { | |
| 2566 // Make sure nobody is trying to call this with a null region. | |
| 2567 if (!region) | |
| 2568 return 0; | |
| 2569 | |
| 2570 // If we have computed our width in this region already, it will be cached,
and we can | |
| 2571 // just return it. | |
| 2572 RenderBoxRegionInfo* boxInfo = region->renderBoxRegionInfo(this); | |
| 2573 if (boxInfo && cacheFlag == CacheRenderBoxRegionInfo) | |
| 2574 return boxInfo; | |
| 2575 | |
| 2576 // No cached value was found, so we have to compute our insets in this regio
n. | |
| 2577 // FIXME: For now we limit this computation to normal RenderBlocks. Future p
atches will expand | |
| 2578 // support to cover all boxes. | |
| 2579 RenderFlowThread* flowThread = flowThreadContainingBlock(); | |
| 2580 if (isRenderFlowThread() || !flowThread || !canHaveBoxInfoInRegion() || flow
Thread->style()->writingMode() != style()->writingMode()) | |
| 2581 return 0; | |
| 2582 | |
| 2583 LogicalExtentComputedValues computedValues; | |
| 2584 computeLogicalWidthInRegion(computedValues, region); | |
| 2585 | |
| 2586 // Now determine the insets based off where this object is supposed to be po
sitioned. | |
| 2587 RenderBlock* cb = containingBlock(); | |
| 2588 RenderRegion* clampedContainingBlockRegion = cb->clampToStartAndEndRegions(r
egion); | |
| 2589 RenderBoxRegionInfo* containingBlockInfo = cb->renderBoxRegionInfo(clampedCo
ntainingBlockRegion); | |
| 2590 LayoutUnit containingBlockLogicalWidth = cb->logicalWidth(); | |
| 2591 LayoutUnit containingBlockLogicalWidthInRegion = containingBlockInfo ? conta
iningBlockInfo->logicalWidth() : containingBlockLogicalWidth; | |
| 2592 | |
| 2593 LayoutUnit marginStartInRegion = computedValues.m_margins.m_start; | |
| 2594 LayoutUnit startMarginDelta = marginStartInRegion - marginStart(); | |
| 2595 LayoutUnit logicalWidthInRegion = computedValues.m_extent; | |
| 2596 LayoutUnit logicalLeftInRegion = computedValues.m_position; | |
| 2597 LayoutUnit widthDelta = logicalWidthInRegion - logicalWidth(); | |
| 2598 LayoutUnit logicalLeftDelta = isOutOfFlowPositioned() ? logicalLeftInRegion
- logicalLeft() : startMarginDelta; | |
| 2599 LayoutUnit logicalRightInRegion = containingBlockLogicalWidthInRegion - (log
icalLeftInRegion + logicalWidthInRegion); | |
| 2600 LayoutUnit oldLogicalRight = containingBlockLogicalWidth - (logicalLeft() +
logicalWidth()); | |
| 2601 LayoutUnit logicalRightDelta = isOutOfFlowPositioned() ? logicalRightInRegio
n - oldLogicalRight : startMarginDelta; | |
| 2602 | |
| 2603 LayoutUnit logicalLeftOffset = 0; | |
| 2604 | |
| 2605 if (!isOutOfFlowPositioned() && avoidsFloats() && cb->containsFloats()) { | |
| 2606 LayoutUnit startPositionDelta = toRenderBlockFlow(cb)->computeStartPosit
ionDeltaForChildAvoidingFloats(this, marginStartInRegion, region); | |
| 2607 if (cb->style()->isLeftToRightDirection()) | |
| 2608 logicalLeftDelta += startPositionDelta; | |
| 2609 else | |
| 2610 logicalRightDelta += startPositionDelta; | |
| 2611 } | |
| 2612 | |
| 2613 if (cb->style()->isLeftToRightDirection()) | |
| 2614 logicalLeftOffset += logicalLeftDelta; | |
| 2615 else | |
| 2616 logicalLeftOffset -= (widthDelta + logicalRightDelta); | |
| 2617 | |
| 2618 LayoutUnit logicalRightOffset = logicalWidth() - (logicalLeftOffset + logica
lWidthInRegion); | |
| 2619 bool isShifted = (containingBlockInfo && containingBlockInfo->isShifted()) | |
| 2620 || (style()->isLeftToRightDirection() && logicalLeftOffset) | |
| 2621 || (!style()->isLeftToRightDirection() && logicalRightOffset); | |
| 2622 | |
| 2623 // FIXME: Although it's unlikely, these boxes can go outside our bounds, and
so we will need to incorporate them into overflow. | |
| 2624 if (cacheFlag == CacheRenderBoxRegionInfo) | |
| 2625 return region->setRenderBoxRegionInfo(this, logicalLeftOffset, logicalWi
dthInRegion, isShifted); | |
| 2626 return new RenderBoxRegionInfo(logicalLeftOffset, logicalWidthInRegion, isSh
ifted); | |
| 2627 } | |
| 2628 | |
| 2629 static bool shouldFlipBeforeAfterMargins(const RenderStyle* containingBlockStyle
, const RenderStyle* childStyle) | 2473 static bool shouldFlipBeforeAfterMargins(const RenderStyle* containingBlockStyle
, const RenderStyle* childStyle) |
| 2630 { | 2474 { |
| 2631 ASSERT(containingBlockStyle->isHorizontalWritingMode() != childStyle->isHori
zontalWritingMode()); | 2475 ASSERT(containingBlockStyle->isHorizontalWritingMode() != childStyle->isHori
zontalWritingMode()); |
| 2632 WritingMode childWritingMode = childStyle->writingMode(); | 2476 WritingMode childWritingMode = childStyle->writingMode(); |
| 2633 bool shouldFlip = false; | 2477 bool shouldFlip = false; |
| 2634 switch (containingBlockStyle->writingMode()) { | 2478 switch (containingBlockStyle->writingMode()) { |
| 2635 case TopToBottomWritingMode: | 2479 case TopToBottomWritingMode: |
| 2636 shouldFlip = (childWritingMode == RightToLeftWritingMode); | 2480 shouldFlip = (childWritingMode == RightToLeftWritingMode); |
| 2637 break; | 2481 break; |
| 2638 case BottomToTopWritingMode: | 2482 case BottomToTopWritingMode: |
| (...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3123 | 2967 |
| 3124 void RenderBox::computeAndSetBlockDirectionMargins(const RenderBlock* containing
Block) | 2968 void RenderBox::computeAndSetBlockDirectionMargins(const RenderBlock* containing
Block) |
| 3125 { | 2969 { |
| 3126 LayoutUnit marginBefore; | 2970 LayoutUnit marginBefore; |
| 3127 LayoutUnit marginAfter; | 2971 LayoutUnit marginAfter; |
| 3128 computeBlockDirectionMargins(containingBlock, marginBefore, marginAfter); | 2972 computeBlockDirectionMargins(containingBlock, marginBefore, marginAfter); |
| 3129 containingBlock->setMarginBeforeForChild(this, marginBefore); | 2973 containingBlock->setMarginBeforeForChild(this, marginBefore); |
| 3130 containingBlock->setMarginAfterForChild(this, marginAfter); | 2974 containingBlock->setMarginAfterForChild(this, marginAfter); |
| 3131 } | 2975 } |
| 3132 | 2976 |
| 3133 LayoutUnit RenderBox::containingBlockLogicalWidthForPositioned(const RenderBoxMo
delObject* containingBlock, RenderRegion* region, bool checkForPerpendicularWrit
ingMode) const | 2977 LayoutUnit RenderBox::containingBlockLogicalWidthForPositioned(const RenderBoxMo
delObject* containingBlock, bool checkForPerpendicularWritingMode) const |
| 3134 { | 2978 { |
| 3135 if (checkForPerpendicularWritingMode && containingBlock->isHorizontalWriting
Mode() != isHorizontalWritingMode()) | 2979 if (checkForPerpendicularWritingMode && containingBlock->isHorizontalWriting
Mode() != isHorizontalWritingMode()) |
| 3136 return containingBlockLogicalHeightForPositioned(containingBlock, false)
; | 2980 return containingBlockLogicalHeightForPositioned(containingBlock, false)
; |
| 3137 | 2981 |
| 3138 // Use viewport as container for top-level fixed-position elements. | 2982 // Use viewport as container for top-level fixed-position elements. |
| 3139 if (style()->position() == FixedPosition && containingBlock->isRenderView())
{ | 2983 if (style()->position() == FixedPosition && containingBlock->isRenderView())
{ |
| 3140 const RenderView* view = toRenderView(containingBlock); | 2984 const RenderView* view = toRenderView(containingBlock); |
| 3141 if (FrameView* frameView = view->frameView()) { | 2985 if (FrameView* frameView = view->frameView()) { |
| 3142 LayoutRect viewportRect = frameView->viewportConstrainedVisibleConte
ntRect(); | 2986 LayoutRect viewportRect = frameView->viewportConstrainedVisibleConte
ntRect(); |
| 3143 return containingBlock->isHorizontalWritingMode() ? viewportRect.wid
th() : viewportRect.height(); | 2987 return containingBlock->isHorizontalWritingMode() ? viewportRect.wid
th() : viewportRect.height(); |
| 3144 } | 2988 } |
| 3145 } | 2989 } |
| 3146 | 2990 |
| 3147 if (containingBlock->isBox()) { | 2991 if (containingBlock->isBox()) |
| 3148 RenderFlowThread* flowThread = flowThreadContainingBlock(); | 2992 return toRenderBox(containingBlock)->clientLogicalWidth(); |
| 3149 if (!flowThread) | |
| 3150 return toRenderBox(containingBlock)->clientLogicalWidth(); | |
| 3151 | |
| 3152 const RenderBlock* cb = toRenderBlock(containingBlock); | |
| 3153 RenderBoxRegionInfo* boxInfo = 0; | |
| 3154 if (!region) { | |
| 3155 if (containingBlock->isRenderFlowThread() && !checkForPerpendicularW
ritingMode) | |
| 3156 return toRenderFlowThread(containingBlock)->contentLogicalWidthO
fFirstRegion(); | |
| 3157 if (isWritingModeRoot()) { | |
| 3158 LayoutUnit cbPageOffset = cb->offsetFromLogicalTopOfFirstPage(); | |
| 3159 RenderRegion* cbRegion = cb->regionAtBlockOffset(cbPageOffset); | |
| 3160 if (cbRegion) { | |
| 3161 cbRegion = cb->clampToStartAndEndRegions(cbRegion); | |
| 3162 boxInfo = cb->renderBoxRegionInfo(cbRegion); | |
| 3163 } | |
| 3164 } | |
| 3165 } else if (region && flowThread->isHorizontalWritingMode() == containing
Block->isHorizontalWritingMode()) { | |
| 3166 RenderRegion* containingBlockRegion = cb->clampToStartAndEndRegions(
region); | |
| 3167 boxInfo = cb->renderBoxRegionInfo(containingBlockRegion); | |
| 3168 } | |
| 3169 return (boxInfo) ? max<LayoutUnit>(0, cb->clientLogicalWidth() - (cb->lo
gicalWidth() - boxInfo->logicalWidth())) : cb->clientLogicalWidth(); | |
| 3170 } | |
| 3171 | 2993 |
| 3172 ASSERT(containingBlock->isRenderInline() && containingBlock->isInFlowPositio
ned()); | 2994 ASSERT(containingBlock->isRenderInline() && containingBlock->isInFlowPositio
ned()); |
| 3173 | 2995 |
| 3174 const RenderInline* flow = toRenderInline(containingBlock); | 2996 const RenderInline* flow = toRenderInline(containingBlock); |
| 3175 InlineFlowBox* first = flow->firstLineBox(); | 2997 InlineFlowBox* first = flow->firstLineBox(); |
| 3176 InlineFlowBox* last = flow->lastLineBox(); | 2998 InlineFlowBox* last = flow->lastLineBox(); |
| 3177 | 2999 |
| 3178 // If the containing block is empty, return a width of 0. | 3000 // If the containing block is empty, return a width of 0. |
| 3179 if (!first || !last) | 3001 if (!first || !last) |
| 3180 return 0; | 3002 return 0; |
| 3181 | 3003 |
| 3182 LayoutUnit fromLeft; | 3004 LayoutUnit fromLeft; |
| 3183 LayoutUnit fromRight; | 3005 LayoutUnit fromRight; |
| 3184 if (containingBlock->style()->isLeftToRightDirection()) { | 3006 if (containingBlock->style()->isLeftToRightDirection()) { |
| 3185 fromLeft = first->logicalLeft() + first->borderLogicalLeft(); | 3007 fromLeft = first->logicalLeft() + first->borderLogicalLeft(); |
| 3186 fromRight = last->logicalLeft() + last->logicalWidth() - last->borderLog
icalRight(); | 3008 fromRight = last->logicalLeft() + last->logicalWidth() - last->borderLog
icalRight(); |
| 3187 } else { | 3009 } else { |
| 3188 fromRight = first->logicalLeft() + first->logicalWidth() - first->border
LogicalRight(); | 3010 fromRight = first->logicalLeft() + first->logicalWidth() - first->border
LogicalRight(); |
| 3189 fromLeft = last->logicalLeft() + last->borderLogicalLeft(); | 3011 fromLeft = last->logicalLeft() + last->borderLogicalLeft(); |
| 3190 } | 3012 } |
| 3191 | 3013 |
| 3192 return max<LayoutUnit>(0, fromRight - fromLeft); | 3014 return max<LayoutUnit>(0, fromRight - fromLeft); |
| 3193 } | 3015 } |
| 3194 | 3016 |
| 3195 LayoutUnit RenderBox::containingBlockLogicalHeightForPositioned(const RenderBoxM
odelObject* containingBlock, bool checkForPerpendicularWritingMode) const | 3017 LayoutUnit RenderBox::containingBlockLogicalHeightForPositioned(const RenderBoxM
odelObject* containingBlock, bool checkForPerpendicularWritingMode) const |
| 3196 { | 3018 { |
| 3197 if (checkForPerpendicularWritingMode && containingBlock->isHorizontalWriting
Mode() != isHorizontalWritingMode()) | 3019 if (checkForPerpendicularWritingMode && containingBlock->isHorizontalWriting
Mode() != isHorizontalWritingMode()) |
| 3198 return containingBlockLogicalWidthForPositioned(containingBlock, 0, fals
e); | 3020 return containingBlockLogicalWidthForPositioned(containingBlock, false); |
| 3199 | 3021 |
| 3200 // Use viewport as container for top-level fixed-position elements. | 3022 // Use viewport as container for top-level fixed-position elements. |
| 3201 if (style()->position() == FixedPosition && containingBlock->isRenderView())
{ | 3023 if (style()->position() == FixedPosition && containingBlock->isRenderView())
{ |
| 3202 const RenderView* view = toRenderView(containingBlock); | 3024 const RenderView* view = toRenderView(containingBlock); |
| 3203 if (FrameView* frameView = view->frameView()) { | 3025 if (FrameView* frameView = view->frameView()) { |
| 3204 LayoutRect viewportRect = frameView->viewportConstrainedVisibleConte
ntRect(); | 3026 LayoutRect viewportRect = frameView->viewportConstrainedVisibleConte
ntRect(); |
| 3205 return containingBlock->isHorizontalWritingMode() ? viewportRect.hei
ght() : viewportRect.width(); | 3027 return containingBlock->isHorizontalWritingMode() ? viewportRect.hei
ght() : viewportRect.width(); |
| 3206 } | 3028 } |
| 3207 } | 3029 } |
| 3208 | 3030 |
| 3209 if (containingBlock->isBox()) { | 3031 if (containingBlock->isBox()) { |
| 3210 const RenderBlock* cb = containingBlock->isRenderBlock() ? | 3032 const RenderBlock* cb = containingBlock->isRenderBlock() ? |
| 3211 toRenderBlock(containingBlock) : containingBlock->containingBlock(); | 3033 toRenderBlock(containingBlock) : containingBlock->containingBlock(); |
| 3212 LayoutUnit result = cb->clientLogicalHeight(); | 3034 return cb->clientLogicalHeight(); |
| 3213 RenderFlowThread* flowThread = flowThreadContainingBlock(); | |
| 3214 if (flowThread && containingBlock->isRenderFlowThread() && flowThread->i
sHorizontalWritingMode() == containingBlock->isHorizontalWritingMode()) | |
| 3215 return toRenderFlowThread(containingBlock)->contentLogicalHeightOfFi
rstRegion(); | |
| 3216 return result; | |
| 3217 } | 3035 } |
| 3218 | 3036 |
| 3219 ASSERT(containingBlock->isRenderInline() && containingBlock->isInFlowPositio
ned()); | 3037 ASSERT(containingBlock->isRenderInline() && containingBlock->isInFlowPositio
ned()); |
| 3220 | 3038 |
| 3221 const RenderInline* flow = toRenderInline(containingBlock); | 3039 const RenderInline* flow = toRenderInline(containingBlock); |
| 3222 InlineFlowBox* first = flow->firstLineBox(); | 3040 InlineFlowBox* first = flow->firstLineBox(); |
| 3223 InlineFlowBox* last = flow->lastLineBox(); | 3041 InlineFlowBox* last = flow->lastLineBox(); |
| 3224 | 3042 |
| 3225 // If the containing block is empty, return a height of 0. | 3043 // If the containing block is empty, return a height of 0. |
| 3226 if (!first || !last) | 3044 if (!first || !last) |
| 3227 return 0; | 3045 return 0; |
| 3228 | 3046 |
| 3229 LayoutUnit heightResult; | 3047 LayoutUnit heightResult; |
| 3230 LayoutRect boundingBox = flow->linesBoundingBox(); | 3048 LayoutRect boundingBox = flow->linesBoundingBox(); |
| 3231 if (containingBlock->isHorizontalWritingMode()) | 3049 if (containingBlock->isHorizontalWritingMode()) |
| 3232 heightResult = boundingBox.height(); | 3050 heightResult = boundingBox.height(); |
| 3233 else | 3051 else |
| 3234 heightResult = boundingBox.width(); | 3052 heightResult = boundingBox.width(); |
| 3235 heightResult -= (containingBlock->borderBefore() + containingBlock->borderAf
ter()); | 3053 heightResult -= (containingBlock->borderBefore() + containingBlock->borderAf
ter()); |
| 3236 return heightResult; | 3054 return heightResult; |
| 3237 } | 3055 } |
| 3238 | 3056 |
| 3239 static void computeInlineStaticDistance(Length& logicalLeft, Length& logicalRigh
t, const RenderBox* child, const RenderBoxModelObject* containerBlock, LayoutUni
t containerLogicalWidth, RenderRegion* region) | 3057 static void computeInlineStaticDistance(Length& logicalLeft, Length& logicalRigh
t, const RenderBox* child, const RenderBoxModelObject* containerBlock, LayoutUni
t containerLogicalWidth) |
| 3240 { | 3058 { |
| 3241 if (!logicalLeft.isAuto() || !logicalRight.isAuto()) | 3059 if (!logicalLeft.isAuto() || !logicalRight.isAuto()) |
| 3242 return; | 3060 return; |
| 3243 | 3061 |
| 3244 // FIXME: The static distance computation has not been patched for mixed wri
ting modes yet. | 3062 // FIXME: The static distance computation has not been patched for mixed wri
ting modes yet. |
| 3245 if (child->parent()->style()->direction() == LTR) { | 3063 if (child->parent()->style()->direction() == LTR) { |
| 3246 LayoutUnit staticPosition = child->layer()->staticInlinePosition() - con
tainerBlock->borderLogicalLeft(); | 3064 LayoutUnit staticPosition = child->layer()->staticInlinePosition() - con
tainerBlock->borderLogicalLeft(); |
| 3247 for (RenderObject* curr = child->parent(); curr && curr != containerBloc
k; curr = curr->container()) { | 3065 for (RenderObject* curr = child->parent(); curr && curr != containerBloc
k; curr = curr->container()) { |
| 3248 if (curr->isBox()) { | 3066 if (curr->isBox()) { |
| 3249 staticPosition += toRenderBox(curr)->logicalLeft(); | 3067 staticPosition += toRenderBox(curr)->logicalLeft(); |
| 3250 if (toRenderBox(curr)->isRelPositioned()) | 3068 if (toRenderBox(curr)->isRelPositioned()) |
| 3251 staticPosition += toRenderBox(curr)->relativePositionOffset(
).width(); | 3069 staticPosition += toRenderBox(curr)->relativePositionOffset(
).width(); |
| 3252 if (region && curr->isRenderBlock()) { | |
| 3253 const RenderBlock* cb = toRenderBlock(curr); | |
| 3254 region = cb->clampToStartAndEndRegions(region); | |
| 3255 RenderBoxRegionInfo* boxInfo = cb->renderBoxRegionInfo(regio
n); | |
| 3256 if (boxInfo) | |
| 3257 staticPosition += boxInfo->logicalLeft(); | |
| 3258 } | |
| 3259 } else if (curr->isInline()) { | 3070 } else if (curr->isInline()) { |
| 3260 if (curr->isRelPositioned()) { | 3071 if (curr->isRelPositioned()) { |
| 3261 if (!curr->style()->logicalLeft().isAuto()) | 3072 if (!curr->style()->logicalLeft().isAuto()) |
| 3262 staticPosition += curr->style()->logicalLeft().value(); | 3073 staticPosition += curr->style()->logicalLeft().value(); |
| 3263 else | 3074 else |
| 3264 staticPosition -= curr->style()->logicalRight().value(); | 3075 staticPosition -= curr->style()->logicalRight().value(); |
| 3265 } | 3076 } |
| 3266 } | 3077 } |
| 3267 } | 3078 } |
| 3268 logicalLeft.setValue(Fixed, staticPosition); | 3079 logicalLeft.setValue(Fixed, staticPosition); |
| 3269 } else { | 3080 } else { |
| 3270 RenderBox* enclosingBox = child->parent()->enclosingBox(); | 3081 RenderBox* enclosingBox = child->parent()->enclosingBox(); |
| 3271 LayoutUnit staticPosition = child->layer()->staticInlinePosition() + con
tainerLogicalWidth + containerBlock->borderLogicalLeft(); | 3082 LayoutUnit staticPosition = child->layer()->staticInlinePosition() + con
tainerLogicalWidth + containerBlock->borderLogicalLeft(); |
| 3272 for (RenderObject* curr = child->parent(); curr; curr = curr->container(
)) { | 3083 for (RenderObject* curr = child->parent(); curr; curr = curr->container(
)) { |
| 3273 if (curr->isBox()) { | 3084 if (curr->isBox()) { |
| 3274 if (curr != containerBlock) { | 3085 if (curr != containerBlock) { |
| 3275 staticPosition -= toRenderBox(curr)->logicalLeft(); | 3086 staticPosition -= toRenderBox(curr)->logicalLeft(); |
| 3276 if (toRenderBox(curr)->isRelPositioned()) | 3087 if (toRenderBox(curr)->isRelPositioned()) |
| 3277 staticPosition -= toRenderBox(curr)->relativePositionOff
set().width(); | 3088 staticPosition -= toRenderBox(curr)->relativePositionOff
set().width(); |
| 3278 } | 3089 } |
| 3279 if (curr == enclosingBox) | 3090 if (curr == enclosingBox) |
| 3280 staticPosition -= enclosingBox->logicalWidth(); | 3091 staticPosition -= enclosingBox->logicalWidth(); |
| 3281 if (region && curr->isRenderBlock()) { | |
| 3282 const RenderBlock* cb = toRenderBlock(curr); | |
| 3283 region = cb->clampToStartAndEndRegions(region); | |
| 3284 RenderBoxRegionInfo* boxInfo = cb->renderBoxRegionInfo(regio
n); | |
| 3285 if (boxInfo) { | |
| 3286 if (curr != containerBlock) | |
| 3287 staticPosition -= cb->logicalWidth() - (boxInfo->log
icalLeft() + boxInfo->logicalWidth()); | |
| 3288 if (curr == enclosingBox) | |
| 3289 staticPosition += enclosingBox->logicalWidth() - box
Info->logicalWidth(); | |
| 3290 } | |
| 3291 } | |
| 3292 } else if (curr->isInline()) { | 3092 } else if (curr->isInline()) { |
| 3293 if (curr->isRelPositioned()) { | 3093 if (curr->isRelPositioned()) { |
| 3294 if (!curr->style()->logicalLeft().isAuto()) | 3094 if (!curr->style()->logicalLeft().isAuto()) |
| 3295 staticPosition -= curr->style()->logicalLeft().value(); | 3095 staticPosition -= curr->style()->logicalLeft().value(); |
| 3296 else | 3096 else |
| 3297 staticPosition += curr->style()->logicalRight().value(); | 3097 staticPosition += curr->style()->logicalRight().value(); |
| 3298 } | 3098 } |
| 3299 } | 3099 } |
| 3300 if (curr == containerBlock) | 3100 if (curr == containerBlock) |
| 3301 break; | 3101 break; |
| 3302 } | 3102 } |
| 3303 logicalRight.setValue(Fixed, staticPosition); | 3103 logicalRight.setValue(Fixed, staticPosition); |
| 3304 } | 3104 } |
| 3305 } | 3105 } |
| 3306 | 3106 |
| 3307 void RenderBox::computePositionedLogicalWidth(LogicalExtentComputedValues& compu
tedValues, RenderRegion* region) const | 3107 void RenderBox::computePositionedLogicalWidth(LogicalExtentComputedValues& compu
tedValues) const |
| 3308 { | 3108 { |
| 3309 if (isReplaced()) { | 3109 if (isReplaced()) { |
| 3310 // FIXME: Positioned replaced elements inside a flow thread are not work
ing properly | |
| 3311 // with variable width regions (see https://bugs.webkit.org/show_bug.cgi
?id=69896 ). | |
| 3312 computePositionedLogicalWidthReplaced(computedValues); | 3110 computePositionedLogicalWidthReplaced(computedValues); |
| 3313 return; | 3111 return; |
| 3314 } | 3112 } |
| 3315 | 3113 |
| 3316 // QUESTIONS | 3114 // QUESTIONS |
| 3317 // FIXME 1: Should we still deal with these the cases of 'left' or 'right' h
aving | 3115 // FIXME 1: Should we still deal with these the cases of 'left' or 'right' h
aving |
| 3318 // the type 'static' in determining whether to calculate the static distance
? | 3116 // the type 'static' in determining whether to calculate the static distance
? |
| 3319 // NOTE: 'static' is not a legal value for 'left' or 'right' as of CSS 2.1. | 3117 // NOTE: 'static' is not a legal value for 'left' or 'right' as of CSS 2.1. |
| 3320 | 3118 |
| 3321 // FIXME 2: Can perhaps optimize out cases when max-width/min-width are grea
ter | 3119 // FIXME 2: Can perhaps optimize out cases when max-width/min-width are grea
ter |
| 3322 // than or less than the computed width(). Be careful of box-sizing and | 3120 // than or less than the computed width(). Be careful of box-sizing and |
| 3323 // percentage issues. | 3121 // percentage issues. |
| 3324 | 3122 |
| 3325 // The following is based off of the W3C Working Draft from April 11, 2006 o
f | 3123 // The following is based off of the W3C Working Draft from April 11, 2006 o
f |
| 3326 // CSS 2.1: Section 10.3.7 "Absolutely positioned, non-replaced elements" | 3124 // CSS 2.1: Section 10.3.7 "Absolutely positioned, non-replaced elements" |
| 3327 // <http://www.w3.org/TR/CSS21/visudet.html#abs-non-replaced-width> | 3125 // <http://www.w3.org/TR/CSS21/visudet.html#abs-non-replaced-width> |
| 3328 // (block-style-comments in this function and in computePositionedLogicalWid
thUsing() | 3126 // (block-style-comments in this function and in computePositionedLogicalWid
thUsing() |
| 3329 // correspond to text from the spec) | 3127 // correspond to text from the spec) |
| 3330 | 3128 |
| 3331 | 3129 |
| 3332 // We don't use containingBlock(), since we may be positioned by an enclosin
g | 3130 // We don't use containingBlock(), since we may be positioned by an enclosin
g |
| 3333 // relative positioned inline. | 3131 // relative positioned inline. |
| 3334 const RenderBoxModelObject* containerBlock = toRenderBoxModelObject(containe
r()); | 3132 const RenderBoxModelObject* containerBlock = toRenderBoxModelObject(containe
r()); |
| 3335 | 3133 |
| 3336 const LayoutUnit containerLogicalWidth = containingBlockLogicalWidthForPosit
ioned(containerBlock, region); | 3134 const LayoutUnit containerLogicalWidth = containingBlockLogicalWidthForPosit
ioned(containerBlock); |
| 3337 | 3135 |
| 3338 // Use the container block's direction except when calculating the static di
stance | 3136 // Use the container block's direction except when calculating the static di
stance |
| 3339 // This conforms with the reference results for abspos-replaced-width-margin
-000.htm | 3137 // This conforms with the reference results for abspos-replaced-width-margin
-000.htm |
| 3340 // of the CSS 2.1 test suite | 3138 // of the CSS 2.1 test suite |
| 3341 TextDirection containerDirection = containerBlock->style()->direction(); | 3139 TextDirection containerDirection = containerBlock->style()->direction(); |
| 3342 | 3140 |
| 3343 bool isHorizontal = isHorizontalWritingMode(); | 3141 bool isHorizontal = isHorizontalWritingMode(); |
| 3344 const LayoutUnit bordersPlusPadding = borderAndPaddingLogicalWidth(); | 3142 const LayoutUnit bordersPlusPadding = borderAndPaddingLogicalWidth(); |
| 3345 const Length marginLogicalLeft = isHorizontal ? style()->marginLeft() : styl
e()->marginTop(); | 3143 const Length marginLogicalLeft = isHorizontal ? style()->marginLeft() : styl
e()->marginTop(); |
| 3346 const Length marginLogicalRight = isHorizontal ? style()->marginRight() : st
yle()->marginBottom(); | 3144 const Length marginLogicalRight = isHorizontal ? style()->marginRight() : st
yle()->marginBottom(); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 3367 * user agents are free to make a guess at its probable position. | 3165 * user agents are free to make a guess at its probable position. |
| 3368 * | 3166 * |
| 3369 * For the purposes of calculating the static position, the containing block
of | 3167 * For the purposes of calculating the static position, the containing block
of |
| 3370 * fixed positioned elements is the initial containing block instead of the | 3168 * fixed positioned elements is the initial containing block instead of the |
| 3371 * viewport, and all scrollable boxes should be assumed to be scrolled to th
eir | 3169 * viewport, and all scrollable boxes should be assumed to be scrolled to th
eir |
| 3372 * origin. | 3170 * origin. |
| 3373 \*--------------------------------------------------------------------------
-*/ | 3171 \*--------------------------------------------------------------------------
-*/ |
| 3374 | 3172 |
| 3375 // see FIXME 1 | 3173 // see FIXME 1 |
| 3376 // Calculate the static distance if needed. | 3174 // Calculate the static distance if needed. |
| 3377 computeInlineStaticDistance(logicalLeftLength, logicalRightLength, this, con
tainerBlock, containerLogicalWidth, region); | 3175 computeInlineStaticDistance(logicalLeftLength, logicalRightLength, this, con
tainerBlock, containerLogicalWidth); |
| 3378 | 3176 |
| 3379 // Calculate constraint equation values for 'width' case. | 3177 // Calculate constraint equation values for 'width' case. |
| 3380 computePositionedLogicalWidthUsing(style()->logicalWidth(), containerBlock,
containerDirection, | 3178 computePositionedLogicalWidthUsing(style()->logicalWidth(), containerBlock,
containerDirection, |
| 3381 containerLogicalWidth, bordersPlusPadding
, | 3179 containerLogicalWidth, bordersPlusPadding
, |
| 3382 logicalLeftLength, logicalRightLength, ma
rginLogicalLeft, marginLogicalRight, | 3180 logicalLeftLength, logicalRightLength, ma
rginLogicalLeft, marginLogicalRight, |
| 3383 computedValues); | 3181 computedValues); |
| 3384 | 3182 |
| 3385 // Calculate constraint equation values for 'max-width' case. | 3183 // Calculate constraint equation values for 'max-width' case. |
| 3386 if (!style()->logicalMaxWidth().isUndefined()) { | 3184 if (!style()->logicalMaxWidth().isUndefined()) { |
| 3387 LogicalExtentComputedValues maxValues; | 3185 LogicalExtentComputedValues maxValues; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 3410 | 3208 |
| 3411 if (computedValues.m_extent < minValues.m_extent) { | 3209 if (computedValues.m_extent < minValues.m_extent) { |
| 3412 computedValues.m_extent = minValues.m_extent; | 3210 computedValues.m_extent = minValues.m_extent; |
| 3413 computedValues.m_position = minValues.m_position; | 3211 computedValues.m_position = minValues.m_position; |
| 3414 computedValues.m_margins.m_start = minValues.m_margins.m_start; | 3212 computedValues.m_margins.m_start = minValues.m_margins.m_start; |
| 3415 computedValues.m_margins.m_end = minValues.m_margins.m_end; | 3213 computedValues.m_margins.m_end = minValues.m_margins.m_end; |
| 3416 } | 3214 } |
| 3417 } | 3215 } |
| 3418 | 3216 |
| 3419 computedValues.m_extent += bordersPlusPadding; | 3217 computedValues.m_extent += bordersPlusPadding; |
| 3420 | |
| 3421 // Adjust logicalLeft if we need to for the flipped version of our writing m
ode in regions. | |
| 3422 // FIXME: Add support for other types of objects as containerBlock, not only
RenderBlock. | |
| 3423 RenderFlowThread* flowThread = flowThreadContainingBlock(); | |
| 3424 if (flowThread && !region && isWritingModeRoot() && isHorizontalWritingMode(
) == containerBlock->isHorizontalWritingMode() && containerBlock->isRenderBlock(
)) { | |
| 3425 ASSERT(containerBlock->canHaveBoxInfoInRegion()); | |
| 3426 LayoutUnit logicalLeftPos = computedValues.m_position; | |
| 3427 const RenderBlock* cb = toRenderBlock(containerBlock); | |
| 3428 LayoutUnit cbPageOffset = cb->offsetFromLogicalTopOfFirstPage(); | |
| 3429 RenderRegion* cbRegion = cb->regionAtBlockOffset(cbPageOffset); | |
| 3430 if (cbRegion) { | |
| 3431 cbRegion = cb->clampToStartAndEndRegions(cbRegion); | |
| 3432 RenderBoxRegionInfo* boxInfo = cb->renderBoxRegionInfo(cbRegion); | |
| 3433 if (boxInfo) { | |
| 3434 logicalLeftPos += boxInfo->logicalLeft(); | |
| 3435 computedValues.m_position = logicalLeftPos; | |
| 3436 } | |
| 3437 } | |
| 3438 } | |
| 3439 } | 3218 } |
| 3440 | 3219 |
| 3441 static void computeLogicalLeftPositionedOffset(LayoutUnit& logicalLeftPos, const
RenderBox* child, LayoutUnit logicalWidthValue, const RenderBoxModelObject* con
tainerBlock, LayoutUnit containerLogicalWidth) | 3220 static void computeLogicalLeftPositionedOffset(LayoutUnit& logicalLeftPos, const
RenderBox* child, LayoutUnit logicalWidthValue, const RenderBoxModelObject* con
tainerBlock, LayoutUnit containerLogicalWidth) |
| 3442 { | 3221 { |
| 3443 // Deal with differing writing modes here. Our offset needs to be in the co
ntaining block's coordinate space. If the containing block is flipped | 3222 // Deal with differing writing modes here. Our offset needs to be in the co
ntaining block's coordinate space. If the containing block is flipped |
| 3444 // along this axis, then we need to flip the coordinate. This can only happ
en if the containing block is both a flipped mode and perpendicular to us. | 3223 // along this axis, then we need to flip the coordinate. This can only happ
en if the containing block is both a flipped mode and perpendicular to us. |
| 3445 if (containerBlock->isHorizontalWritingMode() != child->isHorizontalWritingM
ode() && containerBlock->style()->isFlippedBlocksWritingMode()) { | 3224 if (containerBlock->isHorizontalWritingMode() != child->isHorizontalWritingM
ode() && containerBlock->style()->isFlippedBlocksWritingMode()) { |
| 3446 logicalLeftPos = containerLogicalWidth - logicalWidthValue - logicalLeft
Pos; | 3225 logicalLeftPos = containerLogicalWidth - logicalWidthValue - logicalLeft
Pos; |
| 3447 logicalLeftPos += (child->isHorizontalWritingMode() ? containerBlock->bo
rderRight() : containerBlock->borderBottom()); | 3226 logicalLeftPos += (child->isHorizontalWritingMode() ? containerBlock->bo
rderRight() : containerBlock->borderBottom()); |
| 3448 } else | 3227 } else |
| (...skipping 16 matching lines...) Expand all Loading... |
| 3465 { | 3244 { |
| 3466 if (logicalWidth.isIntrinsic()) | 3245 if (logicalWidth.isIntrinsic()) |
| 3467 logicalWidth = Length(computeIntrinsicLogicalWidthUsing(logicalWidth, co
ntainerLogicalWidth, bordersPlusPadding) - bordersPlusPadding, Fixed); | 3246 logicalWidth = Length(computeIntrinsicLogicalWidthUsing(logicalWidth, co
ntainerLogicalWidth, bordersPlusPadding) - bordersPlusPadding, Fixed); |
| 3468 | 3247 |
| 3469 // 'left' and 'right' cannot both be 'auto' because one would of been | 3248 // 'left' and 'right' cannot both be 'auto' because one would of been |
| 3470 // converted to the static position already | 3249 // converted to the static position already |
| 3471 ASSERT(!(logicalLeft.isAuto() && logicalRight.isAuto())); | 3250 ASSERT(!(logicalLeft.isAuto() && logicalRight.isAuto())); |
| 3472 | 3251 |
| 3473 LayoutUnit logicalLeftValue = 0; | 3252 LayoutUnit logicalLeftValue = 0; |
| 3474 | 3253 |
| 3475 const LayoutUnit containerRelativeLogicalWidth = containingBlockLogicalWidth
ForPositioned(containerBlock, 0, false); | 3254 const LayoutUnit containerRelativeLogicalWidth = containingBlockLogicalWidth
ForPositioned(containerBlock, false); |
| 3476 | 3255 |
| 3477 bool logicalWidthIsAuto = logicalWidth.isIntrinsicOrAuto(); | 3256 bool logicalWidthIsAuto = logicalWidth.isIntrinsicOrAuto(); |
| 3478 bool logicalLeftIsAuto = logicalLeft.isAuto(); | 3257 bool logicalLeftIsAuto = logicalLeft.isAuto(); |
| 3479 bool logicalRightIsAuto = logicalRight.isAuto(); | 3258 bool logicalRightIsAuto = logicalRight.isAuto(); |
| 3480 LayoutUnit& marginLogicalLeftValue = style()->isLeftToRightDirection() ? com
putedValues.m_margins.m_start : computedValues.m_margins.m_end; | 3259 LayoutUnit& marginLogicalLeftValue = style()->isLeftToRightDirection() ? com
putedValues.m_margins.m_start : computedValues.m_margins.m_end; |
| 3481 LayoutUnit& marginLogicalRightValue = style()->isLeftToRightDirection() ? co
mputedValues.m_margins.m_end : computedValues.m_margins.m_start; | 3260 LayoutUnit& marginLogicalRightValue = style()->isLeftToRightDirection() ? co
mputedValues.m_margins.m_end : computedValues.m_margins.m_start; |
| 3482 if (!logicalLeftIsAuto && !logicalWidthIsAuto && !logicalRightIsAuto) { | 3261 if (!logicalLeftIsAuto && !logicalWidthIsAuto && !logicalRightIsAuto) { |
| 3483 /*----------------------------------------------------------------------
-*\ | 3262 /*----------------------------------------------------------------------
-*\ |
| 3484 * If none of the three is 'auto': If both 'margin-left' and 'margin- | 3263 * If none of the three is 'auto': If both 'margin-left' and 'margin- |
| 3485 * right' are 'auto', solve the equation under the extra constraint that | 3264 * right' are 'auto', solve the equation under the extra constraint that |
| (...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3739 if (computedValues.m_extent < minValues.m_extent) { | 3518 if (computedValues.m_extent < minValues.m_extent) { |
| 3740 computedValues.m_extent = minValues.m_extent; | 3519 computedValues.m_extent = minValues.m_extent; |
| 3741 computedValues.m_position = minValues.m_position; | 3520 computedValues.m_position = minValues.m_position; |
| 3742 computedValues.m_margins.m_before = minValues.m_margins.m_before; | 3521 computedValues.m_margins.m_before = minValues.m_margins.m_before; |
| 3743 computedValues.m_margins.m_after = minValues.m_margins.m_after; | 3522 computedValues.m_margins.m_after = minValues.m_margins.m_after; |
| 3744 } | 3523 } |
| 3745 } | 3524 } |
| 3746 | 3525 |
| 3747 // Set final height value. | 3526 // Set final height value. |
| 3748 computedValues.m_extent += bordersPlusPadding; | 3527 computedValues.m_extent += bordersPlusPadding; |
| 3749 | |
| 3750 // Adjust logicalTop if we need to for perpendicular writing modes in region
s. | |
| 3751 // FIXME: Add support for other types of objects as containerBlock, not only
RenderBlock. | |
| 3752 RenderFlowThread* flowThread = flowThreadContainingBlock(); | |
| 3753 if (flowThread && isHorizontalWritingMode() != containerBlock->isHorizontalW
ritingMode() && containerBlock->isRenderBlock()) { | |
| 3754 ASSERT(containerBlock->canHaveBoxInfoInRegion()); | |
| 3755 LayoutUnit logicalTopPos = computedValues.m_position; | |
| 3756 const RenderBlock* cb = toRenderBlock(containerBlock); | |
| 3757 LayoutUnit cbPageOffset = cb->offsetFromLogicalTopOfFirstPage() - logica
lLeft(); | |
| 3758 RenderRegion* cbRegion = cb->regionAtBlockOffset(cbPageOffset); | |
| 3759 if (cbRegion) { | |
| 3760 cbRegion = cb->clampToStartAndEndRegions(cbRegion); | |
| 3761 RenderBoxRegionInfo* boxInfo = cb->renderBoxRegionInfo(cbRegion); | |
| 3762 if (boxInfo) { | |
| 3763 logicalTopPos += boxInfo->logicalLeft(); | |
| 3764 computedValues.m_position = logicalTopPos; | |
| 3765 } | |
| 3766 } | |
| 3767 } | |
| 3768 } | 3528 } |
| 3769 | 3529 |
| 3770 static void computeLogicalTopPositionedOffset(LayoutUnit& logicalTopPos, const R
enderBox* child, LayoutUnit logicalHeightValue, const RenderBoxModelObject* cont
ainerBlock, LayoutUnit containerLogicalHeight) | 3530 static void computeLogicalTopPositionedOffset(LayoutUnit& logicalTopPos, const R
enderBox* child, LayoutUnit logicalHeightValue, const RenderBoxModelObject* cont
ainerBlock, LayoutUnit containerLogicalHeight) |
| 3771 { | 3531 { |
| 3772 // Deal with differing writing modes here. Our offset needs to be in the co
ntaining block's coordinate space. If the containing block is flipped | 3532 // Deal with differing writing modes here. Our offset needs to be in the co
ntaining block's coordinate space. If the containing block is flipped |
| 3773 // along this axis, then we need to flip the coordinate. This can only happ
en if the containing block is both a flipped mode and perpendicular to us. | 3533 // along this axis, then we need to flip the coordinate. This can only happ
en if the containing block is both a flipped mode and perpendicular to us. |
| 3774 if ((child->style()->isFlippedBlocksWritingMode() && child->isHorizontalWrit
ingMode() != containerBlock->isHorizontalWritingMode()) | 3534 if ((child->style()->isFlippedBlocksWritingMode() && child->isHorizontalWrit
ingMode() != containerBlock->isHorizontalWritingMode()) |
| 3775 || (child->style()->isFlippedBlocksWritingMode() != containerBlock->styl
e()->isFlippedBlocksWritingMode() && child->isHorizontalWritingMode() == contain
erBlock->isHorizontalWritingMode())) | 3535 || (child->style()->isFlippedBlocksWritingMode() != containerBlock->styl
e()->isFlippedBlocksWritingMode() && child->isHorizontalWritingMode() == contain
erBlock->isHorizontalWritingMode())) |
| 3776 logicalTopPos = containerLogicalHeight - logicalHeightValue - logicalTop
Pos; | 3536 logicalTopPos = containerLogicalHeight - logicalHeightValue - logicalTop
Pos; |
| 3777 | 3537 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 3794 Length logicalTop, Length lo
gicalBottom, Length marginBefore, Length marginAfter, | 3554 Length logicalTop, Length lo
gicalBottom, Length marginBefore, Length marginAfter, |
| 3795 LogicalExtentComputedValues&
computedValues) const | 3555 LogicalExtentComputedValues&
computedValues) const |
| 3796 { | 3556 { |
| 3797 // 'top' and 'bottom' cannot both be 'auto' because 'top would of been | 3557 // 'top' and 'bottom' cannot both be 'auto' because 'top would of been |
| 3798 // converted to the static position in computePositionedLogicalHeight() | 3558 // converted to the static position in computePositionedLogicalHeight() |
| 3799 ASSERT(!(logicalTop.isAuto() && logicalBottom.isAuto())); | 3559 ASSERT(!(logicalTop.isAuto() && logicalBottom.isAuto())); |
| 3800 | 3560 |
| 3801 LayoutUnit logicalHeightValue; | 3561 LayoutUnit logicalHeightValue; |
| 3802 LayoutUnit contentLogicalHeight = logicalHeight - bordersPlusPadding; | 3562 LayoutUnit contentLogicalHeight = logicalHeight - bordersPlusPadding; |
| 3803 | 3563 |
| 3804 const LayoutUnit containerRelativeLogicalWidth = containingBlockLogicalWidth
ForPositioned(containerBlock, 0, false); | 3564 const LayoutUnit containerRelativeLogicalWidth = containingBlockLogicalWidth
ForPositioned(containerBlock, false); |
| 3805 | 3565 |
| 3806 LayoutUnit logicalTopValue = 0; | 3566 LayoutUnit logicalTopValue = 0; |
| 3807 | 3567 |
| 3808 bool logicalHeightIsAuto = logicalHeightLength.isAuto(); | 3568 bool logicalHeightIsAuto = logicalHeightLength.isAuto(); |
| 3809 bool logicalTopIsAuto = logicalTop.isAuto(); | 3569 bool logicalTopIsAuto = logicalTop.isAuto(); |
| 3810 bool logicalBottomIsAuto = logicalBottom.isAuto(); | 3570 bool logicalBottomIsAuto = logicalBottom.isAuto(); |
| 3811 | 3571 |
| 3812 LayoutUnit resolvedLogicalHeight; | 3572 LayoutUnit resolvedLogicalHeight; |
| 3813 // Height is never unsolved for tables. | 3573 // Height is never unsolved for tables. |
| 3814 if (isTable()) { | 3574 if (isTable()) { |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3925 // CSS 2.1: Section 10.3.8 "Absolutely positioned, replaced elements" | 3685 // CSS 2.1: Section 10.3.8 "Absolutely positioned, replaced elements" |
| 3926 // <http://www.w3.org/TR/2005/WD-CSS21-20050613/visudet.html#abs-replaced-wi
dth> | 3686 // <http://www.w3.org/TR/2005/WD-CSS21-20050613/visudet.html#abs-replaced-wi
dth> |
| 3927 // (block-style-comments in this function correspond to text from the spec a
nd | 3687 // (block-style-comments in this function correspond to text from the spec a
nd |
| 3928 // the numbers correspond to numbers in spec) | 3688 // the numbers correspond to numbers in spec) |
| 3929 | 3689 |
| 3930 // We don't use containingBlock(), since we may be positioned by an enclosin
g | 3690 // We don't use containingBlock(), since we may be positioned by an enclosin
g |
| 3931 // relative positioned inline. | 3691 // relative positioned inline. |
| 3932 const RenderBoxModelObject* containerBlock = toRenderBoxModelObject(containe
r()); | 3692 const RenderBoxModelObject* containerBlock = toRenderBoxModelObject(containe
r()); |
| 3933 | 3693 |
| 3934 const LayoutUnit containerLogicalWidth = containingBlockLogicalWidthForPosit
ioned(containerBlock); | 3694 const LayoutUnit containerLogicalWidth = containingBlockLogicalWidthForPosit
ioned(containerBlock); |
| 3935 const LayoutUnit containerRelativeLogicalWidth = containingBlockLogicalWidth
ForPositioned(containerBlock, 0, false); | 3695 const LayoutUnit containerRelativeLogicalWidth = containingBlockLogicalWidth
ForPositioned(containerBlock, false); |
| 3936 | 3696 |
| 3937 // To match WinIE, in quirks mode use the parent's 'direction' property | 3697 // To match WinIE, in quirks mode use the parent's 'direction' property |
| 3938 // instead of the the container block's. | 3698 // instead of the the container block's. |
| 3939 TextDirection containerDirection = containerBlock->style()->direction(); | 3699 TextDirection containerDirection = containerBlock->style()->direction(); |
| 3940 | 3700 |
| 3941 // Variables to solve. | 3701 // Variables to solve. |
| 3942 bool isHorizontal = isHorizontalWritingMode(); | 3702 bool isHorizontal = isHorizontalWritingMode(); |
| 3943 Length logicalLeft = style()->logicalLeft(); | 3703 Length logicalLeft = style()->logicalLeft(); |
| 3944 Length logicalRight = style()->logicalRight(); | 3704 Length logicalRight = style()->logicalRight(); |
| 3945 Length marginLogicalLeft = isHorizontal ? style()->marginLeft() : style()->m
arginTop(); | 3705 Length marginLogicalLeft = isHorizontal ? style()->marginLeft() : style()->m
arginTop(); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 3957 computedValues.m_extent = computeReplacedLogicalWidth() + borderAndPaddingLo
gicalWidth(); | 3717 computedValues.m_extent = computeReplacedLogicalWidth() + borderAndPaddingLo
gicalWidth(); |
| 3958 | 3718 |
| 3959 const LayoutUnit availableSpace = containerLogicalWidth - computedValues.m_e
xtent; | 3719 const LayoutUnit availableSpace = containerLogicalWidth - computedValues.m_e
xtent; |
| 3960 | 3720 |
| 3961 /*-----------------------------------------------------------------------*\ | 3721 /*-----------------------------------------------------------------------*\ |
| 3962 * 2. If both 'left' and 'right' have the value 'auto', then if 'direction' | 3722 * 2. If both 'left' and 'right' have the value 'auto', then if 'direction' |
| 3963 * of the containing block is 'ltr', set 'left' to the static position; | 3723 * of the containing block is 'ltr', set 'left' to the static position; |
| 3964 * else if 'direction' is 'rtl', set 'right' to the static position. | 3724 * else if 'direction' is 'rtl', set 'right' to the static position. |
| 3965 \*-----------------------------------------------------------------------*/ | 3725 \*-----------------------------------------------------------------------*/ |
| 3966 // see FIXME 1 | 3726 // see FIXME 1 |
| 3967 computeInlineStaticDistance(logicalLeft, logicalRight, this, containerBlock,
containerLogicalWidth, 0); // FIXME: Pass the region. | 3727 computeInlineStaticDistance(logicalLeft, logicalRight, this, containerBlock,
containerLogicalWidth); |
| 3968 | 3728 |
| 3969 /*-----------------------------------------------------------------------*\ | 3729 /*-----------------------------------------------------------------------*\ |
| 3970 * 3. If 'left' or 'right' are 'auto', replace any 'auto' on 'margin-left' | 3730 * 3. If 'left' or 'right' are 'auto', replace any 'auto' on 'margin-left' |
| 3971 * or 'margin-right' with '0'. | 3731 * or 'margin-right' with '0'. |
| 3972 \*-----------------------------------------------------------------------*/ | 3732 \*-----------------------------------------------------------------------*/ |
| 3973 if (logicalLeft.isAuto() || logicalRight.isAuto()) { | 3733 if (logicalLeft.isAuto() || logicalRight.isAuto()) { |
| 3974 if (marginLogicalLeft.isAuto()) | 3734 if (marginLogicalLeft.isAuto()) |
| 3975 marginLogicalLeft.setValue(Fixed, 0); | 3735 marginLogicalLeft.setValue(Fixed, 0); |
| 3976 if (marginLogicalRight.isAuto()) | 3736 if (marginLogicalRight.isAuto()) |
| 3977 marginLogicalRight.setValue(Fixed, 0); | 3737 marginLogicalRight.setValue(Fixed, 0); |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4093 // The following is based off of the W3C Working Draft from April 11, 2006 o
f | 3853 // The following is based off of the W3C Working Draft from April 11, 2006 o
f |
| 4094 // CSS 2.1: Section 10.6.5 "Absolutely positioned, replaced elements" | 3854 // CSS 2.1: Section 10.6.5 "Absolutely positioned, replaced elements" |
| 4095 // <http://www.w3.org/TR/2005/WD-CSS21-20050613/visudet.html#abs-replaced-he
ight> | 3855 // <http://www.w3.org/TR/2005/WD-CSS21-20050613/visudet.html#abs-replaced-he
ight> |
| 4096 // (block-style-comments in this function correspond to text from the spec a
nd | 3856 // (block-style-comments in this function correspond to text from the spec a
nd |
| 4097 // the numbers correspond to numbers in spec) | 3857 // the numbers correspond to numbers in spec) |
| 4098 | 3858 |
| 4099 // We don't use containingBlock(), since we may be positioned by an enclosin
g relpositioned inline. | 3859 // We don't use containingBlock(), since we may be positioned by an enclosin
g relpositioned inline. |
| 4100 const RenderBoxModelObject* containerBlock = toRenderBoxModelObject(containe
r()); | 3860 const RenderBoxModelObject* containerBlock = toRenderBoxModelObject(containe
r()); |
| 4101 | 3861 |
| 4102 const LayoutUnit containerLogicalHeight = containingBlockLogicalHeightForPos
itioned(containerBlock); | 3862 const LayoutUnit containerLogicalHeight = containingBlockLogicalHeightForPos
itioned(containerBlock); |
| 4103 const LayoutUnit containerRelativeLogicalWidth = containingBlockLogicalWidth
ForPositioned(containerBlock, 0, false); | 3863 const LayoutUnit containerRelativeLogicalWidth = containingBlockLogicalWidth
ForPositioned(containerBlock, false); |
| 4104 | 3864 |
| 4105 // Variables to solve. | 3865 // Variables to solve. |
| 4106 Length marginBefore = style()->marginBefore(); | 3866 Length marginBefore = style()->marginBefore(); |
| 4107 Length marginAfter = style()->marginAfter(); | 3867 Length marginAfter = style()->marginAfter(); |
| 4108 LayoutUnit& marginBeforeAlias = computedValues.m_margins.m_before; | 3868 LayoutUnit& marginBeforeAlias = computedValues.m_margins.m_before; |
| 4109 LayoutUnit& marginAfterAlias = computedValues.m_margins.m_after; | 3869 LayoutUnit& marginAfterAlias = computedValues.m_margins.m_after; |
| 4110 | 3870 |
| 4111 Length logicalTop = style()->logicalTop(); | 3871 Length logicalTop = style()->logicalTop(); |
| 4112 Length logicalBottom = style()->logicalBottom(); | 3872 Length logicalBottom = style()->logicalBottom(); |
| 4113 | 3873 |
| (...skipping 794 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4908 return 0; | 4668 return 0; |
| 4909 | 4669 |
| 4910 if (!layoutState && !flowThreadContainingBlock()) | 4670 if (!layoutState && !flowThreadContainingBlock()) |
| 4911 return 0; | 4671 return 0; |
| 4912 | 4672 |
| 4913 RenderBlock* containerBlock = containingBlock(); | 4673 RenderBlock* containerBlock = containingBlock(); |
| 4914 return containerBlock->offsetFromLogicalTopOfFirstPage() + logicalTop(); | 4674 return containerBlock->offsetFromLogicalTopOfFirstPage() + logicalTop(); |
| 4915 } | 4675 } |
| 4916 | 4676 |
| 4917 } // namespace WebCore | 4677 } // namespace WebCore |
| OLD | NEW |