Bug 1297993 - Include the ID of the offending <key> element in the key conflict message. r=masayuki
authorJared Wein <jwein@mozilla.com>
Wed, 31 Aug 2016 12:53:24 -0400
changeset 408122 286a80b932232b2d9c90446c59214a028b5edec9
parent 408121 fdf90317de6820adc8c2b9b1e70f8d11fa859636
child 408123 3cc323454ca207296929482625fee1d3224cc1d8
child 408229 9951bd123089111571abc88aec7a24691e519c00
child 408345 9e00b305da24074ae5aba1227beb5e096b026100
child 408574 215b219482a545aea1118d436eb77334bbb4be21
push id28150
push usernalexander@mozilla.com
push dateWed, 31 Aug 2016 18:42:03 +0000
reviewersmasayuki
bugs1297993
milestone51.0a1
Bug 1297993 - Include the ID of the offending <key> element in the key conflict message. r=masayuki MozReview-Commit-ID: 7hZLCZqfHAy
dom/locales/en-US/chrome/layout/xbl.properties
dom/xbl/nsXBLPrototypeHandler.cpp
--- a/dom/locales/en-US/chrome/layout/xbl.properties
+++ b/dom/locales/en-US/chrome/layout/xbl.properties
@@ -1,15 +1,15 @@
 # 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/.
 
 UnexpectedElement=Unexpected <%1$S> element.
-# LOCALIZATION NOTE: do not localize key=“%S” modifiers=“%S”
-GTK2Conflict=Key event not available on GTK2: key=“%S” modifiers=“%S”
-WinConflict=Key event not available on some keyboard layouts: key=“%S” modifiers=“%S”
+# LOCALIZATION NOTE: do not localize key=“%S” modifiers=“%S” id=“%S”
+GTK2Conflict2=Key event not available on GTK2: key=“%S” modifiers=“%S” id=“%S”
+WinConflict2=Key event not available on some keyboard layouts: key=“%S” modifiers=“%S” id=“%S”
 TooDeepBindingRecursion=The XBL binding “%S” is already used by too many ancestor elements; not applying it to prevent infinite recursion.
 CircularExtendsBinding=Extending the XBL binding “%S” with “%S” would lead to it extending itself
 # LOCALIZATION NOTE: do not localize <handler command="…">
 CommandNotInChrome=Use of <handler command="…"> not allowed outside chrome.
 MalformedXBL = An XBL file is malformed. Did you forget the XBL namespace on the bindings tag?
 InvalidExtendsBinding=Extending “%S” is invalid. In general, do not extend tag names.
 MissingIdAttr = An “id” attribute missing on the binding tag.
--- a/dom/xbl/nsXBLPrototypeHandler.cpp
+++ b/dom/xbl/nsXBLPrototypeHandler.cpp
@@ -834,23 +834,23 @@ nsXBLPrototypeHandler::ConstructPrototyp
 
     // We have a charcode.
     mMisc = 1;
     mDetail = key[0];
     const uint8_t GTK2Modifiers = cShift | cControl | cShiftMask | cControlMask;
     if ((mKeyMask & GTK2Modifiers) == GTK2Modifiers &&
         modifiers.First() != char16_t(',') &&
         (mDetail == 'u' || mDetail == 'U'))
-      ReportKeyConflict(key.get(), modifiers.get(), aKeyElement, "GTK2Conflict");
+      ReportKeyConflict(key.get(), modifiers.get(), aKeyElement, "GTK2Conflict2");
     const uint8_t WinModifiers = cControl | cAlt | cControlMask | cAltMask;
     if ((mKeyMask & WinModifiers) == WinModifiers &&
         modifiers.First() != char16_t(',') &&
         (('A' <= mDetail && mDetail <= 'Z') ||
          ('a' <= mDetail && mDetail <= 'z')))
-      ReportKeyConflict(key.get(), modifiers.get(), aKeyElement, "WinConflict");
+      ReportKeyConflict(key.get(), modifiers.get(), aKeyElement, "WinConflict2");
   }
   else {
     key.Assign(aKeyCode);
     if (mType & NS_HANDLER_TYPE_XUL)
       aKeyElement->GetAttr(kNameSpaceID_None, nsGkAtoms::keycode, key);
     
     if (!key.IsEmpty()) {
       if (mKeyMask == 0)
@@ -884,17 +884,19 @@ nsXBLPrototypeHandler::ReportKeyConflict
     nsXBLDocumentInfo* docInfo = mPrototypeBinding->XBLDocumentInfo();
     if (docInfo) {
       doc = docInfo->GetDocument();
     }
   } else if (aKeyElement) {
     doc = aKeyElement->OwnerDoc();
   }
 
-  const char16_t* params[] = { aKey, aModifiers };
+  nsAutoString id;
+  aKeyElement->GetAttr(kNameSpaceID_None, nsGkAtoms::id, id);
+  const char16_t* params[] = { aKey, aModifiers, id.get() };
   nsContentUtils::ReportToConsole(nsIScriptError::warningFlag,
                                   NS_LITERAL_CSTRING("XBL Prototype Handler"), doc,
                                   nsContentUtils::eXBL_PROPERTIES,
                                   aMessageName,
                                   params, ArrayLength(params),
                                   nullptr, EmptyString(), mLineNumber);
 }