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 541 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1109 if (afterMargin) { | 1112 if (afterMargin) { |
1110 if (afterMargin > 0) | 1113 if (afterMargin > 0) |
1111 childAfterPositive = afterMargin; | 1114 childAfterPositive = afterMargin; |
1112 else | 1115 else |
1113 childAfterNegative = -afterMargin; | 1116 childAfterNegative = -afterMargin; |
1114 } | 1117 } |
1115 | 1118 |
1116 return LayoutBlockFlow::MarginValues(childBeforePositive, childBeforeNegativ
e, childAfterPositive, childAfterNegative); | 1119 return LayoutBlockFlow::MarginValues(childBeforePositive, childBeforeNegativ
e, childAfterPositive, childAfterNegative); |
1117 } | 1120 } |
1118 | 1121 |
1119 LayoutUnit LayoutBlockFlow::collapseMargins(LayoutBox& child, MarginInfo& margin
Info, bool childIsSelfCollapsing) | 1122 LayoutUnit LayoutBlockFlow::collapseMargins(LayoutBox& child, MarginInfo& margin
Info, bool childIsSelfCollapsing, bool childDiscardMarginBefore, bool childDisca
rdMarginAfter) |
1120 { | 1123 { |
1121 bool childDiscardMarginBefore = mustDiscardMarginBeforeForChild(child); | |
1122 bool childDiscardMarginAfter = mustDiscardMarginAfterForChild(child); | |
1123 | |
1124 // The child discards the before margin when the the after margin has discar
d in the case of a self collapsing block. | 1124 // The child discards the before margin when the the after margin has discar
d in the case of a self collapsing block. |
1125 childDiscardMarginBefore = childDiscardMarginBefore || (childDiscardMarginAf
ter && childIsSelfCollapsing); | 1125 childDiscardMarginBefore = childDiscardMarginBefore || (childDiscardMarginAf
ter && childIsSelfCollapsing); |
1126 | 1126 |
1127 // Get the four margin values for the child and cache them. | 1127 // Get the four margin values for the child and cache them. |
1128 const LayoutBlockFlow::MarginValues childMargins = marginValuesForChild(chil
d); | 1128 const LayoutBlockFlow::MarginValues childMargins = marginValuesForChild(chil
d); |
1129 | 1129 |
1130 // Get our max pos and neg top margins. | 1130 // Get our max pos and neg top margins. |
1131 LayoutUnit posTop = childMargins.positiveMarginBefore(); | 1131 LayoutUnit posTop = childMargins.positiveMarginBefore(); |
1132 LayoutUnit negTop = childMargins.negativeMarginBefore(); | 1132 LayoutUnit negTop = childMargins.negativeMarginBefore(); |
1133 | 1133 |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1291 LayoutUnit collapsedBeforePos = marginInfo.positiveMargin(); | 1291 LayoutUnit collapsedBeforePos = marginInfo.positiveMargin(); |
1292 LayoutUnit collapsedBeforeNeg = marginInfo.negativeMargin(); | 1292 LayoutUnit collapsedBeforeNeg = marginInfo.negativeMargin(); |
1293 logicalTop += collapsedBeforePos - collapsedBeforeNeg; | 1293 logicalTop += collapsedBeforePos - collapsedBeforeNeg; |
1294 } | 1294 } |
1295 | 1295 |
1296 DeprecatedPaintLayer* childLayer = child.layer(); | 1296 DeprecatedPaintLayer* childLayer = child.layer(); |
1297 if (childLayer->staticBlockPosition() != logicalTop) | 1297 if (childLayer->staticBlockPosition() != logicalTop) |
1298 childLayer->setStaticBlockPosition(logicalTop); | 1298 childLayer->setStaticBlockPosition(logicalTop); |
1299 } | 1299 } |
1300 | 1300 |
1301 LayoutUnit LayoutBlockFlow::clearFloatsIfNeeded(LayoutBox& child, MarginInfo& ma
rginInfo, LayoutUnit oldTopPosMargin, LayoutUnit oldTopNegMargin, LayoutUnit yPo
s, bool childIsSelfCollapsing) | 1301 LayoutUnit LayoutBlockFlow::clearFloatsIfNeeded(LayoutBox& child, MarginInfo& ma
rginInfo, LayoutUnit oldTopPosMargin, LayoutUnit oldTopNegMargin, LayoutUnit yPo
s, bool childIsSelfCollapsing, bool childDiscardMargin) |
1302 { | 1302 { |
1303 LayoutUnit heightIncrease = getClearDelta(&child, yPos); | 1303 LayoutUnit heightIncrease = getClearDelta(&child, yPos); |
1304 marginInfo.setLastChildIsSelfCollapsingBlockWithClearance(false); | 1304 marginInfo.setLastChildIsSelfCollapsingBlockWithClearance(false); |
1305 | 1305 |
1306 if (!heightIncrease) | 1306 if (!heightIncrease) |
1307 return yPos; | 1307 return yPos; |
1308 | 1308 |
1309 if (childIsSelfCollapsing) { | 1309 if (childIsSelfCollapsing) { |
1310 marginInfo.setLastChildIsSelfCollapsingBlockWithClearance(true); | 1310 marginInfo.setLastChildIsSelfCollapsingBlockWithClearance(true); |
1311 bool childDiscardMargin = mustDiscardMarginBeforeForChild(child) || must
DiscardMarginAfterForChild(child); | |
1312 marginInfo.setDiscardMargin(childDiscardMargin); | 1311 marginInfo.setDiscardMargin(childDiscardMargin); |
1313 | 1312 |
1314 // For self-collapsing blocks that clear, they can still collapse their | 1313 // For self-collapsing blocks that clear, they can still collapse their |
1315 // margins with following siblings. Reset the current margins to represe
nt | 1314 // margins with following siblings. Reset the current margins to represe
nt |
1316 // the self-collapsing block's margins only. | 1315 // the self-collapsing block's margins only. |
1317 // If DISCARD is specified for -webkit-margin-collapse, reset the margin
values. | 1316 // If DISCARD is specified for -webkit-margin-collapse, reset the margin
values. |
1318 LayoutBlockFlow::MarginValues childMargins = marginValuesForChild(child)
; | 1317 LayoutBlockFlow::MarginValues childMargins = marginValuesForChild(child)
; |
1319 if (!childDiscardMargin) { | 1318 if (!childDiscardMargin) { |
1320 marginInfo.setPositiveMargin(std::max(childMargins.positiveMarginBef
ore(), childMargins.positiveMarginAfter())); | 1319 marginInfo.setPositiveMargin(std::max(childMargins.positiveMarginBef
ore(), childMargins.positiveMarginAfter())); |
1321 marginInfo.setNegativeMargin(std::max(childMargins.negativeMarginBef
ore(), childMargins.negativeMarginAfter())); | 1320 marginInfo.setNegativeMargin(std::max(childMargins.negativeMarginBef
ore(), childMargins.negativeMarginAfter())); |
(...skipping 1744 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3066 FrameView* frameView = document().view(); | 3065 FrameView* frameView = document().view(); |
3067 LayoutUnit top = (style()->position() == FixedPosition) ? 0 : frameView->scr
ollOffset().height(); | 3066 LayoutUnit top = (style()->position() == FixedPosition) ? 0 : frameView->scr
ollOffset().height(); |
3068 int visibleHeight = frameView->visibleContentRect(IncludeScrollbars).height(
); | 3067 int visibleHeight = frameView->visibleContentRect(IncludeScrollbars).height(
); |
3069 if (size().height() < visibleHeight) | 3068 if (size().height() < visibleHeight) |
3070 top += (visibleHeight - size().height()) / 2; | 3069 top += (visibleHeight - size().height()) / 2; |
3071 setY(top); | 3070 setY(top); |
3072 dialog->setCentered(top); | 3071 dialog->setCentered(top); |
3073 } | 3072 } |
3074 | 3073 |
3075 } // namespace blink | 3074 } // namespace blink |
OLD | NEW |