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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 #include "core/layout/LayoutMultiColumnSpannerPlaceholder.h" | 42 #include "core/layout/LayoutMultiColumnSpannerPlaceholder.h" |
43 #include "core/layout/LayoutPagedFlowThread.h" | 43 #include "core/layout/LayoutPagedFlowThread.h" |
44 #include "core/layout/LayoutView.h" | 44 #include "core/layout/LayoutView.h" |
45 #include "core/layout/TextAutosizer.h" | 45 #include "core/layout/TextAutosizer.h" |
46 #include "core/layout/line/GlyphOverflow.h" | 46 #include "core/layout/line/GlyphOverflow.h" |
47 #include "core/layout/line/InlineIterator.h" | 47 #include "core/layout/line/InlineIterator.h" |
48 #include "core/layout/line/InlineTextBox.h" | 48 #include "core/layout/line/InlineTextBox.h" |
49 #include "core/layout/line/LineWidth.h" | 49 #include "core/layout/line/LineWidth.h" |
50 #include "core/layout/shapes/ShapeOutsideInfo.h" | 50 #include "core/layout/shapes/ShapeOutsideInfo.h" |
51 #include "core/paint/PaintLayer.h" | 51 #include "core/paint/PaintLayer.h" |
| 52 #include "wtf/PtrUtil.h" |
| 53 #include <memory> |
52 | 54 |
53 namespace blink { | 55 namespace blink { |
54 | 56 |
55 bool LayoutBlockFlow::s_canPropagateFloatIntoSibling = false; | 57 bool LayoutBlockFlow::s_canPropagateFloatIntoSibling = false; |
56 | 58 |
57 struct SameSizeAsLayoutBlockFlow : public LayoutBlock { | 59 struct SameSizeAsLayoutBlockFlow : public LayoutBlock { |
58 LineBoxList lineBoxes; | 60 LineBoxList lineBoxes; |
59 LayoutUnit m_paintInvalidationLogicalTopAndBottom[2]; | 61 LayoutUnit m_paintInvalidationLogicalTopAndBottom[2]; |
60 void* pointers[2]; | 62 void* pointers[2]; |
61 }; | 63 }; |
(...skipping 1055 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1117 floatMap.remove(floatingObject.layoutObject()); | 1119 floatMap.remove(floatingObject.layoutObject()); |
1118 } else { | 1120 } else { |
1119 changeLogicalTop = LayoutUnit(); | 1121 changeLogicalTop = LayoutUnit(); |
1120 changeLogicalBottom = std::max(changeLogicalBottom, logicalB
ottom); | 1122 changeLogicalBottom = std::max(changeLogicalBottom, logicalB
ottom); |
1121 } | 1123 } |
1122 } | 1124 } |
1123 } | 1125 } |
1124 | 1126 |
1125 LayoutBoxToFloatInfoMap::iterator end = floatMap.end(); | 1127 LayoutBoxToFloatInfoMap::iterator end = floatMap.end(); |
1126 for (LayoutBoxToFloatInfoMap::iterator it = floatMap.begin(); it != end;
++it) { | 1128 for (LayoutBoxToFloatInfoMap::iterator it = floatMap.begin(); it != end;
++it) { |
1127 OwnPtr<FloatingObject>& floatingObject = it->value; | 1129 std::unique_ptr<FloatingObject>& floatingObject = it->value; |
1128 if (!floatingObject->isDescendant()) { | 1130 if (!floatingObject->isDescendant()) { |
1129 changeLogicalTop = LayoutUnit(); | 1131 changeLogicalTop = LayoutUnit(); |
1130 changeLogicalBottom = std::max(changeLogicalBottom, logicalBotto
mForFloat(*floatingObject)); | 1132 changeLogicalBottom = std::max(changeLogicalBottom, logicalBotto
mForFloat(*floatingObject)); |
1131 } | 1133 } |
1132 } | 1134 } |
1133 | 1135 |
1134 markLinesDirtyInBlockRange(changeLogicalTop, changeLogicalBottom); | 1136 markLinesDirtyInBlockRange(changeLogicalTop, changeLogicalBottom); |
1135 } else if (!oldIntrudingFloatSet.isEmpty()) { | 1137 } else if (!oldIntrudingFloatSet.isEmpty()) { |
1136 // If there are previously intruding floats that no longer intrude, then
children with floats | 1138 // If there are previously intruding floats that no longer intrude, then
children with floats |
1137 // should also get layout because they might need their floating object
lists cleared. | 1139 // should also get layout because they might need their floating object
lists cleared. |
(...skipping 617 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1755 { | 1757 { |
1756 if (style()->marginBeforeCollapse() == MarginCollapseDiscard) { | 1758 if (style()->marginBeforeCollapse() == MarginCollapseDiscard) { |
1757 ASSERT(value); | 1759 ASSERT(value); |
1758 return; | 1760 return; |
1759 } | 1761 } |
1760 | 1762 |
1761 if (!m_rareData && !value) | 1763 if (!m_rareData && !value) |
1762 return; | 1764 return; |
1763 | 1765 |
1764 if (!m_rareData) | 1766 if (!m_rareData) |
1765 m_rareData = adoptPtr(new LayoutBlockFlowRareData(this)); | 1767 m_rareData = wrapUnique(new LayoutBlockFlowRareData(this)); |
1766 | 1768 |
1767 m_rareData->m_discardMarginBefore = value; | 1769 m_rareData->m_discardMarginBefore = value; |
1768 } | 1770 } |
1769 | 1771 |
1770 void LayoutBlockFlow::setMustDiscardMarginAfter(bool value) | 1772 void LayoutBlockFlow::setMustDiscardMarginAfter(bool value) |
1771 { | 1773 { |
1772 if (style()->marginAfterCollapse() == MarginCollapseDiscard) { | 1774 if (style()->marginAfterCollapse() == MarginCollapseDiscard) { |
1773 ASSERT(value); | 1775 ASSERT(value); |
1774 return; | 1776 return; |
1775 } | 1777 } |
1776 | 1778 |
1777 if (!m_rareData && !value) | 1779 if (!m_rareData && !value) |
1778 return; | 1780 return; |
1779 | 1781 |
1780 if (!m_rareData) | 1782 if (!m_rareData) |
1781 m_rareData = adoptPtr(new LayoutBlockFlowRareData(this)); | 1783 m_rareData = wrapUnique(new LayoutBlockFlowRareData(this)); |
1782 | 1784 |
1783 m_rareData->m_discardMarginAfter = value; | 1785 m_rareData->m_discardMarginAfter = value; |
1784 } | 1786 } |
1785 | 1787 |
1786 bool LayoutBlockFlow::mustDiscardMarginBefore() const | 1788 bool LayoutBlockFlow::mustDiscardMarginBefore() const |
1787 { | 1789 { |
1788 return style()->marginBeforeCollapse() == MarginCollapseDiscard || (m_rareDa
ta && m_rareData->m_discardMarginBefore); | 1790 return style()->marginBeforeCollapse() == MarginCollapseDiscard || (m_rareDa
ta && m_rareData->m_discardMarginBefore); |
1789 } | 1791 } |
1790 | 1792 |
1791 bool LayoutBlockFlow::mustDiscardMarginAfter() const | 1793 bool LayoutBlockFlow::mustDiscardMarginAfter() const |
(...skipping 24 matching lines...) Expand all Loading... |
1816 | 1818 |
1817 // FIXME: See |mustDiscardMarginBeforeForChild| above. | 1819 // FIXME: See |mustDiscardMarginBeforeForChild| above. |
1818 return false; | 1820 return false; |
1819 } | 1821 } |
1820 | 1822 |
1821 void LayoutBlockFlow::setMaxMarginBeforeValues(LayoutUnit pos, LayoutUnit neg) | 1823 void LayoutBlockFlow::setMaxMarginBeforeValues(LayoutUnit pos, LayoutUnit neg) |
1822 { | 1824 { |
1823 if (!m_rareData) { | 1825 if (!m_rareData) { |
1824 if (pos == LayoutBlockFlowRareData::positiveMarginBeforeDefault(this) &&
neg == LayoutBlockFlowRareData::negativeMarginBeforeDefault(this)) | 1826 if (pos == LayoutBlockFlowRareData::positiveMarginBeforeDefault(this) &&
neg == LayoutBlockFlowRareData::negativeMarginBeforeDefault(this)) |
1825 return; | 1827 return; |
1826 m_rareData = adoptPtr(new LayoutBlockFlowRareData(this)); | 1828 m_rareData = wrapUnique(new LayoutBlockFlowRareData(this)); |
1827 } | 1829 } |
1828 m_rareData->m_margins.setPositiveMarginBefore(pos); | 1830 m_rareData->m_margins.setPositiveMarginBefore(pos); |
1829 m_rareData->m_margins.setNegativeMarginBefore(neg); | 1831 m_rareData->m_margins.setNegativeMarginBefore(neg); |
1830 } | 1832 } |
1831 | 1833 |
1832 void LayoutBlockFlow::setMaxMarginAfterValues(LayoutUnit pos, LayoutUnit neg) | 1834 void LayoutBlockFlow::setMaxMarginAfterValues(LayoutUnit pos, LayoutUnit neg) |
1833 { | 1835 { |
1834 if (!m_rareData) { | 1836 if (!m_rareData) { |
1835 if (pos == LayoutBlockFlowRareData::positiveMarginAfterDefault(this) &&
neg == LayoutBlockFlowRareData::negativeMarginAfterDefault(this)) | 1837 if (pos == LayoutBlockFlowRareData::positiveMarginAfterDefault(this) &&
neg == LayoutBlockFlowRareData::negativeMarginAfterDefault(this)) |
1836 return; | 1838 return; |
1837 m_rareData = adoptPtr(new LayoutBlockFlowRareData(this)); | 1839 m_rareData = wrapUnique(new LayoutBlockFlowRareData(this)); |
1838 } | 1840 } |
1839 m_rareData->m_margins.setPositiveMarginAfter(pos); | 1841 m_rareData->m_margins.setPositiveMarginAfter(pos); |
1840 m_rareData->m_margins.setNegativeMarginAfter(neg); | 1842 m_rareData->m_margins.setNegativeMarginAfter(neg); |
1841 } | 1843 } |
1842 | 1844 |
1843 bool LayoutBlockFlow::mustSeparateMarginBeforeForChild(const LayoutBox& child) c
onst | 1845 bool LayoutBlockFlow::mustSeparateMarginBeforeForChild(const LayoutBox& child) c
onst |
1844 { | 1846 { |
1845 ASSERT(!child.selfNeedsLayout()); | 1847 ASSERT(!child.selfNeedsLayout()); |
1846 const ComputedStyle& childStyle = child.styleRef(); | 1848 const ComputedStyle& childStyle = child.styleRef(); |
1847 if (!child.isWritingModeRoot()) | 1849 if (!child.isWritingModeRoot()) |
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2191 if (newLogicalTop < logicalTop) | 2193 if (newLogicalTop < logicalTop) |
2192 break; | 2194 break; |
2193 } | 2195 } |
2194 ASSERT_NOT_REACHED(); | 2196 ASSERT_NOT_REACHED(); |
2195 } | 2197 } |
2196 return result; | 2198 return result; |
2197 } | 2199 } |
2198 | 2200 |
2199 void LayoutBlockFlow::createFloatingObjects() | 2201 void LayoutBlockFlow::createFloatingObjects() |
2200 { | 2202 { |
2201 m_floatingObjects = adoptPtr(new FloatingObjects(this, isHorizontalWritingMo
de())); | 2203 m_floatingObjects = wrapUnique(new FloatingObjects(this, isHorizontalWriting
Mode())); |
2202 } | 2204 } |
2203 | 2205 |
2204 void LayoutBlockFlow::willBeDestroyed() | 2206 void LayoutBlockFlow::willBeDestroyed() |
2205 { | 2207 { |
2206 // Mark as being destroyed to avoid trouble with merges in removeChild(). | 2208 // Mark as being destroyed to avoid trouble with merges in removeChild(). |
2207 m_beingDestroyed = true; | 2209 m_beingDestroyed = true; |
2208 | 2210 |
2209 // Make sure to destroy anonymous children first while they are still connec
ted to the rest of the tree, so that they will | 2211 // Make sure to destroy anonymous children first while they are still connec
ted to the rest of the tree, so that they will |
2210 // properly dirty line boxes that they are removed from. Effects that do :be
fore/:after only on hover could crash otherwise. | 2212 // properly dirty line boxes that they are removed from. Effects that do :be
fore/:after only on hover could crash otherwise. |
2211 children()->destroyLeftoverChildren(); | 2213 children()->destroyLeftoverChildren(); |
(...skipping 784 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2996 } else { | 2998 } else { |
2997 // Don't insert the object again if it's already in the list | 2999 // Don't insert the object again if it's already in the list |
2998 const FloatingObjectSet& floatingObjectSet = m_floatingObjects->set(); | 3000 const FloatingObjectSet& floatingObjectSet = m_floatingObjects->set(); |
2999 FloatingObjectSetIterator it = floatingObjectSet.find<FloatingObjectHash
Translator>(&floatBox); | 3001 FloatingObjectSetIterator it = floatingObjectSet.find<FloatingObjectHash
Translator>(&floatBox); |
3000 if (it != floatingObjectSet.end()) | 3002 if (it != floatingObjectSet.end()) |
3001 return it->get(); | 3003 return it->get(); |
3002 } | 3004 } |
3003 | 3005 |
3004 // Create the special object entry & append it to the list | 3006 // Create the special object entry & append it to the list |
3005 | 3007 |
3006 OwnPtr<FloatingObject> newObj = FloatingObject::create(&floatBox); | 3008 std::unique_ptr<FloatingObject> newObj = FloatingObject::create(&floatBox); |
3007 | 3009 |
3008 // Our location is irrelevant if we're unsplittable or no pagination is in e
ffect. | 3010 // Our location is irrelevant if we're unsplittable or no pagination is in e
ffect. |
3009 // Just go ahead and lay out the float. | 3011 // Just go ahead and lay out the float. |
3010 bool isChildLayoutBlock = floatBox.isLayoutBlock(); | 3012 bool isChildLayoutBlock = floatBox.isLayoutBlock(); |
3011 if (isChildLayoutBlock && !floatBox.needsLayout() && view()->layoutState()->
pageLogicalHeightChanged()) | 3013 if (isChildLayoutBlock && !floatBox.needsLayout() && view()->layoutState()->
pageLogicalHeightChanged()) |
3012 floatBox.setChildNeedsLayout(MarkOnlyThis); | 3014 floatBox.setChildNeedsLayout(MarkOnlyThis); |
3013 | 3015 |
3014 floatBox.layoutIfNeeded(); | 3016 floatBox.layoutIfNeeded(); |
3015 | 3017 |
3016 setLogicalWidthForFloat(*newObj, logicalWidthForChild(floatBox) + marginStar
tForChild(floatBox) + marginEndForChild(floatBox)); | 3018 setLogicalWidthForFloat(*newObj, logicalWidthForChild(floatBox) + marginStar
tForChild(floatBox) + marginEndForChild(floatBox)); |
(...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3454 LayoutBlock* containingBlock = this->containingBlock(); | 3456 LayoutBlock* containingBlock = this->containingBlock(); |
3455 return containingBlock && containingBlock->isLayoutBlockFlow(); | 3457 return containingBlock && containingBlock->isLayoutBlockFlow(); |
3456 } | 3458 } |
3457 | 3459 |
3458 void LayoutBlockFlow::setPaginationStrutPropagatedFromChild(LayoutUnit strut) | 3460 void LayoutBlockFlow::setPaginationStrutPropagatedFromChild(LayoutUnit strut) |
3459 { | 3461 { |
3460 strut = std::max(strut, LayoutUnit()); | 3462 strut = std::max(strut, LayoutUnit()); |
3461 if (!m_rareData) { | 3463 if (!m_rareData) { |
3462 if (!strut) | 3464 if (!strut) |
3463 return; | 3465 return; |
3464 m_rareData = adoptPtr(new LayoutBlockFlowRareData(this)); | 3466 m_rareData = wrapUnique(new LayoutBlockFlowRareData(this)); |
3465 } | 3467 } |
3466 m_rareData->m_paginationStrutPropagatedFromChild = strut; | 3468 m_rareData->m_paginationStrutPropagatedFromChild = strut; |
3467 } | 3469 } |
3468 | 3470 |
3469 void LayoutBlockFlow::positionSpannerDescendant(LayoutMultiColumnSpannerPlacehol
der& child) | 3471 void LayoutBlockFlow::positionSpannerDescendant(LayoutMultiColumnSpannerPlacehol
der& child) |
3470 { | 3472 { |
3471 LayoutBox& spanner = *child.layoutObjectInFlowThread(); | 3473 LayoutBox& spanner = *child.layoutObjectInFlowThread(); |
3472 // FIXME: |spanner| is a descendant, but never a direct child, so the names
here are bad, if | 3474 // FIXME: |spanner| is a descendant, but never a direct child, so the names
here are bad, if |
3473 // nothing else. | 3475 // nothing else. |
3474 setLogicalTopForChild(spanner, child.logicalTop()); | 3476 setLogicalTopForChild(spanner, child.logicalTop()); |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3596 LayoutBlockFlowRareData& rareData = ensureRareData(); | 3598 LayoutBlockFlowRareData& rareData = ensureRareData(); |
3597 ASSERT(!rareData.m_multiColumnFlowThread); | 3599 ASSERT(!rareData.m_multiColumnFlowThread); |
3598 rareData.m_multiColumnFlowThread = flowThread; | 3600 rareData.m_multiColumnFlowThread = flowThread; |
3599 } | 3601 } |
3600 | 3602 |
3601 LayoutBlockFlow::LayoutBlockFlowRareData& LayoutBlockFlow::ensureRareData() | 3603 LayoutBlockFlow::LayoutBlockFlowRareData& LayoutBlockFlow::ensureRareData() |
3602 { | 3604 { |
3603 if (m_rareData) | 3605 if (m_rareData) |
3604 return *m_rareData; | 3606 return *m_rareData; |
3605 | 3607 |
3606 m_rareData = adoptPtr(new LayoutBlockFlowRareData(this)); | 3608 m_rareData = wrapUnique(new LayoutBlockFlowRareData(this)); |
3607 return *m_rareData; | 3609 return *m_rareData; |
3608 } | 3610 } |
3609 | 3611 |
3610 void LayoutBlockFlow::positionDialog() | 3612 void LayoutBlockFlow::positionDialog() |
3611 { | 3613 { |
3612 HTMLDialogElement* dialog = toHTMLDialogElement(node()); | 3614 HTMLDialogElement* dialog = toHTMLDialogElement(node()); |
3613 if (dialog->getCenteringMode() == HTMLDialogElement::NotCentered) | 3615 if (dialog->getCenteringMode() == HTMLDialogElement::NotCentered) |
3614 return; | 3616 return; |
3615 | 3617 |
3616 bool canCenterDialog = (style()->position() == AbsolutePosition || style()->
position() == FixedPosition) | 3618 bool canCenterDialog = (style()->position() == AbsolutePosition || style()->
position() == FixedPosition) |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3829 if (!rect.isEmpty()) | 3831 if (!rect.isEmpty()) |
3830 rects.append(rect); | 3832 rects.append(rect); |
3831 } | 3833 } |
3832 } | 3834 } |
3833 | 3835 |
3834 if (inlineElementContinuation) | 3836 if (inlineElementContinuation) |
3835 inlineElementContinuation->addOutlineRects(rects, additionalOffset + (in
lineElementContinuation->containingBlock()->location() - location()), includeBlo
ckOverflows); | 3837 inlineElementContinuation->addOutlineRects(rects, additionalOffset + (in
lineElementContinuation->containingBlock()->location() - location()), includeBlo
ckOverflows); |
3836 } | 3838 } |
3837 | 3839 |
3838 } // namespace blink | 3840 } // namespace blink |
OLD | NEW |