Bug 1439812 - Move noscript methods of nsIPlainTextEditor to TextEditor. r=masayuki
authorMakoto Kato <m_kato@ga2.so-net.ne.jp>
Wed, 21 Feb 2018 13:21:57 +0900
changeset 404656 690c1b3c488085627fd49d7d77ea27aa90e7f324
parent 404655 280bf2bdcda14eb973b0462853e6ca608f2e113d
child 404657 2931f4f700efb1d4d2b913440b743fc0a297420b
push id100058
push userrgurzau@mozilla.com
push dateWed, 21 Feb 2018 17:32:49 +0000
treeherdermozilla-inbound@fa4bede5ed1f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmasayuki
bugs1439812
milestone60.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1439812 - Move noscript methods of nsIPlainTextEditor to TextEditor. r=masayuki maxTextLength is unused from script, so I would like to move to TextEditor. Also, there is no reason to keep setText on nsIPlainText. MozReview-Commit-ID: CZ8pa9Pm8qt
editor/libeditor/TextEditor.cpp
editor/libeditor/TextEditor.h
editor/nsIPlaintextEditor.idl
--- a/editor/libeditor/TextEditor.cpp
+++ b/editor/libeditor/TextEditor.cpp
@@ -797,17 +797,17 @@ TextEditor::InsertLineBreak()
 
   if (!cancel) {
     // post-process, always called if WillInsertBreak didn't return cancel==true
     rv = rules->DidDoAction(selection, &ruleInfo, rv);
   }
   return rv;
 }
 
-NS_IMETHODIMP
+nsresult
 TextEditor::SetText(const nsAString& aString)
 {
   if (NS_WARN_IF(!mRules)) {
     return NS_ERROR_NOT_INITIALIZED;
   }
 
   // Protect the edit rules object from dying
   RefPtr<TextEditRules> rules(mRules);
@@ -1014,35 +1014,16 @@ TextEditor::GetTextLength(int32_t* aCoun
     }
   }
 
   *aCount = totalLength;
   return NS_OK;
 }
 
 NS_IMETHODIMP
-TextEditor::SetMaxTextLength(int32_t aMaxTextLength)
-{
-  mMaxTextLength = aMaxTextLength;
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-TextEditor::GetMaxTextLength(int32_t* aMaxTextLength)
-{
-  // NOTE: If you need to override this method, you need to make
-  //       MaxTextLength() virtual.
-  if (NS_WARN_IF(!aMaxTextLength)) {
-    return NS_ERROR_INVALID_POINTER;
-  }
-  *aMaxTextLength = MaxTextLength();
-  return NS_OK;
-}
-
-NS_IMETHODIMP
 TextEditor::GetWrapWidth(int32_t* aWrapColumn)
 {
   NS_ENSURE_TRUE( aWrapColumn, NS_ERROR_NULL_POINTER);
 
   *aWrapColumn = mWrapColumn;
   return NS_OK;
 }
 
--- a/editor/libeditor/TextEditor.h
+++ b/editor/libeditor/TextEditor.h
@@ -168,17 +168,30 @@ public:
    * principals match, or we are in a editor context where this doesn't matter.
    * Otherwise, the data must be sanitized first.
    */
   bool IsSafeToInsertData(nsIDOMDocument* aSourceDoc);
 
   static void GetDefaultEditorPrefs(int32_t& aNewLineHandling,
                                     int32_t& aCaretStyle);
 
+  /**
+    * The maximum number of characters allowed.
+    *   default: -1 (unlimited).
+    */
   int32_t MaxTextLength() const { return mMaxTextLength; }
+  void SetMaxTextLength(int32_t aLength) { mMaxTextLength = aLength; }
+
+  /**
+   * Replace existed string with a string.
+   * This is fast path to replace all string when using single line control.
+   *
+   * @ param aString   the string to be set
+   */
+  nsresult SetText(const nsAString& aString);
 
 protected:
   virtual ~TextEditor();
 
   NS_IMETHOD InitRules();
   void BeginEditorInit();
   nsresult EndEditorInit();
 
--- a/editor/nsIPlaintextEditor.idl
+++ b/editor/nsIPlaintextEditor.idl
@@ -59,22 +59,16 @@ interface nsIPlaintextEditor : nsISuppor
   const long eNewlinesStripSurroundingWhitespace = 5;
 
   /**
     * The length of the contents in characters.
     * XXX change this type to 'unsigned long'
     */
   readonly attribute long textLength;
 
-  /**
-    * The maximum number of characters allowed.
-    *   default: -1 (unlimited).
-    */
-  attribute long maxTextLength;
-
   /** Get and set the body wrap width.
     *
     * Special values:
     *    0 = wrap to window width
     *   -1 = no wrap at all
     */
   attribute long wrapWidth;
 
@@ -98,23 +92,15 @@ interface nsIPlaintextEditor : nsISuppor
    * If the selection is not collapsed, the selection is deleted
    * and the insertion takes place at the resulting collapsed selection.
    *
    * @param aString   the string to be inserted
    */
    void insertText(in DOMString aStringToInsert);
 
   /**
-   * Replace existed string with a string.
-   * This is fast path to replace all string when using single line control.
-   *
-   * @ param aString   the string to be set
-   */
-  [noscript] void setText(in DOMString aString);
-
-  /**
    * Insert a line break into the content model.
    * The interpretation of a break is up to the implementation:
    * it may enter a character, split a node in the tree, etc.
    * This may be more efficient than calling InsertText with a newline.
    */
   void insertLineBreak();
 };