| 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/render_text.h" | 5 #include "ui/gfx/render_text.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <climits> | 8 #include <climits> |
| 9 | 9 |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 405 SkTypeface::Style skia_style = ConvertFontStyleToSkiaTypefaceStyle(style); | 405 SkTypeface::Style skia_style = ConvertFontStyleToSkiaTypefaceStyle(style); |
| 406 return skia::AdoptRef(SkTypeface::CreateFromName(family.c_str(), skia_style)); | 406 return skia::AdoptRef(SkTypeface::CreateFromName(family.c_str(), skia_style)); |
| 407 } | 407 } |
| 408 | 408 |
| 409 } // namespace internal | 409 } // namespace internal |
| 410 | 410 |
| 411 RenderText::~RenderText() { | 411 RenderText::~RenderText() { |
| 412 } | 412 } |
| 413 | 413 |
| 414 RenderText* RenderText::CreateInstance() { | 414 RenderText* RenderText::CreateInstance() { |
| 415 #if defined(OS_MACOSX) && defined(TOOLKIT_VIEWS) |
| 416 // Use the more complete HarfBuzz implementation for Views controls on Mac. |
| 417 return new RenderTextHarfBuzz; |
| 418 #else |
| 415 if (CommandLine::ForCurrentProcess()->HasSwitch( | 419 if (CommandLine::ForCurrentProcess()->HasSwitch( |
| 416 switches::kEnableHarfBuzzRenderText)) { | 420 switches::kEnableHarfBuzzRenderText)) { |
| 417 return new RenderTextHarfBuzz; | 421 return new RenderTextHarfBuzz; |
| 418 } | 422 } |
| 419 return CreateNativeInstance(); | 423 return CreateNativeInstance(); |
| 424 #endif |
| 420 } | 425 } |
| 421 | 426 |
| 422 void RenderText::SetText(const base::string16& text) { | 427 void RenderText::SetText(const base::string16& text) { |
| 423 DCHECK(!composition_range_.IsValid()); | 428 DCHECK(!composition_range_.IsValid()); |
| 424 if (text_ == text) | 429 if (text_ == text) |
| 425 return; | 430 return; |
| 426 text_ = text; | 431 text_ = text; |
| 427 | 432 |
| 428 // Adjust ranged styles and colors to accommodate a new text length. | 433 // Adjust ranged styles and colors to accommodate a new text length. |
| 429 const size_t text_length = text_.length(); | 434 const size_t text_length = text_.length(); |
| (...skipping 900 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1330 cursor_bounds_ += delta_offset; | 1335 cursor_bounds_ += delta_offset; |
| 1331 } | 1336 } |
| 1332 | 1337 |
| 1333 void RenderText::DrawSelection(Canvas* canvas) { | 1338 void RenderText::DrawSelection(Canvas* canvas) { |
| 1334 const std::vector<Rect> sel = GetSubstringBounds(selection()); | 1339 const std::vector<Rect> sel = GetSubstringBounds(selection()); |
| 1335 for (std::vector<Rect>::const_iterator i = sel.begin(); i < sel.end(); ++i) | 1340 for (std::vector<Rect>::const_iterator i = sel.begin(); i < sel.end(); ++i) |
| 1336 canvas->FillRect(*i, selection_background_focused_color_); | 1341 canvas->FillRect(*i, selection_background_focused_color_); |
| 1337 } | 1342 } |
| 1338 | 1343 |
| 1339 } // namespace gfx | 1344 } // namespace gfx |
| OLD | NEW |