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

Side by Side Diff: Source/platform/text/TextBoundaries.cpp

Issue 23618052: TextBreakIterator should use the C++ icu API instead of the C one (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Downcast to icu::RuleBasedBreakIterator Created 7 years, 2 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/rendering/break_lines.cpp ('k') | Source/platform/text/TextBreakIterator.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) 2006, 2007 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
3 * Copyright (C) 2009 Dominik Röttsches <dominik.roettsches@access-company.com> 3 * Copyright (C) 2009 Dominik Röttsches <dominik.roettsches@access-company.com>
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 return last; 58 return last;
59 } 59 }
60 return 0; 60 return 0;
61 } 61 }
62 62
63 int findNextWordFromIndex(const UChar* chars, int len, int position, bool forwar d) 63 int findNextWordFromIndex(const UChar* chars, int len, int position, bool forwar d)
64 { 64 {
65 TextBreakIterator* it = wordBreakIterator(chars, len); 65 TextBreakIterator* it = wordBreakIterator(chars, len);
66 66
67 if (forward) { 67 if (forward) {
68 position = textBreakFollowing(it, position); 68 position = it->following(position);
69 while (position != TextBreakDone) { 69 while (position != TextBreakDone) {
70 // We stop searching when the character preceeding the break 70 // We stop searching when the character preceeding the break
71 // is alphanumeric. 71 // is alphanumeric.
72 if (position < len && isAlphanumeric(chars[position - 1])) 72 if (position < len && isAlphanumeric(chars[position - 1]))
73 return position; 73 return position;
74 74
75 position = textBreakFollowing(it, position); 75 position = it->following(position);
76 } 76 }
77 77
78 return len; 78 return len;
79 } else { 79 } else {
80 position = textBreakPreceding(it, position); 80 position = it->preceding(position);
81 while (position != TextBreakDone) { 81 while (position != TextBreakDone) {
82 // We stop searching when the character following the break 82 // We stop searching when the character following the break
83 // is alphanumeric. 83 // is alphanumeric.
84 if (position > 0 && isAlphanumeric(chars[position])) 84 if (position > 0 && isAlphanumeric(chars[position]))
85 return position; 85 return position;
86 86
87 position = textBreakPreceding(it, position); 87 position = it->preceding(position);
88 } 88 }
89 89
90 return 0; 90 return 0;
91 } 91 }
92 } 92 }
93 93
94 void findWordBoundary(const UChar* chars, int len, int position, int* start, int * end) 94 void findWordBoundary(const UChar* chars, int len, int position, int* start, int * end)
95 { 95 {
96 TextBreakIterator* it = wordBreakIterator(chars, len); 96 TextBreakIterator* it = wordBreakIterator(chars, len);
97 *end = textBreakFollowing(it, position); 97 *end = it->following(position);
98 if (*end < 0) 98 if (*end < 0)
99 *end = textBreakLast(it); 99 *end = it->last();
100 *start = textBreakPrevious(it); 100 *start = it->previous();
101 } 101 }
102 102
103 103
104 } // namespace WebCore 104 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/rendering/break_lines.cpp ('k') | Source/platform/text/TextBreakIterator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698