2001-09-25 05:32:19 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-05-21 15:12:37 +04: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 09:22:37 +04:00
|
|
|
|
|
|
|
#include "nsISupports.idl"
|
2001-03-01 16:42:49 +03:00
|
|
|
|
|
|
|
/* THIS IS A PUBLIC INTERFACE */
|
2000-09-14 09:22:37 +04: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 20:46:42 +04:00
|
|
|
interface nsIDOMNode;
|
|
|
|
interface nsIDOMRange;
|
2012-02-01 14:54:22 +04:00
|
|
|
interface nsINode;
|
2000-09-14 09:22:37 +04:00
|
|
|
|
2001-03-01 16:42:49 +03:00
|
|
|
/**
|
|
|
|
* Interface for manipulating and querying the current selected range
|
|
|
|
* of nodes within the document.
|
2001-03-24 03:22:18 +03:00
|
|
|
*
|
2010-07-22 22:02:06 +04:00
|
|
|
* @version 1.0
|
2001-03-01 16:42:49 +03:00
|
|
|
*/
|
2001-03-24 03:22:18 +03:00
|
|
|
|
2012-06-11 03:44:50 +04:00
|
|
|
[scriptable, uuid(12cf5a4d-fffb-4f2f-9cec-c65195661d76)]
|
2000-09-14 09:22:37 +04:00
|
|
|
interface nsISelection : nsISupports
|
2001-03-01 16:42:49 +03:00
|
|
|
{
|
|
|
|
/**
|
2006-03-09 21:44:20 +03:00
|
|
|
* Returns the node in which the selection begins.
|
2001-03-01 16:42:49 +03:00
|
|
|
*/
|
|
|
|
readonly attribute nsIDOMNode anchorNode;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The offset within the (text) node where the selection begins.
|
|
|
|
*/
|
|
|
|
readonly attribute long anchorOffset;
|
|
|
|
|
|
|
|
/**
|
2006-03-09 21:44:20 +03:00
|
|
|
* Returns the node in which the selection ends.
|
2001-03-01 16:42:49 +03:00
|
|
|
*/
|
|
|
|
readonly attribute nsIDOMNode focusNode;
|
|
|
|
|
|
|
|
/**
|
2006-03-09 21:44:20 +03:00
|
|
|
* The offset within the (text) node where the selection ends.
|
2001-03-01 16:42:49 +03:00
|
|
|
*/
|
|
|
|
readonly attribute long focusOffset;
|
|
|
|
|
|
|
|
/**
|
2001-06-15 23:42:16 +04:00
|
|
|
* Indicates if the selection is collapsed or not.
|
2001-03-01 16:42:49 +03:00
|
|
|
*/
|
|
|
|
readonly attribute boolean isCollapsed;
|
2012-05-18 12:29:39 +04:00
|
|
|
[noscript,notxpcom,nostdcall] boolean collapsed();
|
2001-03-01 16:42:49 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the number of ranges in the selection.
|
|
|
|
*/
|
|
|
|
readonly attribute long rangeCount;
|
2000-09-14 09:22:37 +04:00
|
|
|
|
2001-03-01 16:42:49 +03:00
|
|
|
/**
|
|
|
|
* Returns the range at the specified index.
|
|
|
|
*/
|
|
|
|
nsIDOMRange getRangeAt(in long index);
|
|
|
|
|
|
|
|
/**
|
2001-05-15 10:10:38 +04: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 16:42:49 +03:00
|
|
|
*/
|
|
|
|
void collapse(in nsIDOMNode parentNode, in long offset);
|
2012-02-01 14:54:22 +04:00
|
|
|
[noscript] void collapseNative(in nsINode parentNode, in long offset);
|
2001-05-15 10:10:38 +04:00
|
|
|
|
2001-03-01 16:42:49 +03:00
|
|
|
/**
|
2006-03-09 21:44:20 +03: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 10:10:38 +04:00
|
|
|
* @param parentNode The node where the selection will be extended to
|
2006-03-09 21:44:20 +03:00
|
|
|
* @param offset Where in node to place the offset in the new selection end
|
2001-03-01 16:42:49 +03:00
|
|
|
*/
|
|
|
|
void extend(in nsIDOMNode parentNode, in long offset);
|
2012-05-18 12:29:39 +04:00
|
|
|
[noscript] void extendNative(in nsINode parentNode, in long offset);
|
2001-03-01 16:42:49 +03:00
|
|
|
|
|
|
|
/**
|
2001-05-15 10:10:38 +04: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 16:42:49 +03:00
|
|
|
*/
|
|
|
|
void collapseToStart();
|
|
|
|
|
|
|
|
/**
|
2001-05-15 10:10:38 +04: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 16:42:49 +03:00
|
|
|
*/
|
|
|
|
void collapseToEnd();
|
|
|
|
|
|
|
|
/**
|
2006-03-30 01:57:22 +04:00
|
|
|
* Indicates whether the node is part of the selection. If partlyContained
|
|
|
|
* 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
|
|
|
|
* function only returns true when the entire node is part of the selection.
|
2001-03-01 16:42:49 +03:00
|
|
|
*/
|
2006-03-30 01:57:22 +04:00
|
|
|
boolean containsNode(in nsIDOMNode node, in boolean partlyContained);
|
2001-03-01 16:42:49 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Adds all children of the specified node to the selection.
|
2001-05-15 10:10:38 +04:00
|
|
|
* @param parentNode the parent of the children to be added to the selection.
|
2001-03-01 16:42:49 +03:00
|
|
|
*/
|
2000-09-14 09:22:37 +04:00
|
|
|
void selectAllChildren(in nsIDOMNode parentNode);
|
|
|
|
|
2001-03-01 16:42:49 +03: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 09:22:37 +04:00
|
|
|
|
2001-03-01 16:42:49 +03:00
|
|
|
/**
|
|
|
|
* Deletes this selection from document the nodes belong to.
|
|
|
|
*/
|
|
|
|
void deleteFromDocument();
|
2000-09-14 09:22:37 +04:00
|
|
|
|
2001-03-21 04:16:22 +03:00
|
|
|
/**
|
|
|
|
* Modifies the cursor Bidi level after a change in keyboard direction
|
2001-05-15 10:10:38 +04:00
|
|
|
* @param langRTL is PR_TRUE if the new language is right-to-left or
|
|
|
|
* PR_FALSE if the new language is left-to-right.
|
2001-03-21 04:16:22 +03:00
|
|
|
*/
|
|
|
|
void selectionLanguageChange(in boolean langRTL);
|
|
|
|
|
2001-03-01 16:42:49 +03:00
|
|
|
/**
|
|
|
|
* Returns the whole selection into a plain text string.
|
|
|
|
*/
|
2012-06-11 03:44:50 +04:00
|
|
|
DOMString toString();
|
|
|
|
|
2011-08-08 00:18:00 +04: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 09:22:37 +04:00
|
|
|
};
|