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 445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
456 LayoutMultiColumnSet* previousSet = | 456 LayoutMultiColumnSet* previousSet = |
457 columnSet->previousSiblingMultiColumnSet(); | 457 columnSet->previousSiblingMultiColumnSet(); |
458 if (!previousSet) | 458 if (!previousSet) |
459 break; | 459 break; |
460 columnSet = previousSet; | 460 columnSet = previousSet; |
461 } | 461 } |
462 } else { | 462 } else { |
463 DCHECK(!m_columnSetsInvalidated); | 463 DCHECK(!m_columnSetsInvalidated); |
464 if (m_multiColumnSetList.isEmpty()) | 464 if (m_multiColumnSetList.isEmpty()) |
465 return nullptr; | 465 return nullptr; |
466 if (offset < LayoutUnit()) | 466 if (offset < LayoutUnit()) { |
467 return m_multiColumnSetList.first(); | 467 columnSet = m_multiColumnSetList.first(); |
| 468 } else { |
| 469 MultiColumnSetSearchAdapter adapter(offset); |
| 470 m_multiColumnSetIntervalTree |
| 471 .allOverlapsWithAdapter<MultiColumnSetSearchAdapter>(adapter); |
468 | 472 |
469 MultiColumnSetSearchAdapter adapter(offset); | 473 // If no set was found, the offset is in the flow thread overflow. |
470 m_multiColumnSetIntervalTree | 474 if (!adapter.result() && !m_multiColumnSetList.isEmpty()) |
471 .allOverlapsWithAdapter<MultiColumnSetSearchAdapter>(adapter); | 475 columnSet = m_multiColumnSetList.last(); |
472 | 476 else |
473 // If no set was found, the offset is in the flow thread overflow. | 477 columnSet = adapter.result(); |
474 if (!adapter.result() && !m_multiColumnSetList.isEmpty()) | 478 } |
475 return m_multiColumnSetList.last(); | |
476 columnSet = adapter.result(); | |
477 } | 479 } |
478 if (pageBoundaryRule == AssociateWithFormerPage && columnSet && | 480 if (pageBoundaryRule == AssociateWithFormerPage && columnSet && |
479 offset == columnSet->logicalTopInFlowThread()) { | 481 offset == columnSet->logicalTopInFlowThread()) { |
480 // The column set that we found starts at the exact same flow thread offset | 482 // The column set that we found starts at the exact same flow thread offset |
481 // as we specified. Since we are to associate offsets at boundaries with the | 483 // as we specified. Since we are to associate offsets at boundaries with the |
482 // former fragmentainer, the fragmentainer we're looking for is in the | 484 // former fragmentainer, the fragmentainer we're looking for is in the |
483 // previous column set. | 485 // previous column set. |
484 if (LayoutMultiColumnSet* previousSet = | 486 if (LayoutMultiColumnSet* previousSet = |
485 columnSet->previousSiblingMultiColumnSet()) | 487 columnSet->previousSiblingMultiColumnSet()) |
486 return previousSet; | 488 columnSet = previousSet; |
| 489 } |
| 490 // Avoid returning zero-height column sets, if possible. We found a column set |
| 491 // based on a flow thread coordinate. If multiple column sets share that |
| 492 // coordinate (because we have zero-height column sets between column |
| 493 // spanners, for instance), look for one that has a height. |
| 494 for (LayoutMultiColumnSet* walker = columnSet; walker; |
| 495 walker = walker->nextSiblingMultiColumnSet()) { |
| 496 if (!walker->isPageLogicalHeightKnown()) |
| 497 continue; |
| 498 if (walker->logicalTopInFlowThread() == offset) |
| 499 return walker; |
| 500 break; |
487 } | 501 } |
488 return columnSet; | 502 return columnSet; |
489 } | 503 } |
490 | 504 |
491 void LayoutMultiColumnFlowThread::layoutColumns( | 505 void LayoutMultiColumnFlowThread::layoutColumns( |
492 SubtreeLayoutScope& layoutScope) { | 506 SubtreeLayoutScope& layoutScope) { |
493 // Since we ended up here, it means that the multicol container (our parent) | 507 // Since we ended up here, it means that the multicol container (our parent) |
494 // needed layout. Since contents of the multicol container are diverted to the | 508 // needed layout. Since contents of the multicol container are diverted to the |
495 // flow thread, the flow thread needs layout as well. | 509 // flow thread, the flow thread needs layout as well. |
496 layoutScope.setChildNeedsLayout(this); | 510 layoutScope.setChildNeedsLayout(this); |
(...skipping 858 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1355 const { | 1369 const { |
1356 return MultiColumnLayoutState(m_lastSetWorkedOn); | 1370 return MultiColumnLayoutState(m_lastSetWorkedOn); |
1357 } | 1371 } |
1358 | 1372 |
1359 void LayoutMultiColumnFlowThread::restoreMultiColumnLayoutState( | 1373 void LayoutMultiColumnFlowThread::restoreMultiColumnLayoutState( |
1360 const MultiColumnLayoutState& state) { | 1374 const MultiColumnLayoutState& state) { |
1361 m_lastSetWorkedOn = state.columnSet(); | 1375 m_lastSetWorkedOn = state.columnSet(); |
1362 } | 1376 } |
1363 | 1377 |
1364 } // namespace blink | 1378 } // namespace blink |
OLD | NEW |