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 530 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
541 if (!child.needsLayout()) | 541 if (!child.needsLayout()) |
542 child.markForPaginationRelayoutIfNeeded(layoutScope); | 542 child.markForPaginationRelayoutIfNeeded(layoutScope); |
543 | 543 |
544 bool childNeededLayout = child.needsLayout(); | 544 bool childNeededLayout = child.needsLayout(); |
545 if (childNeededLayout) | 545 if (childNeededLayout) |
546 child.layout(); | 546 child.layout(); |
547 | 547 |
548 // Cache if we are at the top of the block right now. | 548 // Cache if we are at the top of the block right now. |
549 bool atBeforeSideOfBlock = marginInfo.atBeforeSideOfBlock(); | 549 bool atBeforeSideOfBlock = marginInfo.atBeforeSideOfBlock(); |
550 bool childIsSelfCollapsing = child.isSelfCollapsingBlock(); | 550 bool childIsSelfCollapsing = child.isSelfCollapsingBlock(); |
| 551 bool childDiscardMarginBefore = mustDiscardMarginBeforeForChild(child); |
| 552 bool childDiscardMarginAfter = mustDiscardMarginAfterForChild(child); |
551 | 553 |
552 // Now determine the correct ypos based off examination of collapsing margin | 554 // Now determine the correct ypos based off examination of collapsing margin |
553 // values. | 555 // values. |
554 LayoutUnit logicalTopBeforeClear = collapseMargins(child, marginInfo, childI
sSelfCollapsing); | 556 LayoutUnit logicalTopBeforeClear = collapseMargins(child, marginInfo, childI
sSelfCollapsing, childDiscardMarginBefore, childDiscardMarginAfter); |
555 | 557 |
556 // Now check for clear. | 558 // Now check for clear. |
557 LayoutUnit logicalTopAfterClear = clearFloatsIfNeeded(child, marginInfo, old
PosMarginBefore, oldNegMarginBefore, logicalTopBeforeClear, childIsSelfCollapsin
g); | 559 bool childDiscardMargin = childDiscardMarginBefore || childDiscardMarginAfte
r; |
| 560 LayoutUnit logicalTopAfterClear = clearFloatsIfNeeded(child, marginInfo, old
PosMarginBefore, oldNegMarginBefore, logicalTopBeforeClear, childIsSelfCollapsin
g, childDiscardMargin); |
558 | 561 |
559 bool paginated = view()->layoutState()->isPaginated(); | 562 bool paginated = view()->layoutState()->isPaginated(); |
560 if (paginated) { | 563 if (paginated) { |
561 logicalTopAfterClear = adjustBlockChildForPagination(logicalTopAfterClea
r, estimateWithoutPagination, child, | 564 logicalTopAfterClear = adjustBlockChildForPagination(logicalTopAfterClea
r, estimateWithoutPagination, child, |
562 atBeforeSideOfBlock && logicalTopBeforeClear == logicalTopAfterClear
); | 565 atBeforeSideOfBlock && logicalTopBeforeClear == logicalTopAfterClear
); |
563 } | 566 } |
564 | 567 |
565 setLogicalTopForChild(child, logicalTopAfterClear); | 568 setLogicalTopForChild(child, logicalTopAfterClear); |
566 | 569 |
567 // Now we have a final top position. See if it really does end up being diff
erent from our estimate. | 570 // Now we have a final top position. See if it really does end up being diff
erent from our estimate. |
(...skipping 547 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1115 if (afterMargin) { | 1118 if (afterMargin) { |
1116 if (afterMargin > 0) | 1119 if (afterMargin > 0) |
1117 childAfterPositive = afterMargin; | 1120 childAfterPositive = afterMargin; |
1118 else | 1121 else |
1119 childAfterNegative = -afterMargin; | 1122 childAfterNegative = -afterMargin; |
1120 } | 1123 } |
1121 | 1124 |
1122 return LayoutBlockFlow::MarginValues(childBeforePositive, childBeforeNegativ
e, childAfterPositive, childAfterNegative); | 1125 return LayoutBlockFlow::MarginValues(childBeforePositive, childBeforeNegativ
e, childAfterPositive, childAfterNegative); |
1123 } | 1126 } |
1124 | 1127 |
1125 LayoutUnit LayoutBlockFlow::collapseMargins(LayoutBox& child, MarginInfo& margin
Info, bool childIsSelfCollapsing) | 1128 LayoutUnit LayoutBlockFlow::collapseMargins(LayoutBox& child, MarginInfo& margin
Info, bool childIsSelfCollapsing, bool childDiscardMarginBefore, bool childDisca
rdMarginAfter) |
1126 { | 1129 { |
1127 bool childDiscardMarginBefore = mustDiscardMarginBeforeForChild(child); | |
1128 bool childDiscardMarginAfter = mustDiscardMarginAfterForChild(child); | |
1129 | |
1130 // The child discards the before margin when the the after margin has discar
d in the case of a self collapsing block. | 1130 // The child discards the before margin when the the after margin has discar
d in the case of a self collapsing block. |
1131 childDiscardMarginBefore = childDiscardMarginBefore || (childDiscardMarginAf
ter && childIsSelfCollapsing); | 1131 childDiscardMarginBefore = childDiscardMarginBefore || (childDiscardMarginAf
ter && childIsSelfCollapsing); |
1132 | 1132 |
1133 // Get the four margin values for the child and cache them. | 1133 // Get the four margin values for the child and cache them. |
1134 const LayoutBlockFlow::MarginValues childMargins = marginValuesForChild(chil
d); | 1134 const LayoutBlockFlow::MarginValues childMargins = marginValuesForChild(chil
d); |
1135 | 1135 |
1136 // Get our max pos and neg top margins. | 1136 // Get our max pos and neg top margins. |
1137 LayoutUnit posTop = childMargins.positiveMarginBefore(); | 1137 LayoutUnit posTop = childMargins.positiveMarginBefore(); |
1138 LayoutUnit negTop = childMargins.negativeMarginBefore(); | 1138 LayoutUnit negTop = childMargins.negativeMarginBefore(); |
1139 | 1139 |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1298 LayoutUnit collapsedBeforeNeg = marginInfo.negativeMargin(); | 1298 LayoutUnit collapsedBeforeNeg = marginInfo.negativeMargin(); |
1299 logicalTop += collapsedBeforePos - collapsedBeforeNeg; | 1299 logicalTop += collapsedBeforePos - collapsedBeforeNeg; |
1300 } | 1300 } |
1301 | 1301 |
1302 DeprecatedPaintLayer* childLayer = child.layer(); | 1302 DeprecatedPaintLayer* childLayer = child.layer(); |
1303 if (childLayer->staticBlockPosition() != logicalTop) { | 1303 if (childLayer->staticBlockPosition() != logicalTop) { |
1304 childLayer->setStaticBlockPosition(logicalTop); | 1304 childLayer->setStaticBlockPosition(logicalTop); |
1305 } | 1305 } |
1306 } | 1306 } |
1307 | 1307 |
1308 LayoutUnit LayoutBlockFlow::clearFloatsIfNeeded(LayoutBox& child, MarginInfo& ma
rginInfo, LayoutUnit oldTopPosMargin, LayoutUnit oldTopNegMargin, LayoutUnit yPo
s, bool childIsSelfCollapsing) | 1308 LayoutUnit LayoutBlockFlow::clearFloatsIfNeeded(LayoutBox& child, MarginInfo& ma
rginInfo, LayoutUnit oldTopPosMargin, LayoutUnit oldTopNegMargin, LayoutUnit yPo
s, bool childIsSelfCollapsing, bool childDiscardMargin) |
1309 { | 1309 { |
1310 LayoutUnit heightIncrease = getClearDelta(&child, yPos); | 1310 LayoutUnit heightIncrease = getClearDelta(&child, yPos); |
1311 marginInfo.setLastChildIsSelfCollapsingBlockWithClearance(false); | 1311 marginInfo.setLastChildIsSelfCollapsingBlockWithClearance(false); |
1312 | 1312 |
1313 if (!heightIncrease) | 1313 if (!heightIncrease) |
1314 return yPos; | 1314 return yPos; |
1315 | 1315 |
1316 if (childIsSelfCollapsing) { | 1316 if (childIsSelfCollapsing) { |
1317 marginInfo.setLastChildIsSelfCollapsingBlockWithClearance(true); | 1317 marginInfo.setLastChildIsSelfCollapsingBlockWithClearance(true); |
1318 bool childDiscardMargin = mustDiscardMarginBeforeForChild(child) || must
DiscardMarginAfterForChild(child); | |
1319 marginInfo.setDiscardMargin(childDiscardMargin); | 1318 marginInfo.setDiscardMargin(childDiscardMargin); |
1320 | 1319 |
1321 // For self-collapsing blocks that clear, they can still collapse their | 1320 // For self-collapsing blocks that clear, they can still collapse their |
1322 // margins with following siblings. Reset the current margins to represe
nt | 1321 // margins with following siblings. Reset the current margins to represe
nt |
1323 // the self-collapsing block's margins only. | 1322 // the self-collapsing block's margins only. |
1324 // If DISCARD is specified for -webkit-margin-collapse, reset the margin
values. | 1323 // If DISCARD is specified for -webkit-margin-collapse, reset the margin
values. |
1325 LayoutBlockFlow::MarginValues childMargins = marginValuesForChild(child)
; | 1324 LayoutBlockFlow::MarginValues childMargins = marginValuesForChild(child)
; |
1326 if (!childDiscardMargin) { | 1325 if (!childDiscardMargin) { |
1327 marginInfo.setPositiveMargin(std::max(childMargins.positiveMarginBef
ore(), childMargins.positiveMarginAfter())); | 1326 marginInfo.setPositiveMargin(std::max(childMargins.positiveMarginBef
ore(), childMargins.positiveMarginAfter())); |
1328 marginInfo.setNegativeMargin(std::max(childMargins.negativeMarginBef
ore(), childMargins.negativeMarginAfter())); | 1327 marginInfo.setNegativeMargin(std::max(childMargins.negativeMarginBef
ore(), childMargins.negativeMarginAfter())); |
(...skipping 1744 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3073 FrameView* frameView = document().view(); | 3072 FrameView* frameView = document().view(); |
3074 LayoutUnit top = (style()->position() == FixedPosition) ? 0 : frameView->scr
ollOffset().height(); | 3073 LayoutUnit top = (style()->position() == FixedPosition) ? 0 : frameView->scr
ollOffset().height(); |
3075 int visibleHeight = frameView->visibleContentRect(IncludeScrollbars).height(
); | 3074 int visibleHeight = frameView->visibleContentRect(IncludeScrollbars).height(
); |
3076 if (size().height() < visibleHeight) | 3075 if (size().height() < visibleHeight) |
3077 top += (visibleHeight - size().height()) / 2; | 3076 top += (visibleHeight - size().height()) / 2; |
3078 setY(top); | 3077 setY(top); |
3079 dialog->setCentered(top); | 3078 dialog->setCentered(top); |
3080 } | 3079 } |
3081 | 3080 |
3082 } // namespace blink | 3081 } // namespace blink |
OLD | NEW |