| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/base/ime/input_method_chromeos.h" | 5 #include "ui/base/ime/input_method_chromeos.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <cstring> | 8 #include <cstring> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 591 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 602 const std::vector<chromeos::CompositionText::UnderlineAttribute>& | 602 const std::vector<chromeos::CompositionText::UnderlineAttribute>& |
| 603 underline_attributes = text.underline_attributes(); | 603 underline_attributes = text.underline_attributes(); |
| 604 if (!underline_attributes.empty()) { | 604 if (!underline_attributes.empty()) { |
| 605 for (size_t i = 0; i < underline_attributes.size(); ++i) { | 605 for (size_t i = 0; i < underline_attributes.size(); ++i) { |
| 606 const uint32 start = underline_attributes[i].start_index; | 606 const uint32 start = underline_attributes[i].start_index; |
| 607 const uint32 end = underline_attributes[i].end_index; | 607 const uint32 end = underline_attributes[i].end_index; |
| 608 if (start >= end) | 608 if (start >= end) |
| 609 continue; | 609 continue; |
| 610 CompositionUnderline underline( | 610 CompositionUnderline underline( |
| 611 char16_offsets[start], char16_offsets[end], | 611 char16_offsets[start], char16_offsets[end], |
| 612 SK_ColorBLACK, false /* thick */); | 612 SK_ColorBLACK, false /* thick */, SK_ColorTRANSPARENT); |
| 613 if (underline_attributes[i].type == | 613 if (underline_attributes[i].type == |
| 614 chromeos::CompositionText::COMPOSITION_TEXT_UNDERLINE_DOUBLE) | 614 chromeos::CompositionText::COMPOSITION_TEXT_UNDERLINE_DOUBLE) |
| 615 underline.thick = true; | 615 underline.thick = true; |
| 616 else if (underline_attributes[i].type == | 616 else if (underline_attributes[i].type == |
| 617 chromeos::CompositionText::COMPOSITION_TEXT_UNDERLINE_ERROR) | 617 chromeos::CompositionText::COMPOSITION_TEXT_UNDERLINE_ERROR) |
| 618 underline.color = SK_ColorRED; | 618 underline.color = SK_ColorRED; |
| 619 out_composition->underlines.push_back(underline); | 619 out_composition->underlines.push_back(underline); |
| 620 } | 620 } |
| 621 } | 621 } |
| 622 | 622 |
| 623 DCHECK(text.selection_start() <= text.selection_end()); | 623 DCHECK(text.selection_start() <= text.selection_end()); |
| 624 if (text.selection_start() < text.selection_end()) { | 624 if (text.selection_start() < text.selection_end()) { |
| 625 const uint32 start = text.selection_start(); | 625 const uint32 start = text.selection_start(); |
| 626 const uint32 end = text.selection_end(); | 626 const uint32 end = text.selection_end(); |
| 627 CompositionUnderline underline( | 627 CompositionUnderline underline( |
| 628 char16_offsets[start], char16_offsets[end], | 628 char16_offsets[start], char16_offsets[end], |
| 629 SK_ColorBLACK, true /* thick */); | 629 SK_ColorBLACK, true /* thick */, SK_ColorTRANSPARENT); |
| 630 out_composition->underlines.push_back(underline); | 630 out_composition->underlines.push_back(underline); |
| 631 | 631 |
| 632 // If the cursor is at start or end of this underline, then we treat | 632 // If the cursor is at start or end of this underline, then we treat |
| 633 // it as the selection range as well, but make sure to set the cursor | 633 // it as the selection range as well, but make sure to set the cursor |
| 634 // position to the selection end. | 634 // position to the selection end. |
| 635 if (underline.start_offset == cursor_offset) { | 635 if (underline.start_offset == cursor_offset) { |
| 636 out_composition->selection.set_start(underline.end_offset); | 636 out_composition->selection.set_start(underline.end_offset); |
| 637 out_composition->selection.set_end(cursor_offset); | 637 out_composition->selection.set_end(cursor_offset); |
| 638 } else if (underline.end_offset == cursor_offset) { | 638 } else if (underline.end_offset == cursor_offset) { |
| 639 out_composition->selection.set_start(underline.start_offset); | 639 out_composition->selection.set_start(underline.start_offset); |
| 640 out_composition->selection.set_end(cursor_offset); | 640 out_composition->selection.set_end(cursor_offset); |
| 641 } | 641 } |
| 642 } | 642 } |
| 643 | 643 |
| 644 // Use a black thin underline by default. | 644 // Use a black thin underline by default. |
| 645 if (out_composition->underlines.empty()) { | 645 if (out_composition->underlines.empty()) { |
| 646 out_composition->underlines.push_back(CompositionUnderline( | 646 out_composition->underlines.push_back(CompositionUnderline( |
| 647 0, length, SK_ColorBLACK, false /* thick */)); | 647 0, length, SK_ColorBLACK, false /* thick */, SK_ColorTRANSPARENT)); |
| 648 } | 648 } |
| 649 } | 649 } |
| 650 | 650 |
| 651 bool InputMethodChromeOS::IsInputFieldFocused() { | 651 bool InputMethodChromeOS::IsInputFieldFocused() { |
| 652 TextInputType type = GetTextInputType(); | 652 TextInputType type = GetTextInputType(); |
| 653 return (type != TEXT_INPUT_TYPE_NONE) && (type != TEXT_INPUT_TYPE_PASSWORD); | 653 return (type != TEXT_INPUT_TYPE_NONE) && (type != TEXT_INPUT_TYPE_PASSWORD); |
| 654 } | 654 } |
| 655 | 655 |
| 656 } // namespace ui | 656 } // namespace ui |
| OLD | NEW |