| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "core/layout/ColumnBalancer.h" | 5 #include "core/layout/ColumnBalancer.h" |
| 6 | 6 |
| 7 #include "core/layout/LayoutMultiColumnFlowThread.h" | 7 #include "core/layout/LayoutMultiColumnFlowThread.h" |
| 8 #include "core/layout/LayoutMultiColumnSet.h" | 8 #include "core/layout/LayoutMultiColumnSet.h" |
| 9 #include "core/layout/api/LineLayoutBlockFlow.h" | 9 #include "core/layout/api/LineLayoutBlockFlow.h" |
| 10 | 10 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 // block flow with inline children, there may be interesting floats to examine | 34 // block flow with inline children, there may be interesting floats to examine |
| 35 // here. | 35 // here. |
| 36 traverseChildren(box); | 36 traverseChildren(box); |
| 37 } | 37 } |
| 38 | 38 |
| 39 void ColumnBalancer::traverseLines(const LayoutBlockFlow& blockFlow) { | 39 void ColumnBalancer::traverseLines(const LayoutBlockFlow& blockFlow) { |
| 40 for (const RootInlineBox* line = blockFlow.firstRootBox(); line; | 40 for (const RootInlineBox* line = blockFlow.firstRootBox(); line; |
| 41 line = line->nextRootBox()) { | 41 line = line->nextRootBox()) { |
| 42 LayoutUnit lineTopInFlowThread = | 42 LayoutUnit lineTopInFlowThread = |
| 43 m_flowThreadOffset + line->lineTopWithLeading(); | 43 m_flowThreadOffset + line->lineTopWithLeading(); |
| 44 if (lineTopInFlowThread < logicalTopInFlowThread()) | 44 if (lineTopInFlowThread < logicalTopInFlowThread()) { |
| 45 continue; | 45 // If the line is fully about the flow thread portion range we're working |
| 46 // with, we can skip it. If its logical top is outside the range, but its |
| 47 // logical bottom protrudes into the range, we need to examine it. |
| 48 LayoutUnit lineBottom = line->lineBottomWithLeading(); |
| 49 if (m_flowThreadOffset + lineBottom <= logicalTopInFlowThread()) |
| 50 continue; |
| 51 } |
| 46 if (lineTopInFlowThread >= logicalBottomInFlowThread()) | 52 if (lineTopInFlowThread >= logicalBottomInFlowThread()) |
| 47 break; | 53 break; |
| 48 examineLine(*line); | 54 examineLine(*line); |
| 49 } | 55 } |
| 50 } | 56 } |
| 51 | 57 |
| 52 void ColumnBalancer::traverseChildren(const LayoutObject& object) { | 58 void ColumnBalancer::traverseChildren(const LayoutObject& object) { |
| 53 // The break-after value from the previous in-flow block-level object to be | 59 // The break-after value from the previous in-flow block-level object to be |
| 54 // joined with the break-before value of the next in-flow block-level sibling. | 60 // joined with the break-before value of the next in-flow block-level sibling. |
| 55 EBreak previousBreakAfterValue = BreakAuto; | 61 EBreak previousBreakAfterValue = BreakAuto; |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 for (unsigned i = 1; i < minimumLineCount && firstLine->prevRootBox(); i++) | 232 for (unsigned i = 1; i < minimumLineCount && firstLine->prevRootBox(); i++) |
| 227 firstLine = firstLine->prevRootBox(); | 233 firstLine = firstLine->prevRootBox(); |
| 228 return lastLine.lineBottomWithLeading() - firstLine->lineTopWithLeading(); | 234 return lastLine.lineBottomWithLeading() - firstLine->lineTopWithLeading(); |
| 229 } | 235 } |
| 230 | 236 |
| 231 void InitialColumnHeightFinder::examineLine(const RootInlineBox& line) { | 237 void InitialColumnHeightFinder::examineLine(const RootInlineBox& line) { |
| 232 LayoutUnit lineTop = line.lineTopWithLeading(); | 238 LayoutUnit lineTop = line.lineTopWithLeading(); |
| 233 LayoutUnit lineTopInFlowThread = flowThreadOffset() + lineTop; | 239 LayoutUnit lineTopInFlowThread = flowThreadOffset() + lineTop; |
| 234 LayoutUnit minimumLogialHeight = | 240 LayoutUnit minimumLogialHeight = |
| 235 columnLogicalHeightRequirementForLine(line.block().styleRef(), line); | 241 columnLogicalHeightRequirementForLine(line.block().styleRef(), line); |
| 242 if (lineTopInFlowThread < LayoutUnit()) |
| 243 minimumLogialHeight += lineTopInFlowThread; |
| 236 m_tallestUnbreakableLogicalHeight = | 244 m_tallestUnbreakableLogicalHeight = |
| 237 std::max(m_tallestUnbreakableLogicalHeight, minimumLogialHeight); | 245 std::max(m_tallestUnbreakableLogicalHeight, minimumLogialHeight); |
| 238 ASSERT( | 246 ASSERT( |
| 239 isFirstAfterBreak(lineTopInFlowThread) || !line.paginationStrut() || | 247 isFirstAfterBreak(lineTopInFlowThread) || !line.paginationStrut() || |
| 240 !isLogicalTopWithinBounds(lineTopInFlowThread - line.paginationStrut())); | 248 !isLogicalTopWithinBounds(lineTopInFlowThread - line.paginationStrut())); |
| 241 if (isFirstAfterBreak(lineTopInFlowThread) && | 249 if (isFirstAfterBreak(lineTopInFlowThread) && |
| 242 m_lastBreakSeen != lineTopInFlowThread) { | 250 m_lastBreakSeen != lineTopInFlowThread) { |
| 243 m_lastBreakSeen = lineTopInFlowThread; | 251 m_lastBreakSeen = lineTopInFlowThread; |
| 244 recordStrutBeforeOffset(lineTopInFlowThread, line.paginationStrut()); | 252 recordStrutBeforeOffset(lineTopInFlowThread, line.paginationStrut()); |
| 245 } | 253 } |
| (...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 482 if (group.columnLogicalTopForOffset(lineTopInFlowThread) != | 490 if (group.columnLogicalTopForOffset(lineTopInFlowThread) != |
| 483 group.columnLogicalTopForOffset(lineBottomWithOverflow)) { | 491 group.columnLogicalTopForOffset(lineBottomWithOverflow)) { |
| 484 LayoutUnit shortage = | 492 LayoutUnit shortage = |
| 485 lineBottomWithOverflow - | 493 lineBottomWithOverflow - |
| 486 group.columnLogicalTopForOffset(lineBottomWithOverflow); | 494 group.columnLogicalTopForOffset(lineBottomWithOverflow); |
| 487 recordSpaceShortage(shortage); | 495 recordSpaceShortage(shortage); |
| 488 } | 496 } |
| 489 } | 497 } |
| 490 | 498 |
| 491 } // namespace blink | 499 } // namespace blink |
| OLD | NEW |