| 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 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 387 return CreateVisiblePosition(pos, VP_UPSTREAM_IF_POSSIBLE); | 387 return CreateVisiblePosition(pos, VP_UPSTREAM_IF_POSSIBLE); |
| 388 } | 388 } |
| 389 | 389 |
| 390 // TODO(yosin) Rename this function to reflect the fact it ignores bidi levels. | 390 // TODO(yosin) Rename this function to reflect the fact it ignores bidi levels. |
| 391 template <typename Strategy> | 391 template <typename Strategy> |
| 392 static VisiblePositionTemplate<Strategy> EndOfLineAlgorithm( | 392 static VisiblePositionTemplate<Strategy> EndOfLineAlgorithm( |
| 393 const VisiblePositionTemplate<Strategy>& current_position) { | 393 const VisiblePositionTemplate<Strategy>& current_position) { |
| 394 DCHECK(current_position.IsValid()) << current_position; | 394 DCHECK(current_position.IsValid()) << current_position; |
| 395 // TODO(yosin) this is the current behavior that might need to be fixed. | 395 // TODO(yosin) this is the current behavior that might need to be fixed. |
| 396 // Please refer to https://bugs.webkit.org/show_bug.cgi?id=49107 for detail. | 396 // Please refer to https://bugs.webkit.org/show_bug.cgi?id=49107 for detail. |
| 397 VisiblePositionTemplate<Strategy> vis_pos = | 397 const VisiblePositionTemplate<Strategy>& candidate_position = |
| 398 EndPositionForLine(current_position, kUseInlineBoxOrdering); | 398 EndPositionForLine(current_position, kUseInlineBoxOrdering); |
| 399 | 399 |
| 400 // Make sure the end of line is at the same line as the given input | 400 // Make sure the end of line is at the same line as the given input |
| 401 // position. Else use the previous position to obtain end of line. This | 401 // position. Else use the previous position to obtain end of line. This |
| 402 // condition happens when the input position is before the space character | 402 // condition happens when the input position is before the space character |
| 403 // at the end of a soft-wrapped non-editable line. In this scenario, | 403 // at the end of a soft-wrapped non-editable line. In this scenario, |
| 404 // |endPositionForLine()| would incorrectly hand back a position in the next | 404 // |endPositionForLine()| would incorrectly hand back a position in the next |
| 405 // line instead. This fix is to account for the discrepancy between lines | 405 // line instead. This fix is to account for the discrepancy between lines |
| 406 // with "webkit-line-break:after-white-space" style versus lines without | 406 // with "webkit-line-break:after-white-space" style versus lines without |
| 407 // that style, which would break before a space by default. | 407 // that style, which would break before a space by default. |
| 408 if (!InSameLine(current_position, vis_pos)) { | 408 if (InSameLine(current_position, candidate_position)) { |
| 409 vis_pos = PreviousPositionOf(current_position); | 409 return HonorEditingBoundaryAtOrAfter(candidate_position, |
| 410 if (vis_pos.IsNull()) | 410 current_position.DeepEquivalent()); |
| 411 return VisiblePositionTemplate<Strategy>(); | |
| 412 vis_pos = EndPositionForLine(vis_pos, kUseInlineBoxOrdering); | |
| 413 } | 411 } |
| 414 | 412 const VisiblePositionTemplate<Strategy>& adjusted_position = |
| 415 return HonorEditingBoundaryAtOrAfter(vis_pos, | 413 PreviousPositionOf(current_position); |
| 416 current_position.DeepEquivalent()); | 414 if (adjusted_position.IsNull()) |
| 415 return VisiblePositionTemplate<Strategy>(); |
| 416 return HonorEditingBoundaryAtOrAfter( |
| 417 EndPositionForLine(adjusted_position, kUseInlineBoxOrdering), |
| 418 current_position.DeepEquivalent()); |
| 417 } | 419 } |
| 418 | 420 |
| 419 // TODO(yosin) Rename this function to reflect the fact it ignores bidi levels. | 421 // TODO(yosin) Rename this function to reflect the fact it ignores bidi levels. |
| 420 VisiblePosition EndOfLine(const VisiblePosition& current_position) { | 422 VisiblePosition EndOfLine(const VisiblePosition& current_position) { |
| 421 return EndOfLineAlgorithm<EditingStrategy>(current_position); | 423 return EndOfLineAlgorithm<EditingStrategy>(current_position); |
| 422 } | 424 } |
| 423 | 425 |
| 424 VisiblePositionInFlatTree EndOfLine( | 426 VisiblePositionInFlatTree EndOfLine( |
| 425 const VisiblePositionInFlatTree& current_position) { | 427 const VisiblePositionInFlatTree& current_position) { |
| 426 return EndOfLineAlgorithm<EditingInFlatTreeStrategy>(current_position); | 428 return EndOfLineAlgorithm<EditingInFlatTreeStrategy>(current_position); |
| (...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 687 // to the end of the line we're on. | 689 // to the end of the line we're on. |
| 688 Element* root_element = HasEditableStyle(*node, editable_type) | 690 Element* root_element = HasEditableStyle(*node, editable_type) |
| 689 ? RootEditableElement(*node, editable_type) | 691 ? RootEditableElement(*node, editable_type) |
| 690 : node->GetDocument().documentElement(); | 692 : node->GetDocument().documentElement(); |
| 691 if (!root_element) | 693 if (!root_element) |
| 692 return VisiblePosition(); | 694 return VisiblePosition(); |
| 693 return VisiblePosition::LastPositionInNode(root_element); | 695 return VisiblePosition::LastPositionInNode(root_element); |
| 694 } | 696 } |
| 695 | 697 |
| 696 } // namespace blink | 698 } // namespace blink |
| OLD | NEW |