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 654 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 665 void RenderText::SetCompositionRange(const Range& composition_range) { | 665 void RenderText::SetCompositionRange(const Range& composition_range) { |
| 666 CHECK(!composition_range.IsValid() || | 666 CHECK(!composition_range.IsValid() || |
| 667 Range(0, text_.length()).Contains(composition_range)); | 667 Range(0, text_.length()).Contains(composition_range)); |
| 668 composition_range_.set_end(composition_range.end()); | 668 composition_range_.set_end(composition_range.end()); |
| 669 composition_range_.set_start(composition_range.start()); | 669 composition_range_.set_start(composition_range.start()); |
| 670 ResetLayout(); | 670 ResetLayout(); |
| 671 } | 671 } |
| 672 | 672 |
| 673 void RenderText::SetColor(SkColor value) { | 673 void RenderText::SetColor(SkColor value) { |
| 674 colors_.SetValue(value); | 674 colors_.SetValue(value); |
| 675 | |
| 676 #if defined(OS_WIN) | |
| 677 // TODO(msw): Windows applies colors and decorations in the layout process. | |
| 678 cached_bounds_and_offset_valid_ = false; | |
| 679 ResetLayout(); | |
| 680 #endif | |
| 681 } | 675 } |
| 682 | 676 |
| 683 void RenderText::ApplyColor(SkColor value, const Range& range) { | 677 void RenderText::ApplyColor(SkColor value, const Range& range) { |
| 684 colors_.ApplyValue(value, range); | 678 colors_.ApplyValue(value, range); |
| 685 | |
| 686 #if defined(OS_WIN) | |
|
ckocagil
2014/08/30 01:26:15
This one shouldn't be needed after http://crrev.co
msw
2014/09/02 18:02:21
Acknowledged.
| |
| 687 // TODO(msw): Windows applies colors and decorations in the layout process. | |
| 688 cached_bounds_and_offset_valid_ = false; | |
| 689 ResetLayout(); | |
| 690 #endif | |
| 691 } | 679 } |
| 692 | 680 |
| 693 void RenderText::SetStyle(TextStyle style, bool value) { | 681 void RenderText::SetStyle(TextStyle style, bool value) { |
| 694 styles_[style].SetValue(value); | 682 styles_[style].SetValue(value); |
| 695 | 683 |
| 696 // Only invalidate the layout on font changes; not for colors or decorations. | 684 cached_bounds_and_offset_valid_ = false; |
| 697 bool invalidate = (style == BOLD) || (style == ITALIC); | 685 ResetLayout(); |
| 698 #if defined(OS_WIN) | |
| 699 // TODO(msw): Windows applies colors and decorations in the layout process. | |
| 700 invalidate = true; | |
| 701 #endif | |
| 702 if (invalidate) { | |
| 703 cached_bounds_and_offset_valid_ = false; | |
| 704 ResetLayout(); | |
| 705 } | |
| 706 } | 686 } |
| 707 | 687 |
| 708 void RenderText::ApplyStyle(TextStyle style, bool value, const Range& range) { | 688 void RenderText::ApplyStyle(TextStyle style, bool value, const Range& range) { |
| 709 styles_[style].ApplyValue(value, range); | 689 styles_[style].ApplyValue(value, range); |
| 710 | 690 |
| 711 // Only invalidate the layout on font changes; not for colors or decorations. | 691 cached_bounds_and_offset_valid_ = false; |
| 712 bool invalidate = (style == BOLD) || (style == ITALIC); | 692 ResetLayout(); |
| 713 #if defined(OS_WIN) | |
|
ckocagil
2014/08/30 01:26:15
HarfBuzz always needs invalidation on style change
msw
2014/09/02 18:02:21
Acknowledged.
| |
| 714 // TODO(msw): Windows applies colors and decorations in the layout process. | |
| 715 invalidate = true; | |
| 716 #endif | |
| 717 if (invalidate) { | |
| 718 cached_bounds_and_offset_valid_ = false; | |
| 719 ResetLayout(); | |
| 720 } | |
| 721 } | 693 } |
| 722 | 694 |
| 723 bool RenderText::GetStyle(TextStyle style) const { | 695 bool RenderText::GetStyle(TextStyle style) const { |
| 724 return (styles_[style].breaks().size() == 1) && | 696 return (styles_[style].breaks().size() == 1) && |
| 725 styles_[style].breaks().front().second; | 697 styles_[style].breaks().front().second; |
| 726 } | 698 } |
| 727 | 699 |
| 728 void RenderText::SetDirectionalityMode(DirectionalityMode mode) { | 700 void RenderText::SetDirectionalityMode(DirectionalityMode mode) { |
| 729 if (mode == directionality_mode_) | 701 if (mode == directionality_mode_) |
| 730 return; | 702 return; |
| (...skipping 700 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1431 SetDisplayOffset(display_offset_.x() + delta_x); | 1403 SetDisplayOffset(display_offset_.x() + delta_x); |
| 1432 } | 1404 } |
| 1433 | 1405 |
| 1434 void RenderText::DrawSelection(Canvas* canvas) { | 1406 void RenderText::DrawSelection(Canvas* canvas) { |
| 1435 const std::vector<Rect> sel = GetSubstringBounds(selection()); | 1407 const std::vector<Rect> sel = GetSubstringBounds(selection()); |
| 1436 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) |
| 1437 canvas->FillRect(*i, selection_background_focused_color_); | 1409 canvas->FillRect(*i, selection_background_focused_color_); |
| 1438 } | 1410 } |
| 1439 | 1411 |
| 1440 } // namespace gfx | 1412 } // namespace gfx |
| OLD | NEW |