Bug 1297993 - Include the ID of the offending <key> element in the key conflict message. r?masayuki draft
authorJared Wein <jwein@mozilla.com>
Thu, 25 Aug 2016 08:39:44 -0400
changeset 405325 8f56c9145fdaa8d4104dae83dd00494421ab570b
parent 404538 1b93a25d0fe22bd10bae50eb705a25616f84477c
child 529437 42658d8d0125de0ef479078b2358bc60a80c1f3f
push id27486
push userjwein@mozilla.com
push dateThu, 25 Aug 2016 12:40:06 +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: DGgyGY6fjlM
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”
+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);
 }