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

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

Issue 1766223002: Clear floats even when they are not tracked by a previous sibling (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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
« no previous file with comments | « third_party/WebKit/LayoutTests/fast/block/float/block-with-negative-margin-clears-float-expected.txt ('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 883 matching lines...) Expand 10 before | Expand all | Expand 10 after
894 // We should not process floats if the parent node is not a LayoutBlockFlow. Otherwise, we will add 894 // We should not process floats if the parent node is not a LayoutBlockFlow. Otherwise, we will add
895 // floats in an invalid context. This will cause a crash arising from a bad cast on the parent. 895 // floats in an invalid context. This will cause a crash arising from a bad cast on the parent.
896 // See <rdar://problem/8049753>, where float property is applied on a text n ode in a SVG. 896 // See <rdar://problem/8049753>, where float property is applied on a text n ode in a SVG.
897 if (!parent() || !parent()->isLayoutBlockFlow()) 897 if (!parent() || !parent()->isLayoutBlockFlow())
898 return; 898 return;
899 899
900 // Attempt to locate a previous sibling with overhanging floats. We skip any elements that 900 // Attempt to locate a previous sibling with overhanging floats. We skip any elements that
901 // may have shifted to avoid floats, and any objects whose floats cannot int eract with objects 901 // may have shifted to avoid floats, and any objects whose floats cannot int eract with objects
902 // outside it (i.e. objects that create a new block formatting context). 902 // outside it (i.e. objects that create a new block formatting context).
903 LayoutBlockFlow* parentBlockFlow = toLayoutBlockFlow(parent()); 903 LayoutBlockFlow* parentBlockFlow = toLayoutBlockFlow(parent());
904 bool parentHasFloats = false; 904 bool siblingFloatMayIntrude = false;
905 LayoutObject* prev = previousSibling(); 905 LayoutObject* prev = previousSibling();
906 while (prev && (!prev->isBox() || !prev->isLayoutBlock() || toLayoutBlock(pr ev)->avoidsFloats() || toLayoutBlock(prev)->createsNewFormattingContext())) { 906 while (prev && (!prev->isBox() || !prev->isLayoutBlock() || toLayoutBlock(pr ev)->avoidsFloats() || toLayoutBlock(prev)->createsNewFormattingContext())) {
907 if (prev->isFloating()) 907 if (prev->isFloating())
908 parentHasFloats = true; 908 siblingFloatMayIntrude = true;
909 prev = prev->previousSibling(); 909 prev = prev->previousSibling();
910 } 910 }
911 911
912 // First add in floats from the parent. Self-collapsing blocks let their par ent track any floats that intrude into 912 // First add in floats from the parent. Self-collapsing blocks let their par ent track any floats that intrude into
913 // them (as opposed to floats they contain themselves) so check for those he re too. 913 // them (as opposed to floats they contain themselves) so check for those he re too. If margin collapsing has moved
914 // us up past the top a previous sibling then we need to check for floats fr om the parent too.
914 LayoutUnit logicalTopOffset = logicalTop(); 915 LayoutUnit logicalTopOffset = logicalTop();
915 bool parentHasIntrudingFloats = !parentHasFloats && (!prev || toLayoutBlockF low(prev)->isSelfCollapsingBlock()) && parentBlockFlow->lowestFloatLogicalBottom () > logicalTopOffset; 916 bool parentFloatsMayIntrude = !siblingFloatMayIntrude && (!prev || toLayoutB lockFlow(prev)->isSelfCollapsingBlock() || toLayoutBlock(prev)->logicalTop() > l ogicalTopOffset)
916 if (parentHasFloats || parentHasIntrudingFloats) 917 && parentBlockFlow->lowestFloatLogicalBottom() > logicalTopOffset;
918 if (siblingFloatMayIntrude || parentFloatsMayIntrude)
917 addIntrudingFloats(parentBlockFlow, parentBlockFlow->logicalLeftOffsetFo rContent(), logicalTopOffset); 919 addIntrudingFloats(parentBlockFlow, parentBlockFlow->logicalLeftOffsetFo rContent(), logicalTopOffset);
918 920
919 // Add overhanging floats from the previous LayoutBlockFlow, but only if it has a float that intrudes into our space. 921 // Add overhanging floats from the previous LayoutBlockFlow, but only if it has a float that intrudes into our space.
920 if (prev) { 922 if (prev) {
921 LayoutBlockFlow* blockFlow = toLayoutBlockFlow(prev); 923 LayoutBlockFlow* blockFlow = toLayoutBlockFlow(prev);
922 logicalTopOffset -= blockFlow->logicalTop(); 924 logicalTopOffset -= blockFlow->logicalTop();
923 if (blockFlow->lowestFloatLogicalBottom() > logicalTopOffset) 925 if (blockFlow->lowestFloatLogicalBottom() > logicalTopOffset)
924 addIntrudingFloats(blockFlow, LayoutUnit(), logicalTopOffset); 926 addIntrudingFloats(blockFlow, LayoutUnit(), logicalTopOffset);
925 } 927 }
926 928
(...skipping 1929 matching lines...) Expand 10 before | Expand all | Expand 10 after
2856 FrameView* frameView = document().view(); 2858 FrameView* frameView = document().view();
2857 LayoutUnit top = LayoutUnit((style()->position() == FixedPosition) ? 0 : fra meView->scrollOffset().height()); 2859 LayoutUnit top = LayoutUnit((style()->position() == FixedPosition) ? 0 : fra meView->scrollOffset().height());
2858 int visibleHeight = frameView->visibleContentRect(IncludeScrollbars).height( ); 2860 int visibleHeight = frameView->visibleContentRect(IncludeScrollbars).height( );
2859 if (size().height() < visibleHeight) 2861 if (size().height() < visibleHeight)
2860 top += (visibleHeight - size().height()) / 2; 2862 top += (visibleHeight - size().height()) / 2;
2861 setY(top); 2863 setY(top);
2862 dialog->setCentered(top); 2864 dialog->setCentered(top);
2863 } 2865 }
2864 2866
2865 } // namespace blink 2867 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/fast/block/float/block-with-negative-margin-clears-float-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698