Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(335)

Side by Side Diff: ui/base/ime/input_method_chromeos.cc

Issue 313053007: Passing BackgroundColorSpan and UnderlineSpan from Clank to Blink. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Putting back import java.lang.CharSequence for android_aosp. Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/base/ime/composition_underline.h ('k') | ui/base/ime/input_method_chromeos_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 590 matching lines...) Expand 10 before | Expand all | Expand 10 after
601 out_composition->selection = gfx::Range(cursor_offset); 601 out_composition->selection = gfx::Range(cursor_offset);
602 602
603 const std::vector<chromeos::CompositionText::UnderlineAttribute>& 603 const std::vector<chromeos::CompositionText::UnderlineAttribute>&
604 underline_attributes = text.underline_attributes(); 604 underline_attributes = text.underline_attributes();
605 if (!underline_attributes.empty()) { 605 if (!underline_attributes.empty()) {
606 for (size_t i = 0; i < underline_attributes.size(); ++i) { 606 for (size_t i = 0; i < underline_attributes.size(); ++i) {
607 const uint32 start = underline_attributes[i].start_index; 607 const uint32 start = underline_attributes[i].start_index;
608 const uint32 end = underline_attributes[i].end_index; 608 const uint32 end = underline_attributes[i].end_index;
609 if (start >= end) 609 if (start >= end)
610 continue; 610 continue;
611 CompositionUnderline underline( 611 CompositionUnderline underline(char16_offsets[start],
612 char16_offsets[start], char16_offsets[end], 612 char16_offsets[end],
613 SK_ColorBLACK, false /* thick */); 613 SK_ColorBLACK,
614 false /* thick */,
615 SK_ColorTRANSPARENT);
614 if (underline_attributes[i].type == 616 if (underline_attributes[i].type ==
615 chromeos::CompositionText::COMPOSITION_TEXT_UNDERLINE_DOUBLE) 617 chromeos::CompositionText::COMPOSITION_TEXT_UNDERLINE_DOUBLE)
616 underline.thick = true; 618 underline.thick = true;
617 else if (underline_attributes[i].type == 619 else if (underline_attributes[i].type ==
618 chromeos::CompositionText::COMPOSITION_TEXT_UNDERLINE_ERROR) 620 chromeos::CompositionText::COMPOSITION_TEXT_UNDERLINE_ERROR)
619 underline.color = SK_ColorRED; 621 underline.color = SK_ColorRED;
620 out_composition->underlines.push_back(underline); 622 out_composition->underlines.push_back(underline);
621 } 623 }
622 } 624 }
623 625
624 DCHECK(text.selection_start() <= text.selection_end()); 626 DCHECK(text.selection_start() <= text.selection_end());
625 if (text.selection_start() < text.selection_end()) { 627 if (text.selection_start() < text.selection_end()) {
626 const uint32 start = text.selection_start(); 628 const uint32 start = text.selection_start();
627 const uint32 end = text.selection_end(); 629 const uint32 end = text.selection_end();
628 CompositionUnderline underline( 630 CompositionUnderline underline(char16_offsets[start],
629 char16_offsets[start], char16_offsets[end], 631 char16_offsets[end],
630 SK_ColorBLACK, true /* thick */); 632 SK_ColorBLACK,
633 true /* thick */,
634 SK_ColorTRANSPARENT);
631 out_composition->underlines.push_back(underline); 635 out_composition->underlines.push_back(underline);
632 636
633 // If the cursor is at start or end of this underline, then we treat 637 // If the cursor is at start or end of this underline, then we treat
634 // it as the selection range as well, but make sure to set the cursor 638 // it as the selection range as well, but make sure to set the cursor
635 // position to the selection end. 639 // position to the selection end.
636 if (underline.start_offset == cursor_offset) { 640 if (underline.start_offset == cursor_offset) {
637 out_composition->selection.set_start(underline.end_offset); 641 out_composition->selection.set_start(underline.end_offset);
638 out_composition->selection.set_end(cursor_offset); 642 out_composition->selection.set_end(cursor_offset);
639 } else if (underline.end_offset == cursor_offset) { 643 } else if (underline.end_offset == cursor_offset) {
640 out_composition->selection.set_start(underline.start_offset); 644 out_composition->selection.set_start(underline.start_offset);
641 out_composition->selection.set_end(cursor_offset); 645 out_composition->selection.set_end(cursor_offset);
642 } 646 }
643 } 647 }
644 648
645 // Use a black thin underline by default. 649 // Use a black thin underline by default.
646 if (out_composition->underlines.empty()) { 650 if (out_composition->underlines.empty()) {
647 out_composition->underlines.push_back(CompositionUnderline( 651 out_composition->underlines.push_back(CompositionUnderline(
648 0, length, SK_ColorBLACK, false /* thick */)); 652 0, length, SK_ColorBLACK, false /* thick */, SK_ColorTRANSPARENT));
649 } 653 }
650 } 654 }
651 655
652 bool InputMethodChromeOS::IsInputFieldFocused() { 656 bool InputMethodChromeOS::IsInputFieldFocused() {
653 TextInputType type = GetTextInputType(); 657 TextInputType type = GetTextInputType();
654 return (type != TEXT_INPUT_TYPE_NONE) && (type != TEXT_INPUT_TYPE_PASSWORD); 658 return (type != TEXT_INPUT_TYPE_NONE) && (type != TEXT_INPUT_TYPE_PASSWORD);
655 } 659 }
656 660
657 } // namespace ui 661 } // namespace ui
OLDNEW
« no previous file with comments | « ui/base/ime/composition_underline.h ('k') | ui/base/ime/input_method_chromeos_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698