| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights | 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 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 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 371 logical_start_in_layout_object); | 371 logical_start_in_layout_object); |
| 372 } else { | 372 } else { |
| 373 bool logical_end_in_layout_object = | 373 bool logical_end_in_layout_object = |
| 374 offset_in_box == | 374 offset_in_box == |
| 375 static_cast<int>(text_box->Start() + text_box->Len()) && | 375 static_cast<int>(text_box->Start() + text_box->Len()) && |
| 376 next_box_in_different_block; | 376 next_box_in_different_block; |
| 377 is_word_break = IslogicalEndOfWord(iter, offset_in_iterator, | 377 is_word_break = IslogicalEndOfWord(iter, offset_in_iterator, |
| 378 logical_end_in_layout_object); | 378 logical_end_in_layout_object); |
| 379 } | 379 } |
| 380 | 380 |
| 381 if (is_word_break) | 381 if (is_word_break) { |
| 382 return adjacent_character_position; | 382 return HonorEditingBoundaryAtOrBefore(adjacent_character_position, |
| 383 visible_position.DeepEquivalent()); |
| 384 } |
| 383 | 385 |
| 384 current = adjacent_character_position; | 386 current = adjacent_character_position; |
| 385 } | 387 } |
| 386 return VisiblePosition(); | 388 return VisiblePosition(); |
| 387 } | 389 } |
| 388 | 390 |
| 389 } // namespace | 391 } // namespace |
| 390 | 392 |
| 391 VisiblePosition SelectionModifier::LeftWordPosition( | 393 VisiblePosition SelectionModifier::LeftWordPosition( |
| 392 const VisiblePosition& visible_position, | 394 const VisiblePosition& visible_position, |
| 393 bool skips_space_when_moving_right) { | 395 bool skips_space_when_moving_right) { |
| 394 DCHECK(visible_position.IsValid()) << visible_position; | 396 DCHECK(visible_position.IsValid()) << visible_position; |
| 395 VisiblePosition left_word_break = VisualWordPosition( | 397 const VisiblePosition& left_word_break = VisualWordPosition( |
| 396 visible_position, kMoveLeft, skips_space_when_moving_right); | 398 visible_position, kMoveLeft, skips_space_when_moving_right); |
| 397 left_word_break = HonorEditingBoundaryAtOrBefore( | 399 if (left_word_break.IsNotNull()) |
| 398 left_word_break, visible_position.DeepEquivalent()); | 400 return left_word_break; |
| 399 | |
| 400 // TODO(editing-dev) How should we handle a non-editable position? | 401 // TODO(editing-dev) How should we handle a non-editable position? |
| 401 if (left_word_break.IsNull() && | 402 if (!IsEditablePosition(visible_position.DeepEquivalent())) |
| 402 IsEditablePosition(visible_position.DeepEquivalent())) { | 403 return left_word_break; |
| 403 TextDirection block_direction = | 404 const TextDirection block_direction = |
| 404 DirectionOfEnclosingBlockOf(visible_position.DeepEquivalent()); | 405 DirectionOfEnclosingBlockOf(visible_position.DeepEquivalent()); |
| 405 left_word_break = block_direction == TextDirection::kLtr | 406 return block_direction == TextDirection::kLtr |
| 406 ? StartOfEditableContent(visible_position) | 407 ? StartOfEditableContent(visible_position) |
| 407 : EndOfEditableContent(visible_position); | 408 : EndOfEditableContent(visible_position); |
| 408 } | |
| 409 return left_word_break; | |
| 410 } | 409 } |
| 411 | 410 |
| 412 VisiblePosition SelectionModifier::RightWordPosition( | 411 VisiblePosition SelectionModifier::RightWordPosition( |
| 413 const VisiblePosition& visible_position, | 412 const VisiblePosition& visible_position, |
| 414 bool skips_space_when_moving_right) { | 413 bool skips_space_when_moving_right) { |
| 415 DCHECK(visible_position.IsValid()) << visible_position; | 414 DCHECK(visible_position.IsValid()) << visible_position; |
| 416 VisiblePosition right_word_break = VisualWordPosition( | 415 const VisiblePosition& right_word_break = VisualWordPosition( |
| 417 visible_position, kMoveRight, skips_space_when_moving_right); | 416 visible_position, kMoveRight, skips_space_when_moving_right); |
| 418 right_word_break = HonorEditingBoundaryAtOrBefore( | 417 if (right_word_break.IsNotNull()) |
| 419 right_word_break, visible_position.DeepEquivalent()); | 418 return right_word_break; |
| 420 | |
| 421 // TODO(editing-dev) How should we handle a non-editable position? | 419 // TODO(editing-dev) How should we handle a non-editable position? |
| 422 if (right_word_break.IsNull() && | 420 if (!IsEditablePosition(visible_position.DeepEquivalent())) |
| 423 IsEditablePosition(visible_position.DeepEquivalent())) { | 421 return right_word_break; |
| 424 TextDirection block_direction = | 422 const TextDirection block_direction = |
| 425 blink::DirectionOfEnclosingBlockOf(visible_position.DeepEquivalent()); | 423 blink::DirectionOfEnclosingBlockOf(visible_position.DeepEquivalent()); |
| 426 right_word_break = block_direction == TextDirection::kLtr | 424 return block_direction == TextDirection::kLtr |
| 427 ? EndOfEditableContent(visible_position) | 425 ? EndOfEditableContent(visible_position) |
| 428 : StartOfEditableContent(visible_position); | 426 : StartOfEditableContent(visible_position); |
| 429 } | |
| 430 return right_word_break; | |
| 431 } | 427 } |
| 432 | 428 |
| 433 } // namespace blink | 429 } // namespace blink |
| OLD | NEW |