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