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 873 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
884 void LayoutBlockFlow::rebuildFloatsFromIntruding() | 884 void LayoutBlockFlow::rebuildFloatsFromIntruding() |
885 { | 885 { |
886 if (m_floatingObjects) | 886 if (m_floatingObjects) |
887 m_floatingObjects->setHorizontalWritingMode(isHorizontalWritingMode()); | 887 m_floatingObjects->setHorizontalWritingMode(isHorizontalWritingMode()); |
888 | 888 |
889 HashSet<LayoutBox*> oldIntrudingFloatSet; | 889 HashSet<LayoutBox*> oldIntrudingFloatSet; |
890 if (!childrenInline() && m_floatingObjects) { | 890 if (!childrenInline() && m_floatingObjects) { |
891 const FloatingObjectSet& floatingObjectSet = m_floatingObjects->set(); | 891 const FloatingObjectSet& floatingObjectSet = m_floatingObjects->set(); |
892 FloatingObjectSetIterator end = floatingObjectSet.end(); | 892 FloatingObjectSetIterator end = floatingObjectSet.end(); |
893 for (FloatingObjectSetIterator it = floatingObjectSet.begin(); it != end ; ++it) { | 893 for (FloatingObjectSetIterator it = floatingObjectSet.begin(); it != end ; ++it) { |
894 FloatingObject* floatingObject = it->get(); | 894 FloatingObject& floatingObject = *it->get(); |
Julien - ping for review
2015/03/18 01:36:08
const FloatingObject here too.
Sunil Ratnu
2015/06/04 08:40:46
Done.
| |
895 if (!floatingObject->isDescendant()) | 895 if (!floatingObject.isDescendant()) |
896 oldIntrudingFloatSet.add(floatingObject->layoutObject()); | 896 oldIntrudingFloatSet.add(floatingObject.layoutObject()); |
897 } | 897 } |
898 } | 898 } |
899 | 899 |
900 // Inline blocks are covered by the isReplaced() check in the avoidFloats me thod. | 900 // Inline blocks are covered by the isReplaced() check in the avoidFloats me thod. |
901 if (avoidsFloats() || isDocumentElement() || isLayoutView() || isFloatingOrO utOfFlowPositioned() || isTableCell()) { | 901 if (avoidsFloats() || isDocumentElement() || isLayoutView() || isFloatingOrO utOfFlowPositioned() || isTableCell()) { |
902 if (m_floatingObjects) { | 902 if (m_floatingObjects) { |
903 m_floatingObjects->clear(); | 903 m_floatingObjects->clear(); |
904 } | 904 } |
905 if (!oldIntrudingFloatSet.isEmpty()) | 905 if (!oldIntrudingFloatSet.isEmpty()) |
906 markAllDescendantsWithFloatsForLayout(); | 906 markAllDescendantsWithFloatsForLayout(); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
949 addIntrudingFloats(blockFlow, 0, logicalTopOffset); | 949 addIntrudingFloats(blockFlow, 0, logicalTopOffset); |
950 } | 950 } |
951 | 951 |
952 if (childrenInline()) { | 952 if (childrenInline()) { |
953 LayoutUnit changeLogicalTop = LayoutUnit::max(); | 953 LayoutUnit changeLogicalTop = LayoutUnit::max(); |
954 LayoutUnit changeLogicalBottom = LayoutUnit::min(); | 954 LayoutUnit changeLogicalBottom = LayoutUnit::min(); |
955 if (m_floatingObjects) { | 955 if (m_floatingObjects) { |
956 const FloatingObjectSet& floatingObjectSet = m_floatingObjects->set( ); | 956 const FloatingObjectSet& floatingObjectSet = m_floatingObjects->set( ); |
957 FloatingObjectSetIterator end = floatingObjectSet.end(); | 957 FloatingObjectSetIterator end = floatingObjectSet.end(); |
958 for (FloatingObjectSetIterator it = floatingObjectSet.begin(); it != end; ++it) { | 958 for (FloatingObjectSetIterator it = floatingObjectSet.begin(); it != end; ++it) { |
959 FloatingObject* floatingObject = it->get(); | 959 FloatingObject& floatingObject = *it->get(); |
Julien - ping for review
2015/03/18 01:36:08
Can this one be const FloatingObject&?
Sunil Ratnu
2015/06/04 08:40:46
Yes, it can be. Made it a const.
| |
960 FloatingObject* oldFloatingObject = floatMap.get(floatingObject- >layoutObject()); | 960 FloatingObject* oldFloatingObject = floatMap.get(floatingObject. layoutObject()); |
961 LayoutUnit logicalBottom = logicalBottomForFloat(floatingObject) ; | 961 LayoutUnit logicalBottom = logicalBottomForFloat(floatingObject) ; |
962 if (oldFloatingObject) { | 962 if (oldFloatingObject) { |
963 LayoutUnit oldLogicalBottom = logicalBottomForFloat(oldFloat ingObject); | 963 LayoutUnit oldLogicalBottom = logicalBottomForFloat(*oldFloa tingObject); |
964 if (logicalWidthForFloat(floatingObject) != logicalWidthForF loat(oldFloatingObject) || logicalLeftForFloat(floatingObject) != logicalLeftFor Float(oldFloatingObject)) { | 964 if (logicalWidthForFloat(floatingObject) != logicalWidthForF loat(*oldFloatingObject) || logicalLeftForFloat(floatingObject) != logicalLeftFo rFloat(*oldFloatingObject)) { |
965 changeLogicalTop = 0; | 965 changeLogicalTop = 0; |
966 changeLogicalBottom = std::max(changeLogicalBottom, std: :max(logicalBottom, oldLogicalBottom)); | 966 changeLogicalBottom = std::max(changeLogicalBottom, std: :max(logicalBottom, oldLogicalBottom)); |
967 } else { | 967 } else { |
968 if (logicalBottom != oldLogicalBottom) { | 968 if (logicalBottom != oldLogicalBottom) { |
969 changeLogicalTop = std::min(changeLogicalTop, std::m in(logicalBottom, oldLogicalBottom)); | 969 changeLogicalTop = std::min(changeLogicalTop, std::m in(logicalBottom, oldLogicalBottom)); |
970 changeLogicalBottom = std::max(changeLogicalBottom, std::max(logicalBottom, oldLogicalBottom)); | 970 changeLogicalBottom = std::max(changeLogicalBottom, std::max(logicalBottom, oldLogicalBottom)); |
971 } | 971 } |
972 LayoutUnit logicalTop = logicalTopForFloat(floatingObjec t); | 972 LayoutUnit logicalTop = logicalTopForFloat(floatingObjec t); |
973 LayoutUnit oldLogicalTop = logicalTopForFloat(oldFloatin gObject); | 973 LayoutUnit oldLogicalTop = logicalTopForFloat(*oldFloati ngObject); |
974 if (logicalTop != oldLogicalTop) { | 974 if (logicalTop != oldLogicalTop) { |
975 changeLogicalTop = std::min(changeLogicalTop, std::m in(logicalTop, oldLogicalTop)); | 975 changeLogicalTop = std::min(changeLogicalTop, std::m in(logicalTop, oldLogicalTop)); |
976 changeLogicalBottom = std::max(changeLogicalBottom, std::max(logicalTop, oldLogicalTop)); | 976 changeLogicalBottom = std::max(changeLogicalBottom, std::max(logicalTop, oldLogicalTop)); |
977 } | 977 } |
978 } | 978 } |
979 | 979 |
980 if (oldFloatingObject->originatingLine() && !selfNeedsLayout ()) { | 980 if (oldFloatingObject->originatingLine() && !selfNeedsLayout ()) { |
981 ASSERT(oldFloatingObject->originatingLine()->layoutObjec t() == this); | 981 ASSERT(oldFloatingObject->originatingLine()->layoutObjec t() == this); |
982 oldFloatingObject->originatingLine()->markDirty(); | 982 oldFloatingObject->originatingLine()->markDirty(); |
983 } | 983 } |
984 | 984 |
985 floatMap.remove(floatingObject->layoutObject()); | 985 floatMap.remove(floatingObject.layoutObject()); |
986 } else { | 986 } else { |
987 changeLogicalTop = 0; | 987 changeLogicalTop = 0; |
988 changeLogicalBottom = std::max(changeLogicalBottom, logicalB ottom); | 988 changeLogicalBottom = std::max(changeLogicalBottom, logicalB ottom); |
989 } | 989 } |
990 } | 990 } |
991 } | 991 } |
992 | 992 |
993 RendererToFloatInfoMap::iterator end = floatMap.end(); | 993 RendererToFloatInfoMap::iterator end = floatMap.end(); |
994 for (RendererToFloatInfoMap::iterator it = floatMap.begin(); it != end; ++it) { | 994 for (RendererToFloatInfoMap::iterator it = floatMap.begin(); it != end; ++it) { |
995 OwnPtr<FloatingObject>& floatingObject = it->value; | 995 OwnPtr<FloatingObject>& floatingObject = it->value; |
996 if (!floatingObject->isDescendant()) { | 996 if (!floatingObject->isDescendant()) { |
997 changeLogicalTop = 0; | 997 changeLogicalTop = 0; |
998 changeLogicalBottom = std::max(changeLogicalBottom, logicalBotto mForFloat(floatingObject.get())); | 998 changeLogicalBottom = std::max(changeLogicalBottom, logicalBotto mForFloat(*floatingObject)); |
999 } | 999 } |
1000 } | 1000 } |
1001 | 1001 |
1002 markLinesDirtyInBlockRange(changeLogicalTop, changeLogicalBottom); | 1002 markLinesDirtyInBlockRange(changeLogicalTop, changeLogicalBottom); |
1003 } else if (!oldIntrudingFloatSet.isEmpty()) { | 1003 } else if (!oldIntrudingFloatSet.isEmpty()) { |
1004 // If there are previously intruding floats that no longer intrude, then children with floats | 1004 // If there are previously intruding floats that no longer intrude, then children with floats |
1005 // should also get layout because they might need their floating object lists cleared. | 1005 // should also get layout because they might need their floating object lists cleared. |
1006 if (m_floatingObjects->set().size() < oldIntrudingFloatSet.size()) { | 1006 if (m_floatingObjects->set().size() < oldIntrudingFloatSet.size()) { |
1007 markAllDescendantsWithFloatsForLayout(); | 1007 markAllDescendantsWithFloatsForLayout(); |
1008 } else { | 1008 } else { |
(...skipping 766 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1775 } | 1775 } |
1776 | 1776 |
1777 void LayoutBlockFlow::addOverflowFromFloats() | 1777 void LayoutBlockFlow::addOverflowFromFloats() |
1778 { | 1778 { |
1779 if (!m_floatingObjects) | 1779 if (!m_floatingObjects) |
1780 return; | 1780 return; |
1781 | 1781 |
1782 const FloatingObjectSet& floatingObjectSet = m_floatingObjects->set(); | 1782 const FloatingObjectSet& floatingObjectSet = m_floatingObjects->set(); |
1783 FloatingObjectSetIterator end = floatingObjectSet.end(); | 1783 FloatingObjectSetIterator end = floatingObjectSet.end(); |
1784 for (FloatingObjectSetIterator it = floatingObjectSet.begin(); it != end; ++ it) { | 1784 for (FloatingObjectSetIterator it = floatingObjectSet.begin(); it != end; ++ it) { |
1785 FloatingObject* floatingObject = it->get(); | 1785 const FloatingObject& floatingObject = *it->get(); |
1786 if (floatingObject->isDescendant()) | 1786 if (floatingObject.isDescendant()) |
1787 addOverflowFromChild(floatingObject->layoutObject(), LayoutSize(xPos itionForFloatIncludingMargin(floatingObject), yPositionForFloatIncludingMargin(f loatingObject))); | 1787 addOverflowFromChild(floatingObject.layoutObject(), LayoutSize(xPosi tionForFloatIncludingMargin(floatingObject), yPositionForFloatIncludingMargin(fl oatingObject))); |
1788 } | 1788 } |
1789 } | 1789 } |
1790 | 1790 |
1791 void LayoutBlockFlow::computeOverflow(LayoutUnit oldClientAfterEdge, bool recomp uteFloats) | 1791 void LayoutBlockFlow::computeOverflow(LayoutUnit oldClientAfterEdge, bool recomp uteFloats) |
1792 { | 1792 { |
1793 LayoutBlock::computeOverflow(oldClientAfterEdge, recomputeFloats); | 1793 LayoutBlock::computeOverflow(oldClientAfterEdge, recomputeFloats); |
1794 if (!hasColumns() && (recomputeFloats || createsNewFormattingContext() || ha sSelfPaintingLayer())) | 1794 if (!hasColumns() && (recomputeFloats || createsNewFormattingContext() || ha sSelfPaintingLayer())) |
1795 addOverflowFromFloats(); | 1795 addOverflowFromFloats(); |
1796 } | 1796 } |
1797 | 1797 |
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2046 // displayed. | 2046 // displayed. |
2047 // See bug https://code.google.com/p/chromium/issues/detail?id=230907 | 2047 // See bug https://code.google.com/p/chromium/issues/detail?id=230907 |
2048 if (m_floatingObjects) { | 2048 if (m_floatingObjects) { |
2049 if (!toBlockFlow->m_floatingObjects) | 2049 if (!toBlockFlow->m_floatingObjects) |
2050 toBlockFlow->createFloatingObjects(); | 2050 toBlockFlow->createFloatingObjects(); |
2051 | 2051 |
2052 const FloatingObjectSet& fromFloatingObjectSet = m_floatingObjects->set( ); | 2052 const FloatingObjectSet& fromFloatingObjectSet = m_floatingObjects->set( ); |
2053 FloatingObjectSetIterator end = fromFloatingObjectSet.end(); | 2053 FloatingObjectSetIterator end = fromFloatingObjectSet.end(); |
2054 | 2054 |
2055 for (FloatingObjectSetIterator it = fromFloatingObjectSet.begin(); it != end; ++it) { | 2055 for (FloatingObjectSetIterator it = fromFloatingObjectSet.begin(); it != end; ++it) { |
2056 FloatingObject* floatingObject = it->get(); | 2056 FloatingObject& floatingObject = *it->get(); |
2057 | 2057 |
2058 // Don't insert the object again if it's already in the list | 2058 // Don't insert the object again if it's already in the list |
2059 if (toBlockFlow->containsFloat(floatingObject->layoutObject())) | 2059 if (toBlockFlow->containsFloat(floatingObject.layoutObject())) |
2060 continue; | 2060 continue; |
2061 | 2061 |
2062 toBlockFlow->m_floatingObjects->add(floatingObject->unsafeClone()); | 2062 toBlockFlow->m_floatingObjects->add(floatingObject.unsafeClone()); |
2063 } | 2063 } |
2064 } | 2064 } |
2065 | 2065 |
2066 } | 2066 } |
2067 | 2067 |
2068 void LayoutBlockFlow::invalidatePaintForOverhangingFloats(bool paintAllDescendan ts) | 2068 void LayoutBlockFlow::invalidatePaintForOverhangingFloats(bool paintAllDescendan ts) |
2069 { | 2069 { |
2070 // Invalidate paint of any overhanging floats (if we know we're the one to p aint them). | 2070 // Invalidate paint of any overhanging floats (if we know we're the one to p aint them). |
2071 // Otherwise, bail out. | 2071 // Otherwise, bail out. |
2072 if (!hasOverhangingFloats()) | 2072 if (!hasOverhangingFloats()) |
2073 return; | 2073 return; |
2074 | 2074 |
2075 const FloatingObjectSet& floatingObjectSet = m_floatingObjects->set(); | 2075 const FloatingObjectSet& floatingObjectSet = m_floatingObjects->set(); |
2076 FloatingObjectSetIterator end = floatingObjectSet.end(); | 2076 FloatingObjectSetIterator end = floatingObjectSet.end(); |
2077 for (FloatingObjectSetIterator it = floatingObjectSet.begin(); it != end; ++ it) { | 2077 for (FloatingObjectSetIterator it = floatingObjectSet.begin(); it != end; ++ it) { |
2078 FloatingObject* floatingObject = it->get(); | 2078 FloatingObject& floatingObject = *it->get(); |
2079 // Only issue paint invaldiations for the object if it is overhanging, i s not in its own layer, and | 2079 // Only issue paint invaldiations for the object if it is overhanging, i s not in its own layer, and |
2080 // is our responsibility to paint (m_shouldPaint is set). When paintAllD escendants is true, the latter | 2080 // is our responsibility to paint (m_shouldPaint is set). When paintAllD escendants is true, the latter |
2081 // condition is replaced with being a descendant of us. | 2081 // condition is replaced with being a descendant of us. |
2082 if (logicalBottomForFloat(floatingObject) > logicalHeight() | 2082 if (logicalBottomForFloat(floatingObject) > logicalHeight() |
2083 && !floatingObject->layoutObject()->hasSelfPaintingLayer() | 2083 && !floatingObject.layoutObject()->hasSelfPaintingLayer() |
2084 && (floatingObject->shouldPaint() || (paintAllDescendants && floatin gObject->layoutObject()->isDescendantOf(this)))) { | 2084 && (floatingObject.shouldPaint() || (paintAllDescendants && floating Object.layoutObject()->isDescendantOf(this)))) { |
2085 | 2085 |
2086 LayoutBox* floatingRenderer = floatingObject->layoutObject(); | 2086 LayoutBox* floatingRenderer = floatingObject.layoutObject(); |
2087 floatingRenderer->setShouldDoFullPaintInvalidation(); | 2087 floatingRenderer->setShouldDoFullPaintInvalidation(); |
2088 floatingRenderer->invalidatePaintForOverhangingFloats(false); | 2088 floatingRenderer->invalidatePaintForOverhangingFloats(false); |
2089 } | 2089 } |
2090 } | 2090 } |
2091 } | 2091 } |
2092 | 2092 |
2093 void LayoutBlockFlow::invalidatePaintForOverflow() | 2093 void LayoutBlockFlow::invalidatePaintForOverflow() |
2094 { | 2094 { |
2095 // FIXME: We could tighten up the left and right invalidation points if we l et layoutInlineChildren fill them in based off the particular lines | 2095 // FIXME: We could tighten up the left and right invalidation points if we l et layoutInlineChildren fill them in based off the particular lines |
2096 // it had to lay out. We wouldn't need the hasOverflowClip() hack in that ca se either. | 2096 // it had to lay out. We wouldn't need the hasOverflowClip() hack in that ca se either. |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2146 } | 2146 } |
2147 | 2147 |
2148 void LayoutBlockFlow::clipOutFloatingObjects(const LayoutBlock* rootBlock, const PaintInfo* paintInfo, const LayoutPoint& rootBlockPhysicalPosition, const Layou tSize& offsetFromRootBlock) const | 2148 void LayoutBlockFlow::clipOutFloatingObjects(const LayoutBlock* rootBlock, const PaintInfo* paintInfo, const LayoutPoint& rootBlockPhysicalPosition, const Layou tSize& offsetFromRootBlock) const |
2149 { | 2149 { |
2150 if (!m_floatingObjects) | 2150 if (!m_floatingObjects) |
2151 return; | 2151 return; |
2152 | 2152 |
2153 const FloatingObjectSet& floatingObjectSet = m_floatingObjects->set(); | 2153 const FloatingObjectSet& floatingObjectSet = m_floatingObjects->set(); |
2154 FloatingObjectSetIterator end = floatingObjectSet.end(); | 2154 FloatingObjectSetIterator end = floatingObjectSet.end(); |
2155 for (FloatingObjectSetIterator it = floatingObjectSet.begin(); it != end; ++ it) { | 2155 for (FloatingObjectSetIterator it = floatingObjectSet.begin(); it != end; ++ it) { |
2156 FloatingObject* floatingObject = it->get(); | 2156 FloatingObject& floatingObject = *it->get(); |
2157 LayoutRect floatBox(LayoutPoint(offsetFromRootBlock), floatingObject->la youtObject()->size()); | 2157 LayoutRect floatBox(LayoutPoint(offsetFromRootBlock), floatingObject.lay outObject()->size()); |
2158 floatBox.move(positionForFloatIncludingMargin(floatingObject)); | 2158 floatBox.move(positionForFloatIncludingMargin(floatingObject)); |
2159 rootBlock->flipForWritingMode(floatBox); | 2159 rootBlock->flipForWritingMode(floatBox); |
2160 floatBox.move(rootBlockPhysicalPosition.x(), rootBlockPhysicalPosition.y ()); | 2160 floatBox.move(rootBlockPhysicalPosition.x(), rootBlockPhysicalPosition.y ()); |
2161 | 2161 |
2162 ASSERT(paintInfo->context->clipRecorderStack()); | 2162 ASSERT(paintInfo->context->clipRecorderStack()); |
2163 paintInfo->context->clipRecorderStack()->addClipRecorder(adoptPtr(new Cl ipRecorder( | 2163 paintInfo->context->clipRecorderStack()->addClipRecorder(adoptPtr(new Cl ipRecorder( |
2164 displayItemClient(), paintInfo->context, paintInfo->displayItemTypeF orClipping(), floatBox, SkRegion::kDifference_Op))); | 2164 displayItemClient(), paintInfo->context, paintInfo->displayItemTypeF orClipping(), floatBox, SkRegion::kDifference_Op))); |
2165 } | 2165 } |
2166 } | 2166 } |
2167 | 2167 |
(...skipping 26 matching lines...) Expand all Loading... | |
2194 void LayoutBlockFlow::removeFloatingObjects() | 2194 void LayoutBlockFlow::removeFloatingObjects() |
2195 { | 2195 { |
2196 if (!m_floatingObjects) | 2196 if (!m_floatingObjects) |
2197 return; | 2197 return; |
2198 | 2198 |
2199 markSiblingsWithFloatsForLayout(); | 2199 markSiblingsWithFloatsForLayout(); |
2200 | 2200 |
2201 m_floatingObjects->clear(); | 2201 m_floatingObjects->clear(); |
2202 } | 2202 } |
2203 | 2203 |
2204 LayoutPoint LayoutBlockFlow::flipFloatForWritingModeForChild(const FloatingObjec t* child, const LayoutPoint& point) const | 2204 LayoutPoint LayoutBlockFlow::flipFloatForWritingModeForChild(const FloatingObjec t& child, const LayoutPoint& point) const |
2205 { | 2205 { |
2206 if (!style()->isFlippedBlocksWritingMode()) | 2206 if (!style()->isFlippedBlocksWritingMode()) |
2207 return point; | 2207 return point; |
2208 | 2208 |
2209 // This is similar to LayoutBox::flipForWritingModeForChild. We have to subt ract out our left/top offsets twice, since | 2209 // This is similar to LayoutBox::flipForWritingModeForChild. We have to subt ract out our left/top offsets twice, since |
2210 // it's going to get added back in. We hide this complication here so that t he calling code looks normal for the unflipped | 2210 // it's going to get added back in. We hide this complication here so that t he calling code looks normal for the unflipped |
2211 // case. | 2211 // case. |
2212 if (isHorizontalWritingMode()) | 2212 if (isHorizontalWritingMode()) |
2213 return LayoutPoint(point.x(), point.y() + size().height() - child->layou tObject()->size().height() - 2 * yPositionForFloatIncludingMargin(child)); | 2213 return LayoutPoint(point.x(), point.y() + size().height() - child.layout Object()->size().height() - 2 * yPositionForFloatIncludingMargin(child)); |
2214 return LayoutPoint(point.x() + size().width() - child->layoutObject()->size( ).width() - 2 * xPositionForFloatIncludingMargin(child), point.y()); | 2214 return LayoutPoint(point.x() + size().width() - child.layoutObject()->size() .width() - 2 * xPositionForFloatIncludingMargin(child), point.y()); |
2215 } | 2215 } |
2216 | 2216 |
2217 LayoutUnit LayoutBlockFlow::logicalLeftOffsetForPositioningFloat(LayoutUnit logi calTop, LayoutUnit fixedOffset, bool applyTextIndent, LayoutUnit* heightRemainin g) const | 2217 LayoutUnit LayoutBlockFlow::logicalLeftOffsetForPositioningFloat(LayoutUnit logi calTop, LayoutUnit fixedOffset, bool applyTextIndent, LayoutUnit* heightRemainin g) const |
2218 { | 2218 { |
2219 LayoutUnit offset = fixedOffset; | 2219 LayoutUnit offset = fixedOffset; |
2220 if (m_floatingObjects && m_floatingObjects->hasLeftObjects()) | 2220 if (m_floatingObjects && m_floatingObjects->hasLeftObjects()) |
2221 offset = m_floatingObjects->logicalLeftOffsetForPositioningFloat(fixedOf fset, logicalTop, heightRemaining); | 2221 offset = m_floatingObjects->logicalLeftOffsetForPositioningFloat(fixedOf fset, logicalTop, heightRemaining); |
2222 return adjustLogicalLeftOffsetForLine(offset, applyTextIndent); | 2222 return adjustLogicalLeftOffsetForLine(offset, applyTextIndent); |
2223 } | 2223 } |
2224 | 2224 |
(...skipping 18 matching lines...) Expand all Loading... | |
2243 LayoutUnit LayoutBlockFlow::adjustLogicalRightOffsetForLine(LayoutUnit offsetFro mFloats, bool applyTextIndent) const | 2243 LayoutUnit LayoutBlockFlow::adjustLogicalRightOffsetForLine(LayoutUnit offsetFro mFloats, bool applyTextIndent) const |
2244 { | 2244 { |
2245 LayoutUnit right = offsetFromFloats; | 2245 LayoutUnit right = offsetFromFloats; |
2246 | 2246 |
2247 if (applyTextIndent && !style()->isLeftToRightDirection()) | 2247 if (applyTextIndent && !style()->isLeftToRightDirection()) |
2248 right -= textIndentOffset(); | 2248 right -= textIndentOffset(); |
2249 | 2249 |
2250 return right; | 2250 return right; |
2251 } | 2251 } |
2252 | 2252 |
2253 LayoutPoint LayoutBlockFlow::computeLogicalLocationForFloat(const FloatingObject * floatingObject, LayoutUnit logicalTopOffset) const | 2253 LayoutPoint LayoutBlockFlow::computeLogicalLocationForFloat(const FloatingObject & floatingObject, LayoutUnit logicalTopOffset) const |
2254 { | 2254 { |
2255 LayoutBox* childBox = floatingObject->layoutObject(); | 2255 LayoutBox* childBox = floatingObject.layoutObject(); |
2256 LayoutUnit logicalLeftOffset = logicalLeftOffsetForContent(); // Constant pa rt of left offset. | 2256 LayoutUnit logicalLeftOffset = logicalLeftOffsetForContent(); // Constant pa rt of left offset. |
2257 LayoutUnit logicalRightOffset; // Constant part of right offset. | 2257 LayoutUnit logicalRightOffset; // Constant part of right offset. |
2258 logicalRightOffset = logicalRightOffsetForContent(); | 2258 logicalRightOffset = logicalRightOffsetForContent(); |
2259 | 2259 |
2260 LayoutUnit floatLogicalWidth = std::min(logicalWidthForFloat(floatingObject) , logicalRightOffset - logicalLeftOffset); // The width we look for. | 2260 LayoutUnit floatLogicalWidth = std::min(logicalWidthForFloat(floatingObject) , logicalRightOffset - logicalLeftOffset); // The width we look for. |
2261 | 2261 |
2262 LayoutUnit floatLogicalLeft; | 2262 LayoutUnit floatLogicalLeft; |
2263 | 2263 |
2264 bool insideFlowThread = flowThreadContainingBlock(); | 2264 bool insideFlowThread = flowThreadContainingBlock(); |
2265 | 2265 |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2327 floatBox.setChildNeedsLayout(MarkOnlyThis); | 2327 floatBox.setChildNeedsLayout(MarkOnlyThis); |
2328 | 2328 |
2329 bool needsBlockDirectionLocationSetBeforeLayout = isChildLayoutBlock && view ()->layoutState()->needsBlockDirectionLocationSetBeforeLayout(); | 2329 bool needsBlockDirectionLocationSetBeforeLayout = isChildLayoutBlock && view ()->layoutState()->needsBlockDirectionLocationSetBeforeLayout(); |
2330 if (!needsBlockDirectionLocationSetBeforeLayout || isWritingModeRoot()) { // We are unsplittable if we're a block flow root. | 2330 if (!needsBlockDirectionLocationSetBeforeLayout || isWritingModeRoot()) { // We are unsplittable if we're a block flow root. |
2331 floatBox.layoutIfNeeded(); | 2331 floatBox.layoutIfNeeded(); |
2332 } else { | 2332 } else { |
2333 floatBox.updateLogicalWidth(); | 2333 floatBox.updateLogicalWidth(); |
2334 floatBox.computeAndSetBlockDirectionMargins(this); | 2334 floatBox.computeAndSetBlockDirectionMargins(this); |
2335 } | 2335 } |
2336 | 2336 |
2337 setLogicalWidthForFloat(newObj.get(), logicalWidthForChild(floatBox) + margi nStartForChild(floatBox) + marginEndForChild(floatBox)); | 2337 setLogicalWidthForFloat(*newObj, logicalWidthForChild(floatBox) + marginStar tForChild(floatBox) + marginEndForChild(floatBox)); |
2338 | 2338 |
2339 return m_floatingObjects->add(newObj.release()); | 2339 return m_floatingObjects->add(newObj.release()); |
2340 } | 2340 } |
2341 | 2341 |
2342 void LayoutBlockFlow::removeFloatingObject(LayoutBox* floatBox) | 2342 void LayoutBlockFlow::removeFloatingObject(LayoutBox* floatBox) |
2343 { | 2343 { |
2344 if (m_floatingObjects) { | 2344 if (m_floatingObjects) { |
2345 const FloatingObjectSet& floatingObjectSet = m_floatingObjects->set(); | 2345 const FloatingObjectSet& floatingObjectSet = m_floatingObjects->set(); |
2346 FloatingObjectSetIterator it = floatingObjectSet.find<FloatingObjectHash Translator>(floatBox); | 2346 FloatingObjectSetIterator it = floatingObjectSet.find<FloatingObjectHash Translator>(floatBox); |
2347 if (it != floatingObjectSet.end()) { | 2347 if (it != floatingObjectSet.end()) { |
2348 FloatingObject* floatingObject = it->get(); | 2348 FloatingObject& floatingObject = *it->get(); |
Julien - ping for review
2015/03/18 01:36:07
const FloatingObject&? (I will not repeat this com
Sunil Ratnu
2015/06/04 08:40:46
We cant have const here because of the remove() me
| |
2349 if (childrenInline()) { | 2349 if (childrenInline()) { |
2350 LayoutUnit logicalTop = logicalTopForFloat(floatingObject); | 2350 LayoutUnit logicalTop = logicalTopForFloat(floatingObject); |
2351 LayoutUnit logicalBottom = logicalBottomForFloat(floatingObject) ; | 2351 LayoutUnit logicalBottom = logicalBottomForFloat(floatingObject) ; |
2352 | 2352 |
2353 // Fix for https://bugs.webkit.org/show_bug.cgi?id=54995. | 2353 // Fix for https://bugs.webkit.org/show_bug.cgi?id=54995. |
2354 if (logicalBottom < 0 || logicalBottom < logicalTop || logicalTo p == LayoutUnit::max()) { | 2354 if (logicalBottom < 0 || logicalBottom < logicalTop || logicalTo p == LayoutUnit::max()) { |
2355 logicalBottom = LayoutUnit::max(); | 2355 logicalBottom = LayoutUnit::max(); |
2356 } else { | 2356 } else { |
2357 // Special-case zero- and less-than-zero-height floats: thos e don't touch | 2357 // Special-case zero- and less-than-zero-height floats: thos e don't touch |
2358 // the line that they're on, but it still needs to be dirtie d. This is | 2358 // the line that they're on, but it still needs to be dirtie d. This is |
2359 // accomplished by pretending they have a height of 1. | 2359 // accomplished by pretending they have a height of 1. |
2360 logicalBottom = std::max(logicalBottom, logicalTop + 1); | 2360 logicalBottom = std::max(logicalBottom, logicalTop + 1); |
2361 } | 2361 } |
2362 if (floatingObject->originatingLine()) { | 2362 if (floatingObject.originatingLine()) { |
2363 if (!selfNeedsLayout()) { | 2363 if (!selfNeedsLayout()) { |
2364 ASSERT(floatingObject->originatingLine()->layoutObject() == this); | 2364 ASSERT(floatingObject.originatingLine()->layoutObject() == this); |
2365 floatingObject->originatingLine()->markDirty(); | 2365 floatingObject.originatingLine()->markDirty(); |
2366 } | 2366 } |
2367 #if ENABLE(ASSERT) | 2367 #if ENABLE(ASSERT) |
2368 floatingObject->setOriginatingLine(0); | 2368 floatingObject.setOriginatingLine(0); |
2369 #endif | 2369 #endif |
2370 } | 2370 } |
2371 markLinesDirtyInBlockRange(0, logicalBottom); | 2371 markLinesDirtyInBlockRange(0, logicalBottom); |
2372 } | 2372 } |
2373 m_floatingObjects->remove(floatingObject); | 2373 m_floatingObjects->remove(&floatingObject); |
2374 } | 2374 } |
2375 } | 2375 } |
2376 } | 2376 } |
2377 | 2377 |
2378 void LayoutBlockFlow::removeFloatingObjectsBelow(FloatingObject* lastFloat, int logicalOffset) | 2378 void LayoutBlockFlow::removeFloatingObjectsBelow(FloatingObject* lastFloat, int logicalOffset) |
2379 { | 2379 { |
2380 if (!containsFloats()) | 2380 if (!containsFloats()) |
2381 return; | 2381 return; |
2382 | 2382 |
2383 const FloatingObjectSet& floatingObjectSet = m_floatingObjects->set(); | 2383 const FloatingObjectSet& floatingObjectSet = m_floatingObjects->set(); |
2384 FloatingObject* curr = floatingObjectSet.last().get(); | 2384 FloatingObject* curr = floatingObjectSet.last().get(); |
2385 while (curr != lastFloat && (!curr->isPlaced() || logicalTopForFloat(curr) > = logicalOffset)) { | 2385 while (curr != lastFloat && (!curr->isPlaced() || logicalTopForFloat(*curr) >= logicalOffset)) { |
2386 m_floatingObjects->remove(curr); | 2386 m_floatingObjects->remove(curr); |
2387 if (floatingObjectSet.isEmpty()) | 2387 if (floatingObjectSet.isEmpty()) |
2388 break; | 2388 break; |
2389 curr = floatingObjectSet.last().get(); | 2389 curr = floatingObjectSet.last().get(); |
2390 } | 2390 } |
2391 } | 2391 } |
2392 | 2392 |
2393 bool LayoutBlockFlow::positionNewFloats(LineWidth* width) | 2393 bool LayoutBlockFlow::positionNewFloats(LineWidth* width) |
2394 { | 2394 { |
2395 if (!m_floatingObjects) | 2395 if (!m_floatingObjects) |
(...skipping 20 matching lines...) Expand all Loading... | |
2416 lastPlacedFloatingObject = it->get(); | 2416 lastPlacedFloatingObject = it->get(); |
2417 ++it; | 2417 ++it; |
2418 break; | 2418 break; |
2419 } | 2419 } |
2420 } | 2420 } |
2421 | 2421 |
2422 LayoutUnit logicalTop = logicalHeight(); | 2422 LayoutUnit logicalTop = logicalHeight(); |
2423 | 2423 |
2424 // The float cannot start above the top position of the last positioned floa t. | 2424 // The float cannot start above the top position of the last positioned floa t. |
2425 if (lastPlacedFloatingObject) | 2425 if (lastPlacedFloatingObject) |
2426 logicalTop = std::max(logicalTopForFloat(lastPlacedFloatingObject), logi calTop); | 2426 logicalTop = std::max(logicalTopForFloat(*lastPlacedFloatingObject), log icalTop); |
2427 | 2427 |
2428 FloatingObjectSetIterator end = floatingObjectSet.end(); | 2428 FloatingObjectSetIterator end = floatingObjectSet.end(); |
2429 // Now walk through the set of unpositioned floats and place them. | 2429 // Now walk through the set of unpositioned floats and place them. |
2430 for (; it != end; ++it) { | 2430 for (; it != end; ++it) { |
2431 FloatingObject* floatingObject = it->get(); | 2431 FloatingObject& floatingObject = *it->get(); |
2432 // The containing block is responsible for positioning floats, so if we have floats in our | 2432 // The containing block is responsible for positioning floats, so if we have floats in our |
2433 // list that come from somewhere else, do not attempt to position them. | 2433 // list that come from somewhere else, do not attempt to position them. |
2434 if (floatingObject->layoutObject()->containingBlock() != this) | 2434 if (floatingObject.layoutObject()->containingBlock() != this) |
2435 continue; | 2435 continue; |
2436 | 2436 |
2437 LayoutBox* childBox = floatingObject->layoutObject(); | 2437 LayoutBox* childBox = floatingObject.layoutObject(); |
2438 | 2438 |
2439 // FIXME Investigate if this can be removed. crbug.com/370006 | 2439 // FIXME Investigate if this can be removed. crbug.com/370006 |
2440 childBox->setMayNeedPaintInvalidation(); | 2440 childBox->setMayNeedPaintInvalidation(); |
2441 | 2441 |
2442 LayoutUnit childLogicalLeftMargin = style()->isLeftToRightDirection() ? marginStartForChild(*childBox) : marginEndForChild(*childBox); | 2442 LayoutUnit childLogicalLeftMargin = style()->isLeftToRightDirection() ? marginStartForChild(*childBox) : marginEndForChild(*childBox); |
2443 if (childBox->style()->clear() & CLEFT) | 2443 if (childBox->style()->clear() & CLEFT) |
2444 logicalTop = std::max(lowestFloatLogicalBottom(FloatingObject::Float Left), logicalTop); | 2444 logicalTop = std::max(lowestFloatLogicalBottom(FloatingObject::Float Left), logicalTop); |
2445 if (childBox->style()->clear() & CRIGHT) | 2445 if (childBox->style()->clear() & CRIGHT) |
2446 logicalTop = std::max(lowestFloatLogicalBottom(FloatingObject::Float Right), logicalTop); | 2446 logicalTop = std::max(lowestFloatLogicalBottom(FloatingObject::Float Right), logicalTop); |
2447 | 2447 |
(...skipping 20 matching lines...) Expand all Loading... | |
2468 // See if we have a pagination strut that is making us move down fur ther. | 2468 // See if we have a pagination strut that is making us move down fur ther. |
2469 // Note that an unsplittable child can't also have a pagination stru t, so this is | 2469 // Note that an unsplittable child can't also have a pagination stru t, so this is |
2470 // exclusive with the case above. | 2470 // exclusive with the case above. |
2471 LayoutBlockFlow* childBlockFlow = childBox->isLayoutBlockFlow() ? to LayoutBlockFlow(childBox) : 0; | 2471 LayoutBlockFlow* childBlockFlow = childBox->isLayoutBlockFlow() ? to LayoutBlockFlow(childBox) : 0; |
2472 if (childBlockFlow && childBlockFlow->paginationStrut()) { | 2472 if (childBlockFlow && childBlockFlow->paginationStrut()) { |
2473 newLogicalTop += childBlockFlow->paginationStrut(); | 2473 newLogicalTop += childBlockFlow->paginationStrut(); |
2474 childBlockFlow->setPaginationStrut(0); | 2474 childBlockFlow->setPaginationStrut(0); |
2475 } | 2475 } |
2476 | 2476 |
2477 if (newLogicalTop != floatLogicalLocation.y()) { | 2477 if (newLogicalTop != floatLogicalLocation.y()) { |
2478 floatingObject->setPaginationStrut(newLogicalTop - floatLogicalL ocation.y()); | 2478 floatingObject.setPaginationStrut(newLogicalTop - floatLogicalLo cation.y()); |
2479 | 2479 |
2480 floatLogicalLocation = computeLogicalLocationForFloat(floatingOb ject, newLogicalTop); | 2480 floatLogicalLocation = computeLogicalLocationForFloat(floatingOb ject, newLogicalTop); |
2481 setLogicalLeftForFloat(floatingObject, floatLogicalLocation.x()) ; | 2481 setLogicalLeftForFloat(floatingObject, floatLogicalLocation.x()) ; |
2482 | 2482 |
2483 setLogicalLeftForChild(*childBox, floatLogicalLocation.x() + chi ldLogicalLeftMargin); | 2483 setLogicalLeftForChild(*childBox, floatLogicalLocation.x() + chi ldLogicalLeftMargin); |
2484 setLogicalTopForChild(*childBox, floatLogicalLocation.y() + marg inBeforeForChild(*childBox)); | 2484 setLogicalTopForChild(*childBox, floatLogicalLocation.y() + marg inBeforeForChild(*childBox)); |
2485 | 2485 |
2486 if (childBox->isLayoutBlock()) | 2486 if (childBox->isLayoutBlock()) |
2487 childBox->setChildNeedsLayout(MarkOnlyThis); | 2487 childBox->setChildNeedsLayout(MarkOnlyThis); |
2488 childBox->layoutIfNeeded(); | 2488 childBox->layoutIfNeeded(); |
2489 } | 2489 } |
2490 } | 2490 } |
2491 | 2491 |
2492 setLogicalTopForFloat(floatingObject, floatLogicalLocation.y()); | 2492 setLogicalTopForFloat(floatingObject, floatLogicalLocation.y()); |
2493 | 2493 |
2494 setLogicalHeightForFloat(floatingObject, logicalHeightForChild(*childBox ) + marginBeforeForChild(*childBox) + marginAfterForChild(*childBox)); | 2494 setLogicalHeightForFloat(floatingObject, logicalHeightForChild(*childBox ) + marginBeforeForChild(*childBox) + marginAfterForChild(*childBox)); |
2495 | 2495 |
2496 m_floatingObjects->addPlacedObject(floatingObject); | 2496 m_floatingObjects->addPlacedObject(&floatingObject); |
2497 | 2497 |
2498 if (ShapeOutsideInfo* shapeOutside = childBox->shapeOutsideInfo()) | 2498 if (ShapeOutsideInfo* shapeOutside = childBox->shapeOutsideInfo()) |
2499 shapeOutside->setReferenceBoxLogicalSize(logicalSizeForChild(*childB ox)); | 2499 shapeOutside->setReferenceBoxLogicalSize(logicalSizeForChild(*childB ox)); |
2500 | 2500 |
2501 if (width) | 2501 if (width) |
2502 width->shrinkAvailableWidthForNewFloatIfNeeded(floatingObject); | 2502 width->shrinkAvailableWidthForNewFloatIfNeeded(floatingObject); |
2503 } | 2503 } |
2504 return true; | 2504 return true; |
2505 } | 2505 } |
2506 | 2506 |
2507 bool LayoutBlockFlow::hasOverhangingFloat(LayoutBox* renderer) | 2507 bool LayoutBlockFlow::hasOverhangingFloat(LayoutBox* renderer) |
2508 { | 2508 { |
2509 if (!m_floatingObjects || hasColumns() || !parent()) | 2509 if (!m_floatingObjects || hasColumns() || !parent()) |
2510 return false; | 2510 return false; |
2511 | 2511 |
2512 const FloatingObjectSet& floatingObjectSet = m_floatingObjects->set(); | 2512 const FloatingObjectSet& floatingObjectSet = m_floatingObjects->set(); |
2513 FloatingObjectSetIterator it = floatingObjectSet.find<FloatingObjectHashTran slator>(renderer); | 2513 FloatingObjectSetIterator it = floatingObjectSet.find<FloatingObjectHashTran slator>(renderer); |
2514 if (it == floatingObjectSet.end()) | 2514 if (it == floatingObjectSet.end()) |
2515 return false; | 2515 return false; |
2516 | 2516 |
2517 return logicalBottomForFloat(it->get()) > logicalHeight(); | 2517 return logicalBottomForFloat(*it->get()) > logicalHeight(); |
2518 } | 2518 } |
2519 | 2519 |
2520 void LayoutBlockFlow::addIntrudingFloats(LayoutBlockFlow* prev, LayoutUnit logic alLeftOffset, LayoutUnit logicalTopOffset) | 2520 void LayoutBlockFlow::addIntrudingFloats(LayoutBlockFlow* prev, LayoutUnit logic alLeftOffset, LayoutUnit logicalTopOffset) |
2521 { | 2521 { |
2522 ASSERT(!avoidsFloats()); | 2522 ASSERT(!avoidsFloats()); |
2523 | 2523 |
2524 // If we create our own block formatting context then our contents don't int eract with floats outside it, even those from our parent. | 2524 // If we create our own block formatting context then our contents don't int eract with floats outside it, even those from our parent. |
2525 if (createsNewFormattingContext()) | 2525 if (createsNewFormattingContext()) |
2526 return; | 2526 return; |
2527 | 2527 |
2528 // If the parent or previous sibling doesn't have any floats to add, don't b other. | 2528 // If the parent or previous sibling doesn't have any floats to add, don't b other. |
2529 if (!prev->m_floatingObjects) | 2529 if (!prev->m_floatingObjects) |
2530 return; | 2530 return; |
2531 | 2531 |
2532 logicalLeftOffset += marginLogicalLeft(); | 2532 logicalLeftOffset += marginLogicalLeft(); |
2533 | 2533 |
2534 const FloatingObjectSet& prevSet = prev->m_floatingObjects->set(); | 2534 const FloatingObjectSet& prevSet = prev->m_floatingObjects->set(); |
2535 FloatingObjectSetIterator prevEnd = prevSet.end(); | 2535 FloatingObjectSetIterator prevEnd = prevSet.end(); |
2536 for (FloatingObjectSetIterator prevIt = prevSet.begin(); prevIt != prevEnd; ++prevIt) { | 2536 for (FloatingObjectSetIterator prevIt = prevSet.begin(); prevIt != prevEnd; ++prevIt) { |
2537 FloatingObject* floatingObject = prevIt->get(); | 2537 FloatingObject& floatingObject = *prevIt->get(); |
2538 if (logicalBottomForFloat(floatingObject) > logicalTopOffset) { | 2538 if (logicalBottomForFloat(floatingObject) > logicalTopOffset) { |
2539 if (!m_floatingObjects || !m_floatingObjects->set().contains(floatin gObject)) { | 2539 if (!m_floatingObjects || !m_floatingObjects->set().contains(&floati ngObject)) { |
2540 // We create the floating object list lazily. | 2540 // We create the floating object list lazily. |
2541 if (!m_floatingObjects) | 2541 if (!m_floatingObjects) |
2542 createFloatingObjects(); | 2542 createFloatingObjects(); |
2543 | 2543 |
2544 // Applying the child's margin makes no sense in the case where the child was passed in. | 2544 // Applying the child's margin makes no sense in the case where the child was passed in. |
2545 // since this margin was added already through the modification of the |logicalLeftOffset| variable | 2545 // since this margin was added already through the modification of the |logicalLeftOffset| variable |
2546 // above. |logicalLeftOffset| will equal the margin in this case , so it's already been taken | 2546 // above. |logicalLeftOffset| will equal the margin in this case , so it's already been taken |
2547 // into account. Only apply this code if prev is the parent, sin ce otherwise the left margin | 2547 // into account. Only apply this code if prev is the parent, sin ce otherwise the left margin |
2548 // will get applied twice. | 2548 // will get applied twice. |
2549 LayoutSize offset = isHorizontalWritingMode() | 2549 LayoutSize offset = isHorizontalWritingMode() |
2550 ? LayoutSize(logicalLeftOffset - (prev != parent() ? prev->m arginLeft() : LayoutUnit()), logicalTopOffset) | 2550 ? LayoutSize(logicalLeftOffset - (prev != parent() ? prev->m arginLeft() : LayoutUnit()), logicalTopOffset) |
2551 : LayoutSize(logicalTopOffset, logicalLeftOffset - (prev != parent() ? prev->marginTop() : LayoutUnit())); | 2551 : LayoutSize(logicalTopOffset, logicalLeftOffset - (prev != parent() ? prev->marginTop() : LayoutUnit())); |
2552 | 2552 |
2553 m_floatingObjects->add(floatingObject->copyToNewContainer(offset )); | 2553 m_floatingObjects->add(floatingObject.copyToNewContainer(offset) ); |
2554 } | 2554 } |
2555 } | 2555 } |
2556 } | 2556 } |
2557 } | 2557 } |
2558 | 2558 |
2559 void LayoutBlockFlow::addOverhangingFloats(LayoutBlockFlow* child, bool makeChil dPaintOtherFloats) | 2559 void LayoutBlockFlow::addOverhangingFloats(LayoutBlockFlow* child, bool makeChil dPaintOtherFloats) |
2560 { | 2560 { |
2561 // Prevent floats from being added to the canvas by the root element, e.g., <html>. | 2561 // Prevent floats from being added to the canvas by the root element, e.g., <html>. |
2562 if (!child->containsFloats() || child->isLayoutRegion() || child->createsNew FormattingContext()) | 2562 if (!child->containsFloats() || child->isLayoutRegion() || child->createsNew FormattingContext()) |
2563 return; | 2563 return; |
2564 | 2564 |
2565 LayoutUnit childLogicalTop = child->logicalTop(); | 2565 LayoutUnit childLogicalTop = child->logicalTop(); |
2566 LayoutUnit childLogicalLeft = child->logicalLeft(); | 2566 LayoutUnit childLogicalLeft = child->logicalLeft(); |
2567 | 2567 |
2568 // Floats that will remain the child's responsibility to paint should factor into its | 2568 // Floats that will remain the child's responsibility to paint should factor into its |
2569 // overflow. | 2569 // overflow. |
2570 FloatingObjectSetIterator childEnd = child->m_floatingObjects->set().end(); | 2570 FloatingObjectSetIterator childEnd = child->m_floatingObjects->set().end(); |
2571 for (FloatingObjectSetIterator childIt = child->m_floatingObjects->set().beg in(); childIt != childEnd; ++childIt) { | 2571 for (FloatingObjectSetIterator childIt = child->m_floatingObjects->set().beg in(); childIt != childEnd; ++childIt) { |
2572 FloatingObject* floatingObject = childIt->get(); | 2572 FloatingObject& floatingObject = *childIt->get(); |
2573 LayoutUnit logicalBottomForFloat = std::min(this->logicalBottomForFloat( floatingObject), LayoutUnit::max() - childLogicalTop); | 2573 LayoutUnit logicalBottomForFloat = std::min(this->logicalBottomForFloat( floatingObject), LayoutUnit::max() - childLogicalTop); |
2574 LayoutUnit logicalBottom = childLogicalTop + logicalBottomForFloat; | 2574 LayoutUnit logicalBottom = childLogicalTop + logicalBottomForFloat; |
2575 | 2575 |
2576 if (logicalBottom > logicalHeight()) { | 2576 if (logicalBottom > logicalHeight()) { |
2577 // If the object is not in the list, we add it now. | 2577 // If the object is not in the list, we add it now. |
2578 if (!containsFloat(floatingObject->layoutObject())) { | 2578 if (!containsFloat(floatingObject.layoutObject())) { |
2579 LayoutSize offset = isHorizontalWritingMode() ? LayoutSize(-chil dLogicalLeft, -childLogicalTop) : LayoutSize(-childLogicalTop, -childLogicalLeft ); | 2579 LayoutSize offset = isHorizontalWritingMode() ? LayoutSize(-chil dLogicalLeft, -childLogicalTop) : LayoutSize(-childLogicalTop, -childLogicalLeft ); |
2580 bool shouldPaint = false; | 2580 bool shouldPaint = false; |
2581 | 2581 |
2582 // The nearest enclosing layer always paints the float (so that zindex and stacking | 2582 // The nearest enclosing layer always paints the float (so that zindex and stacking |
2583 // behaves properly). We always want to propagate the desire to paint the float as | 2583 // behaves properly). We always want to propagate the desire to paint the float as |
2584 // far out as we can, to the outermost block that overlaps the f loat, stopping only | 2584 // far out as we can, to the outermost block that overlaps the f loat, stopping only |
2585 // if we hit a self-painting layer boundary. | 2585 // if we hit a self-painting layer boundary. |
2586 if (floatingObject->layoutObject()->enclosingFloatPaintingLayer( ) == enclosingFloatPaintingLayer()) { | 2586 if (floatingObject.layoutObject()->enclosingFloatPaintingLayer() == enclosingFloatPaintingLayer()) { |
2587 floatingObject->setShouldPaint(false); | 2587 floatingObject.setShouldPaint(false); |
2588 shouldPaint = true; | 2588 shouldPaint = true; |
2589 } | 2589 } |
2590 // We create the floating object list lazily. | 2590 // We create the floating object list lazily. |
2591 if (!m_floatingObjects) | 2591 if (!m_floatingObjects) |
2592 createFloatingObjects(); | 2592 createFloatingObjects(); |
2593 | 2593 |
2594 m_floatingObjects->add(floatingObject->copyToNewContainer(offset , shouldPaint, true)); | 2594 m_floatingObjects->add(floatingObject.copyToNewContainer(offset, shouldPaint, true)); |
2595 } | 2595 } |
2596 } else { | 2596 } else { |
2597 if (makeChildPaintOtherFloats && !floatingObject->shouldPaint() && ! floatingObject->layoutObject()->hasSelfPaintingLayer() | 2597 if (makeChildPaintOtherFloats && !floatingObject.shouldPaint() && !f loatingObject.layoutObject()->hasSelfPaintingLayer() |
2598 && floatingObject->layoutObject()->isDescendantOf(child) && floa tingObject->layoutObject()->enclosingFloatPaintingLayer() == child->enclosingFlo atPaintingLayer()) { | 2598 && floatingObject.layoutObject()->isDescendantOf(child) && float ingObject.layoutObject()->enclosingFloatPaintingLayer() == child->enclosingFloat PaintingLayer()) { |
2599 // The float is not overhanging from this block, so if it is a d escendant of the child, the child should | 2599 // The float is not overhanging from this block, so if it is a d escendant of the child, the child should |
2600 // paint it (the other case is that it is intruding into the chi ld), unless it has its own layer or enclosing | 2600 // paint it (the other case is that it is intruding into the chi ld), unless it has its own layer or enclosing |
2601 // layer. | 2601 // layer. |
2602 // If makeChildPaintOtherFloats is false, it means that the chil d must already know about all the floats | 2602 // If makeChildPaintOtherFloats is false, it means that the chil d must already know about all the floats |
2603 // it should paint. | 2603 // it should paint. |
2604 floatingObject->setShouldPaint(true); | 2604 floatingObject.setShouldPaint(true); |
2605 } | 2605 } |
2606 | 2606 |
2607 // 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 | 2607 // 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 |
2608 // child now. | 2608 // child now. |
2609 if (floatingObject->isDescendant()) | 2609 if (floatingObject.isDescendant()) |
2610 child->addOverflowFromChild(floatingObject->layoutObject(), Layo utSize(xPositionForFloatIncludingMargin(floatingObject), yPositionForFloatInclud ingMargin(floatingObject))); | 2610 child->addOverflowFromChild(floatingObject.layoutObject(), Layou tSize(xPositionForFloatIncludingMargin(floatingObject), yPositionForFloatIncludi ngMargin(floatingObject))); |
2611 } | 2611 } |
2612 } | 2612 } |
2613 } | 2613 } |
2614 | 2614 |
2615 LayoutUnit LayoutBlockFlow::lowestFloatLogicalBottom(FloatingObject::Type floatT ype) const | 2615 LayoutUnit LayoutBlockFlow::lowestFloatLogicalBottom(FloatingObject::Type floatT ype) const |
2616 { | 2616 { |
2617 if (!m_floatingObjects) | 2617 if (!m_floatingObjects) |
2618 return LayoutUnit(); | 2618 return LayoutUnit(); |
2619 | 2619 |
2620 return m_floatingObjects->lowestFloatLogicalBottom(floatType); | 2620 return m_floatingObjects->lowestFloatLogicalBottom(floatType); |
2621 } | 2621 } |
2622 | 2622 |
2623 LayoutUnit LayoutBlockFlow::nextFloatLogicalBottomBelow(LayoutUnit logicalHeight , ShapeOutsideFloatOffsetMode offsetMode) const | 2623 LayoutUnit LayoutBlockFlow::nextFloatLogicalBottomBelow(LayoutUnit logicalHeight , ShapeOutsideFloatOffsetMode offsetMode) const |
2624 { | 2624 { |
2625 if (!m_floatingObjects) | 2625 if (!m_floatingObjects) |
2626 return logicalHeight; | 2626 return logicalHeight; |
2627 | 2627 |
2628 LayoutUnit logicalBottom; | 2628 LayoutUnit logicalBottom; |
2629 const FloatingObjectSet& floatingObjectSet = m_floatingObjects->set(); | 2629 const FloatingObjectSet& floatingObjectSet = m_floatingObjects->set(); |
2630 FloatingObjectSetIterator end = floatingObjectSet.end(); | 2630 FloatingObjectSetIterator end = floatingObjectSet.end(); |
2631 for (FloatingObjectSetIterator it = floatingObjectSet.begin(); it != end; ++ it) { | 2631 for (FloatingObjectSetIterator it = floatingObjectSet.begin(); it != end; ++ it) { |
2632 FloatingObject* floatingObject = it->get(); | 2632 FloatingObject& floatingObject = *it->get(); |
2633 LayoutUnit floatLogicalBottom = logicalBottomForFloat(floatingObject); | 2633 LayoutUnit floatLogicalBottom = logicalBottomForFloat(floatingObject); |
2634 ShapeOutsideInfo* shapeOutside = floatingObject->layoutObject()->shapeOu tsideInfo(); | 2634 ShapeOutsideInfo* shapeOutside = floatingObject.layoutObject()->shapeOut sideInfo(); |
2635 if (shapeOutside && (offsetMode == ShapeOutsideFloatShapeOffset)) { | 2635 if (shapeOutside && (offsetMode == ShapeOutsideFloatShapeOffset)) { |
2636 LayoutUnit shapeLogicalBottom = logicalTopForFloat(floatingObject) + marginBeforeForChild(*(floatingObject->layoutObject())) + shapeOutside->shapeLo gicalBottom(); | 2636 LayoutUnit shapeLogicalBottom = logicalTopForFloat(floatingObject) + marginBeforeForChild(*(floatingObject.layoutObject())) + shapeOutside->shapeLog icalBottom(); |
2637 // Use the shapeLogicalBottom unless it extends outside of the margi n box, in which case it is clipped. | 2637 // Use the shapeLogicalBottom unless it extends outside of the margi n box, in which case it is clipped. |
2638 if (shapeLogicalBottom < floatLogicalBottom) | 2638 if (shapeLogicalBottom < floatLogicalBottom) |
2639 floatLogicalBottom = shapeLogicalBottom; | 2639 floatLogicalBottom = shapeLogicalBottom; |
2640 } | 2640 } |
2641 if (floatLogicalBottom > logicalHeight) | 2641 if (floatLogicalBottom > logicalHeight) |
2642 logicalBottom = logicalBottom ? std::min(floatLogicalBottom, logical Bottom) : floatLogicalBottom; | 2642 logicalBottom = logicalBottom ? std::min(floatLogicalBottom, logical Bottom) : floatLogicalBottom; |
2643 } | 2643 } |
2644 | 2644 |
2645 return logicalBottom; | 2645 return logicalBottom; |
2646 } | 2646 } |
2647 | 2647 |
2648 bool LayoutBlockFlow::hitTestFloats(const HitTestRequest& request, HitTestResult & result, const HitTestLocation& locationInContainer, const LayoutPoint& accumul atedOffset) | 2648 bool LayoutBlockFlow::hitTestFloats(const HitTestRequest& request, HitTestResult & result, const HitTestLocation& locationInContainer, const LayoutPoint& accumul atedOffset) |
2649 { | 2649 { |
2650 if (!m_floatingObjects) | 2650 if (!m_floatingObjects) |
2651 return false; | 2651 return false; |
2652 | 2652 |
2653 LayoutPoint adjustedLocation = accumulatedOffset; | 2653 LayoutPoint adjustedLocation = accumulatedOffset; |
2654 if (isLayoutView()) { | 2654 if (isLayoutView()) { |
2655 DoublePoint position = toLayoutView(this)->frameView()->scrollPositionDo uble(); | 2655 DoublePoint position = toLayoutView(this)->frameView()->scrollPositionDo uble(); |
2656 adjustedLocation.move(position.x(), position.y()); | 2656 adjustedLocation.move(position.x(), position.y()); |
2657 } | 2657 } |
2658 | 2658 |
2659 const FloatingObjectSet& floatingObjectSet = m_floatingObjects->set(); | 2659 const FloatingObjectSet& floatingObjectSet = m_floatingObjects->set(); |
2660 FloatingObjectSetIterator begin = floatingObjectSet.begin(); | 2660 FloatingObjectSetIterator begin = floatingObjectSet.begin(); |
2661 for (FloatingObjectSetIterator it = floatingObjectSet.end(); it != begin;) { | 2661 for (FloatingObjectSetIterator it = floatingObjectSet.end(); it != begin;) { |
2662 --it; | 2662 --it; |
2663 FloatingObject* floatingObject = it->get(); | 2663 FloatingObject& floatingObject = *it->get(); |
2664 if (floatingObject->shouldPaint() && !floatingObject->layoutObject()->ha sSelfPaintingLayer()) { | 2664 if (floatingObject.shouldPaint() && !floatingObject.layoutObject()->hasS elfPaintingLayer()) { |
2665 LayoutUnit xOffset = xPositionForFloatIncludingMargin(floatingObject ) - floatingObject->layoutObject()->location().x(); | 2665 LayoutUnit xOffset = xPositionForFloatIncludingMargin(floatingObject ) - floatingObject.layoutObject()->location().x(); |
2666 LayoutUnit yOffset = yPositionForFloatIncludingMargin(floatingObject ) - floatingObject->layoutObject()->location().y(); | 2666 LayoutUnit yOffset = yPositionForFloatIncludingMargin(floatingObject ) - floatingObject.layoutObject()->location().y(); |
2667 LayoutPoint childPoint = flipFloatForWritingModeForChild(floatingObj ect, adjustedLocation + LayoutSize(xOffset, yOffset)); | 2667 LayoutPoint childPoint = flipFloatForWritingModeForChild(floatingObj ect, adjustedLocation + LayoutSize(xOffset, yOffset)); |
2668 if (floatingObject->layoutObject()->hitTest(request, result, locatio nInContainer, childPoint)) { | 2668 if (floatingObject.layoutObject()->hitTest(request, result, location InContainer, childPoint)) { |
2669 updateHitTestResult(result, locationInContainer.point() - toLayo utSize(childPoint)); | 2669 updateHitTestResult(result, locationInContainer.point() - toLayo utSize(childPoint)); |
2670 return true; | 2670 return true; |
2671 } | 2671 } |
2672 } | 2672 } |
2673 } | 2673 } |
2674 | 2674 |
2675 return false; | 2675 return false; |
2676 } | 2676 } |
2677 | 2677 |
2678 LayoutUnit LayoutBlockFlow::logicalLeftFloatOffsetForLine(LayoutUnit logicalTop, LayoutUnit fixedOffset, LayoutUnit logicalHeight) const | 2678 LayoutUnit LayoutBlockFlow::logicalLeftFloatOffsetForLine(LayoutUnit logicalTop, LayoutUnit fixedOffset, LayoutUnit logicalHeight) const |
(...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3155 } | 3155 } |
3156 if (isAnonymous()) | 3156 if (isAnonymous()) |
3157 return "LayoutBlockFlow (anonymous)"; | 3157 return "LayoutBlockFlow (anonymous)"; |
3158 if (isRelPositioned()) | 3158 if (isRelPositioned()) |
3159 return "LayoutBlockFlow (relative positioned)"; | 3159 return "LayoutBlockFlow (relative positioned)"; |
3160 return "LayoutBlockFlow"; | 3160 return "LayoutBlockFlow"; |
3161 } | 3161 } |
3162 | 3162 |
3163 | 3163 |
3164 } // namespace blink | 3164 } // namespace blink |
OLD | NEW |