OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserv
ed. | 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserv
ed. |
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 437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
448 rightWordBreak = visiblePosition.honorEditingBoundaryAtOrBefore(rightWordBre
ak); | 448 rightWordBreak = visiblePosition.honorEditingBoundaryAtOrBefore(rightWordBre
ak); |
449 | 449 |
450 // FIXME: How should we handle a non-editable position? | 450 // FIXME: How should we handle a non-editable position? |
451 if (rightWordBreak.isNull() && isEditablePosition(visiblePosition.deepEquiva
lent())) { | 451 if (rightWordBreak.isNull() && isEditablePosition(visiblePosition.deepEquiva
lent())) { |
452 TextDirection blockDirection = directionOfEnclosingBlock(visiblePosition
.deepEquivalent()); | 452 TextDirection blockDirection = directionOfEnclosingBlock(visiblePosition
.deepEquivalent()); |
453 rightWordBreak = blockDirection == LTR ? endOfEditableContent(visiblePos
ition) : startOfEditableContent(visiblePosition); | 453 rightWordBreak = blockDirection == LTR ? endOfEditableContent(visiblePos
ition) : startOfEditableContent(visiblePosition); |
454 } | 454 } |
455 return rightWordBreak; | 455 return rightWordBreak; |
456 } | 456 } |
457 | 457 |
| 458 template <typename Strategy> |
| 459 static ContainerNode* nonShadowBoundaryParentNode(Node* node) |
| 460 { |
| 461 ContainerNode* parent = Strategy::parent(*node); |
| 462 return parent && !parent->isShadowRoot() ? parent : nullptr; |
| 463 } |
| 464 |
| 465 template <typename Strategy> |
| 466 static Node* parentEditingBoundary(const PositionAlgorithm<Strategy>& position) |
| 467 { |
| 468 Node* const anchorNode = position.anchorNode(); |
| 469 if (!anchorNode) |
| 470 return nullptr; |
| 471 |
| 472 Node* documentElement = anchorNode->document().documentElement(); |
| 473 if (!documentElement) |
| 474 return nullptr; |
| 475 |
| 476 Node* boundary = position.computeContainerNode(); |
| 477 while (boundary != documentElement && nonShadowBoundaryParentNode<Strategy>(
boundary) && anchorNode->hasEditableStyle() == Strategy::parent(*boundary)->hasE
ditableStyle()) |
| 478 boundary = nonShadowBoundaryParentNode<Strategy>(boundary); |
| 479 |
| 480 return boundary; |
| 481 } |
458 | 482 |
459 enum BoundarySearchContextAvailability { DontHaveMoreContext, MayHaveMoreContext
}; | 483 enum BoundarySearchContextAvailability { DontHaveMoreContext, MayHaveMoreContext
}; |
460 | 484 |
461 typedef unsigned (*BoundarySearchFunction)(const UChar*, unsigned length, unsign
ed offset, BoundarySearchContextAvailability, bool& needMoreContext); | 485 typedef unsigned (*BoundarySearchFunction)(const UChar*, unsigned length, unsign
ed offset, BoundarySearchContextAvailability, bool& needMoreContext); |
462 | 486 |
463 static VisiblePosition previousBoundary(const VisiblePosition& c, BoundarySearch
Function searchFunction) | 487 static VisiblePosition previousBoundary(const VisiblePosition& c, BoundarySearch
Function searchFunction) |
464 { | 488 { |
465 Position pos = c.deepEquivalent(); | 489 Position pos = c.deepEquivalent(); |
466 Node* boundary = parentEditingBoundary(pos); | 490 Node* boundary = parentEditingBoundary(pos); |
467 if (!boundary) | 491 if (!boundary) |
(...skipping 1454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1922 { | 1946 { |
1923 return mostBackwardCaretPosition<EditingStrategy>(position, rule); | 1947 return mostBackwardCaretPosition<EditingStrategy>(position, rule); |
1924 } | 1948 } |
1925 | 1949 |
1926 PositionInComposedTree mostBackwardCaretPosition(const PositionInComposedTree& p
osition, EditingBoundaryCrossingRule rule) | 1950 PositionInComposedTree mostBackwardCaretPosition(const PositionInComposedTree& p
osition, EditingBoundaryCrossingRule rule) |
1927 { | 1951 { |
1928 return mostBackwardCaretPosition<EditingInComposedTreeStrategy>(position, ru
le); | 1952 return mostBackwardCaretPosition<EditingInComposedTreeStrategy>(position, ru
le); |
1929 } | 1953 } |
1930 | 1954 |
1931 } | 1955 } |
OLD | NEW |