OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
4 * (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com) | 4 * (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com) |
5 * (C) 2005, 2006 Samuel Weinig (sam.weinig@gmail.com) | 5 * (C) 2005, 2006 Samuel Weinig (sam.weinig@gmail.com) |
6 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserv
ed. | 6 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserv
ed. |
7 * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved. | 7 * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved. |
8 * | 8 * |
9 * This library is free software; you can redistribute it and/or | 9 * This library is free software; you can redistribute it and/or |
10 * modify it under the terms of the GNU Library General Public | 10 * modify it under the terms of the GNU Library General Public |
(...skipping 2219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2230 computedValues.m_extent = logicalWidthLength.value() + borderAndPaddingL
ogicalWidth(); | 2230 computedValues.m_extent = logicalWidthLength.value() + borderAndPaddingL
ogicalWidth(); |
2231 else { | 2231 else { |
2232 LayoutUnit containerWidthInInlineDirection = containerLogicalWidth; | 2232 LayoutUnit containerWidthInInlineDirection = containerLogicalWidth; |
2233 if (hasPerpendicularContainingBlock) | 2233 if (hasPerpendicularContainingBlock) |
2234 containerWidthInInlineDirection = perpendicularContainingBlockLogica
lHeight(); | 2234 containerWidthInInlineDirection = perpendicularContainingBlockLogica
lHeight(); |
2235 LayoutUnit preferredWidth = computeLogicalWidthUsing(MainOrPreferredSize
, styleToUse->logicalWidth(), containerWidthInInlineDirection, cb); | 2235 LayoutUnit preferredWidth = computeLogicalWidthUsing(MainOrPreferredSize
, styleToUse->logicalWidth(), containerWidthInInlineDirection, cb); |
2236 computedValues.m_extent = constrainLogicalWidthByMinMax(preferredWidth,
containerWidthInInlineDirection, cb); | 2236 computedValues.m_extent = constrainLogicalWidthByMinMax(preferredWidth,
containerWidthInInlineDirection, cb); |
2237 } | 2237 } |
2238 | 2238 |
2239 // Margin calculations. | 2239 // Margin calculations. |
2240 if (hasPerpendicularContainingBlock || isFloating() || isInline()) { | 2240 computeMarginsForDirection(InlineDirection, cb, containerLogicalWidth, compu
tedValues.m_extent, computedValues.m_margins.m_start, |
2241 computedValues.m_margins.m_start = minimumValueForLength(styleToUse->mar
ginStart(), containerLogicalWidth); | 2241 computedValues.m_margins.m_end, style()->marginStart(), style()->marginE
nd()); |
2242 computedValues.m_margins.m_end = minimumValueForLength(styleToUse->margi
nEnd(), containerLogicalWidth); | |
2243 } else { | |
2244 bool hasInvertedDirection = cb->style()->isLeftToRightDirection() != sty
le()->isLeftToRightDirection(); | |
2245 computeInlineDirectionMargins(cb, containerLogicalWidth, computedValues.
m_extent, | |
2246 hasInvertedDirection ? computedValues.m_margins.m_end : computedValu
es.m_margins.m_start, | |
2247 hasInvertedDirection ? computedValues.m_margins.m_start : computedVa
lues.m_margins.m_end); | |
2248 } | |
2249 | 2242 |
2250 if (!hasPerpendicularContainingBlock && containerLogicalWidth && containerLo
gicalWidth != (computedValues.m_extent + computedValues.m_margins.m_start + comp
utedValues.m_margins.m_end) | 2243 if (!hasPerpendicularContainingBlock && containerLogicalWidth && containerLo
gicalWidth != (computedValues.m_extent + computedValues.m_margins.m_start + comp
utedValues.m_margins.m_end) |
2251 && !isFloating() && !isInline() && !cb->isFlexibleBoxIncludingDeprecated
() && !cb->isRenderGrid()) { | 2244 && !isFloating() && !isInline() && !cb->isFlexibleBoxIncludingDeprecated
() && !cb->isRenderGrid()) { |
2252 LayoutUnit newMargin = containerLogicalWidth - computedValues.m_extent -
cb->marginStartForChild(this); | 2245 LayoutUnit newMargin = containerLogicalWidth - computedValues.m_extent -
cb->marginStartForChild(this); |
2253 bool hasInvertedDirection = cb->style()->isLeftToRightDirection() != sty
le()->isLeftToRightDirection(); | 2246 bool hasInvertedDirection = cb->style()->isLeftToRightDirection() != sty
le()->isLeftToRightDirection(); |
2254 if (hasInvertedDirection) | 2247 if (hasInvertedDirection) |
2255 computedValues.m_margins.m_start = newMargin; | 2248 computedValues.m_margins.m_start = newMargin; |
2256 else | 2249 else |
2257 computedValues.m_margins.m_end = newMargin; | 2250 computedValues.m_margins.m_end = newMargin; |
2258 } | 2251 } |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2406 | 2399 |
2407 return false; | 2400 return false; |
2408 } | 2401 } |
2409 | 2402 |
2410 bool RenderBox::autoWidthShouldFitContent() const | 2403 bool RenderBox::autoWidthShouldFitContent() const |
2411 { | 2404 { |
2412 return node() && (isHTMLInputElement(*node()) || isHTMLSelectElement(*node()
) || isHTMLButtonElement(*node()) | 2405 return node() && (isHTMLInputElement(*node()) || isHTMLSelectElement(*node()
) || isHTMLButtonElement(*node()) |
2413 || isHTMLTextAreaElement(*node()) || (isHTMLLegendElement(*node()) && !s
tyle()->hasOutOfFlowPosition())); | 2406 || isHTMLTextAreaElement(*node()) || (isHTMLLegendElement(*node()) && !s
tyle()->hasOutOfFlowPosition())); |
2414 } | 2407 } |
2415 | 2408 |
2416 void RenderBox::computeInlineDirectionMargins(RenderBlock* containingBlock, Layo
utUnit containerWidth, LayoutUnit childWidth, LayoutUnit& marginStart, LayoutUni
t& marginEnd) const | 2409 void RenderBox::computeMarginsForDirection(MarginDirection flowDirection, const
RenderBlock* containingBlock, LayoutUnit containerWidth, LayoutUnit childWidth,
LayoutUnit& marginStart, LayoutUnit& marginEnd, Length marginStartLength, Length
marginEndLength) const |
2417 { | 2410 { |
2418 const RenderStyle* containingBlockStyle = containingBlock->style(); | 2411 if (flowDirection == BlockDirection || isFloating() || isInline()) { |
2419 Length marginStartLength = style()->marginStartUsing(containingBlockStyle); | 2412 if (isTableCell() && flowDirection == BlockDirection) { |
2420 Length marginEndLength = style()->marginEndUsing(containingBlockStyle); | 2413 // FIXME: Not right if we allow cells to have different directionali
ty than the table. If we do allow this, though, |
| 2414 // we may just do it with an extra anonymous block inside the cell. |
| 2415 marginStart = 0; |
| 2416 marginEnd = 0; |
| 2417 return; |
| 2418 } |
2421 | 2419 |
2422 if (isFloating() || isInline()) { | 2420 // Margins are calculated with respect to the logical width of |
| 2421 // the containing block (8.3) |
2423 // Inline blocks/tables and floats don't have their margins increased. | 2422 // Inline blocks/tables and floats don't have their margins increased. |
2424 marginStart = minimumValueForLength(marginStartLength, containerWidth); | 2423 marginStart = minimumValueForLength(marginStartLength, containerWidth); |
2425 marginEnd = minimumValueForLength(marginEndLength, containerWidth); | 2424 marginEnd = minimumValueForLength(marginEndLength, containerWidth); |
2426 return; | 2425 return; |
2427 } | 2426 } |
2428 | 2427 |
2429 if (containingBlock->isFlexibleBox()) { | 2428 if (containingBlock->isFlexibleBox()) { |
2430 // We need to let flexbox handle the margin adjustment - otherwise, flex
box | 2429 // We need to let flexbox handle the margin adjustment - otherwise, flex
box |
2431 // will think we're wider than we actually are and calculate line sizes
wrong. | 2430 // will think we're wider than we actually are and calculate line sizes
wrong. |
2432 // See also http://dev.w3.org/csswg/css-flexbox/#auto-margins | 2431 // See also http://dev.w3.org/csswg/css-flexbox/#auto-margins |
(...skipping 15 matching lines...) Expand all Loading... |
2448 } | 2447 } |
2449 } | 2448 } |
2450 | 2449 |
2451 // CSS 2.1 (10.3.3): "If 'width' is not 'auto' and 'border-left-width' + 'pa
dding-left' + 'width' + 'padding-right' + 'border-right-width' | 2450 // CSS 2.1 (10.3.3): "If 'width' is not 'auto' and 'border-left-width' + 'pa
dding-left' + 'width' + 'padding-right' + 'border-right-width' |
2452 // (plus any of 'margin-left' or 'margin-right' that are not 'auto') is larg
er than the width of the containing block, then any 'auto' | 2451 // (plus any of 'margin-left' or 'margin-right' that are not 'auto') is larg
er than the width of the containing block, then any 'auto' |
2453 // values for 'margin-left' or 'margin-right' are, for the following rules,
treated as zero. | 2452 // values for 'margin-left' or 'margin-right' are, for the following rules,
treated as zero. |
2454 LayoutUnit marginBoxWidth = childWidth + (!style()->width().isAuto() ? margi
nStartWidth + marginEndWidth : LayoutUnit()); | 2453 LayoutUnit marginBoxWidth = childWidth + (!style()->width().isAuto() ? margi
nStartWidth + marginEndWidth : LayoutUnit()); |
2455 | 2454 |
2456 // CSS 2.1: "If both 'margin-left' and 'margin-right' are 'auto', their used
values are equal. This horizontally centers the element | 2455 // CSS 2.1: "If both 'margin-left' and 'margin-right' are 'auto', their used
values are equal. This horizontally centers the element |
2457 // with respect to the edges of the containing block." | 2456 // with respect to the edges of the containing block." |
| 2457 const RenderStyle* containingBlockStyle = containingBlock->style(); |
2458 if ((marginStartLength.isAuto() && marginEndLength.isAuto() && marginBoxWidt
h < availableWidth) | 2458 if ((marginStartLength.isAuto() && marginEndLength.isAuto() && marginBoxWidt
h < availableWidth) |
2459 || (!marginStartLength.isAuto() && !marginEndLength.isAuto() && containi
ngBlock->style()->textAlign() == WEBKIT_CENTER)) { | 2459 || (!marginStartLength.isAuto() && !marginEndLength.isAuto() && containi
ngBlockStyle->textAlign() == WEBKIT_CENTER)) { |
2460 // Other browsers center the margin box for align=center elements so we
match them here. | 2460 // Other browsers center the margin box for align=center elements so we
match them here. |
2461 LayoutUnit centeredMarginBoxStart = max<LayoutUnit>(0, (availableWidth -
childWidth - marginStartWidth - marginEndWidth) / 2); | 2461 LayoutUnit centeredMarginBoxStart = max<LayoutUnit>(0, (availableWidth -
childWidth - marginStartWidth - marginEndWidth) / 2); |
2462 marginStart = centeredMarginBoxStart + marginStartWidth; | 2462 marginStart = centeredMarginBoxStart + marginStartWidth; |
2463 marginEnd = availableWidth - childWidth - marginStart + marginEndWidth; | 2463 marginEnd = availableWidth - childWidth - marginStart + marginEndWidth; |
2464 return; | 2464 return; |
2465 } | 2465 } |
2466 | 2466 |
2467 // CSS 2.1: "If there is exactly one value specified as 'auto', its used val
ue follows from the equality." | 2467 // CSS 2.1: "If there is exactly one value specified as 'auto', its used val
ue follows from the equality." |
2468 if (marginEndLength.isAuto() && marginBoxWidth < availableWidth) { | 2468 if (marginEndLength.isAuto() && marginBoxWidth < availableWidth) { |
2469 marginStart = marginStartWidth; | 2469 marginStart = marginStartWidth; |
2470 marginEnd = availableWidth - childWidth - marginStart; | 2470 marginEnd = availableWidth - childWidth - marginStart; |
2471 return; | 2471 return; |
2472 } | 2472 } |
2473 | 2473 |
2474 bool pushToEndFromTextAlign = !marginEndLength.isAuto() && ((!containingBloc
kStyle->isLeftToRightDirection() && containingBlockStyle->textAlign() == WEBKIT_
LEFT) | 2474 bool pushToEndFromTextAlign = !marginEndLength.isAuto() && ((!containingBloc
kStyle->isLeftToRightDirection() && containingBlockStyle->textAlign() == WEBKIT_
LEFT) |
2475 || (containingBlockStyle->isLeftToRightDirection() && containingBlockSty
le->textAlign() == WEBKIT_RIGHT)); | 2475 || (containingBlockStyle->isLeftToRightDirection() && containingBlockSty
le->textAlign() == WEBKIT_RIGHT)); |
2476 if ((marginStartLength.isAuto() && marginBoxWidth < availableWidth) || pushT
oEndFromTextAlign) { | 2476 if ((marginStartLength.isAuto() && marginBoxWidth < availableWidth) || pushT
oEndFromTextAlign) { |
2477 marginEnd = marginEndWidth; | 2477 marginEnd = marginEndWidth; |
2478 marginStart = availableWidth - childWidth - marginEnd; | 2478 marginStart = availableWidth - childWidth - marginEnd; |
2479 return; | 2479 return; |
2480 } | 2480 } |
2481 | 2481 |
2482 // Either no auto margins, or our margin box width is >= the container width
, auto margins will just turn into 0. | 2482 // Either no auto margins, or our margin box width is >= the container width
, auto margins will just turn into 0. |
2483 marginStart = marginStartWidth; | 2483 marginStart = marginStartWidth; |
2484 marginEnd = marginEndWidth; | 2484 marginEnd = marginEndWidth; |
2485 } | 2485 } |
2486 | 2486 |
2487 static bool shouldFlipBeforeAfterMargins(const RenderStyle* containingBlockStyle
, const RenderStyle* childStyle) | |
2488 { | |
2489 ASSERT(containingBlockStyle->isHorizontalWritingMode() != childStyle->isHori
zontalWritingMode()); | |
2490 WritingMode childWritingMode = childStyle->writingMode(); | |
2491 bool shouldFlip = false; | |
2492 switch (containingBlockStyle->writingMode()) { | |
2493 case TopToBottomWritingMode: | |
2494 shouldFlip = (childWritingMode == RightToLeftWritingMode); | |
2495 break; | |
2496 case BottomToTopWritingMode: | |
2497 shouldFlip = (childWritingMode == RightToLeftWritingMode); | |
2498 break; | |
2499 case RightToLeftWritingMode: | |
2500 shouldFlip = (childWritingMode == BottomToTopWritingMode); | |
2501 break; | |
2502 case LeftToRightWritingMode: | |
2503 shouldFlip = (childWritingMode == BottomToTopWritingMode); | |
2504 break; | |
2505 } | |
2506 | |
2507 if (!containingBlockStyle->isLeftToRightDirection()) | |
2508 shouldFlip = !shouldFlip; | |
2509 | |
2510 return shouldFlip; | |
2511 } | |
2512 | |
2513 void RenderBox::updateLogicalHeight() | 2487 void RenderBox::updateLogicalHeight() |
2514 { | 2488 { |
2515 m_intrinsicContentLogicalHeight = contentLogicalHeight(); | 2489 m_intrinsicContentLogicalHeight = contentLogicalHeight(); |
2516 | 2490 |
2517 LogicalExtentComputedValues computedValues; | 2491 LogicalExtentComputedValues computedValues; |
2518 computeLogicalHeight(logicalHeight(), logicalTop(), computedValues); | 2492 computeLogicalHeight(logicalHeight(), logicalTop(), computedValues); |
2519 | 2493 |
2520 setLogicalHeight(computedValues.m_extent); | 2494 setLogicalHeight(computedValues.m_extent); |
2521 setLogicalTop(computedValues.m_position); | 2495 setLogicalTop(computedValues.m_position); |
2522 setMarginBefore(computedValues.m_margins.m_before); | 2496 setMarginBefore(computedValues.m_margins.m_before); |
2523 setMarginAfter(computedValues.m_margins.m_after); | 2497 setMarginAfter(computedValues.m_margins.m_after); |
2524 } | 2498 } |
2525 | 2499 |
2526 void RenderBox::computeLogicalHeight(LayoutUnit logicalHeight, LayoutUnit logica
lTop, LogicalExtentComputedValues& computedValues) const | 2500 void RenderBox::computeLogicalHeight(LayoutUnit logicalHeight, LayoutUnit logica
lTop, LogicalExtentComputedValues& computedValues) const |
2527 { | 2501 { |
2528 computedValues.m_extent = logicalHeight; | 2502 computedValues.m_extent = logicalHeight; |
2529 computedValues.m_position = logicalTop; | 2503 computedValues.m_position = logicalTop; |
2530 | 2504 |
2531 // Cell height is managed by the table and inline non-replaced elements do n
ot support a height property. | 2505 // Cell height is managed by the table and inline non-replaced elements do n
ot support a height property. |
2532 if (isTableCell() || (isInline() && !isReplaced())) | 2506 if (isTableCell() || (isInline() && !isReplaced())) |
2533 return; | 2507 return; |
2534 | 2508 |
2535 Length h; | 2509 Length h; |
2536 if (isOutOfFlowPositioned()) | 2510 if (isOutOfFlowPositioned()) |
2537 computePositionedLogicalHeight(computedValues); | 2511 computePositionedLogicalHeight(computedValues); |
2538 else { | 2512 else { |
2539 RenderBlock* cb = containingBlock(); | 2513 RenderBlock* cb = containingBlock(); |
2540 bool hasPerpendicularContainingBlock = cb->isHorizontalWritingMode() !=
isHorizontalWritingMode(); | |
2541 | 2514 |
2542 if (!hasPerpendicularContainingBlock) { | 2515 // If we are perpendicular to our containing block then we need to resol
ve our block-start and block-end margins so that if they |
2543 bool shouldFlipBeforeAfter = cb->style()->writingMode() != style()->
writingMode(); | 2516 // are 'auto' we are centred or aligned within the inline flow containin
g block: this is done by computing the margins as though they are inline. |
2544 computeBlockDirectionMargins(cb, | 2517 // Note that as this is the 'sizing phase' we are using our own writing
mode rather than the containing block's. We use the containing block's |
2545 shouldFlipBeforeAfter ? computedValues.m_margins.m_after : compu
tedValues.m_margins.m_before, | 2518 // writing mode when figuring out the block-direction margins for positi
oning in |computeAndSetBlockDirectionMargins| (i.e. margin collapsing etc.). |
2546 shouldFlipBeforeAfter ? computedValues.m_margins.m_before : comp
utedValues.m_margins.m_after); | 2519 // See http://www.w3.org/TR/2014/CR-css-writing-modes-3-20140320/#orthog
onal-flows |
2547 } | 2520 MarginDirection flowDirection = isHorizontalWritingMode() != cb->isHoriz
ontalWritingMode() ? InlineDirection : BlockDirection; |
2548 | 2521 |
2549 // For tables, calculate margins only. | 2522 // For tables, calculate margins only. |
2550 if (isTable()) { | 2523 if (isTable()) { |
2551 if (hasPerpendicularContainingBlock) { | 2524 // FIXME: RenderTable::layout() calls updateLogicalHeight() when an
empty table has no height yet, so auto margins can come out wrong here when |
2552 bool shouldFlipBeforeAfter = shouldFlipBeforeAfterMargins(cb->st
yle(), style()); | 2525 // we are perpendicular to our containing block. |
2553 computeInlineDirectionMargins(cb, containingBlockLogicalWidthFor
Content(), computedValues.m_extent, | 2526 computeMarginsForDirection(flowDirection, cb, containingBlockLogical
WidthForContent(), computedValues.m_extent, computedValues.m_margins.m_before, |
2554 shouldFlipBeforeAfter ? computedValues.m_margins.m_after : c
omputedValues.m_margins.m_before, | 2527 computedValues.m_margins.m_after, style()->marginBefore(), style
()->marginAfter()); |
2555 shouldFlipBeforeAfter ? computedValues.m_margins.m_before :
computedValues.m_margins.m_after); | |
2556 } | |
2557 return; | 2528 return; |
2558 } | 2529 } |
2559 | 2530 |
2560 // FIXME: Account for block-flow in flexible boxes. | 2531 // FIXME: Account for block-flow in flexible boxes. |
2561 // https://bugs.webkit.org/show_bug.cgi?id=46418 | 2532 // https://bugs.webkit.org/show_bug.cgi?id=46418 |
2562 bool inHorizontalBox = parent()->isDeprecatedFlexibleBox() && parent()->
style()->boxOrient() == HORIZONTAL; | 2533 bool inHorizontalBox = parent()->isDeprecatedFlexibleBox() && parent()->
style()->boxOrient() == HORIZONTAL; |
2563 bool stretching = parent()->style()->boxAlign() == BSTRETCH; | 2534 bool stretching = parent()->style()->boxAlign() == BSTRETCH; |
2564 bool treatAsReplaced = shouldComputeSizeAsReplaced() && (!inHorizontalBo
x || !stretching); | 2535 bool treatAsReplaced = shouldComputeSizeAsReplaced() && (!inHorizontalBo
x || !stretching); |
2565 bool checkMinMaxHeight = false; | 2536 bool checkMinMaxHeight = false; |
2566 | 2537 |
(...skipping 26 matching lines...) Expand all Loading... |
2593 heightResult = constrainLogicalHeightByMinMax(heightResult, computed
Values.m_extent - borderAndPaddingLogicalHeight()); | 2564 heightResult = constrainLogicalHeightByMinMax(heightResult, computed
Values.m_extent - borderAndPaddingLogicalHeight()); |
2594 } else { | 2565 } else { |
2595 // The only times we don't check min/max height are when a fixed len
gth has | 2566 // The only times we don't check min/max height are when a fixed len
gth has |
2596 // been given as an override. Just use that. The value has already
been adjusted | 2567 // been given as an override. Just use that. The value has already
been adjusted |
2597 // for box-sizing. | 2568 // for box-sizing. |
2598 ASSERT(h.isFixed()); | 2569 ASSERT(h.isFixed()); |
2599 heightResult = h.value() + borderAndPaddingLogicalHeight(); | 2570 heightResult = h.value() + borderAndPaddingLogicalHeight(); |
2600 } | 2571 } |
2601 | 2572 |
2602 computedValues.m_extent = heightResult; | 2573 computedValues.m_extent = heightResult; |
2603 | 2574 computeMarginsForDirection(flowDirection, cb, containingBlockLogicalWidt
hForContent(), computedValues.m_extent, computedValues.m_margins.m_before, |
2604 if (hasPerpendicularContainingBlock) { | 2575 computedValues.m_margins.m_after, style()->marginBefore(), style()->
marginAfter()); |
2605 bool shouldFlipBeforeAfter = shouldFlipBeforeAfterMargins(cb->style(
), style()); | |
2606 computeInlineDirectionMargins(cb, containingBlockLogicalWidthForCont
ent(), heightResult, | |
2607 shouldFlipBeforeAfter ? computedValues.m_margins.m_after : compu
tedValues.m_margins.m_before, | |
2608 shouldFlipBeforeAfter ? computedValues.m_margins.m_before : comp
utedValues.m_margins.m_after); | |
2609 } | |
2610 } | 2576 } |
2611 | 2577 |
2612 // WinIE quirk: The <html> block always fills the entire canvas in quirks mo
de. The <body> always fills the | 2578 // WinIE quirk: The <html> block always fills the entire canvas in quirks mo
de. The <body> always fills the |
2613 // <html> block in quirks mode. Only apply this quirk if the block is norma
l flow and no height | 2579 // <html> block in quirks mode. Only apply this quirk if the block is norma
l flow and no height |
2614 // is specified. When we're printing, we also need this quirk if the body or
root has a percentage | 2580 // is specified. When we're printing, we also need this quirk if the body or
root has a percentage |
2615 // height since we don't set a height in RenderView when we're printing. So
without this quirk, the | 2581 // height since we don't set a height in RenderView when we're printing. So
without this quirk, the |
2616 // height has nothing to be a percentage of, and it ends up being 0. That is
bad. | 2582 // height has nothing to be a percentage of, and it ends up being 0. That is
bad. |
2617 bool paginatedContentNeedsBaseHeight = document().printing() && h.isPercent(
) | 2583 bool paginatedContentNeedsBaseHeight = document().printing() && h.isPercent(
) |
2618 && (isDocumentElement() || (isBody() && document().documentElement()->re
nderer()->style()->logicalHeight().isPercent())) && !isInline(); | 2584 && (isDocumentElement() || (isBody() && document().documentElement()->re
nderer()->style()->logicalHeight().isPercent())) && !isInline(); |
2619 if (stretchesToViewport() || paginatedContentNeedsBaseHeight) { | 2585 if (stretchesToViewport() || paginatedContentNeedsBaseHeight) { |
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2952 | 2918 |
2953 // FIXME: This is wrong if the containingBlock has a perpendicular writing m
ode. | 2919 // FIXME: This is wrong if the containingBlock has a perpendicular writing m
ode. |
2954 LayoutUnit availableHeight = containingBlockLogicalHeightForContent(heightTy
pe); | 2920 LayoutUnit availableHeight = containingBlockLogicalHeightForContent(heightTy
pe); |
2955 if (heightType == ExcludeMarginBorderPadding) { | 2921 if (heightType == ExcludeMarginBorderPadding) { |
2956 // FIXME: Margin collapsing hasn't happened yet, so this incorrectly rem
oves collapsed margins. | 2922 // FIXME: Margin collapsing hasn't happened yet, so this incorrectly rem
oves collapsed margins. |
2957 availableHeight -= marginBefore() + marginAfter() + borderAndPaddingLogi
calHeight(); | 2923 availableHeight -= marginBefore() + marginAfter() + borderAndPaddingLogi
calHeight(); |
2958 } | 2924 } |
2959 return availableHeight; | 2925 return availableHeight; |
2960 } | 2926 } |
2961 | 2927 |
2962 void RenderBox::computeBlockDirectionMargins(const RenderBlock* containingBlock,
LayoutUnit& marginBefore, LayoutUnit& marginAfter) const | |
2963 { | |
2964 if (isTableCell()) { | |
2965 // FIXME: Not right if we allow cells to have different directionality t
han the table. If we do allow this, though, | |
2966 // we may just do it with an extra anonymous block inside the cell. | |
2967 marginBefore = 0; | |
2968 marginAfter = 0; | |
2969 return; | |
2970 } | |
2971 | |
2972 // Margins are calculated with respect to the logical width of | |
2973 // the containing block (8.3) | |
2974 LayoutUnit cw = containingBlockLogicalWidthForContent(); | |
2975 RenderStyle* containingBlockStyle = containingBlock->style(); | |
2976 marginBefore = minimumValueForLength(style()->marginBeforeUsing(containingBl
ockStyle), cw); | |
2977 marginAfter = minimumValueForLength(style()->marginAfterUsing(containingBloc
kStyle), cw); | |
2978 } | |
2979 | |
2980 void RenderBox::computeAndSetBlockDirectionMargins(const RenderBlock* containing
Block) | 2928 void RenderBox::computeAndSetBlockDirectionMargins(const RenderBlock* containing
Block) |
2981 { | 2929 { |
2982 LayoutUnit marginBefore; | 2930 LayoutUnit marginBefore; |
2983 LayoutUnit marginAfter; | 2931 LayoutUnit marginAfter; |
2984 computeBlockDirectionMargins(containingBlock, marginBefore, marginAfter); | 2932 computeMarginsForDirection(BlockDirection, containingBlock, containingBlockL
ogicalWidthForContent(), logicalHeight(), marginBefore, marginAfter, |
| 2933 style()->marginBeforeUsing(containingBlock->style()), |
| 2934 style()->marginAfterUsing(containingBlock->style())); |
| 2935 // Note that in this 'positioning phase' of the layout we are using the cont
aining block's writing mode rather than our own when calculating margins. |
| 2936 // See http://www.w3.org/TR/2014/CR-css-writing-modes-3-20140320/#orthogonal
-flows |
2985 containingBlock->setMarginBeforeForChild(this, marginBefore); | 2937 containingBlock->setMarginBeforeForChild(this, marginBefore); |
2986 containingBlock->setMarginAfterForChild(this, marginAfter); | 2938 containingBlock->setMarginAfterForChild(this, marginAfter); |
2987 } | 2939 } |
2988 | 2940 |
2989 LayoutUnit RenderBox::containingBlockLogicalWidthForPositioned(const RenderBoxMo
delObject* containingBlock, bool checkForPerpendicularWritingMode) const | 2941 LayoutUnit RenderBox::containingBlockLogicalWidthForPositioned(const RenderBoxMo
delObject* containingBlock, bool checkForPerpendicularWritingMode) const |
2990 { | 2942 { |
2991 if (checkForPerpendicularWritingMode && containingBlock->isHorizontalWriting
Mode() != isHorizontalWritingMode()) | 2943 if (checkForPerpendicularWritingMode && containingBlock->isHorizontalWriting
Mode() != isHorizontalWritingMode()) |
2992 return containingBlockLogicalHeightForPositioned(containingBlock, false)
; | 2944 return containingBlockLogicalHeightForPositioned(containingBlock, false)
; |
2993 | 2945 |
2994 // Use viewport as container for top-level fixed-position elements. | 2946 // Use viewport as container for top-level fixed-position elements. |
(...skipping 1700 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4695 return 0; | 4647 return 0; |
4696 | 4648 |
4697 if (!layoutState && !flowThreadContainingBlock()) | 4649 if (!layoutState && !flowThreadContainingBlock()) |
4698 return 0; | 4650 return 0; |
4699 | 4651 |
4700 RenderBlock* containerBlock = containingBlock(); | 4652 RenderBlock* containerBlock = containingBlock(); |
4701 return containerBlock->offsetFromLogicalTopOfFirstPage() + logicalTop(); | 4653 return containerBlock->offsetFromLogicalTopOfFirstPage() + logicalTop(); |
4702 } | 4654 } |
4703 | 4655 |
4704 } // namespace WebCore | 4656 } // namespace WebCore |
OLD | NEW |