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 2385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2396 // Skip the LayoutBlock override, since that one deals with anonymous child
insertion in a way | 2396 // Skip the LayoutBlock override, since that one deals with anonymous child
insertion in a way |
2397 // that isn't sufficient for us, and can only cause trouble at this point. | 2397 // that isn't sufficient for us, and can only cause trouble at this point. |
2398 LayoutBox::addChild(newChild, beforeChild); | 2398 LayoutBox::addChild(newChild, beforeChild); |
2399 | 2399 |
2400 if (madeBoxesNonInline && parent() && isAnonymousBlock() && parent()->isLayo
utBlock()) { | 2400 if (madeBoxesNonInline && parent() && isAnonymousBlock() && parent()->isLayo
utBlock()) { |
2401 toLayoutBlock(parent())->removeLeftoverAnonymousBlock(this); | 2401 toLayoutBlock(parent())->removeLeftoverAnonymousBlock(this); |
2402 // |this| may be dead now. | 2402 // |this| may be dead now. |
2403 } | 2403 } |
2404 } | 2404 } |
2405 | 2405 |
| 2406 static bool isMergeableAnonymousBlock(const LayoutBlockFlow* block) |
| 2407 { |
| 2408 return block->isAnonymousBlock() && !block->continuation() && !block->beingD
estroyed() && !block->isRubyRun() && !block->isRubyBase(); |
| 2409 } |
| 2410 |
2406 void LayoutBlockFlow::removeChild(LayoutObject* oldChild) | 2411 void LayoutBlockFlow::removeChild(LayoutObject* oldChild) |
2407 { | 2412 { |
2408 // No need to waste time in merging or removing empty anonymous blocks. | 2413 // No need to waste time in merging or removing empty anonymous blocks. |
2409 // We can just bail out if our document is getting destroyed. | 2414 // We can just bail out if our document is getting destroyed. |
2410 if (documentBeingDestroyed()) { | 2415 if (documentBeingDestroyed()) { |
2411 LayoutBox::removeChild(oldChild); | 2416 LayoutBox::removeChild(oldChild); |
2412 return; | 2417 return; |
2413 } | 2418 } |
2414 | 2419 |
2415 // If this child is a block, and if our previous and next siblings are | 2420 // If this child is a block, and if our previous and next siblings are |
2416 // both anonymous blocks with inline content, then we can go ahead and | 2421 // both anonymous blocks with inline content, then we can go ahead and |
2417 // fold the inline content back together. | 2422 // fold the inline content back together. |
2418 LayoutObject* prev = oldChild->previousSibling(); | 2423 LayoutObject* prev = oldChild->previousSibling(); |
2419 LayoutObject* next = oldChild->nextSibling(); | 2424 LayoutObject* next = oldChild->nextSibling(); |
2420 bool mergedAnonymousBlocks = false; | 2425 bool mergedAnonymousBlocks = false; |
2421 if (prev && next && !oldChild->isInline() && !oldChild->virtualContinuation(
) && prev->isLayoutBlockFlow() && next->isLayoutBlockFlow()) { | 2426 if (prev && next && !oldChild->isInline() && !oldChild->virtualContinuation(
) && prev->isLayoutBlockFlow() && next->isLayoutBlockFlow()) { |
2422 if (toLayoutBlockFlow(prev)->mergeSiblingContiguousAnonymousBlock(toLayo
utBlockFlow(next))) { | 2427 if (toLayoutBlockFlow(prev)->mergeSiblingContiguousAnonymousBlock(toLayo
utBlockFlow(next))) { |
2423 mergedAnonymousBlocks = true; | 2428 mergedAnonymousBlocks = true; |
2424 next = nullptr; | 2429 next = nullptr; |
2425 } | 2430 } |
2426 } | 2431 } |
2427 | 2432 |
2428 LayoutBlock::removeChild(oldChild); | 2433 LayoutBlock::removeChild(oldChild); |
2429 | 2434 |
2430 LayoutObject* child = prev ? prev : next; | 2435 LayoutObject* child = prev ? prev : next; |
2431 if (mergedAnonymousBlocks && child && !child->previousSibling() && !child->n
extSibling()) { | 2436 if (child && child->isLayoutBlockFlow() && !child->previousSibling() && !chi
ld->nextSibling()) { |
2432 // The removal has knocked us down to containing only a single anonymous | 2437 // If the removal has knocked us down to containing only a single anonym
ous |
2433 // box. We can go ahead and pull the content right back up into our | 2438 // box we can go ahead and pull the content right back up into our |
2434 // box. | 2439 // box. |
2435 collapseAnonymousBlockChild(toLayoutBlockFlow(child)); | 2440 if (mergedAnonymousBlocks || isMergeableAnonymousBlock(toLayoutBlockFlow
(child))) |
| 2441 collapseAnonymousBlockChild(toLayoutBlockFlow(child)); |
2436 } | 2442 } |
2437 | 2443 |
2438 if (!firstChild()) { | 2444 if (!firstChild()) { |
2439 // If this was our last child be sure to clear out our line boxes. | 2445 // If this was our last child be sure to clear out our line boxes. |
2440 if (childrenInline()) | 2446 if (childrenInline()) |
2441 deleteLineBoxTree(); | 2447 deleteLineBoxTree(); |
2442 | 2448 |
2443 // If we are an empty anonymous block in the continuation chain, | 2449 // If we are an empty anonymous block in the continuation chain, |
2444 // we need to remove ourself and fix the continuation chain. | 2450 // we need to remove ourself and fix the continuation chain. |
2445 if (!beingDestroyed() && isAnonymousBlockContinuation() && !oldChild->is
ListMarker()) { | 2451 if (!beingDestroyed() && isAnonymousBlockContinuation() && !oldChild->is
ListMarker()) { |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2547 return; | 2553 return; |
2548 setNeedsLayoutAndPrefWidthsRecalcAndFullPaintInvalidation(LayoutInvalidation
Reason::ChildAnonymousBlockChanged); | 2554 setNeedsLayoutAndPrefWidthsRecalcAndFullPaintInvalidation(LayoutInvalidation
Reason::ChildAnonymousBlockChanged); |
2549 | 2555 |
2550 child->moveAllChildrenTo(this, child->nextSibling(), child->hasLayer()); | 2556 child->moveAllChildrenTo(this, child->nextSibling(), child->hasLayer()); |
2551 setChildrenInline(child->childrenInline()); | 2557 setChildrenInline(child->childrenInline()); |
2552 | 2558 |
2553 children()->removeChildNode(this, child, child->hasLayer()); | 2559 children()->removeChildNode(this, child, child->hasLayer()); |
2554 child->destroy(); | 2560 child->destroy(); |
2555 } | 2561 } |
2556 | 2562 |
2557 static bool isMergeableAnonymousBlock(const LayoutBlockFlow* block) | |
2558 { | |
2559 return block->isAnonymousBlock() && !block->continuation() && !block->beingD
estroyed() && !block->isRubyRun() && !block->isRubyBase(); | |
2560 } | |
2561 | |
2562 bool LayoutBlockFlow::mergeSiblingContiguousAnonymousBlock(LayoutBlockFlow* sibl
ingThatMayBeDeleted) | 2563 bool LayoutBlockFlow::mergeSiblingContiguousAnonymousBlock(LayoutBlockFlow* sibl
ingThatMayBeDeleted) |
2563 { | 2564 { |
2564 // Note: |this| and |siblingThatMayBeDeleted| may not be adjacent siblings a
t this point. There | 2565 // Note: |this| and |siblingThatMayBeDeleted| may not be adjacent siblings a
t this point. There |
2565 // may be an object between them which is about to be removed. | 2566 // may be an object between them which is about to be removed. |
2566 | 2567 |
2567 if (!isMergeableAnonymousBlock(this) || !isMergeableAnonymousBlock(siblingTh
atMayBeDeleted)) | 2568 if (!isMergeableAnonymousBlock(this) || !isMergeableAnonymousBlock(siblingTh
atMayBeDeleted)) |
2568 return false; | 2569 return false; |
2569 | 2570 |
2570 setNeedsLayoutAndPrefWidthsRecalcAndFullPaintInvalidation(LayoutInvalidation
Reason::AnonymousBlockChange); | 2571 setNeedsLayoutAndPrefWidthsRecalcAndFullPaintInvalidation(LayoutInvalidation
Reason::AnonymousBlockChange); |
2571 | 2572 |
(...skipping 1203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3775 if (!rect.isEmpty()) | 3776 if (!rect.isEmpty()) |
3776 rects.append(rect); | 3777 rects.append(rect); |
3777 } | 3778 } |
3778 } | 3779 } |
3779 | 3780 |
3780 if (inlineElementContinuation) | 3781 if (inlineElementContinuation) |
3781 inlineElementContinuation->addOutlineRects(rects, additionalOffset + (in
lineElementContinuation->containingBlock()->location() - location()), includeBlo
ckOverflows); | 3782 inlineElementContinuation->addOutlineRects(rects, additionalOffset + (in
lineElementContinuation->containingBlock()->location() - location()), includeBlo
ckOverflows); |
3782 } | 3783 } |
3783 | 3784 |
3784 } // namespace blink | 3785 } // namespace blink |
OLD | NEW |