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