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