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

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

Issue 268363016: Improve the find word boundary performance (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Add findWordEndBoundary Created 6 years, 5 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 | « no previous file | Source/platform/text/TextBoundaries.h » ('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, 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 635 matching lines...) Expand 10 before | Expand all | Expand 10 after
646 } 646 }
647 647
648 static unsigned endWordBoundary(const UChar* characters, unsigned length, unsign ed offset, BoundarySearchContextAvailability mayHaveMoreContext, bool& needMoreC ontext) 648 static unsigned endWordBoundary(const UChar* characters, unsigned length, unsign ed offset, BoundarySearchContextAvailability mayHaveMoreContext, bool& needMoreC ontext)
649 { 649 {
650 ASSERT(offset <= length); 650 ASSERT(offset <= length);
651 if (mayHaveMoreContext && endOfFirstWordBoundaryContext(characters + offset, length - offset) == static_cast<int>(length - offset)) { 651 if (mayHaveMoreContext && endOfFirstWordBoundaryContext(characters + offset, length - offset) == static_cast<int>(length - offset)) {
652 needMoreContext = true; 652 needMoreContext = true;
653 return length; 653 return length;
654 } 654 }
655 needMoreContext = false; 655 needMoreContext = false;
656 int start, end; 656 return findWordEndBoundary(characters, length, offset);
657 findWordBoundary(characters, length, offset, &start, &end);
658 return end;
659 } 657 }
660 658
661 VisiblePosition endOfWord(const VisiblePosition &c, EWordSide side) 659 VisiblePosition endOfWord(const VisiblePosition &c, EWordSide side)
662 { 660 {
663 VisiblePosition p = c; 661 VisiblePosition p = c;
664 if (side == LeftWordIfOnBoundary) { 662 if (side == LeftWordIfOnBoundary) {
665 if (isStartOfParagraph(c)) 663 if (isStartOfParagraph(c))
666 return c; 664 return c;
667 665
668 p = c.previous(); 666 p = c.previous();
(...skipping 713 matching lines...) Expand 10 before | Expand all | Expand 10 after
1382 { 1380 {
1383 return direction == LTR ? logicalStartOfLine(c) : logicalEndOfLine(c); 1381 return direction == LTR ? logicalStartOfLine(c) : logicalEndOfLine(c);
1384 } 1382 }
1385 1383
1386 VisiblePosition rightBoundaryOfLine(const VisiblePosition& c, TextDirection dire ction) 1384 VisiblePosition rightBoundaryOfLine(const VisiblePosition& c, TextDirection dire ction)
1387 { 1385 {
1388 return direction == LTR ? logicalEndOfLine(c) : logicalStartOfLine(c); 1386 return direction == LTR ? logicalEndOfLine(c) : logicalStartOfLine(c);
1389 } 1387 }
1390 1388
1391 } 1389 }
OLDNEW
« no previous file with comments | « no previous file | Source/platform/text/TextBoundaries.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698