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 748 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
759 if (mode == UseLogicalOrdering) { | 759 if (mode == UseLogicalOrdering) { |
760 if (Node* editableRoot = highestEditableRoot(c.deepEquivalent())) { | 760 if (Node* editableRoot = highestEditableRoot(c.deepEquivalent())) { |
761 if (!editableRoot->contains(visPos.deepEquivalent().containerNode())
) | 761 if (!editableRoot->contains(visPos.deepEquivalent().containerNode())
) |
762 return VisiblePosition(firstPositionInNode(editableRoot)); | 762 return VisiblePosition(firstPositionInNode(editableRoot)); |
763 } | 763 } |
764 } | 764 } |
765 | 765 |
766 return c.honorEditingBoundaryAtOrBefore(visPos); | 766 return c.honorEditingBoundaryAtOrBefore(visPos); |
767 } | 767 } |
768 | 768 |
| 769 bool isStartOfWordASpace(const VisiblePosition& visiblePosition) |
| 770 { |
| 771 if (visiblePosition.isNull()) |
| 772 return false; |
| 773 |
| 774 Position position = visiblePosition.deepEquivalent(); |
| 775 Node* node = position.anchorNode(); |
| 776 Document& document = node->document(); |
| 777 |
| 778 if (!document.documentElement()) |
| 779 return false; |
| 780 |
| 781 Node* boundary = node->enclosingBlockFlowElement(); |
| 782 if (!boundary) |
| 783 return false; |
| 784 |
| 785 RefPtr<Range> searchRange(document.createRange()); |
| 786 Position start(position.parentAnchoredEquivalent()); |
| 787 TrackExceptionState exceptionState; |
| 788 |
| 789 searchRange->selectNodeContents(boundary, exceptionState); |
| 790 if (exceptionState.hadException()) |
| 791 return false; |
| 792 |
| 793 searchRange->setStart(start.anchorNode(), start.deprecatedEditingOffset(), e
xceptionState); |
| 794 if (exceptionState.hadException()) |
| 795 return false; |
| 796 |
| 797 TextIterator it(searchRange.get(), TextIteratorEmitsCharactersBetweenAllVisi
blePositions); |
| 798 return it.length() ? isASCIISpace(it.characterAt(0)) : false; |
| 799 } |
| 800 |
769 // FIXME: Rename this function to reflect the fact it ignores bidi levels. | 801 // FIXME: Rename this function to reflect the fact it ignores bidi levels. |
770 VisiblePosition startOfLine(const VisiblePosition& currentPosition) | 802 VisiblePosition startOfLine(const VisiblePosition& currentPosition) |
771 { | 803 { |
772 return startOfLine(currentPosition, UseInlineBoxOrdering); | 804 return startOfLine(currentPosition, UseInlineBoxOrdering); |
773 } | 805 } |
774 | 806 |
775 VisiblePosition logicalStartOfLine(const VisiblePosition& currentPosition) | 807 VisiblePosition logicalStartOfLine(const VisiblePosition& currentPosition) |
776 { | 808 { |
777 return startOfLine(currentPosition, UseLogicalOrdering); | 809 return startOfLine(currentPosition, UseLogicalOrdering); |
778 } | 810 } |
(...skipping 607 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1386 { | 1418 { |
1387 return direction == LTR ? logicalStartOfLine(c) : logicalEndOfLine(c); | 1419 return direction == LTR ? logicalStartOfLine(c) : logicalEndOfLine(c); |
1388 } | 1420 } |
1389 | 1421 |
1390 VisiblePosition rightBoundaryOfLine(const VisiblePosition& c, TextDirection dire
ction) | 1422 VisiblePosition rightBoundaryOfLine(const VisiblePosition& c, TextDirection dire
ction) |
1391 { | 1423 { |
1392 return direction == LTR ? logicalEndOfLine(c) : logicalStartOfLine(c); | 1424 return direction == LTR ? logicalEndOfLine(c) : logicalStartOfLine(c); |
1393 } | 1425 } |
1394 | 1426 |
1395 } | 1427 } |
OLD | NEW |