| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2004, 2008, 2009, 2010 Apple Inc. All rights reserved. | 2 * Copyright (C) 2004, 2008, 2009, 2010 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 563 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 574 } | 574 } |
| 575 | 575 |
| 576 static bool isBoundary(TextGranularity granularity) | 576 static bool isBoundary(TextGranularity granularity) |
| 577 { | 577 { |
| 578 return granularity == LineBoundary || granularity == ParagraphBoundary || gr
anularity == DocumentBoundary; | 578 return granularity == LineBoundary || granularity == ParagraphBoundary || gr
anularity == DocumentBoundary; |
| 579 } | 579 } |
| 580 | 580 |
| 581 bool SelectionEditor::modify(EAlteration alter, SelectionDirection direction, Te
xtGranularity granularity, EUserTriggered userTriggered) | 581 bool SelectionEditor::modify(EAlteration alter, SelectionDirection direction, Te
xtGranularity granularity, EUserTriggered userTriggered) |
| 582 { | 582 { |
| 583 if (userTriggered == UserTriggered) { | 583 if (userTriggered == UserTriggered) { |
| 584 OwnPtrWillBeRawPtr<FrameSelection> trialFrameSelection = FrameSelection:
:create(); | 584 RawPtr<FrameSelection> trialFrameSelection = FrameSelection::create(); |
| 585 trialFrameSelection->setSelection(m_selection); | 585 trialFrameSelection->setSelection(m_selection); |
| 586 trialFrameSelection->modify(alter, direction, granularity, NotUserTrigge
red); | 586 trialFrameSelection->modify(alter, direction, granularity, NotUserTrigge
red); |
| 587 | 587 |
| 588 if (trialFrameSelection->selection().isRange() && m_selection.isCaret()
&& !dispatchSelectStart()) | 588 if (trialFrameSelection->selection().isRange() && m_selection.isCaret()
&& !dispatchSelectStart()) |
| 589 return false; | 589 return false; |
| 590 } | 590 } |
| 591 | 591 |
| 592 willBeModified(alter, direction); | 592 willBeModified(alter, direction); |
| 593 | 593 |
| 594 bool wasRange = m_selection.isRange(); | 594 bool wasRange = m_selection.isRange(); |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 687 y = rect.y() + rect.height() / 2; | 687 y = rect.y() + rect.height() / 2; |
| 688 return true; | 688 return true; |
| 689 } | 689 } |
| 690 | 690 |
| 691 bool SelectionEditor::modify(EAlteration alter, unsigned verticalDistance, Verti
calDirection direction, EUserTriggered userTriggered, CursorAlignOnScroll align) | 691 bool SelectionEditor::modify(EAlteration alter, unsigned verticalDistance, Verti
calDirection direction, EUserTriggered userTriggered, CursorAlignOnScroll align) |
| 692 { | 692 { |
| 693 if (!verticalDistance) | 693 if (!verticalDistance) |
| 694 return false; | 694 return false; |
| 695 | 695 |
| 696 if (userTriggered == UserTriggered) { | 696 if (userTriggered == UserTriggered) { |
| 697 OwnPtrWillBeRawPtr<FrameSelection> trialFrameSelection = FrameSelection:
:create(); | 697 RawPtr<FrameSelection> trialFrameSelection = FrameSelection::create(); |
| 698 trialFrameSelection->setSelection(m_selection); | 698 trialFrameSelection->setSelection(m_selection); |
| 699 trialFrameSelection->modify(alter, verticalDistance, direction, NotUserT
riggered); | 699 trialFrameSelection->modify(alter, verticalDistance, direction, NotUserT
riggered); |
| 700 } | 700 } |
| 701 | 701 |
| 702 willBeModified(alter, direction == FrameSelection::DirectionUp ? DirectionBa
ckward : DirectionForward); | 702 willBeModified(alter, direction == FrameSelection::DirectionUp ? DirectionBa
ckward : DirectionForward); |
| 703 | 703 |
| 704 VisiblePosition pos; | 704 VisiblePosition pos; |
| 705 LayoutUnit xPos; | 705 LayoutUnit xPos; |
| 706 switch (alter) { | 706 switch (alter) { |
| 707 case FrameSelection::AlterationMove: | 707 case FrameSelection::AlterationMove: |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 842 // can be modified by event handlers, we should create |Range| object before | 842 // can be modified by event handlers, we should create |Range| object before |
| 843 // calling it. | 843 // calling it. |
| 844 m_logicalRange = createRange(range); | 844 m_logicalRange = createRange(range); |
| 845 | 845 |
| 846 VisibleSelection newSelection(range.startPosition(), range.endPosition(), af
finity, directional == SelectionDirectionalMode::Directional); | 846 VisibleSelection newSelection(range.startPosition(), range.endPosition(), af
finity, directional == SelectionDirectionalMode::Directional); |
| 847 m_frameSelection->setSelection(newSelection, options); | 847 m_frameSelection->setSelection(newSelection, options); |
| 848 startObservingVisibleSelectionChange(); | 848 startObservingVisibleSelectionChange(); |
| 849 return true; | 849 return true; |
| 850 } | 850 } |
| 851 | 851 |
| 852 PassRefPtrWillBeRawPtr<Range> SelectionEditor::firstRange() const | 852 RawPtr<Range> SelectionEditor::firstRange() const |
| 853 { | 853 { |
| 854 if (m_logicalRange) | 854 if (m_logicalRange) |
| 855 return m_logicalRange->cloneRange(); | 855 return m_logicalRange->cloneRange(); |
| 856 return firstRangeOf(m_selection); | 856 return firstRangeOf(m_selection); |
| 857 } | 857 } |
| 858 | 858 |
| 859 bool SelectionEditor::dispatchSelectStart() | 859 bool SelectionEditor::dispatchSelectStart() |
| 860 { | 860 { |
| 861 Node* selectStartTarget = m_selection.extent().computeContainerNode(); | 861 Node* selectStartTarget = m_selection.extent().computeContainerNode(); |
| 862 if (!selectStartTarget) | 862 if (!selectStartTarget) |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 901 DEFINE_TRACE(SelectionEditor) | 901 DEFINE_TRACE(SelectionEditor) |
| 902 { | 902 { |
| 903 visitor->trace(m_frameSelection); | 903 visitor->trace(m_frameSelection); |
| 904 visitor->trace(m_selection); | 904 visitor->trace(m_selection); |
| 905 visitor->trace(m_selectionInFlatTree); | 905 visitor->trace(m_selectionInFlatTree); |
| 906 visitor->trace(m_logicalRange); | 906 visitor->trace(m_logicalRange); |
| 907 VisibleSelectionChangeObserver::trace(visitor); | 907 VisibleSelectionChangeObserver::trace(visitor); |
| 908 } | 908 } |
| 909 | 909 |
| 910 } // namespace blink | 910 } // namespace blink |
| OLD | NEW |