| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "win8/metro_driver/ime/text_store.h" | 5 #include "win8/metro_driver/ime/text_store.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/win/scoped_variant.h" | 9 #include "base/win/scoped_variant.h" |
| 10 #include "ui/base/win/atl_module.h" | 10 #include "ui/base/win/atl_module.h" |
| (...skipping 747 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 758 | 758 |
| 759 base::win::ScopedComPtr<IEnumTfRanges> ranges; | 759 base::win::ScopedComPtr<IEnumTfRanges> ranges; |
| 760 if (FAILED(track_property->EnumRanges(read_only_edit_cookie, ranges.Receive(), | 760 if (FAILED(track_property->EnumRanges(read_only_edit_cookie, ranges.Receive(), |
| 761 start_to_end_range))) { | 761 start_to_end_range))) { |
| 762 return false; | 762 return false; |
| 763 } | 763 } |
| 764 | 764 |
| 765 while (true) { | 765 while (true) { |
| 766 base::win::ScopedComPtr<ITfRange> range; | 766 base::win::ScopedComPtr<ITfRange> range; |
| 767 if (ranges->Next(1, range.Receive(), NULL) != S_OK) | 767 if (ranges->Next(1, range.Receive(), NULL) != S_OK) |
| 768 break; | 768 return true; |
| 769 base::win::ScopedVariant value; | 769 base::win::ScopedVariant value; |
| 770 base::win::ScopedComPtr<IEnumTfPropertyValue> enum_prop_value; | 770 base::win::ScopedComPtr<IEnumTfPropertyValue> enum_prop_value; |
| 771 if (FAILED(track_property->GetValue(read_only_edit_cookie, range, | 771 if (FAILED(track_property->GetValue(read_only_edit_cookie, range, |
| 772 value.Receive()))) { | 772 value.Receive()))) { |
| 773 return false; | 773 return false; |
| 774 } | 774 } |
| 775 if (FAILED(enum_prop_value.QueryFrom(value.AsInput()->punkVal))) | 775 if (FAILED(enum_prop_value.QueryFrom(value.AsInput()->punkVal))) |
| 776 return false; | 776 return false; |
| 777 | 777 |
| 778 TF_PROPERTYVAL property_value; | 778 TF_PROPERTYVAL property_value; |
| 779 bool is_composition = false; | 779 bool is_composition = false; |
| 780 bool has_display_attribute = false; | 780 metro_viewer::UnderlineInfo underline; |
| 781 TF_DISPLAYATTRIBUTE display_attribute; | |
| 782 while (enum_prop_value->Next(1, &property_value, NULL) == S_OK) { | 781 while (enum_prop_value->Next(1, &property_value, NULL) == S_OK) { |
| 783 if (IsEqualGUID(property_value.guidId, GUID_PROP_COMPOSING)) { | 782 if (IsEqualGUID(property_value.guidId, GUID_PROP_COMPOSING)) { |
| 784 is_composition = (property_value.varValue.lVal == TRUE); | 783 is_composition = (property_value.varValue.lVal == TRUE); |
| 785 } else if (IsEqualGUID(property_value.guidId, GUID_PROP_ATTRIBUTE)) { | 784 } else if (IsEqualGUID(property_value.guidId, GUID_PROP_ATTRIBUTE)) { |
| 786 TfGuidAtom guid_atom = | 785 TfGuidAtom guid_atom = |
| 787 static_cast<TfGuidAtom>(property_value.varValue.lVal); | 786 static_cast<TfGuidAtom>(property_value.varValue.lVal); |
| 787 TF_DISPLAYATTRIBUTE display_attribute; |
| 788 if (GetDisplayAttribute(guid_atom, &display_attribute)) | 788 if (GetDisplayAttribute(guid_atom, &display_attribute)) |
| 789 has_display_attribute = true; | 789 underline.thick = !!display_attribute.fBoldLine; |
| 790 } | 790 } |
| 791 VariantClear(&property_value.varValue); | 791 VariantClear(&property_value.varValue); |
| 792 } | 792 } |
| 793 | 793 |
| 794 base::win::ScopedComPtr<ITfRangeACP> range_acp; | 794 base::win::ScopedComPtr<ITfRangeACP> range_acp; |
| 795 range_acp.QueryFrom(range); | 795 range_acp.QueryFrom(range); |
| 796 LONG start_pos, length; | 796 LONG start_pos, length; |
| 797 range_acp->GetExtent(&start_pos, &length); | 797 range_acp->GetExtent(&start_pos, &length); |
| 798 if (!is_composition) { | 798 if (is_composition) { |
| 799 if (*committed_size < static_cast<size_t>(start_pos + length)) | |
| 800 *committed_size = start_pos + length; | |
| 801 } else { | |
| 802 metro_viewer::UnderlineInfo underline; | |
| 803 underline.start_offset = start_pos; | 799 underline.start_offset = start_pos; |
| 804 underline.end_offset = start_pos + length; | 800 underline.end_offset = start_pos + length; |
| 805 underline.thick = !!display_attribute.fBoldLine; | |
| 806 undelines->push_back(underline); | 801 undelines->push_back(underline); |
| 802 } else if (*committed_size < static_cast<size_t>(start_pos + length)) { |
| 803 *committed_size = start_pos + length; |
| 807 } | 804 } |
| 808 } | 805 } |
| 809 return true; | |
| 810 } | 806 } |
| 811 | 807 |
| 812 bool TextStore::CancelComposition() { | 808 bool TextStore::CancelComposition() { |
| 813 // If there is an on-going document lock, we must not edit the text. | 809 // If there is an on-going document lock, we must not edit the text. |
| 814 if (edit_flag_) | 810 if (edit_flag_) |
| 815 return false; | 811 return false; |
| 816 | 812 |
| 817 if (string_buffer_.empty()) | 813 if (string_buffer_.empty()) |
| 818 return true; | 814 return true; |
| 819 | 815 |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 889 | 885 |
| 890 bool TextStore::HasReadLock() const { | 886 bool TextStore::HasReadLock() const { |
| 891 return (current_lock_type_ & TS_LF_READ) == TS_LF_READ; | 887 return (current_lock_type_ & TS_LF_READ) == TS_LF_READ; |
| 892 } | 888 } |
| 893 | 889 |
| 894 bool TextStore::HasReadWriteLock() const { | 890 bool TextStore::HasReadWriteLock() const { |
| 895 return (current_lock_type_ & TS_LF_READWRITE) == TS_LF_READWRITE; | 891 return (current_lock_type_ & TS_LF_READWRITE) == TS_LF_READWRITE; |
| 896 } | 892 } |
| 897 | 893 |
| 898 } // namespace metro_driver | 894 } // namespace metro_driver |
| OLD | NEW |