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 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 391 paint->setAutohinted(params.autohinter); | 391 paint->setAutohinted(params.autohinter); |
| 392 paint->setHinting(FontRenderParamsHintingToSkPaintHinting(params.hinting)); | 392 paint->setHinting(FontRenderParamsHintingToSkPaintHinting(params.hinting)); |
| 393 } | 393 } |
| 394 | 394 |
| 395 } // namespace internal | 395 } // namespace internal |
| 396 | 396 |
| 397 RenderText::~RenderText() { | 397 RenderText::~RenderText() { |
| 398 } | 398 } |
| 399 | 399 |
| 400 RenderText* RenderText::CreateInstance() { | 400 RenderText* RenderText::CreateInstance() { |
| 401 #if defined(OS_MACOSX) && !defined(TOOLKIT_VIEWS) | |
| 402 return CreateNativeInstance(); | |
|
msw
2014/11/12 18:55:21
Allow HarfBuzz with switches::kEnableHarfBuzzRende
ckocagil
2014/11/12 19:23:01
Done.
| |
| 403 #else | |
| 401 return CommandLine::ForCurrentProcess()->HasSwitch( | 404 return CommandLine::ForCurrentProcess()->HasSwitch( |
|
msw
2014/11/12 18:55:21
optional nit: cache the command line value in a st
ckocagil
2014/11/12 19:23:01
Done.
| |
| 402 switches::kDisableHarfBuzzRenderText) ? CreateNativeInstance() : | 405 switches::kDisableHarfBuzzRenderText) ? CreateNativeInstance() : |
| 403 new RenderTextHarfBuzz; | 406 new RenderTextHarfBuzz; |
| 407 #endif | |
| 404 } | 408 } |
| 405 | 409 |
| 406 void RenderText::SetText(const base::string16& text) { | 410 void RenderText::SetText(const base::string16& text) { |
| 407 DCHECK(!composition_range_.IsValid()); | 411 DCHECK(!composition_range_.IsValid()); |
| 408 if (text_ == text) | 412 if (text_ == text) |
| 409 return; | 413 return; |
| 410 text_ = text; | 414 text_ = text; |
| 411 | 415 |
| 412 // Adjust ranged styles and colors to accommodate a new text length. | 416 // Adjust ranged styles and colors to accommodate a new text length. |
| 413 // Clear style ranges as they might break new text graphemes and apply | 417 // Clear style ranges as they might break new text graphemes and apply |
| (...skipping 984 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1398 SetDisplayOffset(display_offset_.x() + delta_x); | 1402 SetDisplayOffset(display_offset_.x() + delta_x); |
| 1399 } | 1403 } |
| 1400 | 1404 |
| 1401 void RenderText::DrawSelection(Canvas* canvas) { | 1405 void RenderText::DrawSelection(Canvas* canvas) { |
| 1402 const std::vector<Rect> sel = GetSubstringBounds(selection()); | 1406 const std::vector<Rect> sel = GetSubstringBounds(selection()); |
| 1403 for (std::vector<Rect>::const_iterator i = sel.begin(); i < sel.end(); ++i) | 1407 for (std::vector<Rect>::const_iterator i = sel.begin(); i < sel.end(); ++i) |
| 1404 canvas->FillRect(*i, selection_background_focused_color_); | 1408 canvas->FillRect(*i, selection_background_focused_color_); |
| 1405 } | 1409 } |
| 1406 | 1410 |
| 1407 } // namespace gfx | 1411 } // namespace gfx |
| OLD | NEW |