| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ui/gfx/canvas.h" | 5 #include "ui/gfx/canvas.h" |
| 6 | 6 |
| 7 #include "base/i18n/rtl.h" | 7 #include "base/i18n/rtl.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "ui/gfx/font_list.h" | 10 #include "ui/gfx/font_list.h" |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 UpdateRenderText(rect, base::string16(), font_list, flags, 0, | 184 UpdateRenderText(rect, base::string16(), font_list, flags, 0, |
| 185 render_text.get()); | 185 render_text.get()); |
| 186 | 186 |
| 187 float h = 0; | 187 float h = 0; |
| 188 float w = 0; | 188 float w = 0; |
| 189 for (size_t i = 0; i < strings.size(); ++i) { | 189 for (size_t i = 0; i < strings.size(); ++i) { |
| 190 StripAcceleratorChars(flags, &strings[i]); | 190 StripAcceleratorChars(flags, &strings[i]); |
| 191 render_text->SetText(strings[i]); | 191 render_text->SetText(strings[i]); |
| 192 const SizeF& string_size = render_text->GetStringSizeF(); | 192 const SizeF& string_size = render_text->GetStringSizeF(); |
| 193 w = std::max(w, string_size.width()); | 193 w = std::max(w, string_size.width()); |
| 194 h += (i > 0 && line_height > 0) ? line_height : string_size.height(); | 194 h += (i > 0 && line_height > 0) ? |
| 195 std::max(static_cast<float>(line_height), string_size.height()) |
| 196 : string_size.height(); |
| 195 } | 197 } |
| 196 *width = w; | 198 *width = w; |
| 197 *height = h; | 199 *height = h; |
| 198 } else { | 200 } else { |
| 199 // If the string is too long, the call by |RenderTextWin| to |ScriptShape()| | 201 // If the string is too long, the call by |RenderTextWin| to |ScriptShape()| |
| 200 // will inexplicably fail with result E_INVALIDARG. Guard against this. | 202 // will inexplicably fail with result E_INVALIDARG. Guard against this. |
| 201 const size_t kMaxRenderTextLength = 5000; | 203 const size_t kMaxRenderTextLength = 5000; |
| 202 if (adjusted_text.length() >= kMaxRenderTextLength) { | 204 if (adjusted_text.length() >= kMaxRenderTextLength) { |
| 203 *width = static_cast<float>( | 205 *width = static_cast<float>( |
| 204 font_list.GetExpectedTextWidth(adjusted_text.length())); | 206 font_list.GetExpectedTextWidth(adjusted_text.length())); |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 393 UpdateRenderText(rect, text, font_list, flags, color, render_text.get()); | 395 UpdateRenderText(rect, text, font_list, flags, color, render_text.get()); |
| 394 render_text->SetElideBehavior(FADE_TAIL); | 396 render_text->SetElideBehavior(FADE_TAIL); |
| 395 | 397 |
| 396 canvas_->save(); | 398 canvas_->save(); |
| 397 ClipRect(display_rect); | 399 ClipRect(display_rect); |
| 398 render_text->Draw(this); | 400 render_text->Draw(this); |
| 399 canvas_->restore(); | 401 canvas_->restore(); |
| 400 } | 402 } |
| 401 | 403 |
| 402 } // namespace gfx | 404 } // namespace gfx |
| OLD | NEW |