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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 #include "core/rendering/RenderGeometryMap.h" | 48 #include "core/rendering/RenderGeometryMap.h" |
49 #include "core/rendering/RenderGrid.h" | 49 #include "core/rendering/RenderGrid.h" |
50 #include "core/rendering/RenderInline.h" | 50 #include "core/rendering/RenderInline.h" |
51 #include "core/rendering/RenderLayer.h" | 51 #include "core/rendering/RenderLayer.h" |
52 #include "core/rendering/RenderLayerCompositor.h" | 52 #include "core/rendering/RenderLayerCompositor.h" |
53 #include "core/rendering/RenderListMarker.h" | 53 #include "core/rendering/RenderListMarker.h" |
54 #include "core/rendering/RenderRegion.h" | 54 #include "core/rendering/RenderRegion.h" |
55 #include "core/rendering/RenderTableCell.h" | 55 #include "core/rendering/RenderTableCell.h" |
56 #include "core/rendering/RenderTheme.h" | 56 #include "core/rendering/RenderTheme.h" |
57 #include "core/rendering/RenderView.h" | 57 #include "core/rendering/RenderView.h" |
| 58 #include "platform/LengthFunctions.h" |
58 #include "platform/geometry/FloatQuad.h" | 59 #include "platform/geometry/FloatQuad.h" |
59 #include "platform/geometry/TransformState.h" | 60 #include "platform/geometry/TransformState.h" |
60 #include "platform/graphics/GraphicsContextStateSaver.h" | 61 #include "platform/graphics/GraphicsContextStateSaver.h" |
61 | 62 |
62 using namespace std; | 63 using namespace std; |
63 | 64 |
64 namespace WebCore { | 65 namespace WebCore { |
65 | 66 |
66 using namespace HTMLNames; | 67 using namespace HTMLNames; |
67 | 68 |
(...skipping 652 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
720 result.move(box.width() + reflectionOffset(), 0); | 721 result.move(box.width() + reflectionOffset(), 0); |
721 break; | 722 break; |
722 } | 723 } |
723 return result; | 724 return result; |
724 } | 725 } |
725 | 726 |
726 int RenderBox::reflectionOffset() const | 727 int RenderBox::reflectionOffset() const |
727 { | 728 { |
728 if (!style()->boxReflect()) | 729 if (!style()->boxReflect()) |
729 return 0; | 730 return 0; |
730 RenderView* renderView = view(); | |
731 if (style()->boxReflect()->direction() == ReflectionLeft || style()->boxRefl
ect()->direction() == ReflectionRight) | 731 if (style()->boxReflect()->direction() == ReflectionLeft || style()->boxRefl
ect()->direction() == ReflectionRight) |
732 return valueForLength(style()->boxReflect()->offset(), borderBoxRect().w
idth(), renderView); | 732 return valueForLength(style()->boxReflect()->offset(), borderBoxRect().w
idth()); |
733 return valueForLength(style()->boxReflect()->offset(), borderBoxRect().heigh
t(), renderView); | 733 return valueForLength(style()->boxReflect()->offset(), borderBoxRect().heigh
t()); |
734 } | 734 } |
735 | 735 |
736 LayoutRect RenderBox::reflectedRect(const LayoutRect& r) const | 736 LayoutRect RenderBox::reflectedRect(const LayoutRect& r) const |
737 { | 737 { |
738 if (!style()->boxReflect()) | 738 if (!style()->boxReflect()) |
739 return LayoutRect(); | 739 return LayoutRect(); |
740 | 740 |
741 LayoutRect box = borderBoxRect(); | 741 LayoutRect box = borderBoxRect(); |
742 LayoutRect result = r; | 742 LayoutRect result = r; |
743 switch (style()->boxReflect()->direction()) { | 743 switch (style()->boxReflect()->direction()) { |
(...skipping 533 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1277 // FIXME: Should eventually give the theme control over whether the box shad
ow should paint, since controls could have | 1277 // FIXME: Should eventually give the theme control over whether the box shad
ow should paint, since controls could have |
1278 // custom shadows of their own. | 1278 // custom shadows of their own. |
1279 if (!boxShadowShouldBeAppliedToBackground(bleedAvoidance)) | 1279 if (!boxShadowShouldBeAppliedToBackground(bleedAvoidance)) |
1280 paintBoxShadow(paintInfo, paintRect, style(), Normal); | 1280 paintBoxShadow(paintInfo, paintRect, style(), Normal); |
1281 | 1281 |
1282 GraphicsContextStateSaver stateSaver(*paintInfo.context, false); | 1282 GraphicsContextStateSaver stateSaver(*paintInfo.context, false); |
1283 if (bleedAvoidance == BackgroundBleedUseTransparencyLayer) { | 1283 if (bleedAvoidance == BackgroundBleedUseTransparencyLayer) { |
1284 // To avoid the background color bleeding out behind the border, we'll r
ender background and border | 1284 // To avoid the background color bleeding out behind the border, we'll r
ender background and border |
1285 // into a transparency layer, and then clip that in one go (which requir
es setting up the clip before | 1285 // into a transparency layer, and then clip that in one go (which requir
es setting up the clip before |
1286 // beginning the layer). | 1286 // beginning the layer). |
1287 RoundedRect border = style()->getRoundedBorderFor(paintRect, view()); | 1287 RoundedRect border = style()->getRoundedBorderFor(paintRect); |
1288 stateSaver.save(); | 1288 stateSaver.save(); |
1289 paintInfo.context->clipRoundedRect(border); | 1289 paintInfo.context->clipRoundedRect(border); |
1290 paintInfo.context->beginTransparencyLayer(1); | 1290 paintInfo.context->beginTransparencyLayer(1); |
1291 } | 1291 } |
1292 | 1292 |
1293 paintBackgroundWithBorderAndBoxShadow(paintInfo, paintRect, bleedAvoidance); | 1293 paintBackgroundWithBorderAndBoxShadow(paintInfo, paintRect, bleedAvoidance); |
1294 | 1294 |
1295 if (bleedAvoidance == BackgroundBleedUseTransparencyLayer) | 1295 if (bleedAvoidance == BackgroundBleedUseTransparencyLayer) |
1296 paintInfo.context->endLayer(); | 1296 paintInfo.context->endLayer(); |
1297 } | 1297 } |
(...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1763 clipRect.move(layer()->scrollableArea()->verticalScrollbarWidth(relevanc
y), 0); | 1763 clipRect.move(layer()->scrollableArea()->verticalScrollbarWidth(relevanc
y), 0); |
1764 clipRect.contract(layer()->scrollableArea()->verticalScrollbarWidth(relevanc
y), layer()->scrollableArea()->horizontalScrollbarHeight(relevancy)); | 1764 clipRect.contract(layer()->scrollableArea()->verticalScrollbarWidth(relevanc
y), layer()->scrollableArea()->horizontalScrollbarHeight(relevancy)); |
1765 | 1765 |
1766 return clipRect; | 1766 return clipRect; |
1767 } | 1767 } |
1768 | 1768 |
1769 LayoutRect RenderBox::clipRect(const LayoutPoint& location, RenderRegion* region
) | 1769 LayoutRect RenderBox::clipRect(const LayoutPoint& location, RenderRegion* region
) |
1770 { | 1770 { |
1771 LayoutRect borderBoxRect = borderBoxRectInRegion(region); | 1771 LayoutRect borderBoxRect = borderBoxRectInRegion(region); |
1772 LayoutRect clipRect = LayoutRect(borderBoxRect.location() + location, border
BoxRect.size()); | 1772 LayoutRect clipRect = LayoutRect(borderBoxRect.location() + location, border
BoxRect.size()); |
1773 RenderView* renderView = view(); | |
1774 | 1773 |
1775 if (!style()->clipLeft().isAuto()) { | 1774 if (!style()->clipLeft().isAuto()) { |
1776 LayoutUnit c = valueForLength(style()->clipLeft(), borderBoxRect.width()
, renderView); | 1775 LayoutUnit c = valueForLength(style()->clipLeft(), borderBoxRect.width()
); |
1777 clipRect.move(c, 0); | 1776 clipRect.move(c, 0); |
1778 clipRect.contract(c, 0); | 1777 clipRect.contract(c, 0); |
1779 } | 1778 } |
1780 | 1779 |
1781 // We don't use the region-specific border box's width and height since clip
offsets are (stupidly) specified | 1780 // We don't use the region-specific border box's width and height since clip
offsets are (stupidly) specified |
1782 // from the left and top edges. Therefore it's better to avoid constraining
to smaller widths and heights. | 1781 // from the left and top edges. Therefore it's better to avoid constraining
to smaller widths and heights. |
1783 | 1782 |
1784 if (!style()->clipRight().isAuto()) | 1783 if (!style()->clipRight().isAuto()) |
1785 clipRect.contract(width() - valueForLength(style()->clipRight(), width()
, renderView), 0); | 1784 clipRect.contract(width() - valueForLength(style()->clipRight(), width()
), 0); |
1786 | 1785 |
1787 if (!style()->clipTop().isAuto()) { | 1786 if (!style()->clipTop().isAuto()) { |
1788 LayoutUnit c = valueForLength(style()->clipTop(), borderBoxRect.height()
, renderView); | 1787 LayoutUnit c = valueForLength(style()->clipTop(), borderBoxRect.height()
); |
1789 clipRect.move(0, c); | 1788 clipRect.move(0, c); |
1790 clipRect.contract(0, c); | 1789 clipRect.contract(0, c); |
1791 } | 1790 } |
1792 | 1791 |
1793 if (!style()->clipBottom().isAuto()) | 1792 if (!style()->clipBottom().isAuto()) |
1794 clipRect.contract(0, height() - valueForLength(style()->clipBottom(), he
ight(), renderView)); | 1793 clipRect.contract(0, height() - valueForLength(style()->clipBottom(), he
ight())); |
1795 | 1794 |
1796 return clipRect; | 1795 return clipRect; |
1797 } | 1796 } |
1798 | 1797 |
1799 LayoutUnit RenderBox::shrinkLogicalWidthToAvoidFloats(LayoutUnit childMarginStar
t, LayoutUnit childMarginEnd, const RenderBlockFlow* cb, RenderRegion* region) c
onst | 1798 LayoutUnit RenderBox::shrinkLogicalWidthToAvoidFloats(LayoutUnit childMarginStar
t, LayoutUnit childMarginEnd, const RenderBlockFlow* cb, RenderRegion* region) c
onst |
1800 { | 1799 { |
1801 RenderRegion* containingBlockRegion = 0; | 1800 RenderRegion* containingBlockRegion = 0; |
1802 LayoutUnit logicalTopPosition = logicalTop(); | 1801 LayoutUnit logicalTopPosition = logicalTop(); |
1803 if (region) { | 1802 if (region) { |
1804 LayoutUnit offsetFromLogicalTopOfRegion = region ? region->logicalTopFor
FlowThreadContent() - offsetFromLogicalTopOfFirstPage() : LayoutUnit(); | 1803 LayoutUnit offsetFromLogicalTopOfRegion = region ? region->logicalTopFor
FlowThreadContent() - offsetFromLogicalTopOfFirstPage() : LayoutUnit(); |
(...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2302 | 2301 |
2303 RenderStyle* styleToUse = style(); | 2302 RenderStyle* styleToUse = style(); |
2304 Length logicalWidthLength = treatAsReplaced ? Length(computeReplacedLogicalW
idth(), Fixed) : styleToUse->logicalWidth(); | 2303 Length logicalWidthLength = treatAsReplaced ? Length(computeReplacedLogicalW
idth(), Fixed) : styleToUse->logicalWidth(); |
2305 | 2304 |
2306 RenderBlock* cb = containingBlock(); | 2305 RenderBlock* cb = containingBlock(); |
2307 LayoutUnit containerLogicalWidth = max<LayoutUnit>(0, containingBlockLogical
WidthForContentInRegion(region)); | 2306 LayoutUnit containerLogicalWidth = max<LayoutUnit>(0, containingBlockLogical
WidthForContentInRegion(region)); |
2308 bool hasPerpendicularContainingBlock = cb->isHorizontalWritingMode() != isHo
rizontalWritingMode(); | 2307 bool hasPerpendicularContainingBlock = cb->isHorizontalWritingMode() != isHo
rizontalWritingMode(); |
2309 | 2308 |
2310 if (isInline() && !isInlineBlockOrInlineTable()) { | 2309 if (isInline() && !isInlineBlockOrInlineTable()) { |
2311 // just calculate margins | 2310 // just calculate margins |
2312 RenderView* renderView = view(); | 2311 computedValues.m_margins.m_start = minimumValueForLength(styleToUse->mar
ginStart(), containerLogicalWidth); |
2313 computedValues.m_margins.m_start = minimumValueForLength(styleToUse->mar
ginStart(), containerLogicalWidth, renderView); | 2312 computedValues.m_margins.m_end = minimumValueForLength(styleToUse->margi
nEnd(), containerLogicalWidth); |
2314 computedValues.m_margins.m_end = minimumValueForLength(styleToUse->margi
nEnd(), containerLogicalWidth, renderView); | |
2315 if (treatAsReplaced) | 2313 if (treatAsReplaced) |
2316 computedValues.m_extent = max<LayoutUnit>(floatValueForLength(logica
lWidthLength, 0, 0) + borderAndPaddingLogicalWidth(), minPreferredLogicalWidth()
); | 2314 computedValues.m_extent = max<LayoutUnit>(floatValueForLength(logica
lWidthLength, 0) + borderAndPaddingLogicalWidth(), minPreferredLogicalWidth()); |
2317 return; | 2315 return; |
2318 } | 2316 } |
2319 | 2317 |
2320 // Width calculations | 2318 // Width calculations |
2321 if (treatAsReplaced) | 2319 if (treatAsReplaced) |
2322 computedValues.m_extent = logicalWidthLength.value() + borderAndPaddingL
ogicalWidth(); | 2320 computedValues.m_extent = logicalWidthLength.value() + borderAndPaddingL
ogicalWidth(); |
2323 else { | 2321 else { |
2324 LayoutUnit containerWidthInInlineDirection = containerLogicalWidth; | 2322 LayoutUnit containerWidthInInlineDirection = containerLogicalWidth; |
2325 if (hasPerpendicularContainingBlock) | 2323 if (hasPerpendicularContainingBlock) |
2326 containerWidthInInlineDirection = perpendicularContainingBlockLogica
lHeight(); | 2324 containerWidthInInlineDirection = perpendicularContainingBlockLogica
lHeight(); |
2327 LayoutUnit preferredWidth = computeLogicalWidthInRegionUsing(MainOrPrefe
rredSize, styleToUse->logicalWidth(), containerWidthInInlineDirection, cb, regio
n); | 2325 LayoutUnit preferredWidth = computeLogicalWidthInRegionUsing(MainOrPrefe
rredSize, styleToUse->logicalWidth(), containerWidthInInlineDirection, cb, regio
n); |
2328 computedValues.m_extent = constrainLogicalWidthInRegionByMinMax(preferre
dWidth, containerWidthInInlineDirection, cb, region); | 2326 computedValues.m_extent = constrainLogicalWidthInRegionByMinMax(preferre
dWidth, containerWidthInInlineDirection, cb, region); |
2329 } | 2327 } |
2330 | 2328 |
2331 // Margin calculations. | 2329 // Margin calculations. |
2332 if (hasPerpendicularContainingBlock || isFloating() || isInline()) { | 2330 if (hasPerpendicularContainingBlock || isFloating() || isInline()) { |
2333 RenderView* renderView = view(); | 2331 computedValues.m_margins.m_start = minimumValueForLength(styleToUse->mar
ginStart(), containerLogicalWidth); |
2334 computedValues.m_margins.m_start = minimumValueForLength(styleToUse->mar
ginStart(), containerLogicalWidth, renderView); | 2332 computedValues.m_margins.m_end = minimumValueForLength(styleToUse->margi
nEnd(), containerLogicalWidth); |
2335 computedValues.m_margins.m_end = minimumValueForLength(styleToUse->margi
nEnd(), containerLogicalWidth, renderView); | |
2336 } else { | 2333 } else { |
2337 LayoutUnit containerLogicalWidthForAutoMargins = containerLogicalWidth; | 2334 LayoutUnit containerLogicalWidthForAutoMargins = containerLogicalWidth; |
2338 if (avoidsFloats() && cb->containsFloats()) | 2335 if (avoidsFloats() && cb->containsFloats()) |
2339 containerLogicalWidthForAutoMargins = containingBlockAvailableLineWi
dthInRegion(region); | 2336 containerLogicalWidthForAutoMargins = containingBlockAvailableLineWi
dthInRegion(region); |
2340 bool hasInvertedDirection = cb->style()->isLeftToRightDirection() != sty
le()->isLeftToRightDirection(); | 2337 bool hasInvertedDirection = cb->style()->isLeftToRightDirection() != sty
le()->isLeftToRightDirection(); |
2341 computeInlineDirectionMargins(cb, containerLogicalWidthForAutoMargins, c
omputedValues.m_extent, | 2338 computeInlineDirectionMargins(cb, containerLogicalWidthForAutoMargins, c
omputedValues.m_extent, |
2342 hasInvertedDirection ? computedValues.m_margins.m_end : computedValu
es.m_margins.m_start, | 2339 hasInvertedDirection ? computedValues.m_margins.m_end : computedValu
es.m_margins.m_start, |
2343 hasInvertedDirection ? computedValues.m_margins.m_start : computedVa
lues.m_margins.m_end); | 2340 hasInvertedDirection ? computedValues.m_margins.m_start : computedVa
lues.m_margins.m_end); |
2344 } | 2341 } |
2345 | 2342 |
(...skipping 23 matching lines...) Expand all Loading... |
2369 | 2366 |
2370 LayoutUnit RenderBox::fillAvailableMeasure(LayoutUnit availableLogicalWidth) con
st | 2367 LayoutUnit RenderBox::fillAvailableMeasure(LayoutUnit availableLogicalWidth) con
st |
2371 { | 2368 { |
2372 LayoutUnit marginStart = 0; | 2369 LayoutUnit marginStart = 0; |
2373 LayoutUnit marginEnd = 0; | 2370 LayoutUnit marginEnd = 0; |
2374 return fillAvailableMeasure(availableLogicalWidth, marginStart, marginEnd); | 2371 return fillAvailableMeasure(availableLogicalWidth, marginStart, marginEnd); |
2375 } | 2372 } |
2376 | 2373 |
2377 LayoutUnit RenderBox::fillAvailableMeasure(LayoutUnit availableLogicalWidth, Lay
outUnit& marginStart, LayoutUnit& marginEnd) const | 2374 LayoutUnit RenderBox::fillAvailableMeasure(LayoutUnit availableLogicalWidth, Lay
outUnit& marginStart, LayoutUnit& marginEnd) const |
2378 { | 2375 { |
2379 RenderView* renderView = view(); | 2376 marginStart = minimumValueForLength(style()->marginStart(), availableLogical
Width); |
2380 marginStart = minimumValueForLength(style()->marginStart(), availableLogical
Width, renderView); | 2377 marginEnd = minimumValueForLength(style()->marginEnd(), availableLogicalWidt
h); |
2381 marginEnd = minimumValueForLength(style()->marginEnd(), availableLogicalWidt
h, renderView); | |
2382 return availableLogicalWidth - marginStart - marginEnd; | 2378 return availableLogicalWidth - marginStart - marginEnd; |
2383 } | 2379 } |
2384 | 2380 |
2385 LayoutUnit RenderBox::computeIntrinsicLogicalWidthUsing(Length logicalWidthLengt
h, LayoutUnit availableLogicalWidth, LayoutUnit borderAndPadding) const | 2381 LayoutUnit RenderBox::computeIntrinsicLogicalWidthUsing(Length logicalWidthLengt
h, LayoutUnit availableLogicalWidth, LayoutUnit borderAndPadding) const |
2386 { | 2382 { |
2387 if (logicalWidthLength.type() == FillAvailable) | 2383 if (logicalWidthLength.type() == FillAvailable) |
2388 return fillAvailableMeasure(availableLogicalWidth); | 2384 return fillAvailableMeasure(availableLogicalWidth); |
2389 | 2385 |
2390 LayoutUnit minLogicalWidth = 0; | 2386 LayoutUnit minLogicalWidth = 0; |
2391 LayoutUnit maxLogicalWidth = 0; | 2387 LayoutUnit maxLogicalWidth = 0; |
(...skipping 13 matching lines...) Expand all Loading... |
2405 | 2401 |
2406 ASSERT_NOT_REACHED(); | 2402 ASSERT_NOT_REACHED(); |
2407 return 0; | 2403 return 0; |
2408 } | 2404 } |
2409 | 2405 |
2410 LayoutUnit RenderBox::computeLogicalWidthInRegionUsing(SizeType widthType, Lengt
h logicalWidth, LayoutUnit availableLogicalWidth, | 2406 LayoutUnit RenderBox::computeLogicalWidthInRegionUsing(SizeType widthType, Lengt
h logicalWidth, LayoutUnit availableLogicalWidth, |
2411 const RenderBlock* cb, RenderRegion* region) const | 2407 const RenderBlock* cb, RenderRegion* region) const |
2412 { | 2408 { |
2413 if (!logicalWidth.isIntrinsicOrAuto()) { | 2409 if (!logicalWidth.isIntrinsicOrAuto()) { |
2414 // FIXME: If the containing block flow is perpendicular to our direction
we need to use the available logical height instead. | 2410 // FIXME: If the containing block flow is perpendicular to our direction
we need to use the available logical height instead. |
2415 return adjustBorderBoxLogicalWidthForBoxSizing(valueForLength(logicalWid
th, availableLogicalWidth, view())); | 2411 return adjustBorderBoxLogicalWidthForBoxSizing(valueForLength(logicalWid
th, availableLogicalWidth)); |
2416 } | 2412 } |
2417 | 2413 |
2418 if (logicalWidth.isIntrinsic()) | 2414 if (logicalWidth.isIntrinsic()) |
2419 return computeIntrinsicLogicalWidthUsing(logicalWidth, availableLogicalW
idth, borderAndPaddingLogicalWidth()); | 2415 return computeIntrinsicLogicalWidthUsing(logicalWidth, availableLogicalW
idth, borderAndPaddingLogicalWidth()); |
2420 | 2416 |
2421 LayoutUnit marginStart = 0; | 2417 LayoutUnit marginStart = 0; |
2422 LayoutUnit marginEnd = 0; | 2418 LayoutUnit marginEnd = 0; |
2423 LayoutUnit logicalWidthResult = fillAvailableMeasure(availableLogicalWidth,
marginStart, marginEnd); | 2419 LayoutUnit logicalWidthResult = fillAvailableMeasure(availableLogicalWidth,
marginStart, marginEnd); |
2424 | 2420 |
2425 if (shrinkToAvoidFloats() && cb->containsFloats()) | 2421 if (shrinkToAvoidFloats() && cb->containsFloats()) |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2512 { | 2508 { |
2513 return node() && (node()->hasTagName(inputTag) || node()->hasTagName(selectT
ag) || node()->hasTagName(buttonTag) | 2509 return node() && (node()->hasTagName(inputTag) || node()->hasTagName(selectT
ag) || node()->hasTagName(buttonTag) |
2514 || node()->hasTagName(textareaTag) || node()->hasTagName(legendTag)); | 2510 || node()->hasTagName(textareaTag) || node()->hasTagName(legendTag)); |
2515 } | 2511 } |
2516 | 2512 |
2517 void RenderBox::computeInlineDirectionMargins(RenderBlock* containingBlock, Layo
utUnit containerWidth, LayoutUnit childWidth, LayoutUnit& marginStart, LayoutUni
t& marginEnd) const | 2513 void RenderBox::computeInlineDirectionMargins(RenderBlock* containingBlock, Layo
utUnit containerWidth, LayoutUnit childWidth, LayoutUnit& marginStart, LayoutUni
t& marginEnd) const |
2518 { | 2514 { |
2519 const RenderStyle* containingBlockStyle = containingBlock->style(); | 2515 const RenderStyle* containingBlockStyle = containingBlock->style(); |
2520 Length marginStartLength = style()->marginStartUsing(containingBlockStyle); | 2516 Length marginStartLength = style()->marginStartUsing(containingBlockStyle); |
2521 Length marginEndLength = style()->marginEndUsing(containingBlockStyle); | 2517 Length marginEndLength = style()->marginEndUsing(containingBlockStyle); |
2522 RenderView* renderView = view(); | |
2523 | 2518 |
2524 if (isFloating() || isInline()) { | 2519 if (isFloating() || isInline()) { |
2525 // Inline blocks/tables and floats don't have their margins increased. | 2520 // Inline blocks/tables and floats don't have their margins increased. |
2526 marginStart = minimumValueForLength(marginStartLength, containerWidth, r
enderView); | 2521 marginStart = minimumValueForLength(marginStartLength, containerWidth); |
2527 marginEnd = minimumValueForLength(marginEndLength, containerWidth, rende
rView); | 2522 marginEnd = minimumValueForLength(marginEndLength, containerWidth); |
2528 return; | 2523 return; |
2529 } | 2524 } |
2530 | 2525 |
2531 if (containingBlock->isFlexibleBox()) { | 2526 if (containingBlock->isFlexibleBox()) { |
2532 // We need to let flexbox handle the margin adjustment - otherwise, flex
box | 2527 // We need to let flexbox handle the margin adjustment - otherwise, flex
box |
2533 // will think we're wider than we actually are and calculate line sizes
wrong. | 2528 // will think we're wider than we actually are and calculate line sizes
wrong. |
2534 // See also http://dev.w3.org/csswg/css-flexbox/#auto-margins | 2529 // See also http://dev.w3.org/csswg/css-flexbox/#auto-margins |
2535 if (marginStartLength.isAuto()) | 2530 if (marginStartLength.isAuto()) |
2536 marginStartLength.setValue(0); | 2531 marginStartLength.setValue(0); |
2537 if (marginEndLength.isAuto()) | 2532 if (marginEndLength.isAuto()) |
2538 marginEndLength.setValue(0); | 2533 marginEndLength.setValue(0); |
2539 } | 2534 } |
2540 | 2535 |
2541 // Case One: The object is being centered in the containing block's availabl
e logical width. | 2536 // Case One: The object is being centered in the containing block's availabl
e logical width. |
2542 if ((marginStartLength.isAuto() && marginEndLength.isAuto() && childWidth <
containerWidth) | 2537 if ((marginStartLength.isAuto() && marginEndLength.isAuto() && childWidth <
containerWidth) |
2543 || (!marginStartLength.isAuto() && !marginEndLength.isAuto() && containi
ngBlock->style()->textAlign() == WEBKIT_CENTER)) { | 2538 || (!marginStartLength.isAuto() && !marginEndLength.isAuto() && containi
ngBlock->style()->textAlign() == WEBKIT_CENTER)) { |
2544 // Other browsers center the margin box for align=center elements so we
match them here. | 2539 // Other browsers center the margin box for align=center elements so we
match them here. |
2545 LayoutUnit marginStartWidth = minimumValueForLength(marginStartLength, c
ontainerWidth, renderView); | 2540 LayoutUnit marginStartWidth = minimumValueForLength(marginStartLength, c
ontainerWidth); |
2546 LayoutUnit marginEndWidth = minimumValueForLength(marginEndLength, conta
inerWidth, renderView); | 2541 LayoutUnit marginEndWidth = minimumValueForLength(marginEndLength, conta
inerWidth); |
2547 LayoutUnit centeredMarginBoxStart = max<LayoutUnit>(0, (containerWidth -
childWidth - marginStartWidth - marginEndWidth) / 2); | 2542 LayoutUnit centeredMarginBoxStart = max<LayoutUnit>(0, (containerWidth -
childWidth - marginStartWidth - marginEndWidth) / 2); |
2548 marginStart = centeredMarginBoxStart + marginStartWidth; | 2543 marginStart = centeredMarginBoxStart + marginStartWidth; |
2549 marginEnd = containerWidth - childWidth - marginStart + marginEndWidth; | 2544 marginEnd = containerWidth - childWidth - marginStart + marginEndWidth; |
2550 return; | 2545 return; |
2551 } | 2546 } |
2552 | 2547 |
2553 // Case Two: The object is being pushed to the start of the containing block
's available logical width. | 2548 // Case Two: The object is being pushed to the start of the containing block
's available logical width. |
2554 if (marginEndLength.isAuto() && childWidth < containerWidth) { | 2549 if (marginEndLength.isAuto() && childWidth < containerWidth) { |
2555 marginStart = valueForLength(marginStartLength, containerWidth, renderVi
ew); | 2550 marginStart = valueForLength(marginStartLength, containerWidth); |
2556 marginEnd = containerWidth - childWidth - marginStart; | 2551 marginEnd = containerWidth - childWidth - marginStart; |
2557 return; | 2552 return; |
2558 } | 2553 } |
2559 | 2554 |
2560 // Case Three: The object is being pushed to the end of the containing block
's available logical width. | 2555 // Case Three: The object is being pushed to the end of the containing block
's available logical width. |
2561 bool pushToEndFromTextAlign = !marginEndLength.isAuto() && ((!containingBloc
kStyle->isLeftToRightDirection() && containingBlockStyle->textAlign() == WEBKIT_
LEFT) | 2556 bool pushToEndFromTextAlign = !marginEndLength.isAuto() && ((!containingBloc
kStyle->isLeftToRightDirection() && containingBlockStyle->textAlign() == WEBKIT_
LEFT) |
2562 || (containingBlockStyle->isLeftToRightDirection() && containingBlockSty
le->textAlign() == WEBKIT_RIGHT)); | 2557 || (containingBlockStyle->isLeftToRightDirection() && containingBlockSty
le->textAlign() == WEBKIT_RIGHT)); |
2563 if ((marginStartLength.isAuto() && childWidth < containerWidth) || pushToEnd
FromTextAlign) { | 2558 if ((marginStartLength.isAuto() && childWidth < containerWidth) || pushToEnd
FromTextAlign) { |
2564 marginEnd = valueForLength(marginEndLength, containerWidth, renderView); | 2559 marginEnd = valueForLength(marginEndLength, containerWidth); |
2565 marginStart = containerWidth - childWidth - marginEnd; | 2560 marginStart = containerWidth - childWidth - marginEnd; |
2566 return; | 2561 return; |
2567 } | 2562 } |
2568 | 2563 |
2569 // Case Four: Either no auto margins, or our width is >= the container width
(css2.1, 10.3.3). In that case | 2564 // Case Four: Either no auto margins, or our width is >= the container width
(css2.1, 10.3.3). In that case |
2570 // auto margins will just turn into 0. | 2565 // auto margins will just turn into 0. |
2571 marginStart = minimumValueForLength(marginStartLength, containerWidth, rende
rView); | 2566 marginStart = minimumValueForLength(marginStartLength, containerWidth); |
2572 marginEnd = minimumValueForLength(marginEndLength, containerWidth, renderVie
w); | 2567 marginEnd = minimumValueForLength(marginEndLength, containerWidth); |
2573 } | 2568 } |
2574 | 2569 |
2575 RenderBoxRegionInfo* RenderBox::renderBoxRegionInfo(RenderRegion* region, Render
BoxRegionInfoFlags cacheFlag) const | 2570 RenderBoxRegionInfo* RenderBox::renderBoxRegionInfo(RenderRegion* region, Render
BoxRegionInfoFlags cacheFlag) const |
2576 { | 2571 { |
2577 // Make sure nobody is trying to call this with a null region. | 2572 // Make sure nobody is trying to call this with a null region. |
2578 if (!region) | 2573 if (!region) |
2579 return 0; | 2574 return 0; |
2580 | 2575 |
2581 // If we have computed our width in this region already, it will be cached,
and we can | 2576 // If we have computed our width in this region already, it will be cached,
and we can |
2582 // just return it. | 2577 // just return it. |
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2828 // If that happens, this code will have to change. | 2823 // If that happens, this code will have to change. |
2829 if (height.isIntrinsic()) { | 2824 if (height.isIntrinsic()) { |
2830 if (intrinsicContentHeight == -1) | 2825 if (intrinsicContentHeight == -1) |
2831 return -1; // Intrinsic height isn't available. | 2826 return -1; // Intrinsic height isn't available. |
2832 return computeIntrinsicLogicalContentHeightUsing(height, intrinsicConten
tHeight, borderAndPaddingLogicalHeight()); | 2827 return computeIntrinsicLogicalContentHeightUsing(height, intrinsicConten
tHeight, borderAndPaddingLogicalHeight()); |
2833 } | 2828 } |
2834 if (height.isFixed()) | 2829 if (height.isFixed()) |
2835 return height.value(); | 2830 return height.value(); |
2836 if (height.isPercent()) | 2831 if (height.isPercent()) |
2837 return computePercentageLogicalHeight(height); | 2832 return computePercentageLogicalHeight(height); |
2838 if (height.isViewportPercentage()) | |
2839 return valueForLength(height, 0, view()); | |
2840 return -1; | 2833 return -1; |
2841 } | 2834 } |
2842 | 2835 |
2843 bool RenderBox::skipContainingBlockForPercentHeightCalculation(const RenderBox*
containingBlock) const | 2836 bool RenderBox::skipContainingBlockForPercentHeightCalculation(const RenderBox*
containingBlock) const |
2844 { | 2837 { |
2845 // For quirks mode and anonymous blocks, we skip auto-height containingBlock
s when computing percentages. | 2838 // For quirks mode and anonymous blocks, we skip auto-height containingBlock
s when computing percentages. |
2846 // For standards mode, we treat the percentage as auto if it has an auto-hei
ght containing block. | 2839 // For standards mode, we treat the percentage as auto if it has an auto-hei
ght containing block. |
2847 if (!document().inQuirksMode() && !containingBlock->isAnonymousBlock()) | 2840 if (!document().inQuirksMode() && !containingBlock->isAnonymousBlock()) |
2848 return false; | 2841 return false; |
2849 return !containingBlock->isTableCell() && !containingBlock->isOutOfFlowPosit
ioned() && containingBlock->style()->logicalHeight().isAuto() && isHorizontalWri
tingMode() == containingBlock->isHorizontalWritingMode(); | 2842 return !containingBlock->isTableCell() && !containingBlock->isOutOfFlowPosit
ioned() && containingBlock->style()->logicalHeight().isAuto() && isHorizontalWri
tingMode() == containingBlock->isHorizontalWritingMode(); |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2907 LayoutUnit heightWithScrollbar = cb->computePercentageLogicalHeight(cbst
yle->logicalHeight()); | 2900 LayoutUnit heightWithScrollbar = cb->computePercentageLogicalHeight(cbst
yle->logicalHeight()); |
2908 if (heightWithScrollbar != -1) { | 2901 if (heightWithScrollbar != -1) { |
2909 LayoutUnit contentBoxHeightWithScrollbar = cb->adjustContentBoxLogic
alHeightForBoxSizing(heightWithScrollbar); | 2902 LayoutUnit contentBoxHeightWithScrollbar = cb->adjustContentBoxLogic
alHeightForBoxSizing(heightWithScrollbar); |
2910 // We need to adjust for min/max height because this method does not | 2903 // We need to adjust for min/max height because this method does not |
2911 // handle the min/max of the current block, its caller does. So the | 2904 // handle the min/max of the current block, its caller does. So the |
2912 // return value from the recursive call will not have been adjusted | 2905 // return value from the recursive call will not have been adjusted |
2913 // yet. | 2906 // yet. |
2914 LayoutUnit contentBoxHeight = cb->constrainContentBoxLogicalHeightBy
MinMax(contentBoxHeightWithScrollbar - cb->scrollbarLogicalHeight(), -1); | 2907 LayoutUnit contentBoxHeight = cb->constrainContentBoxLogicalHeightBy
MinMax(contentBoxHeightWithScrollbar - cb->scrollbarLogicalHeight(), -1); |
2915 availableHeight = max<LayoutUnit>(0, contentBoxHeight); | 2908 availableHeight = max<LayoutUnit>(0, contentBoxHeight); |
2916 } | 2909 } |
2917 } else if (cbstyle->logicalHeight().isViewportPercentage()) { | |
2918 LayoutUnit heightWithScrollbar = valueForLength(cbstyle->logicalHeight()
, 0, view()); | |
2919 if (heightWithScrollbar != -1) { | |
2920 LayoutUnit contentBoxHeightWithScrollbar = cb->adjustContentBoxLogic
alHeightForBoxSizing(heightWithScrollbar); | |
2921 // We need to adjust for min/max height because this method does not | |
2922 // handle the min/max of the current block, its caller does. So the | |
2923 // return value from the recursive call will not have been adjusted | |
2924 // yet. | |
2925 LayoutUnit contentBoxHeight = cb->constrainContentBoxLogicalHeightBy
MinMax(contentBoxHeightWithScrollbar - cb->scrollbarLogicalHeight(), -1); | |
2926 availableHeight = max<LayoutUnit>(0, contentBoxHeight); | |
2927 } | |
2928 } else if (isOutOfFlowPositionedWithSpecifiedHeight) { | 2910 } else if (isOutOfFlowPositionedWithSpecifiedHeight) { |
2929 // Don't allow this to affect the block' height() member variable, since
this | 2911 // Don't allow this to affect the block' height() member variable, since
this |
2930 // can get called while the block is still laying out its kids. | 2912 // can get called while the block is still laying out its kids. |
2931 LogicalExtentComputedValues computedValues; | 2913 LogicalExtentComputedValues computedValues; |
2932 cb->computeLogicalHeight(cb->logicalHeight(), 0, computedValues); | 2914 cb->computeLogicalHeight(cb->logicalHeight(), 0, computedValues); |
2933 availableHeight = computedValues.m_extent - cb->borderAndPaddingLogicalH
eight() - cb->scrollbarLogicalHeight(); | 2915 availableHeight = computedValues.m_extent - cb->borderAndPaddingLogicalH
eight() - cb->scrollbarLogicalHeight(); |
2934 } else if (cb->isRenderView()) | 2916 } else if (cb->isRenderView()) |
2935 availableHeight = viewLogicalHeightForPercentages(); | 2917 availableHeight = viewLogicalHeightForPercentages(); |
2936 | 2918 |
2937 if (availableHeight == -1) | 2919 if (availableHeight == -1) |
(...skipping 29 matching lines...) Expand all Loading... |
2967 { | 2949 { |
2968 switch (logicalWidth.type()) { | 2950 switch (logicalWidth.type()) { |
2969 case Fixed: | 2951 case Fixed: |
2970 return adjustContentBoxLogicalWidthForBoxSizing(logicalWidth.value()
); | 2952 return adjustContentBoxLogicalWidthForBoxSizing(logicalWidth.value()
); |
2971 case MinContent: | 2953 case MinContent: |
2972 case MaxContent: { | 2954 case MaxContent: { |
2973 // MinContent/MaxContent don't need the availableLogicalWidth argume
nt. | 2955 // MinContent/MaxContent don't need the availableLogicalWidth argume
nt. |
2974 LayoutUnit availableLogicalWidth = 0; | 2956 LayoutUnit availableLogicalWidth = 0; |
2975 return computeIntrinsicLogicalWidthUsing(logicalWidth, availableLogi
calWidth, borderAndPaddingLogicalWidth()) - borderAndPaddingLogicalWidth(); | 2957 return computeIntrinsicLogicalWidthUsing(logicalWidth, availableLogi
calWidth, borderAndPaddingLogicalWidth()) - borderAndPaddingLogicalWidth(); |
2976 } | 2958 } |
2977 case ViewportPercentageWidth: | |
2978 case ViewportPercentageHeight: | |
2979 case ViewportPercentageMin: | |
2980 case ViewportPercentageMax: | |
2981 return adjustContentBoxLogicalWidthForBoxSizing(valueForLength(logic
alWidth, 0, view())); | |
2982 case FitContent: | 2959 case FitContent: |
2983 case FillAvailable: | 2960 case FillAvailable: |
2984 case Percent: | 2961 case Percent: |
2985 case Calculated: { | 2962 case Calculated: { |
2986 // FIXME: containingBlockLogicalWidthForContent() is wrong if the re
placed element's block-flow is perpendicular to the | 2963 // FIXME: containingBlockLogicalWidthForContent() is wrong if the re
placed element's block-flow is perpendicular to the |
2987 // containing block's block-flow. | 2964 // containing block's block-flow. |
2988 // https://bugs.webkit.org/show_bug.cgi?id=46496 | 2965 // https://bugs.webkit.org/show_bug.cgi?id=46496 |
2989 const LayoutUnit cw = isOutOfFlowPositioned() ? containingBlockLogic
alWidthForPositioned(toRenderBoxModelObject(container())) : containingBlockLogic
alWidthForContent(); | 2966 const LayoutUnit cw = isOutOfFlowPositioned() ? containingBlockLogic
alWidthForPositioned(toRenderBoxModelObject(container())) : containingBlockLogic
alWidthForContent(); |
2990 Length containerLogicalWidth = containingBlock()->style()->logicalWi
dth(); | 2967 Length containerLogicalWidth = containingBlock()->style()->logicalWi
dth(); |
2991 // FIXME: Handle cases when containing block width is calculated or
viewport percent. | 2968 // FIXME: Handle cases when containing block width is calculated or
viewport percent. |
2992 // https://bugs.webkit.org/show_bug.cgi?id=91071 | 2969 // https://bugs.webkit.org/show_bug.cgi?id=91071 |
2993 if (logicalWidth.isIntrinsic()) | 2970 if (logicalWidth.isIntrinsic()) |
2994 return computeIntrinsicLogicalWidthUsing(logicalWidth, cw, borde
rAndPaddingLogicalWidth()) - borderAndPaddingLogicalWidth(); | 2971 return computeIntrinsicLogicalWidthUsing(logicalWidth, cw, borde
rAndPaddingLogicalWidth()) - borderAndPaddingLogicalWidth(); |
2995 if (cw > 0 || (!cw && (containerLogicalWidth.isFixed() || containerL
ogicalWidth.isPercent()))) | 2972 if (cw > 0 || (!cw && (containerLogicalWidth.isFixed() || containerL
ogicalWidth.isPercent()))) |
2996 return adjustContentBoxLogicalWidthForBoxSizing(minimumValueForL
ength(logicalWidth, cw)); | 2973 return adjustContentBoxLogicalWidthForBoxSizing(minimumValueForL
ength(logicalWidth, cw)); |
2997 } | 2974 } |
2998 // fall through | 2975 // fall through |
2999 case Intrinsic: | 2976 case Intrinsic: |
3000 case MinIntrinsic: | 2977 case MinIntrinsic: |
3001 case Auto: | 2978 case Auto: |
3002 case ExtendToZoom: | |
3003 case Undefined: | 2979 case Undefined: |
3004 return intrinsicLogicalWidth(); | 2980 return intrinsicLogicalWidth(); |
| 2981 case ExtendToZoom: |
| 2982 case DeviceWidth: |
| 2983 case DeviceHeight: |
| 2984 break; |
3005 } | 2985 } |
3006 | 2986 |
3007 ASSERT_NOT_REACHED(); | 2987 ASSERT_NOT_REACHED(); |
3008 return 0; | 2988 return 0; |
3009 } | 2989 } |
3010 | 2990 |
3011 LayoutUnit RenderBox::computeReplacedLogicalHeight() const | 2991 LayoutUnit RenderBox::computeReplacedLogicalHeight() const |
3012 { | 2992 { |
3013 return computeReplacedLogicalHeightRespectingMinMaxHeight(computeReplacedLog
icalHeightUsing(style()->logicalHeight())); | 2993 return computeReplacedLogicalHeightRespectingMinMaxHeight(computeReplacedLog
icalHeightUsing(style()->logicalHeight())); |
3014 } | 2994 } |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3065 // <http://bugs.webkit.org/show_bug.cgi?id=15359> | 3045 // <http://bugs.webkit.org/show_bug.cgi?id=15359> |
3066 availableHeight = max(availableHeight, intrinsicLogicalH
eight()); | 3046 availableHeight = max(availableHeight, intrinsicLogicalH
eight()); |
3067 return valueForLength(logicalHeight, availableHeight - b
orderAndPaddingLogicalHeight()); | 3047 return valueForLength(logicalHeight, availableHeight - b
orderAndPaddingLogicalHeight()); |
3068 } | 3048 } |
3069 toRenderBlock(cb)->addPercentHeightDescendant(const_cast<Ren
derBox*>(this)); | 3049 toRenderBlock(cb)->addPercentHeightDescendant(const_cast<Ren
derBox*>(this)); |
3070 cb = cb->containingBlock(); | 3050 cb = cb->containingBlock(); |
3071 } | 3051 } |
3072 } | 3052 } |
3073 return adjustContentBoxLogicalHeightForBoxSizing(valueForLength(logi
calHeight, availableHeight)); | 3053 return adjustContentBoxLogicalHeightForBoxSizing(valueForLength(logi
calHeight, availableHeight)); |
3074 } | 3054 } |
3075 case ViewportPercentageWidth: | |
3076 case ViewportPercentageHeight: | |
3077 case ViewportPercentageMin: | |
3078 case ViewportPercentageMax: | |
3079 return adjustContentBoxLogicalHeightForBoxSizing(valueForLength(logi
calHeight, 0, view())); | |
3080 case MinContent: | 3055 case MinContent: |
3081 case MaxContent: | 3056 case MaxContent: |
3082 case FitContent: | 3057 case FitContent: |
3083 case FillAvailable: | 3058 case FillAvailable: |
3084 return adjustContentBoxLogicalHeightForBoxSizing(computeIntrinsicLog
icalContentHeightUsing(logicalHeight, intrinsicLogicalHeight(), borderAndPadding
Height())); | 3059 return adjustContentBoxLogicalHeightForBoxSizing(computeIntrinsicLog
icalContentHeightUsing(logicalHeight, intrinsicLogicalHeight(), borderAndPadding
Height())); |
3085 default: | 3060 default: |
3086 return intrinsicLogicalHeight(); | 3061 return intrinsicLogicalHeight(); |
3087 } | 3062 } |
3088 } | 3063 } |
3089 | 3064 |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3141 // FIXME: Not right if we allow cells to have different directionality t
han the table. If we do allow this, though, | 3116 // FIXME: Not right if we allow cells to have different directionality t
han the table. If we do allow this, though, |
3142 // we may just do it with an extra anonymous block inside the cell. | 3117 // we may just do it with an extra anonymous block inside the cell. |
3143 marginBefore = 0; | 3118 marginBefore = 0; |
3144 marginAfter = 0; | 3119 marginAfter = 0; |
3145 return; | 3120 return; |
3146 } | 3121 } |
3147 | 3122 |
3148 // Margins are calculated with respect to the logical width of | 3123 // Margins are calculated with respect to the logical width of |
3149 // the containing block (8.3) | 3124 // the containing block (8.3) |
3150 LayoutUnit cw = containingBlockLogicalWidthForContent(); | 3125 LayoutUnit cw = containingBlockLogicalWidthForContent(); |
3151 RenderView* renderView = view(); | |
3152 RenderStyle* containingBlockStyle = containingBlock->style(); | 3126 RenderStyle* containingBlockStyle = containingBlock->style(); |
3153 marginBefore = minimumValueForLength(style()->marginBeforeUsing(containingBl
ockStyle), cw, renderView); | 3127 marginBefore = minimumValueForLength(style()->marginBeforeUsing(containingBl
ockStyle), cw); |
3154 marginAfter = minimumValueForLength(style()->marginAfterUsing(containingBloc
kStyle), cw, renderView); | 3128 marginAfter = minimumValueForLength(style()->marginAfterUsing(containingBloc
kStyle), cw); |
3155 } | 3129 } |
3156 | 3130 |
3157 void RenderBox::computeAndSetBlockDirectionMargins(const RenderBlock* containing
Block) | 3131 void RenderBox::computeAndSetBlockDirectionMargins(const RenderBlock* containing
Block) |
3158 { | 3132 { |
3159 LayoutUnit marginBefore; | 3133 LayoutUnit marginBefore; |
3160 LayoutUnit marginAfter; | 3134 LayoutUnit marginAfter; |
3161 computeBlockDirectionMargins(containingBlock, marginBefore, marginAfter); | 3135 computeBlockDirectionMargins(containingBlock, marginBefore, marginAfter); |
3162 containingBlock->setMarginBeforeForChild(this, marginBefore); | 3136 containingBlock->setMarginBeforeForChild(this, marginBefore); |
3163 containingBlock->setMarginAfterForChild(this, marginAfter); | 3137 containingBlock->setMarginAfterForChild(this, marginAfter); |
3164 } | 3138 } |
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3502 // converted to the static position already | 3476 // converted to the static position already |
3503 ASSERT(!(logicalLeft.isAuto() && logicalRight.isAuto())); | 3477 ASSERT(!(logicalLeft.isAuto() && logicalRight.isAuto())); |
3504 | 3478 |
3505 LayoutUnit logicalLeftValue = 0; | 3479 LayoutUnit logicalLeftValue = 0; |
3506 | 3480 |
3507 const LayoutUnit containerRelativeLogicalWidth = containingBlockLogicalWidth
ForPositioned(containerBlock, 0, false); | 3481 const LayoutUnit containerRelativeLogicalWidth = containingBlockLogicalWidth
ForPositioned(containerBlock, 0, false); |
3508 | 3482 |
3509 bool logicalWidthIsAuto = logicalWidth.isIntrinsicOrAuto(); | 3483 bool logicalWidthIsAuto = logicalWidth.isIntrinsicOrAuto(); |
3510 bool logicalLeftIsAuto = logicalLeft.isAuto(); | 3484 bool logicalLeftIsAuto = logicalLeft.isAuto(); |
3511 bool logicalRightIsAuto = logicalRight.isAuto(); | 3485 bool logicalRightIsAuto = logicalRight.isAuto(); |
3512 RenderView* renderView = view(); | |
3513 LayoutUnit& marginLogicalLeftValue = style()->isLeftToRightDirection() ? com
putedValues.m_margins.m_start : computedValues.m_margins.m_end; | 3486 LayoutUnit& marginLogicalLeftValue = style()->isLeftToRightDirection() ? com
putedValues.m_margins.m_start : computedValues.m_margins.m_end; |
3514 LayoutUnit& marginLogicalRightValue = style()->isLeftToRightDirection() ? co
mputedValues.m_margins.m_end : computedValues.m_margins.m_start; | 3487 LayoutUnit& marginLogicalRightValue = style()->isLeftToRightDirection() ? co
mputedValues.m_margins.m_end : computedValues.m_margins.m_start; |
3515 if (!logicalLeftIsAuto && !logicalWidthIsAuto && !logicalRightIsAuto) { | 3488 if (!logicalLeftIsAuto && !logicalWidthIsAuto && !logicalRightIsAuto) { |
3516 /*----------------------------------------------------------------------
-*\ | 3489 /*----------------------------------------------------------------------
-*\ |
3517 * If none of the three is 'auto': If both 'margin-left' and 'margin- | 3490 * If none of the three is 'auto': If both 'margin-left' and 'margin- |
3518 * right' are 'auto', solve the equation under the extra constraint that | 3491 * right' are 'auto', solve the equation under the extra constraint that |
3519 * the two margins get equal values, unless this would make them negativ
e, | 3492 * the two margins get equal values, unless this would make them negativ
e, |
3520 * in which case when direction of the containing block is 'ltr' ('rtl')
, | 3493 * in which case when direction of the containing block is 'ltr' ('rtl')
, |
3521 * set 'margin-left' ('margin-right') to zero and solve for 'margin-righ
t' | 3494 * set 'margin-left' ('margin-right') to zero and solve for 'margin-righ
t' |
3522 * ('margin-left'). If one of 'margin-left' or 'margin-right' is 'auto', | 3495 * ('margin-left'). If one of 'margin-left' or 'margin-right' is 'auto', |
3523 * solve the equation for that value. If the values are over-constrained
, | 3496 * solve the equation for that value. If the values are over-constrained
, |
3524 * ignore the value for 'left' (in case the 'direction' property of the | 3497 * ignore the value for 'left' (in case the 'direction' property of the |
3525 * containing block is 'rtl') or 'right' (in case 'direction' is 'ltr') | 3498 * containing block is 'rtl') or 'right' (in case 'direction' is 'ltr') |
3526 * and solve for that value. | 3499 * and solve for that value. |
3527 \*----------------------------------------------------------------------
-*/ | 3500 \*----------------------------------------------------------------------
-*/ |
3528 // NOTE: It is not necessary to solve for 'right' in the over constrain
ed | 3501 // NOTE: It is not necessary to solve for 'right' in the over constrain
ed |
3529 // case because the value is not used for any further calculations. | 3502 // case because the value is not used for any further calculations. |
3530 | 3503 |
3531 logicalLeftValue = valueForLength(logicalLeft, containerLogicalWidth, re
nderView); | 3504 logicalLeftValue = valueForLength(logicalLeft, containerLogicalWidth); |
3532 computedValues.m_extent = adjustContentBoxLogicalWidthForBoxSizing(value
ForLength(logicalWidth, containerLogicalWidth, renderView)); | 3505 computedValues.m_extent = adjustContentBoxLogicalWidthForBoxSizing(value
ForLength(logicalWidth, containerLogicalWidth)); |
3533 | 3506 |
3534 const LayoutUnit availableSpace = containerLogicalWidth - (logicalLeftVa
lue + computedValues.m_extent + valueForLength(logicalRight, containerLogicalWid
th, renderView) + bordersPlusPadding); | 3507 const LayoutUnit availableSpace = containerLogicalWidth - (logicalLeftVa
lue + computedValues.m_extent + valueForLength(logicalRight, containerLogicalWid
th) + bordersPlusPadding); |
3535 | 3508 |
3536 // Margins are now the only unknown | 3509 // Margins are now the only unknown |
3537 if (marginLogicalLeft.isAuto() && marginLogicalRight.isAuto()) { | 3510 if (marginLogicalLeft.isAuto() && marginLogicalRight.isAuto()) { |
3538 // Both margins auto, solve for equality | 3511 // Both margins auto, solve for equality |
3539 if (availableSpace >= 0) { | 3512 if (availableSpace >= 0) { |
3540 marginLogicalLeftValue = availableSpace / 2; // split the differ
ence | 3513 marginLogicalLeftValue = availableSpace / 2; // split the differ
ence |
3541 marginLogicalRightValue = availableSpace - marginLogicalLeftValu
e; // account for odd valued differences | 3514 marginLogicalRightValue = availableSpace - marginLogicalLeftValu
e; // account for odd valued differences |
3542 } else { | 3515 } else { |
3543 // Use the containing block's direction rather than the parent b
lock's | 3516 // Use the containing block's direction rather than the parent b
lock's |
3544 // per CSS 2.1 reference test abspos-non-replaced-width-margin-0
00. | 3517 // per CSS 2.1 reference test abspos-non-replaced-width-margin-0
00. |
3545 if (containerDirection == LTR) { | 3518 if (containerDirection == LTR) { |
3546 marginLogicalLeftValue = 0; | 3519 marginLogicalLeftValue = 0; |
3547 marginLogicalRightValue = availableSpace; // will be negativ
e | 3520 marginLogicalRightValue = availableSpace; // will be negativ
e |
3548 } else { | 3521 } else { |
3549 marginLogicalLeftValue = availableSpace; // will be negative | 3522 marginLogicalLeftValue = availableSpace; // will be negative |
3550 marginLogicalRightValue = 0; | 3523 marginLogicalRightValue = 0; |
3551 } | 3524 } |
3552 } | 3525 } |
3553 } else if (marginLogicalLeft.isAuto()) { | 3526 } else if (marginLogicalLeft.isAuto()) { |
3554 // Solve for left margin | 3527 // Solve for left margin |
3555 marginLogicalRightValue = valueForLength(marginLogicalRight, contain
erRelativeLogicalWidth, renderView); | 3528 marginLogicalRightValue = valueForLength(marginLogicalRight, contain
erRelativeLogicalWidth); |
3556 marginLogicalLeftValue = availableSpace - marginLogicalRightValue; | 3529 marginLogicalLeftValue = availableSpace - marginLogicalRightValue; |
3557 } else if (marginLogicalRight.isAuto()) { | 3530 } else if (marginLogicalRight.isAuto()) { |
3558 // Solve for right margin | 3531 // Solve for right margin |
3559 marginLogicalLeftValue = valueForLength(marginLogicalLeft, container
RelativeLogicalWidth, renderView); | 3532 marginLogicalLeftValue = valueForLength(marginLogicalLeft, container
RelativeLogicalWidth); |
3560 marginLogicalRightValue = availableSpace - marginLogicalLeftValue; | 3533 marginLogicalRightValue = availableSpace - marginLogicalLeftValue; |
3561 } else { | 3534 } else { |
3562 // Over-constrained, solve for left if direction is RTL | 3535 // Over-constrained, solve for left if direction is RTL |
3563 marginLogicalLeftValue = valueForLength(marginLogicalLeft, container
RelativeLogicalWidth, renderView); | 3536 marginLogicalLeftValue = valueForLength(marginLogicalLeft, container
RelativeLogicalWidth); |
3564 marginLogicalRightValue = valueForLength(marginLogicalRight, contain
erRelativeLogicalWidth, renderView); | 3537 marginLogicalRightValue = valueForLength(marginLogicalRight, contain
erRelativeLogicalWidth); |
3565 | 3538 |
3566 // Use the containing block's direction rather than the parent block
's | 3539 // Use the containing block's direction rather than the parent block
's |
3567 // per CSS 2.1 reference test abspos-non-replaced-width-margin-000. | 3540 // per CSS 2.1 reference test abspos-non-replaced-width-margin-000. |
3568 if (containerDirection == RTL) | 3541 if (containerDirection == RTL) |
3569 logicalLeftValue = (availableSpace + logicalLeftValue) - marginL
ogicalLeftValue - marginLogicalRightValue; | 3542 logicalLeftValue = (availableSpace + logicalLeftValue) - marginL
ogicalLeftValue - marginLogicalRightValue; |
3570 } | 3543 } |
3571 } else { | 3544 } else { |
3572 /*--------------------------------------------------------------------*\ | 3545 /*--------------------------------------------------------------------*\ |
3573 * Otherwise, set 'auto' values for 'margin-left' and 'margin-right' | 3546 * Otherwise, set 'auto' values for 'margin-left' and 'margin-right' |
3574 * to 0, and pick the one of the following six rules that applies. | 3547 * to 0, and pick the one of the following six rules that applies. |
(...skipping 29 matching lines...) Expand all Loading... |
3604 * for 'width' after setting 'left' (in case 1) or 'right' (in case 3) | 3577 * for 'width' after setting 'left' (in case 1) or 'right' (in case 3) |
3605 * to 0. | 3578 * to 0. |
3606 * | 3579 * |
3607 * Then the shrink-to-fit width is: | 3580 * Then the shrink-to-fit width is: |
3608 * min(max(preferred minimum width, available width), preferred width). | 3581 * min(max(preferred minimum width, available width), preferred width). |
3609 \*--------------------------------------------------------------------*/ | 3582 \*--------------------------------------------------------------------*/ |
3610 // NOTE: For rules 3 and 6 it is not necessary to solve for 'right' | 3583 // NOTE: For rules 3 and 6 it is not necessary to solve for 'right' |
3611 // because the value is not used for any further calculations. | 3584 // because the value is not used for any further calculations. |
3612 | 3585 |
3613 // Calculate margins, 'auto' margins are ignored. | 3586 // Calculate margins, 'auto' margins are ignored. |
3614 marginLogicalLeftValue = minimumValueForLength(marginLogicalLeft, contai
nerRelativeLogicalWidth, renderView); | 3587 marginLogicalLeftValue = minimumValueForLength(marginLogicalLeft, contai
nerRelativeLogicalWidth); |
3615 marginLogicalRightValue = minimumValueForLength(marginLogicalRight, cont
ainerRelativeLogicalWidth, renderView); | 3588 marginLogicalRightValue = minimumValueForLength(marginLogicalRight, cont
ainerRelativeLogicalWidth); |
3616 | 3589 |
3617 const LayoutUnit availableSpace = containerLogicalWidth - (marginLogical
LeftValue + marginLogicalRightValue + bordersPlusPadding); | 3590 const LayoutUnit availableSpace = containerLogicalWidth - (marginLogical
LeftValue + marginLogicalRightValue + bordersPlusPadding); |
3618 | 3591 |
3619 // FIXME: Is there a faster way to find the correct case? | 3592 // FIXME: Is there a faster way to find the correct case? |
3620 // Use rule/case that applies. | 3593 // Use rule/case that applies. |
3621 if (logicalLeftIsAuto && logicalWidthIsAuto && !logicalRightIsAuto) { | 3594 if (logicalLeftIsAuto && logicalWidthIsAuto && !logicalRightIsAuto) { |
3622 // RULE 1: (use shrink-to-fit for width, and solve of left) | 3595 // RULE 1: (use shrink-to-fit for width, and solve of left) |
3623 LayoutUnit logicalRightValue = valueForLength(logicalRight, containe
rLogicalWidth, renderView); | 3596 LayoutUnit logicalRightValue = valueForLength(logicalRight, containe
rLogicalWidth); |
3624 | 3597 |
3625 // FIXME: would it be better to have shrink-to-fit in one step? | 3598 // FIXME: would it be better to have shrink-to-fit in one step? |
3626 LayoutUnit preferredWidth = maxPreferredLogicalWidth() - bordersPlus
Padding; | 3599 LayoutUnit preferredWidth = maxPreferredLogicalWidth() - bordersPlus
Padding; |
3627 LayoutUnit preferredMinWidth = minPreferredLogicalWidth() - bordersP
lusPadding; | 3600 LayoutUnit preferredMinWidth = minPreferredLogicalWidth() - bordersP
lusPadding; |
3628 LayoutUnit availableWidth = availableSpace - logicalRightValue; | 3601 LayoutUnit availableWidth = availableSpace - logicalRightValue; |
3629 computedValues.m_extent = min(max(preferredMinWidth, availableWidth)
, preferredWidth); | 3602 computedValues.m_extent = min(max(preferredMinWidth, availableWidth)
, preferredWidth); |
3630 logicalLeftValue = availableSpace - (computedValues.m_extent + logic
alRightValue); | 3603 logicalLeftValue = availableSpace - (computedValues.m_extent + logic
alRightValue); |
3631 } else if (!logicalLeftIsAuto && logicalWidthIsAuto && logicalRightIsAut
o) { | 3604 } else if (!logicalLeftIsAuto && logicalWidthIsAuto && logicalRightIsAut
o) { |
3632 // RULE 3: (use shrink-to-fit for width, and no need solve of right) | 3605 // RULE 3: (use shrink-to-fit for width, and no need solve of right) |
3633 logicalLeftValue = valueForLength(logicalLeft, containerLogicalWidth
, renderView); | 3606 logicalLeftValue = valueForLength(logicalLeft, containerLogicalWidth
); |
3634 | 3607 |
3635 shrinkToFitWidth(availableSpace, logicalLeftValue, bordersPlusPaddin
g, computedValues); | 3608 shrinkToFitWidth(availableSpace, logicalLeftValue, bordersPlusPaddin
g, computedValues); |
3636 } else if (logicalLeftIsAuto && !logicalWidthIsAuto && !logicalRightIsAu
to) { | 3609 } else if (logicalLeftIsAuto && !logicalWidthIsAuto && !logicalRightIsAu
to) { |
3637 // RULE 4: (solve for left) | 3610 // RULE 4: (solve for left) |
3638 computedValues.m_extent = adjustContentBoxLogicalWidthForBoxSizing(v
alueForLength(logicalWidth, containerLogicalWidth, renderView)); | 3611 computedValues.m_extent = adjustContentBoxLogicalWidthForBoxSizing(v
alueForLength(logicalWidth, containerLogicalWidth)); |
3639 logicalLeftValue = availableSpace - (computedValues.m_extent + value
ForLength(logicalRight, containerLogicalWidth, renderView)); | 3612 logicalLeftValue = availableSpace - (computedValues.m_extent + value
ForLength(logicalRight, containerLogicalWidth)); |
3640 } else if (!logicalLeftIsAuto && logicalWidthIsAuto && !logicalRightIsAu
to) { | 3613 } else if (!logicalLeftIsAuto && logicalWidthIsAuto && !logicalRightIsAu
to) { |
3641 // RULE 5: (solve for width) | 3614 // RULE 5: (solve for width) |
3642 logicalLeftValue = valueForLength(logicalLeft, containerLogicalWidth
, renderView); | 3615 logicalLeftValue = valueForLength(logicalLeft, containerLogicalWidth
); |
3643 if (autoWidthShouldFitContent()) | 3616 if (autoWidthShouldFitContent()) |
3644 shrinkToFitWidth(availableSpace, logicalLeftValue, bordersPlusPa
dding, computedValues); | 3617 shrinkToFitWidth(availableSpace, logicalLeftValue, bordersPlusPa
dding, computedValues); |
3645 else | 3618 else |
3646 computedValues.m_extent = availableSpace - (logicalLeftValue + v
alueForLength(logicalRight, containerLogicalWidth, renderView)); | 3619 computedValues.m_extent = availableSpace - (logicalLeftValue + v
alueForLength(logicalRight, containerLogicalWidth)); |
3647 } else if (!logicalLeftIsAuto && !logicalWidthIsAuto && logicalRightIsAu
to) { | 3620 } else if (!logicalLeftIsAuto && !logicalWidthIsAuto && logicalRightIsAu
to) { |
3648 // RULE 6: (no need solve for right) | 3621 // RULE 6: (no need solve for right) |
3649 logicalLeftValue = valueForLength(logicalLeft, containerLogicalWidth
, renderView); | 3622 logicalLeftValue = valueForLength(logicalLeft, containerLogicalWidth
); |
3650 computedValues.m_extent = adjustContentBoxLogicalWidthForBoxSizing(v
alueForLength(logicalWidth, containerLogicalWidth, renderView)); | 3623 computedValues.m_extent = adjustContentBoxLogicalWidthForBoxSizing(v
alueForLength(logicalWidth, containerLogicalWidth)); |
3651 } | 3624 } |
3652 } | 3625 } |
3653 | 3626 |
3654 // Use computed values to calculate the horizontal position. | 3627 // Use computed values to calculate the horizontal position. |
3655 | 3628 |
3656 // FIXME: This hack is needed to calculate the logical left position for a
'rtl' relatively | 3629 // FIXME: This hack is needed to calculate the logical left position for a
'rtl' relatively |
3657 // positioned, inline because right now, it is using the logical left positi
on | 3630 // positioned, inline because right now, it is using the logical left positi
on |
3658 // of the first line box when really it should use the last line box. When | 3631 // of the first line box when really it should use the last line box. When |
3659 // this is fixed elsewhere, this block should be removed. | 3632 // this is fixed elsewhere, this block should be removed. |
3660 if (containerBlock->isRenderInline() && !containerBlock->style()->isLeftToRi
ghtDirection()) { | 3633 if (containerBlock->isRenderInline() && !containerBlock->style()->isLeftToRi
ghtDirection()) { |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3834 LayoutUnit logicalHeightValue; | 3807 LayoutUnit logicalHeightValue; |
3835 LayoutUnit contentLogicalHeight = logicalHeight - bordersPlusPadding; | 3808 LayoutUnit contentLogicalHeight = logicalHeight - bordersPlusPadding; |
3836 | 3809 |
3837 const LayoutUnit containerRelativeLogicalWidth = containingBlockLogicalWidth
ForPositioned(containerBlock, 0, false); | 3810 const LayoutUnit containerRelativeLogicalWidth = containingBlockLogicalWidth
ForPositioned(containerBlock, 0, false); |
3838 | 3811 |
3839 LayoutUnit logicalTopValue = 0; | 3812 LayoutUnit logicalTopValue = 0; |
3840 | 3813 |
3841 bool logicalHeightIsAuto = logicalHeightLength.isAuto(); | 3814 bool logicalHeightIsAuto = logicalHeightLength.isAuto(); |
3842 bool logicalTopIsAuto = logicalTop.isAuto(); | 3815 bool logicalTopIsAuto = logicalTop.isAuto(); |
3843 bool logicalBottomIsAuto = logicalBottom.isAuto(); | 3816 bool logicalBottomIsAuto = logicalBottom.isAuto(); |
3844 RenderView* renderView = view(); | |
3845 | 3817 |
3846 LayoutUnit resolvedLogicalHeight; | 3818 LayoutUnit resolvedLogicalHeight; |
3847 // Height is never unsolved for tables. | 3819 // Height is never unsolved for tables. |
3848 if (isTable()) { | 3820 if (isTable()) { |
3849 resolvedLogicalHeight = contentLogicalHeight; | 3821 resolvedLogicalHeight = contentLogicalHeight; |
3850 logicalHeightIsAuto = false; | 3822 logicalHeightIsAuto = false; |
3851 } else { | 3823 } else { |
3852 if (logicalHeightLength.isIntrinsic()) | 3824 if (logicalHeightLength.isIntrinsic()) |
3853 resolvedLogicalHeight = computeIntrinsicLogicalContentHeightUsing(lo
gicalHeightLength, contentLogicalHeight, bordersPlusPadding); | 3825 resolvedLogicalHeight = computeIntrinsicLogicalContentHeightUsing(lo
gicalHeightLength, contentLogicalHeight, bordersPlusPadding); |
3854 else | 3826 else |
3855 resolvedLogicalHeight = adjustContentBoxLogicalHeightForBoxSizing(va
lueForLength(logicalHeightLength, containerLogicalHeight, renderView)); | 3827 resolvedLogicalHeight = adjustContentBoxLogicalHeightForBoxSizing(va
lueForLength(logicalHeightLength, containerLogicalHeight)); |
3856 } | 3828 } |
3857 | 3829 |
3858 if (!logicalTopIsAuto && !logicalHeightIsAuto && !logicalBottomIsAuto) { | 3830 if (!logicalTopIsAuto && !logicalHeightIsAuto && !logicalBottomIsAuto) { |
3859 /*----------------------------------------------------------------------
-*\ | 3831 /*----------------------------------------------------------------------
-*\ |
3860 * If none of the three are 'auto': If both 'margin-top' and 'margin- | 3832 * If none of the three are 'auto': If both 'margin-top' and 'margin- |
3861 * bottom' are 'auto', solve the equation under the extra constraint tha
t | 3833 * bottom' are 'auto', solve the equation under the extra constraint tha
t |
3862 * the two margins get equal values. If one of 'margin-top' or 'margin- | 3834 * the two margins get equal values. If one of 'margin-top' or 'margin- |
3863 * bottom' is 'auto', solve the equation for that value. If the values | 3835 * bottom' is 'auto', solve the equation for that value. If the values |
3864 * are over-constrained, ignore the value for 'bottom' and solve for tha
t | 3836 * are over-constrained, ignore the value for 'bottom' and solve for tha
t |
3865 * value. | 3837 * value. |
3866 \*----------------------------------------------------------------------
-*/ | 3838 \*----------------------------------------------------------------------
-*/ |
3867 // NOTE: It is not necessary to solve for 'bottom' in the over constrai
ned | 3839 // NOTE: It is not necessary to solve for 'bottom' in the over constrai
ned |
3868 // case because the value is not used for any further calculations. | 3840 // case because the value is not used for any further calculations. |
3869 | 3841 |
3870 logicalHeightValue = resolvedLogicalHeight; | 3842 logicalHeightValue = resolvedLogicalHeight; |
3871 logicalTopValue = valueForLength(logicalTop, containerLogicalHeight, ren
derView); | 3843 logicalTopValue = valueForLength(logicalTop, containerLogicalHeight); |
3872 | 3844 |
3873 const LayoutUnit availableSpace = containerLogicalHeight - (logicalTopVa
lue + logicalHeightValue + valueForLength(logicalBottom, containerLogicalHeight,
renderView) + bordersPlusPadding); | 3845 const LayoutUnit availableSpace = containerLogicalHeight - (logicalTopVa
lue + logicalHeightValue + valueForLength(logicalBottom, containerLogicalHeight)
+ bordersPlusPadding); |
3874 | 3846 |
3875 // Margins are now the only unknown | 3847 // Margins are now the only unknown |
3876 if (marginBefore.isAuto() && marginAfter.isAuto()) { | 3848 if (marginBefore.isAuto() && marginAfter.isAuto()) { |
3877 // Both margins auto, solve for equality | 3849 // Both margins auto, solve for equality |
3878 // NOTE: This may result in negative values. | 3850 // NOTE: This may result in negative values. |
3879 computedValues.m_margins.m_before = availableSpace / 2; // split the
difference | 3851 computedValues.m_margins.m_before = availableSpace / 2; // split the
difference |
3880 computedValues.m_margins.m_after = availableSpace - computedValues.m
_margins.m_before; // account for odd valued differences | 3852 computedValues.m_margins.m_after = availableSpace - computedValues.m
_margins.m_before; // account for odd valued differences |
3881 } else if (marginBefore.isAuto()) { | 3853 } else if (marginBefore.isAuto()) { |
3882 // Solve for top margin | 3854 // Solve for top margin |
3883 computedValues.m_margins.m_after = valueForLength(marginAfter, conta
inerRelativeLogicalWidth, renderView); | 3855 computedValues.m_margins.m_after = valueForLength(marginAfter, conta
inerRelativeLogicalWidth); |
3884 computedValues.m_margins.m_before = availableSpace - computedValues.
m_margins.m_after; | 3856 computedValues.m_margins.m_before = availableSpace - computedValues.
m_margins.m_after; |
3885 } else if (marginAfter.isAuto()) { | 3857 } else if (marginAfter.isAuto()) { |
3886 // Solve for bottom margin | 3858 // Solve for bottom margin |
3887 computedValues.m_margins.m_before = valueForLength(marginBefore, con
tainerRelativeLogicalWidth, renderView); | 3859 computedValues.m_margins.m_before = valueForLength(marginBefore, con
tainerRelativeLogicalWidth); |
3888 computedValues.m_margins.m_after = availableSpace - computedValues.m
_margins.m_before; | 3860 computedValues.m_margins.m_after = availableSpace - computedValues.m
_margins.m_before; |
3889 } else { | 3861 } else { |
3890 // Over-constrained, (no need solve for bottom) | 3862 // Over-constrained, (no need solve for bottom) |
3891 computedValues.m_margins.m_before = valueForLength(marginBefore, con
tainerRelativeLogicalWidth, renderView); | 3863 computedValues.m_margins.m_before = valueForLength(marginBefore, con
tainerRelativeLogicalWidth); |
3892 computedValues.m_margins.m_after = valueForLength(marginAfter, conta
inerRelativeLogicalWidth, renderView); | 3864 computedValues.m_margins.m_after = valueForLength(marginAfter, conta
inerRelativeLogicalWidth); |
3893 } | 3865 } |
3894 } else { | 3866 } else { |
3895 /*--------------------------------------------------------------------*\ | 3867 /*--------------------------------------------------------------------*\ |
3896 * Otherwise, set 'auto' values for 'margin-top' and 'margin-bottom' | 3868 * Otherwise, set 'auto' values for 'margin-top' and 'margin-bottom' |
3897 * to 0, and pick the one of the following six rules that applies. | 3869 * to 0, and pick the one of the following six rules that applies. |
3898 * | 3870 * |
3899 * 1. 'top' and 'height' are 'auto' and 'bottom' is not 'auto', then | 3871 * 1. 'top' and 'height' are 'auto' and 'bottom' is not 'auto', then |
3900 * the height is based on the content, and solve for 'top'. | 3872 * the height is based on the content, and solve for 'top'. |
3901 * | 3873 * |
3902 * OMIT RULE 2 AS IT SHOULD NEVER BE HIT | 3874 * OMIT RULE 2 AS IT SHOULD NEVER BE HIT |
3903 * ------------------------------------------------------------------ | 3875 * ------------------------------------------------------------------ |
3904 * 2. 'top' and 'bottom' are 'auto' and 'height' is not 'auto', then | 3876 * 2. 'top' and 'bottom' are 'auto' and 'height' is not 'auto', then |
3905 * set 'top' to the static position, and solve for 'bottom'. | 3877 * set 'top' to the static position, and solve for 'bottom'. |
3906 * ------------------------------------------------------------------ | 3878 * ------------------------------------------------------------------ |
3907 * | 3879 * |
3908 * 3. 'height' and 'bottom' are 'auto' and 'top' is not 'auto', then | 3880 * 3. 'height' and 'bottom' are 'auto' and 'top' is not 'auto', then |
3909 * the height is based on the content, and solve for 'bottom'. | 3881 * the height is based on the content, and solve for 'bottom'. |
3910 * 4. 'top' is 'auto', 'height' and 'bottom' are not 'auto', and | 3882 * 4. 'top' is 'auto', 'height' and 'bottom' are not 'auto', and |
3911 * solve for 'top'. | 3883 * solve for 'top'. |
3912 * 5. 'height' is 'auto', 'top' and 'bottom' are not 'auto', and | 3884 * 5. 'height' is 'auto', 'top' and 'bottom' are not 'auto', and |
3913 * solve for 'height'. | 3885 * solve for 'height'. |
3914 * 6. 'bottom' is 'auto', 'top' and 'height' are not 'auto', and | 3886 * 6. 'bottom' is 'auto', 'top' and 'height' are not 'auto', and |
3915 * solve for 'bottom'. | 3887 * solve for 'bottom'. |
3916 \*--------------------------------------------------------------------*/ | 3888 \*--------------------------------------------------------------------*/ |
3917 // NOTE: For rules 3 and 6 it is not necessary to solve for 'bottom' | 3889 // NOTE: For rules 3 and 6 it is not necessary to solve for 'bottom' |
3918 // because the value is not used for any further calculations. | 3890 // because the value is not used for any further calculations. |
3919 | 3891 |
3920 // Calculate margins, 'auto' margins are ignored. | 3892 // Calculate margins, 'auto' margins are ignored. |
3921 computedValues.m_margins.m_before = minimumValueForLength(marginBefore,
containerRelativeLogicalWidth, renderView); | 3893 computedValues.m_margins.m_before = minimumValueForLength(marginBefore,
containerRelativeLogicalWidth); |
3922 computedValues.m_margins.m_after = minimumValueForLength(marginAfter, co
ntainerRelativeLogicalWidth, renderView); | 3894 computedValues.m_margins.m_after = minimumValueForLength(marginAfter, co
ntainerRelativeLogicalWidth); |
3923 | 3895 |
3924 const LayoutUnit availableSpace = containerLogicalHeight - (computedValu
es.m_margins.m_before + computedValues.m_margins.m_after + bordersPlusPadding); | 3896 const LayoutUnit availableSpace = containerLogicalHeight - (computedValu
es.m_margins.m_before + computedValues.m_margins.m_after + bordersPlusPadding); |
3925 | 3897 |
3926 // Use rule/case that applies. | 3898 // Use rule/case that applies. |
3927 if (logicalTopIsAuto && logicalHeightIsAuto && !logicalBottomIsAuto) { | 3899 if (logicalTopIsAuto && logicalHeightIsAuto && !logicalBottomIsAuto) { |
3928 // RULE 1: (height is content based, solve of top) | 3900 // RULE 1: (height is content based, solve of top) |
3929 logicalHeightValue = contentLogicalHeight; | 3901 logicalHeightValue = contentLogicalHeight; |
3930 logicalTopValue = availableSpace - (logicalHeightValue + valueForLen
gth(logicalBottom, containerLogicalHeight, renderView)); | 3902 logicalTopValue = availableSpace - (logicalHeightValue + valueForLen
gth(logicalBottom, containerLogicalHeight)); |
3931 } else if (!logicalTopIsAuto && logicalHeightIsAuto && logicalBottomIsAu
to) { | 3903 } else if (!logicalTopIsAuto && logicalHeightIsAuto && logicalBottomIsAu
to) { |
3932 // RULE 3: (height is content based, no need solve of bottom) | 3904 // RULE 3: (height is content based, no need solve of bottom) |
3933 logicalTopValue = valueForLength(logicalTop, containerLogicalHeight,
renderView); | 3905 logicalTopValue = valueForLength(logicalTop, containerLogicalHeight)
; |
3934 logicalHeightValue = contentLogicalHeight; | 3906 logicalHeightValue = contentLogicalHeight; |
3935 } else if (logicalTopIsAuto && !logicalHeightIsAuto && !logicalBottomIsA
uto) { | 3907 } else if (logicalTopIsAuto && !logicalHeightIsAuto && !logicalBottomIsA
uto) { |
3936 // RULE 4: (solve of top) | 3908 // RULE 4: (solve of top) |
3937 logicalHeightValue = resolvedLogicalHeight; | 3909 logicalHeightValue = resolvedLogicalHeight; |
3938 logicalTopValue = availableSpace - (logicalHeightValue + valueForLen
gth(logicalBottom, containerLogicalHeight, renderView)); | 3910 logicalTopValue = availableSpace - (logicalHeightValue + valueForLen
gth(logicalBottom, containerLogicalHeight)); |
3939 } else if (!logicalTopIsAuto && logicalHeightIsAuto && !logicalBottomIsA
uto) { | 3911 } else if (!logicalTopIsAuto && logicalHeightIsAuto && !logicalBottomIsA
uto) { |
3940 // RULE 5: (solve of height) | 3912 // RULE 5: (solve of height) |
3941 logicalTopValue = valueForLength(logicalTop, containerLogicalHeight,
renderView); | 3913 logicalTopValue = valueForLength(logicalTop, containerLogicalHeight)
; |
3942 logicalHeightValue = max<LayoutUnit>(0, availableSpace - (logicalTop
Value + valueForLength(logicalBottom, containerLogicalHeight, renderView))); | 3914 logicalHeightValue = max<LayoutUnit>(0, availableSpace - (logicalTop
Value + valueForLength(logicalBottom, containerLogicalHeight))); |
3943 } else if (!logicalTopIsAuto && !logicalHeightIsAuto && logicalBottomIsA
uto) { | 3915 } else if (!logicalTopIsAuto && !logicalHeightIsAuto && logicalBottomIsA
uto) { |
3944 // RULE 6: (no need solve of bottom) | 3916 // RULE 6: (no need solve of bottom) |
3945 logicalHeightValue = resolvedLogicalHeight; | 3917 logicalHeightValue = resolvedLogicalHeight; |
3946 logicalTopValue = valueForLength(logicalTop, containerLogicalHeight,
renderView); | 3918 logicalTopValue = valueForLength(logicalTop, containerLogicalHeight)
; |
3947 } | 3919 } |
3948 } | 3920 } |
3949 computedValues.m_extent = logicalHeightValue; | 3921 computedValues.m_extent = logicalHeightValue; |
3950 | 3922 |
3951 // Use computed values to calculate the vertical position. | 3923 // Use computed values to calculate the vertical position. |
3952 computedValues.m_position = logicalTopValue + computedValues.m_margins.m_bef
ore; | 3924 computedValues.m_position = logicalTopValue + computedValues.m_margins.m_bef
ore; |
3953 computeLogicalTopPositionedOffset(computedValues.m_position, this, logicalHe
ightValue, containerBlock, containerLogicalHeight); | 3925 computeLogicalTopPositionedOffset(computedValues.m_position, this, logicalHe
ightValue, containerBlock, containerLogicalHeight); |
3954 } | 3926 } |
3955 | 3927 |
3956 void RenderBox::computePositionedLogicalWidthReplaced(LogicalExtentComputedValue
s& computedValues) const | 3928 void RenderBox::computePositionedLogicalWidthReplaced(LogicalExtentComputedValue
s& computedValues) const |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4014 /*-----------------------------------------------------------------------*\ | 3986 /*-----------------------------------------------------------------------*\ |
4015 * 4. If at this point both 'margin-left' and 'margin-right' are still | 3987 * 4. If at this point both 'margin-left' and 'margin-right' are still |
4016 * 'auto', solve the equation under the extra constraint that the two | 3988 * 'auto', solve the equation under the extra constraint that the two |
4017 * margins must get equal values, unless this would make them negative, | 3989 * margins must get equal values, unless this would make them negative, |
4018 * in which case when the direction of the containing block is 'ltr' | 3990 * in which case when the direction of the containing block is 'ltr' |
4019 * ('rtl'), set 'margin-left' ('margin-right') to zero and solve for | 3991 * ('rtl'), set 'margin-left' ('margin-right') to zero and solve for |
4020 * 'margin-right' ('margin-left'). | 3992 * 'margin-right' ('margin-left'). |
4021 \*-----------------------------------------------------------------------*/ | 3993 \*-----------------------------------------------------------------------*/ |
4022 LayoutUnit logicalLeftValue = 0; | 3994 LayoutUnit logicalLeftValue = 0; |
4023 LayoutUnit logicalRightValue = 0; | 3995 LayoutUnit logicalRightValue = 0; |
4024 RenderView* renderView = view(); | |
4025 | 3996 |
4026 if (marginLogicalLeft.isAuto() && marginLogicalRight.isAuto()) { | 3997 if (marginLogicalLeft.isAuto() && marginLogicalRight.isAuto()) { |
4027 // 'left' and 'right' cannot be 'auto' due to step 3 | 3998 // 'left' and 'right' cannot be 'auto' due to step 3 |
4028 ASSERT(!(logicalLeft.isAuto() && logicalRight.isAuto())); | 3999 ASSERT(!(logicalLeft.isAuto() && logicalRight.isAuto())); |
4029 | 4000 |
4030 logicalLeftValue = valueForLength(logicalLeft, containerLogicalWidth, re
nderView); | 4001 logicalLeftValue = valueForLength(logicalLeft, containerLogicalWidth); |
4031 logicalRightValue = valueForLength(logicalRight, containerLogicalWidth,
renderView); | 4002 logicalRightValue = valueForLength(logicalRight, containerLogicalWidth); |
4032 | 4003 |
4033 LayoutUnit difference = availableSpace - (logicalLeftValue + logicalRigh
tValue); | 4004 LayoutUnit difference = availableSpace - (logicalLeftValue + logicalRigh
tValue); |
4034 if (difference > 0) { | 4005 if (difference > 0) { |
4035 marginLogicalLeftAlias = difference / 2; // split the difference | 4006 marginLogicalLeftAlias = difference / 2; // split the difference |
4036 marginLogicalRightAlias = difference - marginLogicalLeftAlias; // ac
count for odd valued differences | 4007 marginLogicalRightAlias = difference - marginLogicalLeftAlias; // ac
count for odd valued differences |
4037 } else { | 4008 } else { |
4038 // Use the containing block's direction rather than the parent block
's | 4009 // Use the containing block's direction rather than the parent block
's |
4039 // per CSS 2.1 reference test abspos-replaced-width-margin-000. | 4010 // per CSS 2.1 reference test abspos-replaced-width-margin-000. |
4040 if (containerDirection == LTR) { | 4011 if (containerDirection == LTR) { |
4041 marginLogicalLeftAlias = 0; | 4012 marginLogicalLeftAlias = 0; |
4042 marginLogicalRightAlias = difference; // will be negative | 4013 marginLogicalRightAlias = difference; // will be negative |
4043 } else { | 4014 } else { |
4044 marginLogicalLeftAlias = difference; // will be negative | 4015 marginLogicalLeftAlias = difference; // will be negative |
4045 marginLogicalRightAlias = 0; | 4016 marginLogicalRightAlias = 0; |
4046 } | 4017 } |
4047 } | 4018 } |
4048 | 4019 |
4049 /*-----------------------------------------------------------------------*\ | 4020 /*-----------------------------------------------------------------------*\ |
4050 * 5. If at this point there is an 'auto' left, solve the equation for | 4021 * 5. If at this point there is an 'auto' left, solve the equation for |
4051 * that value. | 4022 * that value. |
4052 \*-----------------------------------------------------------------------*/ | 4023 \*-----------------------------------------------------------------------*/ |
4053 } else if (logicalLeft.isAuto()) { | 4024 } else if (logicalLeft.isAuto()) { |
4054 marginLogicalLeftAlias = valueForLength(marginLogicalLeft, containerRela
tiveLogicalWidth, renderView); | 4025 marginLogicalLeftAlias = valueForLength(marginLogicalLeft, containerRela
tiveLogicalWidth); |
4055 marginLogicalRightAlias = valueForLength(marginLogicalRight, containerRe
lativeLogicalWidth, renderView); | 4026 marginLogicalRightAlias = valueForLength(marginLogicalRight, containerRe
lativeLogicalWidth); |
4056 logicalRightValue = valueForLength(logicalRight, containerLogicalWidth,
renderView); | 4027 logicalRightValue = valueForLength(logicalRight, containerLogicalWidth); |
4057 | 4028 |
4058 // Solve for 'left' | 4029 // Solve for 'left' |
4059 logicalLeftValue = availableSpace - (logicalRightValue + marginLogicalLe
ftAlias + marginLogicalRightAlias); | 4030 logicalLeftValue = availableSpace - (logicalRightValue + marginLogicalLe
ftAlias + marginLogicalRightAlias); |
4060 } else if (logicalRight.isAuto()) { | 4031 } else if (logicalRight.isAuto()) { |
4061 marginLogicalLeftAlias = valueForLength(marginLogicalLeft, containerRela
tiveLogicalWidth, renderView); | 4032 marginLogicalLeftAlias = valueForLength(marginLogicalLeft, containerRela
tiveLogicalWidth); |
4062 marginLogicalRightAlias = valueForLength(marginLogicalRight, containerRe
lativeLogicalWidth, renderView); | 4033 marginLogicalRightAlias = valueForLength(marginLogicalRight, containerRe
lativeLogicalWidth); |
4063 logicalLeftValue = valueForLength(logicalLeft, containerLogicalWidth, re
nderView); | 4034 logicalLeftValue = valueForLength(logicalLeft, containerLogicalWidth); |
4064 | 4035 |
4065 // Solve for 'right' | 4036 // Solve for 'right' |
4066 logicalRightValue = availableSpace - (logicalLeftValue + marginLogicalLe
ftAlias + marginLogicalRightAlias); | 4037 logicalRightValue = availableSpace - (logicalLeftValue + marginLogicalLe
ftAlias + marginLogicalRightAlias); |
4067 } else if (marginLogicalLeft.isAuto()) { | 4038 } else if (marginLogicalLeft.isAuto()) { |
4068 marginLogicalRightAlias = valueForLength(marginLogicalRight, containerRe
lativeLogicalWidth, renderView); | 4039 marginLogicalRightAlias = valueForLength(marginLogicalRight, containerRe
lativeLogicalWidth); |
4069 logicalLeftValue = valueForLength(logicalLeft, containerLogicalWidth, re
nderView); | 4040 logicalLeftValue = valueForLength(logicalLeft, containerLogicalWidth); |
4070 logicalRightValue = valueForLength(logicalRight, containerLogicalWidth,
renderView); | 4041 logicalRightValue = valueForLength(logicalRight, containerLogicalWidth); |
4071 | 4042 |
4072 // Solve for 'margin-left' | 4043 // Solve for 'margin-left' |
4073 marginLogicalLeftAlias = availableSpace - (logicalLeftValue + logicalRig
htValue + marginLogicalRightAlias); | 4044 marginLogicalLeftAlias = availableSpace - (logicalLeftValue + logicalRig
htValue + marginLogicalRightAlias); |
4074 } else if (marginLogicalRight.isAuto()) { | 4045 } else if (marginLogicalRight.isAuto()) { |
4075 marginLogicalLeftAlias = valueForLength(marginLogicalLeft, containerRela
tiveLogicalWidth, renderView); | 4046 marginLogicalLeftAlias = valueForLength(marginLogicalLeft, containerRela
tiveLogicalWidth); |
4076 logicalLeftValue = valueForLength(logicalLeft, containerLogicalWidth, re
nderView); | 4047 logicalLeftValue = valueForLength(logicalLeft, containerLogicalWidth); |
4077 logicalRightValue = valueForLength(logicalRight, containerLogicalWidth,
renderView); | 4048 logicalRightValue = valueForLength(logicalRight, containerLogicalWidth); |
4078 | 4049 |
4079 // Solve for 'margin-right' | 4050 // Solve for 'margin-right' |
4080 marginLogicalRightAlias = availableSpace - (logicalLeftValue + logicalRi
ghtValue + marginLogicalLeftAlias); | 4051 marginLogicalRightAlias = availableSpace - (logicalLeftValue + logicalRi
ghtValue + marginLogicalLeftAlias); |
4081 } else { | 4052 } else { |
4082 // Nothing is 'auto', just calculate the values. | 4053 // Nothing is 'auto', just calculate the values. |
4083 marginLogicalLeftAlias = valueForLength(marginLogicalLeft, containerRela
tiveLogicalWidth, renderView); | 4054 marginLogicalLeftAlias = valueForLength(marginLogicalLeft, containerRela
tiveLogicalWidth); |
4084 marginLogicalRightAlias = valueForLength(marginLogicalRight, containerRe
lativeLogicalWidth, renderView); | 4055 marginLogicalRightAlias = valueForLength(marginLogicalRight, containerRe
lativeLogicalWidth); |
4085 logicalRightValue = valueForLength(logicalRight, containerLogicalWidth,
renderView); | 4056 logicalRightValue = valueForLength(logicalRight, containerLogicalWidth); |
4086 logicalLeftValue = valueForLength(logicalLeft, containerLogicalWidth, re
nderView); | 4057 logicalLeftValue = valueForLength(logicalLeft, containerLogicalWidth); |
4087 // If the containing block is right-to-left, then push the left position
as far to the right as possible | 4058 // If the containing block is right-to-left, then push the left position
as far to the right as possible |
4088 if (containerDirection == RTL) { | 4059 if (containerDirection == RTL) { |
4089 int totalLogicalWidth = computedValues.m_extent + logicalLeftValue +
logicalRightValue + marginLogicalLeftAlias + marginLogicalRightAlias; | 4060 int totalLogicalWidth = computedValues.m_extent + logicalLeftValue +
logicalRightValue + marginLogicalLeftAlias + marginLogicalRightAlias; |
4090 logicalLeftValue = containerLogicalWidth - (totalLogicalWidth - logi
calLeftValue); | 4061 logicalLeftValue = containerLogicalWidth - (totalLogicalWidth - logi
calLeftValue); |
4091 } | 4062 } |
4092 } | 4063 } |
4093 | 4064 |
4094 /*-----------------------------------------------------------------------*\ | 4065 /*-----------------------------------------------------------------------*\ |
4095 * 6. If at this point the values are over-constrained, ignore the value | 4066 * 6. If at this point the values are over-constrained, ignore the value |
4096 * for either 'left' (in case the 'direction' property of the | 4067 * for either 'left' (in case the 'direction' property of the |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4138 const LayoutUnit containerRelativeLogicalWidth = containingBlockLogicalWidth
ForPositioned(containerBlock, 0, false); | 4109 const LayoutUnit containerRelativeLogicalWidth = containingBlockLogicalWidth
ForPositioned(containerBlock, 0, false); |
4139 | 4110 |
4140 // Variables to solve. | 4111 // Variables to solve. |
4141 Length marginBefore = style()->marginBefore(); | 4112 Length marginBefore = style()->marginBefore(); |
4142 Length marginAfter = style()->marginAfter(); | 4113 Length marginAfter = style()->marginAfter(); |
4143 LayoutUnit& marginBeforeAlias = computedValues.m_margins.m_before; | 4114 LayoutUnit& marginBeforeAlias = computedValues.m_margins.m_before; |
4144 LayoutUnit& marginAfterAlias = computedValues.m_margins.m_after; | 4115 LayoutUnit& marginAfterAlias = computedValues.m_margins.m_after; |
4145 | 4116 |
4146 Length logicalTop = style()->logicalTop(); | 4117 Length logicalTop = style()->logicalTop(); |
4147 Length logicalBottom = style()->logicalBottom(); | 4118 Length logicalBottom = style()->logicalBottom(); |
4148 RenderView* renderView = view(); | |
4149 | 4119 |
4150 /*-----------------------------------------------------------------------*\ | 4120 /*-----------------------------------------------------------------------*\ |
4151 * 1. The used value of 'height' is determined as for inline replaced | 4121 * 1. The used value of 'height' is determined as for inline replaced |
4152 * elements. | 4122 * elements. |
4153 \*-----------------------------------------------------------------------*/ | 4123 \*-----------------------------------------------------------------------*/ |
4154 // NOTE: This value of height is FINAL in that the min/max height calculatio
ns | 4124 // NOTE: This value of height is FINAL in that the min/max height calculatio
ns |
4155 // are dealt with in computeReplacedHeight(). This means that the steps to
produce | 4125 // are dealt with in computeReplacedHeight(). This means that the steps to
produce |
4156 // correct max/min in the non-replaced version, are not necessary. | 4126 // correct max/min in the non-replaced version, are not necessary. |
4157 computedValues.m_extent = computeReplacedLogicalHeight() + borderAndPaddingL
ogicalHeight(); | 4127 computedValues.m_extent = computeReplacedLogicalHeight() + borderAndPaddingL
ogicalHeight(); |
4158 const LayoutUnit availableSpace = containerLogicalHeight - computedValues.m_
extent; | 4128 const LayoutUnit availableSpace = containerLogicalHeight - computedValues.m_
extent; |
(...skipping 23 matching lines...) Expand all Loading... |
4182 * 'auto', solve the equation under the extra constraint that the two | 4152 * 'auto', solve the equation under the extra constraint that the two |
4183 * margins must get equal values. | 4153 * margins must get equal values. |
4184 \*-----------------------------------------------------------------------*/ | 4154 \*-----------------------------------------------------------------------*/ |
4185 LayoutUnit logicalTopValue = 0; | 4155 LayoutUnit logicalTopValue = 0; |
4186 LayoutUnit logicalBottomValue = 0; | 4156 LayoutUnit logicalBottomValue = 0; |
4187 | 4157 |
4188 if (marginBefore.isAuto() && marginAfter.isAuto()) { | 4158 if (marginBefore.isAuto() && marginAfter.isAuto()) { |
4189 // 'top' and 'bottom' cannot be 'auto' due to step 2 and 3 combined. | 4159 // 'top' and 'bottom' cannot be 'auto' due to step 2 and 3 combined. |
4190 ASSERT(!(logicalTop.isAuto() || logicalBottom.isAuto())); | 4160 ASSERT(!(logicalTop.isAuto() || logicalBottom.isAuto())); |
4191 | 4161 |
4192 logicalTopValue = valueForLength(logicalTop, containerLogicalHeight, ren
derView); | 4162 logicalTopValue = valueForLength(logicalTop, containerLogicalHeight); |
4193 logicalBottomValue = valueForLength(logicalBottom, containerLogicalHeigh
t, renderView); | 4163 logicalBottomValue = valueForLength(logicalBottom, containerLogicalHeigh
t); |
4194 | 4164 |
4195 LayoutUnit difference = availableSpace - (logicalTopValue + logicalBotto
mValue); | 4165 LayoutUnit difference = availableSpace - (logicalTopValue + logicalBotto
mValue); |
4196 // NOTE: This may result in negative values. | 4166 // NOTE: This may result in negative values. |
4197 marginBeforeAlias = difference / 2; // split the difference | 4167 marginBeforeAlias = difference / 2; // split the difference |
4198 marginAfterAlias = difference - marginBeforeAlias; // account for odd va
lued differences | 4168 marginAfterAlias = difference - marginBeforeAlias; // account for odd va
lued differences |
4199 | 4169 |
4200 /*-----------------------------------------------------------------------*\ | 4170 /*-----------------------------------------------------------------------*\ |
4201 * 5. If at this point there is only one 'auto' left, solve the equation | 4171 * 5. If at this point there is only one 'auto' left, solve the equation |
4202 * for that value. | 4172 * for that value. |
4203 \*-----------------------------------------------------------------------*/ | 4173 \*-----------------------------------------------------------------------*/ |
4204 } else if (logicalTop.isAuto()) { | 4174 } else if (logicalTop.isAuto()) { |
4205 marginBeforeAlias = valueForLength(marginBefore, containerRelativeLogica
lWidth, renderView); | 4175 marginBeforeAlias = valueForLength(marginBefore, containerRelativeLogica
lWidth); |
4206 marginAfterAlias = valueForLength(marginAfter, containerRelativeLogicalW
idth, renderView); | 4176 marginAfterAlias = valueForLength(marginAfter, containerRelativeLogicalW
idth); |
4207 logicalBottomValue = valueForLength(logicalBottom, containerLogicalHeigh
t, renderView); | 4177 logicalBottomValue = valueForLength(logicalBottom, containerLogicalHeigh
t); |
4208 | 4178 |
4209 // Solve for 'top' | 4179 // Solve for 'top' |
4210 logicalTopValue = availableSpace - (logicalBottomValue + marginBeforeAli
as + marginAfterAlias); | 4180 logicalTopValue = availableSpace - (logicalBottomValue + marginBeforeAli
as + marginAfterAlias); |
4211 } else if (logicalBottom.isAuto()) { | 4181 } else if (logicalBottom.isAuto()) { |
4212 marginBeforeAlias = valueForLength(marginBefore, containerRelativeLogica
lWidth, renderView); | 4182 marginBeforeAlias = valueForLength(marginBefore, containerRelativeLogica
lWidth); |
4213 marginAfterAlias = valueForLength(marginAfter, containerRelativeLogicalW
idth, renderView); | 4183 marginAfterAlias = valueForLength(marginAfter, containerRelativeLogicalW
idth); |
4214 logicalTopValue = valueForLength(logicalTop, containerLogicalHeight, ren
derView); | 4184 logicalTopValue = valueForLength(logicalTop, containerLogicalHeight); |
4215 | 4185 |
4216 // Solve for 'bottom' | 4186 // Solve for 'bottom' |
4217 // NOTE: It is not necessary to solve for 'bottom' because we don't ever | 4187 // NOTE: It is not necessary to solve for 'bottom' because we don't ever |
4218 // use the value. | 4188 // use the value. |
4219 } else if (marginBefore.isAuto()) { | 4189 } else if (marginBefore.isAuto()) { |
4220 marginAfterAlias = valueForLength(marginAfter, containerRelativeLogicalW
idth, renderView); | 4190 marginAfterAlias = valueForLength(marginAfter, containerRelativeLogicalW
idth); |
4221 logicalTopValue = valueForLength(logicalTop, containerLogicalHeight, ren
derView); | 4191 logicalTopValue = valueForLength(logicalTop, containerLogicalHeight); |
4222 logicalBottomValue = valueForLength(logicalBottom, containerLogicalHeigh
t, renderView); | 4192 logicalBottomValue = valueForLength(logicalBottom, containerLogicalHeigh
t); |
4223 | 4193 |
4224 // Solve for 'margin-top' | 4194 // Solve for 'margin-top' |
4225 marginBeforeAlias = availableSpace - (logicalTopValue + logicalBottomVal
ue + marginAfterAlias); | 4195 marginBeforeAlias = availableSpace - (logicalTopValue + logicalBottomVal
ue + marginAfterAlias); |
4226 } else if (marginAfter.isAuto()) { | 4196 } else if (marginAfter.isAuto()) { |
4227 marginBeforeAlias = valueForLength(marginBefore, containerRelativeLogica
lWidth, renderView); | 4197 marginBeforeAlias = valueForLength(marginBefore, containerRelativeLogica
lWidth); |
4228 logicalTopValue = valueForLength(logicalTop, containerLogicalHeight, ren
derView); | 4198 logicalTopValue = valueForLength(logicalTop, containerLogicalHeight); |
4229 logicalBottomValue = valueForLength(logicalBottom, containerLogicalHeigh
t, renderView); | 4199 logicalBottomValue = valueForLength(logicalBottom, containerLogicalHeigh
t); |
4230 | 4200 |
4231 // Solve for 'margin-bottom' | 4201 // Solve for 'margin-bottom' |
4232 marginAfterAlias = availableSpace - (logicalTopValue + logicalBottomValu
e + marginBeforeAlias); | 4202 marginAfterAlias = availableSpace - (logicalTopValue + logicalBottomValu
e + marginBeforeAlias); |
4233 } else { | 4203 } else { |
4234 // Nothing is 'auto', just calculate the values. | 4204 // Nothing is 'auto', just calculate the values. |
4235 marginBeforeAlias = valueForLength(marginBefore, containerRelativeLogica
lWidth, renderView); | 4205 marginBeforeAlias = valueForLength(marginBefore, containerRelativeLogica
lWidth); |
4236 marginAfterAlias = valueForLength(marginAfter, containerRelativeLogicalW
idth, renderView); | 4206 marginAfterAlias = valueForLength(marginAfter, containerRelativeLogicalW
idth); |
4237 logicalTopValue = valueForLength(logicalTop, containerLogicalHeight, ren
derView); | 4207 logicalTopValue = valueForLength(logicalTop, containerLogicalHeight); |
4238 // NOTE: It is not necessary to solve for 'bottom' because we don't ever | 4208 // NOTE: It is not necessary to solve for 'bottom' because we don't ever |
4239 // use the value. | 4209 // use the value. |
4240 } | 4210 } |
4241 | 4211 |
4242 /*-----------------------------------------------------------------------*\ | 4212 /*-----------------------------------------------------------------------*\ |
4243 * 6. If at this point the values are over-constrained, ignore the value | 4213 * 6. If at this point the values are over-constrained, ignore the value |
4244 * for 'bottom' and solve for that value. | 4214 * for 'bottom' and solve for that value. |
4245 \*-----------------------------------------------------------------------*/ | 4215 \*-----------------------------------------------------------------------*/ |
4246 // NOTE: It is not necessary to do this step because we don't end up using | 4216 // NOTE: It is not necessary to do this step because we don't end up using |
4247 // the value of 'bottom' regardless of whether the values are over-constrain
ed | 4217 // the value of 'bottom' regardless of whether the values are over-constrain
ed |
(...skipping 632 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4880 // FIXME: This should probably include viewport percentage heights as well. | 4850 // FIXME: This should probably include viewport percentage heights as well. |
4881 return style()->height().isPercent() || style()->width().isPercent() | 4851 return style()->height().isPercent() || style()->width().isPercent() |
4882 || style()->maxHeight().isPercent() || style()->maxWidth().isPercent() | 4852 || style()->maxHeight().isPercent() || style()->maxWidth().isPercent() |
4883 || style()->minHeight().isPercent() || style()->minWidth().isPercent(); | 4853 || style()->minHeight().isPercent() || style()->minWidth().isPercent(); |
4884 } | 4854 } |
4885 | 4855 |
4886 bool RenderBox::hasRelativeLogicalHeight() const | 4856 bool RenderBox::hasRelativeLogicalHeight() const |
4887 { | 4857 { |
4888 return style()->logicalHeight().isPercent() | 4858 return style()->logicalHeight().isPercent() |
4889 || style()->logicalMinHeight().isPercent() | 4859 || style()->logicalMinHeight().isPercent() |
4890 || style()->logicalMaxHeight().isPercent() | 4860 || style()->logicalMaxHeight().isPercent(); |
4891 || style()->logicalHeight().isViewportPercentage() | |
4892 || style()->logicalMinHeight().isViewportPercentage() | |
4893 || style()->logicalMaxHeight().isViewportPercentage(); | |
4894 } | 4861 } |
4895 | 4862 |
4896 static void markBoxForRelayoutAfterSplit(RenderBox* box) | 4863 static void markBoxForRelayoutAfterSplit(RenderBox* box) |
4897 { | 4864 { |
4898 // FIXME: The table code should handle that automatically. If not, | 4865 // FIXME: The table code should handle that automatically. If not, |
4899 // we should fix it and remove the table part checks. | 4866 // we should fix it and remove the table part checks. |
4900 if (box->isTable()) { | 4867 if (box->isTable()) { |
4901 // Because we may have added some sections with already computed column
structures, we need to | 4868 // Because we may have added some sections with already computed column
structures, we need to |
4902 // sync the table structure with them now. This avoids crashes when addi
ng new cells to the table. | 4869 // sync the table structure with them now. This avoids crashes when addi
ng new cells to the table. |
4903 toRenderTable(box)->forceSectionsRecalc(); | 4870 toRenderTable(box)->forceSectionsRecalc(); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4950 return 0; | 4917 return 0; |
4951 | 4918 |
4952 if (!layoutState && !flowThreadContainingBlock()) | 4919 if (!layoutState && !flowThreadContainingBlock()) |
4953 return 0; | 4920 return 0; |
4954 | 4921 |
4955 RenderBlock* containerBlock = containingBlock(); | 4922 RenderBlock* containerBlock = containingBlock(); |
4956 return containerBlock->offsetFromLogicalTopOfFirstPage() + logicalTop(); | 4923 return containerBlock->offsetFromLogicalTopOfFirstPage() + logicalTop(); |
4957 } | 4924 } |
4958 | 4925 |
4959 } // namespace WebCore | 4926 } // namespace WebCore |
OLD | NEW |