| 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 return CommandLine::ForCurrentProcess()->HasSwitch( | 401 #if defined(OS_MACOSX) && !defined(TOOLKIT_VIEWS) |
| 402 switches::kDisableHarfBuzzRenderText) ? CreateNativeInstance() : | 402 static const bool use_harfbuzz = CommandLine::ForCurrentProcess()-> |
| 403 new RenderTextHarfBuzz; | 403 HasSwitch(switches::kEnableHarfBuzzRenderText); |
| 404 #else |
| 405 static const bool use_harfbuzz = !CommandLine::ForCurrentProcess()-> |
| 406 HasSwitch(switches::kDisableHarfBuzzRenderText); |
| 407 #endif |
| 408 return use_harfbuzz ? new RenderTextHarfBuzz : CreateNativeInstance(); |
| 404 } | 409 } |
| 405 | 410 |
| 406 void RenderText::SetText(const base::string16& text) { | 411 void RenderText::SetText(const base::string16& text) { |
| 407 DCHECK(!composition_range_.IsValid()); | 412 DCHECK(!composition_range_.IsValid()); |
| 408 if (text_ == text) | 413 if (text_ == text) |
| 409 return; | 414 return; |
| 410 text_ = text; | 415 text_ = text; |
| 411 | 416 |
| 412 // Adjust ranged styles and colors to accommodate a new text length. | 417 // Adjust ranged styles and colors to accommodate a new text length. |
| 413 // Clear style ranges as they might break new text graphemes and apply | 418 // 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); | 1403 SetDisplayOffset(display_offset_.x() + delta_x); |
| 1399 } | 1404 } |
| 1400 | 1405 |
| 1401 void RenderText::DrawSelection(Canvas* canvas) { | 1406 void RenderText::DrawSelection(Canvas* canvas) { |
| 1402 const std::vector<Rect> sel = GetSubstringBounds(selection()); | 1407 const std::vector<Rect> sel = GetSubstringBounds(selection()); |
| 1403 for (std::vector<Rect>::const_iterator i = sel.begin(); i < sel.end(); ++i) | 1408 for (std::vector<Rect>::const_iterator i = sel.begin(); i < sel.end(); ++i) |
| 1404 canvas->FillRect(*i, selection_background_focused_color_); | 1409 canvas->FillRect(*i, selection_background_focused_color_); |
| 1405 } | 1410 } |
| 1406 | 1411 |
| 1407 } // namespace gfx | 1412 } // namespace gfx |
| OLD | NEW |