Bug 240627 Add warnings for some reserved key shortcuts r=bryner sr=bz

This commit is contained in:
neil%parkwaycc.co.uk 2005-10-08 10:20:02 +00:00
Родитель c5eb47073a
Коммит 27a5e72b92
3 изменённых файлов: 31 добавлений и 0 удалений

Просмотреть файл

@ -68,6 +68,8 @@
#include "nsPIWindowRoot.h"
#include "nsIDOMWindowInternal.h"
#include "nsIServiceManager.h"
#include "nsContentUtils.h"
#include "nsIScriptError.h"
#include "nsXPIDLString.h"
#include "nsReadableUtils.h"
#include "nsXULAtoms.h"
@ -889,6 +891,17 @@ nsXBLPrototypeHandler::ConstructPrototype(nsIContent* aKeyElement,
// We have a charcode.
mMisc = 1;
mDetail = key[0];
const PRUint8 GTK2Modifiers = cShift | cControl | cShiftMask | cControlMask;
if ((mKeyMask & GTK2Modifiers) == GTK2Modifiers &&
modifiers.First() != PRUnichar(',') &&
(('0' <= mDetail && mDetail <= '9') ||
('a' <= mDetail && mDetail <= 'f')))
ReportKeyConflict(key.get(), modifiers.get(), aKeyElement, "GTK2Conflict");
const PRUint8 WinModifiers = cControl | cAlt | cControlMask | cAltMask;
if ((mKeyMask & WinModifiers) == WinModifiers &&
modifiers.First() != PRUnichar(',') &&
'a' <= mDetail && mDetail <= 'f')
ReportKeyConflict(key.get(), modifiers.get(), aKeyElement, "WinConflict");
}
else {
key.Assign(aKeyCode);
@ -918,6 +931,20 @@ nsXBLPrototypeHandler::ConstructPrototype(nsIContent* aKeyElement,
}
}
void
nsXBLPrototypeHandler::ReportKeyConflict(const PRUnichar* aKey, const PRUnichar* aModifiers, nsIContent* aKeyElement, const char *aMessageName)
{
nsIURI* uri = mPrototypeBinding ? uri = mPrototypeBinding->DocURI() :
aKeyElement ? aKeyElement->GetOwnerDoc()->GetDocumentURI() : nsnull;
const PRUnichar* params[] = { aKey, aModifiers };
nsContentUtils::ReportToConsole(nsContentUtils::eXBL_PROPERTIES,
aMessageName,
params, NS_ARRAY_LENGTH(params),
uri, EmptyString(), mLineNumber, 0,
nsIScriptError::warningFlag,
"XBL Prototype Handler");
}
PRBool
nsXBLPrototypeHandler::ModifiersMatchMask(nsIDOMUIEvent* aEvent)
{

Просмотреть файл

@ -160,6 +160,7 @@ protected:
const PRUnichar* aPreventDefault=nsnull,
const PRUnichar* aAllowUntrusted=nsnull);
void ReportKeyConflict(const PRUnichar* aKey, const PRUnichar* aModifiers, nsIContent* aElement, const char *aMessageName);
void GetEventType(nsAString& type);
PRBool ModifiersMatchMask(nsIDOMUIEvent* aEvent);

Просмотреть файл

@ -34,3 +34,6 @@
# ***** END LICENSE BLOCK *****
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"