2001-09-26 02:53:13 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
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/. */
|
2001-03-28 03:11:08 +04:00
|
|
|
|
|
|
|
#include "nsISupports.idl"
|
|
|
|
#include "domstubs.idl"
|
|
|
|
|
2011-08-12 23:12:45 +04:00
|
|
|
interface nsIContent;
|
2016-09-20 13:47:00 +03:00
|
|
|
interface nsIArray;
|
2001-03-28 03:11:08 +04:00
|
|
|
|
2018-05-11 20:46:15 +03:00
|
|
|
webidl Document;
|
2018-04-27 06:35:18 +03:00
|
|
|
webidl Element;
|
2018-04-27 06:35:18 +03:00
|
|
|
webidl Node;
|
2018-05-08 20:52:36 +03:00
|
|
|
webidl Selection;
|
2012-05-06 11:53:11 +04:00
|
|
|
|
2017-08-04 07:57:56 +03:00
|
|
|
[scriptable, builtinclass, uuid(87ee993e-985f-4a43-a974-0d9512da2fb0)]
|
2001-03-28 03:11:08 +04:00
|
|
|
interface nsIHTMLEditor : nsISupports
|
|
|
|
{
|
|
|
|
%{C++
|
|
|
|
typedef short EAlignment;
|
|
|
|
%}
|
|
|
|
|
|
|
|
// used by GetAlignment()
|
|
|
|
const short eLeft = 0;
|
|
|
|
const short eCenter = 1;
|
|
|
|
const short eRight = 2;
|
|
|
|
const short eJustify = 3;
|
2015-05-28 18:58:42 +03:00
|
|
|
|
|
|
|
|
2001-03-28 03:11:08 +04:00
|
|
|
/* ------------ Inline property methods -------------- */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* SetInlineProperty() sets the aggregate properties on the current selection
|
|
|
|
*
|
2015-05-28 18:58:42 +03:00
|
|
|
* @param aProperty the property to set on the selection
|
2002-03-15 01:11:14 +03:00
|
|
|
* @param aAttribute the attribute of the property, if applicable.
|
|
|
|
* May be null.
|
2001-03-28 03:11:08 +04:00
|
|
|
* Example: aProperty="font", aAttribute="color"
|
2002-03-15 01:11:14 +03:00
|
|
|
* @param aValue if aAttribute is not null, the value of the attribute.
|
|
|
|
* May be null.
|
|
|
|
* Example: aProperty="font", aAttribute="color",
|
|
|
|
* aValue="0x00FFFF"
|
2001-03-28 03:11:08 +04:00
|
|
|
*/
|
2019-03-30 14:55:29 +03:00
|
|
|
[can_run_script]
|
2017-08-25 08:40:45 +03:00
|
|
|
void setInlineProperty(in AString aProperty,
|
2002-03-15 01:11:14 +03:00
|
|
|
in AString aAttribute,
|
|
|
|
in AString aValue);
|
2001-03-28 03:11:08 +04:00
|
|
|
|
|
|
|
/**
|
2002-03-15 01:11:14 +03:00
|
|
|
* getInlineProperty() gets aggregate properties of the current selection.
|
2001-03-28 03:11:08 +04:00
|
|
|
* All object in the current selection are scanned and their attributes are
|
|
|
|
* represented in a list of Property object.
|
|
|
|
*
|
2015-05-28 18:58:42 +03:00
|
|
|
* @param aProperty the property to get on the selection
|
2002-03-15 01:11:14 +03:00
|
|
|
* @param aAttribute the attribute of the property, if applicable.
|
|
|
|
* May be null.
|
2001-03-28 03:11:08 +04:00
|
|
|
* Example: aProperty="font", aAttribute="color"
|
2002-03-15 01:11:14 +03:00
|
|
|
* @param aValue if aAttribute is not null, the value of the attribute.
|
|
|
|
* May be null.
|
|
|
|
* Example: aProperty="font", aAttribute="color",
|
|
|
|
* aValue="0x00FFFF"
|
2012-10-25 20:32:24 +04:00
|
|
|
* @param aFirst [OUT] PR_TRUE if the first text node in the
|
2002-03-15 01:11:14 +03:00
|
|
|
* selection has the property
|
2012-10-25 20:32:24 +04:00
|
|
|
* @param aAny [OUT] PR_TRUE if any of the text nodes in the
|
2002-03-15 01:11:14 +03:00
|
|
|
* selection have the property
|
2012-10-25 20:32:24 +04:00
|
|
|
* @param aAll [OUT] PR_TRUE if all of the text nodes in the
|
2002-03-15 01:11:14 +03:00
|
|
|
* selection have the property
|
2001-03-28 03:11:08 +04:00
|
|
|
*/
|
2017-08-25 08:40:45 +03:00
|
|
|
void getInlineProperty(in AString aProperty,
|
|
|
|
in AString aAttribute,
|
|
|
|
in AString aValue,
|
2002-03-15 01:11:14 +03:00
|
|
|
out boolean aFirst,
|
|
|
|
out boolean aAny,
|
|
|
|
out boolean aAll);
|
|
|
|
|
2017-08-25 08:40:45 +03:00
|
|
|
AString getInlinePropertyWithAttrValue(in AString aProperty,
|
|
|
|
in AString aAttribute,
|
|
|
|
in AString aValue,
|
|
|
|
out boolean aFirst,
|
|
|
|
out boolean aAny,
|
|
|
|
out boolean aAll);
|
2015-05-28 18:58:42 +03:00
|
|
|
|
2001-03-28 03:11:08 +04:00
|
|
|
/**
|
2015-05-28 18:58:42 +03:00
|
|
|
* removeAllInlineProperties() deletes all the inline properties from all
|
2001-03-28 03:11:08 +04:00
|
|
|
* text in the current selection.
|
|
|
|
*/
|
2019-03-30 14:55:29 +03:00
|
|
|
[can_run_script]
|
2002-03-15 01:11:14 +03:00
|
|
|
void removeAllInlineProperties();
|
2001-03-28 03:11:08 +04:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
2018-11-30 04:21:59 +03:00
|
|
|
* removeInlineProperty() removes a property which changes inline style of
|
|
|
|
* text. E.g., bold, italic, super and sub.
|
2001-03-28 03:11:08 +04:00
|
|
|
*
|
2018-11-30 04:21:59 +03:00
|
|
|
* @param aProperty Tag name whcih represents the inline style you want to
|
|
|
|
* remove. E.g., "strong", "b", etc.
|
|
|
|
* If "href", <a> element which has href attribute will be
|
|
|
|
* removed.
|
|
|
|
* If "name", <a> element which has non-empty name
|
|
|
|
* attribute will be removed.
|
|
|
|
* @param aAttribute If aProperty is "font", aAttribute should be "face",
|
|
|
|
* "size", "color" or "bgcolor".
|
2001-03-28 03:11:08 +04:00
|
|
|
*/
|
2019-03-30 14:55:29 +03:00
|
|
|
[can_run_script]
|
2017-08-25 08:40:45 +03:00
|
|
|
void removeInlineProperty(in AString aProperty, in AString aAttribute);
|
2001-03-28 03:11:08 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Increase font size for text in selection by 1 HTML unit
|
|
|
|
* All existing text is scanned for existing <FONT SIZE> attributes
|
2002-03-15 01:11:14 +03:00
|
|
|
* so they will be incremented instead of inserting new <FONT> tag
|
2001-03-28 03:11:08 +04:00
|
|
|
*/
|
2019-03-30 14:55:29 +03:00
|
|
|
[can_run_script]
|
2002-03-15 01:11:14 +03:00
|
|
|
void increaseFontSize();
|
2001-03-28 03:11:08 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Decrease font size for text in selection by 1 HTML unit
|
|
|
|
* All existing text is scanned for existing <FONT SIZE> attributes
|
2002-03-15 01:11:14 +03:00
|
|
|
* so they will be decreased instead of inserting new <FONT> tag
|
2001-03-28 03:11:08 +04:00
|
|
|
*/
|
2019-03-30 14:55:29 +03:00
|
|
|
[can_run_script]
|
2002-03-15 01:11:14 +03:00
|
|
|
void decreaseFontSize();
|
2001-03-28 03:11:08 +04:00
|
|
|
|
|
|
|
/* ------------ HTML content methods -------------- */
|
|
|
|
|
2001-04-07 04:45:26 +04:00
|
|
|
/**
|
2002-03-15 01:11:14 +03:00
|
|
|
* Tests if a node is a BLOCK element according the the HTML 4.0 DTD.
|
2001-04-07 04:45:26 +04:00
|
|
|
* This does NOT consider CSS effect on display type
|
|
|
|
*
|
|
|
|
* @param aNode the node to test
|
|
|
|
*/
|
2018-05-24 20:18:34 +03:00
|
|
|
boolean nodeIsBlock(in Node node);
|
2001-04-07 04:45:26 +04:00
|
|
|
|
2001-03-28 03:11:08 +04:00
|
|
|
/**
|
|
|
|
* Insert some HTML source at the current location
|
|
|
|
*
|
|
|
|
* @param aInputString the string to be inserted
|
|
|
|
*/
|
2019-03-30 14:55:29 +03:00
|
|
|
[can_run_script]
|
2002-03-15 01:11:14 +03:00
|
|
|
void insertHTML(in AString aInputString);
|
2001-03-28 03:11:08 +04:00
|
|
|
|
|
|
|
|
2015-05-28 18:58:42 +03:00
|
|
|
/**
|
2002-10-06 05:23:18 +04:00
|
|
|
* Paste the text in the OS clipboard at the cursor position, replacing
|
|
|
|
* the selected text (if any), but strip out any HTML styles and formatting
|
|
|
|
*/
|
2019-03-12 04:55:03 +03:00
|
|
|
[can_run_script]
|
2002-10-06 05:23:18 +04:00
|
|
|
void pasteNoFormatting(in long aSelectionType);
|
|
|
|
|
2015-05-28 18:58:42 +03:00
|
|
|
/**
|
2002-10-06 05:23:18 +04:00
|
|
|
* Rebuild the entire document from source HTML
|
2001-03-28 03:11:08 +04:00
|
|
|
* Needed to be able to edit HEAD and other outside-of-BODY content
|
|
|
|
*
|
|
|
|
* @param aSourceString HTML source string of the entire new document
|
|
|
|
*/
|
2019-03-26 13:06:43 +03:00
|
|
|
[can_run_script]
|
2002-03-15 01:11:14 +03:00
|
|
|
void rebuildDocumentFromSource(in AString aSourceString);
|
2001-03-28 03:11:08 +04:00
|
|
|
|
2015-05-28 18:58:42 +03:00
|
|
|
/**
|
2002-10-06 05:23:18 +04:00
|
|
|
* Insert an element, which may have child nodes, at the selection
|
2001-03-28 03:11:08 +04:00
|
|
|
* Used primarily to insert a new element for various insert element dialogs,
|
|
|
|
* but it enforces the HTML 4.0 DTD "CanContain" rules, so it should
|
|
|
|
* be useful for other elements.
|
|
|
|
*
|
|
|
|
* @param aElement The element to insert
|
|
|
|
* @param aDeleteSelection Delete the selection before inserting
|
2015-05-28 18:58:42 +03:00
|
|
|
* If aDeleteSelection is PR_FALSE, then the element is inserted
|
2001-03-28 03:11:08 +04:00
|
|
|
* after the end of the selection for all element except
|
|
|
|
* Named Anchors, which insert before the selection
|
2015-05-28 18:58:42 +03:00
|
|
|
*/
|
2019-03-30 14:55:29 +03:00
|
|
|
[can_run_script]
|
2018-04-27 06:35:18 +03:00
|
|
|
void insertElementAtSelection(in Element aElement,
|
2002-03-15 01:11:14 +03:00
|
|
|
in boolean aDeleteSelection);
|
2001-03-28 03:11:08 +04:00
|
|
|
|
2015-05-28 18:58:42 +03:00
|
|
|
/**
|
2002-11-27 03:35:09 +03:00
|
|
|
* Set the BaseURL for the document to the current URL
|
|
|
|
* but only if the page doesn't have a <base> tag
|
|
|
|
* This should be done after the document URL has changed,
|
|
|
|
* such as after saving a file
|
|
|
|
* This is used as base for relativizing link and image urls
|
|
|
|
*/
|
|
|
|
void updateBaseURL();
|
|
|
|
|
|
|
|
|
2001-03-28 03:11:08 +04:00
|
|
|
/* ------------ Selection manipulation -------------- */
|
2018-05-08 20:52:36 +03:00
|
|
|
/* Should these be moved to Selection? */
|
2015-05-28 18:58:42 +03:00
|
|
|
|
|
|
|
/**
|
2002-10-06 05:23:18 +04:00
|
|
|
* Set the selection at the suppled element
|
2001-03-28 03:11:08 +04:00
|
|
|
*
|
|
|
|
* @param aElement An element in the document
|
|
|
|
*/
|
2019-03-26 13:09:47 +03:00
|
|
|
[can_run_script]
|
2018-04-27 06:35:18 +03:00
|
|
|
void selectElement(in Element aElement);
|
2001-03-28 03:11:08 +04:00
|
|
|
|
2015-05-28 18:58:42 +03:00
|
|
|
/**
|
2002-10-06 05:23:18 +04:00
|
|
|
* Create a collapsed selection just after aElement
|
2015-05-28 18:58:42 +03:00
|
|
|
*
|
2001-03-28 03:11:08 +04:00
|
|
|
* XXX could we parameterize SelectElement(before/select/after>?
|
|
|
|
*
|
|
|
|
* The selection is set to parent-of-aElement with an
|
|
|
|
* offset 1 greater than aElement's offset
|
|
|
|
* but it enforces the HTML 4.0 DTD "CanContain" rules, so it should
|
|
|
|
* be useful for other elements.
|
|
|
|
*
|
|
|
|
* @param aElement An element in the document
|
|
|
|
*/
|
2018-04-27 06:35:18 +03:00
|
|
|
void setCaretAfterElement(in Element aElement);
|
2001-03-28 03:11:08 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* SetParagraphFormat Insert a block paragraph tag around selection
|
|
|
|
* @param aParagraphFormat "p", "h1" to "h6", "address", "pre", or "blockquote"
|
|
|
|
*/
|
2019-05-08 01:34:28 +03:00
|
|
|
[can_run_script]
|
2002-03-15 01:11:14 +03:00
|
|
|
void setParagraphFormat(in AString aParagraphFormat);
|
2001-03-28 03:11:08 +04:00
|
|
|
|
|
|
|
/**
|
2002-03-15 01:11:14 +03:00
|
|
|
* getParagraphState returns what block tag paragraph format is in
|
|
|
|
* the selection.
|
2001-03-28 03:11:08 +04:00
|
|
|
* @param aMixed True if there is more than one format
|
2002-03-15 01:11:14 +03:00
|
|
|
* @return Name of block tag. "" is returned for none.
|
2001-03-28 03:11:08 +04:00
|
|
|
*/
|
2019-03-30 14:55:29 +03:00
|
|
|
[can_run_script]
|
2002-03-15 01:11:14 +03:00
|
|
|
AString getParagraphState(out boolean aMixed);
|
2001-03-28 03:11:08 +04:00
|
|
|
|
2015-05-28 18:58:42 +03:00
|
|
|
/**
|
2002-03-15 01:11:14 +03:00
|
|
|
* getFontFaceState returns what font face is in the selection.
|
2001-03-28 03:11:08 +04:00
|
|
|
* @param aMixed True if there is more than one font face
|
2002-03-15 01:11:14 +03:00
|
|
|
* @return Name of face. Note: "tt" is returned for
|
2001-03-28 03:11:08 +04:00
|
|
|
* tt tag. "" is returned for none.
|
|
|
|
*/
|
2002-03-15 01:11:14 +03:00
|
|
|
AString getFontFaceState(out boolean aMixed);
|
2015-05-28 18:58:42 +03:00
|
|
|
|
|
|
|
/**
|
2018-08-27 09:52:35 +03:00
|
|
|
* getBackgroundColorState returns what the background color of the selection.
|
2001-03-28 03:11:08 +04:00
|
|
|
* @param aMixed True if there is more than one font color
|
2002-03-15 01:11:14 +03:00
|
|
|
* @return Color string. "" is returned for none.
|
2001-03-28 03:11:08 +04:00
|
|
|
*/
|
2002-03-15 01:11:14 +03:00
|
|
|
AString getBackgroundColorState(out boolean aMixed);
|
2001-03-28 03:11:08 +04:00
|
|
|
|
2015-05-28 18:58:42 +03:00
|
|
|
/**
|
2002-03-15 01:11:14 +03:00
|
|
|
* getHighlightColorState returns what the highlight color of the selection.
|
2002-01-09 16:51:37 +03:00
|
|
|
* @param aMixed True if there is more than one font color
|
2002-03-15 01:11:14 +03:00
|
|
|
* @return Color string. "" is returned for none.
|
2002-01-09 16:51:37 +03:00
|
|
|
*/
|
2002-03-15 01:11:14 +03:00
|
|
|
AString getHighlightColorState(out boolean aMixed);
|
2002-01-09 16:51:37 +03:00
|
|
|
|
2015-05-28 18:58:42 +03:00
|
|
|
/**
|
2002-03-15 01:11:14 +03:00
|
|
|
* getListState returns what list type is in the selection.
|
2001-03-28 03:11:08 +04:00
|
|
|
* @param aMixed True if there is more than one type of list, or
|
|
|
|
* if there is some list and non-list
|
2015-05-28 18:58:42 +03:00
|
|
|
* @param aOL The company that employs me. No, really, it's
|
2001-03-28 03:11:08 +04:00
|
|
|
* true if an "ol" list is selected.
|
|
|
|
* @param aUL true if an "ul" list is selected.
|
|
|
|
* @param aDL true if a "dl" list is selected.
|
|
|
|
*/
|
2019-03-30 14:55:29 +03:00
|
|
|
[can_run_script]
|
2002-03-15 01:11:14 +03:00
|
|
|
void getListState(out boolean aMixed, out boolean aOL, out boolean aUL,
|
|
|
|
out boolean aDL);
|
2015-05-28 18:58:42 +03:00
|
|
|
|
|
|
|
/**
|
2002-03-15 01:11:14 +03:00
|
|
|
* getListItemState returns what list item type is in the selection.
|
2001-03-28 03:11:08 +04:00
|
|
|
* @param aMixed True if there is more than one type of list item, or
|
|
|
|
* if there is some list and non-list
|
|
|
|
* @param aLI true if "li" list items are selected.
|
|
|
|
* @param aDT true if "dt" list items are selected.
|
|
|
|
* @param aDD true if "dd" list items are selected.
|
|
|
|
*/
|
2019-03-30 14:55:29 +03:00
|
|
|
[can_run_script]
|
2002-03-15 01:11:14 +03:00
|
|
|
void getListItemState(out boolean aMixed, out boolean aLI,
|
|
|
|
out boolean aDT, out boolean aDD);
|
2015-05-28 18:58:42 +03:00
|
|
|
|
|
|
|
/**
|
2002-03-15 01:11:14 +03:00
|
|
|
* getAlignment returns what alignment is in the selection.
|
2001-03-28 03:11:08 +04:00
|
|
|
* @param aMixed True if there is more than one type of list item, or
|
|
|
|
* if there is some list and non-list
|
2002-03-15 01:11:14 +03:00
|
|
|
* @param aAlign enum value for first encountered alignment
|
|
|
|
* (left/center/right)
|
2001-03-28 03:11:08 +04:00
|
|
|
*/
|
2019-03-30 14:55:29 +03:00
|
|
|
[can_run_script]
|
2002-03-15 01:11:14 +03:00
|
|
|
void getAlignment(out boolean aMixed, out short aAlign);
|
2015-05-28 18:58:42 +03:00
|
|
|
|
2001-03-28 03:11:08 +04:00
|
|
|
/**
|
|
|
|
* Document me!
|
2015-05-28 18:58:42 +03:00
|
|
|
*
|
2001-03-28 03:11:08 +04:00
|
|
|
*/
|
2019-05-08 01:34:28 +03:00
|
|
|
[can_run_script]
|
2002-03-15 01:11:14 +03:00
|
|
|
void makeOrChangeList(in AString aListType, in boolean entireList,
|
|
|
|
in AString aBulletType);
|
2001-03-28 03:11:08 +04:00
|
|
|
|
|
|
|
/**
|
2018-08-20 15:23:56 +03:00
|
|
|
* removeList removes list items (<li>, <dd>, and <dt>) and list structures
|
|
|
|
* (<ul>, <ol>, and <dl>).
|
2015-05-28 18:58:42 +03:00
|
|
|
*
|
2018-08-20 15:23:56 +03:00
|
|
|
* @param aListType Unused.
|
2001-03-28 03:11:08 +04:00
|
|
|
*/
|
2002-03-15 01:11:14 +03:00
|
|
|
void removeList(in AString aListType);
|
2001-03-28 03:11:08 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Document me!
|
2015-05-28 18:58:42 +03:00
|
|
|
*
|
2001-03-28 03:11:08 +04:00
|
|
|
*/
|
2019-05-08 01:34:28 +03:00
|
|
|
[can_run_script]
|
2002-03-15 01:11:14 +03:00
|
|
|
void indent(in AString aIndent);
|
2001-03-28 03:11:08 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Document me!
|
2015-05-28 18:58:42 +03:00
|
|
|
*
|
2001-03-28 03:11:08 +04:00
|
|
|
*/
|
2002-03-15 01:11:14 +03:00
|
|
|
void align(in AString aAlign);
|
2001-03-28 03:11:08 +04:00
|
|
|
|
2015-05-28 18:58:42 +03:00
|
|
|
/**
|
Bug 1484092 - part 1: Make HTMLEditor::GetElementOrParentByTagName() use nsAtom for the tag name r=m_kato
HTMLElementOrParentByTagName() is the last user of IsLinkTag(const nsAString&)
and IsNamedAnchorTag(const nsAString&). For making their maintenance easier,
let's make GetElementOrParentByTagName() take const nsAtom& for tag name.
GetElementOrParentByTagName() has two functions, one is looking for an element
starting from a node. The other is, if the start node is nullptr, it retrieves
anchor node of Selection as start node. Therefore, this patch splits the
first part to GetElementOrParentByTagNameInternal(). Then, creates its
wrapper which retrieves anchor of Selection automatically,
GetElementOrParentByTagNameAtSelection().
Additionally, this patch makes all internal callers of HTMLEditor use
GetElementOrParentByTagNameInternal() or
GetElementOrParentByTagNameAtSelection() directly. Then, public method,
GetElementOrParentByTagName() is called only by outer classes.
Note that some callers use both GetElementOrParentByTagNameInternal()
and GetElementOrParentByTagNameAtSelection() since they don't check whether
setting node is nullptr. They may be bug of them. We should investigate
the API callers later.
Differential Revision: https://phabricator.services.mozilla.com/D3584
--HG--
extra : moz-landing-system : lando
2018-08-17 17:06:18 +03:00
|
|
|
* GetElementOrParentByTagName() looks for an element node whose name matches
|
|
|
|
* aTagName from aNode or anchor node of Selection to <body> element.
|
2003-06-25 12:50:48 +04:00
|
|
|
*
|
Bug 1484092 - part 1: Make HTMLEditor::GetElementOrParentByTagName() use nsAtom for the tag name r=m_kato
HTMLElementOrParentByTagName() is the last user of IsLinkTag(const nsAString&)
and IsNamedAnchorTag(const nsAString&). For making their maintenance easier,
let's make GetElementOrParentByTagName() take const nsAtom& for tag name.
GetElementOrParentByTagName() has two functions, one is looking for an element
starting from a node. The other is, if the start node is nullptr, it retrieves
anchor node of Selection as start node. Therefore, this patch splits the
first part to GetElementOrParentByTagNameInternal(). Then, creates its
wrapper which retrieves anchor of Selection automatically,
GetElementOrParentByTagNameAtSelection().
Additionally, this patch makes all internal callers of HTMLEditor use
GetElementOrParentByTagNameInternal() or
GetElementOrParentByTagNameAtSelection() directly. Then, public method,
GetElementOrParentByTagName() is called only by outer classes.
Note that some callers use both GetElementOrParentByTagNameInternal()
and GetElementOrParentByTagNameAtSelection() since they don't check whether
setting node is nullptr. They may be bug of them. We should investigate
the API callers later.
Differential Revision: https://phabricator.services.mozilla.com/D3584
--HG--
extra : moz-landing-system : lando
2018-08-17 17:06:18 +03:00
|
|
|
* @param aTagName The tag name which you want to look for.
|
|
|
|
* Must not be empty string.
|
|
|
|
* If "list", the result may be <ul>, <ol> or <dl>
|
|
|
|
* element.
|
|
|
|
* If "td", the result may be <td> or <th>.
|
|
|
|
* If "href", the result may be <a> element
|
|
|
|
* which has "href" attribute with non-empty value.
|
2018-08-17 17:50:56 +03:00
|
|
|
* If "anchor", the result may be <a> which has
|
|
|
|
* "name" attribute with non-empty value.
|
Bug 1484092 - part 1: Make HTMLEditor::GetElementOrParentByTagName() use nsAtom for the tag name r=m_kato
HTMLElementOrParentByTagName() is the last user of IsLinkTag(const nsAString&)
and IsNamedAnchorTag(const nsAString&). For making their maintenance easier,
let's make GetElementOrParentByTagName() take const nsAtom& for tag name.
GetElementOrParentByTagName() has two functions, one is looking for an element
starting from a node. The other is, if the start node is nullptr, it retrieves
anchor node of Selection as start node. Therefore, this patch splits the
first part to GetElementOrParentByTagNameInternal(). Then, creates its
wrapper which retrieves anchor of Selection automatically,
GetElementOrParentByTagNameAtSelection().
Additionally, this patch makes all internal callers of HTMLEditor use
GetElementOrParentByTagNameInternal() or
GetElementOrParentByTagNameAtSelection() directly. Then, public method,
GetElementOrParentByTagName() is called only by outer classes.
Note that some callers use both GetElementOrParentByTagNameInternal()
and GetElementOrParentByTagNameAtSelection() since they don't check whether
setting node is nullptr. They may be bug of them. We should investigate
the API callers later.
Differential Revision: https://phabricator.services.mozilla.com/D3584
--HG--
extra : moz-landing-system : lando
2018-08-17 17:06:18 +03:00
|
|
|
* @param aNode If non-null, this starts to look for the result
|
|
|
|
* from it. Otherwise, i.e., null, starts from
|
|
|
|
* anchor node of Selection.
|
|
|
|
* @return If an element which matches aTagName, returns
|
|
|
|
* an Element. Otherwise, nullptr.
|
2003-06-25 12:50:48 +04:00
|
|
|
*/
|
2018-04-27 06:35:18 +03:00
|
|
|
Element getElementOrParentByTagName(in AString aTagName,
|
|
|
|
in Node aNode);
|
2001-03-28 03:11:08 +04:00
|
|
|
|
2015-05-28 18:58:42 +03:00
|
|
|
/**
|
2018-11-05 14:38:10 +03:00
|
|
|
* getSelectedElement() returns a "selected" element node. "selected" means:
|
|
|
|
* - there is only one selection range
|
|
|
|
* - the range starts from an element node or in an element
|
|
|
|
* - the range ends at immediately after same element
|
|
|
|
* - and the range does not include any other element nodes.
|
|
|
|
* Additionally, only when aTagName is "href", this thinks that an <a>
|
|
|
|
* element which has non-empty "href" attribute includes the range, the
|
|
|
|
* <a> element is selected.
|
2018-01-30 07:27:59 +03:00
|
|
|
*
|
2018-11-05 14:38:10 +03:00
|
|
|
* @param aTagName Case-insensitive element name.
|
|
|
|
* If empty string, this returns any element node or null.
|
|
|
|
* If "href", this returns an <a> element which has
|
|
|
|
* non-empty "href" attribute or null.
|
|
|
|
* If "anchor", this returns an <a> element which has
|
|
|
|
* non-empty "name" attribute or null.
|
|
|
|
* Otherwise, returns an element node whose name is
|
|
|
|
* same as aTagName or null.
|
|
|
|
* @return A "selected" element.
|
2003-06-25 12:50:48 +04:00
|
|
|
*/
|
2018-01-30 07:27:59 +03:00
|
|
|
nsISupports getSelectedElement(in AString aTagName);
|
2001-03-28 03:11:08 +04:00
|
|
|
|
2015-05-28 18:58:42 +03:00
|
|
|
/**
|
2003-06-25 12:50:48 +04:00
|
|
|
* Return a new element with default attribute values
|
2015-05-28 18:58:42 +03:00
|
|
|
*
|
2003-06-25 12:50:48 +04:00
|
|
|
* This does not rely on the selection, and is not sensitive to context.
|
2015-05-28 18:58:42 +03:00
|
|
|
*
|
2003-06-25 12:50:48 +04:00
|
|
|
* Used primarily to supply new element for various insert element dialogs
|
2015-05-28 18:58:42 +03:00
|
|
|
* (Image, Link, NamedAnchor, Table, and HorizontalRule
|
2003-06-25 12:50:48 +04:00
|
|
|
* are the only returned elements as of 7/25/99)
|
|
|
|
*
|
|
|
|
* @param aTagName The HTML tagname
|
|
|
|
* Special input values for Links and Named anchors:
|
|
|
|
* Use "href" to get a link node
|
|
|
|
* (an "A" tag with the "href" attribute set)
|
|
|
|
* Use "anchor" or "namedanchor" to get a named anchor node
|
|
|
|
* (an "A" tag with the "name" attribute set)
|
|
|
|
* @return The new element created.
|
|
|
|
*/
|
2019-03-30 14:55:29 +03:00
|
|
|
[can_run_script]
|
2018-04-27 06:35:18 +03:00
|
|
|
Element createElementWithDefaults(in AString aTagName);
|
2001-03-28 03:11:08 +04:00
|
|
|
|
2015-05-28 18:58:42 +03:00
|
|
|
/**
|
2003-06-25 12:50:48 +04:00
|
|
|
* Insert an link element as the parent of the current selection
|
|
|
|
*
|
|
|
|
* @param aElement An "A" element with a non-empty "href" attribute
|
|
|
|
*/
|
2019-03-30 14:55:29 +03:00
|
|
|
[can_run_script]
|
2018-04-27 06:35:18 +03:00
|
|
|
void insertLinkAroundSelection(in Element aAnchorElement);
|
2001-03-28 03:11:08 +04:00
|
|
|
|
2015-05-28 18:58:42 +03:00
|
|
|
/**
|
2003-06-25 12:50:48 +04:00
|
|
|
* Set the value of the "bgcolor" attribute on the document's <body> element
|
|
|
|
*
|
|
|
|
* @param aColor The HTML color string, such as "#ffccff" or "yellow"
|
|
|
|
*/
|
2019-05-08 08:09:56 +03:00
|
|
|
[can_run_script]
|
2002-03-15 01:11:14 +03:00
|
|
|
void setBackgroundColor(in AString aColor);
|
2001-03-28 03:11:08 +04:00
|
|
|
|
2001-08-08 01:39:07 +04:00
|
|
|
/**
|
|
|
|
* Find all the nodes in the document which contain references
|
|
|
|
* to outside URIs (e.g. a href, img src, script src, etc.)
|
|
|
|
* The objects in the array will be type nsIURIRefObject.
|
|
|
|
*
|
|
|
|
* @return aNodeList the linked nodes found
|
|
|
|
*/
|
2016-09-20 13:47:00 +03:00
|
|
|
nsIArray getLinkedObjects();
|
2002-01-09 16:51:37 +03:00
|
|
|
|
2015-05-28 18:58:42 +03:00
|
|
|
/**
|
2003-06-25 12:50:48 +04:00
|
|
|
* A boolean which is true is the HTMLEditor has been instantiated
|
|
|
|
* with CSS knowledge and if the CSS pref is currently checked
|
|
|
|
*
|
|
|
|
* @return true if CSS handled and enabled
|
|
|
|
*/
|
2002-03-15 01:11:14 +03:00
|
|
|
attribute boolean isCSSEnabled;
|
2002-01-25 13:16:52 +03:00
|
|
|
|
2003-06-25 12:50:48 +04:00
|
|
|
/**
|
2018-08-17 11:56:28 +03:00
|
|
|
* checkSelectionStateForAnonymousButtons() may refresh editing UI such as
|
|
|
|
* resizers, inline-table-editing UI, absolute positioning UI for current
|
|
|
|
* Selection and focus state. When this method shows or hides UI, the
|
|
|
|
* editor (and/or its document/window) could be broken by mutation observers.
|
|
|
|
* FYI: Current user in script is only BlueGriffon.
|
2003-06-25 12:50:48 +04:00
|
|
|
*/
|
2019-05-09 10:37:51 +03:00
|
|
|
[can_run_script]
|
2018-10-30 13:01:38 +03:00
|
|
|
void checkSelectionStateForAnonymousButtons();
|
2003-06-25 12:50:48 +04:00
|
|
|
|
2018-04-27 06:35:18 +03:00
|
|
|
boolean isAnonymousElement(in Element aElement);
|
2005-01-12 22:11:48 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* A boolean indicating if a return key pressed in a paragraph creates
|
|
|
|
* another paragraph or just inserts a <br> at the caret
|
|
|
|
*
|
|
|
|
* @return true if CR in a paragraph creates a new paragraph
|
|
|
|
*/
|
|
|
|
attribute boolean returnInParagraphCreatesNewParagraph;
|
2001-03-28 03:11:08 +04:00
|
|
|
};
|
|
|
|
|