| 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 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 bool determinedMarginBeforeQuirk() const { return m_determinedMarginBeforeQu
irk; } | 146 bool determinedMarginBeforeQuirk() const { return m_determinedMarginBeforeQu
irk; } |
| 147 bool hasMarginBeforeQuirk() const { return m_hasMarginBeforeQuirk; } | 147 bool hasMarginBeforeQuirk() const { return m_hasMarginBeforeQuirk; } |
| 148 bool hasMarginAfterQuirk() const { return m_hasMarginAfterQuirk; } | 148 bool hasMarginAfterQuirk() const { return m_hasMarginAfterQuirk; } |
| 149 LayoutUnit positiveMargin() const { return m_positiveMargin; } | 149 LayoutUnit positiveMargin() const { return m_positiveMargin; } |
| 150 LayoutUnit negativeMargin() const { return m_negativeMargin; } | 150 LayoutUnit negativeMargin() const { return m_negativeMargin; } |
| 151 bool discardMargin() const { return m_discardMargin; } | 151 bool discardMargin() const { return m_discardMargin; } |
| 152 LayoutUnit margin() const { return m_positiveMargin - m_negativeMargin; } | 152 LayoutUnit margin() const { return m_positiveMargin - m_negativeMargin; } |
| 153 void setLastChildIsSelfCollapsingBlockWithClearance(bool value) { m_lastChil
dIsSelfCollapsingBlockWithClearance = value; } | 153 void setLastChildIsSelfCollapsingBlockWithClearance(bool value) { m_lastChil
dIsSelfCollapsingBlockWithClearance = value; } |
| 154 bool lastChildIsSelfCollapsingBlockWithClearance() const { return m_lastChil
dIsSelfCollapsingBlockWithClearance; } | 154 bool lastChildIsSelfCollapsingBlockWithClearance() const { return m_lastChil
dIsSelfCollapsingBlockWithClearance; } |
| 155 }; | 155 }; |
| 156 static bool inNormalFlow(LayoutBox* child) | |
| 157 { | |
| 158 LayoutBlock* curr = child->containingBlock(); | |
| 159 LayoutView* layoutView = child->view(); | |
| 160 while (curr && curr != layoutView) { | |
| 161 if (curr->isLayoutFlowThread()) | |
| 162 return true; | |
| 163 if (curr->isFloatingOrOutOfFlowPositioned()) | |
| 164 return false; | |
| 165 curr = curr->containingBlock(); | |
| 166 } | |
| 167 return true; | |
| 168 } | |
| 169 | 156 |
| 170 LayoutBlockFlow::LayoutBlockFlow(ContainerNode* node) | 157 LayoutBlockFlow::LayoutBlockFlow(ContainerNode* node) |
| 171 : LayoutBlock(node) | 158 : LayoutBlock(node) |
| 172 { | 159 { |
| 173 static_assert(sizeof(MarginInfo) == sizeof(SameSizeAsMarginInfo), "MarginInf
o should stay small"); | 160 static_assert(sizeof(MarginInfo) == sizeof(SameSizeAsMarginInfo), "MarginInf
o should stay small"); |
| 174 setChildrenInline(true); | 161 setChildrenInline(true); |
| 175 } | 162 } |
| 176 | 163 |
| 177 LayoutBlockFlow::~LayoutBlockFlow() | 164 LayoutBlockFlow::~LayoutBlockFlow() |
| 178 { | 165 { |
| (...skipping 1530 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1709 return childStyle.marginAfterCollapse() == MSEPARATE; | 1696 return childStyle.marginAfterCollapse() == MSEPARATE; |
| 1710 if (child.isHorizontalWritingMode() == isHorizontalWritingMode()) | 1697 if (child.isHorizontalWritingMode() == isHorizontalWritingMode()) |
| 1711 return childStyle.marginBeforeCollapse() == MSEPARATE; | 1698 return childStyle.marginBeforeCollapse() == MSEPARATE; |
| 1712 | 1699 |
| 1713 // FIXME: See |mustDiscardMarginBeforeForChild| above. | 1700 // FIXME: See |mustDiscardMarginBeforeForChild| above. |
| 1714 return false; | 1701 return false; |
| 1715 } | 1702 } |
| 1716 | 1703 |
| 1717 LayoutUnit LayoutBlockFlow::applyBeforeBreak(LayoutBox& child, LayoutUnit logica
lOffset) | 1704 LayoutUnit LayoutBlockFlow::applyBeforeBreak(LayoutBox& child, LayoutUnit logica
lOffset) |
| 1718 { | 1705 { |
| 1719 // FIXME: Add page break checking here when we support printing. | 1706 if (child.hasForcedBreakBefore()) { |
| 1720 LayoutFlowThread* flowThread = flowThreadContainingBlock(); | 1707 if (LayoutFlowThread* flowThread = flowThreadContainingBlock()) { |
| 1721 bool checkColumnBreaks = flowThread; | |
| 1722 bool checkPageBreaks = !checkColumnBreaks && view()->layoutState()->pageLogi
calHeight(); // FIXME: Once columns can print we have to check this. | |
| 1723 bool checkBeforeAlways = (checkColumnBreaks && child.style()->columnBreakBef
ore() == PBALWAYS) | |
| 1724 || (checkPageBreaks && child.style()->pageBreakBefore() == PBALWAYS); | |
| 1725 if (checkBeforeAlways && inNormalFlow(&child)) { | |
| 1726 if (checkColumnBreaks) { | |
| 1727 LayoutUnit offsetBreakAdjustment = 0; | 1708 LayoutUnit offsetBreakAdjustment = 0; |
| 1728 if (flowThread->addForcedColumnBreak(offsetFromLogicalTopOfFirstPage
() + logicalOffset, &child, true, &offsetBreakAdjustment)) | 1709 if (flowThread->addForcedColumnBreak(offsetFromLogicalTopOfFirstPage
() + logicalOffset, &child, true, &offsetBreakAdjustment)) |
| 1729 return logicalOffset + offsetBreakAdjustment; | 1710 return logicalOffset + offsetBreakAdjustment; |
| 1730 } | 1711 } |
| 1731 return nextPageLogicalTop(logicalOffset, AssociateWithFormerPage); | 1712 return nextPageLogicalTop(logicalOffset, AssociateWithFormerPage); |
| 1732 } | 1713 } |
| 1733 return logicalOffset; | 1714 return logicalOffset; |
| 1734 } | 1715 } |
| 1735 | 1716 |
| 1736 LayoutUnit LayoutBlockFlow::applyAfterBreak(LayoutBox& child, LayoutUnit logical
Offset, MarginInfo& marginInfo) | 1717 LayoutUnit LayoutBlockFlow::applyAfterBreak(LayoutBox& child, LayoutUnit logical
Offset, MarginInfo& marginInfo) |
| 1737 { | 1718 { |
| 1738 // FIXME: Add page break checking here when we support printing. | 1719 if (child.hasForcedBreakAfter()) { |
| 1739 LayoutFlowThread* flowThread = flowThreadContainingBlock(); | |
| 1740 bool checkColumnBreaks = flowThread; | |
| 1741 bool checkPageBreaks = !checkColumnBreaks && view()->layoutState()->pageLogi
calHeight(); // FIXME: Once columns can print we have to check this. | |
| 1742 bool checkAfterAlways = (checkColumnBreaks && child.style()->columnBreakAfte
r() == PBALWAYS) | |
| 1743 || (checkPageBreaks && child.style()->pageBreakAfter() == PBALWAYS); | |
| 1744 if (checkAfterAlways && inNormalFlow(&child)) { | |
| 1745 // So our margin doesn't participate in the next collapsing steps. | 1720 // So our margin doesn't participate in the next collapsing steps. |
| 1746 marginInfo.clearMargin(); | 1721 marginInfo.clearMargin(); |
| 1747 | 1722 |
| 1748 if (checkColumnBreaks) { | 1723 if (LayoutFlowThread* flowThread = flowThreadContainingBlock()) { |
| 1749 LayoutUnit offsetBreakAdjustment = 0; | 1724 LayoutUnit offsetBreakAdjustment = 0; |
| 1750 if (flowThread->addForcedColumnBreak(offsetFromLogicalTopOfFirstPage
() + logicalOffset, &child, false, &offsetBreakAdjustment)) | 1725 if (flowThread->addForcedColumnBreak(offsetFromLogicalTopOfFirstPage
() + logicalOffset, &child, false, &offsetBreakAdjustment)) |
| 1751 return logicalOffset + offsetBreakAdjustment; | 1726 return logicalOffset + offsetBreakAdjustment; |
| 1752 } | 1727 } |
| 1753 return nextPageLogicalTop(logicalOffset, AssociateWithFormerPage); | 1728 return nextPageLogicalTop(logicalOffset, AssociateWithFormerPage); |
| 1754 } | 1729 } |
| 1755 return logicalOffset; | 1730 return logicalOffset; |
| 1756 } | 1731 } |
| 1757 | 1732 |
| 1758 void LayoutBlockFlow::addOverflowFromFloats() | 1733 void LayoutBlockFlow::addOverflowFromFloats() |
| (...skipping 1340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3099 FrameView* frameView = document().view(); | 3074 FrameView* frameView = document().view(); |
| 3100 LayoutUnit top = (style()->position() == FixedPosition) ? 0 : frameView->scr
ollOffset().height(); | 3075 LayoutUnit top = (style()->position() == FixedPosition) ? 0 : frameView->scr
ollOffset().height(); |
| 3101 int visibleHeight = frameView->visibleContentRect(IncludeScrollbars).height(
); | 3076 int visibleHeight = frameView->visibleContentRect(IncludeScrollbars).height(
); |
| 3102 if (size().height() < visibleHeight) | 3077 if (size().height() < visibleHeight) |
| 3103 top += (visibleHeight - size().height()) / 2; | 3078 top += (visibleHeight - size().height()) / 2; |
| 3104 setY(top); | 3079 setY(top); |
| 3105 dialog->setCentered(top); | 3080 dialog->setCentered(top); |
| 3106 } | 3081 } |
| 3107 | 3082 |
| 3108 } // namespace blink | 3083 } // namespace blink |
| OLD | NEW |