Bug 1024864 Warn KeyboardEvent.key value change when KeyboardEvent.key is read and its key value is obsolete r=smaug
authorMasayuki Nakano <masayuki@d-toybox.com>
Sat, 14 Jun 2014 11:24:16 +0900
changeset 188739 3bb907654de0bfba7d1aa1022bb2867caa47664c
parent 188738 407e66c2e91d87849d73700a9093e922eb2b8809
child 188740 54b35d7d75cead73bfb507087f0f5abc3e98a293
push id26965
push userphilringnalda@gmail.com
push dateSun, 15 Jun 2014 16:28:39 +0000
treeherdermozilla-central@7a8d540c1cb2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1024864
milestone33.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 1024864 Warn KeyboardEvent.key value change when KeyboardEvent.key is read and its key value is obsolete r=smaug
content/base/public/nsDeprecatedOperationList.h
dom/events/KeyboardEvent.cpp
dom/locales/en-US/chrome/dom/dom.properties
--- a/content/base/public/nsDeprecatedOperationList.h
+++ b/content/base/public/nsDeprecatedOperationList.h
@@ -35,8 +35,33 @@ DEPRECATED_OPERATION(UseOfCaptureEvents)
 DEPRECATED_OPERATION(UseOfReleaseEvents)
 DEPRECATED_OPERATION(UseOfDOM3LoadMethod)
 DEPRECATED_OPERATION(ShowModalDialog)
 DEPRECATED_OPERATION(Window_Content)
 DEPRECATED_OPERATION(SyncXMLHttpRequest)
 DEPRECATED_OPERATION(DataContainerEvent)
 DEPRECATED_OPERATION(SendAsBinary)
 DEPRECATED_OPERATION(Window_Controllers)
