| 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 673 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 684 // The logical top might be saturated for very large elements. Comparing | 684 // The logical top might be saturated for very large elements. Comparing |
| 685 // with the old logical top might then yield a false negative, as adding and | 685 // with the old logical top might then yield a false negative, as adding and |
| 686 // removing margins, borders etc. from a saturated number might yield | 686 // removing margins, borders etc. from a saturated number might yield |
| 687 // incorrect results. If this is the case, always mark for layout. | 687 // incorrect results. If this is the case, always mark for layout. |
| 688 mark_descendants_with_floats = true; | 688 mark_descendants_with_floats = true; |
| 689 } else if (!child.AvoidsFloats() || child.ShrinkToAvoidFloats()) { | 689 } else if (!child.AvoidsFloats() || child.ShrinkToAvoidFloats()) { |
| 690 // If an element might be affected by the presence of floats, then always | 690 // If an element might be affected by the presence of floats, then always |
| 691 // mark it for layout. | 691 // mark it for layout. |
| 692 LayoutUnit lowest_float = | 692 LayoutUnit lowest_float = |
| 693 std::max(previous_float_logical_bottom, LowestFloatLogicalBottom()); | 693 std::max(previous_float_logical_bottom, LowestFloatLogicalBottom()); |
| 694 lowest_float = std::max(lowest_float, child.LowestFloatLogicalBottom()); | |
| 695 if (lowest_float > new_logical_top) | 694 if (lowest_float > new_logical_top) |
| 696 mark_descendants_with_floats = true; | 695 mark_descendants_with_floats = true; |
| 697 } | 696 } |
| 698 | 697 |
| 699 if (mark_descendants_with_floats) | 698 if (mark_descendants_with_floats) |
| 700 child.MarkAllDescendantsWithFloatsForLayout(); | 699 child.MarkAllDescendantsWithFloatsForLayout(); |
| 701 } | 700 } |
| 702 | 701 |
| 703 bool LayoutBlockFlow::PositionAndLayoutOnceIfNeeded( | 702 bool LayoutBlockFlow::PositionAndLayoutOnceIfNeeded( |
| 704 LayoutBox& child, | 703 LayoutBox& child, |
| (...skipping 3005 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3710 bool is_paginated = View()->GetLayoutState()->IsPaginated(); | 3709 bool is_paginated = View()->GetLayoutState()->IsPaginated(); |
| 3711 if (is_paginated && !ChildrenInline()) { | 3710 if (is_paginated && !ChildrenInline()) { |
| 3712 // Forced breaks are inserted at class A break points. Floats may be | 3711 // Forced breaks are inserted at class A break points. Floats may be |
| 3713 // affected by a break-after value on the previous in-flow sibling. | 3712 // affected by a break-after value on the previous in-flow sibling. |
| 3714 if (LayoutBox* previous_in_flow_box = child.PreviousInFlowSiblingBox()) { | 3713 if (LayoutBox* previous_in_flow_box = child.PreviousInFlowSiblingBox()) { |
| 3715 logical_top_margin_edge = ApplyForcedBreak( | 3714 logical_top_margin_edge = ApplyForcedBreak( |
| 3716 logical_top_margin_edge, previous_in_flow_box->BreakAfter()); | 3715 logical_top_margin_edge, previous_in_flow_box->BreakAfter()); |
| 3717 } | 3716 } |
| 3718 } | 3717 } |
| 3719 | 3718 |
| 3719 LayoutUnit old_logical_top = child.LogicalTop(); |
| 3720 if (child.NeedsLayout()) { | 3720 if (child.NeedsLayout()) { |
| 3721 if (is_paginated) { | 3721 if (is_paginated) { |
| 3722 // Before we can lay out the float, we need to estimate a position for | 3722 // Before we can lay out the float, we need to estimate a position for |
| 3723 // it. In order to do that, we first need to know its block start margin. | 3723 // it. In order to do that, we first need to know its block start margin. |
| 3724 child.ComputeAndSetBlockDirectionMargins(this); | 3724 child.ComputeAndSetBlockDirectionMargins(this); |
| 3725 LayoutUnit margin_before = MarginBeforeForChild(child); | 3725 LayoutUnit margin_before = MarginBeforeForChild(child); |
| 3726 | 3726 |
| 3727 // We have found the highest possible position for the float, so we'll | 3727 // We have found the highest possible position for the float, so we'll |
| 3728 // lay out right there. Later on, we may be pushed further down by | 3728 // lay out right there. Later on, we may be pushed further down by |
| 3729 // adjacent floats which we don't fit beside, or pushed by fragmentation | 3729 // adjacent floats which we don't fit beside, or pushed by fragmentation |
| (...skipping 29 matching lines...) Expand all Loading... |
| 3759 SetLogicalTopForChild(child, logical_top_margin_edge + margin_before); | 3759 SetLogicalTopForChild(child, logical_top_margin_edge + margin_before); |
| 3760 | 3760 |
| 3761 SubtreeLayoutScope layout_scope(child); | 3761 SubtreeLayoutScope layout_scope(child); |
| 3762 | 3762 |
| 3763 // A new position may mean that we need to insert, move or remove breaks | 3763 // A new position may mean that we need to insert, move or remove breaks |
| 3764 // inside the float. We may also need to lay out if we just ceased to be | 3764 // inside the float. We may also need to lay out if we just ceased to be |
| 3765 // fragmented, in order to remove pagination struts inside the child. | 3765 // fragmented, in order to remove pagination struts inside the child. |
| 3766 MarkChildForPaginationRelayoutIfNeeded(child, layout_scope); | 3766 MarkChildForPaginationRelayoutIfNeeded(child, layout_scope); |
| 3767 child.LayoutIfNeeded(); | 3767 child.LayoutIfNeeded(); |
| 3768 | 3768 |
| 3769 // If negative margin pushes the child completely out of its old position |
| 3770 // mark for layout siblings that may have it in its float lists. |
| 3771 if (child.LogicalBottom() <= old_logical_top) { |
| 3772 LayoutObject* next = child.NextSibling(); |
| 3773 if (next && next->IsLayoutBlockFlow()) { |
| 3774 LayoutBlockFlow* nextBlock = ToLayoutBlockFlow(next); |
| 3775 if (!nextBlock->AvoidsFloats() || nextBlock->ShrinkToAvoidFloats()) |
| 3776 nextBlock->MarkAllDescendantsWithFloatsForLayout(); |
| 3777 } |
| 3778 } |
| 3779 |
| 3769 if (is_paginated) { | 3780 if (is_paginated) { |
| 3770 PaginatedContentWasLaidOut(child.LogicalBottom()); | 3781 PaginatedContentWasLaidOut(child.LogicalBottom()); |
| 3771 | 3782 |
| 3772 // We may have to insert a break before the float. | 3783 // We may have to insert a break before the float. |
| 3773 LayoutUnit new_logical_top_margin_edge = | 3784 LayoutUnit new_logical_top_margin_edge = |
| 3774 AdjustFloatLogicalTopForPagination(child, logical_top_margin_edge); | 3785 AdjustFloatLogicalTopForPagination(child, logical_top_margin_edge); |
| 3775 if (logical_top_margin_edge != new_logical_top_margin_edge) { | 3786 if (logical_top_margin_edge != new_logical_top_margin_edge) { |
| 3776 // We had already found a location for the float, but a soft | 3787 // We had already found a location for the float, but a soft |
| 3777 // fragmentainer break then made us push it further down. This may affect | 3788 // fragmentainer break then made us push it further down. This may affect |
| 3778 // the inline position of the float (since we may no longer be beside the | 3789 // the inline position of the float (since we may no longer be beside the |
| (...skipping 878 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4657 return LayoutBlock::InvalidatePaint(paint_invalidation_state); | 4668 return LayoutBlock::InvalidatePaint(paint_invalidation_state); |
| 4658 } | 4669 } |
| 4659 | 4670 |
| 4660 void LayoutBlockFlow::InvalidateDisplayItemClients( | 4671 void LayoutBlockFlow::InvalidateDisplayItemClients( |
| 4661 PaintInvalidationReason invalidation_reason) const { | 4672 PaintInvalidationReason invalidation_reason) const { |
| 4662 BlockFlowPaintInvalidator(*this).InvalidateDisplayItemClients( | 4673 BlockFlowPaintInvalidator(*this).InvalidateDisplayItemClients( |
| 4663 invalidation_reason); | 4674 invalidation_reason); |
| 4664 } | 4675 } |
| 4665 | 4676 |
| 4666 } // namespace blink | 4677 } // namespace blink |
| OLD | NEW |