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 2468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2479 newContainer->reparentSubsequentFloatingOrOutOfFlowSiblings(); | 2479 newContainer->reparentSubsequentFloatingOrOutOfFlowSiblings(); |
2480 return; | 2480 return; |
2481 } | 2481 } |
2482 LayoutObject* next = child->nextSibling(); | 2482 LayoutObject* next = child->nextSibling(); |
2483 if (next && next->isAnonymousBlock() && next->isLayoutBlockFlow()) { | 2483 if (next && next->isAnonymousBlock() && next->isLayoutBlockFlow()) { |
2484 LayoutBlockFlow* newContainer = toLayoutBlockFlow(next); | 2484 LayoutBlockFlow* newContainer = toLayoutBlockFlow(next); |
2485 moveChildTo(newContainer, child, newContainer->firstChild(), false); | 2485 moveChildTo(newContainer, child, newContainer->firstChild(), false); |
2486 } | 2486 } |
2487 } | 2487 } |
2488 | 2488 |
| 2489 static bool isMergeableAnonymousBlock(const LayoutBlockFlow* block) |
| 2490 { |
| 2491 return block->isAnonymousBlock() && !block->continuation() && !block->beingD
estroyed() && !block->isRubyRun() && !block->isRubyBase(); |
| 2492 } |
| 2493 |
| 2494 bool LayoutBlockFlow::mergeSiblingContiguousAnonymousBlock(LayoutBlockFlow* sibl
ingThatMayBeDeleted) |
| 2495 { |
| 2496 // Note: |this| and |siblingThatMayBeDeleted| may not be adjacent siblings a
t this point. There |
| 2497 // may be an object between them which is about to be removed. |
| 2498 |
| 2499 if (!isMergeableAnonymousBlock(this) || !isMergeableAnonymousBlock(siblingTh
atMayBeDeleted)) |
| 2500 return false; |
| 2501 |
| 2502 setNeedsLayoutAndPrefWidthsRecalcAndFullPaintInvalidation(LayoutInvalidation
Reason::AnonymousBlockChange); |
| 2503 |
| 2504 // If the inlineness of children of the two block don't match, we'd need spe
cial code here |
| 2505 // (but there should be no need for it). |
| 2506 ASSERT(siblingThatMayBeDeleted->childrenInline() == childrenInline()); |
| 2507 // Take all the children out of the |next| block and put them in |
| 2508 // the |prev| block. |
| 2509 siblingThatMayBeDeleted->moveAllChildrenIncludingFloatsTo(this, siblingThatM
ayBeDeleted->hasLayer() || hasLayer()); |
| 2510 // Delete the now-empty block's lines and nuke it. |
| 2511 siblingThatMayBeDeleted->deleteLineBoxTree(); |
| 2512 siblingThatMayBeDeleted->destroy(); |
| 2513 return true; |
| 2514 } |
| 2515 |
| 2516 void LayoutBlockFlow::reparentSubsequentFloatingOrOutOfFlowSiblings() |
| 2517 { |
| 2518 if (!parent() || !parent()->isLayoutBlockFlow()) |
| 2519 return; |
| 2520 if (beingDestroyed() || documentBeingDestroyed()) |
| 2521 return; |
| 2522 LayoutBlockFlow* parentBlockFlow = toLayoutBlockFlow(parent()); |
| 2523 LayoutObject* child = nextSibling(); |
| 2524 while (child && child->isFloatingOrOutOfFlowPositioned()) { |
| 2525 LayoutObject* sibling = child->nextSibling(); |
| 2526 parentBlockFlow->moveChildTo(this, child, nullptr, false); |
| 2527 child = sibling; |
| 2528 } |
| 2529 |
| 2530 if (LayoutObject* next = nextSibling()) { |
| 2531 if (next->isLayoutBlockFlow()) |
| 2532 mergeSiblingContiguousAnonymousBlock(toLayoutBlockFlow(next)); |
| 2533 } |
| 2534 } |
| 2535 |
| 2536 void LayoutBlockFlow::reparentPrecedingFloatingOrOutOfFlowSiblings() |
| 2537 { |
| 2538 if (!parent() || !parent()->isLayoutBlockFlow()) |
| 2539 return; |
| 2540 if (beingDestroyed() || documentBeingDestroyed()) |
| 2541 return; |
| 2542 LayoutBlockFlow* parentBlockFlow = toLayoutBlockFlow(parent()); |
| 2543 LayoutObject* child = previousSibling(); |
| 2544 while (child && child->isFloatingOrOutOfFlowPositioned()) { |
| 2545 LayoutObject* sibling = child->previousSibling(); |
| 2546 parentBlockFlow->moveChildTo(this, child, firstChild(), false); |
| 2547 child = sibling; |
| 2548 } |
| 2549 } |
| 2550 |
2489 void LayoutBlockFlow::invalidatePaintForOverhangingFloats(bool paintAllDescendan
ts) | 2551 void LayoutBlockFlow::invalidatePaintForOverhangingFloats(bool paintAllDescendan
ts) |
2490 { | 2552 { |
2491 // Invalidate paint of any overhanging floats (if we know we're the one to p
aint them). | 2553 // Invalidate paint of any overhanging floats (if we know we're the one to p
aint them). |
2492 // Otherwise, bail out. | 2554 // Otherwise, bail out. |
2493 if (!hasOverhangingFloats()) | 2555 if (!hasOverhangingFloats()) |
2494 return; | 2556 return; |
2495 | 2557 |
2496 const FloatingObjectSet& floatingObjectSet = m_floatingObjects->set(); | 2558 const FloatingObjectSet& floatingObjectSet = m_floatingObjects->set(); |
2497 FloatingObjectSetIterator end = floatingObjectSet.end(); | 2559 FloatingObjectSetIterator end = floatingObjectSet.end(); |
2498 for (FloatingObjectSetIterator it = floatingObjectSet.begin(); it != end; ++
it) { | 2560 for (FloatingObjectSetIterator it = floatingObjectSet.begin(); it != end; ++
it) { |
(...skipping 1065 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3564 if (!rect.isEmpty()) | 3626 if (!rect.isEmpty()) |
3565 rects.append(rect); | 3627 rects.append(rect); |
3566 } | 3628 } |
3567 } | 3629 } |
3568 | 3630 |
3569 if (inlineElementContinuation) | 3631 if (inlineElementContinuation) |
3570 inlineElementContinuation->addOutlineRects(rects, additionalOffset + (in
lineElementContinuation->containingBlock()->location() - location()), includeBlo
ckOverflows); | 3632 inlineElementContinuation->addOutlineRects(rects, additionalOffset + (in
lineElementContinuation->containingBlock()->location() - location()), includeBlo
ckOverflows); |
3571 } | 3633 } |
3572 | 3634 |
3573 } // namespace blink | 3635 } // namespace blink |
OLD | NEW |