Bug 386971 - expose editor from nsIAccEditableText, r=ginn.chen
authorsurkov.alexander@gmail.com
Thu, 05 Jul 2007 10:12:28 -0700
changeset 3155 18d7b0861b4b944ad101e0aba1f115a60449f14e
parent 3154 b2906a284c26b5c4af9fff522434450d2323fad1
child 3156 cd374f03ca37446b0b40b042fa2b46d4a7ad9f9c
push idunknown
push userunknown
push dateunknown
reviewersginn.chen
bugs386971
milestone1.9a7pre
Bug 386971 - expose editor from nsIAccEditableText, r=ginn.chen
accessible/public/nsIAccessibleEditableText.idl
accessible/src/html/nsHyperTextAccessible.cpp
--- a/accessible/public/nsIAccessibleEditableText.idl
+++ b/accessible/public/nsIAccessibleEditableText.idl
@@ -36,30 +36,83 @@
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 #include "nsISupports.idl"
 
-[scriptable, uuid(91F0A56C-11BE-47C7-8D02-7C15E00C05F5)]
+interface nsIEditor;
+
+[scriptable, uuid(1e9884d3-4017-4032-a121-e0185d166db5)]
 interface nsIAccessibleEditableText : nsISupports
 {
-    /**
-      * Set font styles, such as italic, bold...
-      */
+  /**
+   * Sets the attributes for the text between the two given indices. The old
+   * attributes are replaced by the new list of attributes. For example,
+   * sets font styles, such as italic, bold...
+   *
+   *  @param startPos - start index of the text whose attributes are modified.
+   * @param endPos - end index of the text whose attributes are modified.
+   * @param attributes - set of attributes that replaces the old list of
+   *                     attributes of the specified text portion.
+   */
   void setAttributes (in long startPos, in long endPos,
                       in nsISupports attributes);
+
+  /**
+   * Replaces the text represented by this object by the given text.
+   */
   void setTextContents (in AString text);
+
+  /**
+   * Inserts text at the specified position.
+   *
+   * @param text - text that is inserted.
+   * @param position - index at which to insert the text.
+   */
   void insertText (in AString text, in long position);
+
+  /**
+   * Copies the text range into the clipboard.
+   *
+   * @param startPos - start index of the text to moved into the clipboard.
+   * @param endPos - end index of the text to moved into the clipboard.
+   */
   void copyText (in long startPos, in long endPos);
+
+  /**
+   * Deletes a range of text and copies it to the clipboard.
+   *
+   * @param startPos - start index of the text to be deleted.
+   * @param endOffset - end index of the text to be deleted.
+   */
   void cutText (in long startPos, in long endPos);
+
+  /**
+   * Deletes a range of text.
+   *
+   * @param startPos - start index of the text to be deleted.
+   * @param endPos - end index of the text to be deleted.
+   */
   void deleteText (in long startPos, in long endPos);
+
+  /**
+   * Pastes text from the clipboard.
+   *
+   * @param position - index at which to insert the text from the system
+   *                   clipboard into the text represented by this object.
+   */
   void pasteText (in long position);
+
+  /**
+   * Returns an editor.
+   */
+  [noscript] readonly attribute nsIEditor editor;
 };
 
 /*
  Assumptions:
 
  selectAttributes method takes an nsISupports parameter.
         'set' methods throw exception on failure.
  'wstring' inputs are potentially multibyte (UTF-16 for
--- a/accessible/src/html/nsHyperTextAccessible.cpp
+++ b/accessible/src/html/nsHyperTextAccessible.cpp
@@ -1129,16 +1129,27 @@ NS_IMETHODIMP nsHyperTextAccessible::Pas
 {
   nsCOMPtr<nsIEditor> editor = GetEditor();
   if (editor && NS_SUCCEEDED(SetCaretOffset(aPosition)))
     return editor->Paste(nsIClipboard::kGlobalClipboard);
 
   return NS_ERROR_FAILURE;
 }
 
+NS_IMETHODIMP
+nsHyperTextAccessible::GetEditor(nsIEditor **aEditor)
+{
+  NS_ENSURE_ARG_POINTER(aEditor);
+
+  nsCOMPtr<nsIEditor> editor(GetEditor());
+  NS_IF_ADDREF(*aEditor = editor);
+
+  return NS_OK;
+}
+
 /**
   * nsIEditActionListener impl.
   */
 NS_IMETHODIMP nsHyperTextAccessible::WillCreateNode(const nsAString& aTag,
                                                     nsIDOMNode *aParent, PRInt32 aPosition)
 {
   return NS_OK;
 }