Bug 1465875 part 5. Eliminate nsIDOMNSEditableElement. r=qdot
authorBoris Zbarsky <bzbarsky@mit.edu>
Fri, 01 Jun 2018 22:35:23 -0400
changeset 420964 284705205651b1c4f0e730fb9ec71a72b8056b6a
parent 420963 fcf9522e0558ac565904d443685f145e2e2cca5f
child 420965 ab9cf549cd35888c14fdc97155d50191baf4fca6
push id34083
push userapavel@mozilla.com
push dateSat, 02 Jun 2018 23:03:25 +0000
treeherdermozilla-central@1f62ecdf59b6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersqdot
bugs1465875
milestone62.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 1465875 part 5. Eliminate nsIDOMNSEditableElement. r=qdot
dom/html/HTMLInputElement.cpp
dom/html/HTMLInputElement.h
dom/html/HTMLTextAreaElement.cpp
dom/html/HTMLTextAreaElement.h
dom/html/test/test_bug389797.html
dom/interfaces/core/moz.build
dom/interfaces/core/nsIDOMNSEditableElement.idl
dom/moz.build
toolkit/components/satchel/nsFormFillController.cpp
--- a/dom/html/HTMLInputElement.cpp
+++ b/dom/html/HTMLInputElement.cpp
@@ -17,17 +17,16 @@
 #include "mozilla/dom/FileSystemUtils.h"
 #include "mozilla/dom/GetFilesHelper.h"
 #include "mozilla/dom/WheelEventBinding.h"
 #include "nsAttrValueInlines.h"
 #include "nsCRTGlue.h"
 #include "nsQueryObject.h"
 
 #include "nsITextControlElement.h"
-#include "nsIDOMNSEditableElement.h"
 #include "nsIRadioVisitor.h"
 #include "InputType.h"
 
 #include "HTMLFormSubmissionConstants.h"
 #include "mozilla/Telemetry.h"
 #include "nsIControllers.h"
 #include "nsIStringBundle.h"
 #include "nsFocusManager.h"
@@ -1114,17 +1113,16 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_IN
   //XXX should unlink more?
 NS_IMPL_CYCLE_COLLECTION_UNLINK_END
 
 NS_IMPL_ISUPPORTS_CYCLE_COLLECTION_INHERITED(HTMLInputElement,
                                              nsGenericHTMLFormElementWithState,
                                              nsITextControlElement,
                                              imgINotificationObserver,
                                              nsIImageLoadingContent,
-                                             nsIDOMNSEditableElement,
                                              nsIConstraintValidation)
 
 // nsINode
 
 nsresult
 HTMLInputElement::Clone(mozilla::dom::NodeInfo* aNodeInfo, nsINode** aResult,
                         bool aPreallocateArrays) const
 {
@@ -2337,60 +2335,51 @@ HTMLInputElement::GetOwnerNumberControl(
     if (grandparent && grandparent->mType == NS_FORM_INPUT_NUMBER) {
       return grandparent;
     }
   }
   return nullptr;
 }
 
 void
-HTMLInputElement::SetUserInput(const nsAString& aInput,
+HTMLInputElement::SetUserInput(const nsAString& aValue,
                                nsIPrincipal& aSubjectPrincipal) {
   if (mType == NS_FORM_INPUT_FILE &&
       !nsContentUtils::IsSystemPrincipal(&aSubjectPrincipal)) {
     return;
   }
 
-  SetUserInput(aInput);
-}
-
-NS_IMETHODIMP
-HTMLInputElement::SetUserInput(const nsAString& aValue)
-{
   if (mType == NS_FORM_INPUT_FILE)
   {
     Sequence<nsString> list;
     if (!list.AppendElement(aValue, fallible)) {
-      return NS_ERROR_OUT_OF_MEMORY;
-    }
-
-    ErrorResult rv;
-    MozSetFileNameArray(list, rv);
-    return rv.StealNSResult();
-  } else {
-    nsresult rv =
-      SetValueInternal(aValue,
-        nsTextEditorState::eSetValue_BySetUserInput |
-        nsTextEditorState::eSetValue_Notify|
-        nsTextEditorState::eSetValue_MoveCursorToEndIfValueChanged);
-    NS_ENSURE_SUCCESS(rv, rv);
-  }
+      return;
+    }
+
+    MozSetFileNameArray(list, IgnoreErrors());
+    return;
+  }
+
+  nsresult rv =
+    SetValueInternal(aValue,
+      nsTextEditorState::eSetValue_BySetUserInput |
+      nsTextEditorState::eSetValue_Notify|
+      nsTextEditorState::eSetValue_MoveCursorToEndIfValueChanged);
+  NS_ENSURE_SUCCESS_VOID(rv);
 
   nsContentUtils::DispatchTrustedEvent(OwnerDoc(),
                                        static_cast<Element*>(this),
                                        NS_LITERAL_STRING("input"), true,
                                        true);
 
   // If this element is not currently focused, it won't receive a change event for this
   // update through the normal channels. So fire a change event immediately, instead.
   if (!ShouldBlur(this)) {
     FireChangeEventIfNeeded();
   }
