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