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

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: Sync. 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
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 589 matching lines...) Expand 10 before | Expand all | Expand 10 after
600 out_composition->selection = gfx::Range(cursor_offset); 600 out_composition->selection = gfx::Range(cursor_offset);
601 601
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(char16_offsets[start],
611 char16_offsets[start], char16_offsets[end], 611 char16_offsets[end],
612 SK_ColorBLACK, false /* thick */); 612 SK_ColorBLACK,
613 false /* thick */,
614 SK_ColorTRANSPARENT);
613 if (underline_attributes[i].type == 615 if (underline_attributes[i].type ==
614 chromeos::CompositionText::COMPOSITION_TEXT_UNDERLINE_DOUBLE) 616 chromeos::CompositionText::COMPOSITION_TEXT_UNDERLINE_DOUBLE)
615 underline.thick = true; 617 underline.thick = true;
616 else if (underline_attributes[i].type == 618 else if (underline_attributes[i].type ==
617 chromeos::CompositionText::COMPOSITION_TEXT_UNDERLINE_ERROR) 619 chromeos::CompositionText::COMPOSITION_TEXT_UNDERLINE_ERROR)
618 underline.color = SK_ColorRED; 620 underline.color = SK_ColorRED;
619 out_composition->underlines.push_back(underline); 621 out_composition->underlines.push_back(underline);
620 } 622 }
621 } 623 }
622 624
623 DCHECK(text.selection_start() <= text.selection_end()); 625 DCHECK(text.selection_start() <= text.selection_end());
624 if (text.selection_start() < text.selection_end()) { 626 if (text.selection_start() < text.selection_end()) {
625 const uint32 start = text.selection_start(); 627 const uint32 start = text.selection_start();
626 const uint32 end = text.selection_end(); 628 const uint32 end = text.selection_end();
627 CompositionUnderline underline( 629 CompositionUnderline underline(char16_offsets[start],
628 char16_offsets[start], char16_offsets[end], 630 char16_offsets[end],
629 SK_ColorBLACK, true /* thick */); 631 SK_ColorBLACK,
632 true /* thick */,
633 SK_ColorTRANSPARENT);
630 out_composition->underlines.push_back(underline); 634 out_composition->underlines.push_back(underline);
631 635
632 // If the cursor is at start or end of this underline, then we treat 636 // 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 637 // it as the selection range as well, but make sure to set the cursor
634 // position to the selection end. 638 // position to the selection end.
635 if (underline.start_offset == cursor_offset) { 639 if (underline.start_offset == cursor_offset) {
636 out_composition->selection.set_start(underline.end_offset); 640 out_composition->selection.set_start(underline.end_offset);
637 out_composition->selection.set_end(cursor_offset); 641 out_composition->selection.set_end(cursor_offset);
638 } else if (underline.end_offset == cursor_offset) { 642 } else if (underline.end_offset == cursor_offset) {
639 out_composition->selection.set_start(underline.start_offset); 643 out_composition->selection.set_start(underline.start_offset);
640 out_composition->selection.set_end(cursor_offset); 644 out_composition->selection.set_end(cursor_offset);
641 } 645 }
642 } 646 }
643 647
644 // Use a black thin underline by default. 648 // Use a black thin underline by default.
645 if (out_composition->underlines.empty()) { 649 if (out_composition->underlines.empty()) {
646 out_composition->underlines.push_back(CompositionUnderline( 650 out_composition->underlines.push_back(CompositionUnderline(
647 0, length, SK_ColorBLACK, false /* thick */)); 651 0, length, SK_ColorBLACK, false /* thick */, SK_ColorTRANSPARENT));
648 } 652 }
649 } 653 }
650 654
651 bool InputMethodChromeOS::IsInputFieldFocused() { 655 bool InputMethodChromeOS::IsInputFieldFocused() {
652 TextInputType type = GetTextInputType(); 656 TextInputType type = GetTextInputType();
653 return (type != TEXT_INPUT_TYPE_NONE) && (type != TEXT_INPUT_TYPE_PASSWORD); 657 return (type != TEXT_INPUT_TYPE_NONE) && (type != TEXT_INPUT_TYPE_PASSWORD);
654 } 658 }
655 659
656 } // namespace ui 660 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698