-
-  return NS_OK;
 }
 
 nsIEditor*
 HTMLInputElement::GetEditor()
 {
   return GetTextEditorFromState();
 }
 
--- a/dom/html/HTMLInputElement.h
+++ b/dom/html/HTMLInputElement.h
@@ -7,17 +7,16 @@
 #ifndef mozilla_dom_HTMLInputElement_h
 #define mozilla_dom_HTMLInputElement_h
 
 #include "mozilla/Attributes.h"
 #include "nsGenericHTMLElement.h"
 #include "nsImageLoadingContent.h"
 #include "nsITextControlElement.h"
 #include "nsITimer.h"
-#include "nsIDOMNSEditableElement.h"
 #include "nsCOMPtr.h"
 #include "nsIConstraintValidation.h"
 #include "mozilla/UniquePtr.h"
 #include "mozilla/dom/BindingDeclarations.h"
 #include "mozilla/dom/HTMLFormElement.h" // for HasEverTriedInvalidSubmit()
 #include "mozilla/dom/HTMLInputElementBinding.h"
 #include "mozilla/dom/Promise.h"
 #include "mozilla/dom/UnionTypes.h"
@@ -120,17 +119,16 @@ public:
     nsCOMPtr<nsIFilePickerShownCallback> mFpCallback;
     nsCOMPtr<nsIContentPref> mResult;
   };
 };
 
 class HTMLInputElement final : public nsGenericHTMLFormElementWithState,
                                public nsImageLoadingContent,
                                public nsITextControlElement,
