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 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
386 paint->setAutohinted(params.autohinter); | 386 paint->setAutohinted(params.autohinter); |
387 paint->setHinting(FontRenderParamsHintingToSkPaintHinting(params.hinting)); | 387 paint->setHinting(FontRenderParamsHintingToSkPaintHinting(params.hinting)); |
388 } | 388 } |
389 | 389 |
390 } // namespace internal | 390 } // namespace internal |
391 | 391 |
392 RenderText::~RenderText() { | 392 RenderText::~RenderText() { |
393 } | 393 } |
394 | 394 |
395 RenderText* RenderText::CreateInstance() { | 395 RenderText* RenderText::CreateInstance() { |
396 #if defined(OS_MACOSX) && defined(TOOLKIT_VIEWS) | |
397 // Use the more complete HarfBuzz implementation for Views controls on Mac. | |
398 return new RenderTextHarfBuzz; | |
399 #else | |
400 if (CommandLine::ForCurrentProcess()->HasSwitch( | 396 if (CommandLine::ForCurrentProcess()->HasSwitch( |
401 switches::kEnableHarfBuzzRenderText)) { | 397 switches::kEnableHarfBuzzRenderText)) { |
402 return new RenderTextHarfBuzz; | 398 return new RenderTextHarfBuzz; |
403 } | 399 } |
| 400 if (CommandLine::ForCurrentProcess()->HasSwitch( |
| 401 switches::kDisableHarfBuzzRenderText)) { |
| 402 return CreateNativeInstance(); |
| 403 } |
| 404 |
| 405 // Disable on Chrome OS. Blocked on http://crbug.com/423791 |
| 406 #if defined(OS_CHROMEOS) |
404 return CreateNativeInstance(); | 407 return CreateNativeInstance(); |
| 408 #else |
| 409 return new RenderTextHarfBuzz; |
405 #endif | 410 #endif |
406 } | 411 } |
407 | 412 |
408 void RenderText::SetText(const base::string16& text) { | 413 void RenderText::SetText(const base::string16& text) { |
409 DCHECK(!composition_range_.IsValid()); | 414 DCHECK(!composition_range_.IsValid()); |
410 if (text_ == text) | 415 if (text_ == text) |
411 return; | 416 return; |
412 text_ = text; | 417 text_ = text; |
413 | 418 |
414 // Adjust ranged styles and colors to accommodate a new text length. | 419 // Adjust ranged styles and colors to accommodate a new text length. |
(...skipping 966 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1381 SetDisplayOffset(display_offset_.x() + delta_x); | 1386 SetDisplayOffset(display_offset_.x() + delta_x); |
1382 } | 1387 } |
1383 | 1388 |
1384 void RenderText::DrawSelection(Canvas* canvas) { | 1389 void RenderText::DrawSelection(Canvas* canvas) { |
1385 const std::vector<Rect> sel = GetSubstringBounds(selection()); | 1390 const std::vector<Rect> sel = GetSubstringBounds(selection()); |
1386 for (std::vector<Rect>::const_iterator i = sel.begin(); i < sel.end(); ++i) | 1391 for (std::vector<Rect>::const_iterator i = sel.begin(); i < sel.end(); ++i) |
1387 canvas->FillRect(*i, selection_background_focused_color_); | 1392 canvas->FillRect(*i, selection_background_focused_color_); |
1388 } | 1393 } |
1389 | 1394 |
1390 } // namespace gfx | 1395 } // namespace gfx |
OLD | NEW |