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 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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) | 401 #if defined(OS_MACOSX) |
402 static const bool use_harfbuzz = CommandLine::ForCurrentProcess()-> | 402 static const bool use_harfbuzz = |
403 HasSwitch(switches::kEnableHarfBuzzRenderText); | 403 base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 404 switches::kEnableHarfBuzzRenderText); |
404 #else | 405 #else |
405 static const bool use_harfbuzz = !CommandLine::ForCurrentProcess()-> | 406 static const bool use_harfbuzz = |
406 HasSwitch(switches::kDisableHarfBuzzRenderText); | 407 !base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 408 switches::kDisableHarfBuzzRenderText); |
407 #endif | 409 #endif |
408 return use_harfbuzz ? new RenderTextHarfBuzz : CreateNativeInstance(); | 410 return use_harfbuzz ? new RenderTextHarfBuzz : CreateNativeInstance(); |
409 } | 411 } |
410 | 412 |
411 RenderText* RenderText::CreateInstanceForEditing() { | 413 RenderText* RenderText::CreateInstanceForEditing() { |
412 static const bool use_harfbuzz = !CommandLine::ForCurrentProcess()-> | 414 static const bool use_harfbuzz = |
413 HasSwitch(switches::kDisableHarfBuzzRenderText); | 415 !base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 416 switches::kDisableHarfBuzzRenderText); |
414 return use_harfbuzz ? new RenderTextHarfBuzz : CreateNativeInstance(); | 417 return use_harfbuzz ? new RenderTextHarfBuzz : CreateNativeInstance(); |
415 } | 418 } |
416 | 419 |
417 void RenderText::SetText(const base::string16& text) { | 420 void RenderText::SetText(const base::string16& text) { |
418 DCHECK(!composition_range_.IsValid()); | 421 DCHECK(!composition_range_.IsValid()); |
419 if (text_ == text) | 422 if (text_ == text) |
420 return; | 423 return; |
421 text_ = text; | 424 text_ = text; |
422 | 425 |
423 // Adjust ranged styles and colors to accommodate a new text length. | 426 // Adjust ranged styles and colors to accommodate a new text length. |
(...skipping 989 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1413 SetDisplayOffset(display_offset_.x() + delta_x); | 1416 SetDisplayOffset(display_offset_.x() + delta_x); |
1414 } | 1417 } |
1415 | 1418 |
1416 void RenderText::DrawSelection(Canvas* canvas) { | 1419 void RenderText::DrawSelection(Canvas* canvas) { |
1417 const std::vector<Rect> sel = GetSubstringBounds(selection()); | 1420 const std::vector<Rect> sel = GetSubstringBounds(selection()); |
1418 for (std::vector<Rect>::const_iterator i = sel.begin(); i < sel.end(); ++i) | 1421 for (std::vector<Rect>::const_iterator i = sel.begin(); i < sel.end(); ++i) |
1419 canvas->FillRect(*i, selection_background_focused_color_); | 1422 canvas->FillRect(*i, selection_background_focused_color_); |
1420 } | 1423 } |
1421 | 1424 |
1422 } // namespace gfx | 1425 } // namespace gfx |
OLD | NEW |