-                               public nsIDOMNSEditableElement,
                                public nsIConstraintValidation
 {
   friend class AfterSetFilesOrDirectoriesCallback;
   friend class DispatchChangeEventCallback;
   friend class ::InputType;
 
 public:
   using nsIConstraintValidation::GetValidationMessage;
@@ -159,26 +157,16 @@ public:
 #endif
 
   // Element
   virtual bool IsInteractiveHTMLContent(bool aIgnoreTabindex) const override;
 
   // EventTarget
   virtual void AsyncEventRunning(AsyncEventDispatcher* aEvent) override;
 
-  // nsIDOMNSEditableElement
-  NS_IMETHOD GetEditor(nsIEditor** aEditor) override
-  {
-    nsCOMPtr<nsIEditor> editor = GetEditor();
-    editor.forget(aEditor);
-    return NS_OK;
-  }
-
-  NS_IMETHOD SetUserInput(const nsAString& aInput) override;
-
   // Overriden nsIFormControl methods
   NS_IMETHOD Reset() override;
   NS_IMETHOD SubmitNamesValues(HTMLFormSubmission* aFormSubmission) override;
   NS_IMETHOD SaveState() override;
   virtual bool RestoreState(PresState* aState) override;
   virtual bool AllowDrop() override;
   virtual bool IsDisabledForEvents(EventMessage aMessage) override;
 
--- a/dom/html/HTMLTextAreaElement.cpp
+++ b/dom/html/HTMLTextAreaElement.cpp
@@ -82,17 +82,16 @@ NS_IMPL_CYCLE_COLLECTION_INHERITED(HTMLT
                                    nsGenericHTMLFormElementWithState,
                                    mValidity,
                                    mControllers,
                                    mState)
 
 NS_IMPL_ISUPPORTS_CYCLE_COLLECTION_INHERITED(HTMLTextAreaElement,
                                              nsGenericHTMLFormElementWithState,
                                              nsITextControlElement,
-                                             nsIDOMNSEditableElement,
                                              nsIMutationObserver,
                                              nsIConstraintValidation)
 
 // nsIDOMHTMLTextAreaElement
 
 nsresult
 HTMLTextAreaElement::Clone(mozilla::dom::NodeInfo *aNodeInfo, nsINode **aResult,
                            bool aPreallocateChildren) const
@@ -352,23 +351,17 @@ HTMLTextAreaElement::SetValue(const nsAS
   if (mFocusedValue.Equals(currentValue)) {
     GetValueInternal(mFocusedValue, true);
   }
 }
 
 void HTMLTextAreaElement::SetUserInput(const nsAString& aValue,
                                        nsIPrincipal& aSubjectPrincipal)
 {
-  SetUserInput(aValue);
-}
-
-NS_IMETHODIMP
-HTMLTextAreaElement::SetUserInput(const nsAString& aValue)
-{
-  return SetValueInternal(aValue,
+  SetValueInternal(aValue,
     nsTextEditorState::eSetValue_BySetUserInput |
     nsTextEditorState::eSetValue_Notify|
     nsTextEditorState::eSetValue_MoveCursorToEndIfValueChanged);
 }
 
 NS_IMETHODIMP
 HTMLTextAreaElement::SetValueChanged(bool aValueChanged)
 {
--- a/dom/html/HTMLTextAreaElement.h
+++ b/dom/html/HTMLTextAreaElement.h
@@ -5,17 +5,16 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef mozilla_dom_HTMLTextAreaElement_h
 #define mozilla_dom_HTMLTextAreaElement_h
 
 #include "mozilla/Attributes.h"
 #include "nsITextControlElement.h"
 #include "nsIControllers.h"
-#include "nsIDOMNSEditableElement.h"
 #include "nsCOMPtr.h"
 #include "nsGenericHTMLElement.h"
 #include "nsStubMutationObserver.h"
 #include "nsIConstraintValidation.h"
 #include "mozilla/dom/HTMLFormElement.h"
 #include "mozilla/dom/HTMLInputElementBinding.h"
 #include "nsGkAtoms.h"
 
@@ -34,17 +33,16 @@ class EventStates;
 class PresState;
 
 namespace dom {
 
 class HTMLFormSubmission;
 
 class HTMLTextAreaElement final : public nsGenericHTMLFormElementWithState,
                                   public nsITextControlElement,
-                                  public nsIDOMNSEditableElement,
                                   public nsStubMutationObserver,
                                   public nsIConstraintValidation
 {
 public:
   using nsIConstraintValidation::GetValidationMessage;
 
   explicit HTMLTextAreaElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo,
                                FromParser aFromParser = NOT_FROM_PARSER);
@@ -57,25 +55,16 @@ public:
   virtual int32_t TabIndexDefault() override;
 
   // Element
   virtual bool IsInteractiveHTMLContent(bool aIgnoreTabindex) const override
   {
     return true;
   }
 
-  // nsIDOMNSEditableElement
-  NS_IMETHOD GetEditor(nsIEditor** aEditor) override
-  {
-    nsCOMPtr<nsIEditor> editor = GetEditor();
-    editor.forget(aEditor);
-    return NS_OK;
-  }
-  NS_IMETHOD SetUserInput(const nsAString& aInput) override;
-
   // nsIFormControl
   NS_IMETHOD Reset() override;
   NS_IMETHOD SubmitNamesValues(HTMLFormSubmission* aFormSubmission) override;
   NS_IMETHOD SaveState() override;
   virtual bool RestoreState(PresState* aState) override;
   virtual bool IsDisabledForEvents(EventMessage aMessage) override;
 
   virtual void FieldSetDisabledChanged(bool aNotify) override;
--- a/dom/html/test/test_bug389797.html
+++ b/dom/html/test/test_bug389797.html
@@ -31,26 +31,16 @@ function HTML_TAG(aTagName, aImplClass) 
   allTags.push(aTagName);
   classInfos[aTagName] = aImplClass;
   interfaces[aTagName] = [];
 
   // Some interfaces don't appear in classinfo because other interfaces that
   // inherit from them do.
   interfacesNonClassinfo[aTagName] = [ ];
 
-  var interfaceName = "nsIDOM" + getClassName(aTagName);
-  if (interfaceName in SpecialPowers.Ci) {  // no nsIDOMHTMLSpanElement
-    interfaces[aTagName].push(interfaceName);
-  }
-
-  var interfaceNameNS = "nsIDOMNS" + getClassName(aTagName);
-  if (interfaceNameNS in SpecialPowers.Ci) {
-    interfaces[aTagName].push(interfaceNameNS);
-  }
-
   if (arguments.length > 2) {
     for (var i = 0; i < arguments[2].length; ++i) {
       interfaces[aTagName].push(arguments[2][i]);
     }
   }
 
   if (arguments.length > 3) {
     for (i = 0; i < arguments[3].length; ++i) {
@@ -143,18 +133,17 @@ HTML_TAG("hgroup", "")
 HTML_TAG("hr", "HR");
 HTML_TAG("html", "Html");
 HTML_TAG("i", "");
 HTML_TAG("iframe", "IFrame", [ "nsIDOMMozBrowserFrame" ],
                              [ "nsIFrameLoaderOwner" ]);
 HTML_TAG("image", "");
 HTML_TAG("img", "Image", [ "nsIImageLoadingContent" ], []);
 HTML_TAG("input", "Input", [], [ "imgINotificationObserver",
-                                 "nsIImageLoadingContent",
-                                 "nsIDOMNSEditableElement" ]);
+                                 "nsIImageLoadingContent" ]);
 HTML_TAG("ins", "Mod");
 HTML_TAG("kbd", "");
 HTML_TAG("keygen", "Span");
 HTML_TAG("label", "Label");
 HTML_TAG("legend", "Legend");
 HTML_TAG("li", "LI");
 HTML_TAG("link", "Link");
 HTML_TAG("listing", "Pre");
@@ -196,17 +185,17 @@ HTML_TAG("span", "Span");
 HTML_TAG("strike", "");
 HTML_TAG("strong", "");
 HTML_TAG("style", "Style");
 HTML_TAG("sub", "");
 HTML_TAG("sup", "");
 HTML_TAG("table", "Table");
 HTML_TAG("tbody", "TableSection");
 HTML_TAG("td", "TableCell");
-HTML_TAG("textarea", "TextArea", [], [ "nsIDOMNSEditableElement" ]);
+HTML_TAG("textarea", "TextArea");
 HTML_TAG("tfoot", "TableSection");
 HTML_TAG("th", "TableCell");
 HTML_TAG("thead", "TableSection");
 HTML_TAG("template", "Template");
 HTML_TAG("time", "Time");
 HTML_TAG("title", "Title");
 HTML_TAG("tr", "TableRow");
 HTML_TAG("tt", "");
deleted file mode 100644
--- a/dom/interfaces/core/moz.build
+++ /dev/null
@@ -1,15 +0,0 @@
-# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
-# vim: set filetype=python:
-# 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/.
-
-with Files("**"):
-    BUG_COMPONENT = ("Core", "DOM")
-
-XPIDL_SOURCES += [
-    'nsIDOMNSEditableElement.idl',
-]
-
-XPIDL_MODULE = 'dom_core'
-
deleted file mode 100644
--- a/dom/interfaces/core/nsIDOMNSEditableElement.idl
+++ /dev/null
@@ -1,28 +0,0 @@
-/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* 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/. */
-
-#include "nsISupports.idl"
-
-interface nsIEditor;
-
-/**
- * This interface is implemented by elements which have inner editable content,
- * such as HTML input and textarea.
- *
- * Please make sure to update the HTMLTextAreaElement and HTMLInputElement
- * Web IDL interfaces to mirror this interface when changing it.
- *
- */
-
-[scriptable, uuid(3503de34-6631-4594-b7be-c36ff6a520c4)]
-interface nsIDOMNSEditableElement : nsISupports
-{
-  [noscript] readonly attribute nsIEditor editor;
-  // This is similar to set .value on nsIDOMInput/TextAreaElements, but
-  // handling of the value change is closer to the normal user input, so 
-  // 'change' event for example will be dispatched when focusing out the
-  // element.
-  [noscript] void setUserInput(in DOMString input);
-};
--- a/dom/moz.build
+++ b/dom/moz.build
@@ -10,17 +10,16 @@ with Files("**"):
 
 with Files("plugins/**"):
     BUG_COMPONENT = ("Core", "Plug-ins")
 
 JAR_MANIFESTS += ['jar.mn']
 
 interfaces = [
     'base',
-    'core',
     'html',
     'events',
     'sidebar',
     'xul',
     'security',
     'storage',
     'offline',
     'geolocation',
--- a/toolkit/components/satchel/nsFormFillController.cpp
+++ b/toolkit/components/satchel/nsFormFillController.cpp
@@ -573,17 +573,18 @@ nsFormFillController::GetTextValue(nsASt
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsFormFillController::SetTextValue(const nsAString & aTextValue)
 {
   if (mFocusedInput) {
     mSuppressOnInput = true;
-    mFocusedInput->SetUserInput(aTextValue);
+    mFocusedInput->SetUserInput(aTextValue,
+                                *nsContentUtils::GetSystemPrincipal());
     mSuppressOnInput = false;
   }
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsFormFillController::SetTextValueWithReason(const nsAString & aTextValue,