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

Side by Side Diff: Source/core/rendering/AbstractInlineTextBox.cpp

Issue 542553002: Fix crash when trying to iterate over words in an inline text box of length zero. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 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 | Annotate | Revision Log
« no previous file with comments | « LayoutTests/accessibility/inline-text-word-boundary-causes-crash-expected.txt ('k') | no next file » | 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) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google 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 are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * 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 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 m_inlineTextBox->characterWidths(widths); 124 m_inlineTextBox->characterWidths(widths);
125 } 125 }
126 126
127 void AbstractInlineTextBox::wordBoundaries(Vector<WordBoundaries>& words) const 127 void AbstractInlineTextBox::wordBoundaries(Vector<WordBoundaries>& words) const
128 { 128 {
129 if (!m_inlineTextBox) 129 if (!m_inlineTextBox)
130 return; 130 return;
131 131
132 String text = this->text(); 132 String text = this->text();
133 int len = text.length(); 133 int len = text.length();
134 if (!len)
eseidel 2014/09/04 16:39:49 Should this be moved to after wordBreakIterator if
dmazzoni 2014/09/04 16:46:57 Sure. I was torn between catching the actual crash
135 return;
136
134 TextBreakIterator* iterator = wordBreakIterator(text, 0, len); 137 TextBreakIterator* iterator = wordBreakIterator(text, 0, len);
135 int pos = iterator->first(); 138 int pos = iterator->first();
136 while (pos >= 0 && pos < len) { 139 while (pos >= 0 && pos < len) {
137 int next = iterator->next(); 140 int next = iterator->next();
138 if (isWordTextBreak(iterator)) 141 if (isWordTextBreak(iterator))
139 words.append(WordBoundaries(pos, next)); 142 words.append(WordBoundaries(pos, next));
140 pos = next; 143 pos = next;
141 } 144 }
142 } 145 }
143 146
(...skipping 11 matching lines...) Expand all
155 return plainText(range.get(), TextIteratorIgnoresStyleVisibility); 158 return plainText(range.get(), TextIteratorIgnoresStyleVisibility);
156 } 159 }
157 160
158 String result = m_renderText->text().substring(start, len).simplifyWhiteSpac e(WTF::DoNotStripWhiteSpace); 161 String result = m_renderText->text().substring(start, len).simplifyWhiteSpac e(WTF::DoNotStripWhiteSpace);
159 if (m_inlineTextBox->nextTextBox() && m_inlineTextBox->nextTextBox()->start( ) > m_inlineTextBox->end() && result.length() && !result.right(1).containsOnlyWh itespace()) 162 if (m_inlineTextBox->nextTextBox() && m_inlineTextBox->nextTextBox()->start( ) > m_inlineTextBox->end() && result.length() && !result.right(1).containsOnlyWh itespace())
160 return result + " "; 163 return result + " ";
161 return result; 164 return result;
162 } 165 }
163 166
164 } // namespace blink 167 } // namespace blink
OLDNEW
« no previous file with comments | « LayoutTests/accessibility/inline-text-word-boundary-causes-crash-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698