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 2573 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2584 // If we make an object's children inline we are going to frustrate any futu
re attempts to remove | 2584 // If we make an object's children inline we are going to frustrate any futu
re attempts to remove |
2585 // floats from its children's float-lists before the next layout happens so
clear down all the floatlists | 2585 // floats from its children's float-lists before the next layout happens so
clear down all the floatlists |
2586 // now - they will be rebuilt at layout. | 2586 // now - they will be rebuilt at layout. |
2587 removeFloatingObjectsFromDescendants(); | 2587 removeFloatingObjectsFromDescendants(); |
2588 | 2588 |
2589 for (size_t i = 0; i < blocksToRemove.size(); i++) | 2589 for (size_t i = 0; i < blocksToRemove.size(); i++) |
2590 collapseAnonymousBlockChild(this, blocksToRemove[i]); | 2590 collapseAnonymousBlockChild(this, blocksToRemove[i]); |
2591 setChildrenInline(true); | 2591 setChildrenInline(true); |
2592 } | 2592 } |
2593 | 2593 |
| 2594 static void getInlineRun(LayoutObject* start, LayoutObject* boundary, |
| 2595 LayoutObject*& inlineRunStart, |
| 2596 LayoutObject*& inlineRunEnd) |
| 2597 { |
| 2598 // Beginning at |start| we find the largest contiguous run of inlines that |
| 2599 // we can. We denote the run with start and end points, |inlineRunStart| |
| 2600 // and |inlineRunEnd|. Note that these two values may be the same if |
| 2601 // we encounter only one inline. |
| 2602 // |
| 2603 // We skip any non-inlines we encounter as long as we haven't found any |
| 2604 // inlines yet. |
| 2605 // |
| 2606 // |boundary| indicates a non-inclusive boundary point. Regardless of wheth
er |boundary| |
| 2607 // is inline or not, we will not include it in a run with inlines before it.
It's as though we encountered |
| 2608 // a non-inline. |
| 2609 |
| 2610 // Start by skipping as many non-inlines as we can. |
| 2611 LayoutObject * curr = start; |
| 2612 bool sawInline; |
| 2613 do { |
| 2614 while (curr && !(curr->isInline() || curr->isFloatingOrOutOfFlowPosition
ed())) |
| 2615 curr = curr->nextSibling(); |
| 2616 |
| 2617 inlineRunStart = inlineRunEnd = curr; |
| 2618 |
| 2619 if (!curr) |
| 2620 return; // No more inline children to be found. |
| 2621 |
| 2622 sawInline = curr->isInline(); |
| 2623 |
| 2624 curr = curr->nextSibling(); |
| 2625 while (curr && (curr->isInline() || curr->isFloatingOrOutOfFlowPositione
d()) && (curr != boundary)) { |
| 2626 inlineRunEnd = curr; |
| 2627 if (curr->isInline()) |
| 2628 sawInline = true; |
| 2629 curr = curr->nextSibling(); |
| 2630 } |
| 2631 } while (!sawInline); |
| 2632 } |
| 2633 |
| 2634 void LayoutBlockFlow::makeChildrenNonInline(LayoutObject *insertionPoint) |
| 2635 { |
| 2636 // makeChildrenNonInline takes a block whose children are *all* inline and i
t |
| 2637 // makes sure that inline children are coalesced under anonymous |
| 2638 // blocks. If |insertionPoint| is defined, then it represents the insertion
point for |
| 2639 // the new block child that is causing us to have to wrap all the inlines.
This |
| 2640 // means that we cannot coalesce inlines before |insertionPoint| with inline
s following |
| 2641 // |insertionPoint|, because the new child is going to be inserted in betwee
n the inlines, |
| 2642 // splitting them. |
| 2643 ASSERT(!isInline() || isAtomicInlineLevel()); |
| 2644 ASSERT(!insertionPoint || insertionPoint->parent() == this); |
| 2645 |
| 2646 setChildrenInline(false); |
| 2647 |
| 2648 LayoutObject* child = firstChild(); |
| 2649 if (!child) |
| 2650 return; |
| 2651 |
| 2652 deleteLineBoxTree(); |
| 2653 |
| 2654 while (child) { |
| 2655 LayoutObject* inlineRunStart; |
| 2656 LayoutObject* inlineRunEnd; |
| 2657 getInlineRun(child, insertionPoint, inlineRunStart, inlineRunEnd); |
| 2658 |
| 2659 if (!inlineRunStart) |
| 2660 break; |
| 2661 |
| 2662 child = inlineRunEnd->nextSibling(); |
| 2663 |
| 2664 LayoutBlock* block = createAnonymousBlock(); |
| 2665 children()->insertChildNode(this, block, inlineRunStart); |
| 2666 moveChildrenTo(block, inlineRunStart, child); |
| 2667 } |
| 2668 |
| 2669 #if ENABLE(ASSERT) |
| 2670 for (LayoutObject *c = firstChild(); c; c = c->nextSibling()) |
| 2671 ASSERT(!c->isInline()); |
| 2672 #endif |
| 2673 |
| 2674 setShouldDoFullPaintInvalidation(); |
| 2675 } |
| 2676 |
| 2677 void LayoutBlockFlow::childBecameNonInline(LayoutObject*) |
| 2678 { |
| 2679 makeChildrenNonInline(); |
| 2680 if (isAnonymousBlock() && parent() && parent()->isLayoutBlock()) |
| 2681 toLayoutBlock(parent())->removeLeftoverAnonymousBlock(this); |
| 2682 // |this| may be dead here |
| 2683 } |
| 2684 |
2594 void LayoutBlockFlow::invalidatePaintForOverhangingFloats(bool paintAllDescendan
ts) | 2685 void LayoutBlockFlow::invalidatePaintForOverhangingFloats(bool paintAllDescendan
ts) |
2595 { | 2686 { |
2596 // Invalidate paint of any overhanging floats (if we know we're the one to p
aint them). | 2687 // Invalidate paint of any overhanging floats (if we know we're the one to p
aint them). |
2597 // Otherwise, bail out. | 2688 // Otherwise, bail out. |
2598 if (!hasOverhangingFloats()) | 2689 if (!hasOverhangingFloats()) |
2599 return; | 2690 return; |
2600 | 2691 |
2601 const FloatingObjectSet& floatingObjectSet = m_floatingObjects->set(); | 2692 const FloatingObjectSet& floatingObjectSet = m_floatingObjects->set(); |
2602 FloatingObjectSetIterator end = floatingObjectSet.end(); | 2693 FloatingObjectSetIterator end = floatingObjectSet.end(); |
2603 for (FloatingObjectSetIterator it = floatingObjectSet.begin(); it != end; ++
it) { | 2694 for (FloatingObjectSetIterator it = floatingObjectSet.begin(); it != end; ++
it) { |
(...skipping 1065 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3669 if (!rect.isEmpty()) | 3760 if (!rect.isEmpty()) |
3670 rects.append(rect); | 3761 rects.append(rect); |
3671 } | 3762 } |
3672 } | 3763 } |
3673 | 3764 |
3674 if (inlineElementContinuation) | 3765 if (inlineElementContinuation) |
3675 inlineElementContinuation->addOutlineRects(rects, additionalOffset + (in
lineElementContinuation->containingBlock()->location() - location()), includeBlo
ckOverflows); | 3766 inlineElementContinuation->addOutlineRects(rects, additionalOffset + (in
lineElementContinuation->containingBlock()->location() - location()), includeBlo
ckOverflows); |
3676 } | 3767 } |
3677 | 3768 |
3678 } // namespace blink | 3769 } // namespace blink |
OLD | NEW |