| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved. | 2 * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 323 return ComparePositions(a.DeepEquivalent(), b.DeepEquivalent()); | 323 return ComparePositions(a.DeepEquivalent(), b.DeepEquivalent()); |
| 324 } | 324 } |
| 325 | 325 |
| 326 bool IsNodeFullyContained(const EphemeralRange& range, Node& node) { | 326 bool IsNodeFullyContained(const EphemeralRange& range, Node& node) { |
| 327 if (range.IsNull()) | 327 if (range.IsNull()) |
| 328 return false; | 328 return false; |
| 329 | 329 |
| 330 if (!NodeTraversal::CommonAncestor(*range.StartPosition().AnchorNode(), node)) | 330 if (!NodeTraversal::CommonAncestor(*range.StartPosition().AnchorNode(), node)) |
| 331 return false; | 331 return false; |
| 332 | 332 |
| 333 return range.StartPosition() <= Position::BeforeNode(&node) && | 333 return range.StartPosition() <= Position::BeforeNode(node) && |
| 334 Position::AfterNode(&node) <= range.EndPosition(); | 334 Position::AfterNode(&node) <= range.EndPosition(); |
| 335 } | 335 } |
| 336 | 336 |
| 337 // TODO(editing-dev): We should implement real version which refers | 337 // TODO(editing-dev): We should implement real version which refers |
| 338 // "user-select" CSS property. | 338 // "user-select" CSS property. |
| 339 // TODO(editing-dev): We should make |SelectionAdjuster| to use this funciton | 339 // TODO(editing-dev): We should make |SelectionAdjuster| to use this funciton |
| 340 // instead of |isSelectionBondary()|. | 340 // instead of |isSelectionBondary()|. |
| 341 bool IsUserSelectContain(const Node& node) { | 341 bool IsUserSelectContain(const Node& node) { |
| 342 return isHTMLTextAreaElement(node) || isHTMLInputElement(node) || | 342 return isHTMLTextAreaElement(node) || isHTMLInputElement(node) || |
| 343 isHTMLSelectElement(node); | 343 isHTMLSelectElement(node); |
| (...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 843 const PositionTemplate<Strategy>& position, | 843 const PositionTemplate<Strategy>& position, |
| 844 PositionMoveType move_type) { | 844 PositionMoveType move_type) { |
| 845 Node* const node = position.AnchorNode(); | 845 Node* const node = position.AnchorNode(); |
| 846 if (!node) | 846 if (!node) |
| 847 return position; | 847 return position; |
| 848 | 848 |
| 849 const int offset = position.ComputeEditingOffset(); | 849 const int offset = position.ComputeEditingOffset(); |
| 850 | 850 |
| 851 if (offset > 0) { | 851 if (offset > 0) { |
| 852 if (EditingIgnoresContent(*node)) | 852 if (EditingIgnoresContent(*node)) |
| 853 return PositionTemplate<Strategy>::BeforeNode(node); | 853 return PositionTemplate<Strategy>::BeforeNode(*node); |
| 854 if (Node* child = Strategy::ChildAt(*node, offset - 1)) | 854 if (Node* child = Strategy::ChildAt(*node, offset - 1)) |
| 855 return PositionTemplate<Strategy>::LastPositionInOrAfterNode(child); | 855 return PositionTemplate<Strategy>::LastPositionInOrAfterNode(child); |
| 856 | 856 |
| 857 // There are two reasons child might be 0: | 857 // There are two reasons child might be 0: |
| 858 // 1) The node is node like a text node that is not an element, and | 858 // 1) The node is node like a text node that is not an element, and |
| 859 // therefore has no children. Going backward one character at a | 859 // therefore has no children. Going backward one character at a |
| 860 // time is correct. | 860 // time is correct. |
| 861 // 2) The old offset was a bogus offset like (<br>, 1), and there is | 861 // 2) The old offset was a bogus offset like (<br>, 1), and there is |
| 862 // no child. Going from 1 to 0 is correct. | 862 // no child. Going from 1 to 0 is correct. |
| 863 switch (move_type) { | 863 switch (move_type) { |
| 864 case PositionMoveType::kCodeUnit: | 864 case PositionMoveType::kCodeUnit: |
| 865 return PositionTemplate<Strategy>(node, offset - 1); | 865 return PositionTemplate<Strategy>(node, offset - 1); |
| 866 case PositionMoveType::kBackwardDeletion: | 866 case PositionMoveType::kBackwardDeletion: |
| 867 return PositionTemplate<Strategy>( | 867 return PositionTemplate<Strategy>( |
| 868 node, PreviousBackwardDeletionOffsetOf(node, offset)); | 868 node, PreviousBackwardDeletionOffsetOf(node, offset)); |
| 869 case PositionMoveType::kGraphemeCluster: | 869 case PositionMoveType::kGraphemeCluster: |
| 870 return PositionTemplate<Strategy>( | 870 return PositionTemplate<Strategy>( |
| 871 node, PreviousGraphemeBoundaryOf(node, offset)); | 871 node, PreviousGraphemeBoundaryOf(node, offset)); |
| 872 default: | 872 default: |
| 873 NOTREACHED() << "Unhandled moveType: " << move_type; | 873 NOTREACHED() << "Unhandled moveType: " << move_type; |
| 874 } | 874 } |
| 875 } | 875 } |
| 876 | 876 |
| 877 if (ContainerNode* parent = Strategy::Parent(*node)) { | 877 if (ContainerNode* parent = Strategy::Parent(*node)) { |
| 878 if (EditingIgnoresContent(*parent)) | 878 if (EditingIgnoresContent(*parent)) |
| 879 return PositionTemplate<Strategy>::BeforeNode(parent); | 879 return PositionTemplate<Strategy>::BeforeNode(*parent); |
| 880 // TODO(yosin) We should use |Strategy::index(Node&)| instead of | 880 // TODO(yosin) We should use |Strategy::index(Node&)| instead of |
| 881 // |Node::nodeIndex()|. | 881 // |Node::nodeIndex()|. |
| 882 return PositionTemplate<Strategy>(parent, node->NodeIndex()); | 882 return PositionTemplate<Strategy>(parent, node->NodeIndex()); |
| 883 } | 883 } |
| 884 return position; | 884 return position; |
| 885 } | 885 } |
| 886 | 886 |
| 887 Position PreviousPositionOf(const Position& position, | 887 Position PreviousPositionOf(const Position& position, |
| 888 PositionMoveType move_type) { | 888 PositionMoveType move_type) { |
| 889 return PreviousPositionOfAlgorithm<EditingStrategy>(position, move_type); | 889 return PreviousPositionOfAlgorithm<EditingStrategy>(position, move_type); |
| (...skipping 1289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2179 return InputType::kDeleteSoftLineBackward; | 2179 return InputType::kDeleteSoftLineBackward; |
| 2180 if (granularity == kParagraphBoundary) | 2180 if (granularity == kParagraphBoundary) |
| 2181 return InputType::kDeleteHardLineBackward; | 2181 return InputType::kDeleteHardLineBackward; |
| 2182 return InputType::kDeleteContentBackward; | 2182 return InputType::kDeleteContentBackward; |
| 2183 default: | 2183 default: |
| 2184 return InputType::kNone; | 2184 return InputType::kNone; |
| 2185 } | 2185 } |
| 2186 } | 2186 } |
| 2187 | 2187 |
| 2188 } // namespace blink | 2188 } // namespace blink |
| OLD | NEW |