| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Apple Inc. All rights reserved. | 2 * Copyright (C) 2012 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 16 matching lines...) Expand all Loading... |
| 27 #include "core/layout/LayoutMultiColumnSet.h" | 27 #include "core/layout/LayoutMultiColumnSet.h" |
| 28 | 28 |
| 29 #include "core/editing/PositionWithAffinity.h" | 29 #include "core/editing/PositionWithAffinity.h" |
| 30 #include "core/layout/LayoutMultiColumnFlowThread.h" | 30 #include "core/layout/LayoutMultiColumnFlowThread.h" |
| 31 #include "core/layout/MultiColumnFragmentainerGroup.h" | 31 #include "core/layout/MultiColumnFragmentainerGroup.h" |
| 32 #include "core/paint/MultiColumnSetPainter.h" | 32 #include "core/paint/MultiColumnSetPainter.h" |
| 33 | 33 |
| 34 namespace blink { | 34 namespace blink { |
| 35 | 35 |
| 36 LayoutMultiColumnSet::LayoutMultiColumnSet(LayoutFlowThread* flowThread) | 36 LayoutMultiColumnSet::LayoutMultiColumnSet(LayoutFlowThread* flowThread) |
| 37 : LayoutRegion(0, flowThread) | 37 : LayoutBlockFlow(0) |
| 38 , m_fragmentainerGroups(*this) | 38 , m_fragmentainerGroups(*this) |
| 39 , m_flowThread(flowThread) |
| 39 { | 40 { |
| 40 } | 41 } |
| 41 | 42 |
| 42 LayoutMultiColumnSet* LayoutMultiColumnSet::createAnonymous(LayoutFlowThread& fl
owThread, const ComputedStyle& parentStyle) | 43 LayoutMultiColumnSet* LayoutMultiColumnSet::createAnonymous(LayoutFlowThread& fl
owThread, const ComputedStyle& parentStyle) |
| 43 { | 44 { |
| 44 Document& document = flowThread.document(); | 45 Document& document = flowThread.document(); |
| 45 LayoutMultiColumnSet* layoutObject = new LayoutMultiColumnSet(&flowThread); | 46 LayoutMultiColumnSet* layoutObject = new LayoutMultiColumnSet(&flowThread); |
| 46 layoutObject->setDocumentForAnonymous(&document); | 47 layoutObject->setDocumentForAnonymous(&document); |
| 47 layoutObject->setStyle(ComputedStyle::createAnonymousStyleWithDisplay(parent
Style, BLOCK)); | 48 layoutObject->setStyle(ComputedStyle::createAnonymousStyleWithDisplay(parent
Style, BLOCK)); |
| 48 return layoutObject; | 49 return layoutObject; |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 LayoutUnit LayoutMultiColumnSet::logicalTopInFlowThread() const | 95 LayoutUnit LayoutMultiColumnSet::logicalTopInFlowThread() const |
| 95 { | 96 { |
| 96 return firstFragmentainerGroup().logicalTopInFlowThread(); | 97 return firstFragmentainerGroup().logicalTopInFlowThread(); |
| 97 } | 98 } |
| 98 | 99 |
| 99 LayoutUnit LayoutMultiColumnSet::logicalBottomInFlowThread() const | 100 LayoutUnit LayoutMultiColumnSet::logicalBottomInFlowThread() const |
| 100 { | 101 { |
| 101 return lastFragmentainerGroup().logicalBottomInFlowThread(); | 102 return lastFragmentainerGroup().logicalBottomInFlowThread(); |
| 102 } | 103 } |
| 103 | 104 |
| 105 LayoutRect LayoutMultiColumnSet::flowThreadPortionOverflowRect() const |
| 106 { |
| 107 return overflowRectForFlowThreadPortion(flowThreadPortionRect(), !previousSi
blingMultiColumnSet(), !nextSiblingMultiColumnSet()); |
| 108 } |
| 109 |
| 110 LayoutRect LayoutMultiColumnSet::overflowRectForFlowThreadPortion(const LayoutRe
ct& flowThreadPortionRect, bool isFirstPortion, bool isLastPortion) const |
| 111 { |
| 112 if (hasOverflowClip()) |
| 113 return flowThreadPortionRect; |
| 114 |
| 115 LayoutRect flowThreadOverflow = m_flowThread->visualOverflowRect(); |
| 116 |
| 117 // Only clip along the flow thread axis. |
| 118 LayoutRect clipRect; |
| 119 if (m_flowThread->isHorizontalWritingMode()) { |
| 120 LayoutUnit minY = isFirstPortion ? flowThreadOverflow.y() : flowThreadPo
rtionRect.y(); |
| 121 LayoutUnit maxY = isLastPortion ? std::max(flowThreadPortionRect.maxY(),
flowThreadOverflow.maxY()) : flowThreadPortionRect.maxY(); |
| 122 LayoutUnit minX = std::min(flowThreadPortionRect.x(), flowThreadOverflow
.x()); |
| 123 LayoutUnit maxX = std::max(flowThreadPortionRect.maxX(), flowThreadOverf
low.maxX()); |
| 124 clipRect = LayoutRect(minX, minY, maxX - minX, maxY - minY); |
| 125 } else { |
| 126 LayoutUnit minX = isFirstPortion ? flowThreadOverflow.x() : flowThreadPo
rtionRect.x(); |
| 127 LayoutUnit maxX = isLastPortion ? std::max(flowThreadPortionRect.maxX(),
flowThreadOverflow.maxX()) : flowThreadPortionRect.maxX(); |
| 128 LayoutUnit minY = std::min(flowThreadPortionRect.y(), (flowThreadOverflo
w.y())); |
| 129 LayoutUnit maxY = std::max(flowThreadPortionRect.y(), (flowThreadOverflo
w.maxY())); |
| 130 clipRect = LayoutRect(minX, minY, maxX - minX, maxY - minY); |
| 131 } |
| 132 |
| 133 return clipRect; |
| 134 } |
| 135 |
| 104 bool LayoutMultiColumnSet::heightIsAuto() const | 136 bool LayoutMultiColumnSet::heightIsAuto() const |
| 105 { | 137 { |
| 106 LayoutMultiColumnFlowThread* flowThread = multiColumnFlowThread(); | 138 LayoutMultiColumnFlowThread* flowThread = multiColumnFlowThread(); |
| 107 if (!flowThread->isLayoutPagedFlowThread()) { | 139 if (!flowThread->isLayoutPagedFlowThread()) { |
| 108 if (multiColumnBlockFlow()->style()->columnFill() == ColumnFillBalance) | 140 if (multiColumnBlockFlow()->style()->columnFill() == ColumnFillBalance) |
| 109 return true; | 141 return true; |
| 110 if (LayoutBox* next = nextSiblingBox()) { | 142 if (LayoutBox* next = nextSiblingBox()) { |
| 111 if (next->isLayoutMultiColumnSpannerPlaceholder()) { | 143 if (next->isLayoutMultiColumnSpannerPlaceholder()) { |
| 112 // If we're followed by a spanner, we need to balance. | 144 // If we're followed by a spanner, we need to balance. |
| 113 return true; | 145 return true; |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 } | 214 } |
| 183 | 215 |
| 184 void LayoutMultiColumnSet::expandToEncompassFlowThreadContentsIfNeeded() | 216 void LayoutMultiColumnSet::expandToEncompassFlowThreadContentsIfNeeded() |
| 185 { | 217 { |
| 186 ASSERT(multiColumnFlowThread()->lastMultiColumnSet() == this); | 218 ASSERT(multiColumnFlowThread()->lastMultiColumnSet() == this); |
| 187 // FIXME: this may result in the need for creating additional rows, since th
ere may not be | 219 // FIXME: this may result in the need for creating additional rows, since th
ere may not be |
| 188 // enough space remaining in the currently last row. | 220 // enough space remaining in the currently last row. |
| 189 m_fragmentainerGroups.last().expandToEncompassFlowThreadOverflow(); | 221 m_fragmentainerGroups.last().expandToEncompassFlowThreadOverflow(); |
| 190 } | 222 } |
| 191 | 223 |
| 224 void LayoutMultiColumnSet::computeIntrinsicLogicalWidths(LayoutUnit& minLogicalW
idth, LayoutUnit& maxLogicalWidth) const |
| 225 { |
| 226 minLogicalWidth = m_flowThread->minPreferredLogicalWidth(); |
| 227 maxLogicalWidth = m_flowThread->maxPreferredLogicalWidth(); |
| 228 } |
| 229 |
| 192 void LayoutMultiColumnSet::computeLogicalHeight(LayoutUnit, LayoutUnit logicalTo
p, LogicalExtentComputedValues& computedValues) const | 230 void LayoutMultiColumnSet::computeLogicalHeight(LayoutUnit, LayoutUnit logicalTo
p, LogicalExtentComputedValues& computedValues) const |
| 193 { | 231 { |
| 194 LayoutUnit logicalHeight; | 232 LayoutUnit logicalHeight; |
| 195 for (const auto& group : m_fragmentainerGroups) | 233 for (const auto& group : m_fragmentainerGroups) |
| 196 logicalHeight += group.logicalHeight(); | 234 logicalHeight += group.logicalHeight(); |
| 197 computedValues.m_extent = logicalHeight; | 235 computedValues.m_extent = logicalHeight; |
| 198 computedValues.m_position = logicalTop; | 236 computedValues.m_position = logicalTop; |
| 199 } | 237 } |
| 200 | 238 |
| 201 PositionWithAffinity LayoutMultiColumnSet::positionForPoint(const LayoutPoint& p
oint) | 239 PositionWithAffinity LayoutMultiColumnSet::positionForPoint(const LayoutPoint& p
oint) |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 rect.move(group.offsetFromColumnSet()); | 279 rect.move(group.offsetFromColumnSet()); |
| 242 overflowRect.unite(rect); | 280 overflowRect.unite(rect); |
| 243 } | 281 } |
| 244 addLayoutOverflow(overflowRect); | 282 addLayoutOverflow(overflowRect); |
| 245 if (!hasOverflowClip()) | 283 if (!hasOverflowClip()) |
| 246 addVisualOverflow(overflowRect); | 284 addVisualOverflow(overflowRect); |
| 247 } | 285 } |
| 248 | 286 |
| 249 void LayoutMultiColumnSet::insertedIntoTree() | 287 void LayoutMultiColumnSet::insertedIntoTree() |
| 250 { | 288 { |
| 251 LayoutRegion::insertedIntoTree(); | 289 LayoutBlockFlow::insertedIntoTree(); |
| 252 | 290 attachToFlowThread(); |
| 253 attachRegion(); | |
| 254 } | 291 } |
| 255 | 292 |
| 256 void LayoutMultiColumnSet::willBeRemovedFromTree() | 293 void LayoutMultiColumnSet::willBeRemovedFromTree() |
| 257 { | 294 { |
| 258 LayoutRegion::willBeRemovedFromTree(); | 295 LayoutBlockFlow::willBeRemovedFromTree(); |
| 259 | 296 detachFromFlowThread(); |
| 260 detachRegion(); | |
| 261 } | 297 } |
| 262 | 298 |
| 263 void LayoutMultiColumnSet::attachRegion() | 299 void LayoutMultiColumnSet::attachToFlowThread() |
| 264 { | 300 { |
| 265 if (documentBeingDestroyed()) | 301 if (documentBeingDestroyed()) |
| 266 return; | 302 return; |
| 267 | 303 |
| 268 // A region starts off invalid. | |
| 269 setIsValid(false); | |
| 270 | |
| 271 if (!m_flowThread) | 304 if (!m_flowThread) |
| 272 return; | 305 return; |
| 273 | 306 |
| 274 // Only after adding the region to the thread, the region is marked to be va
lid. | 307 m_flowThread->addColumnSetToThread(this); |
| 275 m_flowThread->addRegionToThread(this); | |
| 276 } | 308 } |
| 277 | 309 |
| 278 void LayoutMultiColumnSet::detachRegion() | 310 void LayoutMultiColumnSet::detachFromFlowThread() |
| 279 { | 311 { |
| 280 if (m_flowThread) { | 312 if (m_flowThread) { |
| 281 m_flowThread->removeRegionFromThread(this); | 313 m_flowThread->removeColumnSetFromThread(this); |
| 282 m_flowThread = 0; | 314 m_flowThread = 0; |
| 283 } | 315 } |
| 284 } | 316 } |
| 285 | 317 |
| 286 LayoutRect LayoutMultiColumnSet::flowThreadPortionRect() const | 318 LayoutRect LayoutMultiColumnSet::flowThreadPortionRect() const |
| 287 { | 319 { |
| 288 LayoutRect portionRect(LayoutUnit(), logicalTopInFlowThread(), pageLogicalWi
dth(), logicalHeightInFlowThread()); | 320 LayoutRect portionRect(LayoutUnit(), logicalTopInFlowThread(), pageLogicalWi
dth(), logicalHeightInFlowThread()); |
| 289 if (!isHorizontalWritingMode()) | 321 if (!isHorizontalWritingMode()) |
| 290 return portionRect.transposedRect(); | 322 return portionRect.transposedRect(); |
| 291 return portionRect; | 323 return portionRect; |
| 292 } | 324 } |
| 293 | 325 |
| 294 } | 326 } |
| OLD | NEW |