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

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: Got rid of assert, updated fixme 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 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 TextBreakIterator* iterator = wordBreakIterator(text, 0, len); 134 TextBreakIterator* iterator = wordBreakIterator(text, 0, len);
135
136 // FIXME: When http://crbug.com/411764 is fixed, replace this with an ASSERT .
137 if (!iterator)
138 return;
139
135 int pos = iterator->first(); 140 int pos = iterator->first();
136 while (pos >= 0 && pos < len) { 141 while (pos >= 0 && pos < len) {
137 int next = iterator->next(); 142 int next = iterator->next();
138 if (isWordTextBreak(iterator)) 143 if (isWordTextBreak(iterator))
139 words.append(WordBoundaries(pos, next)); 144 words.append(WordBoundaries(pos, next));
140 pos = next; 145 pos = next;
141 } 146 }
142 } 147 }
143 148
144 String AbstractInlineTextBox::text() const 149 String AbstractInlineTextBox::text() const
(...skipping 10 matching lines...) Expand all
155 return plainText(range.get(), TextIteratorIgnoresStyleVisibility); 160 return plainText(range.get(), TextIteratorIgnoresStyleVisibility);
156 } 161 }
157 162
158 String result = m_renderText->text().substring(start, len).simplifyWhiteSpac e(WTF::DoNotStripWhiteSpace); 163 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()) 164 if (m_inlineTextBox->nextTextBox() && m_inlineTextBox->nextTextBox()->start( ) > m_inlineTextBox->end() && result.length() && !result.right(1).containsOnlyWh itespace())
160 return result + " "; 165 return result + " ";
161 return result; 166 return result;
162 } 167 }
163 168
164 } // namespace blink 169 } // 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