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