| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2007 Apple Inc. All rights reserved. | 2 * Copyright (C) 2007 Apple 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 | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 #include "core/layout/LayoutInline.h" | 30 #include "core/layout/LayoutInline.h" |
| 31 #include "core/layout/LayoutView.h" | 31 #include "core/layout/LayoutView.h" |
| 32 | 32 |
| 33 namespace blink { | 33 namespace blink { |
| 34 | 34 |
| 35 LayoutState::LayoutState(LayoutUnit pageLogicalHeight, bool pageLogicalHeightCha
nged, LayoutView& view) | 35 LayoutState::LayoutState(LayoutUnit pageLogicalHeight, bool pageLogicalHeightCha
nged, LayoutView& view) |
| 36 : m_isPaginated(pageLogicalHeight) | 36 : m_isPaginated(pageLogicalHeight) |
| 37 , m_pageLogicalHeightChanged(pageLogicalHeightChanged) | 37 , m_pageLogicalHeightChanged(pageLogicalHeightChanged) |
| 38 , m_containingBlockLogicalWidthChanged(false) | 38 , m_containingBlockLogicalWidthChanged(false) |
| 39 , m_flowThread(0) | 39 , m_flowThread(0) |
| 40 , m_columnInfo(0) | |
| 41 , m_next(0) | 40 , m_next(0) |
| 42 , m_pageLogicalHeight(pageLogicalHeight) | 41 , m_pageLogicalHeight(pageLogicalHeight) |
| 43 , m_layoutObject(view) | 42 , m_layoutObject(view) |
| 44 { | 43 { |
| 45 ASSERT(!view.layoutState()); | 44 ASSERT(!view.layoutState()); |
| 46 view.pushLayoutState(*this); | 45 view.pushLayoutState(*this); |
| 47 } | 46 } |
| 48 | 47 |
| 49 LayoutState::LayoutState(LayoutBox& layoutObject, const LayoutSize& offset, Layo
utUnit pageLogicalHeight, bool pageLogicalHeightChanged, ColumnInfo* columnInfo,
bool containingBlockLogicalWidthChanged) | 48 LayoutState::LayoutState(LayoutBox& layoutObject, const LayoutSize& offset, Layo
utUnit pageLogicalHeight, bool pageLogicalHeightChanged, bool containingBlockLog
icalWidthChanged) |
| 50 : m_containingBlockLogicalWidthChanged(containingBlockLogicalWidthChanged) | 49 : m_containingBlockLogicalWidthChanged(containingBlockLogicalWidthChanged) |
| 51 , m_columnInfo(columnInfo) | |
| 52 , m_next(layoutObject.view()->layoutState()) | 50 , m_next(layoutObject.view()->layoutState()) |
| 53 , m_layoutObject(layoutObject) | 51 , m_layoutObject(layoutObject) |
| 54 { | 52 { |
| 55 if (layoutObject.isLayoutFlowThread()) | 53 if (layoutObject.isLayoutFlowThread()) |
| 56 m_flowThread = toLayoutFlowThread(&layoutObject); | 54 m_flowThread = toLayoutFlowThread(&layoutObject); |
| 57 else if (!layoutObject.isOutOfFlowPositioned() && !layoutObject.isColumnSpan
All()) | 55 else if (!layoutObject.isOutOfFlowPositioned() && !layoutObject.isColumnSpan
All()) |
| 58 m_flowThread = m_next->flowThread(); | 56 m_flowThread = m_next->flowThread(); |
| 59 else | 57 else |
| 60 m_flowThread = nullptr; | 58 m_flowThread = nullptr; |
| 61 layoutObject.view()->pushLayoutState(*this); | 59 layoutObject.view()->pushLayoutState(*this); |
| 62 bool fixed = layoutObject.isOutOfFlowPositioned() && layoutObject.style()->p
osition() == FixedPosition; | 60 bool fixed = layoutObject.isOutOfFlowPositioned() && layoutObject.style()->p
osition() == FixedPosition; |
| 63 if (fixed) { | 61 if (fixed) { |
| 64 // FIXME: This doesn't work correctly with transforms. | 62 // FIXME: This doesn't work correctly with transforms. |
| 65 FloatPoint fixedOffset = layoutObject.view()->localToAbsolute(FloatPoint
(), IsFixed); | 63 FloatPoint fixedOffset = layoutObject.view()->localToAbsolute(FloatPoint
(), IsFixed); |
| 66 m_layoutOffset = LayoutSize(fixedOffset.x(), fixedOffset.y()) + offset; | 64 m_layoutOffset = LayoutSize(fixedOffset.x(), fixedOffset.y()) + offset; |
| 67 } else { | 65 } else { |
| 68 m_layoutOffset = m_next->m_layoutOffset + offset; | 66 m_layoutOffset = m_next->m_layoutOffset + offset; |
| 69 } | 67 } |
| 70 | 68 |
| 71 if (layoutObject.isOutOfFlowPositioned() && !fixed) { | 69 if (layoutObject.isOutOfFlowPositioned() && !fixed) { |
| 72 if (LayoutObject* container = layoutObject.container()) { | 70 if (LayoutObject* container = layoutObject.container()) { |
| 73 if (container->style()->hasInFlowPosition() && container->isLayoutIn
line()) | 71 if (container->style()->hasInFlowPosition() && container->isLayoutIn
line()) |
| 74 m_layoutOffset += toLayoutInline(container)->offsetForInFlowPosi
tionedInline(layoutObject); | 72 m_layoutOffset += toLayoutInline(container)->offsetForInFlowPosi
tionedInline(layoutObject); |
| 75 } | 73 } |
| 76 } | 74 } |
| 77 // If we establish a new page height, then cache the offset to the top of th
e first page. | 75 // If we establish a new page height, then cache the offset to the top of th
e first page. |
| 78 // We can compare this later on to figure out what part of the page we're ac
tually on, | 76 // We can compare this later on to figure out what part of the page we're ac
tually on, |
| 79 if (pageLogicalHeight || m_columnInfo || layoutObject.isLayoutFlowThread())
{ | 77 if (pageLogicalHeight || layoutObject.isLayoutFlowThread()) { |
| 80 m_pageLogicalHeight = pageLogicalHeight; | 78 m_pageLogicalHeight = pageLogicalHeight; |
| 81 bool isFlipped = layoutObject.style()->isFlippedBlocksWritingMode(); | 79 bool isFlipped = layoutObject.style()->isFlippedBlocksWritingMode(); |
| 82 m_pageOffset = LayoutSize(m_layoutOffset.width() + (!isFlipped ? layoutO
bject.borderLeft() + layoutObject.paddingLeft() : layoutObject.borderRight() + l
ayoutObject.paddingRight()), | 80 m_pageOffset = LayoutSize(m_layoutOffset.width() + (!isFlipped ? layoutO
bject.borderLeft() + layoutObject.paddingLeft() : layoutObject.borderRight() + l
ayoutObject.paddingRight()), |
| 83 m_layoutOffset.height() + (!isFlipped ? layoutObject.borderTop() + l
ayoutObject.paddingTop() : layoutObject.borderBottom() + layoutObject.paddingBot
tom())); | 81 m_layoutOffset.height() + (!isFlipped ? layoutObject.borderTop() + l
ayoutObject.paddingTop() : layoutObject.borderBottom() + layoutObject.paddingBot
tom())); |
| 84 m_pageLogicalHeightChanged = pageLogicalHeightChanged; | 82 m_pageLogicalHeightChanged = pageLogicalHeightChanged; |
| 85 m_isPaginated = true; | 83 m_isPaginated = true; |
| 86 } else if (m_layoutObject.isSVG() && !m_layoutObject.isSVGRoot()) { | 84 } else if (m_layoutObject.isSVG() && !m_layoutObject.isSVGRoot()) { |
| 87 // Pagination inside SVG is not allowed. | 85 // Pagination inside SVG is not allowed. |
| 88 m_flowThread = nullptr; | 86 m_flowThread = nullptr; |
| 89 m_pageLogicalHeightChanged = false; | 87 m_pageLogicalHeightChanged = false; |
| 90 m_isPaginated = false; | 88 m_isPaginated = false; |
| 91 } else { | 89 } else { |
| 92 // If we don't establish a new page height, then propagate the old page
height and offset down. | 90 // If we don't establish a new page height, then propagate the old page
height and offset down. |
| 93 m_pageLogicalHeight = m_next->m_pageLogicalHeight; | 91 m_pageLogicalHeight = m_next->m_pageLogicalHeight; |
| 94 m_pageLogicalHeightChanged = m_next->m_pageLogicalHeightChanged; | 92 m_pageLogicalHeightChanged = m_next->m_pageLogicalHeightChanged; |
| 95 m_pageOffset = m_next->m_pageOffset; | 93 m_pageOffset = m_next->m_pageOffset; |
| 96 | 94 |
| 97 // Disable pagination for objects we don't support. For now this include
s overflow:scroll/auto, inline blocks and | 95 // Disable pagination for objects we don't support. For now this include
s overflow:scroll/auto, inline blocks and |
| 98 // writing mode roots. | 96 // writing mode roots. |
| 99 if (layoutObject.isUnsplittableForPagination()) { | 97 if (layoutObject.isUnsplittableForPagination()) { |
| 100 m_pageLogicalHeight = 0; | 98 m_pageLogicalHeight = 0; |
| 101 m_isPaginated = false; | 99 m_isPaginated = false; |
| 102 } else { | 100 } else { |
| 103 m_isPaginated = m_pageLogicalHeight || m_next->m_columnInfo || layou
tObject.flowThreadContainingBlock(); | 101 m_isPaginated = m_pageLogicalHeight || layoutObject.flowThreadContai
ningBlock(); |
| 104 } | 102 } |
| 105 } | 103 } |
| 106 | 104 |
| 107 if (!m_columnInfo) | |
| 108 m_columnInfo = m_next->m_columnInfo; | |
| 109 | |
| 110 // FIXME: <http://bugs.webkit.org/show_bug.cgi?id=13443> Apply control clip
if present. | 105 // FIXME: <http://bugs.webkit.org/show_bug.cgi?id=13443> Apply control clip
if present. |
| 111 } | 106 } |
| 112 | 107 |
| 113 LayoutState::LayoutState(LayoutObject& root) | 108 LayoutState::LayoutState(LayoutObject& root) |
| 114 : m_isPaginated(false) | 109 : m_isPaginated(false) |
| 115 , m_pageLogicalHeightChanged(false) | 110 , m_pageLogicalHeightChanged(false) |
| 116 , m_containingBlockLogicalWidthChanged(false) | 111 , m_containingBlockLogicalWidthChanged(false) |
| 117 , m_flowThread(0) | 112 , m_flowThread(0) |
| 118 , m_columnInfo(0) | |
| 119 , m_next(root.view()->layoutState()) | 113 , m_next(root.view()->layoutState()) |
| 120 , m_pageLogicalHeight(0) | 114 , m_pageLogicalHeight(0) |
| 121 , m_layoutObject(root) | 115 , m_layoutObject(root) |
| 122 { | 116 { |
| 123 ASSERT(!m_next); | 117 ASSERT(!m_next); |
| 124 // We'll end up pushing in LayoutView itself, so don't bother adding it. | 118 // We'll end up pushing in LayoutView itself, so don't bother adding it. |
| 125 if (root.isLayoutView()) | 119 if (root.isLayoutView()) |
| 126 return; | 120 return; |
| 127 | 121 |
| 128 root.view()->pushLayoutState(*this); | 122 root.view()->pushLayoutState(*this); |
| 129 | 123 |
| 130 LayoutObject* container = root.container(); | 124 LayoutObject* container = root.container(); |
| 131 FloatPoint absContentPoint = container->localToAbsolute(FloatPoint(), UseTra
nsforms); | 125 FloatPoint absContentPoint = container->localToAbsolute(FloatPoint(), UseTra
nsforms); |
| 132 m_layoutOffset = LayoutSize(absContentPoint.x(), absContentPoint.y()); | 126 m_layoutOffset = LayoutSize(absContentPoint.x(), absContentPoint.y()); |
| 133 } | 127 } |
| 134 | 128 |
| 135 LayoutState::~LayoutState() | 129 LayoutState::~LayoutState() |
| 136 { | 130 { |
| 137 if (m_layoutObject.view()->layoutState()) { | 131 if (m_layoutObject.view()->layoutState()) { |
| 138 ASSERT(m_layoutObject.view()->layoutState() == this); | 132 ASSERT(m_layoutObject.view()->layoutState() == this); |
| 139 m_layoutObject.view()->popLayoutState(); | 133 m_layoutObject.view()->popLayoutState(); |
| 140 } | 134 } |
| 141 } | 135 } |
| 142 | 136 |
| 143 void LayoutState::clearPaginationInformation() | 137 void LayoutState::clearPaginationInformation() |
| 144 { | 138 { |
| 145 m_pageLogicalHeight = m_next->m_pageLogicalHeight; | 139 m_pageLogicalHeight = m_next->m_pageLogicalHeight; |
| 146 m_pageOffset = m_next->m_pageOffset; | 140 m_pageOffset = m_next->m_pageOffset; |
| 147 m_columnInfo = m_next->m_columnInfo; | |
| 148 } | 141 } |
| 149 | 142 |
| 150 LayoutUnit LayoutState::pageLogicalOffset(const LayoutBox& child, const LayoutUn
it& childLogicalOffset) const | 143 LayoutUnit LayoutState::pageLogicalOffset(const LayoutBox& child, const LayoutUn
it& childLogicalOffset) const |
| 151 { | 144 { |
| 152 if (child.isHorizontalWritingMode()) | 145 if (child.isHorizontalWritingMode()) |
| 153 return m_layoutOffset.height() + childLogicalOffset - m_pageOffset.heigh
t(); | 146 return m_layoutOffset.height() + childLogicalOffset - m_pageOffset.heigh
t(); |
| 154 return m_layoutOffset.width() + childLogicalOffset - m_pageOffset.width(); | 147 return m_layoutOffset.width() + childLogicalOffset - m_pageOffset.width(); |
| 155 } | 148 } |
| 156 | 149 |
| 157 void LayoutState::addForcedColumnBreak(const LayoutBox& child, const LayoutUnit&
childLogicalOffset) | |
| 158 { | |
| 159 if (!m_columnInfo || m_columnInfo->columnHeight()) | |
| 160 return; | |
| 161 m_columnInfo->addForcedBreak(pageLogicalOffset(child, childLogicalOffset)); | |
| 162 } | |
| 163 | |
| 164 } // namespace blink | 150 } // namespace blink |
| OLD | NEW |