Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(405)

Side by Side Diff: Source/core/rendering/RenderBlockFlow.cpp

Issue 296983005: Revert of Refactor avoidsFloats() to reflect CSS2.1 spec more clearly (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/rendering/RenderBlock.cpp ('k') | Source/core/rendering/RenderBox.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 740 matching lines...) Expand 10 before | Expand all | Expand 10 after
751 const FloatingObjectSet& floatingObjectSet = m_floatingObjects->set(); 751 const FloatingObjectSet& floatingObjectSet = m_floatingObjects->set();
752 FloatingObjectSetIterator end = floatingObjectSet.end(); 752 FloatingObjectSetIterator end = floatingObjectSet.end();
753 for (FloatingObjectSetIterator it = floatingObjectSet.begin(); it != end ; ++it) { 753 for (FloatingObjectSetIterator it = floatingObjectSet.begin(); it != end ; ++it) {
754 FloatingObject* floatingObject = *it; 754 FloatingObject* floatingObject = *it;
755 if (!floatingObject->isDescendant()) 755 if (!floatingObject->isDescendant())
756 oldIntrudingFloatSet.add(floatingObject->renderer()); 756 oldIntrudingFloatSet.add(floatingObject->renderer());
757 } 757 }
758 } 758 }
759 759
760 // Inline blocks are covered by the isReplaced() check in the avoidFloats me thod. 760 // Inline blocks are covered by the isReplaced() check in the avoidFloats me thod.
761 if (avoidsOrIgnoresFloats() || isRenderView()) { 761 if (avoidsFloats() || isDocumentElement() || isRenderView() || isFloatingOrO utOfFlowPositioned() || isTableCell()) {
762 if (m_floatingObjects) { 762 if (m_floatingObjects) {
763 m_floatingObjects->clear(); 763 m_floatingObjects->clear();
764 } 764 }
765 if (!oldIntrudingFloatSet.isEmpty()) 765 if (!oldIntrudingFloatSet.isEmpty())
766 markAllDescendantsWithFloatsForLayout(); 766 markAllDescendantsWithFloatsForLayout();
767 return; 767 return;
768 } 768 }
769 769
770 RendererToFloatInfoMap floatMap; 770 RendererToFloatInfoMap floatMap;
771 771
772 if (m_floatingObjects) { 772 if (m_floatingObjects) {
773 if (childrenInline()) 773 if (childrenInline())
774 m_floatingObjects->moveAllToFloatInfoMap(floatMap); 774 m_floatingObjects->moveAllToFloatInfoMap(floatMap);
775 else 775 else
776 m_floatingObjects->clear(); 776 m_floatingObjects->clear();
777 } 777 }
778 778
779 // We should not process floats if the parent node is not a RenderBlockFlow. Otherwise, we will add 779 // We should not process floats if the parent node is not a RenderBlockFlow. Otherwise, we will add
780 // floats in an invalid context. This will cause a crash arising from a bad cast on the parent. 780 // floats in an invalid context. This will cause a crash arising from a bad cast on the parent.
781 // See <rdar://problem/8049753>, where float property is applied on a text n ode in a SVG. 781 // See <rdar://problem/8049753>, where float property is applied on a text n ode in a SVG.
782 if (!parent() || !parent()->isRenderBlockFlow()) 782 if (!parent() || !parent()->isRenderBlockFlow())
783 return; 783 return;
784 784
785 // Attempt to locate a previous sibling with overhanging floats. We skip any elements that 785 // Attempt to locate a previous sibling with overhanging floats. We skip any elements that
786 // may have shifted to avoid floats, and any objects whose floats cannot int eract with objects 786 // may have shifted to avoid floats, and any objects whose floats cannot int eract with objects
787 // outside it (i.e. objects that create a new block formatting context). 787 // outside it (i.e. objects that create a new block formatting context).
788 RenderBlockFlow* parentBlockFlow = toRenderBlockFlow(parent()); 788 RenderBlockFlow* parentBlockFlow = toRenderBlockFlow(parent());
789 bool parentHasFloats = false; 789 bool parentHasFloats = false;
790 RenderObject* prev = previousSibling(); 790 RenderObject* prev = previousSibling();
791 while (prev && (!prev->isBox() || !prev->isRenderBlock() || toRenderBlock(pr ev)->avoidsOrIgnoresFloats())) { 791 while (prev && (!prev->isBox() || !prev->isRenderBlock() || toRenderBlock(pr ev)->avoidsFloats() || toRenderBlock(prev)->createsBlockFormattingContext())) {
792 if (prev->isFloating()) 792 if (prev->isFloating())
793 parentHasFloats = true; 793 parentHasFloats = true;
794 prev = prev->previousSibling(); 794 prev = prev->previousSibling();
795 } 795 }
796 796
797 // First add in floats from the parent. Self-collapsing blocks let their par ent track any floats that intrude into 797 // First add in floats from the parent. Self-collapsing blocks let their par ent track any floats that intrude into
798 // them (as opposed to floats they contain themselves) so check for those he re too. 798 // them (as opposed to floats they contain themselves) so check for those he re too.
799 LayoutUnit logicalTopOffset = logicalTop(); 799 LayoutUnit logicalTopOffset = logicalTop();
800 bool parentHasIntrudingFloats = !parentHasFloats && (!prev || toRenderBlockF low(prev)->isSelfCollapsingBlock()) && parentBlockFlow->lowestFloatLogicalBottom () > logicalTopOffset; 800 bool parentHasIntrudingFloats = !parentHasFloats && (!prev || toRenderBlockF low(prev)->isSelfCollapsingBlock()) && parentBlockFlow->lowestFloatLogicalBottom () > logicalTopOffset;
801 if (parentHasFloats || parentHasIntrudingFloats) 801 if (parentHasFloats || parentHasIntrudingFloats)
(...skipping 912 matching lines...) Expand 10 before | Expand all | Expand 10 after
1714 1714
1715 void RenderBlockFlow::markSiblingsWithFloatsForLayout(RenderBox* floatToRemove) 1715 void RenderBlockFlow::markSiblingsWithFloatsForLayout(RenderBox* floatToRemove)
1716 { 1716 {
1717 if (!m_floatingObjects) 1717 if (!m_floatingObjects)
1718 return; 1718 return;
1719 1719
1720 const FloatingObjectSet& floatingObjectSet = m_floatingObjects->set(); 1720 const FloatingObjectSet& floatingObjectSet = m_floatingObjects->set();
1721 FloatingObjectSetIterator end = floatingObjectSet.end(); 1721 FloatingObjectSetIterator end = floatingObjectSet.end();
1722 1722
1723 for (RenderObject* next = nextSibling(); next; next = next->nextSibling()) { 1723 for (RenderObject* next = nextSibling(); next; next = next->nextSibling()) {
1724 if (!next->isRenderBlockFlow() || avoidsOrIgnoresFloats()) 1724 if (!next->isRenderBlockFlow() || next->isFloatingOrOutOfFlowPositioned( ) || toRenderBlock(next)->avoidsFloats())
1725 continue; 1725 continue;
1726 1726
1727 RenderBlockFlow* nextBlock = toRenderBlockFlow(next); 1727 RenderBlockFlow* nextBlock = toRenderBlockFlow(next);
1728 for (FloatingObjectSetIterator it = floatingObjectSet.begin(); it != end ; ++it) { 1728 for (FloatingObjectSetIterator it = floatingObjectSet.begin(); it != end ; ++it) {
1729 RenderBox* floatingBox = (*it)->renderer(); 1729 RenderBox* floatingBox = (*it)->renderer();
1730 if (floatToRemove && floatingBox != floatToRemove) 1730 if (floatToRemove && floatingBox != floatToRemove)
1731 continue; 1731 continue;
1732 if (nextBlock->containsFloat(floatingBox)) 1732 if (nextBlock->containsFloat(floatingBox))
1733 nextBlock->markAllDescendantsWithFloatsForLayout(floatingBox); 1733 nextBlock->markAllDescendantsWithFloatsForLayout(floatingBox);
1734 } 1734 }
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
1806 } 1806 }
1807 1807
1808 void RenderBlockFlow::createFloatingObjects() 1808 void RenderBlockFlow::createFloatingObjects()
1809 { 1809 {
1810 m_floatingObjects = adoptPtr(new FloatingObjects(this, isHorizontalWritingMo de())); 1810 m_floatingObjects = adoptPtr(new FloatingObjects(this, isHorizontalWritingMo de()));
1811 } 1811 }
1812 1812
1813 void RenderBlockFlow::styleWillChange(StyleDifference diff, const RenderStyle& n ewStyle) 1813 void RenderBlockFlow::styleWillChange(StyleDifference diff, const RenderStyle& n ewStyle)
1814 { 1814 {
1815 RenderStyle* oldStyle = style(); 1815 RenderStyle* oldStyle = style();
1816 s_canPropagateFloatIntoSibling = oldStyle ? !createsBlockFormattingContext() : false; 1816 s_canPropagateFloatIntoSibling = oldStyle ? !isFloatingOrOutOfFlowPositioned () && !avoidsFloats() : false;
1817 if (oldStyle && parent() && diff.needsFullLayout() && oldStyle->position() ! = newStyle.position() 1817 if (oldStyle && parent() && diff.needsFullLayout() && oldStyle->position() ! = newStyle.position()
1818 && containsFloats() && !isFloating() && !isOutOfFlowPositioned() && newS tyle.hasOutOfFlowPosition()) 1818 && containsFloats() && !isFloating() && !isOutOfFlowPositioned() && newS tyle.hasOutOfFlowPosition())
1819 markAllDescendantsWithFloatsForLayout(); 1819 markAllDescendantsWithFloatsForLayout();
1820 1820
1821 RenderBlock::styleWillChange(diff, newStyle); 1821 RenderBlock::styleWillChange(diff, newStyle);
1822 } 1822 }
1823 1823
1824 void RenderBlockFlow::styleDidChange(StyleDifference diff, const RenderStyle* ol dStyle) 1824 void RenderBlockFlow::styleDidChange(StyleDifference diff, const RenderStyle* ol dStyle)
1825 { 1825 {
1826 RenderBlock::styleDidChange(diff, oldStyle); 1826 RenderBlock::styleDidChange(diff, oldStyle);
1827 1827
1828 // After our style changed, if we lose our ability to propagate floats into next sibling 1828 // After our style changed, if we lose our ability to propagate floats into next sibling
1829 // blocks, then we need to find the top most parent containing that overhang ing float and 1829 // blocks, then we need to find the top most parent containing that overhang ing float and
1830 // then mark its descendants with floats for layout and clear all floats fro m its next 1830 // then mark its descendants with floats for layout and clear all floats fro m its next
1831 // sibling blocks that exist in our floating objects list. See bug 56299 and 62875. 1831 // sibling blocks that exist in our floating objects list. See bug 56299 and 62875.
1832 bool canPropagateFloatIntoSibling = !createsBlockFormattingContext(); 1832 bool canPropagateFloatIntoSibling = !isFloatingOrOutOfFlowPositioned() && !a voidsFloats();
1833 if (diff.needsFullLayout() && s_canPropagateFloatIntoSibling && !canPropagat eFloatIntoSibling && hasOverhangingFloats()) { 1833 if (diff.needsFullLayout() && s_canPropagateFloatIntoSibling && !canPropagat eFloatIntoSibling && hasOverhangingFloats()) {
1834 RenderBlockFlow* parentBlockFlow = this; 1834 RenderBlockFlow* parentBlockFlow = this;
1835 const FloatingObjectSet& floatingObjectSet = m_floatingObjects->set(); 1835 const FloatingObjectSet& floatingObjectSet = m_floatingObjects->set();
1836 FloatingObjectSetIterator end = floatingObjectSet.end(); 1836 FloatingObjectSetIterator end = floatingObjectSet.end();
1837 1837
1838 for (RenderObject* curr = parent(); curr && !curr->isRenderView(); curr = curr->parent()) { 1838 for (RenderObject* curr = parent(); curr && !curr->isRenderView(); curr = curr->parent()) {
1839 if (curr->isRenderBlockFlow()) { 1839 if (curr->isRenderBlockFlow()) {
1840 RenderBlockFlow* currBlock = toRenderBlockFlow(curr); 1840 RenderBlockFlow* currBlock = toRenderBlockFlow(curr);
1841 1841
1842 if (currBlock->hasOverhangingFloats()) { 1842 if (currBlock->hasOverhangingFloats()) {
(...skipping 950 matching lines...) Expand 10 before | Expand all | Expand 10 after
2793 RenderBlockFlow::RenderBlockFlowRareData& RenderBlockFlow::ensureRareData() 2793 RenderBlockFlow::RenderBlockFlowRareData& RenderBlockFlow::ensureRareData()
2794 { 2794 {
2795 if (m_rareData) 2795 if (m_rareData)
2796 return *m_rareData; 2796 return *m_rareData;
2797 2797
2798 m_rareData = adoptPtr(new RenderBlockFlowRareData(this)); 2798 m_rareData = adoptPtr(new RenderBlockFlowRareData(this));
2799 return *m_rareData; 2799 return *m_rareData;
2800 } 2800 }
2801 2801
2802 } // namespace WebCore 2802 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/rendering/RenderBlock.cpp ('k') | Source/core/rendering/RenderBox.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698