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 746 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
757 const FloatingObjectSet& floatingObjectSet = m_floatingObjects->set(); | 757 const FloatingObjectSet& floatingObjectSet = m_floatingObjects->set(); |
758 FloatingObjectSetIterator end = floatingObjectSet.end(); | 758 FloatingObjectSetIterator end = floatingObjectSet.end(); |
759 for (FloatingObjectSetIterator it = floatingObjectSet.begin(); it != end ; ++it) { | 759 for (FloatingObjectSetIterator it = floatingObjectSet.begin(); it != end ; ++it) { |
760 FloatingObject* floatingObject = it->get(); | 760 FloatingObject* floatingObject = it->get(); |
761 if (!floatingObject->isDescendant()) | 761 if (!floatingObject->isDescendant()) |
762 oldIntrudingFloatSet.add(floatingObject->renderer()); | 762 oldIntrudingFloatSet.add(floatingObject->renderer()); |
763 } | 763 } |
764 } | 764 } |
765 | 765 |
766 // Inline blocks are covered by the isReplaced() check in the avoidFloats me thod. | 766 // Inline blocks are covered by the isReplaced() check in the avoidFloats me thod. |
767 if (avoidsFloats() || isDocumentElement() || isRenderView() || isFloatingOrO utOfFlowPositioned() || isTableCell()) { | 767 if (avoidsOrIgnoresFloats() || isRenderView()) { |
768 if (m_floatingObjects) { | 768 if (m_floatingObjects) { |
769 m_floatingObjects->clear(); | 769 m_floatingObjects->clear(); |
770 } | 770 } |
771 if (!oldIntrudingFloatSet.isEmpty()) | 771 if (!oldIntrudingFloatSet.isEmpty()) |
772 markAllDescendantsWithFloatsForLayout(); | 772 markAllDescendantsWithFloatsForLayout(); |
773 return; | 773 return; |
774 } | 774 } |
775 | 775 |
776 RendererToFloatInfoMap floatMap; | 776 RendererToFloatInfoMap floatMap; |
777 | 777 |
778 if (m_floatingObjects) { | 778 if (m_floatingObjects) { |
779 if (childrenInline()) | 779 if (childrenInline()) |
780 m_floatingObjects->moveAllToFloatInfoMap(floatMap); | 780 m_floatingObjects->moveAllToFloatInfoMap(floatMap); |
781 else | 781 else |
782 m_floatingObjects->clear(); | 782 m_floatingObjects->clear(); |
783 } | 783 } |
784 | 784 |
785 // We should not process floats if the parent node is not a RenderBlockFlow. Otherwise, we will add | 785 // We should not process floats if the parent node is not a RenderBlockFlow. Otherwise, we will add |
786 // floats in an invalid context. This will cause a crash arising from a bad cast on the parent. | 786 // floats in an invalid context. This will cause a crash arising from a bad cast on the parent. |
787 // See <rdar://problem/8049753>, where float property is applied on a text n ode in a SVG. | 787 // See <rdar://problem/8049753>, where float property is applied on a text n ode in a SVG. |
788 if (!parent() || !parent()->isRenderBlockFlow()) | 788 if (!parent() || !parent()->isRenderBlockFlow()) |
789 return; | 789 return; |
790 | 790 |
791 // Attempt to locate a previous sibling with overhanging floats. We skip any elements that | 791 // Attempt to locate a previous sibling with overhanging floats. We skip any elements that |
792 // may have shifted to avoid floats, and any objects whose floats cannot int eract with objects | 792 // may have shifted to avoid floats, and any objects whose floats cannot int eract with objects |
793 // outside it (i.e. objects that create a new block formatting context). | 793 // outside it (i.e. objects that create a new block formatting context). |
794 RenderBlockFlow* parentBlockFlow = toRenderBlockFlow(parent()); | 794 RenderBlockFlow* parentBlockFlow = toRenderBlockFlow(parent()); |
795 bool parentHasFloats = false; | 795 bool parentHasFloats = false; |
796 RenderObject* prev = previousSibling(); | 796 RenderObject* prev = previousSibling(); |
797 while (prev && (!prev->isBox() || !prev->isRenderBlock() || toRenderBlock(pr ev)->avoidsFloats() || toRenderBlock(prev)->createsBlockFormattingContext())) { | 797 while (prev && (!prev->isBox() || !prev->isRenderBlock() || toRenderBlock(pr ev)->avoidsOrIgnoresFloats())) { |
798 if (prev->isFloating()) | 798 if (prev->isFloating()) |
799 parentHasFloats = true; | 799 parentHasFloats = true; |
800 prev = prev->previousSibling(); | 800 prev = prev->previousSibling(); |
801 } | 801 } |
802 | 802 |
803 // First add in floats from the parent. Self-collapsing blocks let their par ent track any floats that intrude into | 803 // First add in floats from the parent. Self-collapsing blocks let their par ent track any floats that intrude into |
804 // them (as opposed to floats they contain themselves) so check for those he re too. | 804 // them (as opposed to floats they contain themselves) so check for those he re too. |
805 LayoutUnit logicalTopOffset = logicalTop(); | 805 LayoutUnit logicalTopOffset = logicalTop(); |
806 bool parentHasIntrudingFloats = !parentHasFloats && (!prev || toRenderBlockF low(prev)->isSelfCollapsingBlock()) && parentBlockFlow->lowestFloatLogicalBottom () > logicalTopOffset; | 806 bool parentHasIntrudingFloats = !parentHasFloats && (!prev || toRenderBlockF low(prev)->isSelfCollapsingBlock()) && parentBlockFlow->lowestFloatLogicalBottom () > logicalTopOffset; |
807 if (parentHasFloats || parentHasIntrudingFloats) | 807 if (parentHasFloats || parentHasIntrudingFloats) |
(...skipping 911 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1719 | 1719 |
1720 void RenderBlockFlow::markSiblingsWithFloatsForLayout(RenderBox* floatToRemove) | 1720 void RenderBlockFlow::markSiblingsWithFloatsForLayout(RenderBox* floatToRemove) |
1721 { | 1721 { |
1722 if (!m_floatingObjects) | 1722 if (!m_floatingObjects) |
1723 return; | 1723 return; |
1724 | 1724 |
1725 const FloatingObjectSet& floatingObjectSet = m_floatingObjects->set(); | 1725 const FloatingObjectSet& floatingObjectSet = m_floatingObjects->set(); |
1726 FloatingObjectSetIterator end = floatingObjectSet.end(); | 1726 FloatingObjectSetIterator end = floatingObjectSet.end(); |
1727 | 1727 |
1728 for (RenderObject* next = nextSibling(); next; next = next->nextSibling()) { | 1728 for (RenderObject* next = nextSibling(); next; next = next->nextSibling()) { |
1729 if (!next->isRenderBlockFlow() || next->isFloatingOrOutOfFlowPositioned( ) || toRenderBlock(next)->avoidsFloats()) | 1729 if (!next->isRenderBlockFlow() || avoidsOrIgnoresFloats()) |
1730 continue; | 1730 continue; |
1731 | 1731 |
1732 RenderBlockFlow* nextBlock = toRenderBlockFlow(next); | 1732 RenderBlockFlow* nextBlock = toRenderBlockFlow(next); |
1733 for (FloatingObjectSetIterator it = floatingObjectSet.begin(); it != end ; ++it) { | 1733 for (FloatingObjectSetIterator it = floatingObjectSet.begin(); it != end ; ++it) { |
1734 RenderBox* floatingBox = (*it)->renderer(); | 1734 RenderBox* floatingBox = (*it)->renderer(); |
1735 if (floatToRemove && floatingBox != floatToRemove) | 1735 if (floatToRemove && floatingBox != floatToRemove) |
1736 continue; | 1736 continue; |
1737 if (nextBlock->containsFloat(floatingBox)) | 1737 if (nextBlock->containsFloat(floatingBox)) |
1738 nextBlock->markAllDescendantsWithFloatsForLayout(floatingBox); | 1738 nextBlock->markAllDescendantsWithFloatsForLayout(floatingBox); |
1739 } | 1739 } |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1811 } | 1811 } |
1812 | 1812 |
1813 void RenderBlockFlow::createFloatingObjects() | 1813 void RenderBlockFlow::createFloatingObjects() |
1814 { | 1814 { |
1815 m_floatingObjects = adoptPtr(new FloatingObjects(this, isHorizontalWritingMo de())); | 1815 m_floatingObjects = adoptPtr(new FloatingObjects(this, isHorizontalWritingMo de())); |
1816 } | 1816 } |
1817 | 1817 |
1818 void RenderBlockFlow::styleWillChange(StyleDifference diff, const RenderStyle& n ewStyle) | 1818 void RenderBlockFlow::styleWillChange(StyleDifference diff, const RenderStyle& n ewStyle) |
1819 { | 1819 { |
1820 RenderStyle* oldStyle = style(); | 1820 RenderStyle* oldStyle = style(); |
1821 s_canPropagateFloatIntoSibling = oldStyle ? !isFloatingOrOutOfFlowPositioned () && !avoidsFloats() : false; | 1821 s_canPropagateFloatIntoSibling = oldStyle ? !createsBlockFormattingContext() : false; |
1822 if (oldStyle && parent() && diff.needsFullLayout() && oldStyle->position() ! = newStyle.position() | 1822 if (oldStyle && parent() && diff.needsFullLayout() && oldStyle->position() ! = newStyle.position() |
1823 && containsFloats() && !isFloating() && !isOutOfFlowPositioned() && newS tyle.hasOutOfFlowPosition()) | 1823 && containsFloats() && !isFloating() && !isOutOfFlowPositioned() && newS tyle.hasOutOfFlowPosition()) |
1824 markAllDescendantsWithFloatsForLayout(); | 1824 markAllDescendantsWithFloatsForLayout(); |
1825 | 1825 |
1826 RenderBlock::styleWillChange(diff, newStyle); | 1826 RenderBlock::styleWillChange(diff, newStyle); |
1827 } | 1827 } |
1828 | 1828 |
1829 void RenderBlockFlow::styleDidChange(StyleDifference diff, const RenderStyle* ol dStyle) | 1829 void RenderBlockFlow::styleDidChange(StyleDifference diff, const RenderStyle* ol dStyle) |
1830 { | 1830 { |
1831 RenderBlock::styleDidChange(diff, oldStyle); | 1831 RenderBlock::styleDidChange(diff, oldStyle); |
1832 | 1832 |
1833 // After our style changed, if we lose our ability to propagate floats into next sibling | 1833 // After our style changed, if we lose our ability to propagate floats into next sibling |
1834 // blocks, then we need to find the top most parent containing that overhang ing float and | 1834 // blocks, then we need to find the top most parent containing that overhang ing float and |
1835 // then mark its descendants with floats for layout and clear all floats fro m its next | 1835 // then mark its descendants with floats for layout and clear all floats fro m its next |
1836 // sibling blocks that exist in our floating objects list. See bug 56299 and 62875. | 1836 // sibling blocks that exist in our floating objects list. See bug 56299 and 62875. |
1837 bool canPropagateFloatIntoSibling = !isFloatingOrOutOfFlowPositioned() && !a voidsFloats(); | 1837 bool canPropagateFloatIntoSibling = !avoidsOrIgnoresFloats(); |
rhogan
2014/06/17 21:53:15
This is why the previous version of this patch had
| |
1838 if (diff.needsFullLayout() && s_canPropagateFloatIntoSibling && !canPropagat eFloatIntoSibling && hasOverhangingFloats()) { | 1838 if (diff.needsFullLayout() && s_canPropagateFloatIntoSibling && !canPropagat eFloatIntoSibling && hasOverhangingFloats()) { |
1839 RenderBlockFlow* parentBlockFlow = this; | 1839 RenderBlockFlow* parentBlockFlow = this; |
1840 const FloatingObjectSet& floatingObjectSet = m_floatingObjects->set(); | 1840 const FloatingObjectSet& floatingObjectSet = m_floatingObjects->set(); |
1841 FloatingObjectSetIterator end = floatingObjectSet.end(); | 1841 FloatingObjectSetIterator end = floatingObjectSet.end(); |
1842 | 1842 |
1843 for (RenderObject* curr = parent(); curr && !curr->isRenderView(); curr = curr->parent()) { | 1843 for (RenderObject* curr = parent(); curr && !curr->isRenderView(); curr = curr->parent()) { |
1844 if (curr->isRenderBlockFlow()) { | 1844 if (curr->isRenderBlockFlow()) { |
1845 RenderBlockFlow* currBlock = toRenderBlockFlow(curr); | 1845 RenderBlockFlow* currBlock = toRenderBlockFlow(curr); |
1846 | 1846 |
1847 if (currBlock->hasOverhangingFloats()) { | 1847 if (currBlock->hasOverhangingFloats()) { |
(...skipping 955 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2803 RenderBlockFlow::RenderBlockFlowRareData& RenderBlockFlow::ensureRareData() | 2803 RenderBlockFlow::RenderBlockFlowRareData& RenderBlockFlow::ensureRareData() |
2804 { | 2804 { |
2805 if (m_rareData) | 2805 if (m_rareData) |
2806 return *m_rareData; | 2806 return *m_rareData; |
2807 | 2807 |
2808 m_rareData = adoptPtr(new RenderBlockFlowRareData(this)); | 2808 m_rareData = adoptPtr(new RenderBlockFlowRareData(this)); |
2809 return *m_rareData; | 2809 return *m_rareData; |
2810 } | 2810 } |
2811 | 2811 |
2812 } // namespace WebCore | 2812 } // namespace WebCore |
OLD | NEW |