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

Side by Side Diff: Source/core/layout/LayoutBlockFlow.cpp

Issue 1157863014: Self-collapsing blocks shouldn't get layout bit sit when handling margins (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Updated Created 5 years, 6 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/layout/LayoutBlockFlow.h ('k') | no next file » | 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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 // This flag is set when we know we're examining bottom margins and we know we're at the bottom of the block. 88 // This flag is set when we know we're examining bottom margins and we know we're at the bottom of the block.
89 bool m_atAfterSideOfBlock : 1; 89 bool m_atAfterSideOfBlock : 1;
90 90
91 // These variables are used to detect quirky margins that we need to collaps e away (in table cells 91 // These variables are used to detect quirky margins that we need to collaps e away (in table cells
92 // and in the body element). 92 // and in the body element).
93 bool m_hasMarginBeforeQuirk : 1; 93 bool m_hasMarginBeforeQuirk : 1;
94 bool m_hasMarginAfterQuirk : 1; 94 bool m_hasMarginAfterQuirk : 1;
95 bool m_determinedMarginBeforeQuirk : 1; 95 bool m_determinedMarginBeforeQuirk : 1;
96 96
97 bool m_discardMargin : 1; 97 bool m_discardMargin : 1;
98 bool m_lastChildIsSelfCollapsingBlockWithClearance : 1;
98 99
99 // These flags track the previous maximal positive and negative margins. 100 // These flags track the previous maximal positive and negative margins.
100 LayoutUnit m_positiveMargin; 101 LayoutUnit m_positiveMargin;
101 LayoutUnit m_negativeMargin; 102 LayoutUnit m_negativeMargin;
102 103
103 public: 104 public:
104 MarginInfo(LayoutBlockFlow*, LayoutUnit beforeBorderPadding, LayoutUnit afte rBorderPadding); 105 MarginInfo(LayoutBlockFlow*, LayoutUnit beforeBorderPadding, LayoutUnit afte rBorderPadding);
105 106
106 void setAtBeforeSideOfBlock(bool b) { m_atBeforeSideOfBlock = b; } 107 void setAtBeforeSideOfBlock(bool b) { m_atBeforeSideOfBlock = b; }
107 void setAtAfterSideOfBlock(bool b) { m_atAfterSideOfBlock = b; } 108 void setAtAfterSideOfBlock(bool b) { m_atAfterSideOfBlock = b; }
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 bool canCollapseMarginAfterWithChildren() const { return m_canCollapseMargin AfterWithChildren; } 141 bool canCollapseMarginAfterWithChildren() const { return m_canCollapseMargin AfterWithChildren; }
141 bool canCollapseMarginAfterWithLastChild() const { return m_canCollapseMargi nAfterWithLastChild; } 142 bool canCollapseMarginAfterWithLastChild() const { return m_canCollapseMargi nAfterWithLastChild; }
142 bool quirkContainer() const { return m_quirkContainer; } 143 bool quirkContainer() const { return m_quirkContainer; }
143 bool determinedMarginBeforeQuirk() const { return m_determinedMarginBeforeQu irk; } 144 bool determinedMarginBeforeQuirk() const { return m_determinedMarginBeforeQu irk; }
144 bool hasMarginBeforeQuirk() const { return m_hasMarginBeforeQuirk; } 145 bool hasMarginBeforeQuirk() const { return m_hasMarginBeforeQuirk; }
145 bool hasMarginAfterQuirk() const { return m_hasMarginAfterQuirk; } 146 bool hasMarginAfterQuirk() const { return m_hasMarginAfterQuirk; }
146 LayoutUnit positiveMargin() const { return m_positiveMargin; } 147 LayoutUnit positiveMargin() const { return m_positiveMargin; }
147 LayoutUnit negativeMargin() const { return m_negativeMargin; } 148 LayoutUnit negativeMargin() const { return m_negativeMargin; }
148 bool discardMargin() const { return m_discardMargin; } 149 bool discardMargin() const { return m_discardMargin; }
149 LayoutUnit margin() const { return m_positiveMargin - m_negativeMargin; } 150 LayoutUnit margin() const { return m_positiveMargin - m_negativeMargin; }
151 void setLastChildIsSelfCollapsingBlockWithClearance(bool value) { m_lastChil dIsSelfCollapsingBlockWithClearance = value; }
152 bool lastChildIsSelfCollapsingBlockWithClearance() const { return m_lastChil dIsSelfCollapsingBlockWithClearance; }
150 }; 153 };
151 static bool inNormalFlow(LayoutBox* child) 154 static bool inNormalFlow(LayoutBox* child)
152 { 155 {
153 LayoutBlock* curr = child->containingBlock(); 156 LayoutBlock* curr = child->containingBlock();
154 LayoutView* layoutView = child->view(); 157 LayoutView* layoutView = child->view();
155 while (curr && curr != layoutView) { 158 while (curr && curr != layoutView) {
156 if (curr->isLayoutFlowThread()) 159 if (curr->isLayoutFlowThread())
157 return true; 160 return true;
158 if (curr->isFloatingOrOutOfFlowPositioned()) 161 if (curr->isFloatingOrOutOfFlowPositioned())
159 return false; 162 return false;
(...skipping 870 matching lines...) Expand 10 before | Expand all | Expand 10 after
1030 1033
1031 // Our MarginInfo state used when laying out block children. 1034 // Our MarginInfo state used when laying out block children.
1032 MarginInfo::MarginInfo(LayoutBlockFlow* blockFlow, LayoutUnit beforeBorderPaddin g, LayoutUnit afterBorderPadding) 1035 MarginInfo::MarginInfo(LayoutBlockFlow* blockFlow, LayoutUnit beforeBorderPaddin g, LayoutUnit afterBorderPadding)
1033 : m_canCollapseMarginAfterWithLastChild(true) 1036 : m_canCollapseMarginAfterWithLastChild(true)
1034 , m_atBeforeSideOfBlock(true) 1037 , m_atBeforeSideOfBlock(true)
1035 , m_atAfterSideOfBlock(false) 1038 , m_atAfterSideOfBlock(false)
1036 , m_hasMarginBeforeQuirk(false) 1039 , m_hasMarginBeforeQuirk(false)
1037 , m_hasMarginAfterQuirk(false) 1040 , m_hasMarginAfterQuirk(false)
1038 , m_determinedMarginBeforeQuirk(false) 1041 , m_determinedMarginBeforeQuirk(false)
1039 , m_discardMargin(false) 1042 , m_discardMargin(false)
1043 , m_lastChildIsSelfCollapsingBlockWithClearance(false)
1040 { 1044 {
1041 const ComputedStyle& blockStyle = blockFlow->styleRef(); 1045 const ComputedStyle& blockStyle = blockFlow->styleRef();
1042 ASSERT(blockFlow->isLayoutView() || blockFlow->parent()); 1046 ASSERT(blockFlow->isLayoutView() || blockFlow->parent());
1043 m_canCollapseWithChildren = !blockFlow->createsNewFormattingContext() && !bl ockFlow->isLayoutFlowThread() && !blockFlow->isLayoutView(); 1047 m_canCollapseWithChildren = !blockFlow->createsNewFormattingContext() && !bl ockFlow->isLayoutFlowThread() && !blockFlow->isLayoutView();
1044 1048
1045 m_canCollapseMarginBeforeWithChildren = m_canCollapseWithChildren && !before BorderPadding && blockStyle.marginBeforeCollapse() != MSEPARATE; 1049 m_canCollapseMarginBeforeWithChildren = m_canCollapseWithChildren && !before BorderPadding && blockStyle.marginBeforeCollapse() != MSEPARATE;
1046 1050
1047 // If any height other than auto is specified in CSS, then we don't collapse our bottom 1051 // If any height other than auto is specified in CSS, then we don't collapse our bottom
1048 // margins with our children's margins. To do otherwise would be to risk odd visual 1052 // margins with our children's margins. To do otherwise would be to risk odd visual
1049 // effects when the children overflow out of the parent block and yet still collapse 1053 // effects when the children overflow out of the parent block and yet still collapse
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
1187 1191
1188 LayoutUnit beforeCollapseLogicalTop = logicalHeight(); 1192 LayoutUnit beforeCollapseLogicalTop = logicalHeight();
1189 LayoutUnit logicalTop = beforeCollapseLogicalTop; 1193 LayoutUnit logicalTop = beforeCollapseLogicalTop;
1190 1194
1191 LayoutUnit clearanceForSelfCollapsingBlock; 1195 LayoutUnit clearanceForSelfCollapsingBlock;
1192 LayoutObject* prev = child.previousSibling(); 1196 LayoutObject* prev = child.previousSibling();
1193 LayoutBlockFlow* previousBlockFlow = prev && prev->isLayoutBlockFlow() && ! prev->isFloatingOrOutOfFlowPositioned() ? toLayoutBlockFlow(prev) : 0; 1197 LayoutBlockFlow* previousBlockFlow = prev && prev->isLayoutBlockFlow() && ! prev->isFloatingOrOutOfFlowPositioned() ? toLayoutBlockFlow(prev) : 0;
1194 // If the child's previous sibling is a self-collapsing block that cleared a float then its top border edge has been set at the bottom border edge 1198 // If the child's previous sibling is a self-collapsing block that cleared a float then its top border edge has been set at the bottom border edge
1195 // of the float. Since we want to collapse the child's top margin with the s elf-collapsing block's top and bottom margins we need to adjust our parent's hei ght to match the 1199 // of the float. Since we want to collapse the child's top margin with the s elf-collapsing block's top and bottom margins we need to adjust our parent's hei ght to match the
1196 // margin top of the self-collapsing block. If the resulting collapsed margi n leaves the child still intruding into the float then we will want to clear it. 1200 // margin top of the self-collapsing block. If the resulting collapsed margi n leaves the child still intruding into the float then we will want to clear it.
1197 if (!marginInfo.canCollapseWithMarginBefore() && previousBlockFlow && previo usBlockFlow->isSelfCollapsingBlock()) { 1201 if (!marginInfo.canCollapseWithMarginBefore() && previousBlockFlow && margin Info.lastChildIsSelfCollapsingBlockWithClearance()) {
1198 clearanceForSelfCollapsingBlock = previousBlockFlow->marginOffsetForSelf CollapsingBlock(); 1202 clearanceForSelfCollapsingBlock = marginValuesForChild(*previousBlockFlo w).positiveMarginBefore();
1199 setLogicalHeight(logicalHeight() - clearanceForSelfCollapsingBlock); 1203 setLogicalHeight(logicalHeight() - clearanceForSelfCollapsingBlock);
1200 } 1204 }
1201 1205
1202 if (childIsSelfCollapsing) { 1206 if (childIsSelfCollapsing) {
1203 // For a self collapsing block both the before and after margins get dis carded. The block doesn't contribute anything to the height of the block. 1207 // For a self collapsing block both the before and after margins get dis carded. The block doesn't contribute anything to the height of the block.
1204 // Also, the child's top position equals the logical height of the conta iner. 1208 // Also, the child's top position equals the logical height of the conta iner.
1205 if (!childDiscardMarginBefore && !marginInfo.discardMargin()) { 1209 if (!childDiscardMarginBefore && !marginInfo.discardMargin()) {
1206 // This child has no height. We need to compute our 1210 // This child has no height. We need to compute our
1207 // position before we collapse the child's margins together, 1211 // position before we collapse the child's margins together,
1208 // so that we can get an accurate position for the zero-height block . 1212 // so that we can get an accurate position for the zero-height block .
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
1303 if (childLayer->staticBlockPosition() != logicalTop) { 1307 if (childLayer->staticBlockPosition() != logicalTop) {
1304 childLayer->setStaticBlockPosition(logicalTop); 1308 childLayer->setStaticBlockPosition(logicalTop);
1305 if (hasStaticBlockPosition) 1309 if (hasStaticBlockPosition)
1306 child.setChildNeedsLayout(MarkOnlyThis); 1310 child.setChildNeedsLayout(MarkOnlyThis);
1307 } 1311 }
1308 } 1312 }
1309 1313
1310 LayoutUnit LayoutBlockFlow::clearFloatsIfNeeded(LayoutBox& child, MarginInfo& ma rginInfo, LayoutUnit oldTopPosMargin, LayoutUnit oldTopNegMargin, LayoutUnit yPo s, bool childIsSelfCollapsing) 1314 LayoutUnit LayoutBlockFlow::clearFloatsIfNeeded(LayoutBox& child, MarginInfo& ma rginInfo, LayoutUnit oldTopPosMargin, LayoutUnit oldTopNegMargin, LayoutUnit yPo s, bool childIsSelfCollapsing)
1311 { 1315 {
1312 LayoutUnit heightIncrease = getClearDelta(&child, yPos); 1316 LayoutUnit heightIncrease = getClearDelta(&child, yPos);
1317 marginInfo.setLastChildIsSelfCollapsingBlockWithClearance(false);
1318
1313 if (!heightIncrease) 1319 if (!heightIncrease)
1314 return yPos; 1320 return yPos;
1315 1321
1316 if (childIsSelfCollapsing) { 1322 if (childIsSelfCollapsing) {
1323 marginInfo.setLastChildIsSelfCollapsingBlockWithClearance(true);
1317 bool childDiscardMargin = mustDiscardMarginBeforeForChild(child) || must DiscardMarginAfterForChild(child); 1324 bool childDiscardMargin = mustDiscardMarginBeforeForChild(child) || must DiscardMarginAfterForChild(child);
1318 marginInfo.setDiscardMargin(childDiscardMargin); 1325 marginInfo.setDiscardMargin(childDiscardMargin);
1319 1326
1320 // For self-collapsing blocks that clear, they can still collapse their 1327 // For self-collapsing blocks that clear, they can still collapse their
1321 // margins with following siblings. Reset the current margins to represe nt 1328 // margins with following siblings. Reset the current margins to represe nt
1322 // the self-collapsing block's margins only. 1329 // the self-collapsing block's margins only.
1323 // If DISCARD is specified for -webkit-margin-collapse, reset the margin values. 1330 // If DISCARD is specified for -webkit-margin-collapse, reset the margin values.
1324 LayoutBlockFlow::MarginValues childMargins = marginValuesForChild(child) ; 1331 LayoutBlockFlow::MarginValues childMargins = marginValuesForChild(child) ;
1325 if (!childDiscardMargin) { 1332 if (!childDiscardMargin) {
1326 marginInfo.setPositiveMargin(std::max(childMargins.positiveMarginBef ore(), childMargins.positiveMarginAfter())); 1333 marginInfo.setPositiveMargin(std::max(childMargins.positiveMarginBef ore(), childMargins.positiveMarginAfter()));
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
1492 // For replaced elements and scrolled elements, we want to shift them to the next page if they don't fit on the current one. 1499 // For replaced elements and scrolled elements, we want to shift them to the next page if they don't fit on the current one.
1493 logicalTopEstimate = adjustForUnsplittableChild(child, logicalTopEstimat e); 1500 logicalTopEstimate = adjustForUnsplittableChild(child, logicalTopEstimat e);
1494 1501
1495 if (!child.selfNeedsLayout() && child.isLayoutBlockFlow()) 1502 if (!child.selfNeedsLayout() && child.isLayoutBlockFlow())
1496 logicalTopEstimate += toLayoutBlockFlow(&child)->paginationStrut(); 1503 logicalTopEstimate += toLayoutBlockFlow(&child)->paginationStrut();
1497 } 1504 }
1498 1505
1499 return logicalTopEstimate; 1506 return logicalTopEstimate;
1500 } 1507 }
1501 1508
1502 LayoutUnit LayoutBlockFlow::marginOffsetForSelfCollapsingBlock()
1503 {
1504 ASSERT(isSelfCollapsingBlock());
1505 LayoutBlockFlow* parentBlock = toLayoutBlockFlow(parent());
1506 if (parentBlock && style()->clear() && parentBlock->getClearDelta(this, logi calHeight()))
1507 return marginValuesForChild(*this).positiveMarginBefore();
1508 return LayoutUnit();
1509 }
1510
1511 void LayoutBlockFlow::adjustFloatingBlock(const MarginInfo& marginInfo) 1509 void LayoutBlockFlow::adjustFloatingBlock(const MarginInfo& marginInfo)
1512 { 1510 {
1513 // The float should be positioned taking into account the bottom margin 1511 // The float should be positioned taking into account the bottom margin
1514 // of the previous flow. We add that margin into the height, get the 1512 // of the previous flow. We add that margin into the height, get the
1515 // float positioned properly, and then subtract the margin out of the 1513 // float positioned properly, and then subtract the margin out of the
1516 // height again. In the case of self-collapsing blocks, we always just 1514 // height again. In the case of self-collapsing blocks, we always just
1517 // use the top margins, since the self-collapsing block collapsed its 1515 // use the top margins, since the self-collapsing block collapsed its
1518 // own bottom margin into its top margin. 1516 // own bottom margin into its top margin.
1519 // 1517 //
1520 // Note also that the previous flow may collapse its margin into the top of 1518 // Note also that the previous flow may collapse its margin into the top of
1521 // our block. If this is the case, then we do not add the margin in to our 1519 // our block. If this is the case, then we do not add the margin in to our
1522 // height when computing the position of the float. This condition can be te sted 1520 // height when computing the position of the float. This condition can be te sted
1523 // for by simply calling canCollapseWithMarginBefore. See 1521 // for by simply calling canCollapseWithMarginBefore. See
1524 // http://www.hixie.ch/tests/adhoc/css/box/block/margin-collapse/046.html fo r 1522 // http://www.hixie.ch/tests/adhoc/css/box/block/margin-collapse/046.html fo r
1525 // an example of this scenario. 1523 // an example of this scenario.
1526 LayoutUnit marginOffset = marginInfo.canCollapseWithMarginBefore() ? LayoutU nit() : marginInfo.margin(); 1524 LayoutUnit marginOffset = marginInfo.canCollapseWithMarginBefore() ? LayoutU nit() : marginInfo.margin();
1527 setLogicalHeight(logicalHeight() + marginOffset); 1525 setLogicalHeight(logicalHeight() + marginOffset);
1528 positionNewFloats(); 1526 positionNewFloats();
1529 setLogicalHeight(logicalHeight() - marginOffset); 1527 setLogicalHeight(logicalHeight() - marginOffset);
1530 } 1528 }
1531 1529
1532 void LayoutBlockFlow::handleAfterSideOfBlock(LayoutBox* lastChild, LayoutUnit be foreSide, LayoutUnit afterSide, MarginInfo& marginInfo) 1530 void LayoutBlockFlow::handleAfterSideOfBlock(LayoutBox* lastChild, LayoutUnit be foreSide, LayoutUnit afterSide, MarginInfo& marginInfo)
1533 { 1531 {
1534 marginInfo.setAtAfterSideOfBlock(true); 1532 marginInfo.setAtAfterSideOfBlock(true);
1535 1533
1536 // If our last child was a self-collapsing block with clearance then our log ical height is flush with the 1534 // If our last child was a self-collapsing block with clearance then our log ical height is flush with the
1537 // bottom edge of the float that the child clears. The correct vertical posi tion for the margin-collapsing we want 1535 // bottom edge of the float that the child clears. The correct vertical posi tion for the margin-collapsing we want
1538 // to perform now is at the child's margin-top - so adjust our height to tha t position. 1536 // to perform now is at the child's margin-top - so adjust our height to tha t position.
1539 if (lastChild && lastChild->isLayoutBlockFlow() && lastChild->isSelfCollapsi ngBlock()) 1537 if (marginInfo.lastChildIsSelfCollapsingBlockWithClearance()) {
1540 setLogicalHeight(logicalHeight() - toLayoutBlockFlow(lastChild)->marginO ffsetForSelfCollapsingBlock()); 1538 ASSERT(lastChild);
1539 setLogicalHeight(logicalHeight() - marginValuesForChild(*lastChild).posi tiveMarginBefore());
1540 }
1541 1541
1542 if (marginInfo.canCollapseMarginAfterWithChildren() && !marginInfo.canCollap seMarginAfterWithLastChild()) 1542 if (marginInfo.canCollapseMarginAfterWithChildren() && !marginInfo.canCollap seMarginAfterWithLastChild())
1543 marginInfo.setCanCollapseMarginAfterWithChildren(false); 1543 marginInfo.setCanCollapseMarginAfterWithChildren(false);
1544 1544
1545 // If we can't collapse with children then go ahead and add in the bottom ma rgin. 1545 // If we can't collapse with children then go ahead and add in the bottom ma rgin.
1546 if (!marginInfo.discardMargin() && (!marginInfo.canCollapseWithMarginAfter() && !marginInfo.canCollapseWithMarginBefore() 1546 if (!marginInfo.discardMargin() && (!marginInfo.canCollapseWithMarginAfter() && !marginInfo.canCollapseWithMarginBefore()
1547 && (!document().inQuirksMode() || !marginInfo.quirkContainer() || !margi nInfo.hasMarginAfterQuirk()))) 1547 && (!document().inQuirksMode() || !marginInfo.quirkContainer() || !margi nInfo.hasMarginAfterQuirk())))
1548 setLogicalHeight(logicalHeight() + marginInfo.margin()); 1548 setLogicalHeight(logicalHeight() + marginInfo.margin());
1549 1549
1550 // Now add in our bottom border/padding. 1550 // Now add in our bottom border/padding.
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
1827 break; 1827 break;
1828 case CBOTH: 1828 case CBOTH:
1829 logicalBottom = lowestFloatLogicalBottom(); 1829 logicalBottom = lowestFloatLogicalBottom();
1830 break; 1830 break;
1831 } 1831 }
1832 1832
1833 // We also clear floats if we are too big to sit on the same line as a float (and wish to avoid floats by default). 1833 // We also clear floats if we are too big to sit on the same line as a float (and wish to avoid floats by default).
1834 LayoutUnit result = clearSet ? std::max<LayoutUnit>(0, logicalBottom - logic alTop) : LayoutUnit(); 1834 LayoutUnit result = clearSet ? std::max<LayoutUnit>(0, logicalBottom - logic alTop) : LayoutUnit();
1835 if (!result && child->avoidsFloats()) { 1835 if (!result && child->avoidsFloats()) {
1836 LayoutUnit newLogicalTop = logicalTop; 1836 LayoutUnit newLogicalTop = logicalTop;
1837 LayoutRect borderBox = child->borderBoxRect();
leviw_travelin_and_unemployed 2015/06/16 17:52:59 This was just uselessly inside the loop before? *s
1838 LayoutUnit childLogicalWidthAtOldLogicalTopOffset = isHorizontalWritingM ode() ? borderBox.width() : borderBox.height();
1837 while (true) { 1839 while (true) {
1838 LayoutUnit availableLogicalWidthAtNewLogicalTopOffset = availableLog icalWidthForLine(newLogicalTop, false, logicalHeightForChild(*child)); 1840 LayoutUnit availableLogicalWidthAtNewLogicalTopOffset = availableLog icalWidthForLine(newLogicalTop, false, logicalHeightForChild(*child));
1839 if (availableLogicalWidthAtNewLogicalTopOffset == availableLogicalWi dthForContent()) 1841 if (availableLogicalWidthAtNewLogicalTopOffset == availableLogicalWi dthForContent())
1840 return newLogicalTop - logicalTop; 1842 return newLogicalTop - logicalTop;
1841 1843
1842 LayoutRect borderBox = child->borderBoxRect();
1843 LayoutUnit childLogicalWidthAtOldLogicalTopOffset = isHorizontalWrit ingMode() ? borderBox.width() : borderBox.height();
1844
1845 LogicalExtentComputedValues computedValues; 1844 LogicalExtentComputedValues computedValues;
1846 child->logicalExtentAfterUpdatingLogicalWidth(newLogicalTop, compute dValues); 1845 child->logicalExtentAfterUpdatingLogicalWidth(newLogicalTop, compute dValues);
1847 LayoutUnit childLogicalWidthAtNewLogicalTopOffset = computedValues.m _extent; 1846 LayoutUnit childLogicalWidthAtNewLogicalTopOffset = computedValues.m _extent;
1848 1847
1849 if (childLogicalWidthAtNewLogicalTopOffset <= availableLogicalWidthA tNewLogicalTopOffset) { 1848 if (childLogicalWidthAtNewLogicalTopOffset <= availableLogicalWidthA tNewLogicalTopOffset) {
1850 // Even though we may not be moving, if the logical width did sh rink because of the presence of new floats, then 1849 // Even though we may not be moving, if the logical width did sh rink because of the presence of new floats, then
1851 // we need to force a relayout as though we shifted. This happen s because of the dynamic addition of overhanging floats 1850 // we need to force a relayout as though we shifted. This happen s because of the dynamic addition of overhanging floats
1852 // from previous siblings when negative margins exist on a child (see the addOverhangingFloats call at the end of collapseMargins). 1851 // from previous siblings when negative margins exist on a child (see the addOverhangingFloats call at the end of collapseMargins).
1853 if (childLogicalWidthAtOldLogicalTopOffset != childLogicalWidthA tNewLogicalTopOffset) 1852 if (childLogicalWidthAtOldLogicalTopOffset != childLogicalWidthA tNewLogicalTopOffset)
1854 child->setChildNeedsLayout(MarkOnlyThis); 1853 child->setChildNeedsLayout(MarkOnlyThis);
(...skipping 1225 matching lines...) Expand 10 before | Expand all | Expand 10 after
3080 FrameView* frameView = document().view(); 3079 FrameView* frameView = document().view();
3081 LayoutUnit top = (style()->position() == FixedPosition) ? 0 : frameView->scr ollOffset().height(); 3080 LayoutUnit top = (style()->position() == FixedPosition) ? 0 : frameView->scr ollOffset().height();
3082 int visibleHeight = frameView->visibleContentRect(IncludeScrollbars).height( ); 3081 int visibleHeight = frameView->visibleContentRect(IncludeScrollbars).height( );
3083 if (size().height() < visibleHeight) 3082 if (size().height() < visibleHeight)
3084 top += (visibleHeight - size().height()) / 2; 3083 top += (visibleHeight - size().height()) / 2;
3085 setY(top); 3084 setY(top);
3086 dialog->setCentered(top); 3085 dialog->setCentered(top);
3087 } 3086 }
3088 3087
3089 } // namespace blink 3088 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/layout/LayoutBlockFlow.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698