| 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 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 // and start/end adjustment in |visibleSelection::validate()| for range | 131 // and start/end adjustment in |visibleSelection::validate()| for range |
| 132 // selection. | 132 // selection. |
| 133 static SelectionInDOMTree PrepareToExtendSeelction( | 133 static SelectionInDOMTree PrepareToExtendSeelction( |
| 134 const VisibleSelection& visible_selection, | 134 const VisibleSelection& visible_selection, |
| 135 SelectionDirection direction) { | 135 SelectionDirection direction) { |
| 136 if (visible_selection.Start().IsNull()) | 136 if (visible_selection.Start().IsNull()) |
| 137 return visible_selection.AsSelection(); | 137 return visible_selection.AsSelection(); |
| 138 const bool base_is_start = IsBaseStart(visible_selection, direction); | 138 const bool base_is_start = IsBaseStart(visible_selection, direction); |
| 139 return SelectionInDOMTree::Builder(visible_selection.AsSelection()) | 139 return SelectionInDOMTree::Builder(visible_selection.AsSelection()) |
| 140 .Collapse(base_is_start ? visible_selection.Start() | 140 .Collapse(base_is_start ? visible_selection.Start() |
| 141 : visible_selection.end()) | 141 : visible_selection.End()) |
| 142 .Extend(base_is_start ? visible_selection.end() | 142 .Extend(base_is_start ? visible_selection.End() |
| 143 : visible_selection.Start()) | 143 : visible_selection.Start()) |
| 144 .Build(); | 144 .Build(); |
| 145 } | 145 } |
| 146 | 146 |
| 147 VisiblePosition SelectionModifier::PositionForPlatform( | 147 VisiblePosition SelectionModifier::PositionForPlatform( |
| 148 bool is_get_start) const { | 148 bool is_get_start) const { |
| 149 Settings* settings = GetFrame() ? GetFrame()->GetSettings() : nullptr; | 149 Settings* settings = GetFrame() ? GetFrame()->GetSettings() : nullptr; |
| 150 if (settings && settings->GetEditingBehaviorType() == kEditingMacBehavior) | 150 if (settings && settings->GetEditingBehaviorType() == kEditingMacBehavior) |
| 151 return is_get_start ? selection_.VisibleStart() : selection_.VisibleEnd(); | 151 return is_get_start ? selection_.VisibleStart() : selection_.VisibleEnd(); |
| 152 // Linux and Windows always extend selections from the extent endpoint. | 152 // Linux and Windows always extend selections from the extent endpoint. |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 282 | 282 |
| 283 VisiblePosition SelectionModifier::ModifyMovingRight( | 283 VisiblePosition SelectionModifier::ModifyMovingRight( |
| 284 TextGranularity granularity) { | 284 TextGranularity granularity) { |
| 285 switch (granularity) { | 285 switch (granularity) { |
| 286 case kCharacterGranularity: | 286 case kCharacterGranularity: |
| 287 if (!selection_.IsRange()) { | 287 if (!selection_.IsRange()) { |
| 288 return RightPositionOf( | 288 return RightPositionOf( |
| 289 CreateVisiblePosition(selection_.Extent(), selection_.Affinity())); | 289 CreateVisiblePosition(selection_.Extent(), selection_.Affinity())); |
| 290 } | 290 } |
| 291 if (DirectionOfSelection() == TextDirection::kLtr) | 291 if (DirectionOfSelection() == TextDirection::kLtr) |
| 292 return CreateVisiblePosition(selection_.end(), selection_.Affinity()); | 292 return CreateVisiblePosition(selection_.End(), selection_.Affinity()); |
| 293 return CreateVisiblePosition(selection_.Start(), selection_.Affinity()); | 293 return CreateVisiblePosition(selection_.Start(), selection_.Affinity()); |
| 294 case kWordGranularity: { | 294 case kWordGranularity: { |
| 295 const bool skips_space_when_moving_right = | 295 const bool skips_space_when_moving_right = |
| 296 GetFrame() && | 296 GetFrame() && |
| 297 GetFrame()->GetEditor().Behavior().ShouldSkipSpaceWhenMovingRight(); | 297 GetFrame()->GetEditor().Behavior().ShouldSkipSpaceWhenMovingRight(); |
| 298 return RightWordPosition( | 298 return RightWordPosition( |
| 299 CreateVisiblePosition(selection_.Extent(), selection_.Affinity()), | 299 CreateVisiblePosition(selection_.Extent(), selection_.Affinity()), |
| 300 skips_space_when_moving_right); | 300 skips_space_when_moving_right); |
| 301 } | 301 } |
| 302 case kSentenceGranularity: | 302 case kSentenceGranularity: |
| (...skipping 12 matching lines...) Expand all Loading... |
| 315 return VisiblePosition(); | 315 return VisiblePosition(); |
| 316 } | 316 } |
| 317 | 317 |
| 318 VisiblePosition SelectionModifier::ModifyMovingForward( | 318 VisiblePosition SelectionModifier::ModifyMovingForward( |
| 319 TextGranularity granularity) { | 319 TextGranularity granularity) { |
| 320 VisiblePosition pos; | 320 VisiblePosition pos; |
| 321 // FIXME: Stay in editable content for the less common granularities. | 321 // FIXME: Stay in editable content for the less common granularities. |
| 322 switch (granularity) { | 322 switch (granularity) { |
| 323 case kCharacterGranularity: | 323 case kCharacterGranularity: |
| 324 if (selection_.IsRange()) | 324 if (selection_.IsRange()) |
| 325 pos = CreateVisiblePosition(selection_.end(), selection_.Affinity()); | 325 pos = CreateVisiblePosition(selection_.End(), selection_.Affinity()); |
| 326 else | 326 else |
| 327 pos = NextPositionOf( | 327 pos = NextPositionOf( |
| 328 CreateVisiblePosition(selection_.Extent(), selection_.Affinity()), | 328 CreateVisiblePosition(selection_.Extent(), selection_.Affinity()), |
| 329 kCanSkipOverEditingBoundary); | 329 kCanSkipOverEditingBoundary); |
| 330 break; | 330 break; |
| 331 case kWordGranularity: | 331 case kWordGranularity: |
| 332 pos = NextWordPositionForPlatform( | 332 pos = NextWordPositionForPlatform( |
| 333 CreateVisiblePosition(selection_.Extent(), selection_.Affinity())); | 333 CreateVisiblePosition(selection_.Extent(), selection_.Affinity())); |
| 334 break; | 334 break; |
| 335 case kSentenceGranularity: | 335 case kSentenceGranularity: |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 467 VisiblePosition SelectionModifier::ModifyMovingLeft( | 467 VisiblePosition SelectionModifier::ModifyMovingLeft( |
| 468 TextGranularity granularity) { | 468 TextGranularity granularity) { |
| 469 switch (granularity) { | 469 switch (granularity) { |
| 470 case kCharacterGranularity: | 470 case kCharacterGranularity: |
| 471 if (!selection_.IsRange()) { | 471 if (!selection_.IsRange()) { |
| 472 return LeftPositionOf( | 472 return LeftPositionOf( |
| 473 CreateVisiblePosition(selection_.Extent(), selection_.Affinity())); | 473 CreateVisiblePosition(selection_.Extent(), selection_.Affinity())); |
| 474 } | 474 } |
| 475 if (DirectionOfSelection() == TextDirection::kLtr) | 475 if (DirectionOfSelection() == TextDirection::kLtr) |
| 476 return CreateVisiblePosition(selection_.Start(), selection_.Affinity()); | 476 return CreateVisiblePosition(selection_.Start(), selection_.Affinity()); |
| 477 return CreateVisiblePosition(selection_.end(), selection_.Affinity()); | 477 return CreateVisiblePosition(selection_.End(), selection_.Affinity()); |
| 478 case kWordGranularity: { | 478 case kWordGranularity: { |
| 479 const bool skips_space_when_moving_right = | 479 const bool skips_space_when_moving_right = |
| 480 GetFrame() && | 480 GetFrame() && |
| 481 GetFrame()->GetEditor().Behavior().ShouldSkipSpaceWhenMovingRight(); | 481 GetFrame()->GetEditor().Behavior().ShouldSkipSpaceWhenMovingRight(); |
| 482 return LeftWordPosition( | 482 return LeftWordPosition( |
| 483 CreateVisiblePosition(selection_.Extent(), selection_.Affinity()), | 483 CreateVisiblePosition(selection_.Extent(), selection_.Affinity()), |
| 484 skips_space_when_moving_right); | 484 skips_space_when_moving_right); |
| 485 } | 485 } |
| 486 case kSentenceGranularity: | 486 case kSentenceGranularity: |
| 487 case kLineGranularity: | 487 case kLineGranularity: |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 720 ? kDirectionBackward | 720 ? kDirectionBackward |
| 721 : kDirectionForward)); | 721 : kDirectionForward)); |
| 722 } | 722 } |
| 723 | 723 |
| 724 VisiblePosition pos; | 724 VisiblePosition pos; |
| 725 LayoutUnit x_pos; | 725 LayoutUnit x_pos; |
| 726 switch (alter) { | 726 switch (alter) { |
| 727 case FrameSelection::kAlterationMove: | 727 case FrameSelection::kAlterationMove: |
| 728 pos = CreateVisiblePosition(direction == FrameSelection::kDirectionUp | 728 pos = CreateVisiblePosition(direction == FrameSelection::kDirectionUp |
| 729 ? selection_.Start() | 729 ? selection_.Start() |
| 730 : selection_.end(), | 730 : selection_.End(), |
| 731 selection_.Affinity()); | 731 selection_.Affinity()); |
| 732 x_pos = LineDirectionPointForBlockDirectionNavigation( | 732 x_pos = LineDirectionPointForBlockDirectionNavigation( |
| 733 direction == FrameSelection::kDirectionUp ? START : END); | 733 direction == FrameSelection::kDirectionUp ? START : END); |
| 734 break; | 734 break; |
| 735 case FrameSelection::kAlterationExtend: | 735 case FrameSelection::kAlterationExtend: |
| 736 pos = CreateVisiblePosition(selection_.Extent(), selection_.Affinity()); | 736 pos = CreateVisiblePosition(selection_.Extent(), selection_.Affinity()); |
| 737 x_pos = LineDirectionPointForBlockDirectionNavigation(EXTENT); | 737 x_pos = LineDirectionPointForBlockDirectionNavigation(EXTENT); |
| 738 break; | 738 break; |
| 739 } | 739 } |
| 740 | 740 |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 830 | 830 |
| 831 if (selection_.IsNone()) | 831 if (selection_.IsNone()) |
| 832 return x; | 832 return x; |
| 833 | 833 |
| 834 Position pos; | 834 Position pos; |
| 835 switch (type) { | 835 switch (type) { |
| 836 case START: | 836 case START: |
| 837 pos = selection_.Start(); | 837 pos = selection_.Start(); |
| 838 break; | 838 break; |
| 839 case END: | 839 case END: |
| 840 pos = selection_.end(); | 840 pos = selection_.End(); |
| 841 break; | 841 break; |
| 842 case BASE: | 842 case BASE: |
| 843 pos = selection_.Base(); | 843 pos = selection_.Base(); |
| 844 break; | 844 break; |
| 845 case EXTENT: | 845 case EXTENT: |
| 846 pos = selection_.Extent(); | 846 pos = selection_.Extent(); |
| 847 break; | 847 break; |
| 848 } | 848 } |
| 849 | 849 |
| 850 LocalFrame* frame = pos.GetDocument()->GetFrame(); | 850 LocalFrame* frame = pos.GetDocument()->GetFrame(); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 861 x = LineDirectionPointForBlockDirectionNavigationOf(visible_position); | 861 x = LineDirectionPointForBlockDirectionNavigationOf(visible_position); |
| 862 x_pos_for_vertical_arrow_navigation_ = x; | 862 x_pos_for_vertical_arrow_navigation_ = x; |
| 863 } else { | 863 } else { |
| 864 x = x_pos_for_vertical_arrow_navigation_; | 864 x = x_pos_for_vertical_arrow_navigation_; |
| 865 } | 865 } |
| 866 | 866 |
| 867 return x; | 867 return x; |
| 868 } | 868 } |
| 869 | 869 |
| 870 } // namespace blink | 870 } // namespace blink |
| OLD | NEW |