| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc. All rights reserved. | 2 * Copyright (C) 2004, 2005, 2006 Apple Computer, 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 464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 475 m_affinity = TextAffinity::Downstream; | 475 m_affinity = TextAffinity::Downstream; |
| 476 } | 476 } |
| 477 | 477 |
| 478 template <typename Strategy> | 478 template <typename Strategy> |
| 479 void VisibleSelectionTemplate<Strategy>::validate(TextGranularity granularity) { | 479 void VisibleSelectionTemplate<Strategy>::validate(TextGranularity granularity) { |
| 480 DCHECK(!needsLayoutTreeUpdate(m_base)); | 480 DCHECK(!needsLayoutTreeUpdate(m_base)); |
| 481 DCHECK(!needsLayoutTreeUpdate(m_extent)); | 481 DCHECK(!needsLayoutTreeUpdate(m_extent)); |
| 482 // TODO(xiaochengh): Add a DocumentLifecycle::DisallowTransitionScope here. | 482 // TODO(xiaochengh): Add a DocumentLifecycle::DisallowTransitionScope here. |
| 483 | 483 |
| 484 m_granularity = granularity; | 484 m_granularity = granularity; |
| 485 if (m_granularity != WordGranularity) | 485 m_hasTrailingWhitespace = false; |
| 486 m_hasTrailingWhitespace = false; | |
| 487 setBaseAndExtentToDeepEquivalents(); | 486 setBaseAndExtentToDeepEquivalents(); |
| 488 if (m_base.isNull() || m_extent.isNull()) { | 487 if (m_base.isNull() || m_extent.isNull()) { |
| 489 m_base = m_extent = m_start = m_end = PositionTemplate<Strategy>(); | 488 m_base = m_extent = m_start = m_end = PositionTemplate<Strategy>(); |
| 490 updateSelectionType(); | 489 updateSelectionType(); |
| 491 return; | 490 return; |
| 492 } | 491 } |
| 493 | 492 |
| 494 const PositionTemplate<Strategy> start = m_baseIsFirst ? m_base : m_extent; | 493 const PositionTemplate<Strategy> start = m_baseIsFirst ? m_base : m_extent; |
| 495 const PositionTemplate<Strategy> newStart = computeStartRespectingGranularity( | 494 const PositionTemplate<Strategy> newStart = computeStartRespectingGranularity( |
| 496 PositionWithAffinityTemplate<Strategy>(start, m_affinity), granularity); | 495 PositionWithAffinityTemplate<Strategy>(start, m_affinity), granularity); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 512 // it is useful to make to make the selection "canonical" (if only for | 511 // it is useful to make to make the selection "canonical" (if only for |
| 513 // purposes of comparing selections). This is an ideal point of the code | 512 // purposes of comparing selections). This is an ideal point of the code |
| 514 // to do this operation, since all selection changes that result in a | 513 // to do this operation, since all selection changes that result in a |
| 515 // RANGE come through here before anyone uses it. | 514 // RANGE come through here before anyone uses it. |
| 516 // TODO(yosin) Canonicalizing is good, but haven't we already done it | 515 // TODO(yosin) Canonicalizing is good, but haven't we already done it |
| 517 // (when we set these two positions to |VisiblePosition| | 516 // (when we set these two positions to |VisiblePosition| |
| 518 // |deepEquivalent()|s above)? | 517 // |deepEquivalent()|s above)? |
| 519 m_start = mostForwardCaretPosition(m_start); | 518 m_start = mostForwardCaretPosition(m_start); |
| 520 m_end = mostBackwardCaretPosition(m_end); | 519 m_end = mostBackwardCaretPosition(m_end); |
| 521 } | 520 } |
| 522 if (!m_hasTrailingWhitespace) | |
| 523 return; | |
| 524 appendTrailingWhitespace(); | |
| 525 } | 521 } |
| 526 | 522 |
| 527 template <typename Strategy> | 523 template <typename Strategy> |
| 528 bool VisibleSelectionTemplate<Strategy>::isValidFor( | 524 bool VisibleSelectionTemplate<Strategy>::isValidFor( |
| 529 const Document& document) const { | 525 const Document& document) const { |
| 530 if (isNone()) | 526 if (isNone()) |
| 531 return true; | 527 return true; |
| 532 | 528 |
| 533 return m_base.document() == &document && !m_base.isOrphan() && | 529 return m_base.document() == &document && !m_base.isOrphan() && |
| 534 !m_extent.isOrphan() && !m_start.isOrphan() && !m_end.isOrphan(); | 530 !m_extent.isOrphan() && !m_start.isOrphan() && !m_end.isOrphan(); |
| (...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 857 | 853 |
| 858 void showTree(const blink::VisibleSelectionInFlatTree& sel) { | 854 void showTree(const blink::VisibleSelectionInFlatTree& sel) { |
| 859 sel.showTreeForThis(); | 855 sel.showTreeForThis(); |
| 860 } | 856 } |
| 861 | 857 |
| 862 void showTree(const blink::VisibleSelectionInFlatTree* sel) { | 858 void showTree(const blink::VisibleSelectionInFlatTree* sel) { |
| 863 if (sel) | 859 if (sel) |
| 864 sel->showTreeForThis(); | 860 sel->showTreeForThis(); |
| 865 } | 861 } |
| 866 #endif | 862 #endif |
| OLD | NEW |