Chromium Code Reviews| 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 // views::Textfield requires RenderTextHarfBuzz on Mac because RenderTextMac's | |
|
msw
2014/06/10 23:23:47
nit: Textfield is the heaviest user, but I'm plann
| |
| 417 // implementation is not complete. | |
| 418 return new RenderTextHarfBuzz; | |
| 419 #else | |
| 415 if (CommandLine::ForCurrentProcess()->HasSwitch( | 420 if (CommandLine::ForCurrentProcess()->HasSwitch( |
| 416 switches::kEnableHarfBuzzRenderText)) { | 421 switches::kEnableHarfBuzzRenderText)) { |
| 417 return new RenderTextHarfBuzz; | 422 return new RenderTextHarfBuzz; |
| 418 } | 423 } |
| 419 return CreateNativeInstance(); | 424 return CreateNativeInstance(); |
| 425 #endif | |
| 420 } | 426 } |
| 421 | 427 |
| 422 void RenderText::SetText(const base::string16& text) { | 428 void RenderText::SetText(const base::string16& text) { |
| 423 DCHECK(!composition_range_.IsValid()); | 429 DCHECK(!composition_range_.IsValid()); |
| 424 if (text_ == text) | 430 if (text_ == text) |
| 425 return; | 431 return; |
| 426 text_ = text; | 432 text_ = text; |
| 427 | 433 |
| 428 // Adjust ranged styles and colors to accommodate a new text length. | 434 // Adjust ranged styles and colors to accommodate a new text length. |
| 429 const size_t text_length = text_.length(); | 435 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; | 1336 cursor_bounds_ += delta_offset; |
| 1331 } | 1337 } |
| 1332 | 1338 |
| 1333 void RenderText::DrawSelection(Canvas* canvas) { | 1339 void RenderText::DrawSelection(Canvas* canvas) { |
| 1334 const std::vector<Rect> sel = GetSubstringBounds(selection()); | 1340 const std::vector<Rect> sel = GetSubstringBounds(selection()); |
| 1335 for (std::vector<Rect>::const_iterator i = sel.begin(); i < sel.end(); ++i) | 1341 for (std::vector<Rect>::const_iterator i = sel.begin(); i < sel.end(); ++i) |
| 1336 canvas->FillRect(*i, selection_background_focused_color_); | 1342 canvas->FillRect(*i, selection_background_focused_color_); |
| 1337 } | 1343 } |
| 1338 | 1344 |
| 1339 } // namespace gfx | 1345 } // namespace gfx |
| OLD | NEW |