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