Bug 1297993 - Include the ID of the offending <key> element in the key conflict message. r?masayuki
MozReview-Commit-ID: DGgyGY6fjlM
--- 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);
}