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