/gecko_sdk/idl/nsISelection.idl

http://firefox-mac-pdf.googlecode.com/ · IDL · 169 lines · 26 code · 24 blank · 119 comment · 0 complexity · 0dcf375196aaf58c3add5c80d8343294 MD5 · raw file

  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. * Returns the node in which the selection begins.
  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. * Returns the node in which the selection ends.
  61. */
  62. readonly attribute nsIDOMNode focusNode;
  63. /**
  64. * The offset within the (text) node where the selection ends.
  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 selection end to the specified node and offset,
  89. * preserving the selection begin position. The new selection end result will always
  90. * be from the anchorNode to the new focusNode, 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 selection end
  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. * Indicates whether the node is part of the selection. If partlyContained
  109. * is set to PR_TRUE, the function returns true when some part of the node
  110. * is part of the selection. If partlyContained is set to PR_FALSE, the
  111. * function only returns true when the entire node is part of the selection.
  112. */
  113. boolean containsNode(in nsIDOMNode node, in boolean partlyContained);
  114. /**
  115. * Adds all children of the specified node to the selection.
  116. * @param parentNode the parent of the children to be added to the selection.
  117. */
  118. void selectAllChildren(in nsIDOMNode parentNode);
  119. /**
  120. * Adds a range to the current selection.
  121. */
  122. void addRange(in nsIDOMRange range);
  123. /**
  124. * Removes a range from the current selection.
  125. */
  126. void removeRange(in nsIDOMRange range);
  127. /**
  128. * Removes all ranges from the current selection.
  129. */
  130. void removeAllRanges();
  131. /**
  132. * Deletes this selection from document the nodes belong to.
  133. */
  134. void deleteFromDocument();
  135. /**
  136. * Modifies the cursor Bidi level after a change in keyboard direction
  137. * @param langRTL is PR_TRUE if the new language is right-to-left or
  138. * PR_FALSE if the new language is left-to-right.
  139. */
  140. void selectionLanguageChange(in boolean langRTL);
  141. /**
  142. * Returns the whole selection into a plain text string.
  143. */
  144. wstring toString();
  145. };