2001-09-25 01:32:19 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-05-21 11:12:37 +00:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2000-09-14 05:22:37 +00:00
|
|
|
|
|
|
|
#include "nsISupports.idl"
|
2001-03-01 13:42:49 +00:00
|
|
|
|
|
|
|
/* THIS IS A PUBLIC INTERFACE */
|
2000-09-14 05:22:37 +00:00
|
|
|
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 16:46:42 +00:00
|
|
|
interface nsIDOMNode;
|
|
|
|
interface nsIDOMRange;
|
2012-02-01 10:54:22 +00:00
|
|
|
interface nsINode;
|
2000-09-14 05:22:37 +00:00
|
|
|
|
2001-03-01 13:42:49 +00:00
|
|
|
/**
|
|
|
|
* Interface for manipulating and querying the current selected range
|
|
|
|
* of nodes within the document.
|
2001-03-24 00:22:18 +00:00
|
|
|
*
|
2010-07-22 18:02:06 +00:00
|
|
|
* @version 1.0
|
2001-03-01 13:42:49 +00:00
|
|
|
*/
|
2001-03-24 00:22:18 +00:00
|
|
|
|
2014-05-08 20:45:36 +00:00
|
|
|
[builtinclass, uuid(e0a4d4b3-f34e-44bd-b1f2-4e3bde9b6915)]
|
2000-09-14 05:22:37 +00:00
|
|
|
interface nsISelection : nsISupports
|
2001-03-01 13:42:49 +00:00
|
|
|
{
|
|
|
|
/**
|
2006-03-09 18:44:20 +00:00
|
|
|
* Returns the node in which the selection begins.
|
2001-03-01 13:42:49 +00:00
|
|
|
*/
|
|
|
|
readonly attribute nsIDOMNode anchorNode;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The offset within the (text) node where the selection begins.
|
|
|
|
*/
|
|
|
|
readonly attribute long anchorOffset;
|
|
|
|
|
|
|
|
/**
|
2006-03-09 18:44:20 +00:00
|
|
|
* Returns the node in which the selection ends.
|
2001-03-01 13:42:49 +00:00
|
|
|
*/
|
|
|
|
readonly attribute nsIDOMNode focusNode;
|
|
|
|
|
|
|
|
/**
|
2006-03-09 18:44:20 +00:00
|
|
|
* The offset within the (text) node where the selection ends.
|
2001-03-01 13:42:49 +00:00
|
|
|
*/
|
|
|
|
readonly attribute long focusOffset;
|
|
|
|
|
|
|
|
/**
|
2001-06-15 19:42:16 +00:00
|
|
|
* Indicates if the selection is collapsed or not.
|
2001-03-01 13:42:49 +00:00
|
|
|
*/
|
|
|
|
readonly attribute boolean isCollapsed;
|
2012-05-18 08:29:39 +00:00
|
|
|
[noscript,notxpcom,nostdcall] boolean collapsed();
|
2001-03-01 13:42:49 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the number of ranges in the selection.
|
|
|
|
*/
|
|
|
|
readonly attribute long rangeCount;
|
2000-09-14 05:22:37 +00:00
|
|
|
|
2001-03-01 13:42:49 +00:00
|
|
|
/**
|
|
|
|
* Returns the range at the specified index.
|
|
|
|
*/
|
|
|
|
nsIDOMRange getRangeAt(in long index);
|
|
|
|
|
|
|
|
/**
|
2001-05-15 06:10:38 +00:00
|
|
|
* Collapses the selection to a single point, at the specified offset
|
|
|
|
* in the given DOM node. When the selection is collapsed, and the content
|
|
|
|
* is focused and editable, the caret will blink there.
|
|
|
|
* @param parentNode The given dom node where the selection will be set
|
|
|
|
* @param offset Where in given dom node to place the selection (the offset into the given node)
|
2001-03-01 13:42:49 +00:00
|
|
|
*/
|
|
|
|
void collapse(in nsIDOMNode parentNode, in long offset);
|
2012-02-01 10:54:22 +00:00
|
|
|
[noscript] void collapseNative(in nsINode parentNode, in long offset);
|
2001-05-15 06:10:38 +00:00
|
|
|
|
2001-03-01 13:42:49 +00:00
|
|
|
/**
|
2006-03-09 18:44:20 +00:00
|
|
|
* Extends the selection by moving the selection end to the specified node and offset,
|
|
|
|
* preserving the selection begin position. The new selection end result will always
|
|
|
|
* be from the anchorNode to the new focusNode, regardless of direction.
|
2001-05-15 06:10:38 +00:00
|
|
|
* @param parentNode The node where the selection will be extended to
|
2006-03-09 18:44:20 +00:00
|
|
|
* @param offset Where in node to place the offset in the new selection end
|
2001-03-01 13:42:49 +00:00
|
|
|
*/
|
|
|
|
void extend(in nsIDOMNode parentNode, in long offset);
|
2012-05-18 08:29:39 +00:00
|
|
|
[noscript] void extendNative(in nsINode parentNode, in long offset);
|
2001-03-01 13:42:49 +00:00
|
|
|
|
|
|
|
/**
|
2001-05-15 06:10:38 +00:00
|
|
|
* Collapses the whole selection to a single point at the start
|
|
|
|
* of the current selection (irrespective of direction). If content
|
|
|
|
* is focused and editable, the caret will blink there.
|
2001-03-01 13:42:49 +00:00
|
|
|
*/
|
|
|
|
void collapseToStart();
|
|
|
|
|
|
|
|
/**
|
2001-05-15 06:10:38 +00:00
|
|
|
* Collapses the whole selection to a single point at the end
|
|
|
|
* of the current selection (irrespective of direction). If content
|
|
|
|
* is focused and editable, the caret will blink there.
|
2001-03-01 13:42:49 +00:00
|
|
|
*/
|
|
|
|
void collapseToEnd();
|
|
|
|
|
|
|
|
/**
|
2006-03-29 21:57:22 +00:00
|
|
|
* Indicates whether the node is part of the selection. If partlyContained
|
2012-10-25 16:32:24 +00:00
|
|
|
* is set to PR_TRUE, the function returns true when some part of the node
|
|
|
|
* is part of the selection. If partlyContained is set to PR_FALSE, the
|
2006-03-29 21:57:22 +00:00
|
|
|
* function only returns true when the entire node is part of the selection.
|
2001-03-01 13:42:49 +00:00
|
|
|
*/
|
2006-03-29 21:57:22 +00:00
|
|
|
boolean containsNode(in nsIDOMNode node, in boolean partlyContained);
|
2001-03-01 13:42:49 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Adds all children of the specified node to the selection.
|
2001-05-15 06:10:38 +00:00
|
|
|
* @param parentNode the parent of the children to be added to the selection.
|
2001-03-01 13:42:49 +00:00
|
|
|
*/
|
2000-09-14 05:22:37 +00:00
|
|
|
void selectAllChildren(in nsIDOMNode parentNode);
|
|
|
|
|
2001-03-01 13:42:49 +00:00
|
|
|
/**
|
|
|
|
* Adds a range to the current selection.
|
|
|
|
*/
|
|
|
|
void addRange(in nsIDOMRange range);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Removes a range from the current selection.
|
|
|
|
*/
|
|
|
|
void removeRange(in nsIDOMRange range);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Removes all ranges from the current selection.
|
|
|
|
*/
|
|
|
|
void removeAllRanges();
|
2000-09-14 05:22:37 +00:00
|
|
|
|
2001-03-01 13:42:49 +00:00
|
|
|
/**
|
|
|
|
* Deletes this selection from document the nodes belong to.
|
|
|
|
*/
|
|
|
|
void deleteFromDocument();
|
2000-09-14 05:22:37 +00:00
|
|
|
|
2001-03-01 13:42:49 +00:00
|
|
|
/**
|
|
|
|
* Returns the whole selection into a plain text string.
|
|
|
|
*/
|
2012-06-10 23:44:50 +00:00
|
|
|
DOMString toString();
|
|
|
|
|
2011-08-07 20:18:00 +00:00
|
|
|
/**
|
|
|
|
* Modifies the selection. Note that the parameters are case-insensitive.
|
|
|
|
*
|
|
|
|
* @param alter can be one of { "move", "extend" }
|
|
|
|
* - "move" collapses the selection to the end of the selection and
|
|
|
|
* applies the movement direction/granularity to the collapsed
|
|
|
|
* selection.
|
|
|
|
* - "extend" leaves the start of the selection unchanged, and applies
|
|
|
|
* movement direction/granularity to the end of the selection.
|
|
|
|
* @param direction can be one of { "forward", "backward", "left", "right" }
|
|
|
|
* @param granularity can be one of { "character", "word",
|
|
|
|
* "line", "lineboundary" }
|
|
|
|
*
|
|
|
|
* @returns NS_ERROR_NOT_IMPLEMENTED if the granularity is "sentence",
|
|
|
|
* "sentenceboundary", "paragraph", "paragraphboundary", or
|
|
|
|
* "documentboundary". Returns NS_ERROR_INVALID_ARG if alter, direction,
|
|
|
|
* or granularity has an unrecognized value.
|
|
|
|
*/
|
|
|
|
void modify(in DOMString alter, in DOMString direction,
|
|
|
|
in DOMString granularity);
|
2000-09-14 05:22:37 +00:00
|
|
|
};
|