| 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 883 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 Loading... |
| 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 |
| OLD | NEW |