Bug 691151. Remove Event.getPreventDefault. r=smaug
authorBoris Zbarsky <bzbarsky@mit.edu>
Wed, 15 Nov 2017 12:23:58 -0500
changeset 392023 3b3a7055f264a102dbaa41b9e361efe3d1bfe7cc
parent 392022 5b3b0a38b2d1827f4fc9af6f32e9fb939789d6c8
child 392024 f46e5a93d51054d20f4fd9ce4ec583ce4477cca5
push id32909
push usercbrindusan@mozilla.com
push dateWed, 15 Nov 2017 22:25:14 +0000
treeherdermozilla-central@f41930a869a8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs691151
milestone59.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 691151. Remove Event.getPreventDefault. r=smaug MozReview-Commit-ID: FQ3LzP7rW6e
dom/events/Event.cpp
dom/events/Event.h
dom/interfaces/events/nsIDOMEvent.idl
dom/locales/en-US/chrome/dom/dom.properties
dom/webidl/Event.webidl
layout/forms/test/test_bug935876.html
--- a/dom/events/Event.cpp
+++ b/dom/events/Event.cpp
@@ -1143,39 +1143,16 @@ Event::TimeStampImpl() const
 }
 
 double
 Event::TimeStamp() const
 {
   return nsRFPService::ReduceTimePrecisionAsMSecs(TimeStampImpl());
 }
 
-bool
-Event::GetPreventDefault() const
-{
-  nsCOMPtr<nsPIDOMWindowInner> win(do_QueryInterface(mOwner));
-  if (win) {
-    if (nsIDocument* doc = win->GetExtantDoc()) {
-      doc->WarnOnceAbout(nsIDocument::eGetPreventDefault);
-    }
-  }
-  // GetPreventDefault() is legacy and Gecko specific method.  Although,
-  // the result should be same as defaultPrevented, we don't need to break
-  // backward compatibility of legacy method.  Let's behave traditionally.
-  return DefaultPrevented();
-}
-
-NS_IMETHODIMP
-Event::GetPreventDefault(bool* aReturn)
-{
-  NS_ENSURE_ARG_POINTER(aReturn);
-  *aReturn = GetPreventDefault();
-  return NS_OK;
-}
-
 NS_IMETHODIMP
 Event::GetDefaultPrevented(bool* aReturn)
 {
   NS_ENSURE_ARG_POINTER(aReturn);
   // This method must be called by only event handlers implemented by C++.
   // Then, the handlers must handle default action.  So, this method don't need
   // to check if preventDefault() has been called by content or chrome.
   *aReturn = DefaultPrevented();
--- a/dom/events/Event.h
+++ b/dom/events/Event.h
@@ -231,18 +231,16 @@ public:
   }
 
   double TimeStamp() const;
 
   EventTarget* GetOriginalTarget() const;
   EventTarget* GetExplicitOriginalTarget() const;
   EventTarget* GetComposedTarget() const;
 
-  bool GetPreventDefault() const;
-
   /**
    * @param aCalledByDefaultHandler     Should be true when this is called by
    *                                    C++ or Chrome.  Otherwise, e.g., called
    *                                    by a call of Event.preventDefault() in
    *                                    content script, false.
    */
   void PreventDefaultInternal(bool aCalledByDefaultHandler,
                               nsIPrincipal* aPrincipal = nullptr);
@@ -393,17 +391,16 @@ private:
   NS_IMETHOD StopPropagation(void) override { return _to StopPropagation(); } \
   NS_IMETHOD StopCrossProcessForwarding(void) override { return _to StopCrossProcessForwarding(); } \
   NS_IMETHOD PreventDefault(void) override { return _to PreventDefault(); } \
   void InitEvent(const nsAString& eventTypeArg, bool canBubbleArg, bool cancelableArg) override { _to InitEvent(eventTypeArg, canBubbleArg, cancelableArg); } \
   NS_IMETHOD GetDefaultPrevented(bool* aDefaultPrevented) override { return _to GetDefaultPrevented(aDefaultPrevented); } \
   NS_IMETHOD StopImmediatePropagation(void) override { return _to StopImmediatePropagation(); } \
   NS_IMETHOD GetOriginalTarget(nsIDOMEventTarget** aOriginalTarget) override { return _to GetOriginalTarget(aOriginalTarget); } \
   NS_IMETHOD GetExplicitOriginalTarget(nsIDOMEventTarget** aExplicitOriginalTarget) override { return _to GetExplicitOriginalTarget(aExplicitOriginalTarget); } \
-  NS_IMETHOD GetPreventDefault(bool* aRetval) override { return _to GetPreventDefault(aRetval); } \
   NS_IMETHOD GetIsTrusted(bool* aIsTrusted) override { return _to GetIsTrusted(aIsTrusted); } \
   NS_IMETHOD SetTarget(nsIDOMEventTarget* aTarget) override { return _to SetTarget(aTarget); } \
   NS_IMETHOD_(bool) IsDispatchStopped(void) override { return _to IsDispatchStopped(); } \
   NS_IMETHOD_(WidgetEvent*) WidgetEventPtr(void) override { return _to WidgetEventPtr(); } \
   NS_IMETHOD_(void) SetTrusted(bool aTrusted) override { _to SetTrusted(aTrusted); } \
   NS_IMETHOD_(void) SetOwner(EventTarget* aOwner) override { _to SetOwner(aOwner); } \
   NS_IMETHOD_(Event*) InternalDOMEvent() override { return _to InternalDOMEvent(); } \
   NS_IMETHOD GetCancelBubble(bool* aCancelBubble) override { return _to GetCancelBubble(aCancelBubble); } \
