Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(152)

Side by Side Diff: Source/core/editing/VisibleSelection.cpp

Issue 1307803003: Introduce nextPositionOf() for VisiblePosition (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: 2015-08-28T18:13:02 Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Source/core/editing/VisiblePosition.cpp ('k') | Source/core/editing/VisibleUnits.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc. All rights reserved. 2 * Copyright (C) 2004, 2005, 2006 Apple Computer, 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 461 matching lines...) Expand 10 before | Expand all | Expand 10 after
472 EWordSide side = wordSide; 472 EWordSide side = wordSide;
473 if (isEndOfEditableOrNonEditableContent(originalEnd) || (isEndOfLine(ori ginalEnd) && !isStartOfLine(originalEnd) && !isEndOfParagraph(originalEnd))) 473 if (isEndOfEditableOrNonEditableContent(originalEnd) || (isEndOfLine(ori ginalEnd) && !isStartOfLine(originalEnd) && !isEndOfParagraph(originalEnd)))
474 side = LeftWordIfOnBoundary; 474 side = LeftWordIfOnBoundary;
475 475
476 VisiblePosition wordEnd(endOfWord(originalEnd, side)); 476 VisiblePosition wordEnd(endOfWord(originalEnd, side));
477 VisiblePosition end(wordEnd); 477 VisiblePosition end(wordEnd);
478 478
479 if (isEndOfParagraph(originalEnd) && !isEmptyTableCell(m_start.anchorNod e())) { 479 if (isEndOfParagraph(originalEnd) && !isEmptyTableCell(m_start.anchorNod e())) {
480 // Select the paragraph break (the space from the end of a paragraph to the start of 480 // Select the paragraph break (the space from the end of a paragraph to the start of
481 // the next one) to match TextEdit. 481 // the next one) to match TextEdit.
482 end = wordEnd.next(); 482 end = nextPositionOf(wordEnd);
483 483
484 if (Element* table = isFirstPositionAfterTable(end)) { 484 if (Element* table = isFirstPositionAfterTable(end)) {
485 // The paragraph break after the last paragraph in the last cell of a block table ends 485 // The paragraph break after the last paragraph in the last cell of a block table ends
486 // at the start of the paragraph after the table. 486 // at the start of the paragraph after the table.
487 if (isEnclosingBlock(table)) 487 if (isEnclosingBlock(table))
488 end = end.next(CannotCrossEditingBoundary); 488 end = nextPositionOf(end, CannotCrossEditingBoundary);
489 else 489 else
490 end = wordEnd; 490 end = wordEnd;
491 } 491 }
492 492
493 if (end.isNull()) 493 if (end.isNull())
494 end = wordEnd; 494 end = wordEnd;
495 495
496 } 496 }
497 497
498 m_end = end.deepEquivalent(); 498 m_end = end.deepEquivalent();
499 break; 499 break;
500 } 500 }
501 case SentenceGranularity: { 501 case SentenceGranularity: {
502 m_end = endOfSentence(VisiblePosition(m_end, m_affinity)).deepEquivalent (); 502 m_end = endOfSentence(VisiblePosition(m_end, m_affinity)).deepEquivalent ();
503 break; 503 break;
504 } 504 }
505 case LineGranularity: { 505 case LineGranularity: {
506 VisiblePosition end = endOfLine(VisiblePosition(m_end, m_affinity)); 506 VisiblePosition end = endOfLine(VisiblePosition(m_end, m_affinity));
507 // If the end of this line is at the end of a paragraph, include the spa ce 507 // If the end of this line is at the end of a paragraph, include the spa ce
508 // after the end of the line in the selection. 508 // after the end of the line in the selection.
509 if (isEndOfParagraph(end)) { 509 if (isEndOfParagraph(end)) {
510 VisiblePosition next = end.next(); 510 VisiblePosition next = nextPositionOf(end);
511 if (next.isNotNull()) 511 if (next.isNotNull())
512 end = next; 512 end = next;
513 } 513 }
514 m_end = end.deepEquivalent(); 514 m_end = end.deepEquivalent();
515 break; 515 break;
516 } 516 }
517 case LineBoundary: 517 case LineBoundary:
518 m_end = endOfLine(VisiblePosition(m_end, m_affinity)).deepEquivalent(); 518 m_end = endOfLine(VisiblePosition(m_end, m_affinity)).deepEquivalent();
519 break; 519 break;
520 case ParagraphGranularity: { 520 case ParagraphGranularity: {
521 VisiblePosition visibleParagraphEnd = endOfParagraph(VisiblePosition(m_e nd, m_affinity)); 521 VisiblePosition visibleParagraphEnd = endOfParagraph(VisiblePosition(m_e nd, m_affinity));
522 522
523 // Include the "paragraph break" (the space from the end of this paragra ph to the start 523 // Include the "paragraph break" (the space from the end of this paragra ph to the start
524 // of the next one) in the selection. 524 // of the next one) in the selection.
525 VisiblePosition end(visibleParagraphEnd.next()); 525 VisiblePosition end(nextPositionOf(visibleParagraphEnd));
526 526
527 if (Element* table = isFirstPositionAfterTable(end)) { 527 if (Element* table = isFirstPositionAfterTable(end)) {
528 // The paragraph break after the last paragraph in the last cell of a block table ends 528 // The paragraph break after the last paragraph in the last cell of a block table ends
529 // at the start of the paragraph after the table, not at the positio n just after the table. 529 // at the start of the paragraph after the table, not at the positio n just after the table.
530 if (isEnclosingBlock(table)) 530 if (isEnclosingBlock(table))
531 end = end.next(CannotCrossEditingBoundary); 531 end = nextPositionOf(end, CannotCrossEditingBoundary);
532 // There is no parargraph break after the last paragraph in the last cell of an inline table. 532 // There is no parargraph break after the last paragraph in the last cell of an inline table.
533 else 533 else
534 end = visibleParagraphEnd; 534 end = visibleParagraphEnd;
535 } 535 }
536 536
537 if (end.isNull()) 537 if (end.isNull())
538 end = visibleParagraphEnd; 538 end = visibleParagraphEnd;
539 539
540 m_end = end.deepEquivalent(); 540 m_end = end.deepEquivalent();
541 break; 541 break;
(...skipping 705 matching lines...) Expand 10 before | Expand all | Expand 10 after
1247 sel.showTreeForThis(); 1247 sel.showTreeForThis();
1248 } 1248 }
1249 1249
1250 void showTree(const blink::VisibleSelection* sel) 1250 void showTree(const blink::VisibleSelection* sel)
1251 { 1251 {
1252 if (sel) 1252 if (sel)
1253 sel->showTreeForThis(); 1253 sel->showTreeForThis();
1254 } 1254 }
1255 1255
1256 #endif 1256 #endif
OLDNEW
« no previous file with comments | « Source/core/editing/VisiblePosition.cpp ('k') | Source/core/editing/VisibleUnits.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698