Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(169)

Side by Side Diff: Source/core/layout/LayoutBlockFlow.cpp

Issue 1106533002: Formatting contexts should always expand to enclose floats (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Updated Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/layout/LayoutBlockFlow.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 457 matching lines...) Expand 10 before | Expand all | Expand 10 after
468 setEverHadLayout(true); 468 setEverHadLayout(true);
469 return false; 469 return false;
470 } 470 }
471 471
472 // Calculate our new height. 472 // Calculate our new height.
473 LayoutUnit oldHeight = logicalHeight(); 473 LayoutUnit oldHeight = logicalHeight();
474 LayoutUnit oldClientAfterEdge = clientLogicalBottom(); 474 LayoutUnit oldClientAfterEdge = clientLogicalBottom();
475 475
476 updateLogicalHeight(); 476 updateLogicalHeight();
477 LayoutUnit newHeight = logicalHeight(); 477 LayoutUnit newHeight = logicalHeight();
478 if (oldHeight > newHeight && !childrenInline()) { 478 if (!childrenInline()) {
479 LayoutBlockFlow* lowestBlock = nullptr;
480 bool addedOverhangingFloats = false;
479 // One of our children's floats may have become an overhanging float for us. 481 // One of our children's floats may have become an overhanging float for us.
480 for (LayoutObject* child = lastChild(); child; child = child->previousSi bling()) { 482 for (LayoutObject* child = lastChild(); child; child = child->previousSi bling()) {
483 // TODO(robhogan): We should exclude blocks that create formatting c ontexts, not just out of flow or floating blocks.
481 if (child->isLayoutBlockFlow() && !child->isFloatingOrOutOfFlowPosit ioned()) { 484 if (child->isLayoutBlockFlow() && !child->isFloatingOrOutOfFlowPosit ioned()) {
482 LayoutBlockFlow* block = toLayoutBlockFlow(child); 485 LayoutBlockFlow* block = toLayoutBlockFlow(child);
483 if (block->lowestFloatLogicalBottom() + block->logicalTop() <= n ewHeight) 486 lowestBlock = block;
487 if (oldHeight <= newHeight || block->lowestFloatLogicalBottom() + block->logicalTop() <= newHeight)
484 break; 488 break;
485 addOverhangingFloats(block, false); 489 addOverhangingFloats(block, false);
490 addedOverhangingFloats = true;
486 } 491 }
487 } 492 }
493 if (!addedOverhangingFloats)
494 addLowestFloatFromChildren(lowestBlock);
488 } 495 }
489 496
490 bool heightChanged = (previousHeight != newHeight); 497 bool heightChanged = (previousHeight != newHeight);
491 if (heightChanged) 498 if (heightChanged)
492 relayoutChildren = true; 499 relayoutChildren = true;
493 500
494 layoutPositionedObjects(relayoutChildren || isDocumentElement(), oldLeft != logicalLeft() ? ForcedLayoutAfterContainingBlockMoved : DefaultLayout); 501 layoutPositionedObjects(relayoutChildren || isDocumentElement(), oldLeft != logicalLeft() ? ForcedLayoutAfterContainingBlockMoved : DefaultLayout);
495 502
496 // Add overflow from children (unless we're multi-column, since in that case all our child overflow is clipped anyway). 503 // Add overflow from children (unless we're multi-column, since in that case all our child overflow is clipped anyway).
497 computeOverflow(oldClientAfterEdge); 504 computeOverflow(oldClientAfterEdge);
498 505
499 m_descendantsWithFloatsMarkedForLayout = false; 506 m_descendantsWithFloatsMarkedForLayout = false;
500 return true; 507 return true;
501 } 508 }
502 509
510 void LayoutBlockFlow::addLowestFloatFromChildren(LayoutBlockFlow* block)
511 {
512 // TODO(robhogan): Make createsNewFormattingContext an ASSERT.
513 if (!block || !block->containsFloats() || block->createsNewFormattingContext ())
514 return;
515
516 FloatingObject* floatingObject = block->m_floatingObjects->lowestFloatingObj ect();
517 if (!floatingObject || containsFloat(floatingObject->layoutObject()))
518 return;
519
520 LayoutUnit childLogicalTop = block->logicalTop();
521 LayoutUnit childLogicalLeft = block->logicalLeft();
522 LayoutSize offset = isHorizontalWritingMode() ? LayoutSize(-childLogicalLeft , -childLogicalTop) : LayoutSize(-childLogicalTop, -childLogicalLeft);
leviw_travelin_and_unemployed 2015/05/27 18:51:58 This code is kind of confusing. I think it would b
523
524 if (!m_floatingObjects)
525 createFloatingObjects();
526 FloatingObject* newFloatingObject = m_floatingObjects->add(floatingObject->c opyToNewContainer(offset, false, true));
527 newFloatingObject->setIsLowestNonOverhangingFloatInChild(true);
528 }
529
503 void LayoutBlockFlow::determineLogicalLeftPositionForChild(LayoutBox& child) 530 void LayoutBlockFlow::determineLogicalLeftPositionForChild(LayoutBox& child)
504 { 531 {
505 LayoutUnit startPosition = borderStart() + paddingStart(); 532 LayoutUnit startPosition = borderStart() + paddingStart();
506 LayoutUnit initialStartPosition = startPosition; 533 LayoutUnit initialStartPosition = startPosition;
507 if (style()->shouldPlaceBlockDirectionScrollbarOnLogicalLeft()) 534 if (style()->shouldPlaceBlockDirectionScrollbarOnLogicalLeft())
508 startPosition -= verticalScrollbarWidth(); 535 startPosition -= verticalScrollbarWidth();
509 LayoutUnit totalAvailableLogicalWidth = borderAndPaddingLogicalWidth() + ava ilableLogicalWidth(); 536 LayoutUnit totalAvailableLogicalWidth = borderAndPaddingLogicalWidth() + ava ilableLogicalWidth();
510 537
511 LayoutUnit childMarginStart = marginStartForChild(child); 538 LayoutUnit childMarginStart = marginStartForChild(child);
512 LayoutUnit newPosition = startPosition + childMarginStart; 539 LayoutUnit newPosition = startPosition + childMarginStart;
(...skipping 2066 matching lines...) Expand 10 before | Expand all | Expand 10 after
2579 if (logicalBottom > logicalHeight()) { 2606 if (logicalBottom > logicalHeight()) {
2580 // If the object is not in the list, we add it now. 2607 // If the object is not in the list, we add it now.
2581 if (!containsFloat(floatingObject->layoutObject())) { 2608 if (!containsFloat(floatingObject->layoutObject())) {
2582 LayoutSize offset = isHorizontalWritingMode() ? LayoutSize(-chil dLogicalLeft, -childLogicalTop) : LayoutSize(-childLogicalTop, -childLogicalLeft ); 2609 LayoutSize offset = isHorizontalWritingMode() ? LayoutSize(-chil dLogicalLeft, -childLogicalTop) : LayoutSize(-childLogicalTop, -childLogicalLeft );
2583 bool shouldPaint = false; 2610 bool shouldPaint = false;
2584 2611
2585 // The nearest enclosing layer always paints the float (so that zindex and stacking 2612 // The nearest enclosing layer always paints the float (so that zindex and stacking
2586 // behaves properly). We always want to propagate the desire to paint the float as 2613 // behaves properly). We always want to propagate the desire to paint the float as
2587 // far out as we can, to the outermost block that overlaps the f loat, stopping only 2614 // far out as we can, to the outermost block that overlaps the f loat, stopping only
2588 // if we hit a self-painting layer boundary. 2615 // if we hit a self-painting layer boundary.
2589 if (floatingObject->layoutObject()->enclosingFloatPaintingLayer( ) == enclosingFloatPaintingLayer()) { 2616 if (floatingObject->layoutObject()->enclosingFloatPaintingLayer( ) == enclosingFloatPaintingLayer() && !floatingObject->isLowestNonOverhangingFlo atInChild()) {
2590 floatingObject->setShouldPaint(false); 2617 floatingObject->setShouldPaint(false);
2591 shouldPaint = true; 2618 shouldPaint = true;
2592 } 2619 }
2593 // We create the floating object list lazily. 2620 // We create the floating object list lazily.
2594 if (!m_floatingObjects) 2621 if (!m_floatingObjects)
2595 createFloatingObjects(); 2622 createFloatingObjects();
2596 2623
2597 m_floatingObjects->add(floatingObject->copyToNewContainer(offset , shouldPaint, true)); 2624 m_floatingObjects->add(floatingObject->copyToNewContainer(offset , shouldPaint, true));
2598 } 2625 }
2599 } else { 2626 } else {
2600 if (makeChildPaintOtherFloats && !floatingObject->shouldPaint() && ! floatingObject->layoutObject()->hasSelfPaintingLayer() 2627 if (makeChildPaintOtherFloats && !floatingObject->shouldPaint() && ! floatingObject->layoutObject()->hasSelfPaintingLayer() && !floatingObject->isLow estNonOverhangingFloatInChild()
2601 && floatingObject->layoutObject()->isDescendantOf(child) && floa tingObject->layoutObject()->enclosingFloatPaintingLayer() == child->enclosingFlo atPaintingLayer()) { 2628 && floatingObject->layoutObject()->isDescendantOf(child) && floa tingObject->layoutObject()->enclosingFloatPaintingLayer() == child->enclosingFlo atPaintingLayer()) {
2602 // The float is not overhanging from this block, so if it is a d escendant of the child, the child should 2629 // The float is not overhanging from this block, so if it is a d escendant of the child, the child should
2603 // paint it (the other case is that it is intruding into the chi ld), unless it has its own layer or enclosing 2630 // paint it (the other case is that it is intruding into the chi ld), unless it has its own layer or enclosing
2604 // layer. 2631 // layer.
2605 // If makeChildPaintOtherFloats is false, it means that the chil d must already know about all the floats 2632 // If makeChildPaintOtherFloats is false, it means that the chil d must already know about all the floats
2606 // it should paint. 2633 // it should paint.
2607 floatingObject->setShouldPaint(true); 2634 floatingObject->setShouldPaint(true);
2608 } 2635 }
2609 2636
2610 // 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 2637 // 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
3153 FrameView* frameView = document().view(); 3180 FrameView* frameView = document().view();
3154 LayoutUnit top = (style()->position() == FixedPosition) ? 0 : frameView->scr ollOffset().height(); 3181 LayoutUnit top = (style()->position() == FixedPosition) ? 0 : frameView->scr ollOffset().height();
3155 int visibleHeight = frameView->visibleContentRect(IncludeScrollbars).height( ); 3182 int visibleHeight = frameView->visibleContentRect(IncludeScrollbars).height( );
3156 if (size().height() < visibleHeight) 3183 if (size().height() < visibleHeight)
3157 top += (visibleHeight - size().height()) / 2; 3184 top += (visibleHeight - size().height()) / 2;
3158 setY(top); 3185 setY(top);
3159 dialog->setCentered(top); 3186 dialog->setCentered(top);
3160 } 3187 }
3161 3188
3162 } // namespace blink 3189 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/layout/LayoutBlockFlow.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698