--- a/dom/interfaces/events/nsIDOMEvent.idl
+++ b/dom/interfaces/events/nsIDOMEvent.idl
@@ -193,22 +193,16 @@ interface nsIDOMEvent : nsISupports
    * are retargeted to their parent node when they happen over text nodes (bug
    * 185889), and in that case .target will show the parent and
    * .explicitOriginalTarget will show the text node.
    * .explicitOriginalTarget differs from .originalTarget in that it will never
    * contain anonymous content.
    */
   readonly attribute nsIDOMEventTarget  explicitOriginalTarget;
 
-  /**
-   * @deprecated Use nsIDOMEvent::defaultPrevented.
-   * To be removed in bug 691151.
-   */
-  boolean                   getPreventDefault();
-
   readonly attribute boolean isTrusted;
   attribute boolean cancelBubble;
 
   [noscript] void duplicatePrivateData();
   [noscript] void setTarget(in nsIDOMEventTarget aTarget);
   [notxpcom] boolean IsDispatchStopped();
   [notxpcom] WidgetEvent WidgetEventPtr();
   [noscript,notxpcom] void SetTrusted(in boolean aTrusted);
--- a/dom/locales/en-US/chrome/dom/dom.properties
+++ b/dom/locales/en-US/chrome/dom/dom.properties
@@ -153,18 +153,16 @@ PluginHangUITitle=Warning: Unresponsive 
 PluginHangUIMessage=%S may be busy, or it may have stopped responding. You can stop the plugin now, or you can continue to see if the plugin will complete.
 PluginHangUIWaitButton=Continue
 PluginHangUIStopButton=Stop plugin
 PrefixedFullscreenAPIWarning=Prefixed Fullscreen API is deprecated. Please use unprefixed API for fullscreen. For more help https://developer.mozilla.org/en-US/docs/Web/API/Fullscreen_API
 # LOCALIZATION NOTE: Do not translate "NodeIterator" or "detach()".
 NodeIteratorDetachWarning=Calling detach() on a NodeIterator no longer has an effect.
 # LOCALIZATION NOTE: Do not translate "LenientThis" and "this"
 LenientThisWarning=Ignoring get or set of property that has [LenientThis] because the “this” object is incorrect.
-# LOCALIZATION NOTE: Do not translate "getPreventDefault" or "defaultPrevented".
-GetPreventDefaultWarning=Use of getPreventDefault() is deprecated.  Use defaultPrevented instead.
 # LOCALIZATION NOTE: Do not translate "getUserData", "setUserData", "WeakMap", or "element.dataset".
 GetSetUserDataWarning=Use of getUserData() or setUserData() is deprecated.  Use WeakMap or element.dataset instead.
 # LOCALIZATION NOTE: Do not translate "mozGetAsFile" or "toBlob"
 MozGetAsFileWarning=The non-standard mozGetAsFile method is deprecated and will soon be removed.  Use the standard toBlob method instead.
 # LOCALIZATION NOTE: Do not translate "captureEvents()" or "addEventListener()"
 UseOfCaptureEventsWarning=Use of captureEvents() is deprecated. To upgrade your code, use the DOM 2 addEventListener() method. For more help http://developer.mozilla.org/en/docs/DOM:element.addEventListener
 # LOCALIZATION NOTE: Do not translate "releaseEvents()" or "removeEventListener()"
 UseOfReleaseEventsWarning=Use of releaseEvents() is deprecated. To upgrade your code, use the DOM 2 removeEventListener() method. For more help http://developer.mozilla.org/en/docs/DOM:element.removeEventListener
--- a/dom/webidl/Event.webidl
+++ b/dom/webidl/Event.webidl
@@ -63,16 +63,15 @@ partial interface Event {
   const long SHIFT_MASK   = 0x00000004;
   const long META_MASK    = 0x00000008;
 
   readonly attribute EventTarget? originalTarget;
   readonly attribute EventTarget? explicitOriginalTarget;
   [ChromeOnly] readonly attribute EventTarget? composedTarget;
   [ChromeOnly] readonly attribute boolean multipleActionsPrevented;
   [ChromeOnly] readonly attribute boolean isSynthesized;
-  boolean getPreventDefault();
 };
 
 dictionary EventInit {
   boolean bubbles = false;
   boolean cancelable = false;
   boolean composed = false;
 };
--- a/layout/forms/test/test_bug935876.html
+++ b/layout/forms/test/test_bug935876.html
@@ -67,17 +67,20 @@ function runTests()
     keyPressEventFired = true;
   }
 
   var keyDownEventConsumedByJS = false;
   var keyDownEventConsumed = false;
   function onkeydownInSystemEventGroup(aEvent)
   {
     keyDownEventConsumedByJS = aEvent.defaultPrevented;
-    keyDownEventConsumed = aEvent.getPreventDefault();
+    // If defaultPrevented is true via SpecialPowers, that means default was
+    // prevented, possibly in a non-content-visible way (e.g. by a system
+    // group handler).
+    keyDownEventConsumed = SpecialPowers.wrap(aEvent).defaultPrevented;
   }
 
   function reset()
   {
     keyPressEventFired = false;
     keyDownEventConsumedByJS = false;
     keyDownEventConsumed = false;
   }