| 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 437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 448 pos = StartOfDocument(pos); | 448 pos = StartOfDocument(pos); |
| 449 break; | 449 break; |
| 450 } | 450 } |
| 451 AdjustPositionForUserSelectAll( | 451 AdjustPositionForUserSelectAll( |
| 452 pos, !(DirectionOfEnclosingBlock() == TextDirection::kLtr)); | 452 pos, !(DirectionOfEnclosingBlock() == TextDirection::kLtr)); |
| 453 return pos; | 453 return pos; |
| 454 } | 454 } |
| 455 | 455 |
| 456 VisiblePosition SelectionModifier::ModifyMovingLeft( | 456 VisiblePosition SelectionModifier::ModifyMovingLeft( |
| 457 TextGranularity granularity) { | 457 TextGranularity granularity) { |
| 458 VisiblePosition pos; | |
| 459 switch (granularity) { | 458 switch (granularity) { |
| 460 case kCharacterGranularity: | 459 case kCharacterGranularity: |
| 461 if (selection_.IsRange()) { | 460 if (!selection_.IsRange()) { |
| 462 if (DirectionOfSelection() == TextDirection::kLtr) | 461 return LeftPositionOf( |
| 463 pos = | |
| 464 CreateVisiblePosition(selection_.Start(), selection_.Affinity()); | |
| 465 else | |
| 466 pos = CreateVisiblePosition(selection_.end(), selection_.Affinity()); | |
| 467 } else { | |
| 468 pos = LeftPositionOf( | |
| 469 CreateVisiblePosition(selection_.Extent(), selection_.Affinity())); | 462 CreateVisiblePosition(selection_.Extent(), selection_.Affinity())); |
| 470 } | 463 } |
| 471 break; | 464 if (DirectionOfSelection() == TextDirection::kLtr) |
| 465 return CreateVisiblePosition(selection_.Start(), selection_.Affinity()); |
| 466 return CreateVisiblePosition(selection_.end(), selection_.Affinity()); |
| 472 case kWordGranularity: { | 467 case kWordGranularity: { |
| 473 bool skips_space_when_moving_right = | 468 const bool skips_space_when_moving_right = |
| 474 GetFrame() && | 469 GetFrame() && |
| 475 GetFrame()->GetEditor().Behavior().ShouldSkipSpaceWhenMovingRight(); | 470 GetFrame()->GetEditor().Behavior().ShouldSkipSpaceWhenMovingRight(); |
| 476 pos = LeftWordPosition( | 471 return LeftWordPosition( |
| 477 CreateVisiblePosition(selection_.Extent(), selection_.Affinity()), | 472 CreateVisiblePosition(selection_.Extent(), selection_.Affinity()), |
| 478 skips_space_when_moving_right); | 473 skips_space_when_moving_right); |
| 479 break; | |
| 480 } | 474 } |
| 481 case kSentenceGranularity: | 475 case kSentenceGranularity: |
| 482 case kLineGranularity: | 476 case kLineGranularity: |
| 483 case kParagraphGranularity: | 477 case kParagraphGranularity: |
| 484 case kSentenceBoundary: | 478 case kSentenceBoundary: |
| 485 case kParagraphBoundary: | 479 case kParagraphBoundary: |
| 486 case kDocumentBoundary: | 480 case kDocumentBoundary: |
| 487 // FIXME: Implement all of the above. | 481 // FIXME: Implement all of the above. |
| 488 pos = ModifyMovingBackward(granularity); | 482 return ModifyMovingBackward(granularity); |
| 489 break; | |
| 490 case kLineBoundary: | 483 case kLineBoundary: |
| 491 pos = LeftBoundaryOfLine(StartForPlatform(), DirectionOfEnclosingBlock()); | 484 return LeftBoundaryOfLine(StartForPlatform(), |
| 492 break; | 485 DirectionOfEnclosingBlock()); |
| 493 } | 486 } |
| 494 return pos; | 487 NOTREACHED() << granularity; |
| 488 return VisiblePosition(); |
| 495 } | 489 } |
| 496 | 490 |
| 497 VisiblePosition SelectionModifier::ModifyMovingBackward( | 491 VisiblePosition SelectionModifier::ModifyMovingBackward( |
| 498 TextGranularity granularity) { | 492 TextGranularity granularity) { |
| 499 VisiblePosition pos; | 493 VisiblePosition pos; |
| 500 switch (granularity) { | 494 switch (granularity) { |
| 501 case kCharacterGranularity: | 495 case kCharacterGranularity: |
| 502 if (selection_.IsRange()) | 496 if (selection_.IsRange()) |
| 503 pos = CreateVisiblePosition(selection_.Start(), selection_.Affinity()); | 497 pos = CreateVisiblePosition(selection_.Start(), selection_.Affinity()); |
| 504 else | 498 else |
| (...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 856 x = LineDirectionPointForBlockDirectionNavigationOf(visible_position); | 850 x = LineDirectionPointForBlockDirectionNavigationOf(visible_position); |
| 857 x_pos_for_vertical_arrow_navigation_ = x; | 851 x_pos_for_vertical_arrow_navigation_ = x; |
| 858 } else { | 852 } else { |
| 859 x = x_pos_for_vertical_arrow_navigation_; | 853 x = x_pos_for_vertical_arrow_navigation_; |
| 860 } | 854 } |
| 861 | 855 |
| 862 return x; | 856 return x; |
| 863 } | 857 } |
| 864 | 858 |
| 865 } // namespace blink | 859 } // namespace blink |
| OLD | NEW |