| 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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 #include "core/rendering/RenderGeometryMap.h" | 51 #include "core/rendering/RenderGeometryMap.h" |
| 52 #include "core/rendering/RenderGrid.h" | 52 #include "core/rendering/RenderGrid.h" |
| 53 #include "core/rendering/RenderInline.h" | 53 #include "core/rendering/RenderInline.h" |
| 54 #include "core/rendering/RenderLayer.h" | 54 #include "core/rendering/RenderLayer.h" |
| 55 #include "core/rendering/RenderLayerCompositor.h" | 55 #include "core/rendering/RenderLayerCompositor.h" |
| 56 #include "core/rendering/RenderListMarker.h" | 56 #include "core/rendering/RenderListMarker.h" |
| 57 #include "core/rendering/RenderRegion.h" | 57 #include "core/rendering/RenderRegion.h" |
| 58 #include "core/rendering/RenderTableCell.h" | 58 #include "core/rendering/RenderTableCell.h" |
| 59 #include "core/rendering/RenderTheme.h" | 59 #include "core/rendering/RenderTheme.h" |
| 60 #include "core/rendering/RenderView.h" | 60 #include "core/rendering/RenderView.h" |
| 61 #include "platform/LengthFunctions.h" |
| 61 #include "platform/geometry/FloatQuad.h" | 62 #include "platform/geometry/FloatQuad.h" |
| 62 #include "platform/geometry/TransformState.h" | 63 #include "platform/geometry/TransformState.h" |
| 63 | 64 |
| 64 using namespace std; | 65 using namespace std; |
| 65 | 66 |
| 66 namespace WebCore { | 67 namespace WebCore { |
| 67 | 68 |
| 68 using namespace HTMLNames; | 69 using namespace HTMLNames; |
| 69 | 70 |
| 70 // Used by flexible boxes when flexing this element and by table cells. | 71 // Used by flexible boxes when flexing this element and by table cells. |
| (...skipping 651 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 722 result.move(box.width() + reflectionOffset(), 0); | 723 result.move(box.width() + reflectionOffset(), 0); |
| 723 break; | 724 break; |
| 724 } | 725 } |
| 725 return result; | 726 return result; |
| 726 } | 727 } |
| 727 | 728 |
| 728 int RenderBox::reflectionOffset() const | 729 int RenderBox::reflectionOffset() const |
| 729 { | 730 { |
| 730 if (!style()->boxReflect()) | 731 if (!style()->boxReflect()) |
| 731 return 0; | 732 return 0; |
| 732 RenderView* renderView = view(); | |
| 733 if (style()->boxReflect()->direction() == ReflectionLeft || style()->boxRefl
ect()->direction() == ReflectionRight) | 733 if (style()->boxReflect()->direction() == ReflectionLeft || style()->boxRefl
ect()->direction() == ReflectionRight) |
| 734 return valueForLength(style()->boxReflect()->offset(), borderBoxRect().w
idth(), renderView); | 734 return valueForLength(style()->boxReflect()->offset(), borderBoxRect().w
idth()); |
| 735 return valueForLength(style()->boxReflect()->offset(), borderBoxRect().heigh
t(), renderView); | 735 return valueForLength(style()->boxReflect()->offset(), borderBoxRect().heigh
t()); |
| 736 } | 736 } |
| 737 | 737 |
| 738 LayoutRect RenderBox::reflectedRect(const LayoutRect& r) const | 738 LayoutRect RenderBox::reflectedRect(const LayoutRect& r) const |
| 739 { | 739 { |
| 740 if (!style()->boxReflect()) | 740 if (!style()->boxReflect()) |
| 741 return LayoutRect(); | 741 return LayoutRect(); |
| 742 | 742 |
| 743 LayoutRect box = borderBoxRect(); | 743 LayoutRect box = borderBoxRect(); |
| 744 LayoutRect result = r; | 744 LayoutRect result = r; |
| 745 switch (style()->boxReflect()->direction()) { | 745 switch (style()->boxReflect()->direction()) { |
| (...skipping 563 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1309 // FIXME: Should eventually give the theme control over whether the box shad
ow should paint, since controls could have | 1309 // FIXME: Should eventually give the theme control over whether the box shad
ow should paint, since controls could have |
| 1310 // custom shadows of their own. | 1310 // custom shadows of their own. |
| 1311 if (!boxShadowShouldBeAppliedToBackground(bleedAvoidance)) | 1311 if (!boxShadowShouldBeAppliedToBackground(bleedAvoidance)) |
| 1312 paintBoxShadow(paintInfo, paintRect, style(), Normal); | 1312 paintBoxShadow(paintInfo, paintRect, style(), Normal); |
| 1313 | 1313 |
| 1314 GraphicsContextStateSaver stateSaver(*paintInfo.context, false); | 1314 GraphicsContextStateSaver stateSaver(*paintInfo.context, false); |
| 1315 if (bleedAvoidance == BackgroundBleedUseTransparencyLayer) { | 1315 if (bleedAvoidance == BackgroundBleedUseTransparencyLayer) { |
| 1316 // To avoid the background color bleeding out behind the border, we'll r
ender background and border | 1316 // To avoid the background color bleeding out behind the border, we'll r
ender background and border |
| 1317 // into a transparency layer, and then clip that in one go (which requir
es setting up the clip before | 1317 // into a transparency layer, and then clip that in one go (which requir
es setting up the clip before |
| 1318 // beginning the layer). | 1318 // beginning the layer). |
| 1319 RoundedRect border = style()->getRoundedBorderFor(paintRect, view()); | 1319 RoundedRect border = style()->getRoundedBorderFor(paintRect); |
| 1320 stateSaver.save(); | 1320 stateSaver.save(); |
| 1321 paintInfo.context->clipRoundedRect(border); | 1321 paintInfo.context->clipRoundedRect(border); |
| 1322 paintInfo.context->beginTransparencyLayer(1); | 1322 paintInfo.context->beginTransparencyLayer(1); |
| 1323 } | 1323 } |
| 1324 | 1324 |
| 1325 paintBackgroundWithBorderAndBoxShadow(paintInfo, paintRect, bleedAvoidance); | 1325 paintBackgroundWithBorderAndBoxShadow(paintInfo, paintRect, bleedAvoidance); |
| 1326 | 1326 |
| 1327 if (bleedAvoidance == BackgroundBleedUseTransparencyLayer) | 1327 if (bleedAvoidance == BackgroundBleedUseTransparencyLayer) |
| 1328 paintInfo.context->endLayer(); | 1328 paintInfo.context->endLayer(); |
| 1329 } | 1329 } |
| (...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1795 clipRect.move(layer()->scrollableArea()->verticalScrollbarWidth(relevanc
y), 0); | 1795 clipRect.move(layer()->scrollableArea()->verticalScrollbarWidth(relevanc
y), 0); |
| 1796 clipRect.contract(layer()->scrollableArea()->verticalScrollbarWidth(relevanc
y), layer()->scrollableArea()->horizontalScrollbarHeight(relevancy)); | 1796 clipRect.contract(layer()->scrollableArea()->verticalScrollbarWidth(relevanc
y), layer()->scrollableArea()->horizontalScrollbarHeight(relevancy)); |
| 1797 | 1797 |
| 1798 return clipRect; | 1798 return clipRect; |
| 1799 } | 1799 } |
| 1800 | 1800 |
| 1801 LayoutRect RenderBox::clipRect(const LayoutPoint& location, RenderRegion* region
) | 1801 LayoutRect RenderBox::clipRect(const LayoutPoint& location, RenderRegion* region
) |
| 1802 { | 1802 { |
| 1803 LayoutRect borderBoxRect = borderBoxRectInRegion(region); | 1803 LayoutRect borderBoxRect = borderBoxRectInRegion(region); |
| 1804 LayoutRect clipRect = LayoutRect(borderBoxRect.location() + location, border
BoxRect.size()); | 1804 LayoutRect clipRect = LayoutRect(borderBoxRect.location() + location, border
BoxRect.size()); |
| 1805 RenderView* renderView = view(); | |
| 1806 | 1805 |
| 1807 if (!style()->clipLeft().isAuto()) { | 1806 if (!style()->clipLeft().isAuto()) { |
| 1808 LayoutUnit c = valueForLength(style()->clipLeft(), borderBoxRect.width()
, renderView); | 1807 LayoutUnit c = valueForLength(style()->clipLeft(), borderBoxRect.width()
); |
| 1809 clipRect.move(c, 0); | 1808 clipRect.move(c, 0); |
| 1810 clipRect.contract(c, 0); | 1809 clipRect.contract(c, 0); |
| 1811 } | 1810 } |
| 1812 | 1811 |
| 1813 // We don't use the region-specific border box's width and height since clip
offsets are (stupidly) specified | 1812 // We don't use the region-specific border box's width and height since clip
offsets are (stupidly) specified |
| 1814 // from the left and top edges. Therefore it's better to avoid constraining
to smaller widths and heights. | 1813 // from the left and top edges. Therefore it's better to avoid constraining
to smaller widths and heights. |
| 1815 | 1814 |
| 1816 if (!style()->clipRight().isAuto()) | 1815 if (!style()->clipRight().isAuto()) |
| 1817 clipRect.contract(width() - valueForLength(style()->clipRight(), width()
, renderView), 0); | 1816 clipRect.contract(width() - valueForLength(style()->clipRight(), width()
), 0); |
| 1818 | 1817 |
| 1819 if (!style()->clipTop().isAuto()) { | 1818 if (!style()->clipTop().isAuto()) { |
| 1820 LayoutUnit c = valueForLength(style()->clipTop(), borderBoxRect.height()
, renderView); | 1819 LayoutUnit c = valueForLength(style()->clipTop(), borderBoxRect.height()
); |
| 1821 clipRect.move(0, c); | 1820 clipRect.move(0, c); |
| 1822 clipRect.contract(0, c); | 1821 clipRect.contract(0, c); |
| 1823 } | 1822 } |
| 1824 | 1823 |
| 1825 if (!style()->clipBottom().isAuto()) | 1824 if (!style()->clipBottom().isAuto()) |
| 1826 clipRect.contract(0, height() - valueForLength(style()->clipBottom(), he
ight(), renderView)); | 1825 clipRect.contract(0, height() - valueForLength(style()->clipBottom(), he
ight())); |
| 1827 | 1826 |
| 1828 return clipRect; | 1827 return clipRect; |
| 1829 } | 1828 } |
| 1830 | 1829 |
| 1831 LayoutUnit RenderBox::shrinkLogicalWidthToAvoidFloats(LayoutUnit childMarginStar
t, LayoutUnit childMarginEnd, const RenderBlockFlow* cb, RenderRegion* region) c
onst | 1830 LayoutUnit RenderBox::shrinkLogicalWidthToAvoidFloats(LayoutUnit childMarginStar
t, LayoutUnit childMarginEnd, const RenderBlockFlow* cb, RenderRegion* region) c
onst |
| 1832 { | 1831 { |
| 1833 RenderRegion* containingBlockRegion = 0; | 1832 RenderRegion* containingBlockRegion = 0; |
| 1834 LayoutUnit logicalTopPosition = logicalTop(); | 1833 LayoutUnit logicalTopPosition = logicalTop(); |
| 1835 if (region) { | 1834 if (region) { |
| 1836 LayoutUnit offsetFromLogicalTopOfRegion = region ? region->logicalTopFor
FlowThreadContent() - offsetFromLogicalTopOfFirstPage() : LayoutUnit(); | 1835 LayoutUnit offsetFromLogicalTopOfRegion = region ? region->logicalTopFor
FlowThreadContent() - offsetFromLogicalTopOfFirstPage() : LayoutUnit(); |
| (...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2334 | 2333 |
| 2335 RenderStyle* styleToUse = style(); | 2334 RenderStyle* styleToUse = style(); |
| 2336 Length logicalWidthLength = treatAsReplaced ? Length(computeReplacedLogicalW
idth(), Fixed) : styleToUse->logicalWidth(); | 2335 Length logicalWidthLength = treatAsReplaced ? Length(computeReplacedLogicalW
idth(), Fixed) : styleToUse->logicalWidth(); |
| 2337 | 2336 |
| 2338 RenderBlock* cb = containingBlock(); | 2337 RenderBlock* cb = containingBlock(); |
| 2339 LayoutUnit containerLogicalWidth = max<LayoutUnit>(0, containingBlockLogical
WidthForContentInRegion(region)); | 2338 LayoutUnit containerLogicalWidth = max<LayoutUnit>(0, containingBlockLogical
WidthForContentInRegion(region)); |
| 2340 bool hasPerpendicularContainingBlock = cb->isHorizontalWritingMode() != isHo
rizontalWritingMode(); | 2339 bool hasPerpendicularContainingBlock = cb->isHorizontalWritingMode() != isHo
rizontalWritingMode(); |
| 2341 | 2340 |
| 2342 if (isInline() && !isInlineBlockOrInlineTable()) { | 2341 if (isInline() && !isInlineBlockOrInlineTable()) { |
| 2343 // just calculate margins | 2342 // just calculate margins |
| 2344 RenderView* renderView = view(); | 2343 computedValues.m_margins.m_start = minimumValueForLength(styleToUse->mar
ginStart(), containerLogicalWidth); |
| 2345 computedValues.m_margins.m_start = minimumValueForLength(styleToUse->mar
ginStart(), containerLogicalWidth, renderView); | 2344 computedValues.m_margins.m_end = minimumValueForLength(styleToUse->margi
nEnd(), containerLogicalWidth); |
| 2346 computedValues.m_margins.m_end = minimumValueForLength(styleToUse->margi
nEnd(), containerLogicalWidth, renderView); | |
| 2347 if (treatAsReplaced) | 2345 if (treatAsReplaced) |
| 2348 computedValues.m_extent = max<LayoutUnit>(floatValueForLength(logica
lWidthLength, 0, 0) + borderAndPaddingLogicalWidth(), minPreferredLogicalWidth()
); | 2346 computedValues.m_extent = max<LayoutUnit>(floatValueForLength(logica
lWidthLength, 0) + borderAndPaddingLogicalWidth(), minPreferredLogicalWidth()); |
| 2349 return; | 2347 return; |
| 2350 } | 2348 } |
| 2351 | 2349 |
| 2352 // Width calculations | 2350 // Width calculations |
| 2353 if (treatAsReplaced) | 2351 if (treatAsReplaced) |
| 2354 computedValues.m_extent = logicalWidthLength.value() + borderAndPaddingL
ogicalWidth(); | 2352 computedValues.m_extent = logicalWidthLength.value() + borderAndPaddingL
ogicalWidth(); |
| 2355 else { | 2353 else { |
| 2356 LayoutUnit containerWidthInInlineDirection = containerLogicalWidth; | 2354 LayoutUnit containerWidthInInlineDirection = containerLogicalWidth; |
| 2357 if (hasPerpendicularContainingBlock) | 2355 if (hasPerpendicularContainingBlock) |
| 2358 containerWidthInInlineDirection = perpendicularContainingBlockLogica
lHeight(); | 2356 containerWidthInInlineDirection = perpendicularContainingBlockLogica
lHeight(); |
| 2359 LayoutUnit preferredWidth = computeLogicalWidthInRegionUsing(MainOrPrefe
rredSize, styleToUse->logicalWidth(), containerWidthInInlineDirection, cb, regio
n); | 2357 LayoutUnit preferredWidth = computeLogicalWidthInRegionUsing(MainOrPrefe
rredSize, styleToUse->logicalWidth(), containerWidthInInlineDirection, cb, regio
n); |
| 2360 computedValues.m_extent = constrainLogicalWidthInRegionByMinMax(preferre
dWidth, containerWidthInInlineDirection, cb, region); | 2358 computedValues.m_extent = constrainLogicalWidthInRegionByMinMax(preferre
dWidth, containerWidthInInlineDirection, cb, region); |
| 2361 } | 2359 } |
| 2362 | 2360 |
| 2363 // Margin calculations. | 2361 // Margin calculations. |
| 2364 if (hasPerpendicularContainingBlock || isFloating() || isInline()) { | 2362 if (hasPerpendicularContainingBlock || isFloating() || isInline()) { |
| 2365 RenderView* renderView = view(); | 2363 computedValues.m_margins.m_start = minimumValueForLength(styleToUse->mar
ginStart(), containerLogicalWidth); |
| 2366 computedValues.m_margins.m_start = minimumValueForLength(styleToUse->mar
ginStart(), containerLogicalWidth, renderView); | 2364 computedValues.m_margins.m_end = minimumValueForLength(styleToUse->margi
nEnd(), containerLogicalWidth); |
| 2367 computedValues.m_margins.m_end = minimumValueForLength(styleToUse->margi
nEnd(), containerLogicalWidth, renderView); | |
| 2368 } else { | 2365 } else { |
| 2369 LayoutUnit containerLogicalWidthForAutoMargins = containerLogicalWidth; | 2366 LayoutUnit containerLogicalWidthForAutoMargins = containerLogicalWidth; |
| 2370 if (avoidsFloats() && cb->containsFloats()) | 2367 if (avoidsFloats() && cb->containsFloats()) |
| 2371 containerLogicalWidthForAutoMargins = containingBlockAvailableLineWi
dthInRegion(region); | 2368 containerLogicalWidthForAutoMargins = containingBlockAvailableLineWi
dthInRegion(region); |
| 2372 bool hasInvertedDirection = cb->style()->isLeftToRightDirection() != sty
le()->isLeftToRightDirection(); | 2369 bool hasInvertedDirection = cb->style()->isLeftToRightDirection() != sty
le()->isLeftToRightDirection(); |
| 2373 computeInlineDirectionMargins(cb, containerLogicalWidthForAutoMargins, c
omputedValues.m_extent, | 2370 computeInlineDirectionMargins(cb, containerLogicalWidthForAutoMargins, c
omputedValues.m_extent, |
| 2374 hasInvertedDirection ? computedValues.m_margins.m_end : computedValu
es.m_margins.m_start, | 2371 hasInvertedDirection ? computedValues.m_margins.m_end : computedValu
es.m_margins.m_start, |
| 2375 hasInvertedDirection ? computedValues.m_margins.m_start : computedVa
lues.m_margins.m_end); | 2372 hasInvertedDirection ? computedValues.m_margins.m_start : computedVa
lues.m_margins.m_end); |
| 2376 } | 2373 } |
| 2377 | 2374 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 2401 | 2398 |
| 2402 LayoutUnit RenderBox::fillAvailableMeasure(LayoutUnit availableLogicalWidth) con
st | 2399 LayoutUnit RenderBox::fillAvailableMeasure(LayoutUnit availableLogicalWidth) con
st |
| 2403 { | 2400 { |
| 2404 LayoutUnit marginStart = 0; | 2401 LayoutUnit marginStart = 0; |
| 2405 LayoutUnit marginEnd = 0; | 2402 LayoutUnit marginEnd = 0; |
| 2406 return fillAvailableMeasure(availableLogicalWidth, marginStart, marginEnd); | 2403 return fillAvailableMeasure(availableLogicalWidth, marginStart, marginEnd); |
| 2407 } | 2404 } |
| 2408 | 2405 |
| 2409 LayoutUnit RenderBox::fillAvailableMeasure(LayoutUnit availableLogicalWidth, Lay
outUnit& marginStart, LayoutUnit& marginEnd) const | 2406 LayoutUnit RenderBox::fillAvailableMeasure(LayoutUnit availableLogicalWidth, Lay
outUnit& marginStart, LayoutUnit& marginEnd) const |
| 2410 { | 2407 { |
| 2411 RenderView* renderView = view(); | 2408 marginStart = minimumValueForLength(style()->marginStart(), availableLogical
Width); |
| 2412 marginStart = minimumValueForLength(style()->marginStart(), availableLogical
Width, renderView); | 2409 marginEnd = minimumValueForLength(style()->marginEnd(), availableLogicalWidt
h); |
| 2413 marginEnd = minimumValueForLength(style()->marginEnd(), availableLogicalWidt
h, renderView); | |
| 2414 return availableLogicalWidth - marginStart - marginEnd; | 2410 return availableLogicalWidth - marginStart - marginEnd; |
| 2415 } | 2411 } |
| 2416 | 2412 |
| 2417 LayoutUnit RenderBox::computeIntrinsicLogicalWidthUsing(Length logicalWidthLengt
h, LayoutUnit availableLogicalWidth, LayoutUnit borderAndPadding) const | 2413 LayoutUnit RenderBox::computeIntrinsicLogicalWidthUsing(Length logicalWidthLengt
h, LayoutUnit availableLogicalWidth, LayoutUnit borderAndPadding) const |
| 2418 { | 2414 { |
| 2419 if (logicalWidthLength.type() == FillAvailable) | 2415 if (logicalWidthLength.type() == FillAvailable) |
| 2420 return fillAvailableMeasure(availableLogicalWidth); | 2416 return fillAvailableMeasure(availableLogicalWidth); |
| 2421 | 2417 |
| 2422 LayoutUnit minLogicalWidth = 0; | 2418 LayoutUnit minLogicalWidth = 0; |
| 2423 LayoutUnit maxLogicalWidth = 0; | 2419 LayoutUnit maxLogicalWidth = 0; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 2437 | 2433 |
| 2438 ASSERT_NOT_REACHED(); | 2434 ASSERT_NOT_REACHED(); |
| 2439 return 0; | 2435 return 0; |
| 2440 } | 2436 } |
| 2441 | 2437 |
| 2442 LayoutUnit RenderBox::computeLogicalWidthInRegionUsing(SizeType widthType, Lengt
h logicalWidth, LayoutUnit availableLogicalWidth, | 2438 LayoutUnit RenderBox::computeLogicalWidthInRegionUsing(SizeType widthType, Lengt
h logicalWidth, LayoutUnit availableLogicalWidth, |
| 2443 const RenderBlock* cb, RenderRegion* region) const | 2439 const RenderBlock* cb, RenderRegion* region) const |
| 2444 { | 2440 { |
| 2445 if (!logicalWidth.isIntrinsicOrAuto()) { | 2441 if (!logicalWidth.isIntrinsicOrAuto()) { |
| 2446 // FIXME: If the containing block flow is perpendicular to our direction
we need to use the available logical height instead. | 2442 // FIXME: If the containing block flow is perpendicular to our direction
we need to use the available logical height instead. |
| 2447 return adjustBorderBoxLogicalWidthForBoxSizing(valueForLength(logicalWid
th, availableLogicalWidth, view())); | 2443 return adjustBorderBoxLogicalWidthForBoxSizing(valueForLength(logicalWid
th, availableLogicalWidth)); |
| 2448 } | 2444 } |
| 2449 | 2445 |
| 2450 if (logicalWidth.isIntrinsic()) | 2446 if (logicalWidth.isIntrinsic()) |
| 2451 return computeIntrinsicLogicalWidthUsing(logicalWidth, availableLogicalW
idth, borderAndPaddingLogicalWidth()); | 2447 return computeIntrinsicLogicalWidthUsing(logicalWidth, availableLogicalW
idth, borderAndPaddingLogicalWidth()); |
| 2452 | 2448 |
| 2453 LayoutUnit marginStart = 0; | 2449 LayoutUnit marginStart = 0; |
| 2454 LayoutUnit marginEnd = 0; | 2450 LayoutUnit marginEnd = 0; |
| 2455 LayoutUnit logicalWidthResult = fillAvailableMeasure(availableLogicalWidth,
marginStart, marginEnd); | 2451 LayoutUnit logicalWidthResult = fillAvailableMeasure(availableLogicalWidth,
marginStart, marginEnd); |
| 2456 | 2452 |
| 2457 if (shrinkToAvoidFloats() && cb->containsFloats()) | 2453 if (shrinkToAvoidFloats() && cb->containsFloats()) |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2547 return true; | 2543 return true; |
| 2548 | 2544 |
| 2549 return false; | 2545 return false; |
| 2550 } | 2546 } |
| 2551 | 2547 |
| 2552 void RenderBox::computeInlineDirectionMargins(RenderBlock* containingBlock, Layo
utUnit containerWidth, LayoutUnit childWidth, LayoutUnit& marginStart, LayoutUni
t& marginEnd) const | 2548 void RenderBox::computeInlineDirectionMargins(RenderBlock* containingBlock, Layo
utUnit containerWidth, LayoutUnit childWidth, LayoutUnit& marginStart, LayoutUni
t& marginEnd) const |
| 2553 { | 2549 { |
| 2554 const RenderStyle* containingBlockStyle = containingBlock->style(); | 2550 const RenderStyle* containingBlockStyle = containingBlock->style(); |
| 2555 Length marginStartLength = style()->marginStartUsing(containingBlockStyle); | 2551 Length marginStartLength = style()->marginStartUsing(containingBlockStyle); |
| 2556 Length marginEndLength = style()->marginEndUsing(containingBlockStyle); | 2552 Length marginEndLength = style()->marginEndUsing(containingBlockStyle); |
| 2557 RenderView* renderView = view(); | |
| 2558 | 2553 |
| 2559 if (isFloating() || isInline()) { | 2554 if (isFloating() || isInline()) { |
| 2560 // Inline blocks/tables and floats don't have their margins increased. | 2555 // Inline blocks/tables and floats don't have their margins increased. |
| 2561 marginStart = minimumValueForLength(marginStartLength, containerWidth, r
enderView); | 2556 marginStart = minimumValueForLength(marginStartLength, containerWidth); |
| 2562 marginEnd = minimumValueForLength(marginEndLength, containerWidth, rende
rView); | 2557 marginEnd = minimumValueForLength(marginEndLength, containerWidth); |
| 2563 return; | 2558 return; |
| 2564 } | 2559 } |
| 2565 | 2560 |
| 2566 if (containingBlock->isFlexibleBox()) { | 2561 if (containingBlock->isFlexibleBox()) { |
| 2567 // We need to let flexbox handle the margin adjustment - otherwise, flex
box | 2562 // We need to let flexbox handle the margin adjustment - otherwise, flex
box |
| 2568 // will think we're wider than we actually are and calculate line sizes
wrong. | 2563 // will think we're wider than we actually are and calculate line sizes
wrong. |
| 2569 // See also http://dev.w3.org/csswg/css-flexbox/#auto-margins | 2564 // See also http://dev.w3.org/csswg/css-flexbox/#auto-margins |
| 2570 if (marginStartLength.isAuto()) | 2565 if (marginStartLength.isAuto()) |
| 2571 marginStartLength.setValue(0); | 2566 marginStartLength.setValue(0); |
| 2572 if (marginEndLength.isAuto()) | 2567 if (marginEndLength.isAuto()) |
| 2573 marginEndLength.setValue(0); | 2568 marginEndLength.setValue(0); |
| 2574 } | 2569 } |
| 2575 | 2570 |
| 2576 // Case One: The object is being centered in the containing block's availabl
e logical width. | 2571 // Case One: The object is being centered in the containing block's availabl
e logical width. |
| 2577 if ((marginStartLength.isAuto() && marginEndLength.isAuto() && childWidth <
containerWidth) | 2572 if ((marginStartLength.isAuto() && marginEndLength.isAuto() && childWidth <
containerWidth) |
| 2578 || (!marginStartLength.isAuto() && !marginEndLength.isAuto() && containi
ngBlock->style()->textAlign() == WEBKIT_CENTER)) { | 2573 || (!marginStartLength.isAuto() && !marginEndLength.isAuto() && containi
ngBlock->style()->textAlign() == WEBKIT_CENTER)) { |
| 2579 // Other browsers center the margin box for align=center elements so we
match them here. | 2574 // Other browsers center the margin box for align=center elements so we
match them here. |
| 2580 LayoutUnit marginStartWidth = minimumValueForLength(marginStartLength, c
ontainerWidth, renderView); | 2575 LayoutUnit marginStartWidth = minimumValueForLength(marginStartLength, c
ontainerWidth); |
| 2581 LayoutUnit marginEndWidth = minimumValueForLength(marginEndLength, conta
inerWidth, renderView); | 2576 LayoutUnit marginEndWidth = minimumValueForLength(marginEndLength, conta
inerWidth); |
| 2582 LayoutUnit centeredMarginBoxStart = max<LayoutUnit>(0, (containerWidth -
childWidth - marginStartWidth - marginEndWidth) / 2); | 2577 LayoutUnit centeredMarginBoxStart = max<LayoutUnit>(0, (containerWidth -
childWidth - marginStartWidth - marginEndWidth) / 2); |
| 2583 marginStart = centeredMarginBoxStart + marginStartWidth; | 2578 marginStart = centeredMarginBoxStart + marginStartWidth; |
| 2584 marginEnd = containerWidth - childWidth - marginStart + marginEndWidth; | 2579 marginEnd = containerWidth - childWidth - marginStart + marginEndWidth; |
| 2585 return; | 2580 return; |
| 2586 } | 2581 } |
| 2587 | 2582 |
| 2588 // Case Two: The object is being pushed to the start of the containing block
's available logical width. | 2583 // Case Two: The object is being pushed to the start of the containing block
's available logical width. |
| 2589 if (marginEndLength.isAuto() && childWidth < containerWidth) { | 2584 if (marginEndLength.isAuto() && childWidth < containerWidth) { |
| 2590 marginStart = valueForLength(marginStartLength, containerWidth, renderVi
ew); | 2585 marginStart = valueForLength(marginStartLength, containerWidth); |
| 2591 marginEnd = containerWidth - childWidth - marginStart; | 2586 marginEnd = containerWidth - childWidth - marginStart; |
| 2592 return; | 2587 return; |
| 2593 } | 2588 } |
| 2594 | 2589 |
| 2595 // Case Three: The object is being pushed to the end of the containing block
's available logical width. | 2590 // Case Three: The object is being pushed to the end of the containing block
's available logical width. |
| 2596 bool pushToEndFromTextAlign = !marginEndLength.isAuto() && ((!containingBloc
kStyle->isLeftToRightDirection() && containingBlockStyle->textAlign() == WEBKIT_
LEFT) | 2591 bool pushToEndFromTextAlign = !marginEndLength.isAuto() && ((!containingBloc
kStyle->isLeftToRightDirection() && containingBlockStyle->textAlign() == WEBKIT_
LEFT) |
| 2597 || (containingBlockStyle->isLeftToRightDirection() && containingBlockSty
le->textAlign() == WEBKIT_RIGHT)); | 2592 || (containingBlockStyle->isLeftToRightDirection() && containingBlockSty
le->textAlign() == WEBKIT_RIGHT)); |
| 2598 if ((marginStartLength.isAuto() && childWidth < containerWidth) || pushToEnd
FromTextAlign) { | 2593 if ((marginStartLength.isAuto() && childWidth < containerWidth) || pushToEnd
FromTextAlign) { |
| 2599 marginEnd = valueForLength(marginEndLength, containerWidth, renderView); | 2594 marginEnd = valueForLength(marginEndLength, containerWidth); |
| 2600 marginStart = containerWidth - childWidth - marginEnd; | 2595 marginStart = containerWidth - childWidth - marginEnd; |
| 2601 return; | 2596 return; |
| 2602 } | 2597 } |
| 2603 | 2598 |
| 2604 // Case Four: Either no auto margins, or our width is >= the container width
(css2.1, 10.3.3). In that case | 2599 // Case Four: Either no auto margins, or our width is >= the container width
(css2.1, 10.3.3). In that case |
| 2605 // auto margins will just turn into 0. | 2600 // auto margins will just turn into 0. |
| 2606 marginStart = minimumValueForLength(marginStartLength, containerWidth, rende
rView); | 2601 marginStart = minimumValueForLength(marginStartLength, containerWidth); |
| 2607 marginEnd = minimumValueForLength(marginEndLength, containerWidth, renderVie
w); | 2602 marginEnd = minimumValueForLength(marginEndLength, containerWidth); |
| 2608 } | 2603 } |
| 2609 | 2604 |
| 2610 RenderBoxRegionInfo* RenderBox::renderBoxRegionInfo(RenderRegion* region, Render
BoxRegionInfoFlags cacheFlag) const | 2605 RenderBoxRegionInfo* RenderBox::renderBoxRegionInfo(RenderRegion* region, Render
BoxRegionInfoFlags cacheFlag) const |
| 2611 { | 2606 { |
| 2612 // Make sure nobody is trying to call this with a null region. | 2607 // Make sure nobody is trying to call this with a null region. |
| 2613 if (!region) | 2608 if (!region) |
| 2614 return 0; | 2609 return 0; |
| 2615 | 2610 |
| 2616 // If we have computed our width in this region already, it will be cached,
and we can | 2611 // If we have computed our width in this region already, it will be cached,
and we can |
| 2617 // just return it. | 2612 // just return it. |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2863 // If that happens, this code will have to change. | 2858 // If that happens, this code will have to change. |
| 2864 if (height.isIntrinsic()) { | 2859 if (height.isIntrinsic()) { |
| 2865 if (intrinsicContentHeight == -1) | 2860 if (intrinsicContentHeight == -1) |
| 2866 return -1; // Intrinsic height isn't available. | 2861 return -1; // Intrinsic height isn't available. |
| 2867 return computeIntrinsicLogicalContentHeightUsing(height, intrinsicConten
tHeight, borderAndPaddingLogicalHeight()); | 2862 return computeIntrinsicLogicalContentHeightUsing(height, intrinsicConten
tHeight, borderAndPaddingLogicalHeight()); |
| 2868 } | 2863 } |
| 2869 if (height.isFixed()) | 2864 if (height.isFixed()) |
| 2870 return height.value(); | 2865 return height.value(); |
| 2871 if (height.isPercent()) | 2866 if (height.isPercent()) |
| 2872 return computePercentageLogicalHeight(height); | 2867 return computePercentageLogicalHeight(height); |
| 2873 if (height.isViewportPercentage()) | |
| 2874 return valueForLength(height, 0, view()); | |
| 2875 return -1; | 2868 return -1; |
| 2876 } | 2869 } |
| 2877 | 2870 |
| 2878 bool RenderBox::skipContainingBlockForPercentHeightCalculation(const RenderBox*
containingBlock) const | 2871 bool RenderBox::skipContainingBlockForPercentHeightCalculation(const RenderBox*
containingBlock) const |
| 2879 { | 2872 { |
| 2880 // For quirks mode and anonymous blocks, we skip auto-height containingBlock
s when computing percentages. | 2873 // For quirks mode and anonymous blocks, we skip auto-height containingBlock
s when computing percentages. |
| 2881 // For standards mode, we treat the percentage as auto if it has an auto-hei
ght containing block. | 2874 // For standards mode, we treat the percentage as auto if it has an auto-hei
ght containing block. |
| 2882 if (!document().inQuirksMode() && !containingBlock->isAnonymousBlock()) | 2875 if (!document().inQuirksMode() && !containingBlock->isAnonymousBlock()) |
| 2883 return false; | 2876 return false; |
| 2884 return !containingBlock->isTableCell() && !containingBlock->isOutOfFlowPosit
ioned() && containingBlock->style()->logicalHeight().isAuto() && isHorizontalWri
tingMode() == containingBlock->isHorizontalWritingMode(); | 2877 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... |
| 2942 LayoutUnit heightWithScrollbar = cb->computePercentageLogicalHeight(cbst
yle->logicalHeight()); | 2935 LayoutUnit heightWithScrollbar = cb->computePercentageLogicalHeight(cbst
yle->logicalHeight()); |
| 2943 if (heightWithScrollbar != -1) { | 2936 if (heightWithScrollbar != -1) { |
| 2944 LayoutUnit contentBoxHeightWithScrollbar = cb->adjustContentBoxLogic
alHeightForBoxSizing(heightWithScrollbar); | 2937 LayoutUnit contentBoxHeightWithScrollbar = cb->adjustContentBoxLogic
alHeightForBoxSizing(heightWithScrollbar); |
| 2945 // We need to adjust for min/max height because this method does not | 2938 // We need to adjust for min/max height because this method does not |
| 2946 // handle the min/max of the current block, its caller does. So the | 2939 // handle the min/max of the current block, its caller does. So the |
| 2947 // return value from the recursive call will not have been adjusted | 2940 // return value from the recursive call will not have been adjusted |
| 2948 // yet. | 2941 // yet. |
| 2949 LayoutUnit contentBoxHeight = cb->constrainContentBoxLogicalHeightBy
MinMax(contentBoxHeightWithScrollbar - cb->scrollbarLogicalHeight(), -1); | 2942 LayoutUnit contentBoxHeight = cb->constrainContentBoxLogicalHeightBy
MinMax(contentBoxHeightWithScrollbar - cb->scrollbarLogicalHeight(), -1); |
| 2950 availableHeight = max<LayoutUnit>(0, contentBoxHeight); | 2943 availableHeight = max<LayoutUnit>(0, contentBoxHeight); |
| 2951 } | 2944 } |
| 2952 } else if (cbstyle->logicalHeight().isViewportPercentage()) { | |
| 2953 LayoutUnit heightWithScrollbar = valueForLength(cbstyle->logicalHeight()
, 0, view()); | |
| 2954 if (heightWithScrollbar != -1) { | |
| 2955 LayoutUnit contentBoxHeightWithScrollbar = cb->adjustContentBoxLogic
alHeightForBoxSizing(heightWithScrollbar); | |
| 2956 // We need to adjust for min/max height because this method does not | |
| 2957 // handle the min/max of the current block, its caller does. So the | |
| 2958 // return value from the recursive call will not have been adjusted | |
| 2959 // yet. | |
| 2960 LayoutUnit contentBoxHeight = cb->constrainContentBoxLogicalHeightBy
MinMax(contentBoxHeightWithScrollbar - cb->scrollbarLogicalHeight(), -1); | |
| 2961 availableHeight = max<LayoutUnit>(0, contentBoxHeight); | |
| 2962 } | |
| 2963 } else if (isOutOfFlowPositionedWithSpecifiedHeight) { | 2945 } else if (isOutOfFlowPositionedWithSpecifiedHeight) { |
| 2964 // Don't allow this to affect the block' height() member variable, since
this | 2946 // Don't allow this to affect the block' height() member variable, since
this |
| 2965 // can get called while the block is still laying out its kids. | 2947 // can get called while the block is still laying out its kids. |
| 2966 LogicalExtentComputedValues computedValues; | 2948 LogicalExtentComputedValues computedValues; |
| 2967 cb->computeLogicalHeight(cb->logicalHeight(), 0, computedValues); | 2949 cb->computeLogicalHeight(cb->logicalHeight(), 0, computedValues); |
| 2968 availableHeight = computedValues.m_extent - cb->borderAndPaddingLogicalH
eight() - cb->scrollbarLogicalHeight(); | 2950 availableHeight = computedValues.m_extent - cb->borderAndPaddingLogicalH
eight() - cb->scrollbarLogicalHeight(); |
| 2969 } else if (cb->isRenderView()) | 2951 } else if (cb->isRenderView()) |
| 2970 availableHeight = viewLogicalHeightForPercentages(); | 2952 availableHeight = viewLogicalHeightForPercentages(); |
| 2971 | 2953 |
| 2972 if (availableHeight == -1) | 2954 if (availableHeight == -1) |
| (...skipping 29 matching lines...) Expand all Loading... |
| 3002 { | 2984 { |
| 3003 switch (logicalWidth.type()) { | 2985 switch (logicalWidth.type()) { |
| 3004 case Fixed: | 2986 case Fixed: |
| 3005 return adjustContentBoxLogicalWidthForBoxSizing(logicalWidth.value()
); | 2987 return adjustContentBoxLogicalWidthForBoxSizing(logicalWidth.value()
); |
| 3006 case MinContent: | 2988 case MinContent: |
| 3007 case MaxContent: { | 2989 case MaxContent: { |
| 3008 // MinContent/MaxContent don't need the availableLogicalWidth argume
nt. | 2990 // MinContent/MaxContent don't need the availableLogicalWidth argume
nt. |
| 3009 LayoutUnit availableLogicalWidth = 0; | 2991 LayoutUnit availableLogicalWidth = 0; |
| 3010 return computeIntrinsicLogicalWidthUsing(logicalWidth, availableLogi
calWidth, borderAndPaddingLogicalWidth()) - borderAndPaddingLogicalWidth(); | 2992 return computeIntrinsicLogicalWidthUsing(logicalWidth, availableLogi
calWidth, borderAndPaddingLogicalWidth()) - borderAndPaddingLogicalWidth(); |
| 3011 } | 2993 } |
| 3012 case ViewportPercentageWidth: | |
| 3013 case ViewportPercentageHeight: | |
| 3014 case ViewportPercentageMin: | |
| 3015 case ViewportPercentageMax: | |
| 3016 return adjustContentBoxLogicalWidthForBoxSizing(valueForLength(logic
alWidth, 0, view())); | |
| 3017 case FitContent: | 2994 case FitContent: |
| 3018 case FillAvailable: | 2995 case FillAvailable: |
| 3019 case Percent: | 2996 case Percent: |
| 3020 case Calculated: { | 2997 case Calculated: { |
| 3021 // FIXME: containingBlockLogicalWidthForContent() is wrong if the re
placed element's block-flow is perpendicular to the | 2998 // FIXME: containingBlockLogicalWidthForContent() is wrong if the re
placed element's block-flow is perpendicular to the |
| 3022 // containing block's block-flow. | 2999 // containing block's block-flow. |
| 3023 // https://bugs.webkit.org/show_bug.cgi?id=46496 | 3000 // https://bugs.webkit.org/show_bug.cgi?id=46496 |
| 3024 const LayoutUnit cw = isOutOfFlowPositioned() ? containingBlockLogic
alWidthForPositioned(toRenderBoxModelObject(container())) : containingBlockLogic
alWidthForContent(); | 3001 const LayoutUnit cw = isOutOfFlowPositioned() ? containingBlockLogic
alWidthForPositioned(toRenderBoxModelObject(container())) : containingBlockLogic
alWidthForContent(); |
| 3025 Length containerLogicalWidth = containingBlock()->style()->logicalWi
dth(); | 3002 Length containerLogicalWidth = containingBlock()->style()->logicalWi
dth(); |
| 3026 // FIXME: Handle cases when containing block width is calculated or
viewport percent. | 3003 // FIXME: Handle cases when containing block width is calculated or
viewport percent. |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3100 // <http://bugs.webkit.org/show_bug.cgi?id=15359> | 3077 // <http://bugs.webkit.org/show_bug.cgi?id=15359> |
| 3101 availableHeight = max(availableHeight, intrinsicLogicalH
eight()); | 3078 availableHeight = max(availableHeight, intrinsicLogicalH
eight()); |
| 3102 return valueForLength(logicalHeight, availableHeight - b
orderAndPaddingLogicalHeight()); | 3079 return valueForLength(logicalHeight, availableHeight - b
orderAndPaddingLogicalHeight()); |
| 3103 } | 3080 } |
| 3104 toRenderBlock(cb)->addPercentHeightDescendant(const_cast<Ren
derBox*>(this)); | 3081 toRenderBlock(cb)->addPercentHeightDescendant(const_cast<Ren
derBox*>(this)); |
| 3105 cb = cb->containingBlock(); | 3082 cb = cb->containingBlock(); |
| 3106 } | 3083 } |
| 3107 } | 3084 } |
| 3108 return adjustContentBoxLogicalHeightForBoxSizing(valueForLength(logi
calHeight, availableHeight)); | 3085 return adjustContentBoxLogicalHeightForBoxSizing(valueForLength(logi
calHeight, availableHeight)); |
| 3109 } | 3086 } |
| 3110 case ViewportPercentageWidth: | |
| 3111 case ViewportPercentageHeight: | |
| 3112 case ViewportPercentageMin: | |
| 3113 case ViewportPercentageMax: | |
| 3114 return adjustContentBoxLogicalHeightForBoxSizing(valueForLength(logi
calHeight, 0, view())); | |
| 3115 case MinContent: | 3087 case MinContent: |
| 3116 case MaxContent: | 3088 case MaxContent: |
| 3117 case FitContent: | 3089 case FitContent: |
| 3118 case FillAvailable: | 3090 case FillAvailable: |
| 3119 return adjustContentBoxLogicalHeightForBoxSizing(computeIntrinsicLog
icalContentHeightUsing(logicalHeight, intrinsicLogicalHeight(), borderAndPadding
Height())); | 3091 return adjustContentBoxLogicalHeightForBoxSizing(computeIntrinsicLog
icalContentHeightUsing(logicalHeight, intrinsicLogicalHeight(), borderAndPadding
Height())); |
| 3120 default: | 3092 default: |
| 3121 return intrinsicLogicalHeight(); | 3093 return intrinsicLogicalHeight(); |
| 3122 } | 3094 } |
| 3123 } | 3095 } |
| 3124 | 3096 |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3176 // FIXME: Not right if we allow cells to have different directionality t
han the table. If we do allow this, though, | 3148 // FIXME: Not right if we allow cells to have different directionality t
han the table. If we do allow this, though, |
| 3177 // we may just do it with an extra anonymous block inside the cell. | 3149 // we may just do it with an extra anonymous block inside the cell. |
| 3178 marginBefore = 0; | 3150 marginBefore = 0; |
| 3179 marginAfter = 0; | 3151 marginAfter = 0; |
| 3180 return; | 3152 return; |
| 3181 } | 3153 } |
| 3182 | 3154 |
| 3183 // Margins are calculated with respect to the logical width of | 3155 // Margins are calculated with respect to the logical width of |
| 3184 // the containing block (8.3) | 3156 // the containing block (8.3) |
| 3185 LayoutUnit cw = containingBlockLogicalWidthForContent(); | 3157 LayoutUnit cw = containingBlockLogicalWidthForContent(); |
| 3186 RenderView* renderView = view(); | |
| 3187 RenderStyle* containingBlockStyle = containingBlock->style(); | 3158 RenderStyle* containingBlockStyle = containingBlock->style(); |
| 3188 marginBefore = minimumValueForLength(style()->marginBeforeUsing(containingBl
ockStyle), cw, renderView); | 3159 marginBefore = minimumValueForLength(style()->marginBeforeUsing(containingBl
ockStyle), cw); |
| 3189 marginAfter = minimumValueForLength(style()->marginAfterUsing(containingBloc
kStyle), cw, renderView); | 3160 marginAfter = minimumValueForLength(style()->marginAfterUsing(containingBloc
kStyle), cw); |
| 3190 } | 3161 } |
| 3191 | 3162 |
| 3192 void RenderBox::computeAndSetBlockDirectionMargins(const RenderBlock* containing
Block) | 3163 void RenderBox::computeAndSetBlockDirectionMargins(const RenderBlock* containing
Block) |
| 3193 { | 3164 { |
| 3194 LayoutUnit marginBefore; | 3165 LayoutUnit marginBefore; |
| 3195 LayoutUnit marginAfter; | 3166 LayoutUnit marginAfter; |
| 3196 computeBlockDirectionMargins(containingBlock, marginBefore, marginAfter); | 3167 computeBlockDirectionMargins(containingBlock, marginBefore, marginAfter); |
| 3197 containingBlock->setMarginBeforeForChild(this, marginBefore); | 3168 containingBlock->setMarginBeforeForChild(this, marginBefore); |
| 3198 containingBlock->setMarginAfterForChild(this, marginAfter); | 3169 containingBlock->setMarginAfterForChild(this, marginAfter); |
| 3199 } | 3170 } |
| (...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3537 // converted to the static position already | 3508 // converted to the static position already |
| 3538 ASSERT(!(logicalLeft.isAuto() && logicalRight.isAuto())); | 3509 ASSERT(!(logicalLeft.isAuto() && logicalRight.isAuto())); |
| 3539 | 3510 |
| 3540 LayoutUnit logicalLeftValue = 0; | 3511 LayoutUnit logicalLeftValue = 0; |
| 3541 | 3512 |
| 3542 const LayoutUnit containerRelativeLogicalWidth = containingBlockLogicalWidth
ForPositioned(containerBlock, 0, false); | 3513 const LayoutUnit containerRelativeLogicalWidth = containingBlockLogicalWidth
ForPositioned(containerBlock, 0, false); |
| 3543 | 3514 |
| 3544 bool logicalWidthIsAuto = logicalWidth.isIntrinsicOrAuto(); | 3515 bool logicalWidthIsAuto = logicalWidth.isIntrinsicOrAuto(); |
| 3545 bool logicalLeftIsAuto = logicalLeft.isAuto(); | 3516 bool logicalLeftIsAuto = logicalLeft.isAuto(); |
| 3546 bool logicalRightIsAuto = logicalRight.isAuto(); | 3517 bool logicalRightIsAuto = logicalRight.isAuto(); |
| 3547 RenderView* renderView = view(); | |
| 3548 LayoutUnit& marginLogicalLeftValue = style()->isLeftToRightDirection() ? com
putedValues.m_margins.m_start : computedValues.m_margins.m_end; | 3518 LayoutUnit& marginLogicalLeftValue = style()->isLeftToRightDirection() ? com
putedValues.m_margins.m_start : computedValues.m_margins.m_end; |
| 3549 LayoutUnit& marginLogicalRightValue = style()->isLeftToRightDirection() ? co
mputedValues.m_margins.m_end : computedValues.m_margins.m_start; | 3519 LayoutUnit& marginLogicalRightValue = style()->isLeftToRightDirection() ? co
mputedValues.m_margins.m_end : computedValues.m_margins.m_start; |
| 3550 if (!logicalLeftIsAuto && !logicalWidthIsAuto && !logicalRightIsAuto) { | 3520 if (!logicalLeftIsAuto && !logicalWidthIsAuto && !logicalRightIsAuto) { |
| 3551 /*----------------------------------------------------------------------
-*\ | 3521 /*----------------------------------------------------------------------
-*\ |
| 3552 * If none of the three is 'auto': If both 'margin-left' and 'margin- | 3522 * If none of the three is 'auto': If both 'margin-left' and 'margin- |
| 3553 * right' are 'auto', solve the equation under the extra constraint that | 3523 * right' are 'auto', solve the equation under the extra constraint that |
| 3554 * the two margins get equal values, unless this would make them negativ
e, | 3524 * the two margins get equal values, unless this would make them negativ
e, |
| 3555 * in which case when direction of the containing block is 'ltr' ('rtl')
, | 3525 * in which case when direction of the containing block is 'ltr' ('rtl')
, |
| 3556 * set 'margin-left' ('margin-right') to zero and solve for 'margin-righ
t' | 3526 * set 'margin-left' ('margin-right') to zero and solve for 'margin-righ
t' |
| 3557 * ('margin-left'). If one of 'margin-left' or 'margin-right' is 'auto', | 3527 * ('margin-left'). If one of 'margin-left' or 'margin-right' is 'auto', |
| 3558 * solve the equation for that value. If the values are over-constrained
, | 3528 * solve the equation for that value. If the values are over-constrained
, |
| 3559 * ignore the value for 'left' (in case the 'direction' property of the | 3529 * ignore the value for 'left' (in case the 'direction' property of the |
| 3560 * containing block is 'rtl') or 'right' (in case 'direction' is 'ltr') | 3530 * containing block is 'rtl') or 'right' (in case 'direction' is 'ltr') |
| 3561 * and solve for that value. | 3531 * and solve for that value. |
| 3562 \*----------------------------------------------------------------------
-*/ | 3532 \*----------------------------------------------------------------------
-*/ |
| 3563 // NOTE: It is not necessary to solve for 'right' in the over constrain
ed | 3533 // NOTE: It is not necessary to solve for 'right' in the over constrain
ed |
| 3564 // case because the value is not used for any further calculations. | 3534 // case because the value is not used for any further calculations. |
| 3565 | 3535 |
| 3566 logicalLeftValue = valueForLength(logicalLeft, containerLogicalWidth, re
nderView); | 3536 logicalLeftValue = valueForLength(logicalLeft, containerLogicalWidth); |
| 3567 computedValues.m_extent = adjustContentBoxLogicalWidthForBoxSizing(value
ForLength(logicalWidth, containerLogicalWidth, renderView)); | 3537 computedValues.m_extent = adjustContentBoxLogicalWidthForBoxSizing(value
ForLength(logicalWidth, containerLogicalWidth)); |
| 3568 | 3538 |
| 3569 const LayoutUnit availableSpace = containerLogicalWidth - (logicalLeftVa
lue + computedValues.m_extent + valueForLength(logicalRight, containerLogicalWid
th, renderView) + bordersPlusPadding); | 3539 const LayoutUnit availableSpace = containerLogicalWidth - (logicalLeftVa
lue + computedValues.m_extent + valueForLength(logicalRight, containerLogicalWid
th) + bordersPlusPadding); |
| 3570 | 3540 |
| 3571 // Margins are now the only unknown | 3541 // Margins are now the only unknown |
| 3572 if (marginLogicalLeft.isAuto() && marginLogicalRight.isAuto()) { | 3542 if (marginLogicalLeft.isAuto() && marginLogicalRight.isAuto()) { |
| 3573 // Both margins auto, solve for equality | 3543 // Both margins auto, solve for equality |
| 3574 if (availableSpace >= 0) { | 3544 if (availableSpace >= 0) { |
| 3575 marginLogicalLeftValue = availableSpace / 2; // split the differ
ence | 3545 marginLogicalLeftValue = availableSpace / 2; // split the differ
ence |
| 3576 marginLogicalRightValue = availableSpace - marginLogicalLeftValu
e; // account for odd valued differences | 3546 marginLogicalRightValue = availableSpace - marginLogicalLeftValu
e; // account for odd valued differences |
| 3577 } else { | 3547 } else { |
| 3578 // Use the containing block's direction rather than the parent b
lock's | 3548 // Use the containing block's direction rather than the parent b
lock's |
| 3579 // per CSS 2.1 reference test abspos-non-replaced-width-margin-0
00. | 3549 // per CSS 2.1 reference test abspos-non-replaced-width-margin-0
00. |
| 3580 if (containerDirection == LTR) { | 3550 if (containerDirection == LTR) { |
| 3581 marginLogicalLeftValue = 0; | 3551 marginLogicalLeftValue = 0; |
| 3582 marginLogicalRightValue = availableSpace; // will be negativ
e | 3552 marginLogicalRightValue = availableSpace; // will be negativ
e |
| 3583 } else { | 3553 } else { |
| 3584 marginLogicalLeftValue = availableSpace; // will be negative | 3554 marginLogicalLeftValue = availableSpace; // will be negative |
| 3585 marginLogicalRightValue = 0; | 3555 marginLogicalRightValue = 0; |
| 3586 } | 3556 } |
| 3587 } | 3557 } |
| 3588 } else if (marginLogicalLeft.isAuto()) { | 3558 } else if (marginLogicalLeft.isAuto()) { |
| 3589 // Solve for left margin | 3559 // Solve for left margin |
| 3590 marginLogicalRightValue = valueForLength(marginLogicalRight, contain
erRelativeLogicalWidth, renderView); | 3560 marginLogicalRightValue = valueForLength(marginLogicalRight, contain
erRelativeLogicalWidth); |
| 3591 marginLogicalLeftValue = availableSpace - marginLogicalRightValue; | 3561 marginLogicalLeftValue = availableSpace - marginLogicalRightValue; |
| 3592 } else if (marginLogicalRight.isAuto()) { | 3562 } else if (marginLogicalRight.isAuto()) { |
| 3593 // Solve for right margin | 3563 // Solve for right margin |
| 3594 marginLogicalLeftValue = valueForLength(marginLogicalLeft, container
RelativeLogicalWidth, renderView); | 3564 marginLogicalLeftValue = valueForLength(marginLogicalLeft, container
RelativeLogicalWidth); |
| 3595 marginLogicalRightValue = availableSpace - marginLogicalLeftValue; | 3565 marginLogicalRightValue = availableSpace - marginLogicalLeftValue; |
| 3596 } else { | 3566 } else { |
| 3597 // Over-constrained, solve for left if direction is RTL | 3567 // Over-constrained, solve for left if direction is RTL |
| 3598 marginLogicalLeftValue = valueForLength(marginLogicalLeft, container
RelativeLogicalWidth, renderView); | 3568 marginLogicalLeftValue = valueForLength(marginLogicalLeft, container
RelativeLogicalWidth); |
| 3599 marginLogicalRightValue = valueForLength(marginLogicalRight, contain
erRelativeLogicalWidth, renderView); | 3569 marginLogicalRightValue = valueForLength(marginLogicalRight, contain
erRelativeLogicalWidth); |
| 3600 | 3570 |
| 3601 // Use the containing block's direction rather than the parent block
's | 3571 // Use the containing block's direction rather than the parent block
's |
| 3602 // per CSS 2.1 reference test abspos-non-replaced-width-margin-000. | 3572 // per CSS 2.1 reference test abspos-non-replaced-width-margin-000. |
| 3603 if (containerDirection == RTL) | 3573 if (containerDirection == RTL) |
| 3604 logicalLeftValue = (availableSpace + logicalLeftValue) - marginL
ogicalLeftValue - marginLogicalRightValue; | 3574 logicalLeftValue = (availableSpace + logicalLeftValue) - marginL
ogicalLeftValue - marginLogicalRightValue; |
| 3605 } | 3575 } |
| 3606 } else { | 3576 } else { |
| 3607 /*--------------------------------------------------------------------*\ | 3577 /*--------------------------------------------------------------------*\ |
| 3608 * Otherwise, set 'auto' values for 'margin-left' and 'margin-right' | 3578 * Otherwise, set 'auto' values for 'margin-left' and 'margin-right' |
| 3609 * to 0, and pick the one of the following six rules that applies. | 3579 * to 0, and pick the one of the following six rules that applies. |
| (...skipping 29 matching lines...) Expand all Loading... |
| 3639 * for 'width' after setting 'left' (in case 1) or 'right' (in case 3) | 3609 * for 'width' after setting 'left' (in case 1) or 'right' (in case 3) |
| 3640 * to 0. | 3610 * to 0. |
| 3641 * | 3611 * |
| 3642 * Then the shrink-to-fit width is: | 3612 * Then the shrink-to-fit width is: |
| 3643 * min(max(preferred minimum width, available width), preferred width). | 3613 * min(max(preferred minimum width, available width), preferred width). |
| 3644 \*--------------------------------------------------------------------*/ | 3614 \*--------------------------------------------------------------------*/ |
| 3645 // NOTE: For rules 3 and 6 it is not necessary to solve for 'right' | 3615 // NOTE: For rules 3 and 6 it is not necessary to solve for 'right' |
| 3646 // because the value is not used for any further calculations. | 3616 // because the value is not used for any further calculations. |
| 3647 | 3617 |
| 3648 // Calculate margins, 'auto' margins are ignored. | 3618 // Calculate margins, 'auto' margins are ignored. |
| 3649 marginLogicalLeftValue = minimumValueForLength(marginLogicalLeft, contai
nerRelativeLogicalWidth, renderView); | 3619 marginLogicalLeftValue = minimumValueForLength(marginLogicalLeft, contai
nerRelativeLogicalWidth); |
| 3650 marginLogicalRightValue = minimumValueForLength(marginLogicalRight, cont
ainerRelativeLogicalWidth, renderView); | 3620 marginLogicalRightValue = minimumValueForLength(marginLogicalRight, cont
ainerRelativeLogicalWidth); |
| 3651 | 3621 |
| 3652 const LayoutUnit availableSpace = containerLogicalWidth - (marginLogical
LeftValue + marginLogicalRightValue + bordersPlusPadding); | 3622 const LayoutUnit availableSpace = containerLogicalWidth - (marginLogical
LeftValue + marginLogicalRightValue + bordersPlusPadding); |
| 3653 | 3623 |
| 3654 // FIXME: Is there a faster way to find the correct case? | 3624 // FIXME: Is there a faster way to find the correct case? |
| 3655 // Use rule/case that applies. | 3625 // Use rule/case that applies. |
| 3656 if (logicalLeftIsAuto && logicalWidthIsAuto && !logicalRightIsAuto) { | 3626 if (logicalLeftIsAuto && logicalWidthIsAuto && !logicalRightIsAuto) { |
| 3657 // RULE 1: (use shrink-to-fit for width, and solve of left) | 3627 // RULE 1: (use shrink-to-fit for width, and solve of left) |
| 3658 LayoutUnit logicalRightValue = valueForLength(logicalRight, containe
rLogicalWidth, renderView); | 3628 LayoutUnit logicalRightValue = valueForLength(logicalRight, containe
rLogicalWidth); |
| 3659 | 3629 |
| 3660 // FIXME: would it be better to have shrink-to-fit in one step? | 3630 // FIXME: would it be better to have shrink-to-fit in one step? |
| 3661 LayoutUnit preferredWidth = maxPreferredLogicalWidth() - bordersPlus
Padding; | 3631 LayoutUnit preferredWidth = maxPreferredLogicalWidth() - bordersPlus
Padding; |
| 3662 LayoutUnit preferredMinWidth = minPreferredLogicalWidth() - bordersP
lusPadding; | 3632 LayoutUnit preferredMinWidth = minPreferredLogicalWidth() - bordersP
lusPadding; |
| 3663 LayoutUnit availableWidth = availableSpace - logicalRightValue; | 3633 LayoutUnit availableWidth = availableSpace - logicalRightValue; |
| 3664 computedValues.m_extent = min(max(preferredMinWidth, availableWidth)
, preferredWidth); | 3634 computedValues.m_extent = min(max(preferredMinWidth, availableWidth)
, preferredWidth); |
| 3665 logicalLeftValue = availableSpace - (computedValues.m_extent + logic
alRightValue); | 3635 logicalLeftValue = availableSpace - (computedValues.m_extent + logic
alRightValue); |
| 3666 } else if (!logicalLeftIsAuto && logicalWidthIsAuto && logicalRightIsAut
o) { | 3636 } else if (!logicalLeftIsAuto && logicalWidthIsAuto && logicalRightIsAut
o) { |
| 3667 // RULE 3: (use shrink-to-fit for width, and no need solve of right) | 3637 // RULE 3: (use shrink-to-fit for width, and no need solve of right) |
| 3668 logicalLeftValue = valueForLength(logicalLeft, containerLogicalWidth
, renderView); | 3638 logicalLeftValue = valueForLength(logicalLeft, containerLogicalWidth
); |
| 3669 | 3639 |
| 3670 shrinkToFitWidth(availableSpace, logicalLeftValue, bordersPlusPaddin
g, computedValues); | 3640 shrinkToFitWidth(availableSpace, logicalLeftValue, bordersPlusPaddin
g, computedValues); |
| 3671 } else if (logicalLeftIsAuto && !logicalWidthIsAuto && !logicalRightIsAu
to) { | 3641 } else if (logicalLeftIsAuto && !logicalWidthIsAuto && !logicalRightIsAu
to) { |
| 3672 // RULE 4: (solve for left) | 3642 // RULE 4: (solve for left) |
| 3673 computedValues.m_extent = adjustContentBoxLogicalWidthForBoxSizing(v
alueForLength(logicalWidth, containerLogicalWidth, renderView)); | 3643 computedValues.m_extent = adjustContentBoxLogicalWidthForBoxSizing(v
alueForLength(logicalWidth, containerLogicalWidth)); |
| 3674 logicalLeftValue = availableSpace - (computedValues.m_extent + value
ForLength(logicalRight, containerLogicalWidth, renderView)); | 3644 logicalLeftValue = availableSpace - (computedValues.m_extent + value
ForLength(logicalRight, containerLogicalWidth)); |
| 3675 } else if (!logicalLeftIsAuto && logicalWidthIsAuto && !logicalRightIsAu
to) { | 3645 } else if (!logicalLeftIsAuto && logicalWidthIsAuto && !logicalRightIsAu
to) { |
| 3676 // RULE 5: (solve for width) | 3646 // RULE 5: (solve for width) |
| 3677 logicalLeftValue = valueForLength(logicalLeft, containerLogicalWidth
, renderView); | 3647 logicalLeftValue = valueForLength(logicalLeft, containerLogicalWidth
); |
| 3678 if (autoWidthShouldFitContent()) | 3648 if (autoWidthShouldFitContent()) |
| 3679 shrinkToFitWidth(availableSpace, logicalLeftValue, bordersPlusPa
dding, computedValues); | 3649 shrinkToFitWidth(availableSpace, logicalLeftValue, bordersPlusPa
dding, computedValues); |
| 3680 else | 3650 else |
| 3681 computedValues.m_extent = availableSpace - (logicalLeftValue + v
alueForLength(logicalRight, containerLogicalWidth, renderView)); | 3651 computedValues.m_extent = availableSpace - (logicalLeftValue + v
alueForLength(logicalRight, containerLogicalWidth)); |
| 3682 } else if (!logicalLeftIsAuto && !logicalWidthIsAuto && logicalRightIsAu
to) { | 3652 } else if (!logicalLeftIsAuto && !logicalWidthIsAuto && logicalRightIsAu
to) { |
| 3683 // RULE 6: (no need solve for right) | 3653 // RULE 6: (no need solve for right) |
| 3684 logicalLeftValue = valueForLength(logicalLeft, containerLogicalWidth
, renderView); | 3654 logicalLeftValue = valueForLength(logicalLeft, containerLogicalWidth
); |
| 3685 computedValues.m_extent = adjustContentBoxLogicalWidthForBoxSizing(v
alueForLength(logicalWidth, containerLogicalWidth, renderView)); | 3655 computedValues.m_extent = adjustContentBoxLogicalWidthForBoxSizing(v
alueForLength(logicalWidth, containerLogicalWidth)); |
| 3686 } | 3656 } |
| 3687 } | 3657 } |
| 3688 | 3658 |
| 3689 // Use computed values to calculate the horizontal position. | 3659 // Use computed values to calculate the horizontal position. |
| 3690 | 3660 |
| 3691 // FIXME: This hack is needed to calculate the logical left position for a
'rtl' relatively | 3661 // FIXME: This hack is needed to calculate the logical left position for a
'rtl' relatively |
| 3692 // positioned, inline because right now, it is using the logical left positi
on | 3662 // positioned, inline because right now, it is using the logical left positi
on |
| 3693 // of the first line box when really it should use the last line box. When | 3663 // of the first line box when really it should use the last line box. When |
| 3694 // this is fixed elsewhere, this block should be removed. | 3664 // this is fixed elsewhere, this block should be removed. |
| 3695 if (containerBlock->isRenderInline() && !containerBlock->style()->isLeftToRi
ghtDirection()) { | 3665 if (containerBlock->isRenderInline() && !containerBlock->style()->isLeftToRi
ghtDirection()) { |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3869 LayoutUnit logicalHeightValue; | 3839 LayoutUnit logicalHeightValue; |
| 3870 LayoutUnit contentLogicalHeight = logicalHeight - bordersPlusPadding; | 3840 LayoutUnit contentLogicalHeight = logicalHeight - bordersPlusPadding; |
| 3871 | 3841 |
| 3872 const LayoutUnit containerRelativeLogicalWidth = containingBlockLogicalWidth
ForPositioned(containerBlock, 0, false); | 3842 const LayoutUnit containerRelativeLogicalWidth = containingBlockLogicalWidth
ForPositioned(containerBlock, 0, false); |
| 3873 | 3843 |
| 3874 LayoutUnit logicalTopValue = 0; | 3844 LayoutUnit logicalTopValue = 0; |
| 3875 | 3845 |
| 3876 bool logicalHeightIsAuto = logicalHeightLength.isAuto(); | 3846 bool logicalHeightIsAuto = logicalHeightLength.isAuto(); |
| 3877 bool logicalTopIsAuto = logicalTop.isAuto(); | 3847 bool logicalTopIsAuto = logicalTop.isAuto(); |
| 3878 bool logicalBottomIsAuto = logicalBottom.isAuto(); | 3848 bool logicalBottomIsAuto = logicalBottom.isAuto(); |
| 3879 RenderView* renderView = view(); | |
| 3880 | 3849 |
| 3881 LayoutUnit resolvedLogicalHeight; | 3850 LayoutUnit resolvedLogicalHeight; |
| 3882 // Height is never unsolved for tables. | 3851 // Height is never unsolved for tables. |
| 3883 if (isTable()) { | 3852 if (isTable()) { |
| 3884 resolvedLogicalHeight = contentLogicalHeight; | 3853 resolvedLogicalHeight = contentLogicalHeight; |
| 3885 logicalHeightIsAuto = false; | 3854 logicalHeightIsAuto = false; |
| 3886 } else { | 3855 } else { |
| 3887 if (logicalHeightLength.isIntrinsic()) | 3856 if (logicalHeightLength.isIntrinsic()) |
| 3888 resolvedLogicalHeight = computeIntrinsicLogicalContentHeightUsing(lo
gicalHeightLength, contentLogicalHeight, bordersPlusPadding); | 3857 resolvedLogicalHeight = computeIntrinsicLogicalContentHeightUsing(lo
gicalHeightLength, contentLogicalHeight, bordersPlusPadding); |
| 3889 else | 3858 else |
| 3890 resolvedLogicalHeight = adjustContentBoxLogicalHeightForBoxSizing(va
lueForLength(logicalHeightLength, containerLogicalHeight, renderView)); | 3859 resolvedLogicalHeight = adjustContentBoxLogicalHeightForBoxSizing(va
lueForLength(logicalHeightLength, containerLogicalHeight)); |
| 3891 } | 3860 } |
| 3892 | 3861 |
| 3893 if (!logicalTopIsAuto && !logicalHeightIsAuto && !logicalBottomIsAuto) { | 3862 if (!logicalTopIsAuto && !logicalHeightIsAuto && !logicalBottomIsAuto) { |
| 3894 /*----------------------------------------------------------------------
-*\ | 3863 /*----------------------------------------------------------------------
-*\ |
| 3895 * If none of the three are 'auto': If both 'margin-top' and 'margin- | 3864 * If none of the three are 'auto': If both 'margin-top' and 'margin- |
| 3896 * bottom' are 'auto', solve the equation under the extra constraint tha
t | 3865 * bottom' are 'auto', solve the equation under the extra constraint tha
t |
| 3897 * the two margins get equal values. If one of 'margin-top' or 'margin- | 3866 * the two margins get equal values. If one of 'margin-top' or 'margin- |
| 3898 * bottom' is 'auto', solve the equation for that value. If the values | 3867 * bottom' is 'auto', solve the equation for that value. If the values |
| 3899 * are over-constrained, ignore the value for 'bottom' and solve for tha
t | 3868 * are over-constrained, ignore the value for 'bottom' and solve for tha
t |
| 3900 * value. | 3869 * value. |
| 3901 \*----------------------------------------------------------------------
-*/ | 3870 \*----------------------------------------------------------------------
-*/ |
| 3902 // NOTE: It is not necessary to solve for 'bottom' in the over constrai
ned | 3871 // NOTE: It is not necessary to solve for 'bottom' in the over constrai
ned |
| 3903 // case because the value is not used for any further calculations. | 3872 // case because the value is not used for any further calculations. |
| 3904 | 3873 |
| 3905 logicalHeightValue = resolvedLogicalHeight; | 3874 logicalHeightValue = resolvedLogicalHeight; |
| 3906 logicalTopValue = valueForLength(logicalTop, containerLogicalHeight, ren
derView); | 3875 logicalTopValue = valueForLength(logicalTop, containerLogicalHeight); |
| 3907 | 3876 |
| 3908 const LayoutUnit availableSpace = containerLogicalHeight - (logicalTopVa
lue + logicalHeightValue + valueForLength(logicalBottom, containerLogicalHeight,
renderView) + bordersPlusPadding); | 3877 const LayoutUnit availableSpace = containerLogicalHeight - (logicalTopVa
lue + logicalHeightValue + valueForLength(logicalBottom, containerLogicalHeight)
+ bordersPlusPadding); |
| 3909 | 3878 |
| 3910 // Margins are now the only unknown | 3879 // Margins are now the only unknown |
| 3911 if (marginBefore.isAuto() && marginAfter.isAuto()) { | 3880 if (marginBefore.isAuto() && marginAfter.isAuto()) { |
| 3912 // Both margins auto, solve for equality | 3881 // Both margins auto, solve for equality |
| 3913 // NOTE: This may result in negative values. | 3882 // NOTE: This may result in negative values. |
| 3914 computedValues.m_margins.m_before = availableSpace / 2; // split the
difference | 3883 computedValues.m_margins.m_before = availableSpace / 2; // split the
difference |
| 3915 computedValues.m_margins.m_after = availableSpace - computedValues.m
_margins.m_before; // account for odd valued differences | 3884 computedValues.m_margins.m_after = availableSpace - computedValues.m
_margins.m_before; // account for odd valued differences |
| 3916 } else if (marginBefore.isAuto()) { | 3885 } else if (marginBefore.isAuto()) { |
| 3917 // Solve for top margin | 3886 // Solve for top margin |
| 3918 computedValues.m_margins.m_after = valueForLength(marginAfter, conta
inerRelativeLogicalWidth, renderView); | 3887 computedValues.m_margins.m_after = valueForLength(marginAfter, conta
inerRelativeLogicalWidth); |
| 3919 computedValues.m_margins.m_before = availableSpace - computedValues.
m_margins.m_after; | 3888 computedValues.m_margins.m_before = availableSpace - computedValues.
m_margins.m_after; |
| 3920 } else if (marginAfter.isAuto()) { | 3889 } else if (marginAfter.isAuto()) { |
| 3921 // Solve for bottom margin | 3890 // Solve for bottom margin |
| 3922 computedValues.m_margins.m_before = valueForLength(marginBefore, con
tainerRelativeLogicalWidth, renderView); | 3891 computedValues.m_margins.m_before = valueForLength(marginBefore, con
tainerRelativeLogicalWidth); |
| 3923 computedValues.m_margins.m_after = availableSpace - computedValues.m
_margins.m_before; | 3892 computedValues.m_margins.m_after = availableSpace - computedValues.m
_margins.m_before; |
| 3924 } else { | 3893 } else { |
| 3925 // Over-constrained, (no need solve for bottom) | 3894 // Over-constrained, (no need solve for bottom) |
| 3926 computedValues.m_margins.m_before = valueForLength(marginBefore, con
tainerRelativeLogicalWidth, renderView); | 3895 computedValues.m_margins.m_before = valueForLength(marginBefore, con
tainerRelativeLogicalWidth); |
| 3927 computedValues.m_margins.m_after = valueForLength(marginAfter, conta
inerRelativeLogicalWidth, renderView); | 3896 computedValues.m_margins.m_after = valueForLength(marginAfter, conta
inerRelativeLogicalWidth); |
| 3928 } | 3897 } |
| 3929 } else { | 3898 } else { |
| 3930 /*--------------------------------------------------------------------*\ | 3899 /*--------------------------------------------------------------------*\ |
| 3931 * Otherwise, set 'auto' values for 'margin-top' and 'margin-bottom' | 3900 * Otherwise, set 'auto' values for 'margin-top' and 'margin-bottom' |
| 3932 * to 0, and pick the one of the following six rules that applies. | 3901 * to 0, and pick the one of the following six rules that applies. |
| 3933 * | 3902 * |
| 3934 * 1. 'top' and 'height' are 'auto' and 'bottom' is not 'auto', then | 3903 * 1. 'top' and 'height' are 'auto' and 'bottom' is not 'auto', then |
| 3935 * the height is based on the content, and solve for 'top'. | 3904 * the height is based on the content, and solve for 'top'. |
| 3936 * | 3905 * |
| 3937 * OMIT RULE 2 AS IT SHOULD NEVER BE HIT | 3906 * OMIT RULE 2 AS IT SHOULD NEVER BE HIT |
| 3938 * ------------------------------------------------------------------ | 3907 * ------------------------------------------------------------------ |
| 3939 * 2. 'top' and 'bottom' are 'auto' and 'height' is not 'auto', then | 3908 * 2. 'top' and 'bottom' are 'auto' and 'height' is not 'auto', then |
| 3940 * set 'top' to the static position, and solve for 'bottom'. | 3909 * set 'top' to the static position, and solve for 'bottom'. |
| 3941 * ------------------------------------------------------------------ | 3910 * ------------------------------------------------------------------ |
| 3942 * | 3911 * |
| 3943 * 3. 'height' and 'bottom' are 'auto' and 'top' is not 'auto', then | 3912 * 3. 'height' and 'bottom' are 'auto' and 'top' is not 'auto', then |
| 3944 * the height is based on the content, and solve for 'bottom'. | 3913 * the height is based on the content, and solve for 'bottom'. |
| 3945 * 4. 'top' is 'auto', 'height' and 'bottom' are not 'auto', and | 3914 * 4. 'top' is 'auto', 'height' and 'bottom' are not 'auto', and |
| 3946 * solve for 'top'. | 3915 * solve for 'top'. |
| 3947 * 5. 'height' is 'auto', 'top' and 'bottom' are not 'auto', and | 3916 * 5. 'height' is 'auto', 'top' and 'bottom' are not 'auto', and |
| 3948 * solve for 'height'. | 3917 * solve for 'height'. |
| 3949 * 6. 'bottom' is 'auto', 'top' and 'height' are not 'auto', and | 3918 * 6. 'bottom' is 'auto', 'top' and 'height' are not 'auto', and |
| 3950 * solve for 'bottom'. | 3919 * solve for 'bottom'. |
| 3951 \*--------------------------------------------------------------------*/ | 3920 \*--------------------------------------------------------------------*/ |
| 3952 // NOTE: For rules 3 and 6 it is not necessary to solve for 'bottom' | 3921 // NOTE: For rules 3 and 6 it is not necessary to solve for 'bottom' |
| 3953 // because the value is not used for any further calculations. | 3922 // because the value is not used for any further calculations. |
| 3954 | 3923 |
| 3955 // Calculate margins, 'auto' margins are ignored. | 3924 // Calculate margins, 'auto' margins are ignored. |
| 3956 computedValues.m_margins.m_before = minimumValueForLength(marginBefore,
containerRelativeLogicalWidth, renderView); | 3925 computedValues.m_margins.m_before = minimumValueForLength(marginBefore,
containerRelativeLogicalWidth); |
| 3957 computedValues.m_margins.m_after = minimumValueForLength(marginAfter, co
ntainerRelativeLogicalWidth, renderView); | 3926 computedValues.m_margins.m_after = minimumValueForLength(marginAfter, co
ntainerRelativeLogicalWidth); |
| 3958 | 3927 |
| 3959 const LayoutUnit availableSpace = containerLogicalHeight - (computedValu
es.m_margins.m_before + computedValues.m_margins.m_after + bordersPlusPadding); | 3928 const LayoutUnit availableSpace = containerLogicalHeight - (computedValu
es.m_margins.m_before + computedValues.m_margins.m_after + bordersPlusPadding); |
| 3960 | 3929 |
| 3961 // Use rule/case that applies. | 3930 // Use rule/case that applies. |
| 3962 if (logicalTopIsAuto && logicalHeightIsAuto && !logicalBottomIsAuto) { | 3931 if (logicalTopIsAuto && logicalHeightIsAuto && !logicalBottomIsAuto) { |
| 3963 // RULE 1: (height is content based, solve of top) | 3932 // RULE 1: (height is content based, solve of top) |
| 3964 logicalHeightValue = contentLogicalHeight; | 3933 logicalHeightValue = contentLogicalHeight; |
| 3965 logicalTopValue = availableSpace - (logicalHeightValue + valueForLen
gth(logicalBottom, containerLogicalHeight, renderView)); | 3934 logicalTopValue = availableSpace - (logicalHeightValue + valueForLen
gth(logicalBottom, containerLogicalHeight)); |
| 3966 } else if (!logicalTopIsAuto && logicalHeightIsAuto && logicalBottomIsAu
to) { | 3935 } else if (!logicalTopIsAuto && logicalHeightIsAuto && logicalBottomIsAu
to) { |
| 3967 // RULE 3: (height is content based, no need solve of bottom) | 3936 // RULE 3: (height is content based, no need solve of bottom) |
| 3968 logicalTopValue = valueForLength(logicalTop, containerLogicalHeight,
renderView); | 3937 logicalTopValue = valueForLength(logicalTop, containerLogicalHeight)
; |
| 3969 logicalHeightValue = contentLogicalHeight; | 3938 logicalHeightValue = contentLogicalHeight; |
| 3970 } else if (logicalTopIsAuto && !logicalHeightIsAuto && !logicalBottomIsA
uto) { | 3939 } else if (logicalTopIsAuto && !logicalHeightIsAuto && !logicalBottomIsA
uto) { |
| 3971 // RULE 4: (solve of top) | 3940 // RULE 4: (solve of top) |
| 3972 logicalHeightValue = resolvedLogicalHeight; | 3941 logicalHeightValue = resolvedLogicalHeight; |
| 3973 logicalTopValue = availableSpace - (logicalHeightValue + valueForLen
gth(logicalBottom, containerLogicalHeight, renderView)); | 3942 logicalTopValue = availableSpace - (logicalHeightValue + valueForLen
gth(logicalBottom, containerLogicalHeight)); |
| 3974 } else if (!logicalTopIsAuto && logicalHeightIsAuto && !logicalBottomIsA
uto) { | 3943 } else if (!logicalTopIsAuto && logicalHeightIsAuto && !logicalBottomIsA
uto) { |
| 3975 // RULE 5: (solve of height) | 3944 // RULE 5: (solve of height) |
| 3976 logicalTopValue = valueForLength(logicalTop, containerLogicalHeight,
renderView); | 3945 logicalTopValue = valueForLength(logicalTop, containerLogicalHeight)
; |
| 3977 logicalHeightValue = max<LayoutUnit>(0, availableSpace - (logicalTop
Value + valueForLength(logicalBottom, containerLogicalHeight, renderView))); | 3946 logicalHeightValue = max<LayoutUnit>(0, availableSpace - (logicalTop
Value + valueForLength(logicalBottom, containerLogicalHeight))); |
| 3978 } else if (!logicalTopIsAuto && !logicalHeightIsAuto && logicalBottomIsA
uto) { | 3947 } else if (!logicalTopIsAuto && !logicalHeightIsAuto && logicalBottomIsA
uto) { |
| 3979 // RULE 6: (no need solve of bottom) | 3948 // RULE 6: (no need solve of bottom) |
| 3980 logicalHeightValue = resolvedLogicalHeight; | 3949 logicalHeightValue = resolvedLogicalHeight; |
| 3981 logicalTopValue = valueForLength(logicalTop, containerLogicalHeight,
renderView); | 3950 logicalTopValue = valueForLength(logicalTop, containerLogicalHeight)
; |
| 3982 } | 3951 } |
| 3983 } | 3952 } |
| 3984 computedValues.m_extent = logicalHeightValue; | 3953 computedValues.m_extent = logicalHeightValue; |
| 3985 | 3954 |
| 3986 // Use computed values to calculate the vertical position. | 3955 // Use computed values to calculate the vertical position. |
| 3987 computedValues.m_position = logicalTopValue + computedValues.m_margins.m_bef
ore; | 3956 computedValues.m_position = logicalTopValue + computedValues.m_margins.m_bef
ore; |
| 3988 computeLogicalTopPositionedOffset(computedValues.m_position, this, logicalHe
ightValue, containerBlock, containerLogicalHeight); | 3957 computeLogicalTopPositionedOffset(computedValues.m_position, this, logicalHe
ightValue, containerBlock, containerLogicalHeight); |
| 3989 } | 3958 } |
| 3990 | 3959 |
| 3991 void RenderBox::computePositionedLogicalWidthReplaced(LogicalExtentComputedValue
s& computedValues) const | 3960 void RenderBox::computePositionedLogicalWidthReplaced(LogicalExtentComputedValue
s& computedValues) const |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4049 /*-----------------------------------------------------------------------*\ | 4018 /*-----------------------------------------------------------------------*\ |
| 4050 * 4. If at this point both 'margin-left' and 'margin-right' are still | 4019 * 4. If at this point both 'margin-left' and 'margin-right' are still |
| 4051 * 'auto', solve the equation under the extra constraint that the two | 4020 * 'auto', solve the equation under the extra constraint that the two |
| 4052 * margins must get equal values, unless this would make them negative, | 4021 * margins must get equal values, unless this would make them negative, |
| 4053 * in which case when the direction of the containing block is 'ltr' | 4022 * in which case when the direction of the containing block is 'ltr' |
| 4054 * ('rtl'), set 'margin-left' ('margin-right') to zero and solve for | 4023 * ('rtl'), set 'margin-left' ('margin-right') to zero and solve for |
| 4055 * 'margin-right' ('margin-left'). | 4024 * 'margin-right' ('margin-left'). |
| 4056 \*-----------------------------------------------------------------------*/ | 4025 \*-----------------------------------------------------------------------*/ |
| 4057 LayoutUnit logicalLeftValue = 0; | 4026 LayoutUnit logicalLeftValue = 0; |
| 4058 LayoutUnit logicalRightValue = 0; | 4027 LayoutUnit logicalRightValue = 0; |
| 4059 RenderView* renderView = view(); | |
| 4060 | 4028 |
| 4061 if (marginLogicalLeft.isAuto() && marginLogicalRight.isAuto()) { | 4029 if (marginLogicalLeft.isAuto() && marginLogicalRight.isAuto()) { |
| 4062 // 'left' and 'right' cannot be 'auto' due to step 3 | 4030 // 'left' and 'right' cannot be 'auto' due to step 3 |
| 4063 ASSERT(!(logicalLeft.isAuto() && logicalRight.isAuto())); | 4031 ASSERT(!(logicalLeft.isAuto() && logicalRight.isAuto())); |
| 4064 | 4032 |
| 4065 logicalLeftValue = valueForLength(logicalLeft, containerLogicalWidth, re
nderView); | 4033 logicalLeftValue = valueForLength(logicalLeft, containerLogicalWidth); |
| 4066 logicalRightValue = valueForLength(logicalRight, containerLogicalWidth,
renderView); | 4034 logicalRightValue = valueForLength(logicalRight, containerLogicalWidth); |
| 4067 | 4035 |
| 4068 LayoutUnit difference = availableSpace - (logicalLeftValue + logicalRigh
tValue); | 4036 LayoutUnit difference = availableSpace - (logicalLeftValue + logicalRigh
tValue); |
| 4069 if (difference > 0) { | 4037 if (difference > 0) { |
| 4070 marginLogicalLeftAlias = difference / 2; // split the difference | 4038 marginLogicalLeftAlias = difference / 2; // split the difference |
| 4071 marginLogicalRightAlias = difference - marginLogicalLeftAlias; // ac
count for odd valued differences | 4039 marginLogicalRightAlias = difference - marginLogicalLeftAlias; // ac
count for odd valued differences |
| 4072 } else { | 4040 } else { |
| 4073 // Use the containing block's direction rather than the parent block
's | 4041 // Use the containing block's direction rather than the parent block
's |
| 4074 // per CSS 2.1 reference test abspos-replaced-width-margin-000. | 4042 // per CSS 2.1 reference test abspos-replaced-width-margin-000. |
| 4075 if (containerDirection == LTR) { | 4043 if (containerDirection == LTR) { |
| 4076 marginLogicalLeftAlias = 0; | 4044 marginLogicalLeftAlias = 0; |
| 4077 marginLogicalRightAlias = difference; // will be negative | 4045 marginLogicalRightAlias = difference; // will be negative |
| 4078 } else { | 4046 } else { |
| 4079 marginLogicalLeftAlias = difference; // will be negative | 4047 marginLogicalLeftAlias = difference; // will be negative |
| 4080 marginLogicalRightAlias = 0; | 4048 marginLogicalRightAlias = 0; |
| 4081 } | 4049 } |
| 4082 } | 4050 } |
| 4083 | 4051 |
| 4084 /*-----------------------------------------------------------------------*\ | 4052 /*-----------------------------------------------------------------------*\ |
| 4085 * 5. If at this point there is an 'auto' left, solve the equation for | 4053 * 5. If at this point there is an 'auto' left, solve the equation for |
| 4086 * that value. | 4054 * that value. |
| 4087 \*-----------------------------------------------------------------------*/ | 4055 \*-----------------------------------------------------------------------*/ |
| 4088 } else if (logicalLeft.isAuto()) { | 4056 } else if (logicalLeft.isAuto()) { |
| 4089 marginLogicalLeftAlias = valueForLength(marginLogicalLeft, containerRela
tiveLogicalWidth, renderView); | 4057 marginLogicalLeftAlias = valueForLength(marginLogicalLeft, containerRela
tiveLogicalWidth); |
| 4090 marginLogicalRightAlias = valueForLength(marginLogicalRight, containerRe
lativeLogicalWidth, renderView); | 4058 marginLogicalRightAlias = valueForLength(marginLogicalRight, containerRe
lativeLogicalWidth); |
| 4091 logicalRightValue = valueForLength(logicalRight, containerLogicalWidth,
renderView); | 4059 logicalRightValue = valueForLength(logicalRight, containerLogicalWidth); |
| 4092 | 4060 |
| 4093 // Solve for 'left' | 4061 // Solve for 'left' |
| 4094 logicalLeftValue = availableSpace - (logicalRightValue + marginLogicalLe
ftAlias + marginLogicalRightAlias); | 4062 logicalLeftValue = availableSpace - (logicalRightValue + marginLogicalLe
ftAlias + marginLogicalRightAlias); |
| 4095 } else if (logicalRight.isAuto()) { | 4063 } else if (logicalRight.isAuto()) { |
| 4096 marginLogicalLeftAlias = valueForLength(marginLogicalLeft, containerRela
tiveLogicalWidth, renderView); | 4064 marginLogicalLeftAlias = valueForLength(marginLogicalLeft, containerRela
tiveLogicalWidth); |
| 4097 marginLogicalRightAlias = valueForLength(marginLogicalRight, containerRe
lativeLogicalWidth, renderView); | 4065 marginLogicalRightAlias = valueForLength(marginLogicalRight, containerRe
lativeLogicalWidth); |
| 4098 logicalLeftValue = valueForLength(logicalLeft, containerLogicalWidth, re
nderView); | 4066 logicalLeftValue = valueForLength(logicalLeft, containerLogicalWidth); |
| 4099 | 4067 |
| 4100 // Solve for 'right' | 4068 // Solve for 'right' |
| 4101 logicalRightValue = availableSpace - (logicalLeftValue + marginLogicalLe
ftAlias + marginLogicalRightAlias); | 4069 logicalRightValue = availableSpace - (logicalLeftValue + marginLogicalLe
ftAlias + marginLogicalRightAlias); |
| 4102 } else if (marginLogicalLeft.isAuto()) { | 4070 } else if (marginLogicalLeft.isAuto()) { |
| 4103 marginLogicalRightAlias = valueForLength(marginLogicalRight, containerRe
lativeLogicalWidth, renderView); | 4071 marginLogicalRightAlias = valueForLength(marginLogicalRight, containerRe
lativeLogicalWidth); |
| 4104 logicalLeftValue = valueForLength(logicalLeft, containerLogicalWidth, re
nderView); | 4072 logicalLeftValue = valueForLength(logicalLeft, containerLogicalWidth); |
| 4105 logicalRightValue = valueForLength(logicalRight, containerLogicalWidth,
renderView); | 4073 logicalRightValue = valueForLength(logicalRight, containerLogicalWidth); |
| 4106 | 4074 |
| 4107 // Solve for 'margin-left' | 4075 // Solve for 'margin-left' |
| 4108 marginLogicalLeftAlias = availableSpace - (logicalLeftValue + logicalRig
htValue + marginLogicalRightAlias); | 4076 marginLogicalLeftAlias = availableSpace - (logicalLeftValue + logicalRig
htValue + marginLogicalRightAlias); |
| 4109 } else if (marginLogicalRight.isAuto()) { | 4077 } else if (marginLogicalRight.isAuto()) { |
| 4110 marginLogicalLeftAlias = valueForLength(marginLogicalLeft, containerRela
tiveLogicalWidth, renderView); | 4078 marginLogicalLeftAlias = valueForLength(marginLogicalLeft, containerRela
tiveLogicalWidth); |
| 4111 logicalLeftValue = valueForLength(logicalLeft, containerLogicalWidth, re
nderView); | 4079 logicalLeftValue = valueForLength(logicalLeft, containerLogicalWidth); |
| 4112 logicalRightValue = valueForLength(logicalRight, containerLogicalWidth,
renderView); | 4080 logicalRightValue = valueForLength(logicalRight, containerLogicalWidth); |
| 4113 | 4081 |
| 4114 // Solve for 'margin-right' | 4082 // Solve for 'margin-right' |
| 4115 marginLogicalRightAlias = availableSpace - (logicalLeftValue + logicalRi
ghtValue + marginLogicalLeftAlias); | 4083 marginLogicalRightAlias = availableSpace - (logicalLeftValue + logicalRi
ghtValue + marginLogicalLeftAlias); |
| 4116 } else { | 4084 } else { |
| 4117 // Nothing is 'auto', just calculate the values. | 4085 // Nothing is 'auto', just calculate the values. |
| 4118 marginLogicalLeftAlias = valueForLength(marginLogicalLeft, containerRela
tiveLogicalWidth, renderView); | 4086 marginLogicalLeftAlias = valueForLength(marginLogicalLeft, containerRela
tiveLogicalWidth); |
| 4119 marginLogicalRightAlias = valueForLength(marginLogicalRight, containerRe
lativeLogicalWidth, renderView); | 4087 marginLogicalRightAlias = valueForLength(marginLogicalRight, containerRe
lativeLogicalWidth); |
| 4120 logicalRightValue = valueForLength(logicalRight, containerLogicalWidth,
renderView); | 4088 logicalRightValue = valueForLength(logicalRight, containerLogicalWidth); |
| 4121 logicalLeftValue = valueForLength(logicalLeft, containerLogicalWidth, re
nderView); | 4089 logicalLeftValue = valueForLength(logicalLeft, containerLogicalWidth); |
| 4122 // If the containing block is right-to-left, then push the left position
as far to the right as possible | 4090 // If the containing block is right-to-left, then push the left position
as far to the right as possible |
| 4123 if (containerDirection == RTL) { | 4091 if (containerDirection == RTL) { |
| 4124 int totalLogicalWidth = computedValues.m_extent + logicalLeftValue +
logicalRightValue + marginLogicalLeftAlias + marginLogicalRightAlias; | 4092 int totalLogicalWidth = computedValues.m_extent + logicalLeftValue +
logicalRightValue + marginLogicalLeftAlias + marginLogicalRightAlias; |
| 4125 logicalLeftValue = containerLogicalWidth - (totalLogicalWidth - logi
calLeftValue); | 4093 logicalLeftValue = containerLogicalWidth - (totalLogicalWidth - logi
calLeftValue); |
| 4126 } | 4094 } |
| 4127 } | 4095 } |
| 4128 | 4096 |
| 4129 /*-----------------------------------------------------------------------*\ | 4097 /*-----------------------------------------------------------------------*\ |
| 4130 * 6. If at this point the values are over-constrained, ignore the value | 4098 * 6. If at this point the values are over-constrained, ignore the value |
| 4131 * for either 'left' (in case the 'direction' property of the | 4099 * for either 'left' (in case the 'direction' property of the |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4173 const LayoutUnit containerRelativeLogicalWidth = containingBlockLogicalWidth
ForPositioned(containerBlock, 0, false); | 4141 const LayoutUnit containerRelativeLogicalWidth = containingBlockLogicalWidth
ForPositioned(containerBlock, 0, false); |
| 4174 | 4142 |
| 4175 // Variables to solve. | 4143 // Variables to solve. |
| 4176 Length marginBefore = style()->marginBefore(); | 4144 Length marginBefore = style()->marginBefore(); |
| 4177 Length marginAfter = style()->marginAfter(); | 4145 Length marginAfter = style()->marginAfter(); |
| 4178 LayoutUnit& marginBeforeAlias = computedValues.m_margins.m_before; | 4146 LayoutUnit& marginBeforeAlias = computedValues.m_margins.m_before; |
| 4179 LayoutUnit& marginAfterAlias = computedValues.m_margins.m_after; | 4147 LayoutUnit& marginAfterAlias = computedValues.m_margins.m_after; |
| 4180 | 4148 |
| 4181 Length logicalTop = style()->logicalTop(); | 4149 Length logicalTop = style()->logicalTop(); |
| 4182 Length logicalBottom = style()->logicalBottom(); | 4150 Length logicalBottom = style()->logicalBottom(); |
| 4183 RenderView* renderView = view(); | |
| 4184 | 4151 |
| 4185 /*-----------------------------------------------------------------------*\ | 4152 /*-----------------------------------------------------------------------*\ |
| 4186 * 1. The used value of 'height' is determined as for inline replaced | 4153 * 1. The used value of 'height' is determined as for inline replaced |
| 4187 * elements. | 4154 * elements. |
| 4188 \*-----------------------------------------------------------------------*/ | 4155 \*-----------------------------------------------------------------------*/ |
| 4189 // NOTE: This value of height is FINAL in that the min/max height calculatio
ns | 4156 // NOTE: This value of height is FINAL in that the min/max height calculatio
ns |
| 4190 // are dealt with in computeReplacedHeight(). This means that the steps to
produce | 4157 // are dealt with in computeReplacedHeight(). This means that the steps to
produce |
| 4191 // correct max/min in the non-replaced version, are not necessary. | 4158 // correct max/min in the non-replaced version, are not necessary. |
| 4192 computedValues.m_extent = computeReplacedLogicalHeight() + borderAndPaddingL
ogicalHeight(); | 4159 computedValues.m_extent = computeReplacedLogicalHeight() + borderAndPaddingL
ogicalHeight(); |
| 4193 const LayoutUnit availableSpace = containerLogicalHeight - computedValues.m_
extent; | 4160 const LayoutUnit availableSpace = containerLogicalHeight - computedValues.m_
extent; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 4217 * 'auto', solve the equation under the extra constraint that the two | 4184 * 'auto', solve the equation under the extra constraint that the two |
| 4218 * margins must get equal values. | 4185 * margins must get equal values. |
| 4219 \*-----------------------------------------------------------------------*/ | 4186 \*-----------------------------------------------------------------------*/ |
| 4220 LayoutUnit logicalTopValue = 0; | 4187 LayoutUnit logicalTopValue = 0; |
| 4221 LayoutUnit logicalBottomValue = 0; | 4188 LayoutUnit logicalBottomValue = 0; |
| 4222 | 4189 |
| 4223 if (marginBefore.isAuto() && marginAfter.isAuto()) { | 4190 if (marginBefore.isAuto() && marginAfter.isAuto()) { |
| 4224 // 'top' and 'bottom' cannot be 'auto' due to step 2 and 3 combined. | 4191 // 'top' and 'bottom' cannot be 'auto' due to step 2 and 3 combined. |
| 4225 ASSERT(!(logicalTop.isAuto() || logicalBottom.isAuto())); | 4192 ASSERT(!(logicalTop.isAuto() || logicalBottom.isAuto())); |
| 4226 | 4193 |
| 4227 logicalTopValue = valueForLength(logicalTop, containerLogicalHeight, ren
derView); | 4194 logicalTopValue = valueForLength(logicalTop, containerLogicalHeight); |
| 4228 logicalBottomValue = valueForLength(logicalBottom, containerLogicalHeigh
t, renderView); | 4195 logicalBottomValue = valueForLength(logicalBottom, containerLogicalHeigh
t); |
| 4229 | 4196 |
| 4230 LayoutUnit difference = availableSpace - (logicalTopValue + logicalBotto
mValue); | 4197 LayoutUnit difference = availableSpace - (logicalTopValue + logicalBotto
mValue); |
| 4231 // NOTE: This may result in negative values. | 4198 // NOTE: This may result in negative values. |
| 4232 marginBeforeAlias = difference / 2; // split the difference | 4199 marginBeforeAlias = difference / 2; // split the difference |
| 4233 marginAfterAlias = difference - marginBeforeAlias; // account for odd va
lued differences | 4200 marginAfterAlias = difference - marginBeforeAlias; // account for odd va
lued differences |
| 4234 | 4201 |
| 4235 /*-----------------------------------------------------------------------*\ | 4202 /*-----------------------------------------------------------------------*\ |
| 4236 * 5. If at this point there is only one 'auto' left, solve the equation | 4203 * 5. If at this point there is only one 'auto' left, solve the equation |
| 4237 * for that value. | 4204 * for that value. |
| 4238 \*-----------------------------------------------------------------------*/ | 4205 \*-----------------------------------------------------------------------*/ |
| 4239 } else if (logicalTop.isAuto()) { | 4206 } else if (logicalTop.isAuto()) { |
| 4240 marginBeforeAlias = valueForLength(marginBefore, containerRelativeLogica
lWidth, renderView); | 4207 marginBeforeAlias = valueForLength(marginBefore, containerRelativeLogica
lWidth); |
| 4241 marginAfterAlias = valueForLength(marginAfter, containerRelativeLogicalW
idth, renderView); | 4208 marginAfterAlias = valueForLength(marginAfter, containerRelativeLogicalW
idth); |
| 4242 logicalBottomValue = valueForLength(logicalBottom, containerLogicalHeigh
t, renderView); | 4209 logicalBottomValue = valueForLength(logicalBottom, containerLogicalHeigh
t); |
| 4243 | 4210 |
| 4244 // Solve for 'top' | 4211 // Solve for 'top' |
| 4245 logicalTopValue = availableSpace - (logicalBottomValue + marginBeforeAli
as + marginAfterAlias); | 4212 logicalTopValue = availableSpace - (logicalBottomValue + marginBeforeAli
as + marginAfterAlias); |
| 4246 } else if (logicalBottom.isAuto()) { | 4213 } else if (logicalBottom.isAuto()) { |
| 4247 marginBeforeAlias = valueForLength(marginBefore, containerRelativeLogica
lWidth, renderView); | 4214 marginBeforeAlias = valueForLength(marginBefore, containerRelativeLogica
lWidth); |
| 4248 marginAfterAlias = valueForLength(marginAfter, containerRelativeLogicalW
idth, renderView); | 4215 marginAfterAlias = valueForLength(marginAfter, containerRelativeLogicalW
idth); |
| 4249 logicalTopValue = valueForLength(logicalTop, containerLogicalHeight, ren
derView); | 4216 logicalTopValue = valueForLength(logicalTop, containerLogicalHeight); |
| 4250 | 4217 |
| 4251 // Solve for 'bottom' | 4218 // Solve for 'bottom' |
| 4252 // NOTE: It is not necessary to solve for 'bottom' because we don't ever | 4219 // NOTE: It is not necessary to solve for 'bottom' because we don't ever |
| 4253 // use the value. | 4220 // use the value. |
| 4254 } else if (marginBefore.isAuto()) { | 4221 } else if (marginBefore.isAuto()) { |
| 4255 marginAfterAlias = valueForLength(marginAfter, containerRelativeLogicalW
idth, renderView); | 4222 marginAfterAlias = valueForLength(marginAfter, containerRelativeLogicalW
idth); |
| 4256 logicalTopValue = valueForLength(logicalTop, containerLogicalHeight, ren
derView); | 4223 logicalTopValue = valueForLength(logicalTop, containerLogicalHeight); |
| 4257 logicalBottomValue = valueForLength(logicalBottom, containerLogicalHeigh
t, renderView); | 4224 logicalBottomValue = valueForLength(logicalBottom, containerLogicalHeigh
t); |
| 4258 | 4225 |
| 4259 // Solve for 'margin-top' | 4226 // Solve for 'margin-top' |
| 4260 marginBeforeAlias = availableSpace - (logicalTopValue + logicalBottomVal
ue + marginAfterAlias); | 4227 marginBeforeAlias = availableSpace - (logicalTopValue + logicalBottomVal
ue + marginAfterAlias); |
| 4261 } else if (marginAfter.isAuto()) { | 4228 } else if (marginAfter.isAuto()) { |
| 4262 marginBeforeAlias = valueForLength(marginBefore, containerRelativeLogica
lWidth, renderView); | 4229 marginBeforeAlias = valueForLength(marginBefore, containerRelativeLogica
lWidth); |
| 4263 logicalTopValue = valueForLength(logicalTop, containerLogicalHeight, ren
derView); | 4230 logicalTopValue = valueForLength(logicalTop, containerLogicalHeight); |
| 4264 logicalBottomValue = valueForLength(logicalBottom, containerLogicalHeigh
t, renderView); | 4231 logicalBottomValue = valueForLength(logicalBottom, containerLogicalHeigh
t); |
| 4265 | 4232 |
| 4266 // Solve for 'margin-bottom' | 4233 // Solve for 'margin-bottom' |
| 4267 marginAfterAlias = availableSpace - (logicalTopValue + logicalBottomValu
e + marginBeforeAlias); | 4234 marginAfterAlias = availableSpace - (logicalTopValue + logicalBottomValu
e + marginBeforeAlias); |
| 4268 } else { | 4235 } else { |
| 4269 // Nothing is 'auto', just calculate the values. | 4236 // Nothing is 'auto', just calculate the values. |
| 4270 marginBeforeAlias = valueForLength(marginBefore, containerRelativeLogica
lWidth, renderView); | 4237 marginBeforeAlias = valueForLength(marginBefore, containerRelativeLogica
lWidth); |
| 4271 marginAfterAlias = valueForLength(marginAfter, containerRelativeLogicalW
idth, renderView); | 4238 marginAfterAlias = valueForLength(marginAfter, containerRelativeLogicalW
idth); |
| 4272 logicalTopValue = valueForLength(logicalTop, containerLogicalHeight, ren
derView); | 4239 logicalTopValue = valueForLength(logicalTop, containerLogicalHeight); |
| 4273 // NOTE: It is not necessary to solve for 'bottom' because we don't ever | 4240 // NOTE: It is not necessary to solve for 'bottom' because we don't ever |
| 4274 // use the value. | 4241 // use the value. |
| 4275 } | 4242 } |
| 4276 | 4243 |
| 4277 /*-----------------------------------------------------------------------*\ | 4244 /*-----------------------------------------------------------------------*\ |
| 4278 * 6. If at this point the values are over-constrained, ignore the value | 4245 * 6. If at this point the values are over-constrained, ignore the value |
| 4279 * for 'bottom' and solve for that value. | 4246 * for 'bottom' and solve for that value. |
| 4280 \*-----------------------------------------------------------------------*/ | 4247 \*-----------------------------------------------------------------------*/ |
| 4281 // NOTE: It is not necessary to do this step because we don't end up using | 4248 // NOTE: It is not necessary to do this step because we don't end up using |
| 4282 // the value of 'bottom' regardless of whether the values are over-constrain
ed | 4249 // 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... |
| 4915 // FIXME: This should probably include viewport percentage heights as well. | 4882 // FIXME: This should probably include viewport percentage heights as well. |
| 4916 return style()->height().isPercent() || style()->width().isPercent() | 4883 return style()->height().isPercent() || style()->width().isPercent() |
| 4917 || style()->maxHeight().isPercent() || style()->maxWidth().isPercent() | 4884 || style()->maxHeight().isPercent() || style()->maxWidth().isPercent() |
| 4918 || style()->minHeight().isPercent() || style()->minWidth().isPercent(); | 4885 || style()->minHeight().isPercent() || style()->minWidth().isPercent(); |
| 4919 } | 4886 } |
| 4920 | 4887 |
| 4921 bool RenderBox::hasRelativeLogicalHeight() const | 4888 bool RenderBox::hasRelativeLogicalHeight() const |
| 4922 { | 4889 { |
| 4923 return style()->logicalHeight().isPercent() | 4890 return style()->logicalHeight().isPercent() |
| 4924 || style()->logicalMinHeight().isPercent() | 4891 || style()->logicalMinHeight().isPercent() |
| 4925 || style()->logicalMaxHeight().isPercent() | 4892 || style()->logicalMaxHeight().isPercent(); |
| 4926 || style()->logicalHeight().isViewportPercentage() | |
| 4927 || style()->logicalMinHeight().isViewportPercentage() | |
| 4928 || style()->logicalMaxHeight().isViewportPercentage(); | |
| 4929 } | 4893 } |
| 4930 | 4894 |
| 4931 static void markBoxForRelayoutAfterSplit(RenderBox* box) | 4895 static void markBoxForRelayoutAfterSplit(RenderBox* box) |
| 4932 { | 4896 { |
| 4933 // FIXME: The table code should handle that automatically. If not, | 4897 // FIXME: The table code should handle that automatically. If not, |
| 4934 // we should fix it and remove the table part checks. | 4898 // we should fix it and remove the table part checks. |
| 4935 if (box->isTable()) { | 4899 if (box->isTable()) { |
| 4936 // Because we may have added some sections with already computed column
structures, we need to | 4900 // Because we may have added some sections with already computed column
structures, we need to |
| 4937 // sync the table structure with them now. This avoids crashes when addi
ng new cells to the table. | 4901 // sync the table structure with them now. This avoids crashes when addi
ng new cells to the table. |
| 4938 toRenderTable(box)->forceSectionsRecalc(); | 4902 toRenderTable(box)->forceSectionsRecalc(); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4985 return 0; | 4949 return 0; |
| 4986 | 4950 |
| 4987 if (!layoutState && !flowThreadContainingBlock()) | 4951 if (!layoutState && !flowThreadContainingBlock()) |
| 4988 return 0; | 4952 return 0; |
| 4989 | 4953 |
| 4990 RenderBlock* containerBlock = containingBlock(); | 4954 RenderBlock* containerBlock = containingBlock(); |
| 4991 return containerBlock->offsetFromLogicalTopOfFirstPage() + logicalTop(); | 4955 return containerBlock->offsetFromLogicalTopOfFirstPage() + logicalTop(); |
| 4992 } | 4956 } |
| 4993 | 4957 |
| 4994 } // namespace WebCore | 4958 } // namespace WebCore |
| OLD | NEW |