Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 412 updateAfterLayout(); | 412 updateAfterLayout(); |
| 413 | 413 |
| 414 if (isHTMLDialogElement(node()) && isOutOfFlowPositioned()) | 414 if (isHTMLDialogElement(node()) && isOutOfFlowPositioned()) |
| 415 positionDialog(); | 415 positionDialog(); |
| 416 | 416 |
| 417 clearNeedsLayout(); | 417 clearNeedsLayout(); |
| 418 updateIsSelfCollapsing(); | 418 updateIsSelfCollapsing(); |
| 419 } | 419 } |
| 420 | 420 |
| 421 DISABLE_CFI_PERF | 421 DISABLE_CFI_PERF |
| 422 inline bool LayoutBlockFlow::layoutBlockFlow(bool relayoutChildren, | 422 void LayoutBlockFlow::resetLayout() { |
| 423 SubtreeLayoutScope& layoutScope) { | 423 if (!firstChild() && !isAnonymousBlock()) |
| 424 LayoutUnit oldLeft = logicalLeft(); | 424 setChildrenInline(true); |
| 425 bool logicalWidthChanged = updateLogicalWidthAndColumnWidth(); | 425 setContainsInlineWithOutlineAndContinuation(false); |
| 426 relayoutChildren |= logicalWidthChanged; | |
| 427 | 426 |
| 428 rebuildFloatsFromIntruding(); | 427 rebuildFloatsFromIntruding(); |
| 429 | 428 |
| 430 LayoutState state(*this, logicalWidthChanged); | |
| 431 | |
| 432 if (m_paginationStateChanged) { | |
| 433 // We now need a deep layout to clean up struts after pagination, if we | |
| 434 // just ceased to be paginated, or, if we just became paginated on the | |
| 435 // other hand, we now need the deep layout, to insert pagination struts. | |
| 436 m_paginationStateChanged = false; | |
| 437 state.setPaginationStateChanged(); | |
| 438 } | |
| 439 | |
| 440 // We use four values, maxTopPos, maxTopNeg, maxBottomPos, and maxBottomNeg, | 429 // We use four values, maxTopPos, maxTopNeg, maxBottomPos, and maxBottomNeg, |
| 441 // to track our current maximal positive and negative margins. These values | 430 // to track our current maximal positive and negative margins. These values |
| 442 // are used when we are collapsed with adjacent blocks, so for example, if you | 431 // are used when we are collapsed with adjacent blocks, so for example, if you |
| 443 // have block A and B collapsing together, then you'd take the maximal | 432 // have block A and B collapsing together, then you'd take the maximal |
| 444 // positive margin from both A and B and subtract it from the maximal negative | 433 // positive margin from both A and B and subtract it from the maximal negative |
| 445 // margin from both A and B to get the true collapsed margin. This algorithm | 434 // margin from both A and B to get the true collapsed margin. This algorithm |
| 446 // is recursive, so when we finish layout() our block knows its current | 435 // is recursive, so when we finish layout() our block knows its current |
| 447 // maximal positive/negative values. | 436 // maximal positive/negative values. |
| 448 // | 437 // |
| 449 // Start out by setting our margin values to our current margins. Table cells | 438 // Start out by setting our margin values to our current margins. Table cells |
| 450 // have no margins, so we don't fill in the values for table cells. | 439 // have no margins, so we don't fill in the values for table cells. |
| 451 if (!isTableCell()) { | 440 if (!isTableCell()) { |
| 452 initMaxMarginValues(); | 441 initMaxMarginValues(); |
| 453 setHasMarginBeforeQuirk(style()->hasMarginBeforeQuirk()); | 442 setHasMarginBeforeQuirk(style()->hasMarginBeforeQuirk()); |
| 454 setHasMarginAfterQuirk(style()->hasMarginAfterQuirk()); | 443 setHasMarginAfterQuirk(style()->hasMarginAfterQuirk()); |
| 455 } | 444 } |
| 456 | 445 |
| 457 if (state.isPaginated()) { | 446 if (view()->layoutState()->isPaginated()) { |
| 458 setPaginationStrutPropagatedFromChild(LayoutUnit()); | 447 setPaginationStrutPropagatedFromChild(LayoutUnit()); |
| 459 setFirstForcedBreakOffset(LayoutUnit()); | 448 setFirstForcedBreakOffset(LayoutUnit()); |
| 460 | 449 |
| 461 // Start with any applicable computed break-after and break-before values | 450 // Start with any applicable computed break-after and break-before values |
| 462 // for this object. During child layout, breakBefore will be joined with the | 451 // for this object. During child layout, breakBefore will be joined with the |
| 463 // breakBefore value of the first in-flow child, and breakAfter will be | 452 // breakBefore value of the first in-flow child, and breakAfter will be |
| 464 // joined with the breakAfter value of the last in-flow child. This is done | 453 // joined with the breakAfter value of the last in-flow child. This is done |
| 465 // in order to honor the requirement that a class A break point [1] may only | 454 // in order to honor the requirement that a class A break point [1] may only |
| 466 // exists *between* in-flow siblings (i.e. not before the first child and | 455 // exists *between* in-flow siblings (i.e. not before the first child and |
| 467 // not after the last child). | 456 // not after the last child). |
| 468 // | 457 // |
| 469 // [1] https://drafts.csswg.org/css-break/#possible-breaks | 458 // [1] https://drafts.csswg.org/css-break/#possible-breaks |
| 470 setBreakBefore(LayoutBlock::breakBefore()); | 459 setBreakBefore(LayoutBlock::breakBefore()); |
| 471 setBreakAfter(LayoutBlock::breakAfter()); | 460 setBreakAfter(LayoutBlock::breakAfter()); |
| 472 } | 461 } |
| 462 } | |
| 463 | |
| 464 DISABLE_CFI_PERF | |
| 465 inline bool LayoutBlockFlow::layoutBlockFlow(bool relayoutChildren, | |
| 466 SubtreeLayoutScope& layoutScope) { | |
| 467 LayoutUnit oldLeft = logicalLeft(); | |
| 468 bool logicalWidthChanged = updateLogicalWidthAndColumnWidth(); | |
| 469 relayoutChildren |= logicalWidthChanged; | |
| 470 | |
| 471 LayoutState state(*this, logicalWidthChanged); | |
| 472 | |
| 473 if (m_paginationStateChanged) { | |
|
szager1
2016/11/30 20:33:28
Should this be inside resetLayout? Maybe pass a L
mstensho (USE GERRIT)
2016/11/30 20:47:58
This is something that ideally should only be done
| |
| 474 // We now need a deep layout to clean up struts after pagination, if we | |
| 475 // just ceased to be paginated, or, if we just became paginated on the | |
| 476 // other hand, we now need the deep layout, to insert pagination struts. | |
| 477 m_paginationStateChanged = false; | |
| 478 state.setPaginationStateChanged(); | |
| 479 } | |
| 480 | |
| 481 LayoutUnit previousHeight = logicalHeight(); | |
| 482 resetLayout(); | |
| 473 | 483 |
| 474 LayoutUnit beforeEdge = borderBefore() + paddingBefore(); | 484 LayoutUnit beforeEdge = borderBefore() + paddingBefore(); |
| 475 LayoutUnit afterEdge = | 485 LayoutUnit afterEdge = |
| 476 borderAfter() + paddingAfter() + scrollbarLogicalHeight(); | 486 borderAfter() + paddingAfter() + scrollbarLogicalHeight(); |
| 477 LayoutUnit previousHeight = logicalHeight(); | |
| 478 setLogicalHeight(beforeEdge); | 487 setLogicalHeight(beforeEdge); |
| 479 | 488 |
| 480 if (!firstChild() && !isAnonymousBlock()) | |
| 481 setChildrenInline(true); | |
| 482 | |
| 483 TextAutosizer::LayoutScope textAutosizerLayoutScope(this, &layoutScope); | 489 TextAutosizer::LayoutScope textAutosizerLayoutScope(this, &layoutScope); |
| 484 | 490 |
| 485 bool preferredLogicalWidthsWereDirty = preferredLogicalWidthsDirty(); | 491 bool preferredLogicalWidthsWereDirty = preferredLogicalWidthsDirty(); |
| 486 | 492 |
| 487 // Reset the flag here instead of in layoutInlineChildren() in case that | |
| 488 // all inline children are removed from this block. | |
| 489 setContainsInlineWithOutlineAndContinuation(false); | |
| 490 if (childrenInline()) | 493 if (childrenInline()) |
| 491 layoutInlineChildren(relayoutChildren, afterEdge); | 494 layoutInlineChildren(relayoutChildren, afterEdge); |
| 492 else | 495 else |
| 493 layoutBlockChildren(relayoutChildren, layoutScope, beforeEdge, afterEdge); | 496 layoutBlockChildren(relayoutChildren, layoutScope, beforeEdge, afterEdge); |
| 494 | 497 |
| 495 bool preferredLogicalWidthsBecameDirty = | 498 bool preferredLogicalWidthsBecameDirty = |
| 496 !preferredLogicalWidthsWereDirty && preferredLogicalWidthsDirty(); | 499 !preferredLogicalWidthsWereDirty && preferredLogicalWidthsDirty(); |
| 497 if (preferredLogicalWidthsBecameDirty) { | 500 if (preferredLogicalWidthsBecameDirty) { |
| 498 // The only thing that should dirty preferred widths at this point is the | 501 // The only thing that should dirty preferred widths at this point is the |
| 499 // addition of overflow:auto scrollbars in a descendant. To avoid a | 502 // addition of overflow:auto scrollbars in a descendant. To avoid a |
| (...skipping 4031 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4531 return LayoutBlock::invalidatePaintIfNeeded(paintInvalidationState); | 4534 return LayoutBlock::invalidatePaintIfNeeded(paintInvalidationState); |
| 4532 } | 4535 } |
| 4533 | 4536 |
| 4534 void LayoutBlockFlow::invalidateDisplayItemClients( | 4537 void LayoutBlockFlow::invalidateDisplayItemClients( |
| 4535 PaintInvalidationReason invalidationReason) const { | 4538 PaintInvalidationReason invalidationReason) const { |
| 4536 BlockFlowPaintInvalidator(*this).invalidateDisplayItemClients( | 4539 BlockFlowPaintInvalidator(*this).invalidateDisplayItemClients( |
| 4537 invalidationReason); | 4540 invalidationReason); |
| 4538 } | 4541 } |
| 4539 | 4542 |
| 4540 } // namespace blink | 4543 } // namespace blink |
| OLD | NEW |