| 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 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 pos = EndOfDocument(pos); | 257 pos = EndOfDocument(pos); |
| 258 break; | 258 break; |
| 259 } | 259 } |
| 260 AdjustPositionForUserSelectAll( | 260 AdjustPositionForUserSelectAll( |
| 261 pos, DirectionOfEnclosingBlock() == TextDirection::kLtr); | 261 pos, DirectionOfEnclosingBlock() == TextDirection::kLtr); |
| 262 return pos; | 262 return pos; |
| 263 } | 263 } |
| 264 | 264 |
| 265 VisiblePosition SelectionModifier::ModifyMovingRight( | 265 VisiblePosition SelectionModifier::ModifyMovingRight( |
| 266 TextGranularity granularity) { | 266 TextGranularity granularity) { |
| 267 VisiblePosition pos; | |
| 268 switch (granularity) { | 267 switch (granularity) { |
| 269 case kCharacterGranularity: | 268 case kCharacterGranularity: |
| 270 if (selection_.IsRange()) { | 269 if (!selection_.IsRange()) { |
| 271 if (DirectionOfSelection() == TextDirection::kLtr) | 270 return RightPositionOf( |
| 272 pos = CreateVisiblePosition(selection_.end(), selection_.Affinity()); | |
| 273 else | |
| 274 pos = | |
| 275 CreateVisiblePosition(selection_.Start(), selection_.Affinity()); | |
| 276 } else { | |
| 277 pos = RightPositionOf( | |
| 278 CreateVisiblePosition(selection_.Extent(), selection_.Affinity())); | 271 CreateVisiblePosition(selection_.Extent(), selection_.Affinity())); |
| 279 } | 272 } |
| 280 break; | 273 if (DirectionOfSelection() == TextDirection::kLtr) |
| 274 return CreateVisiblePosition(selection_.end(), selection_.Affinity()); |
| 275 return CreateVisiblePosition(selection_.Start(), selection_.Affinity()); |
| 281 case kWordGranularity: { | 276 case kWordGranularity: { |
| 282 bool skips_space_when_moving_right = | 277 const bool skips_space_when_moving_right = |
| 283 GetFrame() && | 278 GetFrame() && |
| 284 GetFrame()->GetEditor().Behavior().ShouldSkipSpaceWhenMovingRight(); | 279 GetFrame()->GetEditor().Behavior().ShouldSkipSpaceWhenMovingRight(); |
| 285 pos = RightWordPosition( | 280 return RightWordPosition( |
| 286 CreateVisiblePosition(selection_.Extent(), selection_.Affinity()), | 281 CreateVisiblePosition(selection_.Extent(), selection_.Affinity()), |
| 287 skips_space_when_moving_right); | 282 skips_space_when_moving_right); |
| 288 break; | |
| 289 } | 283 } |
| 290 case kSentenceGranularity: | 284 case kSentenceGranularity: |
| 291 case kLineGranularity: | 285 case kLineGranularity: |
| 292 case kParagraphGranularity: | 286 case kParagraphGranularity: |
| 293 case kSentenceBoundary: | 287 case kSentenceBoundary: |
| 294 case kParagraphBoundary: | 288 case kParagraphBoundary: |
| 295 case kDocumentBoundary: | 289 case kDocumentBoundary: |
| 296 // FIXME: Implement all of the above. | 290 // TODO(editing-dev): Implement all of the above. |
| 297 pos = ModifyMovingForward(granularity); | 291 return ModifyMovingForward(granularity); |
| 298 break; | |
| 299 case kLineBoundary: | 292 case kLineBoundary: |
| 300 pos = | 293 return RightBoundaryOfLine(StartForPlatform(), |
| 301 RightBoundaryOfLine(StartForPlatform(), DirectionOfEnclosingBlock()); | 294 DirectionOfEnclosingBlock()); |
| 302 break; | |
| 303 } | 295 } |
| 304 return pos; | 296 NOTREACHED() << granularity; |
| 297 return VisiblePosition(); |
| 305 } | 298 } |
| 306 | 299 |
| 307 VisiblePosition SelectionModifier::ModifyMovingForward( | 300 VisiblePosition SelectionModifier::ModifyMovingForward( |
| 308 TextGranularity granularity) { | 301 TextGranularity granularity) { |
| 309 VisiblePosition pos; | 302 VisiblePosition pos; |
| 310 // FIXME: Stay in editable content for the less common granularities. | 303 // FIXME: Stay in editable content for the less common granularities. |
| 311 switch (granularity) { | 304 switch (granularity) { |
| 312 case kCharacterGranularity: | 305 case kCharacterGranularity: |
| 313 if (selection_.IsRange()) | 306 if (selection_.IsRange()) |
| 314 pos = CreateVisiblePosition(selection_.end(), selection_.Affinity()); | 307 pos = CreateVisiblePosition(selection_.end(), selection_.Affinity()); |
| (...skipping 535 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 850 x = LineDirectionPointForBlockDirectionNavigationOf(visible_position); | 843 x = LineDirectionPointForBlockDirectionNavigationOf(visible_position); |
| 851 x_pos_for_vertical_arrow_navigation_ = x; | 844 x_pos_for_vertical_arrow_navigation_ = x; |
| 852 } else { | 845 } else { |
| 853 x = x_pos_for_vertical_arrow_navigation_; | 846 x = x_pos_for_vertical_arrow_navigation_; |
| 854 } | 847 } |
| 855 | 848 |
| 856 return x; | 849 return x; |
| 857 } | 850 } |
| 858 | 851 |
| 859 } // namespace blink | 852 } // namespace blink |
| OLD | NEW |