nsISelection.idl 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
  2. /* ***** BEGIN LICENSE BLOCK *****
  3. * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  4. *
  5. * The contents of this file are subject to the Mozilla Public License Version
  6. * 1.1 (the "License"); you may not use this file except in compliance with
  7. * the License. You may obtain a copy of the License at
  8. * http://www.mozilla.org/MPL/
  9. *
  10. * Software distributed under the License is distributed on an "AS IS" basis,
  11. * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  12. * for the specific language governing rights and limitations under the
  13. * License.
  14. *
  15. * The Original Code is mozilla.org code.
  16. *
  17. * The Initial Developer of the Original Code is
  18. * Netscape Communications Corporation.
  19. * Portions created by the Initial Developer are Copyright (C) 1998
  20. * the Initial Developer. All Rights Reserved.
  21. *
  22. * Contributor(s):
  23. *
  24. * Alternatively, the contents of this file may be used under the terms of
  25. * either of the GNU General Public License Version 2 or later (the "GPL"),
  26. * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  27. * in which case the provisions of the GPL or the LGPL are applicable instead
  28. * of those above. If you wish to allow use of your version of this file only
  29. * under the terms of either the GPL or the LGPL, and not to allow others to
  30. * use your version of this file under the terms of the MPL, indicate your
  31. * decision by deleting the provisions above and replace them with the notice
  32. * and other provisions required by the GPL or the LGPL. If you do not delete
  33. * the provisions above, a recipient may use your version of this file under
  34. * the terms of any one of the MPL, the GPL or the LGPL.
  35. *
  36. * ***** END LICENSE BLOCK ***** */
  37. #include "nsISupports.idl"
  38. /* THIS IS A PUBLIC INTERFACE */
  39. interface nsIDOMNode;
  40. interface nsIDOMRange;
  41. /**
  42. * Interface for manipulating and querying the current selected range
  43. * of nodes within the document.
  44. *
  45. * @status FROZEN
  46. * @version 1.0
  47. */
  48. [scriptable, uuid(B2C7ED59-8634-4352-9E37-5484C8B6E4E1)]
  49. interface nsISelection : nsISupports
  50. {
  51. /**
  52. * The node representing one end of the selection.
  53. */
  54. readonly attribute nsIDOMNode anchorNode;
  55. /**
  56. * The offset within the (text) node where the selection begins.
  57. */
  58. readonly attribute long anchorOffset;
  59. /**
  60. * The node with keyboard focus.
  61. */
  62. readonly attribute nsIDOMNode focusNode;
  63. /**
  64. * The offset within the (text) node where focus starts.
  65. */
  66. readonly attribute long focusOffset;
  67. /**
  68. * Indicates if the selection is collapsed or not.
  69. */
  70. readonly attribute boolean isCollapsed;
  71. /**
  72. * Returns the number of ranges in the selection.
  73. */
  74. readonly attribute long rangeCount;
  75. /**
  76. * Returns the range at the specified index.
  77. */
  78. nsIDOMRange getRangeAt(in long index);
  79. /**
  80. * Collapses the selection to a single point, at the specified offset
  81. * in the given DOM node. When the selection is collapsed, and the content
  82. * is focused and editable, the caret will blink there.
  83. * @param parentNode The given dom node where the selection will be set
  84. * @param offset Where in given dom node to place the selection (the offset into the given node)
  85. */
  86. void collapse(in nsIDOMNode parentNode, in long offset);
  87. /**
  88. * Extends the selection by moving the focus to the specified node and offset,
  89. * preserving the anchor postion. The new selection end result will always
  90. * be from the anchor to the new focus, regardless of direction.
  91. * @param parentNode The node where the selection will be extended to
  92. * @param offset Where in node to place the offset in the new focused node
  93. */
  94. void extend(in nsIDOMNode parentNode, in long offset);
  95. /**
  96. * Collapses the whole selection to a single point at the start
  97. * of the current selection (irrespective of direction). If content
  98. * is focused and editable, the caret will blink there.
  99. */
  100. void collapseToStart();
  101. /**
  102. * Collapses the whole selection to a single point at the end
  103. * of the current selection (irrespective of direction). If content
  104. * is focused and editable, the caret will blink there.
  105. */
  106. void collapseToEnd();
  107. /**
  108. * The value of entirelyContained determines the detail of the search to determine if
  109. * the selection contains the node. If entirelyContained is set to PR_TRUE, t
  110. * or false if
  111. * @param node The node where the selection will be extended to
  112. * @param entirelyContained Whether
  113. */
  114. boolean containsNode(in nsIDOMNode node, in boolean entirelyContained);
  115. /**
  116. * Adds all children of the specified node to the selection.
  117. * @param parentNode the parent of the children to be added to the selection.
  118. */
  119. void selectAllChildren(in nsIDOMNode parentNode);
  120. /**
  121. * Adds a range to the current selection.
  122. */
  123. void addRange(in nsIDOMRange range);
  124. /**
  125. * Removes a range from the current selection.
  126. */
  127. void removeRange(in nsIDOMRange range);
  128. /**
  129. * Removes all ranges from the current selection.
  130. */
  131. void removeAllRanges();
  132. /**
  133. * Deletes this selection from document the nodes belong to.
  134. */
  135. void deleteFromDocument();
  136. /**
  137. * Modifies the cursor Bidi level after a change in keyboard direction
  138. * @param langRTL is PR_TRUE if the new language is right-to-left or
  139. * PR_FALSE if the new language is left-to-right.
  140. */
  141. void selectionLanguageChange(in boolean langRTL);
  142. /**
  143. * Returns the whole selection into a plain text string.
  144. */
  145. wstring toString();
  146. };