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

Side by Side Diff: views/view_text_utils.cc

Issue 6609008: Change other usages of .size() to .empty() when applicable. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Peter nits Created 9 years, 9 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 | « views/view.cc ('k') | webkit/gpu/webgraphicscontext3d_in_process_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "views/view_text_utils.h" 5 #include "views/view_text_utils.h"
6 6
7 #include "base/i18n/bidi_line_iterator.h" 7 #include "base/i18n/bidi_line_iterator.h"
8 #include "base/i18n/break_iterator.h" 8 #include "base/i18n/break_iterator.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 &space_h, flags); 135 &space_h, flags);
136 x += space_w; 136 x += space_w;
137 } 137 }
138 } 138 }
139 int y = position->height() + bounds.y(); 139 int y = position->height() + bounds.y();
140 140
141 // Draw the text on the screen (mirrored, if RTL run). 141 // Draw the text on the screen (mirrored, if RTL run).
142 canvas->DrawStringInt(word, font, text_color, x, y, w, font.GetHeight(), 142 canvas->DrawStringInt(word, font, text_color, x, y, w, font.GetHeight(),
143 flags); 143 flags);
144 144
145 if (word.size() > 0 && word[word.size() - 1] == '\x0a') { 145 if (!word.empty() && word[word.size() - 1] == '\x0a') {
146 // When we come across '\n', we move to the beginning of the next line. 146 // When we come across '\n', we move to the beginning of the next line.
147 position->set_width(0); 147 position->set_width(0);
148 position->Enlarge(0, font.GetHeight()); 148 position->Enlarge(0, font.GetHeight());
149 } else { 149 } else {
150 // Otherwise, we advance position to the next word. 150 // Otherwise, we advance position to the next word.
151 position->Enlarge(w, 0); 151 position->Enlarge(w, 0);
152 } 152 }
153 153
154 if (ltr_within_rtl) 154 if (ltr_within_rtl)
155 break; // LTR within RTL is drawn as one unit, so we are done. 155 break; // LTR within RTL is drawn as one unit, so we are done.
156 } 156 }
157 } 157 }
158 158
159 void WrapIfWordDoesntFit(int word_width, 159 void WrapIfWordDoesntFit(int word_width,
160 int font_height, 160 int font_height,
161 gfx::Size* position, 161 gfx::Size* position,
162 const gfx::Rect& bounds) { 162 const gfx::Rect& bounds) {
163 if (position->width() + word_width > bounds.right()) { 163 if (position->width() + word_width > bounds.right()) {
164 position->set_width(0); 164 position->set_width(0);
165 position->Enlarge(0, font_height); 165 position->Enlarge(0, font_height);
166 } 166 }
167 } 167 }
168 168
169 } // namespace view_text_utils 169 } // namespace view_text_utils
OLDNEW
« no previous file with comments | « views/view.cc ('k') | webkit/gpu/webgraphicscontext3d_in_process_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698