text_input_host.mojom 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. // Copyright 2019 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. module remote_cocoa.mojom;
  5. import "mojo/public/mojom/base/string16.mojom";
  6. import "ui/gfx/geometry/mojom/geometry.mojom";
  7. import "ui/gfx/range/mojom/range.mojom";
  8. // Interface exposing a views::Widget's currently-focused views::View's
  9. // ui::TextInputClient to the NSView corresponding to that views::Widget.
  10. interface TextInputHost {
  11. // Returns true in |has_client| if there exists an active ui::TextInputClient
  12. // for the focused views::View.
  13. [Sync]
  14. HasClient() => (bool has_client);
  15. // Returns true in |has_input_context|| if -[NSView inputContext] should
  16. // return a non-nil value.
  17. [Sync]
  18. HasInputContext() => (bool has_input_context);
  19. // Returns true in |is_rtl| if there exists an active ui::TextInputClient and
  20. // that ui::TextInputClient is RTL (right-to-left).
  21. [Sync]
  22. IsRTL() => (bool is_rtl);
  23. // Retrieves the character range of current selection in the current text
  24. // input. Returns an invalid range if the information cannot be retrieved
  25. // right now or if the selected text is not in the focused views::View.
  26. [Sync]
  27. GetSelectionRange() => (gfx.mojom.Range range);
  28. // Retrieves the currently selected text, and stores it in |text|. Returns
  29. // false in |result| if there was no selection.
  30. [Sync]
  31. GetSelectionText() => (bool result, mojo_base.mojom.String16 text);
  32. // Inserts a given text at the insertion point.
  33. InsertText(mojo_base.mojom.String16 text, bool as_character);
  34. // Deletes contents in the given character range.
  35. DeleteRange(gfx.mojom.Range range);
  36. // Sets composition text in the current ui::TextInputClient to |text| with
  37. // selection range |selected_range|, and delete the content of
  38. // |replacement_range|.
  39. SetCompositionText(mojo_base.mojom.String16 text,
  40. gfx.mojom.Range selected_range,
  41. gfx.mojom.Range replacement_range);
  42. // Converts current composition text into final content.
  43. ConfirmCompositionText();
  44. // Returns true in |has_composition_text| if there is composition text.
  45. [Sync]
  46. HasCompositionText() => (bool has_composition_text);
  47. // Returns in |composition_range| the character range of current composition
  48. // text.
  49. [Sync]
  50. GetCompositionTextRange() => (gfx.mojom.Range composition_range);
  51. // Returns in |text| the string corresponding to |requested_range| for current
  52. // ui::TextInputClient. If a gfx::Range::InvalidRange() is passed, the full
  53. // string stored by for the current ui::TextInputClient is returned. Sets
  54. // |actual_range| corresponding to the returned string.
  55. [Sync]
  56. GetAttributedSubstringForRange(gfx.mojom.Range requested_range) =>
  57. (mojo_base.mojom.String16 text, gfx.mojom.Range actual_range);
  58. // Returns in |rect| the boundary rectangle for composition characters in the
  59. // |requested_range|. Sets |actual_range| corresponding to the returned
  60. // rectangle. For cases where there is no composition text or the
  61. // |requested_range| lies outside the composition range, a zero width
  62. // rectangle corresponding to the caret bounds is returned.
  63. [Sync]
  64. GetFirstRectForRange(gfx.mojom.Range requested_range) =>
  65. (gfx.mojom.Rect rect, gfx.mojom.Range actual_range);
  66. };