+DEPRECATED_OPERATION(KeyNameDown)
+DEPRECATED_OPERATION(KeyNameLeft)
+DEPRECATED_OPERATION(KeyNameRight)
+DEPRECATED_OPERATION(KeyNameUp)
+DEPRECATED_OPERATION(KeyNameCrsel)
+DEPRECATED_OPERATION(KeyNameDel)
+DEPRECATED_OPERATION(KeyNameExsel)
+DEPRECATED_OPERATION(KeyNameMenu)
+DEPRECATED_OPERATION(KeyNameEsc)
+DEPRECATED_OPERATION(KeyNameNonconvert)
+DEPRECATED_OPERATION(KeyNameHalfWidth)
+DEPRECATED_OPERATION(KeyNameRomanCharacters)
+DEPRECATED_OPERATION(KeyNameFullWidth)
+DEPRECATED_OPERATION(KeyNameSelectMedia)
+DEPRECATED_OPERATION(KeyNameMediaNextTrack)
+DEPRECATED_OPERATION(KeyNameMediaPreviousTrack)
+DEPRECATED_OPERATION(KeyNameRed)
+DEPRECATED_OPERATION(KeyNameGreen)
+DEPRECATED_OPERATION(KeyNameYellow)
+DEPRECATED_OPERATION(KeyNameBlue)
+DEPRECATED_OPERATION(KeyNameLive)
+DEPRECATED_OPERATION(KeyNameApps)
+DEPRECATED_OPERATION(KeyNameFastFwd)
+DEPRECATED_OPERATION(KeyNameZoom)
+DEPRECATED_OPERATION(KeyNameDeadKeys)
--- a/dom/events/KeyboardEvent.cpp
+++ b/dom/events/KeyboardEvent.cpp
@@ -1,15 +1,16 @@
 /* -*- Mode: C++; 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 "mozilla/dom/KeyboardEvent.h"
 #include "mozilla/TextEvents.h"
+#include "nsIDocument.h"
 #include "prtime.h"
 
 namespace mozilla {
 namespace dom {
 
 KeyboardEvent::KeyboardEvent(EventTarget* aOwner,
                              nsPresContext* aPresContext,
                              WidgetKeyboardEvent* aEvent)
@@ -121,17 +122,120 @@ KeyboardEvent::GetModifierState(const ns
 
   *aState = GetModifierState(aKey);
   return NS_OK;
 }
 
 NS_IMETHODIMP
 KeyboardEvent::GetKey(nsAString& aKeyName)
 {
-  mEvent->AsKeyboardEvent()->GetDOMKeyName(aKeyName);
+  WidgetKeyboardEvent* keyboardEvent = mEvent->AsKeyboardEvent();
+  keyboardEvent->GetDOMKeyName(aKeyName);
+
+  nsIDocument::DeprecatedOperations deprecatedOperation;
+  switch (keyboardEvent->mKeyNameIndex) {
+    case KEY_NAME_INDEX_Down:
+      deprecatedOperation = nsIDocument::eKeyNameDown;
+      break;
+    case KEY_NAME_INDEX_Left:
+      deprecatedOperation = nsIDocument::eKeyNameLeft;
+      break;
+    case KEY_NAME_INDEX_Right:
+      deprecatedOperation = nsIDocument::eKeyNameRight;
+      break;
+    case KEY_NAME_INDEX_Up:
+      deprecatedOperation = nsIDocument::eKeyNameUp;
+      break;
+    case KEY_NAME_INDEX_Crsel:
+      deprecatedOperation = nsIDocument::eKeyNameCrsel;
+      break;
+    case KEY_NAME_INDEX_Del:
+      deprecatedOperation = nsIDocument::eKeyNameDel;
+      break;
+    case KEY_NAME_INDEX_Exsel:
+      deprecatedOperation = nsIDocument::eKeyNameExsel;
+      break;
+    case KEY_NAME_INDEX_Menu:
+      deprecatedOperation = nsIDocument::eKeyNameMenu;
+      break;
+    case KEY_NAME_INDEX_Esc:
+      deprecatedOperation = nsIDocument::eKeyNameEsc;
+      break;
+    case KEY_NAME_INDEX_Nonconvert:
+      deprecatedOperation = nsIDocument::eKeyNameNonconvert;
+      break;
+    case KEY_NAME_INDEX_HalfWidth:
+      deprecatedOperation = nsIDocument::eKeyNameHalfWidth;
+      break;
+    case KEY_NAME_INDEX_RomanCharacters:
+      deprecatedOperation = nsIDocument::eKeyNameRomanCharacters;
+      break;
+    case KEY_NAME_INDEX_FullWidth:
+      deprecatedOperation = nsIDocument::eKeyNameFullWidth;
+      break;
+    case KEY_NAME_INDEX_SelectMedia:
+      deprecatedOperation = nsIDocument::eKeyNameSelectMedia;
+      break;
+    case KEY_NAME_INDEX_MediaNextTrack:
+      deprecatedOperation = nsIDocument::eKeyNameMediaNextTrack;
+      break;
+    case KEY_NAME_INDEX_MediaPreviousTrack:
+      deprecatedOperation = nsIDocument::eKeyNameMediaPreviousTrack;
+      break;
+    case KEY_NAME_INDEX_Red:
+      deprecatedOperation = nsIDocument::eKeyNameRed;
+      break;
+    case KEY_NAME_INDEX_Green:
+      deprecatedOperation = nsIDocument::eKeyNameGreen;
+      break;
+    case KEY_NAME_INDEX_Yellow:
+      deprecatedOperation = nsIDocument::eKeyNameYellow;
+      break;
+    case KEY_NAME_INDEX_Blue:
+      deprecatedOperation = nsIDocument::eKeyNameBlue;
+      break;
+    case KEY_NAME_INDEX_Live:
+      deprecatedOperation = nsIDocument::eKeyNameLive;
+      break;
+    case KEY_NAME_INDEX_Apps:
+      deprecatedOperation = nsIDocument::eKeyNameApps;
+      break;
+    case KEY_NAME_INDEX_FastFwd:
+      deprecatedOperation = nsIDocument::eKeyNameFastFwd;
+      break;
+    case KEY_NAME_INDEX_Zoom:
+      deprecatedOperation = nsIDocument::eKeyNameZoom;
+      break;
+    case KEY_NAME_INDEX_DeadGrave:
+    case KEY_NAME_INDEX_DeadAcute:
+    case KEY_NAME_INDEX_DeadCircumflex:
+    case KEY_NAME_INDEX_DeadTilde:
+    case KEY_NAME_INDEX_DeadMacron:
+    case KEY_NAME_INDEX_DeadBreve:
+    case KEY_NAME_INDEX_DeadAboveDot:
+    case KEY_NAME_INDEX_DeadUmlaut:
+    case KEY_NAME_INDEX_DeadAboveRing:
+    case KEY_NAME_INDEX_DeadDoubleacute:
+    case KEY_NAME_INDEX_DeadCaron:
+    case KEY_NAME_INDEX_DeadCedilla:
+    case KEY_NAME_INDEX_DeadOgonek:
+    case KEY_NAME_INDEX_DeadIota:
+    case KEY_NAME_INDEX_DeadVoicedSound:
+    case KEY_NAME_INDEX_DeadSemivoicedSound:
+      deprecatedOperation = nsIDocument::eKeyNameDeadKeys;
+      break;
+    default:
+      return NS_OK;
+  }
+
+  nsIDocument* doc = mOwner ? mOwner->GetExtantDoc() : nullptr;
+  if (NS_WARN_IF(!doc)) {
+    return NS_OK;
+  }
+  doc->WarnOnceAbout(deprecatedOperation);
   return NS_OK;
 }
 
 void
 KeyboardEvent::GetCode(nsAString& aCodeName)
 {
   mEvent->AsKeyboardEvent()->GetDOMCodeName(aCodeName);
 }
--- a/dom/locales/en-US/chrome/dom/dom.properties
+++ b/dom/locales/en-US/chrome/dom/dom.properties
@@ -152,8 +152,58 @@ Window_ContentWarning=window._content is
 SyncXMLHttpRequestWarning=Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience. For more help http://xhr.spec.whatwg.org/
 ImplicitMetaViewportTagFallback=No meta-viewport tag found. Please explicitly specify one to prevent unexpected behavioural changes in future versions. For more help https://developer.mozilla.org/en/docs/Mozilla/Mobile/Viewport_meta_tag
 # LOCALIZATION NOTE: Do not translate "DataContainerEvent" or "CustomEvent"
 DataContainerEventWarning=Use of DataContainerEvent is deprecated. Use CustomEvent instead.
 # LOCALIZATION NOTE: Do not translate "sendAsBinary" or "send(Blob data)"
 SendAsBinaryWarning=The non-standard sendAsBinary method is deprecated and will soon be removed. Use the standard send(Blob data) method instead.
 # LOCALIZATION NOTE: Do not translate "window.controllers"
 Window_ControllersWarning=window.controllers is deprecated. Do not use it for UA detection.
+# LOCALIZATION NOTE: Do not translate "KeyboardEvent.key", "Down" and "ArrowDown".
+KeyNameDownWarning=KeyboardEvent.key value "Down" is obsolete and will be renamed to "ArrowDown". For more help https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent.key
+# LOCALIZATION NOTE: Do not translate "KeyboardEvent.key", "Left" and "ArrowLeft".
+KeyNameLeftWarning=KeyboardEvent.key value "Left" is obsolete and will be renamed to "ArrowLeft". For more help https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent.key
+# LOCALIZATION NOTE: Do not translate "KeyboardEvent.key", "Right" and "ArrowRight".
+KeyNameRightWarning=KeyboardEvent.key value "Right" is obsolete and will be renamed to "ArrowRight". For more help https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent.key
+# LOCALIZATION NOTE: Do not translate "KeyboardEvent.key", "Up" and "ArrowUp".
+KeyNameUpWarning=KeyboardEvent.key value "Up" is obsolete and will be renamed to "ArrowUp". For more help https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent.key
+# LOCALIZATION NOTE: Do not translate "KeyboardEvent.key", "Crsel" and "CrSel".
+KeyNameCrselWarning=KeyboardEvent.key value "Crsel" is obsolete and will be renamed to "CrSel". For more help https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent.key
+# LOCALIZATION NOTE: Do not translate "KeyboardEvent.key", "Del" and "Delete".
+KeyNameDelWarning=KeyboardEvent.key value "Del" is obsolete and will be renamed to "Delete". For more help https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent.key
+# LOCALIZATION NOTE: Do not translate "KeyboardEvent.key", "Exsel" and "ExSel".
+KeyNameExselWarning=KeyboardEvent.key value "Exsel" is obsolete and will be renamed to "ExSel". For more help https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent.key
+# LOCALIZATION NOTE: Do not translate "KeyboardEvent.key", "Menu" and "ContextMenu".
+KeyNameMenuWarning=KeyboardEvent.key value "Menu" is obsolete and will be renamed to "ContextMenu". For more help https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent.key
+# LOCALIZATION NOTE: Do not translate "KeyboardEvent.key", "Esc" and "Escape".
+KeyNameEscWarning=KeyboardEvent.key value "Esc" is obsolete and will be renamed to "Escape". For more help https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent.key
+# LOCALIZATION NOTE: Do not translate "KeyboardEvent.key", "Nonconvert" and "NonConvert".
+KeyNameNonconvertWarning=KeyboardEvent.key value "Nonconvert" is obsolete and will be renamed to "NonConvert". For more help https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent.key
+# LOCALIZATION NOTE: Do not translate "KeyboardEvent.key", "HalfWidth" and "Hankaku".
+KeyNameHalfWidthWarning=KeyboardEvent.key value "HalfWidth" is obsolete and will be renamed to "Hankaku". For more help https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent.key
+# LOCALIZATION NOTE: Do not translate "KeyboardEvent.key", "RomanCharacters", "Romaji" and "Eisu".
+KeyNameRomanCharactersWarning=KeyboardEvent.key value "RomanCharacters" is obsolete and will be renamed to "Romaji" or remapped to "Eisu". For more help https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent.key
+# LOCALIZATION NOTE: Do not translate "KeyboardEvent.key", "FullWith" and "Zenkaku".
+KeyNameFullWidthWarning=KeyboardEvent.key value "FullWidth" is obsolete and will be renamed to "Zenkaku". For more help https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent.key
+# LOCALIZATION NOTE: Do not translate "KeyboardEvent.key", "SelectMedia" and "MediaSelect".
+KeyNameSelectMediaWarning=KeyboardEvent.key value "SelectMedia" is obsolete and will be renamed to "MediaSelect". For more help https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent.key
+# LOCALIZATION NOTE: Do not translate "KeyboardEvent.key", "MediaNextTrack" and "MediaTrackNext".
+KeyNameMediaNextTrackWarning=KeyboardEvent.key value "MediaNextTrack" is obsolete and will be renamed to "MediaTrackNext". For more help https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent.key
+# LOCALIZATION NOTE: Do not translate "KeyboardEvent.key", "MediaPreviousTrack" and "MediaTrackPrevious".
+KeyNameMediaPreviousTrackWarning=KeyboardEvent.key value "MediaPreviousTrack" is obsolete and will be renamed to "MediaTrackPrevious". For more help https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent.key
+# LOCALIZATION NOTE: Do not translate "KeyboardEvent.key", "Red" and "ColorF0Red".
+KeyNameRedWarning=KeyboardEvent.key value "Red" is obsolete and will be renamed to "ColorF0Red". For more help https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent.key
+# LOCALIZATION NOTE: Do not translate "KeyboardEvent.key", "Green" and "ColorF1Green".
+KeyNameGreenWarning=KeyboardEvent.key value "Green" is obsolete and will be renamed to "ColorF1Green". For more help https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent.key
+# LOCALIZATION NOTE: Do not translate "KeyboardEvent.key", "Yellow" and "ColorF2Yellow".
+KeyNameYellowWarning=KeyboardEvent.key value "Yellow" is obsolete and will be renamed to "ColorF2Yellow". For more help https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent.key
+# LOCALIZATION NOTE: Do not translate "KeyboardEvent.key", "Blue" and "ColorF3Blue".
+KeyNameBlueWarning=KeyboardEvent.key value "Blue" is obsolete and will be renamed to "ColorF3Blue". For more help https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent.key
+# LOCALIZATION NOTE: Do not translate "KeyboardEvent.key", "Live".
+KeyNameLiveWarning=KeyboardEvent.key value "Live" is obsolete and will be removed. For more help https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent.key
+# LOCALIZATION NOTE: Do not translate "KeyboardEvent.key", "Apps".
+KeyNameAppsWarning=KeyboardEvent.key value "Apps" is obsolete and will be removed. For more help https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent.key
+# LOCALIZATION NOTE: Do not translate "KeyboardEvent.key", "FastFwd" and "MediaFastForward".
+KeyNameFastFwdWarning=KeyboardEvent.key value "FastFwd" is obsolete and will be renamed to "MediaFastForward". For more help https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent.key
+# LOCALIZATION NOTE: Do not translate "KeyboardEvent.key", "Zoom" and "ZoomToggle".
+KeyNameZoomWarning=KeyboardEvent.key value "Zoom" is obsolete and will be renamed to "ZoomToggle". For more help https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent.key
+# LOCALIZATION NOTE: Do not translate "KeyboardEvent.key" and "Dead".
+KeyNameDeadKeysWarning=KeyboardEvent.key values starting with "Dead" are obsolete and will be merged into just "Dead". For more help https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent.key