OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights | 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights |
3 * reserved. | 3 * reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 635 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
646 switch (alter) { | 646 switch (alter) { |
647 case FrameSelection::AlterationMove: | 647 case FrameSelection::AlterationMove: |
648 m_selection = createVisibleSelection( | 648 m_selection = createVisibleSelection( |
649 SelectionInDOMTree::Builder() | 649 SelectionInDOMTree::Builder() |
650 .collapse(position.toPositionWithAffinity()) | 650 .collapse(position.toPositionWithAffinity()) |
651 .setIsDirectional(m_selection.isDirectional()) | 651 .setIsDirectional(m_selection.isDirectional()) |
652 .build()); | 652 .build()); |
653 break; | 653 break; |
654 case FrameSelection::AlterationExtend: | 654 case FrameSelection::AlterationExtend: |
655 | 655 |
656 if (!m_selection.isCaret() && (granularity == WordGranularity || | 656 if (!m_selection.isCaret() && |
657 granularity == ParagraphGranularity || | 657 (granularity == WordGranularity || |
658 granularity == LineGranularity) && | 658 granularity == ParagraphGranularity || |
| 659 granularity == LineGranularity) && |
659 frame() && | 660 frame() && |
660 !frame() | 661 !frame() |
661 ->editor() | 662 ->editor() |
662 .behavior() | 663 .behavior() |
663 .shouldExtendSelectionByWordOrLineAcrossCaret()) { | 664 .shouldExtendSelectionByWordOrLineAcrossCaret()) { |
664 // Don't let the selection go across the base position directly. Needed | 665 // Don't let the selection go across the base position directly. Needed |
665 // to match mac behavior when, for instance, word-selecting backwards | 666 // to match mac behavior when, for instance, word-selecting backwards |
666 // starting with the caret in the middle of a word and then | 667 // starting with the caret in the middle of a word and then |
667 // word-selecting forward, leaving the caret in the same place where it | 668 // word-selecting forward, leaving the caret in the same place where it |
668 // was, instead of directly selecting to the end of the word. | 669 // was, instead of directly selecting to the end of the word. |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
714 bool SelectionModifier::modifyWithPageGranularity(EAlteration alter, | 715 bool SelectionModifier::modifyWithPageGranularity(EAlteration alter, |
715 unsigned verticalDistance, | 716 unsigned verticalDistance, |
716 VerticalDirection direction) { | 717 VerticalDirection direction) { |
717 if (!verticalDistance) | 718 if (!verticalDistance) |
718 return false; | 719 return false; |
719 | 720 |
720 DCHECK(!frame()->document()->needsLayoutTreeUpdate()); | 721 DCHECK(!frame()->document()->needsLayoutTreeUpdate()); |
721 DocumentLifecycle::DisallowTransitionScope disallowTransition( | 722 DocumentLifecycle::DisallowTransitionScope disallowTransition( |
722 frame()->document()->lifecycle()); | 723 frame()->document()->lifecycle()); |
723 | 724 |
724 willBeModified(alter, direction == FrameSelection::DirectionUp | 725 willBeModified(alter, |
725 ? DirectionBackward | 726 direction == FrameSelection::DirectionUp ? DirectionBackward |
726 : DirectionForward); | 727 : DirectionForward); |
727 | 728 |
728 VisiblePosition pos; | 729 VisiblePosition pos; |
729 LayoutUnit xPos; | 730 LayoutUnit xPos; |
730 switch (alter) { | 731 switch (alter) { |
731 case FrameSelection::AlterationMove: | 732 case FrameSelection::AlterationMove: |
732 pos = createVisiblePosition(direction == FrameSelection::DirectionUp | 733 pos = createVisiblePosition(direction == FrameSelection::DirectionUp |
733 ? m_selection.start() | 734 ? m_selection.start() |
734 : m_selection.end(), | 735 : m_selection.end(), |
735 m_selection.affinity()); | 736 m_selection.affinity()); |
736 xPos = lineDirectionPointForBlockDirectionNavigation( | 737 xPos = lineDirectionPointForBlockDirectionNavigation( |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
863 x = lineDirectionPointForBlockDirectionNavigationOf(visiblePosition); | 864 x = lineDirectionPointForBlockDirectionNavigationOf(visiblePosition); |
864 m_xPosForVerticalArrowNavigation = x; | 865 m_xPosForVerticalArrowNavigation = x; |
865 } else { | 866 } else { |
866 x = m_xPosForVerticalArrowNavigation; | 867 x = m_xPosForVerticalArrowNavigation; |
867 } | 868 } |
868 | 869 |
869 return x; | 870 return x; |
870 } | 871 } |
871 | 872 |
872 } // namespace blink | 873 } // namespace blink |
OLD | NEW |