Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(247)

Side by Side Diff: Source/core/rendering/RenderBox.cpp

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

Powered by Google App Engine
This is Rietveld 408576698