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 454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
465 setEverHadLayout(true); | 465 setEverHadLayout(true); |
466 return false; | 466 return false; |
467 } | 467 } |
468 | 468 |
469 // Calculate our new height. | 469 // Calculate our new height. |
470 LayoutUnit oldHeight = logicalHeight(); | 470 LayoutUnit oldHeight = logicalHeight(); |
471 LayoutUnit oldClientAfterEdge = clientLogicalBottom(); | 471 LayoutUnit oldClientAfterEdge = clientLogicalBottom(); |
472 | 472 |
473 updateLogicalHeight(); | 473 updateLogicalHeight(); |
474 LayoutUnit newHeight = logicalHeight(); | 474 LayoutUnit newHeight = logicalHeight(); |
475 if (oldHeight > newHeight && !childrenInline()) { | 475 if (!childrenInline()) { |
476 LayoutBlockFlow* lowestBlock = nullptr; | |
477 bool addedOverhangingFloats = false; | |
476 // One of our children's floats may have become an overhanging float for us. | 478 // One of our children's floats may have become an overhanging float for us. |
477 for (LayoutObject* child = lastChild(); child; child = child->previousSi bling()) { | 479 for (LayoutObject* child = lastChild(); child; child = child->previousSi bling()) { |
480 // TODO(robhogan): We should exclude blocks that create formatting c ontexts, not just out of flow or floating blocks. | |
478 if (child->isLayoutBlockFlow() && !child->isFloatingOrOutOfFlowPosit ioned()) { | 481 if (child->isLayoutBlockFlow() && !child->isFloatingOrOutOfFlowPosit ioned()) { |
479 LayoutBlockFlow* block = toLayoutBlockFlow(child); | 482 LayoutBlockFlow* block = toLayoutBlockFlow(child); |
480 if (block->lowestFloatLogicalBottom() + block->logicalTop() <= n ewHeight) | 483 lowestBlock = block; |
484 if (oldHeight <= newHeight || block->lowestFloatLogicalBottom() + block->logicalTop() <= newHeight) | |
481 break; | 485 break; |
482 addOverhangingFloats(block, false); | 486 addOverhangingFloats(block, false); |
487 addedOverhangingFloats = true; | |
483 } | 488 } |
484 } | 489 } |
490 if (!addedOverhangingFloats) | |
491 addLowestFloatFromChildren(lowestBlock); | |
485 } | 492 } |
486 | 493 |
487 bool heightChanged = (previousHeight != newHeight); | 494 bool heightChanged = (previousHeight != newHeight); |
488 if (heightChanged) | 495 if (heightChanged) |
489 relayoutChildren = true; | 496 relayoutChildren = true; |
490 | 497 |
491 layoutPositionedObjects(relayoutChildren || isDocumentElement(), oldLeft != logicalLeft() ? ForcedLayoutAfterContainingBlockMoved : DefaultLayout); | 498 layoutPositionedObjects(relayoutChildren || isDocumentElement(), oldLeft != logicalLeft() ? ForcedLayoutAfterContainingBlockMoved : DefaultLayout); |
492 | 499 |
493 // Add overflow from children (unless we're multi-column, since in that case all our child overflow is clipped anyway). | 500 // Add overflow from children (unless we're multi-column, since in that case all our child overflow is clipped anyway). |
494 computeOverflow(oldClientAfterEdge); | 501 computeOverflow(oldClientAfterEdge); |
495 | 502 |
496 m_descendantsWithFloatsMarkedForLayout = false; | 503 m_descendantsWithFloatsMarkedForLayout = false; |
497 return true; | 504 return true; |
498 } | 505 } |
499 | 506 |
507 void LayoutBlockFlow::addLowestFloatFromChildren(LayoutBlockFlow* block) | |
508 { | |
509 // TODO(robhogan): Make createsNewFormattingContext an ASSERT. | |
510 if (!block || !block->containsFloats() || block->createsNewFormattingContext ()) | |
511 return; | |
512 | |
513 FloatingObject* floatingObject = block->m_floatingObjects->lowestFloatingObj ect(); | |
514 if (!floatingObject || containsFloat(floatingObject->layoutObject())) | |
515 return; | |
516 | |
517 LayoutSize offset(-block->logicalLeft(), -block->logicalTop()); | |
518 if (!isHorizontalWritingMode()) | |
519 offset = offset.transposedSize(); | |
520 | |
521 if (!m_floatingObjects) | |
522 createFloatingObjects(); | |
523 FloatingObject* newFloatingObject = m_floatingObjects->add(floatingObject->c opyToNewContainer(offset, false, true)); | |
524 newFloatingObject->setIsLowestNonOverhangingFloatInChild(true); | |
leviw_travelin_and_unemployed
2015/06/02 23:05:41
If new floats get added, it seems possible for the
rhogan
2015/06/03 20:30:55
m_floatingObjects gets cleared down at the start o
| |
525 } | |
526 | |
500 void LayoutBlockFlow::determineLogicalLeftPositionForChild(LayoutBox& child) | 527 void LayoutBlockFlow::determineLogicalLeftPositionForChild(LayoutBox& child) |
501 { | 528 { |
502 LayoutUnit startPosition = borderStart() + paddingStart(); | 529 LayoutUnit startPosition = borderStart() + paddingStart(); |
503 LayoutUnit initialStartPosition = startPosition; | 530 LayoutUnit initialStartPosition = startPosition; |
504 if (style()->shouldPlaceBlockDirectionScrollbarOnLogicalLeft()) | 531 if (style()->shouldPlaceBlockDirectionScrollbarOnLogicalLeft()) |
505 startPosition -= verticalScrollbarWidth(); | 532 startPosition -= verticalScrollbarWidth(); |
506 LayoutUnit totalAvailableLogicalWidth = borderAndPaddingLogicalWidth() + ava ilableLogicalWidth(); | 533 LayoutUnit totalAvailableLogicalWidth = borderAndPaddingLogicalWidth() + ava ilableLogicalWidth(); |
507 | 534 |
508 LayoutUnit childMarginStart = marginStartForChild(child); | 535 LayoutUnit childMarginStart = marginStartForChild(child); |
509 LayoutUnit newPosition = startPosition + childMarginStart; | 536 LayoutUnit newPosition = startPosition + childMarginStart; |
(...skipping 2066 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2576 if (logicalBottom > logicalHeight()) { | 2603 if (logicalBottom > logicalHeight()) { |
2577 // If the object is not in the list, we add it now. | 2604 // If the object is not in the list, we add it now. |
2578 if (!containsFloat(floatingObject->layoutObject())) { | 2605 if (!containsFloat(floatingObject->layoutObject())) { |
2579 LayoutSize offset = isHorizontalWritingMode() ? LayoutSize(-chil dLogicalLeft, -childLogicalTop) : LayoutSize(-childLogicalTop, -childLogicalLeft ); | 2606 LayoutSize offset = isHorizontalWritingMode() ? LayoutSize(-chil dLogicalLeft, -childLogicalTop) : LayoutSize(-childLogicalTop, -childLogicalLeft ); |
2580 bool shouldPaint = false; | 2607 bool shouldPaint = false; |
2581 | 2608 |
2582 // The nearest enclosing layer always paints the float (so that zindex and stacking | 2609 // The nearest enclosing layer always paints the float (so that zindex and stacking |
2583 // behaves properly). We always want to propagate the desire to paint the float as | 2610 // behaves properly). We always want to propagate the desire to paint the float as |
2584 // far out as we can, to the outermost block that overlaps the f loat, stopping only | 2611 // far out as we can, to the outermost block that overlaps the f loat, stopping only |
2585 // if we hit a self-painting layer boundary. | 2612 // if we hit a self-painting layer boundary. |
2586 if (floatingObject->layoutObject()->enclosingFloatPaintingLayer( ) == enclosingFloatPaintingLayer()) { | 2613 if (floatingObject->layoutObject()->enclosingFloatPaintingLayer( ) == enclosingFloatPaintingLayer() && !floatingObject->isLowestNonOverhangingFlo atInChild()) { |
2587 floatingObject->setShouldPaint(false); | 2614 floatingObject->setShouldPaint(false); |
2588 shouldPaint = true; | 2615 shouldPaint = true; |
2589 } | 2616 } |
2590 // We create the floating object list lazily. | 2617 // We create the floating object list lazily. |
2591 if (!m_floatingObjects) | 2618 if (!m_floatingObjects) |
2592 createFloatingObjects(); | 2619 createFloatingObjects(); |
2593 | 2620 |
2594 m_floatingObjects->add(floatingObject->copyToNewContainer(offset , shouldPaint, true)); | 2621 m_floatingObjects->add(floatingObject->copyToNewContainer(offset , shouldPaint, true)); |
2595 } | 2622 } |
2596 } else { | 2623 } else { |
2597 if (makeChildPaintOtherFloats && !floatingObject->shouldPaint() && ! floatingObject->layoutObject()->hasSelfPaintingLayer() | 2624 if (makeChildPaintOtherFloats && !floatingObject->shouldPaint() && ! floatingObject->layoutObject()->hasSelfPaintingLayer() && !floatingObject->isLow estNonOverhangingFloatInChild() |
2598 && floatingObject->layoutObject()->isDescendantOf(child) && floa tingObject->layoutObject()->enclosingFloatPaintingLayer() == child->enclosingFlo atPaintingLayer()) { | 2625 && floatingObject->layoutObject()->isDescendantOf(child) && floa tingObject->layoutObject()->enclosingFloatPaintingLayer() == child->enclosingFlo atPaintingLayer()) { |
2599 // The float is not overhanging from this block, so if it is a d escendant of the child, the child should | 2626 // The float is not overhanging from this block, so if it is a d escendant of the child, the child should |
2600 // paint it (the other case is that it is intruding into the chi ld), unless it has its own layer or enclosing | 2627 // paint it (the other case is that it is intruding into the chi ld), unless it has its own layer or enclosing |
2601 // layer. | 2628 // layer. |
2602 // If makeChildPaintOtherFloats is false, it means that the chil d must already know about all the floats | 2629 // If makeChildPaintOtherFloats is false, it means that the chil d must already know about all the floats |
2603 // it should paint. | 2630 // it should paint. |
2604 floatingObject->setShouldPaint(true); | 2631 floatingObject->setShouldPaint(true); |
2605 } | 2632 } |
2606 | 2633 |
2607 // Since the float doesn't overhang, it didn't get put into our list . We need to go ahead and add its overflow in to the | 2634 // Since the float doesn't overhang, it didn't get put into our list . We need to go ahead and add its overflow in to the |
(...skipping 542 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3150 FrameView* frameView = document().view(); | 3177 FrameView* frameView = document().view(); |
3151 LayoutUnit top = (style()->position() == FixedPosition) ? 0 : frameView->scr ollOffset().height(); | 3178 LayoutUnit top = (style()->position() == FixedPosition) ? 0 : frameView->scr ollOffset().height(); |
3152 int visibleHeight = frameView->visibleContentRect(IncludeScrollbars).height( ); | 3179 int visibleHeight = frameView->visibleContentRect(IncludeScrollbars).height( ); |
3153 if (size().height() < visibleHeight) | 3180 if (size().height() < visibleHeight) |
3154 top += (visibleHeight - size().height()) / 2; | 3181 top += (visibleHeight - size().height()) / 2; |
3155 setY(top); | 3182 setY(top); |
3156 dialog->setCentered(top); | 3183 dialog->setCentered(top); |
3157 } | 3184 } |
3158 | 3185 |
3159 } // namespace blink | 3186 } // namespace blink |
OLD | NEW |