| 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/MultiColumnFragmentainerGroup.h" | 5 #include "core/layout/MultiColumnFragmentainerGroup.h" |
| 6 | 6 |
| 7 #include "core/layout/ColumnBalancer.h" | 7 #include "core/layout/ColumnBalancer.h" |
| 8 #include "core/layout/FragmentationContext.h" | 8 #include "core/layout/FragmentationContext.h" |
| 9 #include "core/layout/LayoutMultiColumnSet.h" | 9 #include "core/layout/LayoutMultiColumnSet.h" |
| 10 | 10 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 LayoutUnit | 32 LayoutUnit |
| 33 MultiColumnFragmentainerGroup::BlockOffsetInEnclosingFragmentationContext() | 33 MultiColumnFragmentainerGroup::BlockOffsetInEnclosingFragmentationContext() |
| 34 const { | 34 const { |
| 35 return LogicalTop() + column_set_.LogicalTopFromMulticolContentEdge() + | 35 return LogicalTop() + column_set_.LogicalTopFromMulticolContentEdge() + |
| 36 column_set_.MultiColumnFlowThread() | 36 column_set_.MultiColumnFlowThread() |
| 37 ->BlockOffsetInEnclosingFragmentationContext(); | 37 ->BlockOffsetInEnclosingFragmentationContext(); |
| 38 } | 38 } |
| 39 | 39 |
| 40 LayoutUnit MultiColumnFragmentainerGroup::LogicalHeightInFlowThreadAt( | 40 LayoutUnit MultiColumnFragmentainerGroup::LogicalHeightInFlowThreadAt( |
| 41 unsigned column_index) const { | 41 unsigned column_index) const { |
| 42 if (!column_height_) | 42 LayoutUnit column_height = ColumnLogicalHeight(); |
| 43 if (!column_height) |
| 43 return LayoutUnit(); | 44 return LayoutUnit(); |
| 44 LayoutUnit logical_top = LogicalTopInFlowThreadAt(column_index); | 45 LayoutUnit logical_top = LogicalTopInFlowThreadAt(column_index); |
| 45 LayoutUnit logical_bottom = logical_top + column_height_; | 46 LayoutUnit logical_bottom = logical_top + column_height; |
| 46 if (logical_bottom > LogicalBottomInFlowThread()) { | 47 if (logical_bottom > LogicalBottomInFlowThread()) { |
| 47 DCHECK_EQ(column_index + 1, ActualColumnCount()); | 48 DCHECK_EQ(column_index + 1, ActualColumnCount()); |
| 48 logical_bottom = LogicalBottomInFlowThread(); | 49 logical_bottom = LogicalBottomInFlowThread(); |
| 49 } | 50 } |
| 50 return (logical_bottom - logical_top).ClampNegativeToZero(); | 51 return (logical_bottom - logical_top).ClampNegativeToZero(); |
| 51 } | 52 } |
| 52 | 53 |
| 53 void MultiColumnFragmentainerGroup::ResetColumnHeight() { | 54 void MultiColumnFragmentainerGroup::ResetColumnHeight() { |
| 54 max_column_height_ = CalculateMaxColumnHeight(); | 55 max_logical_height_ = CalculateMaxColumnHeight(); |
| 55 | 56 |
| 56 LayoutMultiColumnFlowThread* flow_thread = | 57 LayoutMultiColumnFlowThread* flow_thread = |
| 57 column_set_.MultiColumnFlowThread(); | 58 column_set_.MultiColumnFlowThread(); |
| 58 if (column_set_.HeightIsAuto()) { | 59 if (column_set_.HeightIsAuto()) { |
| 59 FragmentationContext* enclosing_fragmentation_context = | 60 FragmentationContext* enclosing_fragmentation_context = |
| 60 flow_thread->EnclosingFragmentationContext(); | 61 flow_thread->EnclosingFragmentationContext(); |
| 61 if (enclosing_fragmentation_context && | 62 if (enclosing_fragmentation_context && |
| 62 enclosing_fragmentation_context->IsFragmentainerLogicalHeightKnown()) { | 63 enclosing_fragmentation_context->IsFragmentainerLogicalHeightKnown()) { |
| 63 // Set an initial height, based on the fragmentainer height in the outer | 64 // Set an initial height, based on the fragmentainer height in the outer |
| 64 // fragmentation context, in order to tell how much content this | 65 // fragmentation context, in order to tell how much content this |
| 65 // MultiColumnFragmentainerGroup can hold, and when we need to append a | 66 // MultiColumnFragmentainerGroup can hold, and when we need to append a |
| 66 // new one. | 67 // new one. |
| 67 column_height_ = max_column_height_; | 68 logical_height_ = max_logical_height_; |
| 68 return; | 69 return; |
| 69 } | 70 } |
| 70 } | 71 } |
| 71 // If the multicol container has a definite height, use it as the column | 72 // If the multicol container has a definite height, use it as the column |
| 72 // height. This even applies when we are to balance the columns. We'll still | 73 // height. This even applies when we are to balance the columns. We'll still |
| 73 // use the definite height as an initial height, and lay out once at that | 74 // use the definite height as an initial height, and lay out once at that |
| 74 // column height. If it turns out that the content needs less than this | 75 // column height. If it turns out that the content needs less than this |
| 75 // height, we have to balance and shrink the height and lay out the columns | 76 // height, we have to balance and shrink the height and lay out the columns |
| 76 // over again. | 77 // over again. |
| 77 if (LayoutUnit logical_height = flow_thread->ColumnHeightAvailable()) { | 78 if (LayoutUnit logical_height = flow_thread->ColumnHeightAvailable()) { |
| 78 SetAndConstrainColumnHeight(HeightAdjustedForRowOffset(logical_height)); | 79 SetAndConstrainColumnHeight(HeightAdjustedForRowOffset(logical_height)); |
| 79 } else { | 80 } else { |
| 80 column_height_ = LayoutUnit(); | 81 logical_height_ = LayoutUnit(); |
| 81 } | 82 } |
| 82 } | 83 } |
| 83 | 84 |
| 84 bool MultiColumnFragmentainerGroup::RecalculateColumnHeight( | 85 bool MultiColumnFragmentainerGroup::RecalculateColumnHeight( |
| 85 LayoutMultiColumnSet& column_set) { | 86 LayoutMultiColumnSet& column_set) { |
| 86 LayoutUnit old_column_height = column_height_; | 87 LayoutUnit old_column_height = logical_height_; |
| 87 | 88 |
| 88 max_column_height_ = CalculateMaxColumnHeight(); | 89 max_logical_height_ = CalculateMaxColumnHeight(); |
| 89 | 90 |
| 90 // Only the last row may have auto height, and thus be balanced. There are no | 91 // Only the last row may have auto height, and thus be balanced. There are no |
| 91 // good reasons to balance the preceding rows, and that could potentially lead | 92 // good reasons to balance the preceding rows, and that could potentially lead |
| 92 // to an insane number of layout passes as well. | 93 // to an insane number of layout passes as well. |
| 93 if (IsLastGroup() && column_set.HeightIsAuto()) { | 94 if (IsLastGroup() && column_set.HeightIsAuto()) { |
| 94 LayoutUnit new_column_height; | 95 LayoutUnit new_column_height; |
| 95 if (!column_set.IsInitialHeightCalculated()) { | 96 if (!column_set.IsInitialHeightCalculated()) { |
| 96 // Initial balancing: Start with the lowest imaginable column height. Also | 97 // Initial balancing: Start with the lowest imaginable column height. Also |
| 97 // calculate the height of the tallest piece of unbreakable content. | 98 // calculate the height of the tallest piece of unbreakable content. |
| 98 // Columns should never get any shorter than that (unless constrained by | 99 // Columns should never get any shorter than that (unless constrained by |
| (...skipping 10 matching lines...) Expand all Loading... |
| 109 // Rebalancing: After having laid out again, we'll need to rebalance if | 110 // Rebalancing: After having laid out again, we'll need to rebalance if |
| 110 // the height wasn't enough and we're allowed to stretch it, and then | 111 // the height wasn't enough and we're allowed to stretch it, and then |
| 111 // re-lay out. There are further details on the column balancing | 112 // re-lay out. There are further details on the column balancing |
| 112 // machinery in ColumnBalancer and its derivates. | 113 // machinery in ColumnBalancer and its derivates. |
| 113 new_column_height = RebalanceColumnHeightIfNeeded(); | 114 new_column_height = RebalanceColumnHeightIfNeeded(); |
| 114 } | 115 } |
| 115 SetAndConstrainColumnHeight(new_column_height); | 116 SetAndConstrainColumnHeight(new_column_height); |
| 116 } else { | 117 } else { |
| 117 // The position of the column set may have changed, in which case height | 118 // The position of the column set may have changed, in which case height |
| 118 // available for columns may have changed as well. | 119 // available for columns may have changed as well. |
| 119 SetAndConstrainColumnHeight(column_height_); | 120 SetAndConstrainColumnHeight(logical_height_); |
| 120 } | 121 } |
| 121 | 122 |
| 122 if (column_height_ == old_column_height) | 123 if (logical_height_ == old_column_height) |
| 123 return false; // No change. We're done. | 124 return false; // No change. We're done. |
| 124 | 125 |
| 125 return true; // Need another pass. | 126 return true; // Need another pass. |
| 126 } | 127 } |
| 127 | 128 |
| 128 LayoutSize MultiColumnFragmentainerGroup::FlowThreadTranslationAtOffset( | 129 LayoutSize MultiColumnFragmentainerGroup::FlowThreadTranslationAtOffset( |
| 129 LayoutUnit offset_in_flow_thread, | 130 LayoutUnit offset_in_flow_thread, |
| 130 LayoutBox::PageBoundaryRule rule, | 131 LayoutBox::PageBoundaryRule rule, |
| 131 CoordinateSpaceConversion mode) const { | 132 CoordinateSpaceConversion mode) const { |
| 132 LayoutMultiColumnFlowThread* flow_thread = | 133 LayoutMultiColumnFlowThread* flow_thread = |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 LayoutRect column_rect = ColumnRectAt(column_index); | 205 LayoutRect column_rect = ColumnRectAt(column_index); |
| 205 LayoutPoint local_point(visual_point); | 206 LayoutPoint local_point(visual_point); |
| 206 local_point.MoveBy(-column_rect.Location()); | 207 local_point.MoveBy(-column_rect.Location()); |
| 207 if (!column_set_.IsHorizontalWritingMode()) { | 208 if (!column_set_.IsHorizontalWritingMode()) { |
| 208 if (snap == kSnapToColumn) { | 209 if (snap == kSnapToColumn) { |
| 209 LayoutUnit column_start = column_set_.Style()->IsLeftToRightDirection() | 210 LayoutUnit column_start = column_set_.Style()->IsLeftToRightDirection() |
| 210 ? LayoutUnit() | 211 ? LayoutUnit() |
| 211 : column_rect.Height(); | 212 : column_rect.Height(); |
| 212 if (local_point.X() < 0) | 213 if (local_point.X() < 0) |
| 213 local_point = LayoutPoint(LayoutUnit(), column_start); | 214 local_point = LayoutPoint(LayoutUnit(), column_start); |
| 214 else if (local_point.X() > LogicalHeight()) | 215 else if (local_point.X() > ColumnLogicalHeight()) |
| 215 local_point = LayoutPoint(LogicalHeight(), column_start); | 216 local_point = LayoutPoint(ColumnLogicalHeight(), column_start); |
| 216 } | 217 } |
| 217 return LayoutPoint(local_point.X() + LogicalTopInFlowThreadAt(column_index), | 218 return LayoutPoint(local_point.X() + LogicalTopInFlowThreadAt(column_index), |
| 218 local_point.Y()); | 219 local_point.Y()); |
| 219 } | 220 } |
| 220 if (snap == kSnapToColumn) { | 221 if (snap == kSnapToColumn) { |
| 221 LayoutUnit column_start = column_set_.Style()->IsLeftToRightDirection() | 222 LayoutUnit column_start = column_set_.Style()->IsLeftToRightDirection() |
| 222 ? LayoutUnit() | 223 ? LayoutUnit() |
| 223 : column_rect.Width(); | 224 : column_rect.Width(); |
| 224 if (local_point.Y() < 0) | 225 if (local_point.Y() < 0) |
| 225 local_point = LayoutPoint(column_start, LayoutUnit()); | 226 local_point = LayoutPoint(column_start, LayoutUnit()); |
| 226 else if (local_point.Y() > LogicalHeight()) | 227 else if (local_point.Y() > ColumnLogicalHeight()) |
| 227 local_point = LayoutPoint(column_start, LogicalHeight()); | 228 local_point = LayoutPoint(column_start, ColumnLogicalHeight()); |
| 228 } | 229 } |
| 229 return LayoutPoint(local_point.X(), | 230 return LayoutPoint(local_point.X(), |
| 230 local_point.Y() + LogicalTopInFlowThreadAt(column_index)); | 231 local_point.Y() + LogicalTopInFlowThreadAt(column_index)); |
| 231 } | 232 } |
| 232 | 233 |
| 233 LayoutRect MultiColumnFragmentainerGroup::FragmentsBoundingBox( | 234 LayoutRect MultiColumnFragmentainerGroup::FragmentsBoundingBox( |
| 234 const LayoutRect& bounding_box_in_flow_thread) const { | 235 const LayoutRect& bounding_box_in_flow_thread) const { |
| 235 // Find the start and end column intersected by the bounding box. | 236 // Find the start and end column intersected by the bounding box. |
| 236 LayoutRect flipped_bounding_box_in_flow_thread(bounding_box_in_flow_thread); | 237 LayoutRect flipped_bounding_box_in_flow_thread(bounding_box_in_flow_thread); |
| 237 LayoutFlowThread* flow_thread = column_set_.FlowThread(); | 238 LayoutFlowThread* flow_thread = column_set_.FlowThread(); |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 287 if (column_count > 1) | 288 if (column_count > 1) |
| 288 overflow_rect.UniteEvenIfEmpty(ColumnRectAt(column_count - 1)); | 289 overflow_rect.UniteEvenIfEmpty(ColumnRectAt(column_count - 1)); |
| 289 } | 290 } |
| 290 return overflow_rect; | 291 return overflow_rect; |
| 291 } | 292 } |
| 292 | 293 |
| 293 unsigned MultiColumnFragmentainerGroup::ActualColumnCount() const { | 294 unsigned MultiColumnFragmentainerGroup::ActualColumnCount() const { |
| 294 // We must always return a value of 1 or greater. Column count = 0 is a | 295 // We must always return a value of 1 or greater. Column count = 0 is a |
| 295 // meaningless situation, and will confuse and cause problems in other parts | 296 // meaningless situation, and will confuse and cause problems in other parts |
| 296 // of the code. | 297 // of the code. |
| 297 if (!column_height_) | 298 LayoutUnit column_height = ColumnLogicalHeight(); |
| 299 if (!column_height) |
| 298 return 1; | 300 return 1; |
| 299 | 301 |
| 300 // Our flow thread portion determines our column count. We have as many | 302 // Our flow thread portion determines our column count. We have as many |
| 301 // columns as needed to fit all the content. | 303 // columns as needed to fit all the content. |
| 302 LayoutUnit flow_thread_portion_height = LogicalHeightInFlowThread(); | 304 LayoutUnit flow_thread_portion_height = LogicalHeightInFlowThread(); |
| 303 if (!flow_thread_portion_height) | 305 if (!flow_thread_portion_height) |
| 304 return 1; | 306 return 1; |
| 305 | 307 |
| 306 unsigned count = (flow_thread_portion_height / column_height_).Floor(); | 308 unsigned count = (flow_thread_portion_height / column_height).Floor(); |
| 307 // flowThreadPortionHeight may be saturated, so detect the remainder manually. | 309 // flowThreadPortionHeight may be saturated, so detect the remainder manually. |
| 308 if (count * column_height_ < flow_thread_portion_height) | 310 if (count * column_height < flow_thread_portion_height) |
| 309 count++; | 311 count++; |
| 310 DCHECK_GE(count, 1u); | 312 DCHECK_GE(count, 1u); |
| 311 return count; | 313 return count; |
| 312 } | 314 } |
| 313 | 315 |
| 314 LayoutUnit MultiColumnFragmentainerGroup::HeightAdjustedForRowOffset( | 316 LayoutUnit MultiColumnFragmentainerGroup::HeightAdjustedForRowOffset( |
| 315 LayoutUnit height) const { | 317 LayoutUnit height) const { |
| 316 // Let's avoid zero height, as that would cause an infinite amount of columns | 318 // Let's avoid zero height, as that would cause an infinite amount of columns |
| 317 // to be created. | 319 // to be created. |
| 318 return std::max( | 320 return std::max( |
| (...skipping 16 matching lines...) Expand all Loading... |
| 335 BlockOffsetInEnclosingFragmentationContext()); | 337 BlockOffsetInEnclosingFragmentationContext()); |
| 336 if (max_height > remaining_outer_logical_height) | 338 if (max_height > remaining_outer_logical_height) |
| 337 max_height = remaining_outer_logical_height; | 339 max_height = remaining_outer_logical_height; |
| 338 } | 340 } |
| 339 } | 341 } |
| 340 return max_height; | 342 return max_height; |
| 341 } | 343 } |
| 342 | 344 |
| 343 void MultiColumnFragmentainerGroup::SetAndConstrainColumnHeight( | 345 void MultiColumnFragmentainerGroup::SetAndConstrainColumnHeight( |
| 344 LayoutUnit new_height) { | 346 LayoutUnit new_height) { |
| 345 column_height_ = new_height; | 347 logical_height_ = new_height; |
| 346 if (column_height_ > max_column_height_) | 348 if (logical_height_ > max_logical_height_) |
| 347 column_height_ = max_column_height_; | 349 logical_height_ = max_logical_height_; |
| 348 } | 350 } |
| 349 | 351 |
| 350 LayoutUnit MultiColumnFragmentainerGroup::RebalanceColumnHeightIfNeeded() | 352 LayoutUnit MultiColumnFragmentainerGroup::RebalanceColumnHeightIfNeeded() |
| 351 const { | 353 const { |
| 352 if (ActualColumnCount() <= column_set_.UsedColumnCount()) { | 354 if (ActualColumnCount() <= column_set_.UsedColumnCount()) { |
| 353 // With the current column height, the content fits without creating | 355 // With the current column height, the content fits without creating |
| 354 // overflowing columns. We're done. | 356 // overflowing columns. We're done. |
| 355 return column_height_; | 357 return logical_height_; |
| 356 } | 358 } |
| 357 | 359 |
| 358 if (column_height_ >= max_column_height_) { | 360 if (logical_height_ >= max_logical_height_) { |
| 359 // We cannot stretch any further. We'll just have to live with the | 361 // We cannot stretch any further. We'll just have to live with the |
| 360 // overflowing columns. This typically happens if the max column height is | 362 // overflowing columns. This typically happens if the max column height is |
| 361 // less than the height of the tallest piece of unbreakable content (e.g. | 363 // less than the height of the tallest piece of unbreakable content (e.g. |
| 362 // lines). | 364 // lines). |
| 363 return column_height_; | 365 return logical_height_; |
| 364 } | 366 } |
| 365 | 367 |
| 366 MinimumSpaceShortageFinder shortage_finder( | 368 MinimumSpaceShortageFinder shortage_finder( |
| 367 ColumnSet(), LogicalTopInFlowThread(), LogicalBottomInFlowThread()); | 369 ColumnSet(), LogicalTopInFlowThread(), LogicalBottomInFlowThread()); |
| 368 | 370 |
| 369 if (shortage_finder.ForcedBreaksCount() + 1 >= | 371 if (shortage_finder.ForcedBreaksCount() + 1 >= |
| 370 column_set_.UsedColumnCount()) { | 372 column_set_.UsedColumnCount()) { |
| 371 // Too many forced breaks to allow any implicit breaks. Initial balancing | 373 // Too many forced breaks to allow any implicit breaks. Initial balancing |
| 372 // should already have set a good height. There's nothing more we should do. | 374 // should already have set a good height. There's nothing more we should do. |
| 373 return column_height_; | 375 return logical_height_; |
| 374 } | 376 } |
| 375 | 377 |
| 376 // If the initial guessed column height wasn't enough, stretch it now. Stretch | 378 // If the initial guessed column height wasn't enough, stretch it now. Stretch |
| 377 // by the lowest amount of space. | 379 // by the lowest amount of space. |
| 378 LayoutUnit min_space_shortage = shortage_finder.MinimumSpaceShortage(); | 380 LayoutUnit min_space_shortage = shortage_finder.MinimumSpaceShortage(); |
| 379 | 381 |
| 380 DCHECK_GT(min_space_shortage, 0); // We should never _shrink_ the height! | 382 DCHECK_GT(min_space_shortage, 0); // We should never _shrink_ the height! |
| 381 DCHECK_NE(min_space_shortage, | 383 DCHECK_NE(min_space_shortage, |
| 382 LayoutUnit::Max()); // If this happens, we probably have a bug. | 384 LayoutUnit::Max()); // If this happens, we probably have a bug. |
| 383 if (min_space_shortage == LayoutUnit::Max()) | 385 if (min_space_shortage == LayoutUnit::Max()) |
| 384 return column_height_; // So bail out rather than looping infinitely. | 386 return logical_height_; // So bail out rather than looping infinitely. |
| 385 | 387 |
| 386 return column_height_ + min_space_shortage; | 388 return logical_height_ + min_space_shortage; |
| 387 } | 389 } |
| 388 | 390 |
| 389 LayoutRect MultiColumnFragmentainerGroup::ColumnRectAt( | 391 LayoutRect MultiColumnFragmentainerGroup::ColumnRectAt( |
| 390 unsigned column_index) const { | 392 unsigned column_index) const { |
| 391 LayoutUnit column_logical_width = column_set_.PageLogicalWidth(); | 393 LayoutUnit column_logical_width = column_set_.PageLogicalWidth(); |
| 392 LayoutUnit column_logical_height = LogicalHeightInFlowThreadAt(column_index); | 394 LayoutUnit column_logical_height = LogicalHeightInFlowThreadAt(column_index); |
| 393 LayoutUnit column_logical_top; | 395 LayoutUnit column_logical_top; |
| 394 LayoutUnit column_logical_left; | 396 LayoutUnit column_logical_left; |
| 395 LayoutUnit column_gap = column_set_.ColumnGap(); | 397 LayoutUnit column_gap = column_set_.ColumnGap(); |
| 396 | 398 |
| 397 if (column_set_.MultiColumnFlowThread()->ProgressionIsInline()) { | 399 if (column_set_.MultiColumnFlowThread()->ProgressionIsInline()) { |
| 398 if (column_set_.Style()->IsLeftToRightDirection()) | 400 if (column_set_.Style()->IsLeftToRightDirection()) |
| 399 column_logical_left += column_index * (column_logical_width + column_gap); | 401 column_logical_left += column_index * (column_logical_width + column_gap); |
| 400 else | 402 else |
| 401 column_logical_left += column_set_.ContentLogicalWidth() - | 403 column_logical_left += column_set_.ContentLogicalWidth() - |
| 402 column_logical_width - | 404 column_logical_width - |
| 403 column_index * (column_logical_width + column_gap); | 405 column_index * (column_logical_width + column_gap); |
| 404 } else { | 406 } else { |
| 405 column_logical_top += column_index * (column_height_ + column_gap); | 407 column_logical_top += column_index * (ColumnLogicalHeight() + column_gap); |
| 406 } | 408 } |
| 407 | 409 |
| 408 LayoutRect column_rect(column_logical_left, column_logical_top, | 410 LayoutRect column_rect(column_logical_left, column_logical_top, |
| 409 column_logical_width, column_logical_height); | 411 column_logical_width, column_logical_height); |
| 410 if (!column_set_.IsHorizontalWritingMode()) | 412 if (!column_set_.IsHorizontalWritingMode()) |
| 411 return column_rect.TransposedRect(); | 413 return column_rect.TransposedRect(); |
| 412 return column_rect; | 414 return column_rect; |
| 413 } | 415 } |
| 414 | 416 |
| 415 LayoutRect MultiColumnFragmentainerGroup::FlowThreadPortionRectAt( | 417 LayoutRect MultiColumnFragmentainerGroup::FlowThreadPortionRectAt( |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 491 return overflow_rect; | 493 return overflow_rect; |
| 492 } | 494 } |
| 493 | 495 |
| 494 unsigned MultiColumnFragmentainerGroup::ColumnIndexAtOffset( | 496 unsigned MultiColumnFragmentainerGroup::ColumnIndexAtOffset( |
| 495 LayoutUnit offset_in_flow_thread, | 497 LayoutUnit offset_in_flow_thread, |
| 496 LayoutBox::PageBoundaryRule page_boundary_rule) const { | 498 LayoutBox::PageBoundaryRule page_boundary_rule) const { |
| 497 // Handle the offset being out of range. | 499 // Handle the offset being out of range. |
| 498 if (offset_in_flow_thread < logical_top_in_flow_thread_) | 500 if (offset_in_flow_thread < logical_top_in_flow_thread_) |
| 499 return 0; | 501 return 0; |
| 500 | 502 |
| 501 if (!column_height_) | 503 LayoutUnit column_height = ColumnLogicalHeight(); |
| 504 if (!column_height) |
| 502 return 0; | 505 return 0; |
| 503 unsigned column_index = | 506 unsigned column_index = |
| 504 ((offset_in_flow_thread - logical_top_in_flow_thread_) / column_height_) | 507 ((offset_in_flow_thread - logical_top_in_flow_thread_) / column_height) |
| 505 .Floor(); | 508 .Floor(); |
| 506 if (page_boundary_rule == LayoutBox::kAssociateWithFormerPage && | 509 if (page_boundary_rule == LayoutBox::kAssociateWithFormerPage && |
| 507 column_index > 0 && | 510 column_index > 0 && |
| 508 LogicalTopInFlowThreadAt(column_index) == offset_in_flow_thread) { | 511 LogicalTopInFlowThreadAt(column_index) == offset_in_flow_thread) { |
| 509 // We are exactly at a column boundary, and we've been told to associate | 512 // We are exactly at a column boundary, and we've been told to associate |
| 510 // offsets at column boundaries with the former column, not the latter. | 513 // offsets at column boundaries with the former column, not the latter. |
| 511 column_index--; | 514 column_index--; |
| 512 } | 515 } |
| 513 return column_index; | 516 return column_index; |
| 514 } | 517 } |
| 515 | 518 |
| 516 unsigned MultiColumnFragmentainerGroup::ColumnIndexAtVisualPoint( | 519 unsigned MultiColumnFragmentainerGroup::ColumnIndexAtVisualPoint( |
| 517 const LayoutPoint& visual_point) const { | 520 const LayoutPoint& visual_point) const { |
| 518 bool is_column_progression_inline = | 521 bool is_column_progression_inline = |
| 519 column_set_.MultiColumnFlowThread()->ProgressionIsInline(); | 522 column_set_.MultiColumnFlowThread()->ProgressionIsInline(); |
| 520 bool is_horizontal_writing_mode = column_set_.IsHorizontalWritingMode(); | 523 bool is_horizontal_writing_mode = column_set_.IsHorizontalWritingMode(); |
| 521 LayoutUnit column_length_in_column_progression_direction = | 524 LayoutUnit column_length_in_column_progression_direction = |
| 522 is_column_progression_inline ? column_set_.PageLogicalWidth() | 525 is_column_progression_inline ? column_set_.PageLogicalWidth() |
| 523 : LogicalHeight(); | 526 : ColumnLogicalHeight(); |
| 524 LayoutUnit offset_in_column_progression_direction = | 527 LayoutUnit offset_in_column_progression_direction = |
| 525 is_horizontal_writing_mode == is_column_progression_inline | 528 is_horizontal_writing_mode == is_column_progression_inline |
| 526 ? visual_point.X() | 529 ? visual_point.X() |
| 527 : visual_point.Y(); | 530 : visual_point.Y(); |
| 528 if (!column_set_.Style()->IsLeftToRightDirection() && | 531 if (!column_set_.Style()->IsLeftToRightDirection() && |
| 529 is_column_progression_inline) | 532 is_column_progression_inline) |
| 530 offset_in_column_progression_direction = | 533 offset_in_column_progression_direction = |
| 531 column_set_.LogicalWidth() - offset_in_column_progression_direction; | 534 column_set_.LogicalWidth() - offset_in_column_progression_direction; |
| 532 LayoutUnit column_gap = column_set_.ColumnGap(); | 535 LayoutUnit column_gap = column_set_.ColumnGap(); |
| 533 if (column_length_in_column_progression_direction + column_gap <= 0) | 536 if (column_length_in_column_progression_direction + column_gap <= 0) |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 612 MultiColumnFragmentainerGroupList::AddExtraGroup() { | 615 MultiColumnFragmentainerGroupList::AddExtraGroup() { |
| 613 Append(MultiColumnFragmentainerGroup(column_set_)); | 616 Append(MultiColumnFragmentainerGroup(column_set_)); |
| 614 return Last(); | 617 return Last(); |
| 615 } | 618 } |
| 616 | 619 |
| 617 void MultiColumnFragmentainerGroupList::DeleteExtraGroups() { | 620 void MultiColumnFragmentainerGroupList::DeleteExtraGroups() { |
| 618 Shrink(1); | 621 Shrink(1); |
| 619 } | 622 } |
| 620 | 623 |
| 621 } // namespace blink | 624 } // namespace blink |
| OLD | NEW |