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 654 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
665 VisiblePosition startOfWord(const VisiblePosition& c, EWordSide side) | 665 VisiblePosition startOfWord(const VisiblePosition& c, EWordSide side) |
666 { | 666 { |
667 // FIXME: This returns a null VP for c at the start of the document | 667 // FIXME: This returns a null VP for c at the start of the document |
668 // and side == LeftWordIfOnBoundary | 668 // and side == LeftWordIfOnBoundary |
669 VisiblePosition p = c; | 669 VisiblePosition p = c; |
670 if (side == RightWordIfOnBoundary) { | 670 if (side == RightWordIfOnBoundary) { |
671 // at paragraph end, the startofWord is the current position | 671 // at paragraph end, the startofWord is the current position |
672 if (isEndOfParagraph(c)) | 672 if (isEndOfParagraph(c)) |
673 return c; | 673 return c; |
674 | 674 |
675 p = c.next(); | 675 p = nextPositionOf(c); |
676 if (p.isNull()) | 676 if (p.isNull()) |
677 return c; | 677 return c; |
678 } | 678 } |
679 return previousBoundary(p, startWordBoundary); | 679 return previousBoundary(p, startWordBoundary); |
680 } | 680 } |
681 | 681 |
682 static unsigned endWordBoundary(const UChar* characters, unsigned length, unsign
ed offset, BoundarySearchContextAvailability mayHaveMoreContext, bool& needMoreC
ontext) | 682 static unsigned endWordBoundary(const UChar* characters, unsigned length, unsign
ed offset, BoundarySearchContextAvailability mayHaveMoreContext, bool& needMoreC
ontext) |
683 { | 683 { |
684 ASSERT(offset <= length); | 684 ASSERT(offset <= length); |
685 if (mayHaveMoreContext && endOfFirstWordBoundaryContext(characters + offset,
length - offset) == static_cast<int>(length - offset)) { | 685 if (mayHaveMoreContext && endOfFirstWordBoundaryContext(characters + offset,
length - offset) == static_cast<int>(length - offset)) { |
(...skipping 613 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1299 if (type == PositionAnchorType::OffsetInAnchor) | 1299 if (type == PositionAnchorType::OffsetInAnchor) |
1300 return VisiblePosition(Position(node, offset)); | 1300 return VisiblePosition(Position(node, offset)); |
1301 | 1301 |
1302 return VisiblePosition(Position(node, type)); | 1302 return VisiblePosition(Position(node, type)); |
1303 } | 1303 } |
1304 | 1304 |
1305 // FIXME: isStartOfParagraph(startOfNextParagraph(pos)) is not always true | 1305 // FIXME: isStartOfParagraph(startOfNextParagraph(pos)) is not always true |
1306 VisiblePosition startOfNextParagraph(const VisiblePosition& visiblePosition) | 1306 VisiblePosition startOfNextParagraph(const VisiblePosition& visiblePosition) |
1307 { | 1307 { |
1308 VisiblePosition paragraphEnd(endOfParagraph(visiblePosition, CanSkipOverEdit
ingBoundary)); | 1308 VisiblePosition paragraphEnd(endOfParagraph(visiblePosition, CanSkipOverEdit
ingBoundary)); |
1309 VisiblePosition afterParagraphEnd(paragraphEnd.next(CannotCrossEditingBounda
ry)); | 1309 VisiblePosition afterParagraphEnd(nextPositionOf(paragraphEnd, CannotCrossEd
itingBoundary)); |
1310 // The position after the last position in the last cell of a table | 1310 // The position after the last position in the last cell of a table |
1311 // is not the start of the next paragraph. | 1311 // is not the start of the next paragraph. |
1312 if (isFirstPositionAfterTable(afterParagraphEnd)) | 1312 if (isFirstPositionAfterTable(afterParagraphEnd)) |
1313 return afterParagraphEnd.next(CannotCrossEditingBoundary); | 1313 return nextPositionOf(afterParagraphEnd, CannotCrossEditingBoundary); |
1314 return afterParagraphEnd; | 1314 return afterParagraphEnd; |
1315 } | 1315 } |
1316 | 1316 |
1317 bool inSameParagraph(const VisiblePosition& a, const VisiblePosition& b, Editing
BoundaryCrossingRule boundaryCrossingRule) | 1317 bool inSameParagraph(const VisiblePosition& a, const VisiblePosition& b, Editing
BoundaryCrossingRule boundaryCrossingRule) |
1318 { | 1318 { |
1319 return a.isNotNull() && startOfParagraph(a, boundaryCrossingRule).deepEquiva
lent() == startOfParagraph(b, boundaryCrossingRule).deepEquivalent(); | 1319 return a.isNotNull() && startOfParagraph(a, boundaryCrossingRule).deepEquiva
lent() == startOfParagraph(b, boundaryCrossingRule).deepEquivalent(); |
1320 } | 1320 } |
1321 | 1321 |
1322 bool isStartOfParagraph(const VisiblePosition& pos, EditingBoundaryCrossingRule
boundaryCrossingRule) | 1322 bool isStartOfParagraph(const VisiblePosition& pos, EditingBoundaryCrossingRule
boundaryCrossingRule) |
1323 { | 1323 { |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1413 return endOfDocument(c.deepEquivalent().anchorNode()); | 1413 return endOfDocument(c.deepEquivalent().anchorNode()); |
1414 } | 1414 } |
1415 | 1415 |
1416 bool isStartOfDocument(const VisiblePosition& p) | 1416 bool isStartOfDocument(const VisiblePosition& p) |
1417 { | 1417 { |
1418 return p.isNotNull() && previousPositionOf(p, CanCrossEditingBoundary).isNul
l(); | 1418 return p.isNotNull() && previousPositionOf(p, CanCrossEditingBoundary).isNul
l(); |
1419 } | 1419 } |
1420 | 1420 |
1421 bool isEndOfDocument(const VisiblePosition& p) | 1421 bool isEndOfDocument(const VisiblePosition& p) |
1422 { | 1422 { |
1423 return p.isNotNull() && p.next(CanCrossEditingBoundary).isNull(); | 1423 return p.isNotNull() && nextPositionOf(p, CanCrossEditingBoundary).isNull(); |
1424 } | 1424 } |
1425 | 1425 |
1426 // --------- | 1426 // --------- |
1427 | 1427 |
1428 VisiblePosition startOfEditableContent(const VisiblePosition& visiblePosition) | 1428 VisiblePosition startOfEditableContent(const VisiblePosition& visiblePosition) |
1429 { | 1429 { |
1430 ContainerNode* highestRoot = highestEditableRoot(visiblePosition.deepEquival
ent()); | 1430 ContainerNode* highestRoot = highestEditableRoot(visiblePosition.deepEquival
ent()); |
1431 if (!highestRoot) | 1431 if (!highestRoot) |
1432 return VisiblePosition(); | 1432 return VisiblePosition(); |
1433 | 1433 |
1434 return VisiblePosition(firstPositionInNode(highestRoot)); | 1434 return VisiblePosition(firstPositionInNode(highestRoot)); |
1435 } | 1435 } |
1436 | 1436 |
1437 VisiblePosition endOfEditableContent(const VisiblePosition& visiblePosition) | 1437 VisiblePosition endOfEditableContent(const VisiblePosition& visiblePosition) |
1438 { | 1438 { |
1439 ContainerNode* highestRoot = highestEditableRoot(visiblePosition.deepEquival
ent()); | 1439 ContainerNode* highestRoot = highestEditableRoot(visiblePosition.deepEquival
ent()); |
1440 if (!highestRoot) | 1440 if (!highestRoot) |
1441 return VisiblePosition(); | 1441 return VisiblePosition(); |
1442 | 1442 |
1443 return VisiblePosition(lastPositionInNode(highestRoot)); | 1443 return VisiblePosition(lastPositionInNode(highestRoot)); |
1444 } | 1444 } |
1445 | 1445 |
1446 bool isEndOfEditableOrNonEditableContent(const VisiblePosition& p) | 1446 bool isEndOfEditableOrNonEditableContent(const VisiblePosition& p) |
1447 { | 1447 { |
1448 return p.isNotNull() && p.next().isNull(); | 1448 return p.isNotNull() && nextPositionOf(p).isNull(); |
1449 } | 1449 } |
1450 | 1450 |
1451 VisiblePosition leftBoundaryOfLine(const VisiblePosition& c, TextDirection direc
tion) | 1451 VisiblePosition leftBoundaryOfLine(const VisiblePosition& c, TextDirection direc
tion) |
1452 { | 1452 { |
1453 return direction == LTR ? logicalStartOfLine(c) : logicalEndOfLine(c); | 1453 return direction == LTR ? logicalStartOfLine(c) : logicalEndOfLine(c); |
1454 } | 1454 } |
1455 | 1455 |
1456 VisiblePosition rightBoundaryOfLine(const VisiblePosition& c, TextDirection dire
ction) | 1456 VisiblePosition rightBoundaryOfLine(const VisiblePosition& c, TextDirection dire
ction) |
1457 { | 1457 { |
1458 return direction == LTR ? logicalEndOfLine(c) : logicalStartOfLine(c); | 1458 return direction == LTR ? logicalEndOfLine(c) : logicalStartOfLine(c); |
(...skipping 872 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2331 { | 2331 { |
2332 return isVisuallyEquivalentCandidateAlgorithm<EditingStrategy>(position); | 2332 return isVisuallyEquivalentCandidateAlgorithm<EditingStrategy>(position); |
2333 } | 2333 } |
2334 | 2334 |
2335 bool isVisuallyEquivalentCandidate(const PositionInComposedTree& position) | 2335 bool isVisuallyEquivalentCandidate(const PositionInComposedTree& position) |
2336 { | 2336 { |
2337 return isVisuallyEquivalentCandidateAlgorithm<EditingInComposedTreeStrategy>
(position); | 2337 return isVisuallyEquivalentCandidateAlgorithm<EditingInComposedTreeStrategy>
(position); |
2338 } | 2338 } |
2339 | 2339 |
2340 } // namespace blink | 2340 } // namespace blink |
OLD | NEW |