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

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

Issue 287193013: Revert of Strip anonymous blocks when change in style removes need for them (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 7 months 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/rendering/RenderBox.h ('k') | Source/core/rendering/RenderTable.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 2195 matching lines...) Expand 10 before | Expand all | Expand 10 after
2206 computedValues.m_extent = logicalWidthLength.value() + borderAndPaddingL ogicalWidth(); 2206 computedValues.m_extent = logicalWidthLength.value() + borderAndPaddingL ogicalWidth();
2207 else { 2207 else {
2208 LayoutUnit containerWidthInInlineDirection = containerLogicalWidth; 2208 LayoutUnit containerWidthInInlineDirection = containerLogicalWidth;
2209 if (hasPerpendicularContainingBlock) 2209 if (hasPerpendicularContainingBlock)
2210 containerWidthInInlineDirection = perpendicularContainingBlockLogica lHeight(); 2210 containerWidthInInlineDirection = perpendicularContainingBlockLogica lHeight();
2211 LayoutUnit preferredWidth = computeLogicalWidthUsing(MainOrPreferredSize , styleToUse->logicalWidth(), containerWidthInInlineDirection, cb); 2211 LayoutUnit preferredWidth = computeLogicalWidthUsing(MainOrPreferredSize , styleToUse->logicalWidth(), containerWidthInInlineDirection, cb);
2212 computedValues.m_extent = constrainLogicalWidthByMinMax(preferredWidth, containerWidthInInlineDirection, cb); 2212 computedValues.m_extent = constrainLogicalWidthByMinMax(preferredWidth, containerWidthInInlineDirection, cb);
2213 } 2213 }
2214 2214
2215 // Margin calculations. 2215 // Margin calculations.
2216 computeMarginsForDirection(InlineDirection, cb, containerLogicalWidth, compu tedValues.m_extent, computedValues.m_margins.m_start, 2216 if (hasPerpendicularContainingBlock || isFloating() || isInline()) {
2217 computedValues.m_margins.m_end, style()->marginStart(), style()->marginE nd()); 2217 computedValues.m_margins.m_start = minimumValueForLength(styleToUse->mar ginStart(), containerLogicalWidth);
2218 computedValues.m_margins.m_end = minimumValueForLength(styleToUse->margi nEnd(), containerLogicalWidth);
2219 } else {
2220 bool hasInvertedDirection = cb->style()->isLeftToRightDirection() != sty le()->isLeftToRightDirection();
2221 computeInlineDirectionMargins(cb, containerLogicalWidth, computedValues. m_extent,
2222 hasInvertedDirection ? computedValues.m_margins.m_end : computedValu es.m_margins.m_start,
2223 hasInvertedDirection ? computedValues.m_margins.m_start : computedVa lues.m_margins.m_end);
2224 }
2218 2225
2219 if (!hasPerpendicularContainingBlock && containerLogicalWidth && containerLo gicalWidth != (computedValues.m_extent + computedValues.m_margins.m_start + comp utedValues.m_margins.m_end) 2226 if (!hasPerpendicularContainingBlock && containerLogicalWidth && containerLo gicalWidth != (computedValues.m_extent + computedValues.m_margins.m_start + comp utedValues.m_margins.m_end)
2220 && !isFloating() && !isInline() && !cb->isFlexibleBoxIncludingDeprecated () && !cb->isRenderGrid()) { 2227 && !isFloating() && !isInline() && !cb->isFlexibleBoxIncludingDeprecated () && !cb->isRenderGrid()) {
2221 LayoutUnit newMargin = containerLogicalWidth - computedValues.m_extent - cb->marginStartForChild(this); 2228 LayoutUnit newMargin = containerLogicalWidth - computedValues.m_extent - cb->marginStartForChild(this);
2222 bool hasInvertedDirection = cb->style()->isLeftToRightDirection() != sty le()->isLeftToRightDirection(); 2229 bool hasInvertedDirection = cb->style()->isLeftToRightDirection() != sty le()->isLeftToRightDirection();
2223 if (hasInvertedDirection) 2230 if (hasInvertedDirection)
2224 computedValues.m_margins.m_start = newMargin; 2231 computedValues.m_margins.m_start = newMargin;
2225 else 2232 else
2226 computedValues.m_margins.m_end = newMargin; 2233 computedValues.m_margins.m_end = newMargin;
2227 } 2234 }
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
2375 2382
2376 return false; 2383 return false;
2377 } 2384 }
2378 2385
2379 bool RenderBox::autoWidthShouldFitContent() const 2386 bool RenderBox::autoWidthShouldFitContent() const
2380 { 2387 {
2381 return node() && (isHTMLInputElement(*node()) || isHTMLSelectElement(*node() ) || isHTMLButtonElement(*node()) 2388 return node() && (isHTMLInputElement(*node()) || isHTMLSelectElement(*node() ) || isHTMLButtonElement(*node())
2382 || isHTMLTextAreaElement(*node()) || (isHTMLLegendElement(*node()) && !s tyle()->hasOutOfFlowPosition())); 2389 || isHTMLTextAreaElement(*node()) || (isHTMLLegendElement(*node()) && !s tyle()->hasOutOfFlowPosition()));
2383 } 2390 }
2384 2391
2385 void RenderBox::computeMarginsForDirection(MarginDirection forDirection, const R enderBlock* containingBlock, LayoutUnit containerWidth, LayoutUnit childWidth, L ayoutUnit& marginStart, LayoutUnit& marginEnd, Length marginStartLength, Length marginEndLength) const 2392 void RenderBox::computeInlineDirectionMargins(RenderBlock* containingBlock, Layo utUnit containerWidth, LayoutUnit childWidth, LayoutUnit& marginStart, LayoutUni t& marginEnd) const
2386 { 2393 {
2387 if (forDirection == BlockDirection || isFloating() || isInline()) { 2394 const RenderStyle* containingBlockStyle = containingBlock->style();
2388 if (isTableCell() && forDirection == BlockDirection) { 2395 Length marginStartLength = style()->marginStartUsing(containingBlockStyle);
2389 // FIXME: Not right if we allow cells to have different directionali ty than the table. If we do allow this, though, 2396 Length marginEndLength = style()->marginEndUsing(containingBlockStyle);
2390 // we may just do it with an extra anonymous block inside the cell.
2391 marginStart = 0;
2392 marginEnd = 0;
2393 return;
2394 }
2395 2397
2396 // Margins are calculated with respect to the logical width of 2398 if (isFloating() || isInline()) {
2397 // the containing block (8.3)
2398 // Inline blocks/tables and floats don't have their margins increased. 2399 // Inline blocks/tables and floats don't have their margins increased.
2399 marginStart = minimumValueForLength(marginStartLength, containerWidth); 2400 marginStart = minimumValueForLength(marginStartLength, containerWidth);
2400 marginEnd = minimumValueForLength(marginEndLength, containerWidth); 2401 marginEnd = minimumValueForLength(marginEndLength, containerWidth);
2401 return; 2402 return;
2402 } 2403 }
2403 2404
2404 if (containingBlock->isFlexibleBox()) { 2405 if (containingBlock->isFlexibleBox()) {
2405 // We need to let flexbox handle the margin adjustment - otherwise, flex box 2406 // We need to let flexbox handle the margin adjustment - otherwise, flex box
2406 // will think we're wider than we actually are and calculate line sizes wrong. 2407 // will think we're wider than we actually are and calculate line sizes wrong.
2407 // See also http://dev.w3.org/csswg/css-flexbox/#auto-margins 2408 // See also http://dev.w3.org/csswg/css-flexbox/#auto-margins
(...skipping 15 matching lines...) Expand all
2423 } 2424 }
2424 } 2425 }
2425 2426
2426 // CSS 2.1 (10.3.3): "If 'width' is not 'auto' and 'border-left-width' + 'pa dding-left' + 'width' + 'padding-right' + 'border-right-width' 2427 // CSS 2.1 (10.3.3): "If 'width' is not 'auto' and 'border-left-width' + 'pa dding-left' + 'width' + 'padding-right' + 'border-right-width'
2427 // (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' 2428 // (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'
2428 // values for 'margin-left' or 'margin-right' are, for the following rules, treated as zero. 2429 // values for 'margin-left' or 'margin-right' are, for the following rules, treated as zero.
2429 LayoutUnit marginBoxWidth = childWidth + (!style()->width().isAuto() ? margi nStartWidth + marginEndWidth : LayoutUnit()); 2430 LayoutUnit marginBoxWidth = childWidth + (!style()->width().isAuto() ? margi nStartWidth + marginEndWidth : LayoutUnit());
2430 2431
2431 // CSS 2.1: "If both 'margin-left' and 'margin-right' are 'auto', their used values are equal. This horizontally centers the element 2432 // CSS 2.1: "If both 'margin-left' and 'margin-right' are 'auto', their used values are equal. This horizontally centers the element
2432 // with respect to the edges of the containing block." 2433 // with respect to the edges of the containing block."
2433 const RenderStyle* containingBlockStyle = containingBlock->style();
2434 if ((marginStartLength.isAuto() && marginEndLength.isAuto() && marginBoxWidt h < availableWidth) 2434 if ((marginStartLength.isAuto() && marginEndLength.isAuto() && marginBoxWidt h < availableWidth)
2435 || (!marginStartLength.isAuto() && !marginEndLength.isAuto() && containi ngBlockStyle->textAlign() == WEBKIT_CENTER)) { 2435 || (!marginStartLength.isAuto() && !marginEndLength.isAuto() && containi ngBlock->style()->textAlign() == WEBKIT_CENTER)) {
2436 // Other browsers center the margin box for align=center elements so we match them here. 2436 // Other browsers center the margin box for align=center elements so we match them here.
2437 LayoutUnit centeredMarginBoxStart = max<LayoutUnit>(0, (availableWidth - childWidth - marginStartWidth - marginEndWidth) / 2); 2437 LayoutUnit centeredMarginBoxStart = max<LayoutUnit>(0, (availableWidth - childWidth - marginStartWidth - marginEndWidth) / 2);
2438 marginStart = centeredMarginBoxStart + marginStartWidth; 2438 marginStart = centeredMarginBoxStart + marginStartWidth;
2439 marginEnd = availableWidth - childWidth - marginStart + marginEndWidth; 2439 marginEnd = availableWidth - childWidth - marginStart + marginEndWidth;
2440 return; 2440 return;
2441 } 2441 }
2442 2442
2443 // CSS 2.1: "If there is exactly one value specified as 'auto', its used val ue follows from the equality." 2443 // CSS 2.1: "If there is exactly one value specified as 'auto', its used val ue follows from the equality."
2444 if (marginEndLength.isAuto() && marginBoxWidth < availableWidth) { 2444 if (marginEndLength.isAuto() && marginBoxWidth < availableWidth) {
2445 marginStart = marginStartWidth; 2445 marginStart = marginStartWidth;
2446 marginEnd = availableWidth - childWidth - marginStart; 2446 marginEnd = availableWidth - childWidth - marginStart;
2447 return; 2447 return;
2448 } 2448 }
2449 2449
2450 bool pushToEndFromTextAlign = !marginEndLength.isAuto() && ((!containingBloc kStyle->isLeftToRightDirection() && containingBlockStyle->textAlign() == WEBKIT_ LEFT) 2450 bool pushToEndFromTextAlign = !marginEndLength.isAuto() && ((!containingBloc kStyle->isLeftToRightDirection() && containingBlockStyle->textAlign() == WEBKIT_ LEFT)
2451 || (containingBlockStyle->isLeftToRightDirection() && containingBlockSty le->textAlign() == WEBKIT_RIGHT)); 2451 || (containingBlockStyle->isLeftToRightDirection() && containingBlockSty le->textAlign() == WEBKIT_RIGHT));
2452 if ((marginStartLength.isAuto() && marginBoxWidth < availableWidth) || pushT oEndFromTextAlign) { 2452 if ((marginStartLength.isAuto() && marginBoxWidth < availableWidth) || pushT oEndFromTextAlign) {
2453 marginEnd = marginEndWidth; 2453 marginEnd = marginEndWidth;
2454 marginStart = availableWidth - childWidth - marginEnd; 2454 marginStart = availableWidth - childWidth - marginEnd;
2455 return; 2455 return;
2456 } 2456 }
2457 2457
2458 // Either no auto margins, or our margin box width is >= the container width , auto margins will just turn into 0. 2458 // Either no auto margins, or our margin box width is >= the container width , auto margins will just turn into 0.
2459 marginStart = marginStartWidth; 2459 marginStart = marginStartWidth;
2460 marginEnd = marginEndWidth; 2460 marginEnd = marginEndWidth;
2461 } 2461 }
2462 2462
2463 static bool shouldFlipBeforeAfterMargins(const RenderStyle* containingBlockStyle , const RenderStyle* childStyle)
2464 {
2465 ASSERT(containingBlockStyle->isHorizontalWritingMode() != childStyle->isHori zontalWritingMode());
2466 WritingMode childWritingMode = childStyle->writingMode();
2467 bool shouldFlip = false;
2468 switch (containingBlockStyle->writingMode()) {
2469 case TopToBottomWritingMode:
2470 shouldFlip = (childWritingMode == RightToLeftWritingMode);
2471 break;
2472 case BottomToTopWritingMode:
2473 shouldFlip = (childWritingMode == RightToLeftWritingMode);
2474 break;
2475 case RightToLeftWritingMode:
2476 shouldFlip = (childWritingMode == BottomToTopWritingMode);
2477 break;
2478 case LeftToRightWritingMode:
2479 shouldFlip = (childWritingMode == BottomToTopWritingMode);
2480 break;
2481 }
2482
2483 if (!containingBlockStyle->isLeftToRightDirection())
2484 shouldFlip = !shouldFlip;
2485
2486 return shouldFlip;
2487 }
2488
2463 void RenderBox::updateLogicalHeight() 2489 void RenderBox::updateLogicalHeight()
2464 { 2490 {
2465 m_intrinsicContentLogicalHeight = contentLogicalHeight(); 2491 m_intrinsicContentLogicalHeight = contentLogicalHeight();
2466 2492
2467 LogicalExtentComputedValues computedValues; 2493 LogicalExtentComputedValues computedValues;
2468 computeLogicalHeight(logicalHeight(), logicalTop(), computedValues); 2494 computeLogicalHeight(logicalHeight(), logicalTop(), computedValues);
2469 2495
2470 setLogicalHeight(computedValues.m_extent); 2496 setLogicalHeight(computedValues.m_extent);
2471 setLogicalTop(computedValues.m_position); 2497 setLogicalTop(computedValues.m_position);
2472 setMarginBefore(computedValues.m_margins.m_before); 2498 setMarginBefore(computedValues.m_margins.m_before);
2473 setMarginAfter(computedValues.m_margins.m_after); 2499 setMarginAfter(computedValues.m_margins.m_after);
2474 } 2500 }
2475 2501
2476 void RenderBox::computeLogicalHeight(LayoutUnit logicalHeight, LayoutUnit logica lTop, LogicalExtentComputedValues& computedValues) const 2502 void RenderBox::computeLogicalHeight(LayoutUnit logicalHeight, LayoutUnit logica lTop, LogicalExtentComputedValues& computedValues) const
2477 { 2503 {
2478 computedValues.m_extent = logicalHeight; 2504 computedValues.m_extent = logicalHeight;
2479 computedValues.m_position = logicalTop; 2505 computedValues.m_position = logicalTop;
2480 2506
2481 // Cell height is managed by the table and inline non-replaced elements do n ot support a height property. 2507 // Cell height is managed by the table and inline non-replaced elements do n ot support a height property.
2482 if (isTableCell() || (isInline() && !isReplaced())) 2508 if (isTableCell() || (isInline() && !isReplaced()))
2483 return; 2509 return;
2484 2510
2485 Length h; 2511 Length h;
2486 if (isOutOfFlowPositioned()) 2512 if (isOutOfFlowPositioned())
2487 computePositionedLogicalHeight(computedValues); 2513 computePositionedLogicalHeight(computedValues);
2488 else { 2514 else {
2489 RenderBlock* cb = containingBlock(); 2515 RenderBlock* cb = containingBlock();
2516 bool hasPerpendicularContainingBlock = cb->isHorizontalWritingMode() != isHorizontalWritingMode();
2517
2518 if (!hasPerpendicularContainingBlock) {
2519 bool shouldFlipBeforeAfter = cb->style()->writingMode() != style()-> writingMode();
2520 computeBlockDirectionMargins(cb,
2521 shouldFlipBeforeAfter ? computedValues.m_margins.m_after : compu tedValues.m_margins.m_before,
2522 shouldFlipBeforeAfter ? computedValues.m_margins.m_before : comp utedValues.m_margins.m_after);
2523 }
2490 2524
2491 // For tables, calculate margins only. 2525 // For tables, calculate margins only.
2492 if (isTable()) { 2526 if (isTable()) {
2493 computeMarginsForDirection(BlockDirection, cb, containingBlockLogica lWidthForContent(), computedValues.m_extent, computedValues.m_margins.m_before, 2527 if (hasPerpendicularContainingBlock) {
2494 computedValues.m_margins.m_after, style()->marginBefore(), style ()->marginAfter()); 2528 bool shouldFlipBeforeAfter = shouldFlipBeforeAfterMargins(cb->st yle(), style());
2529 computeInlineDirectionMargins(cb, containingBlockLogicalWidthFor Content(), computedValues.m_extent,
2530 shouldFlipBeforeAfter ? computedValues.m_margins.m_after : c omputedValues.m_margins.m_before,
2531 shouldFlipBeforeAfter ? computedValues.m_margins.m_before : computedValues.m_margins.m_after);
2532 }
2495 return; 2533 return;
2496 } 2534 }
2497 2535
2498 // FIXME: Account for block-flow in flexible boxes. 2536 // FIXME: Account for block-flow in flexible boxes.
2499 // https://bugs.webkit.org/show_bug.cgi?id=46418 2537 // https://bugs.webkit.org/show_bug.cgi?id=46418
2500 bool inHorizontalBox = parent()->isDeprecatedFlexibleBox() && parent()-> style()->boxOrient() == HORIZONTAL; 2538 bool inHorizontalBox = parent()->isDeprecatedFlexibleBox() && parent()-> style()->boxOrient() == HORIZONTAL;
2501 bool stretching = parent()->style()->boxAlign() == BSTRETCH; 2539 bool stretching = parent()->style()->boxAlign() == BSTRETCH;
2502 bool treatAsReplaced = shouldComputeSizeAsReplaced() && (!inHorizontalBo x || !stretching); 2540 bool treatAsReplaced = shouldComputeSizeAsReplaced() && (!inHorizontalBo x || !stretching);
2503 bool checkMinMaxHeight = false; 2541 bool checkMinMaxHeight = false;
2504 2542
(...skipping 26 matching lines...) Expand all
2531 heightResult = constrainLogicalHeightByMinMax(heightResult, computed Values.m_extent - borderAndPaddingLogicalHeight()); 2569 heightResult = constrainLogicalHeightByMinMax(heightResult, computed Values.m_extent - borderAndPaddingLogicalHeight());
2532 } else { 2570 } else {
2533 // The only times we don't check min/max height are when a fixed len gth has 2571 // The only times we don't check min/max height are when a fixed len gth has
2534 // been given as an override. Just use that. The value has already been adjusted 2572 // been given as an override. Just use that. The value has already been adjusted
2535 // for box-sizing. 2573 // for box-sizing.
2536 ASSERT(h.isFixed()); 2574 ASSERT(h.isFixed());
2537 heightResult = h.value() + borderAndPaddingLogicalHeight(); 2575 heightResult = h.value() + borderAndPaddingLogicalHeight();
2538 } 2576 }
2539 2577
2540 computedValues.m_extent = heightResult; 2578 computedValues.m_extent = heightResult;
2541 // 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 2579
2542 // 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. 2580 if (hasPerpendicularContainingBlock) {
2543 // Note that in this 'sizing phase' we are using our own writing mode ra ther than the containing block's. 2581 bool shouldFlipBeforeAfter = shouldFlipBeforeAfterMargins(cb->style( ), style());
2544 // See http://www.w3.org/TR/2014/CR-css-writing-modes-3-20140320/#orthog onal-flows 2582 computeInlineDirectionMargins(cb, containingBlockLogicalWidthForCont ent(), heightResult,
2545 MarginDirection forDirection = isHorizontalWritingMode() != cb->isHorizo ntalWritingMode() ? InlineDirection : BlockDirection; 2583 shouldFlipBeforeAfter ? computedValues.m_margins.m_after : compu tedValues.m_margins.m_before,
2546 computeMarginsForDirection(forDirection, cb, containingBlockLogicalWidth ForContent(), computedValues.m_extent, computedValues.m_margins.m_before, 2584 shouldFlipBeforeAfter ? computedValues.m_margins.m_before : comp utedValues.m_margins.m_after);
2547 computedValues.m_margins.m_after, style()->marginBefore(), style()-> marginAfter()); 2585 }
2548 } 2586 }
2549 2587
2550 // WinIE quirk: The <html> block always fills the entire canvas in quirks mo de. The <body> always fills the 2588 // WinIE quirk: The <html> block always fills the entire canvas in quirks mo de. The <body> always fills the
2551 // <html> block in quirks mode. Only apply this quirk if the block is norma l flow and no height 2589 // <html> block in quirks mode. Only apply this quirk if the block is norma l flow and no height
2552 // is specified. When we're printing, we also need this quirk if the body or root has a percentage 2590 // is specified. When we're printing, we also need this quirk if the body or root has a percentage
2553 // height since we don't set a height in RenderView when we're printing. So without this quirk, the 2591 // height since we don't set a height in RenderView when we're printing. So without this quirk, the
2554 // height has nothing to be a percentage of, and it ends up being 0. That is bad. 2592 // height has nothing to be a percentage of, and it ends up being 0. That is bad.
2555 bool paginatedContentNeedsBaseHeight = document().printing() && h.isPercent( ) 2593 bool paginatedContentNeedsBaseHeight = document().printing() && h.isPercent( )
2556 && (isDocumentElement() || (isBody() && document().documentElement()->re nderer()->style()->logicalHeight().isPercent())) && !isInline(); 2594 && (isDocumentElement() || (isBody() && document().documentElement()->re nderer()->style()->logicalHeight().isPercent())) && !isInline();
2557 if (stretchesToViewport() || paginatedContentNeedsBaseHeight) { 2595 if (stretchesToViewport() || paginatedContentNeedsBaseHeight) {
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after
2890 2928
2891 // FIXME: This is wrong if the containingBlock has a perpendicular writing m ode. 2929 // FIXME: This is wrong if the containingBlock has a perpendicular writing m ode.
2892 LayoutUnit availableHeight = containingBlockLogicalHeightForContent(heightTy pe); 2930 LayoutUnit availableHeight = containingBlockLogicalHeightForContent(heightTy pe);
2893 if (heightType == ExcludeMarginBorderPadding) { 2931 if (heightType == ExcludeMarginBorderPadding) {
2894 // FIXME: Margin collapsing hasn't happened yet, so this incorrectly rem oves collapsed margins. 2932 // FIXME: Margin collapsing hasn't happened yet, so this incorrectly rem oves collapsed margins.
2895 availableHeight -= marginBefore() + marginAfter() + borderAndPaddingLogi calHeight(); 2933 availableHeight -= marginBefore() + marginAfter() + borderAndPaddingLogi calHeight();
2896 } 2934 }
2897 return availableHeight; 2935 return availableHeight;
2898 } 2936 }
2899 2937
2938 void RenderBox::computeBlockDirectionMargins(const RenderBlock* containingBlock, LayoutUnit& marginBefore, LayoutUnit& marginAfter) const
2939 {
2940 if (isTableCell()) {
2941 // FIXME: Not right if we allow cells to have different directionality t han the table. If we do allow this, though,
2942 // we may just do it with an extra anonymous block inside the cell.
2943 marginBefore = 0;
2944 marginAfter = 0;
2945 return;
2946 }
2947
2948 // Margins are calculated with respect to the logical width of
2949 // the containing block (8.3)
2950 LayoutUnit cw = containingBlockLogicalWidthForContent();
2951 RenderStyle* containingBlockStyle = containingBlock->style();
2952 marginBefore = minimumValueForLength(style()->marginBeforeUsing(containingBl ockStyle), cw);
2953 marginAfter = minimumValueForLength(style()->marginAfterUsing(containingBloc kStyle), cw);
2954 }
2955
2900 void RenderBox::computeAndSetBlockDirectionMargins(const RenderBlock* containing Block) 2956 void RenderBox::computeAndSetBlockDirectionMargins(const RenderBlock* containing Block)
2901 { 2957 {
2902 LayoutUnit marginBefore; 2958 LayoutUnit marginBefore;
2903 LayoutUnit marginAfter; 2959 LayoutUnit marginAfter;
2904 computeMarginsForDirection(BlockDirection, containingBlock, containingBlockL ogicalWidthForContent(), logicalHeight(), marginBefore, marginAfter, 2960 computeBlockDirectionMargins(containingBlock, marginBefore, marginAfter);
2905 style()->marginBeforeUsing(containingBlock->style()),
2906 style()->marginAfterUsing(containingBlock->style()));
2907 // 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.
2908 // See http://www.w3.org/TR/2014/CR-css-writing-modes-3-20140320/#orthogonal -flows
2909 containingBlock->setMarginBeforeForChild(this, marginBefore); 2961 containingBlock->setMarginBeforeForChild(this, marginBefore);
2910 containingBlock->setMarginAfterForChild(this, marginAfter); 2962 containingBlock->setMarginAfterForChild(this, marginAfter);
2911 } 2963 }
2912 2964
2913 LayoutUnit RenderBox::containingBlockLogicalWidthForPositioned(const RenderBoxMo delObject* containingBlock, bool checkForPerpendicularWritingMode) const 2965 LayoutUnit RenderBox::containingBlockLogicalWidthForPositioned(const RenderBoxMo delObject* containingBlock, bool checkForPerpendicularWritingMode) const
2914 { 2966 {
2915 if (checkForPerpendicularWritingMode && containingBlock->isHorizontalWriting Mode() != isHorizontalWritingMode()) 2967 if (checkForPerpendicularWritingMode && containingBlock->isHorizontalWriting Mode() != isHorizontalWritingMode())
2916 return containingBlockLogicalHeightForPositioned(containingBlock, false) ; 2968 return containingBlockLogicalHeightForPositioned(containingBlock, false) ;
2917 2969
2918 // Use viewport as container for top-level fixed-position elements. 2970 // Use viewport as container for top-level fixed-position elements.
(...skipping 1712 matching lines...) Expand 10 before | Expand all | Expand 10 after
4631 return 0; 4683 return 0;
4632 4684
4633 if (!layoutState && !flowThreadContainingBlock()) 4685 if (!layoutState && !flowThreadContainingBlock())
4634 return 0; 4686 return 0;
4635 4687
4636 RenderBlock* containerBlock = containingBlock(); 4688 RenderBlock* containerBlock = containingBlock();
4637 return containerBlock->offsetFromLogicalTopOfFirstPage() + logicalTop(); 4689 return containerBlock->offsetFromLogicalTopOfFirstPage() + logicalTop();
4638 } 4690 }
4639 4691
4640 } // namespace WebCore 4692 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/rendering/RenderBox.h ('k') | Source/core/rendering/RenderTable.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698