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 823 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
834 void LayoutBlockFlow::rebuildFloatsFromIntruding() | 834 void LayoutBlockFlow::rebuildFloatsFromIntruding() |
835 { | 835 { |
836 if (m_floatingObjects) | 836 if (m_floatingObjects) |
837 m_floatingObjects->setHorizontalWritingMode(isHorizontalWritingMode()); | 837 m_floatingObjects->setHorizontalWritingMode(isHorizontalWritingMode()); |
838 | 838 |
839 HashSet<LayoutBox*> oldIntrudingFloatSet; | 839 HashSet<LayoutBox*> oldIntrudingFloatSet; |
840 if (!childrenInline() && m_floatingObjects) { | 840 if (!childrenInline() && m_floatingObjects) { |
841 const FloatingObjectSet& floatingObjectSet = m_floatingObjects->set(); | 841 const FloatingObjectSet& floatingObjectSet = m_floatingObjects->set(); |
842 FloatingObjectSetIterator end = floatingObjectSet.end(); | 842 FloatingObjectSetIterator end = floatingObjectSet.end(); |
843 for (FloatingObjectSetIterator it = floatingObjectSet.begin(); it != end
; ++it) { | 843 for (FloatingObjectSetIterator it = floatingObjectSet.begin(); it != end
; ++it) { |
844 FloatingObject* floatingObject = it->get(); | 844 const FloatingObject& floatingObject = *it->get(); |
845 if (!floatingObject->isDescendant()) | 845 if (!floatingObject.isDescendant()) |
846 oldIntrudingFloatSet.add(floatingObject->layoutObject()); | 846 oldIntrudingFloatSet.add(floatingObject.layoutObject()); |
847 } | 847 } |
848 } | 848 } |
849 | 849 |
850 // Inline blocks are covered by the isReplaced() check in the avoidFloats me
thod. | 850 // Inline blocks are covered by the isReplaced() check in the avoidFloats me
thod. |
851 if (avoidsFloats() || isDocumentElement() || isLayoutView() || isFloatingOrO
utOfFlowPositioned() || isTableCell()) { | 851 if (avoidsFloats() || isDocumentElement() || isLayoutView() || isFloatingOrO
utOfFlowPositioned() || isTableCell()) { |
852 if (m_floatingObjects) { | 852 if (m_floatingObjects) { |
853 m_floatingObjects->clear(); | 853 m_floatingObjects->clear(); |
854 } | 854 } |
855 if (!oldIntrudingFloatSet.isEmpty()) | 855 if (!oldIntrudingFloatSet.isEmpty()) |
856 markAllDescendantsWithFloatsForLayout(); | 856 markAllDescendantsWithFloatsForLayout(); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
899 addIntrudingFloats(blockFlow, 0, logicalTopOffset); | 899 addIntrudingFloats(blockFlow, 0, logicalTopOffset); |
900 } | 900 } |
901 | 901 |
902 if (childrenInline()) { | 902 if (childrenInline()) { |
903 LayoutUnit changeLogicalTop = LayoutUnit::max(); | 903 LayoutUnit changeLogicalTop = LayoutUnit::max(); |
904 LayoutUnit changeLogicalBottom = LayoutUnit::min(); | 904 LayoutUnit changeLogicalBottom = LayoutUnit::min(); |
905 if (m_floatingObjects) { | 905 if (m_floatingObjects) { |
906 const FloatingObjectSet& floatingObjectSet = m_floatingObjects->set(
); | 906 const FloatingObjectSet& floatingObjectSet = m_floatingObjects->set(
); |
907 FloatingObjectSetIterator end = floatingObjectSet.end(); | 907 FloatingObjectSetIterator end = floatingObjectSet.end(); |
908 for (FloatingObjectSetIterator it = floatingObjectSet.begin(); it !=
end; ++it) { | 908 for (FloatingObjectSetIterator it = floatingObjectSet.begin(); it !=
end; ++it) { |
909 FloatingObject* floatingObject = it->get(); | 909 const FloatingObject& floatingObject = *it->get(); |
910 FloatingObject* oldFloatingObject = floatMap.get(floatingObject-
>layoutObject()); | 910 FloatingObject* oldFloatingObject = floatMap.get(floatingObject.
layoutObject()); |
911 LayoutUnit logicalBottom = logicalBottomForFloat(floatingObject)
; | 911 LayoutUnit logicalBottom = logicalBottomForFloat(floatingObject)
; |
912 if (oldFloatingObject) { | 912 if (oldFloatingObject) { |
913 LayoutUnit oldLogicalBottom = logicalBottomForFloat(oldFloat
ingObject); | 913 LayoutUnit oldLogicalBottom = logicalBottomForFloat(*oldFloa
tingObject); |
914 if (logicalWidthForFloat(floatingObject) != logicalWidthForF
loat(oldFloatingObject) || logicalLeftForFloat(floatingObject) != logicalLeftFor
Float(oldFloatingObject)) { | 914 if (logicalWidthForFloat(floatingObject) != logicalWidthForF
loat(*oldFloatingObject) || logicalLeftForFloat(floatingObject) != logicalLeftFo
rFloat(*oldFloatingObject)) { |
915 changeLogicalTop = 0; | 915 changeLogicalTop = 0; |
916 changeLogicalBottom = std::max(changeLogicalBottom, std:
:max(logicalBottom, oldLogicalBottom)); | 916 changeLogicalBottom = std::max(changeLogicalBottom, std:
:max(logicalBottom, oldLogicalBottom)); |
917 } else { | 917 } else { |
918 if (logicalBottom != oldLogicalBottom) { | 918 if (logicalBottom != oldLogicalBottom) { |
919 changeLogicalTop = std::min(changeLogicalTop, std::m
in(logicalBottom, oldLogicalBottom)); | 919 changeLogicalTop = std::min(changeLogicalTop, std::m
in(logicalBottom, oldLogicalBottom)); |
920 changeLogicalBottom = std::max(changeLogicalBottom,
std::max(logicalBottom, oldLogicalBottom)); | 920 changeLogicalBottom = std::max(changeLogicalBottom,
std::max(logicalBottom, oldLogicalBottom)); |
921 } | 921 } |
922 LayoutUnit logicalTop = logicalTopForFloat(floatingObjec
t); | 922 LayoutUnit logicalTop = logicalTopForFloat(floatingObjec
t); |
923 LayoutUnit oldLogicalTop = logicalTopForFloat(oldFloatin
gObject); | 923 LayoutUnit oldLogicalTop = logicalTopForFloat(*oldFloati
ngObject); |
924 if (logicalTop != oldLogicalTop) { | 924 if (logicalTop != oldLogicalTop) { |
925 changeLogicalTop = std::min(changeLogicalTop, std::m
in(logicalTop, oldLogicalTop)); | 925 changeLogicalTop = std::min(changeLogicalTop, std::m
in(logicalTop, oldLogicalTop)); |
926 changeLogicalBottom = std::max(changeLogicalBottom,
std::max(logicalTop, oldLogicalTop)); | 926 changeLogicalBottom = std::max(changeLogicalBottom,
std::max(logicalTop, oldLogicalTop)); |
927 } | 927 } |
928 } | 928 } |
929 | 929 |
930 if (oldFloatingObject->originatingLine() && !selfNeedsLayout
()) { | 930 if (oldFloatingObject->originatingLine() && !selfNeedsLayout
()) { |
931 ASSERT(oldFloatingObject->originatingLine()->layoutObjec
t() == this); | 931 ASSERT(oldFloatingObject->originatingLine()->layoutObjec
t() == this); |
932 oldFloatingObject->originatingLine()->markDirty(); | 932 oldFloatingObject->originatingLine()->markDirty(); |
933 } | 933 } |
934 | 934 |
935 floatMap.remove(floatingObject->layoutObject()); | 935 floatMap.remove(floatingObject.layoutObject()); |
936 } else { | 936 } else { |
937 changeLogicalTop = 0; | 937 changeLogicalTop = 0; |
938 changeLogicalBottom = std::max(changeLogicalBottom, logicalB
ottom); | 938 changeLogicalBottom = std::max(changeLogicalBottom, logicalB
ottom); |
939 } | 939 } |
940 } | 940 } |
941 } | 941 } |
942 | 942 |
943 LayoutBoxToFloatInfoMap::iterator end = floatMap.end(); | 943 LayoutBoxToFloatInfoMap::iterator end = floatMap.end(); |
944 for (LayoutBoxToFloatInfoMap::iterator it = floatMap.begin(); it != end;
++it) { | 944 for (LayoutBoxToFloatInfoMap::iterator it = floatMap.begin(); it != end;
++it) { |
945 OwnPtr<FloatingObject>& floatingObject = it->value; | 945 OwnPtr<FloatingObject>& floatingObject = it->value; |
946 if (!floatingObject->isDescendant()) { | 946 if (!floatingObject->isDescendant()) { |
947 changeLogicalTop = 0; | 947 changeLogicalTop = 0; |
948 changeLogicalBottom = std::max(changeLogicalBottom, logicalBotto
mForFloat(floatingObject.get())); | 948 changeLogicalBottom = std::max(changeLogicalBottom, logicalBotto
mForFloat(*floatingObject)); |
949 } | 949 } |
950 } | 950 } |
951 | 951 |
952 markLinesDirtyInBlockRange(changeLogicalTop, changeLogicalBottom); | 952 markLinesDirtyInBlockRange(changeLogicalTop, changeLogicalBottom); |
953 } else if (!oldIntrudingFloatSet.isEmpty()) { | 953 } else if (!oldIntrudingFloatSet.isEmpty()) { |
954 // If there are previously intruding floats that no longer intrude, then
children with floats | 954 // If there are previously intruding floats that no longer intrude, then
children with floats |
955 // should also get layout because they might need their floating object
lists cleared. | 955 // should also get layout because they might need their floating object
lists cleared. |
956 if (m_floatingObjects->set().size() < oldIntrudingFloatSet.size()) { | 956 if (m_floatingObjects->set().size() < oldIntrudingFloatSet.size()) { |
957 markAllDescendantsWithFloatsForLayout(); | 957 markAllDescendantsWithFloatsForLayout(); |
958 } else { | 958 } else { |
(...skipping 756 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1715 } | 1715 } |
1716 | 1716 |
1717 void LayoutBlockFlow::addOverflowFromFloats() | 1717 void LayoutBlockFlow::addOverflowFromFloats() |
1718 { | 1718 { |
1719 if (!m_floatingObjects) | 1719 if (!m_floatingObjects) |
1720 return; | 1720 return; |
1721 | 1721 |
1722 const FloatingObjectSet& floatingObjectSet = m_floatingObjects->set(); | 1722 const FloatingObjectSet& floatingObjectSet = m_floatingObjects->set(); |
1723 FloatingObjectSetIterator end = floatingObjectSet.end(); | 1723 FloatingObjectSetIterator end = floatingObjectSet.end(); |
1724 for (FloatingObjectSetIterator it = floatingObjectSet.begin(); it != end; ++
it) { | 1724 for (FloatingObjectSetIterator it = floatingObjectSet.begin(); it != end; ++
it) { |
1725 FloatingObject* floatingObject = it->get(); | 1725 const FloatingObject& floatingObject = *it->get(); |
1726 if (floatingObject->isDescendant()) | 1726 if (floatingObject.isDescendant()) |
1727 addOverflowFromChild(floatingObject->layoutObject(), LayoutSize(xPos
itionForFloatIncludingMargin(floatingObject), yPositionForFloatIncludingMargin(f
loatingObject))); | 1727 addOverflowFromChild(floatingObject.layoutObject(), LayoutSize(xPosi
tionForFloatIncludingMargin(floatingObject), yPositionForFloatIncludingMargin(fl
oatingObject))); |
1728 } | 1728 } |
1729 } | 1729 } |
1730 | 1730 |
1731 void LayoutBlockFlow::computeOverflow(LayoutUnit oldClientAfterEdge, bool recomp
uteFloats) | 1731 void LayoutBlockFlow::computeOverflow(LayoutUnit oldClientAfterEdge, bool recomp
uteFloats) |
1732 { | 1732 { |
1733 LayoutBlock::computeOverflow(oldClientAfterEdge, recomputeFloats); | 1733 LayoutBlock::computeOverflow(oldClientAfterEdge, recomputeFloats); |
1734 if (recomputeFloats || createsNewFormattingContext() || hasSelfPaintingLayer
()) | 1734 if (recomputeFloats || createsNewFormattingContext() || hasSelfPaintingLayer
()) |
1735 addOverflowFromFloats(); | 1735 addOverflowFromFloats(); |
1736 } | 1736 } |
1737 | 1737 |
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1983 // displayed. | 1983 // displayed. |
1984 // See bug https://code.google.com/p/chromium/issues/detail?id=230907 | 1984 // See bug https://code.google.com/p/chromium/issues/detail?id=230907 |
1985 if (m_floatingObjects) { | 1985 if (m_floatingObjects) { |
1986 if (!toBlockFlow->m_floatingObjects) | 1986 if (!toBlockFlow->m_floatingObjects) |
1987 toBlockFlow->createFloatingObjects(); | 1987 toBlockFlow->createFloatingObjects(); |
1988 | 1988 |
1989 const FloatingObjectSet& fromFloatingObjectSet = m_floatingObjects->set(
); | 1989 const FloatingObjectSet& fromFloatingObjectSet = m_floatingObjects->set(
); |
1990 FloatingObjectSetIterator end = fromFloatingObjectSet.end(); | 1990 FloatingObjectSetIterator end = fromFloatingObjectSet.end(); |
1991 | 1991 |
1992 for (FloatingObjectSetIterator it = fromFloatingObjectSet.begin(); it !=
end; ++it) { | 1992 for (FloatingObjectSetIterator it = fromFloatingObjectSet.begin(); it !=
end; ++it) { |
1993 FloatingObject* floatingObject = it->get(); | 1993 const FloatingObject& floatingObject = *it->get(); |
1994 | 1994 |
1995 // Don't insert the object again if it's already in the list | 1995 // Don't insert the object again if it's already in the list |
1996 if (toBlockFlow->containsFloat(floatingObject->layoutObject())) | 1996 if (toBlockFlow->containsFloat(floatingObject.layoutObject())) |
1997 continue; | 1997 continue; |
1998 | 1998 |
1999 toBlockFlow->m_floatingObjects->add(floatingObject->unsafeClone()); | 1999 toBlockFlow->m_floatingObjects->add(floatingObject.unsafeClone()); |
2000 } | 2000 } |
2001 } | 2001 } |
2002 | 2002 |
2003 } | 2003 } |
2004 | 2004 |
2005 void LayoutBlockFlow::invalidatePaintForOverhangingFloats(bool paintAllDescendan
ts) | 2005 void LayoutBlockFlow::invalidatePaintForOverhangingFloats(bool paintAllDescendan
ts) |
2006 { | 2006 { |
2007 // Invalidate paint of any overhanging floats (if we know we're the one to p
aint them). | 2007 // Invalidate paint of any overhanging floats (if we know we're the one to p
aint them). |
2008 // Otherwise, bail out. | 2008 // Otherwise, bail out. |
2009 if (!hasOverhangingFloats()) | 2009 if (!hasOverhangingFloats()) |
2010 return; | 2010 return; |
2011 | 2011 |
2012 const FloatingObjectSet& floatingObjectSet = m_floatingObjects->set(); | 2012 const FloatingObjectSet& floatingObjectSet = m_floatingObjects->set(); |
2013 FloatingObjectSetIterator end = floatingObjectSet.end(); | 2013 FloatingObjectSetIterator end = floatingObjectSet.end(); |
2014 for (FloatingObjectSetIterator it = floatingObjectSet.begin(); it != end; ++
it) { | 2014 for (FloatingObjectSetIterator it = floatingObjectSet.begin(); it != end; ++
it) { |
2015 FloatingObject* floatingObject = it->get(); | 2015 const FloatingObject& floatingObject = *it->get(); |
2016 // Only issue paint invaldiations for the object if it is overhanging, i
s not in its own layer, and | 2016 // Only issue paint invaldiations for the object if it is overhanging, i
s not in its own layer, and |
2017 // is our responsibility to paint (m_shouldPaint is set). When paintAllD
escendants is true, the latter | 2017 // is our responsibility to paint (m_shouldPaint is set). When paintAllD
escendants is true, the latter |
2018 // condition is replaced with being a descendant of us. | 2018 // condition is replaced with being a descendant of us. |
2019 if (logicalBottomForFloat(floatingObject) > logicalHeight() | 2019 if (logicalBottomForFloat(floatingObject) > logicalHeight() |
2020 && !floatingObject->layoutObject()->hasSelfPaintingLayer() | 2020 && !floatingObject.layoutObject()->hasSelfPaintingLayer() |
2021 && (floatingObject->shouldPaint() || (paintAllDescendants && floatin
gObject->layoutObject()->isDescendantOf(this)))) { | 2021 && (floatingObject.shouldPaint() || (paintAllDescendants && floating
Object.layoutObject()->isDescendantOf(this)))) { |
2022 | 2022 |
2023 LayoutBox* floatingLayoutBox = floatingObject->layoutObject(); | 2023 LayoutBox* floatingLayoutBox = floatingObject.layoutObject(); |
2024 floatingLayoutBox->setShouldDoFullPaintInvalidation(); | 2024 floatingLayoutBox->setShouldDoFullPaintInvalidation(); |
2025 floatingLayoutBox->invalidatePaintForOverhangingFloats(false); | 2025 floatingLayoutBox->invalidatePaintForOverhangingFloats(false); |
2026 } | 2026 } |
2027 } | 2027 } |
2028 } | 2028 } |
2029 | 2029 |
2030 void LayoutBlockFlow::invalidatePaintForOverflow() | 2030 void LayoutBlockFlow::invalidatePaintForOverflow() |
2031 { | 2031 { |
2032 // FIXME: We could tighten up the left and right invalidation points if we l
et layoutInlineChildren fill them in based off the particular lines | 2032 // FIXME: We could tighten up the left and right invalidation points if we l
et layoutInlineChildren fill them in based off the particular lines |
2033 // it had to lay out. We wouldn't need the hasOverflowClip() hack in that ca
se either. | 2033 // it had to lay out. We wouldn't need the hasOverflowClip() hack in that ca
se either. |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2081 | 2081 |
2082 void LayoutBlockFlow::clipOutFloatingObjects(const LayoutBlock* rootBlock, ClipS
cope& clipScope, | 2082 void LayoutBlockFlow::clipOutFloatingObjects(const LayoutBlock* rootBlock, ClipS
cope& clipScope, |
2083 const LayoutPoint& rootBlockPhysicalPosition, const LayoutSize& offsetFromRo
otBlock) const | 2083 const LayoutPoint& rootBlockPhysicalPosition, const LayoutSize& offsetFromRo
otBlock) const |
2084 { | 2084 { |
2085 if (!m_floatingObjects) | 2085 if (!m_floatingObjects) |
2086 return; | 2086 return; |
2087 | 2087 |
2088 const FloatingObjectSet& floatingObjectSet = m_floatingObjects->set(); | 2088 const FloatingObjectSet& floatingObjectSet = m_floatingObjects->set(); |
2089 FloatingObjectSetIterator end = floatingObjectSet.end(); | 2089 FloatingObjectSetIterator end = floatingObjectSet.end(); |
2090 for (FloatingObjectSetIterator it = floatingObjectSet.begin(); it != end; ++
it) { | 2090 for (FloatingObjectSetIterator it = floatingObjectSet.begin(); it != end; ++
it) { |
2091 FloatingObject* floatingObject = it->get(); | 2091 const FloatingObject& floatingObject = *it->get(); |
2092 LayoutRect floatBox(LayoutPoint(offsetFromRootBlock), floatingObject->la
youtObject()->size()); | 2092 LayoutRect floatBox(LayoutPoint(offsetFromRootBlock), floatingObject.lay
outObject()->size()); |
2093 floatBox.move(positionForFloatIncludingMargin(floatingObject)); | 2093 floatBox.move(positionForFloatIncludingMargin(floatingObject)); |
2094 rootBlock->flipForWritingMode(floatBox); | 2094 rootBlock->flipForWritingMode(floatBox); |
2095 floatBox.move(rootBlockPhysicalPosition.x(), rootBlockPhysicalPosition.y
()); | 2095 floatBox.move(rootBlockPhysicalPosition.x(), rootBlockPhysicalPosition.y
()); |
2096 | 2096 |
2097 clipScope.clip(floatBox, SkRegion::kDifference_Op); | 2097 clipScope.clip(floatBox, SkRegion::kDifference_Op); |
2098 } | 2098 } |
2099 } | 2099 } |
2100 | 2100 |
2101 void LayoutBlockFlow::clearFloats(EClear clear) | 2101 void LayoutBlockFlow::clearFloats(EClear clear) |
2102 { | 2102 { |
(...skipping 24 matching lines...) Expand all Loading... |
2127 void LayoutBlockFlow::removeFloatingObjects() | 2127 void LayoutBlockFlow::removeFloatingObjects() |
2128 { | 2128 { |
2129 if (!m_floatingObjects) | 2129 if (!m_floatingObjects) |
2130 return; | 2130 return; |
2131 | 2131 |
2132 markSiblingsWithFloatsForLayout(); | 2132 markSiblingsWithFloatsForLayout(); |
2133 | 2133 |
2134 m_floatingObjects->clear(); | 2134 m_floatingObjects->clear(); |
2135 } | 2135 } |
2136 | 2136 |
2137 LayoutPoint LayoutBlockFlow::flipFloatForWritingModeForChild(const FloatingObjec
t* child, const LayoutPoint& point) const | 2137 LayoutPoint LayoutBlockFlow::flipFloatForWritingModeForChild(const FloatingObjec
t& child, const LayoutPoint& point) const |
2138 { | 2138 { |
2139 if (!style()->isFlippedBlocksWritingMode()) | 2139 if (!style()->isFlippedBlocksWritingMode()) |
2140 return point; | 2140 return point; |
2141 | 2141 |
2142 // This is similar to LayoutBox::flipForWritingModeForChild. We have to subt
ract out our left/top offsets twice, since | 2142 // This is similar to LayoutBox::flipForWritingModeForChild. We have to subt
ract out our left/top offsets twice, since |
2143 // it's going to get added back in. We hide this complication here so that t
he calling code looks normal for the unflipped | 2143 // it's going to get added back in. We hide this complication here so that t
he calling code looks normal for the unflipped |
2144 // case. | 2144 // case. |
2145 if (isHorizontalWritingMode()) | 2145 if (isHorizontalWritingMode()) |
2146 return LayoutPoint(point.x(), point.y() + size().height() - child->layou
tObject()->size().height() - 2 * yPositionForFloatIncludingMargin(child)); | 2146 return LayoutPoint(point.x(), point.y() + size().height() - child.layout
Object()->size().height() - 2 * yPositionForFloatIncludingMargin(child)); |
2147 return LayoutPoint(point.x() + size().width() - child->layoutObject()->size(
).width() - 2 * xPositionForFloatIncludingMargin(child), point.y()); | 2147 return LayoutPoint(point.x() + size().width() - child.layoutObject()->size()
.width() - 2 * xPositionForFloatIncludingMargin(child), point.y()); |
2148 } | 2148 } |
2149 | 2149 |
2150 LayoutUnit LayoutBlockFlow::logicalLeftOffsetForPositioningFloat(LayoutUnit logi
calTop, LayoutUnit fixedOffset, bool applyTextIndent, LayoutUnit* heightRemainin
g) const | 2150 LayoutUnit LayoutBlockFlow::logicalLeftOffsetForPositioningFloat(LayoutUnit logi
calTop, LayoutUnit fixedOffset, bool applyTextIndent, LayoutUnit* heightRemainin
g) const |
2151 { | 2151 { |
2152 LayoutUnit offset = fixedOffset; | 2152 LayoutUnit offset = fixedOffset; |
2153 if (m_floatingObjects && m_floatingObjects->hasLeftObjects()) | 2153 if (m_floatingObjects && m_floatingObjects->hasLeftObjects()) |
2154 offset = m_floatingObjects->logicalLeftOffsetForPositioningFloat(fixedOf
fset, logicalTop, heightRemaining); | 2154 offset = m_floatingObjects->logicalLeftOffsetForPositioningFloat(fixedOf
fset, logicalTop, heightRemaining); |
2155 return adjustLogicalLeftOffsetForLine(offset, applyTextIndent); | 2155 return adjustLogicalLeftOffsetForLine(offset, applyTextIndent); |
2156 } | 2156 } |
2157 | 2157 |
(...skipping 18 matching lines...) Expand all Loading... |
2176 LayoutUnit LayoutBlockFlow::adjustLogicalRightOffsetForLine(LayoutUnit offsetFro
mFloats, bool applyTextIndent) const | 2176 LayoutUnit LayoutBlockFlow::adjustLogicalRightOffsetForLine(LayoutUnit offsetFro
mFloats, bool applyTextIndent) const |
2177 { | 2177 { |
2178 LayoutUnit right = offsetFromFloats; | 2178 LayoutUnit right = offsetFromFloats; |
2179 | 2179 |
2180 if (applyTextIndent && !style()->isLeftToRightDirection()) | 2180 if (applyTextIndent && !style()->isLeftToRightDirection()) |
2181 right -= textIndentOffset(); | 2181 right -= textIndentOffset(); |
2182 | 2182 |
2183 return right; | 2183 return right; |
2184 } | 2184 } |
2185 | 2185 |
2186 LayoutPoint LayoutBlockFlow::computeLogicalLocationForFloat(const FloatingObject
* floatingObject, LayoutUnit logicalTopOffset) const | 2186 LayoutPoint LayoutBlockFlow::computeLogicalLocationForFloat(const FloatingObject
& floatingObject, LayoutUnit logicalTopOffset) const |
2187 { | 2187 { |
2188 LayoutBox* childBox = floatingObject->layoutObject(); | 2188 LayoutBox* childBox = floatingObject.layoutObject(); |
2189 LayoutUnit logicalLeftOffset = logicalLeftOffsetForContent(); // Constant pa
rt of left offset. | 2189 LayoutUnit logicalLeftOffset = logicalLeftOffsetForContent(); // Constant pa
rt of left offset. |
2190 LayoutUnit logicalRightOffset; // Constant part of right offset. | 2190 LayoutUnit logicalRightOffset; // Constant part of right offset. |
2191 logicalRightOffset = logicalRightOffsetForContent(); | 2191 logicalRightOffset = logicalRightOffsetForContent(); |
2192 | 2192 |
2193 LayoutUnit floatLogicalWidth = std::min(logicalWidthForFloat(floatingObject)
, logicalRightOffset - logicalLeftOffset); // The width we look for. | 2193 LayoutUnit floatLogicalWidth = std::min(logicalWidthForFloat(floatingObject)
, logicalRightOffset - logicalLeftOffset); // The width we look for. |
2194 | 2194 |
2195 LayoutUnit floatLogicalLeft; | 2195 LayoutUnit floatLogicalLeft; |
2196 | 2196 |
2197 bool insideFlowThread = flowThreadContainingBlock(); | 2197 bool insideFlowThread = flowThreadContainingBlock(); |
2198 | 2198 |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2260 floatBox.setChildNeedsLayout(MarkOnlyThis); | 2260 floatBox.setChildNeedsLayout(MarkOnlyThis); |
2261 | 2261 |
2262 bool needsBlockDirectionLocationSetBeforeLayout = isChildLayoutBlock && view
()->layoutState()->needsBlockDirectionLocationSetBeforeLayout(); | 2262 bool needsBlockDirectionLocationSetBeforeLayout = isChildLayoutBlock && view
()->layoutState()->needsBlockDirectionLocationSetBeforeLayout(); |
2263 if (!needsBlockDirectionLocationSetBeforeLayout || isWritingModeRoot()) { //
We are unsplittable if we're a block flow root. | 2263 if (!needsBlockDirectionLocationSetBeforeLayout || isWritingModeRoot()) { //
We are unsplittable if we're a block flow root. |
2264 floatBox.layoutIfNeeded(); | 2264 floatBox.layoutIfNeeded(); |
2265 } else { | 2265 } else { |
2266 floatBox.updateLogicalWidth(); | 2266 floatBox.updateLogicalWidth(); |
2267 floatBox.computeAndSetBlockDirectionMargins(this); | 2267 floatBox.computeAndSetBlockDirectionMargins(this); |
2268 } | 2268 } |
2269 | 2269 |
2270 setLogicalWidthForFloat(newObj.get(), logicalWidthForChild(floatBox) + margi
nStartForChild(floatBox) + marginEndForChild(floatBox)); | 2270 setLogicalWidthForFloat(*newObj, logicalWidthForChild(floatBox) + marginStar
tForChild(floatBox) + marginEndForChild(floatBox)); |
2271 | 2271 |
2272 return m_floatingObjects->add(newObj.release()); | 2272 return m_floatingObjects->add(newObj.release()); |
2273 } | 2273 } |
2274 | 2274 |
2275 void LayoutBlockFlow::removeFloatingObject(LayoutBox* floatBox) | 2275 void LayoutBlockFlow::removeFloatingObject(LayoutBox* floatBox) |
2276 { | 2276 { |
2277 if (m_floatingObjects) { | 2277 if (m_floatingObjects) { |
2278 const FloatingObjectSet& floatingObjectSet = m_floatingObjects->set(); | 2278 const FloatingObjectSet& floatingObjectSet = m_floatingObjects->set(); |
2279 FloatingObjectSetIterator it = floatingObjectSet.find<FloatingObjectHash
Translator>(floatBox); | 2279 FloatingObjectSetIterator it = floatingObjectSet.find<FloatingObjectHash
Translator>(floatBox); |
2280 if (it != floatingObjectSet.end()) { | 2280 if (it != floatingObjectSet.end()) { |
2281 FloatingObject* floatingObject = it->get(); | 2281 FloatingObject& floatingObject = *it->get(); |
2282 if (childrenInline()) { | 2282 if (childrenInline()) { |
2283 LayoutUnit logicalTop = logicalTopForFloat(floatingObject); | 2283 LayoutUnit logicalTop = logicalTopForFloat(floatingObject); |
2284 LayoutUnit logicalBottom = logicalBottomForFloat(floatingObject)
; | 2284 LayoutUnit logicalBottom = logicalBottomForFloat(floatingObject)
; |
2285 | 2285 |
2286 // Fix for https://bugs.webkit.org/show_bug.cgi?id=54995. | 2286 // Fix for https://bugs.webkit.org/show_bug.cgi?id=54995. |
2287 if (logicalBottom < 0 || logicalBottom < logicalTop || logicalTo
p == LayoutUnit::max()) { | 2287 if (logicalBottom < 0 || logicalBottom < logicalTop || logicalTo
p == LayoutUnit::max()) { |
2288 logicalBottom = LayoutUnit::max(); | 2288 logicalBottom = LayoutUnit::max(); |
2289 } else { | 2289 } else { |
2290 // Special-case zero- and less-than-zero-height floats: thos
e don't touch | 2290 // Special-case zero- and less-than-zero-height floats: thos
e don't touch |
2291 // the line that they're on, but it still needs to be dirtie
d. This is | 2291 // the line that they're on, but it still needs to be dirtie
d. This is |
2292 // accomplished by pretending they have a height of 1. | 2292 // accomplished by pretending they have a height of 1. |
2293 logicalBottom = std::max(logicalBottom, logicalTop + 1); | 2293 logicalBottom = std::max(logicalBottom, logicalTop + 1); |
2294 } | 2294 } |
2295 if (floatingObject->originatingLine()) { | 2295 if (floatingObject.originatingLine()) { |
2296 if (!selfNeedsLayout()) { | 2296 if (!selfNeedsLayout()) { |
2297 ASSERT(floatingObject->originatingLine()->layoutObject()
== this); | 2297 ASSERT(floatingObject.originatingLine()->layoutObject()
== this); |
2298 floatingObject->originatingLine()->markDirty(); | 2298 floatingObject.originatingLine()->markDirty(); |
2299 } | 2299 } |
2300 #if ENABLE(ASSERT) | 2300 #if ENABLE(ASSERT) |
2301 floatingObject->setOriginatingLine(nullptr); | 2301 floatingObject.setOriginatingLine(nullptr); |
2302 #endif | 2302 #endif |
2303 } | 2303 } |
2304 markLinesDirtyInBlockRange(0, logicalBottom); | 2304 markLinesDirtyInBlockRange(0, logicalBottom); |
2305 } | 2305 } |
2306 m_floatingObjects->remove(floatingObject); | 2306 m_floatingObjects->remove(&floatingObject); |
2307 } | 2307 } |
2308 } | 2308 } |
2309 } | 2309 } |
2310 | 2310 |
2311 void LayoutBlockFlow::removeFloatingObjectsBelow(FloatingObject* lastFloat, int
logicalOffset) | 2311 void LayoutBlockFlow::removeFloatingObjectsBelow(FloatingObject* lastFloat, int
logicalOffset) |
2312 { | 2312 { |
2313 if (!containsFloats()) | 2313 if (!containsFloats()) |
2314 return; | 2314 return; |
2315 | 2315 |
2316 const FloatingObjectSet& floatingObjectSet = m_floatingObjects->set(); | 2316 const FloatingObjectSet& floatingObjectSet = m_floatingObjects->set(); |
2317 FloatingObject* curr = floatingObjectSet.last().get(); | 2317 FloatingObject* curr = floatingObjectSet.last().get(); |
2318 while (curr != lastFloat && (!curr->isPlaced() || logicalTopForFloat(curr) >
= logicalOffset)) { | 2318 while (curr != lastFloat && (!curr->isPlaced() || logicalTopForFloat(*curr)
>= logicalOffset)) { |
2319 m_floatingObjects->remove(curr); | 2319 m_floatingObjects->remove(curr); |
2320 if (floatingObjectSet.isEmpty()) | 2320 if (floatingObjectSet.isEmpty()) |
2321 break; | 2321 break; |
2322 curr = floatingObjectSet.last().get(); | 2322 curr = floatingObjectSet.last().get(); |
2323 } | 2323 } |
2324 } | 2324 } |
2325 | 2325 |
2326 bool LayoutBlockFlow::positionNewFloats(LineWidth* width) | 2326 bool LayoutBlockFlow::positionNewFloats(LineWidth* width) |
2327 { | 2327 { |
2328 if (!m_floatingObjects) | 2328 if (!m_floatingObjects) |
(...skipping 20 matching lines...) Expand all Loading... |
2349 lastPlacedFloatingObject = it->get(); | 2349 lastPlacedFloatingObject = it->get(); |
2350 ++it; | 2350 ++it; |
2351 break; | 2351 break; |
2352 } | 2352 } |
2353 } | 2353 } |
2354 | 2354 |
2355 LayoutUnit logicalTop = logicalHeight(); | 2355 LayoutUnit logicalTop = logicalHeight(); |
2356 | 2356 |
2357 // The float cannot start above the top position of the last positioned floa
t. | 2357 // The float cannot start above the top position of the last positioned floa
t. |
2358 if (lastPlacedFloatingObject) | 2358 if (lastPlacedFloatingObject) |
2359 logicalTop = std::max(logicalTopForFloat(lastPlacedFloatingObject), logi
calTop); | 2359 logicalTop = std::max(logicalTopForFloat(*lastPlacedFloatingObject), log
icalTop); |
2360 | 2360 |
2361 FloatingObjectSetIterator end = floatingObjectSet.end(); | 2361 FloatingObjectSetIterator end = floatingObjectSet.end(); |
2362 // Now walk through the set of unpositioned floats and place them. | 2362 // Now walk through the set of unpositioned floats and place them. |
2363 for (; it != end; ++it) { | 2363 for (; it != end; ++it) { |
2364 FloatingObject* floatingObject = it->get(); | 2364 FloatingObject& floatingObject = *it->get(); |
2365 // The containing block is responsible for positioning floats, so if we
have floats in our | 2365 // The containing block is responsible for positioning floats, so if we
have floats in our |
2366 // list that come from somewhere else, do not attempt to position them. | 2366 // list that come from somewhere else, do not attempt to position them. |
2367 if (floatingObject->layoutObject()->containingBlock() != this) | 2367 if (floatingObject.layoutObject()->containingBlock() != this) |
2368 continue; | 2368 continue; |
2369 | 2369 |
2370 LayoutBox* childBox = floatingObject->layoutObject(); | 2370 LayoutBox* childBox = floatingObject.layoutObject(); |
2371 | 2371 |
2372 // FIXME Investigate if this can be removed. crbug.com/370006 | 2372 // FIXME Investigate if this can be removed. crbug.com/370006 |
2373 childBox->setMayNeedPaintInvalidation(); | 2373 childBox->setMayNeedPaintInvalidation(); |
2374 | 2374 |
2375 LayoutUnit childLogicalLeftMargin = style()->isLeftToRightDirection() ?
marginStartForChild(*childBox) : marginEndForChild(*childBox); | 2375 LayoutUnit childLogicalLeftMargin = style()->isLeftToRightDirection() ?
marginStartForChild(*childBox) : marginEndForChild(*childBox); |
2376 if (childBox->style()->clear() & CLEFT) | 2376 if (childBox->style()->clear() & CLEFT) |
2377 logicalTop = std::max(lowestFloatLogicalBottom(FloatingObject::Float
Left), logicalTop); | 2377 logicalTop = std::max(lowestFloatLogicalBottom(FloatingObject::Float
Left), logicalTop); |
2378 if (childBox->style()->clear() & CRIGHT) | 2378 if (childBox->style()->clear() & CRIGHT) |
2379 logicalTop = std::max(lowestFloatLogicalBottom(FloatingObject::Float
Right), logicalTop); | 2379 logicalTop = std::max(lowestFloatLogicalBottom(FloatingObject::Float
Right), logicalTop); |
2380 | 2380 |
(...skipping 20 matching lines...) Expand all Loading... |
2401 // See if we have a pagination strut that is making us move down fur
ther. | 2401 // See if we have a pagination strut that is making us move down fur
ther. |
2402 // Note that an unsplittable child can't also have a pagination stru
t, so this is | 2402 // Note that an unsplittable child can't also have a pagination stru
t, so this is |
2403 // exclusive with the case above. | 2403 // exclusive with the case above. |
2404 LayoutBlockFlow* childBlockFlow = childBox->isLayoutBlockFlow() ? to
LayoutBlockFlow(childBox) : 0; | 2404 LayoutBlockFlow* childBlockFlow = childBox->isLayoutBlockFlow() ? to
LayoutBlockFlow(childBox) : 0; |
2405 if (childBlockFlow && childBlockFlow->paginationStrut()) { | 2405 if (childBlockFlow && childBlockFlow->paginationStrut()) { |
2406 newLogicalTop += childBlockFlow->paginationStrut(); | 2406 newLogicalTop += childBlockFlow->paginationStrut(); |
2407 childBlockFlow->setPaginationStrut(0); | 2407 childBlockFlow->setPaginationStrut(0); |
2408 } | 2408 } |
2409 | 2409 |
2410 if (newLogicalTop != floatLogicalLocation.y()) { | 2410 if (newLogicalTop != floatLogicalLocation.y()) { |
2411 floatingObject->setPaginationStrut(newLogicalTop - floatLogicalL
ocation.y()); | 2411 floatingObject.setPaginationStrut(newLogicalTop - floatLogicalLo
cation.y()); |
2412 | 2412 |
2413 floatLogicalLocation = computeLogicalLocationForFloat(floatingOb
ject, newLogicalTop); | 2413 floatLogicalLocation = computeLogicalLocationForFloat(floatingOb
ject, newLogicalTop); |
2414 setLogicalLeftForFloat(floatingObject, floatLogicalLocation.x())
; | 2414 setLogicalLeftForFloat(floatingObject, floatLogicalLocation.x())
; |
2415 | 2415 |
2416 setLogicalLeftForChild(*childBox, floatLogicalLocation.x() + chi
ldLogicalLeftMargin); | 2416 setLogicalLeftForChild(*childBox, floatLogicalLocation.x() + chi
ldLogicalLeftMargin); |
2417 setLogicalTopForChild(*childBox, floatLogicalLocation.y() + marg
inBeforeForChild(*childBox)); | 2417 setLogicalTopForChild(*childBox, floatLogicalLocation.y() + marg
inBeforeForChild(*childBox)); |
2418 | 2418 |
2419 if (childBox->isLayoutBlock()) | 2419 if (childBox->isLayoutBlock()) |
2420 childBox->setChildNeedsLayout(MarkOnlyThis); | 2420 childBox->setChildNeedsLayout(MarkOnlyThis); |
2421 childBox->layoutIfNeeded(); | 2421 childBox->layoutIfNeeded(); |
(...skipping 18 matching lines...) Expand all Loading... |
2440 bool LayoutBlockFlow::hasOverhangingFloat(LayoutBox* layoutBox) | 2440 bool LayoutBlockFlow::hasOverhangingFloat(LayoutBox* layoutBox) |
2441 { | 2441 { |
2442 if (!m_floatingObjects || !parent()) | 2442 if (!m_floatingObjects || !parent()) |
2443 return false; | 2443 return false; |
2444 | 2444 |
2445 const FloatingObjectSet& floatingObjectSet = m_floatingObjects->set(); | 2445 const FloatingObjectSet& floatingObjectSet = m_floatingObjects->set(); |
2446 FloatingObjectSetIterator it = floatingObjectSet.find<FloatingObjectHashTran
slator>(layoutBox); | 2446 FloatingObjectSetIterator it = floatingObjectSet.find<FloatingObjectHashTran
slator>(layoutBox); |
2447 if (it == floatingObjectSet.end()) | 2447 if (it == floatingObjectSet.end()) |
2448 return false; | 2448 return false; |
2449 | 2449 |
2450 return logicalBottomForFloat(it->get()) > logicalHeight(); | 2450 return logicalBottomForFloat(*it->get()) > logicalHeight(); |
2451 } | 2451 } |
2452 | 2452 |
2453 void LayoutBlockFlow::addIntrudingFloats(LayoutBlockFlow* prev, LayoutUnit logic
alLeftOffset, LayoutUnit logicalTopOffset) | 2453 void LayoutBlockFlow::addIntrudingFloats(LayoutBlockFlow* prev, LayoutUnit logic
alLeftOffset, LayoutUnit logicalTopOffset) |
2454 { | 2454 { |
2455 ASSERT(!avoidsFloats()); | 2455 ASSERT(!avoidsFloats()); |
2456 | 2456 |
2457 // If we create our own block formatting context then our contents don't int
eract with floats outside it, even those from our parent. | 2457 // If we create our own block formatting context then our contents don't int
eract with floats outside it, even those from our parent. |
2458 if (createsNewFormattingContext()) | 2458 if (createsNewFormattingContext()) |
2459 return; | 2459 return; |
2460 | 2460 |
2461 // If the parent or previous sibling doesn't have any floats to add, don't b
other. | 2461 // If the parent or previous sibling doesn't have any floats to add, don't b
other. |
2462 if (!prev->m_floatingObjects) | 2462 if (!prev->m_floatingObjects) |
2463 return; | 2463 return; |
2464 | 2464 |
2465 logicalLeftOffset += marginLogicalLeft(); | 2465 logicalLeftOffset += marginLogicalLeft(); |
2466 | 2466 |
2467 const FloatingObjectSet& prevSet = prev->m_floatingObjects->set(); | 2467 const FloatingObjectSet& prevSet = prev->m_floatingObjects->set(); |
2468 FloatingObjectSetIterator prevEnd = prevSet.end(); | 2468 FloatingObjectSetIterator prevEnd = prevSet.end(); |
2469 for (FloatingObjectSetIterator prevIt = prevSet.begin(); prevIt != prevEnd;
++prevIt) { | 2469 for (FloatingObjectSetIterator prevIt = prevSet.begin(); prevIt != prevEnd;
++prevIt) { |
2470 FloatingObject* floatingObject = prevIt->get(); | 2470 FloatingObject& floatingObject = *prevIt->get(); |
2471 if (logicalBottomForFloat(floatingObject) > logicalTopOffset) { | 2471 if (logicalBottomForFloat(floatingObject) > logicalTopOffset) { |
2472 if (!m_floatingObjects || !m_floatingObjects->set().contains(floatin
gObject)) { | 2472 if (!m_floatingObjects || !m_floatingObjects->set().contains(&floati
ngObject)) { |
2473 // We create the floating object list lazily. | 2473 // We create the floating object list lazily. |
2474 if (!m_floatingObjects) | 2474 if (!m_floatingObjects) |
2475 createFloatingObjects(); | 2475 createFloatingObjects(); |
2476 | 2476 |
2477 // Applying the child's margin makes no sense in the case where
the child was passed in. | 2477 // Applying the child's margin makes no sense in the case where
the child was passed in. |
2478 // since this margin was added already through the modification
of the |logicalLeftOffset| variable | 2478 // since this margin was added already through the modification
of the |logicalLeftOffset| variable |
2479 // above. |logicalLeftOffset| will equal the margin in this case
, so it's already been taken | 2479 // above. |logicalLeftOffset| will equal the margin in this case
, so it's already been taken |
2480 // into account. Only apply this code if prev is the parent, sin
ce otherwise the left margin | 2480 // into account. Only apply this code if prev is the parent, sin
ce otherwise the left margin |
2481 // will get applied twice. | 2481 // will get applied twice. |
2482 LayoutSize offset = isHorizontalWritingMode() | 2482 LayoutSize offset = isHorizontalWritingMode() |
2483 ? LayoutSize(logicalLeftOffset - (prev != parent() ? prev->m
arginLeft() : LayoutUnit()), logicalTopOffset) | 2483 ? LayoutSize(logicalLeftOffset - (prev != parent() ? prev->m
arginLeft() : LayoutUnit()), logicalTopOffset) |
2484 : LayoutSize(logicalTopOffset, logicalLeftOffset - (prev !=
parent() ? prev->marginTop() : LayoutUnit())); | 2484 : LayoutSize(logicalTopOffset, logicalLeftOffset - (prev !=
parent() ? prev->marginTop() : LayoutUnit())); |
2485 | 2485 |
2486 m_floatingObjects->add(floatingObject->copyToNewContainer(offset
)); | 2486 m_floatingObjects->add(floatingObject.copyToNewContainer(offset)
); |
2487 } | 2487 } |
2488 } | 2488 } |
2489 } | 2489 } |
2490 } | 2490 } |
2491 | 2491 |
2492 void LayoutBlockFlow::addOverhangingFloats(LayoutBlockFlow* child, bool makeChil
dPaintOtherFloats) | 2492 void LayoutBlockFlow::addOverhangingFloats(LayoutBlockFlow* child, bool makeChil
dPaintOtherFloats) |
2493 { | 2493 { |
2494 // Prevent floats from being added to the canvas by the root element, e.g.,
<html>. | 2494 // Prevent floats from being added to the canvas by the root element, e.g.,
<html>. |
2495 if (!child->containsFloats() || child->createsNewFormattingContext()) | 2495 if (!child->containsFloats() || child->createsNewFormattingContext()) |
2496 return; | 2496 return; |
2497 | 2497 |
2498 LayoutUnit childLogicalTop = child->logicalTop(); | 2498 LayoutUnit childLogicalTop = child->logicalTop(); |
2499 LayoutUnit childLogicalLeft = child->logicalLeft(); | 2499 LayoutUnit childLogicalLeft = child->logicalLeft(); |
2500 | 2500 |
2501 // Floats that will remain the child's responsibility to paint should factor
into its | 2501 // Floats that will remain the child's responsibility to paint should factor
into its |
2502 // overflow. | 2502 // overflow. |
2503 FloatingObjectSetIterator childEnd = child->m_floatingObjects->set().end(); | 2503 FloatingObjectSetIterator childEnd = child->m_floatingObjects->set().end(); |
2504 for (FloatingObjectSetIterator childIt = child->m_floatingObjects->set().beg
in(); childIt != childEnd; ++childIt) { | 2504 for (FloatingObjectSetIterator childIt = child->m_floatingObjects->set().beg
in(); childIt != childEnd; ++childIt) { |
2505 FloatingObject* floatingObject = childIt->get(); | 2505 FloatingObject& floatingObject = *childIt->get(); |
2506 LayoutUnit logicalBottomForFloat = std::min(this->logicalBottomForFloat(
floatingObject), LayoutUnit::max() - childLogicalTop); | 2506 LayoutUnit logicalBottomForFloat = std::min(this->logicalBottomForFloat(
floatingObject), LayoutUnit::max() - childLogicalTop); |
2507 LayoutUnit logicalBottom = childLogicalTop + logicalBottomForFloat; | 2507 LayoutUnit logicalBottom = childLogicalTop + logicalBottomForFloat; |
2508 | 2508 |
2509 if (logicalBottom > logicalHeight()) { | 2509 if (logicalBottom > logicalHeight()) { |
2510 // If the object is not in the list, we add it now. | 2510 // If the object is not in the list, we add it now. |
2511 if (!containsFloat(floatingObject->layoutObject())) { | 2511 if (!containsFloat(floatingObject.layoutObject())) { |
2512 LayoutSize offset = isHorizontalWritingMode() ? LayoutSize(-chil
dLogicalLeft, -childLogicalTop) : LayoutSize(-childLogicalTop, -childLogicalLeft
); | 2512 LayoutSize offset = isHorizontalWritingMode() ? LayoutSize(-chil
dLogicalLeft, -childLogicalTop) : LayoutSize(-childLogicalTop, -childLogicalLeft
); |
2513 bool shouldPaint = false; | 2513 bool shouldPaint = false; |
2514 | 2514 |
2515 // The nearest enclosing layer always paints the float (so that
zindex and stacking | 2515 // The nearest enclosing layer always paints the float (so that
zindex and stacking |
2516 // behaves properly). We always want to propagate the desire to
paint the float as | 2516 // behaves properly). We always want to propagate the desire to
paint the float as |
2517 // far out as we can, to the outermost block that overlaps the f
loat, stopping only | 2517 // far out as we can, to the outermost block that overlaps the f
loat, stopping only |
2518 // if we hit a self-painting layer boundary. | 2518 // if we hit a self-painting layer boundary. |
2519 if (floatingObject->layoutObject()->enclosingFloatPaintingLayer(
) == enclosingFloatPaintingLayer() && !floatingObject->isLowestNonOverhangingFlo
atInChild()) { | 2519 if (floatingObject.layoutObject()->enclosingFloatPaintingLayer()
== enclosingFloatPaintingLayer() && !floatingObject.isLowestNonOverhangingFloat
InChild()) { |
2520 floatingObject->setShouldPaint(false); | 2520 floatingObject.setShouldPaint(false); |
2521 shouldPaint = true; | 2521 shouldPaint = true; |
2522 } | 2522 } |
2523 // We create the floating object list lazily. | 2523 // We create the floating object list lazily. |
2524 if (!m_floatingObjects) | 2524 if (!m_floatingObjects) |
2525 createFloatingObjects(); | 2525 createFloatingObjects(); |
2526 | 2526 |
2527 m_floatingObjects->add(floatingObject->copyToNewContainer(offset
, shouldPaint, true)); | 2527 m_floatingObjects->add(floatingObject.copyToNewContainer(offset,
shouldPaint, true)); |
2528 } | 2528 } |
2529 } else { | 2529 } else { |
2530 if (makeChildPaintOtherFloats && !floatingObject->shouldPaint() && !
floatingObject->layoutObject()->hasSelfPaintingLayer() && !floatingObject->isLow
estNonOverhangingFloatInChild() | 2530 if (makeChildPaintOtherFloats && !floatingObject.shouldPaint() && !f
loatingObject.layoutObject()->hasSelfPaintingLayer() && !floatingObject.isLowest
NonOverhangingFloatInChild() |
2531 && floatingObject->layoutObject()->isDescendantOf(child) && floa
tingObject->layoutObject()->enclosingFloatPaintingLayer() == child->enclosingFlo
atPaintingLayer()) { | 2531 && floatingObject.layoutObject()->isDescendantOf(child) && float
ingObject.layoutObject()->enclosingFloatPaintingLayer() == child->enclosingFloat
PaintingLayer()) { |
2532 // The float is not overhanging from this block, so if it is a d
escendant of the child, the child should | 2532 // The float is not overhanging from this block, so if it is a d
escendant of the child, the child should |
2533 // paint it (the other case is that it is intruding into the chi
ld), unless it has its own layer or enclosing | 2533 // paint it (the other case is that it is intruding into the chi
ld), unless it has its own layer or enclosing |
2534 // layer. | 2534 // layer. |
2535 // If makeChildPaintOtherFloats is false, it means that the chil
d must already know about all the floats | 2535 // If makeChildPaintOtherFloats is false, it means that the chil
d must already know about all the floats |
2536 // it should paint. | 2536 // it should paint. |
2537 floatingObject->setShouldPaint(true); | 2537 floatingObject.setShouldPaint(true); |
2538 } | 2538 } |
2539 | 2539 |
2540 // 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 | 2540 // 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 |
2541 // child now. | 2541 // child now. |
2542 if (floatingObject->isDescendant()) | 2542 if (floatingObject.isDescendant()) |
2543 child->addOverflowFromChild(floatingObject->layoutObject(), Layo
utSize(xPositionForFloatIncludingMargin(floatingObject), yPositionForFloatInclud
ingMargin(floatingObject))); | 2543 child->addOverflowFromChild(floatingObject.layoutObject(), Layou
tSize(xPositionForFloatIncludingMargin(floatingObject), yPositionForFloatIncludi
ngMargin(floatingObject))); |
2544 } | 2544 } |
2545 } | 2545 } |
2546 } | 2546 } |
2547 | 2547 |
2548 LayoutUnit LayoutBlockFlow::lowestFloatLogicalBottom(FloatingObject::Type floatT
ype) const | 2548 LayoutUnit LayoutBlockFlow::lowestFloatLogicalBottom(FloatingObject::Type floatT
ype) const |
2549 { | 2549 { |
2550 if (!m_floatingObjects) | 2550 if (!m_floatingObjects) |
2551 return LayoutUnit(); | 2551 return LayoutUnit(); |
2552 | 2552 |
2553 return m_floatingObjects->lowestFloatLogicalBottom(floatType); | 2553 return m_floatingObjects->lowestFloatLogicalBottom(floatType); |
2554 } | 2554 } |
2555 | 2555 |
2556 LayoutUnit LayoutBlockFlow::nextFloatLogicalBottomBelow(LayoutUnit logicalHeight
, ShapeOutsideFloatOffsetMode offsetMode) const | 2556 LayoutUnit LayoutBlockFlow::nextFloatLogicalBottomBelow(LayoutUnit logicalHeight
, ShapeOutsideFloatOffsetMode offsetMode) const |
2557 { | 2557 { |
2558 if (!m_floatingObjects) | 2558 if (!m_floatingObjects) |
2559 return logicalHeight; | 2559 return logicalHeight; |
2560 | 2560 |
2561 LayoutUnit logicalBottom; | 2561 LayoutUnit logicalBottom; |
2562 const FloatingObjectSet& floatingObjectSet = m_floatingObjects->set(); | 2562 const FloatingObjectSet& floatingObjectSet = m_floatingObjects->set(); |
2563 FloatingObjectSetIterator end = floatingObjectSet.end(); | 2563 FloatingObjectSetIterator end = floatingObjectSet.end(); |
2564 for (FloatingObjectSetIterator it = floatingObjectSet.begin(); it != end; ++
it) { | 2564 for (FloatingObjectSetIterator it = floatingObjectSet.begin(); it != end; ++
it) { |
2565 FloatingObject* floatingObject = it->get(); | 2565 const FloatingObject& floatingObject = *it->get(); |
2566 LayoutUnit floatLogicalBottom = logicalBottomForFloat(floatingObject); | 2566 LayoutUnit floatLogicalBottom = logicalBottomForFloat(floatingObject); |
2567 ShapeOutsideInfo* shapeOutside = floatingObject->layoutObject()->shapeOu
tsideInfo(); | 2567 ShapeOutsideInfo* shapeOutside = floatingObject.layoutObject()->shapeOut
sideInfo(); |
2568 if (shapeOutside && (offsetMode == ShapeOutsideFloatShapeOffset)) { | 2568 if (shapeOutside && (offsetMode == ShapeOutsideFloatShapeOffset)) { |
2569 LayoutUnit shapeLogicalBottom = logicalTopForFloat(floatingObject) +
marginBeforeForChild(*(floatingObject->layoutObject())) + shapeOutside->shapeLo
gicalBottom(); | 2569 LayoutUnit shapeLogicalBottom = logicalTopForFloat(floatingObject) +
marginBeforeForChild(*floatingObject.layoutObject()) + shapeOutside->shapeLogic
alBottom(); |
2570 // Use the shapeLogicalBottom unless it extends outside of the margi
n box, in which case it is clipped. | 2570 // Use the shapeLogicalBottom unless it extends outside of the margi
n box, in which case it is clipped. |
2571 if (shapeLogicalBottom < floatLogicalBottom) | 2571 if (shapeLogicalBottom < floatLogicalBottom) |
2572 floatLogicalBottom = shapeLogicalBottom; | 2572 floatLogicalBottom = shapeLogicalBottom; |
2573 } | 2573 } |
2574 if (floatLogicalBottom > logicalHeight) | 2574 if (floatLogicalBottom > logicalHeight) |
2575 logicalBottom = logicalBottom ? std::min(floatLogicalBottom, logical
Bottom) : floatLogicalBottom; | 2575 logicalBottom = logicalBottom ? std::min(floatLogicalBottom, logical
Bottom) : floatLogicalBottom; |
2576 } | 2576 } |
2577 | 2577 |
2578 return logicalBottom; | 2578 return logicalBottom; |
2579 } | 2579 } |
2580 | 2580 |
2581 bool LayoutBlockFlow::hitTestFloats(HitTestResult& result, const HitTestLocation
& locationInContainer, const LayoutPoint& accumulatedOffset) | 2581 bool LayoutBlockFlow::hitTestFloats(HitTestResult& result, const HitTestLocation
& locationInContainer, const LayoutPoint& accumulatedOffset) |
2582 { | 2582 { |
2583 if (!m_floatingObjects) | 2583 if (!m_floatingObjects) |
2584 return false; | 2584 return false; |
2585 | 2585 |
2586 LayoutPoint adjustedLocation = accumulatedOffset; | 2586 LayoutPoint adjustedLocation = accumulatedOffset; |
2587 if (isLayoutView()) { | 2587 if (isLayoutView()) { |
2588 DoublePoint position = toLayoutView(this)->frameView()->scrollPositionDo
uble(); | 2588 DoublePoint position = toLayoutView(this)->frameView()->scrollPositionDo
uble(); |
2589 adjustedLocation.move(position.x(), position.y()); | 2589 adjustedLocation.move(position.x(), position.y()); |
2590 } | 2590 } |
2591 | 2591 |
2592 const FloatingObjectSet& floatingObjectSet = m_floatingObjects->set(); | 2592 const FloatingObjectSet& floatingObjectSet = m_floatingObjects->set(); |
2593 FloatingObjectSetIterator begin = floatingObjectSet.begin(); | 2593 FloatingObjectSetIterator begin = floatingObjectSet.begin(); |
2594 for (FloatingObjectSetIterator it = floatingObjectSet.end(); it != begin;) { | 2594 for (FloatingObjectSetIterator it = floatingObjectSet.end(); it != begin;) { |
2595 --it; | 2595 --it; |
2596 FloatingObject* floatingObject = it->get(); | 2596 const FloatingObject& floatingObject = *it->get(); |
2597 if (floatingObject->shouldPaint() && !floatingObject->layoutObject()->ha
sSelfPaintingLayer()) { | 2597 if (floatingObject.shouldPaint() && !floatingObject.layoutObject()->hasS
elfPaintingLayer()) { |
2598 LayoutUnit xOffset = xPositionForFloatIncludingMargin(floatingObject
) - floatingObject->layoutObject()->location().x(); | 2598 LayoutUnit xOffset = xPositionForFloatIncludingMargin(floatingObject
) - floatingObject.layoutObject()->location().x(); |
2599 LayoutUnit yOffset = yPositionForFloatIncludingMargin(floatingObject
) - floatingObject->layoutObject()->location().y(); | 2599 LayoutUnit yOffset = yPositionForFloatIncludingMargin(floatingObject
) - floatingObject.layoutObject()->location().y(); |
2600 LayoutPoint childPoint = flipFloatForWritingModeForChild(floatingObj
ect, adjustedLocation + LayoutSize(xOffset, yOffset)); | 2600 LayoutPoint childPoint = flipFloatForWritingModeForChild(floatingObj
ect, adjustedLocation + LayoutSize(xOffset, yOffset)); |
2601 if (floatingObject->layoutObject()->hitTest(result, locationInContai
ner, childPoint)) { | 2601 if (floatingObject.layoutObject()->hitTest(result, locationInContain
er, childPoint)) { |
2602 updateHitTestResult(result, locationInContainer.point() - toLayo
utSize(childPoint)); | 2602 updateHitTestResult(result, locationInContainer.point() - toLayo
utSize(childPoint)); |
2603 return true; | 2603 return true; |
2604 } | 2604 } |
2605 } | 2605 } |
2606 } | 2606 } |
2607 | 2607 |
2608 return false; | 2608 return false; |
2609 } | 2609 } |
2610 | 2610 |
2611 LayoutUnit LayoutBlockFlow::logicalLeftFloatOffsetForLine(LayoutUnit logicalTop,
LayoutUnit fixedOffset, LayoutUnit logicalHeight) const | 2611 LayoutUnit LayoutBlockFlow::logicalLeftFloatOffsetForLine(LayoutUnit logicalTop,
LayoutUnit fixedOffset, LayoutUnit logicalHeight) const |
(...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3080 FrameView* frameView = document().view(); | 3080 FrameView* frameView = document().view(); |
3081 LayoutUnit top = (style()->position() == FixedPosition) ? 0 : frameView->scr
ollOffset().height(); | 3081 LayoutUnit top = (style()->position() == FixedPosition) ? 0 : frameView->scr
ollOffset().height(); |
3082 int visibleHeight = frameView->visibleContentRect(IncludeScrollbars).height(
); | 3082 int visibleHeight = frameView->visibleContentRect(IncludeScrollbars).height(
); |
3083 if (size().height() < visibleHeight) | 3083 if (size().height() < visibleHeight) |
3084 top += (visibleHeight - size().height()) / 2; | 3084 top += (visibleHeight - size().height()) / 2; |
3085 setY(top); | 3085 setY(top); |
3086 dialog->setCentered(top); | 3086 dialog->setCentered(top); |
3087 } | 3087 } |
3088 | 3088 |
3089 } // namespace blink | 3089 } // namespace blink |
OLD | NEW |