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 757 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
768 } | 768 } |
769 } | 769 } |
770 | 770 |
771 // Similar to how we apply clearance. Go ahead and boost height() to be the
place where we're going to position the child. | 771 // Similar to how we apply clearance. Go ahead and boost height() to be the
place where we're going to position the child. |
772 setLogicalHeight(logicalHeight() + (result - oldTop)); | 772 setLogicalHeight(logicalHeight() + (result - oldTop)); |
773 | 773 |
774 // Return the final adjusted logical top. | 774 // Return the final adjusted logical top. |
775 return result; | 775 return result; |
776 } | 776 } |
777 | 777 |
778 static inline LayoutUnit calculateMinimumPageHeight(const LayoutStyle& style, Ro
otInlineBox* lastLine, LayoutUnit lineTop, LayoutUnit lineBottom) | 778 static inline LayoutUnit calculateMinimumPageHeight(const ComputedStyle& style,
RootInlineBox* lastLine, LayoutUnit lineTop, LayoutUnit lineBottom) |
779 { | 779 { |
780 // We may require a certain minimum number of lines per page in order to sat
isfy | 780 // We may require a certain minimum number of lines per page in order to sat
isfy |
781 // orphans and widows, and that may affect the minimum page height. | 781 // orphans and widows, and that may affect the minimum page height. |
782 unsigned lineCount = std::max<unsigned>(style.hasAutoOrphans() ? 1 : style.o
rphans(), style.widows()); | 782 unsigned lineCount = std::max<unsigned>(style.hasAutoOrphans() ? 1 : style.o
rphans(), style.widows()); |
783 if (lineCount > 1) { | 783 if (lineCount > 1) { |
784 RootInlineBox* line = lastLine; | 784 RootInlineBox* line = lastLine; |
785 for (unsigned i = 1; i < lineCount && line->prevRootBox(); i++) | 785 for (unsigned i = 1; i < lineCount && line->prevRootBox(); i++) |
786 line = line->prevRootBox(); | 786 line = line->prevRootBox(); |
787 | 787 |
788 // FIXME: Paginating using line overflow isn't all fine. See FIXME in | 788 // FIXME: Paginating using line overflow isn't all fine. See FIXME in |
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1082 // Our MarginInfo state used when laying out block children. | 1082 // Our MarginInfo state used when laying out block children. |
1083 MarginInfo::MarginInfo(LayoutBlockFlow* blockFlow, LayoutUnit beforeBorderPaddin
g, LayoutUnit afterBorderPadding) | 1083 MarginInfo::MarginInfo(LayoutBlockFlow* blockFlow, LayoutUnit beforeBorderPaddin
g, LayoutUnit afterBorderPadding) |
1084 : m_canCollapseMarginAfterWithLastChild(true) | 1084 : m_canCollapseMarginAfterWithLastChild(true) |
1085 , m_atBeforeSideOfBlock(true) | 1085 , m_atBeforeSideOfBlock(true) |
1086 , m_atAfterSideOfBlock(false) | 1086 , m_atAfterSideOfBlock(false) |
1087 , m_hasMarginBeforeQuirk(false) | 1087 , m_hasMarginBeforeQuirk(false) |
1088 , m_hasMarginAfterQuirk(false) | 1088 , m_hasMarginAfterQuirk(false) |
1089 , m_determinedMarginBeforeQuirk(false) | 1089 , m_determinedMarginBeforeQuirk(false) |
1090 , m_discardMargin(false) | 1090 , m_discardMargin(false) |
1091 { | 1091 { |
1092 const LayoutStyle& blockStyle = blockFlow->styleRef(); | 1092 const ComputedStyle& blockStyle = blockFlow->styleRef(); |
1093 ASSERT(blockFlow->isLayoutView() || blockFlow->parent()); | 1093 ASSERT(blockFlow->isLayoutView() || blockFlow->parent()); |
1094 m_canCollapseWithChildren = !blockFlow->createsNewFormattingContext() && !bl
ockFlow->isLayoutFlowThread() && !blockFlow->isLayoutView(); | 1094 m_canCollapseWithChildren = !blockFlow->createsNewFormattingContext() && !bl
ockFlow->isLayoutFlowThread() && !blockFlow->isLayoutView(); |
1095 | 1095 |
1096 m_canCollapseMarginBeforeWithChildren = m_canCollapseWithChildren && !before
BorderPadding && blockStyle.marginBeforeCollapse() != MSEPARATE; | 1096 m_canCollapseMarginBeforeWithChildren = m_canCollapseWithChildren && !before
BorderPadding && blockStyle.marginBeforeCollapse() != MSEPARATE; |
1097 | 1097 |
1098 // If any height other than auto is specified in CSS, then we don't collapse
our bottom | 1098 // If any height other than auto is specified in CSS, then we don't collapse
our bottom |
1099 // margins with our children's margins. To do otherwise would be to risk odd
visual | 1099 // margins with our children's margins. To do otherwise would be to risk odd
visual |
1100 // effects when the children overflow out of the parent block and yet still
collapse | 1100 // effects when the children overflow out of the parent block and yet still
collapse |
1101 // with it. We also don't collapse if we have any bottom border/padding. | 1101 // with it. We also don't collapse if we have any bottom border/padding. |
1102 m_canCollapseMarginAfterWithChildren = m_canCollapseWithChildren && !afterBo
rderPadding | 1102 m_canCollapseMarginAfterWithChildren = m_canCollapseWithChildren && !afterBo
rderPadding |
(...skipping 591 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1694 return; | 1694 return; |
1695 m_rareData = adoptPtr(new LayoutBlockFlowRareData(this)); | 1695 m_rareData = adoptPtr(new LayoutBlockFlowRareData(this)); |
1696 } | 1696 } |
1697 m_rareData->m_margins.setPositiveMarginAfter(pos); | 1697 m_rareData->m_margins.setPositiveMarginAfter(pos); |
1698 m_rareData->m_margins.setNegativeMarginAfter(neg); | 1698 m_rareData->m_margins.setNegativeMarginAfter(neg); |
1699 } | 1699 } |
1700 | 1700 |
1701 bool LayoutBlockFlow::mustSeparateMarginBeforeForChild(const LayoutBox& child) c
onst | 1701 bool LayoutBlockFlow::mustSeparateMarginBeforeForChild(const LayoutBox& child) c
onst |
1702 { | 1702 { |
1703 ASSERT(!child.selfNeedsLayout()); | 1703 ASSERT(!child.selfNeedsLayout()); |
1704 const LayoutStyle& childStyle = child.styleRef(); | 1704 const ComputedStyle& childStyle = child.styleRef(); |
1705 if (!child.isWritingModeRoot()) | 1705 if (!child.isWritingModeRoot()) |
1706 return childStyle.marginBeforeCollapse() == MSEPARATE; | 1706 return childStyle.marginBeforeCollapse() == MSEPARATE; |
1707 if (child.isHorizontalWritingMode() == isHorizontalWritingMode()) | 1707 if (child.isHorizontalWritingMode() == isHorizontalWritingMode()) |
1708 return childStyle.marginAfterCollapse() == MSEPARATE; | 1708 return childStyle.marginAfterCollapse() == MSEPARATE; |
1709 | 1709 |
1710 // FIXME: See |mustDiscardMarginBeforeForChild| above. | 1710 // FIXME: See |mustDiscardMarginBeforeForChild| above. |
1711 return false; | 1711 return false; |
1712 } | 1712 } |
1713 | 1713 |
1714 bool LayoutBlockFlow::mustSeparateMarginAfterForChild(const LayoutBox& child) co
nst | 1714 bool LayoutBlockFlow::mustSeparateMarginAfterForChild(const LayoutBox& child) co
nst |
1715 { | 1715 { |
1716 ASSERT(!child.selfNeedsLayout()); | 1716 ASSERT(!child.selfNeedsLayout()); |
1717 const LayoutStyle& childStyle = child.styleRef(); | 1717 const ComputedStyle& childStyle = child.styleRef(); |
1718 if (!child.isWritingModeRoot()) | 1718 if (!child.isWritingModeRoot()) |
1719 return childStyle.marginAfterCollapse() == MSEPARATE; | 1719 return childStyle.marginAfterCollapse() == MSEPARATE; |
1720 if (child.isHorizontalWritingMode() == isHorizontalWritingMode()) | 1720 if (child.isHorizontalWritingMode() == isHorizontalWritingMode()) |
1721 return childStyle.marginBeforeCollapse() == MSEPARATE; | 1721 return childStyle.marginBeforeCollapse() == MSEPARATE; |
1722 | 1722 |
1723 // FIXME: See |mustDiscardMarginBeforeForChild| above. | 1723 // FIXME: See |mustDiscardMarginBeforeForChild| above. |
1724 return false; | 1724 return false; |
1725 } | 1725 } |
1726 | 1726 |
1727 LayoutUnit LayoutBlockFlow::applyBeforeBreak(LayoutBox& child, LayoutUnit logica
lOffset) | 1727 LayoutUnit LayoutBlockFlow::applyBeforeBreak(LayoutBox& child, LayoutUnit logica
lOffset) |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1924 ASSERT_NOT_REACHED(); | 1924 ASSERT_NOT_REACHED(); |
1925 } | 1925 } |
1926 return result; | 1926 return result; |
1927 } | 1927 } |
1928 | 1928 |
1929 void LayoutBlockFlow::createFloatingObjects() | 1929 void LayoutBlockFlow::createFloatingObjects() |
1930 { | 1930 { |
1931 m_floatingObjects = adoptPtr(new FloatingObjects(this, isHorizontalWritingMo
de())); | 1931 m_floatingObjects = adoptPtr(new FloatingObjects(this, isHorizontalWritingMo
de())); |
1932 } | 1932 } |
1933 | 1933 |
1934 void LayoutBlockFlow::styleWillChange(StyleDifference diff, const LayoutStyle& n
ewStyle) | 1934 void LayoutBlockFlow::styleWillChange(StyleDifference diff, const ComputedStyle&
newStyle) |
1935 { | 1935 { |
1936 const LayoutStyle* oldStyle = style(); | 1936 const ComputedStyle* oldStyle = style(); |
1937 s_canPropagateFloatIntoSibling = oldStyle ? !isFloatingOrOutOfFlowPositioned
() && !avoidsFloats() : false; | 1937 s_canPropagateFloatIntoSibling = oldStyle ? !isFloatingOrOutOfFlowPositioned
() && !avoidsFloats() : false; |
1938 if (oldStyle && parent() && diff.needsFullLayout() && oldStyle->position() !
= newStyle.position() | 1938 if (oldStyle && parent() && diff.needsFullLayout() && oldStyle->position() !
= newStyle.position() |
1939 && containsFloats() && !isFloating() && !isOutOfFlowPositioned() && newS
tyle.hasOutOfFlowPosition()) | 1939 && containsFloats() && !isFloating() && !isOutOfFlowPositioned() && newS
tyle.hasOutOfFlowPosition()) |
1940 markAllDescendantsWithFloatsForLayout(); | 1940 markAllDescendantsWithFloatsForLayout(); |
1941 | 1941 |
1942 LayoutBlock::styleWillChange(diff, newStyle); | 1942 LayoutBlock::styleWillChange(diff, newStyle); |
1943 } | 1943 } |
1944 | 1944 |
1945 void LayoutBlockFlow::styleDidChange(StyleDifference diff, const LayoutStyle* ol
dStyle) | 1945 void LayoutBlockFlow::styleDidChange(StyleDifference diff, const ComputedStyle*
oldStyle) |
1946 { | 1946 { |
1947 LayoutBlock::styleDidChange(diff, oldStyle); | 1947 LayoutBlock::styleDidChange(diff, oldStyle); |
1948 | 1948 |
1949 // After our style changed, if we lose our ability to propagate floats into
next sibling | 1949 // After our style changed, if we lose our ability to propagate floats into
next sibling |
1950 // blocks, then we need to find the top most parent containing that overhang
ing float and | 1950 // blocks, then we need to find the top most parent containing that overhang
ing float and |
1951 // then mark its descendants with floats for layout and clear all floats fro
m its next | 1951 // then mark its descendants with floats for layout and clear all floats fro
m its next |
1952 // sibling blocks that exist in our floating objects list. See bug 56299 and
62875. | 1952 // sibling blocks that exist in our floating objects list. See bug 56299 and
62875. |
1953 bool canPropagateFloatIntoSibling = !isFloatingOrOutOfFlowPositioned() && !a
voidsFloats(); | 1953 bool canPropagateFloatIntoSibling = !isFloatingOrOutOfFlowPositioned() && !a
voidsFloats(); |
1954 if (diff.needsFullLayout() && s_canPropagateFloatIntoSibling && !canPropagat
eFloatIntoSibling && hasOverhangingFloats()) { | 1954 if (diff.needsFullLayout() && s_canPropagateFloatIntoSibling && !canPropagat
eFloatIntoSibling && hasOverhangingFloats()) { |
1955 LayoutBlockFlow* parentBlockFlow = this; | 1955 LayoutBlockFlow* parentBlockFlow = this; |
(...skipping 1078 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3034 cb = cb->containingBlock(); | 3034 cb = cb->containingBlock(); |
3035 } | 3035 } |
3036 return logicalRight; | 3036 return logicalRight; |
3037 } | 3037 } |
3038 | 3038 |
3039 RootInlineBox* LayoutBlockFlow::createRootInlineBox() | 3039 RootInlineBox* LayoutBlockFlow::createRootInlineBox() |
3040 { | 3040 { |
3041 return new RootInlineBox(*this); | 3041 return new RootInlineBox(*this); |
3042 } | 3042 } |
3043 | 3043 |
3044 bool LayoutBlockFlow::isPagedOverflow(const LayoutStyle& style) | 3044 bool LayoutBlockFlow::isPagedOverflow(const ComputedStyle& style) |
3045 { | 3045 { |
3046 return style.isOverflowPaged() && node() != document().viewportDefiningEleme
nt(); | 3046 return style.isOverflowPaged() && node() != document().viewportDefiningEleme
nt(); |
3047 } | 3047 } |
3048 | 3048 |
3049 LayoutBlockFlow::FlowThreadType LayoutBlockFlow::flowThreadType(const LayoutStyl
e& style) | 3049 LayoutBlockFlow::FlowThreadType LayoutBlockFlow::flowThreadType(const ComputedSt
yle& style) |
3050 { | 3050 { |
3051 if (isPagedOverflow(style)) | 3051 if (isPagedOverflow(style)) |
3052 return PagedFlowThread; | 3052 return PagedFlowThread; |
3053 if (style.specifiesColumns()) | 3053 if (style.specifiesColumns()) |
3054 return MultiColumnFlowThread; | 3054 return MultiColumnFlowThread; |
3055 return NoFlowThread; | 3055 return NoFlowThread; |
3056 } | 3056 } |
3057 | 3057 |
3058 LayoutMultiColumnFlowThread* LayoutBlockFlow::createMultiColumnFlowThread(FlowTh
readType type) | 3058 LayoutMultiColumnFlowThread* LayoutBlockFlow::createMultiColumnFlowThread(FlowTh
readType type) |
3059 { | 3059 { |
3060 switch (type) { | 3060 switch (type) { |
3061 case MultiColumnFlowThread: | 3061 case MultiColumnFlowThread: |
3062 return LayoutMultiColumnFlowThread::createAnonymous(document(), styleRef
()); | 3062 return LayoutMultiColumnFlowThread::createAnonymous(document(), styleRef
()); |
3063 case PagedFlowThread: | 3063 case PagedFlowThread: |
3064 // Paged overflow is currently done using the multicol implementation. | 3064 // Paged overflow is currently done using the multicol implementation. |
3065 return LayoutPagedFlowThread::createAnonymous(document(), styleRef()); | 3065 return LayoutPagedFlowThread::createAnonymous(document(), styleRef()); |
3066 default: | 3066 default: |
3067 ASSERT_NOT_REACHED(); | 3067 ASSERT_NOT_REACHED(); |
3068 return nullptr; | 3068 return nullptr; |
3069 } | 3069 } |
3070 } | 3070 } |
3071 | 3071 |
3072 void LayoutBlockFlow::createOrDestroyMultiColumnFlowThreadIfNeeded(const LayoutS
tyle* oldStyle) | 3072 void LayoutBlockFlow::createOrDestroyMultiColumnFlowThreadIfNeeded(const Compute
dStyle* oldStyle) |
3073 { | 3073 { |
3074 if (!RuntimeEnabledFeatures::regionBasedColumnsEnabled()) | 3074 if (!RuntimeEnabledFeatures::regionBasedColumnsEnabled()) |
3075 return; | 3075 return; |
3076 | 3076 |
3077 // Paged overflow trumps multicol in this implementation. Ideally, it should
be possible to have | 3077 // Paged overflow trumps multicol in this implementation. Ideally, it should
be possible to have |
3078 // both paged overflow and multicol on the same element, but then we need tw
o flow | 3078 // both paged overflow and multicol on the same element, but then we need tw
o flow |
3079 // threads. Anyway, this is nothing to worry about until we can actually nes
t multicol properly | 3079 // threads. Anyway, this is nothing to worry about until we can actually nes
t multicol properly |
3080 // inside other fragmentation contexts. | 3080 // inside other fragmentation contexts. |
3081 FlowThreadType type = flowThreadType(styleRef()); | 3081 FlowThreadType type = flowThreadType(styleRef()); |
3082 | 3082 |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3156 } | 3156 } |
3157 if (isAnonymous()) | 3157 if (isAnonymous()) |
3158 return "LayoutBlockFlow (anonymous)"; | 3158 return "LayoutBlockFlow (anonymous)"; |
3159 if (isRelPositioned()) | 3159 if (isRelPositioned()) |
3160 return "LayoutBlockFlow (relative positioned)"; | 3160 return "LayoutBlockFlow (relative positioned)"; |
3161 return "LayoutBlockFlow"; | 3161 return "LayoutBlockFlow"; |
3162 } | 3162 } |
3163 | 3163 |
3164 | 3164 |
3165 } // namespace blink | 3165 } // namespace blink |
OLD | NEW |