15821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Copyright (c) 2012 The Chromium Authors. All rights reserved. 25821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be 35821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// found in the LICENSE file. 45821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 55821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#ifndef UI_BASE_IME_COMPOSITION_TEXT_H_ 65821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define UI_BASE_IME_COMPOSITION_TEXT_H_ 75821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 85e3f23d412006dc4db4e659864679f29341e113fTorne (Richard Coles)#include "base/strings/string16.h" 95821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ui/base/ime/composition_underline.h" 105d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "ui/base/ui_base_export.h" 1158537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)#include "ui/gfx/range/range.h" 125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)namespace ui { 145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// A struct represents the status of an ongoing composition text. 165d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)struct UI_BASE_EXPORT CompositionText { 175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) CompositionText(); 185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) ~CompositionText(); 195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool operator==(const CompositionText& rhs) const { 215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) if ((this->text != rhs.text) || 225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) (this->selection != rhs.selection) || 235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) (this->underlines.size() != rhs.underlines.size())) 245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) return false; 255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) for (size_t i = 0; i < this->underlines.size(); ++i) { 265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) if (this->underlines[i] != rhs.underlines[i]) 275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) return false; 285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) return true; 305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool operator!=(const CompositionText& rhs) const { 335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) return !(*this == rhs); 345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void Clear(); 375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Content of the composition text. 39a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) base::string16 text; 405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Underline information of the composition text. 425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // They must be sorted in ascending order by their start_offset and cannot be 435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // overlapped with each other. 445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) CompositionUnderlines underlines; 455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Selection range in the composition text. It represents the caret position 475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // if the range length is zero. Usually it's used for representing the target 485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // clause (on Windows). Gtk doesn't have such concept, so background color is 495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // usually used instead. 5058537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) gfx::Range selection; 515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}; 525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} // namespace ui 545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif // UI_BASE_IME_COMPOSITION_TEXT_H_ 56