Bug 1684001 - IsURIInPrefList should be infallible. r=masayuki

Differential Revision: https://phabricator.services.mozilla.com/D107455
This commit is contained in:
Emilio Cobos Álvarez 2021-03-08 23:36:40 +00:00
Родитель 3505b7d66e
Коммит 7dac28d4c1
2 изменённых файлов: 22 добавлений и 47 удалений

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

@ -308,22 +308,15 @@ interface nsIPrincipal : nsISerializable
*
* @param scheme The scheme to be checked
*/
[infallible]
boolean schemeIs(in string scheme);
// Nicer, C++ Callable Version of SchemeIs
%{C++
inline bool SchemeIs(const char* aScheme) {
bool ret;
SchemeIs(aScheme, &ret);
return ret;
}
%}
/*
* Checks if the Principal's URI is contained in the given Pref
* @param pref The pref to be checked
*/
bool isURIInPrefList(in string pref);
* Checks if the Principal's URI is contained in the given Pref
* @param pref The pref to be checked
*/
[infallible]
boolean isURIInPrefList(in string pref);
/*
* Uses NS_Security Compare to determine if the

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

@ -8641,41 +8641,25 @@ nsresult PresShell::EventHandler::DispatchEventToDOM(
// behave so, however, some web apps may be broken. On such web apps,
// we should keep using legacy our behavior.
if (!mPresShell->mInitializedWithKeyPressEventDispatchingBlacklist) {
bool isInPrefList = false;
mPresShell->mInitializedWithKeyPressEventDispatchingBlacklist = true;
nsCOMPtr<nsIPrincipal> principal =
GetDocumentPrincipalToCompareWithBlacklist(*mPresShell);
if (principal) {
principal->IsURIInPrefList(
"dom.keyboardevent.keypress.hack.dispatch_non_printable_keys",
&isInPrefList);
mPresShell->mForceDispatchKeyPressEventsForNonPrintableKeys =
isInPrefList;
principal->IsURIInPrefList(
"dom.keyboardevent.keypress.hack.dispatch_non_printable_"
"keys") ||
principal->IsURIInPrefList(
"dom.keyboardevent.keypress.hack."
"dispatch_non_printable_keys.addl");
principal->IsURIInPrefList(
"dom.keyboardevent.keypress.hack."
"dispatch_non_printable_keys.addl",
&isInPrefList);
mPresShell->mForceDispatchKeyPressEventsForNonPrintableKeys |=
isInPrefList;
principal->IsURIInPrefList(
"dom.keyboardevent.keypress.hack."
"use_legacy_keycode_and_charcode",
&isInPrefList);
mPresShell->mForceUseLegacyKeyCodeAndCharCodeValues |= isInPrefList;
principal->IsURIInPrefList(
"dom.keyboardevent.keypress.hack."
"use_legacy_keycode_and_charcode",
&isInPrefList);
mPresShell->mForceUseLegacyKeyCodeAndCharCodeValues |= isInPrefList;
principal->IsURIInPrefList(
"dom.keyboardevent.keypress.hack."
"use_legacy_keycode_and_charcode.addl",
&isInPrefList);
mPresShell->mForceUseLegacyKeyCodeAndCharCodeValues |= isInPrefList;
mPresShell->mForceUseLegacyKeyCodeAndCharCodeValues |=
principal->IsURIInPrefList(
"dom.keyboardevent.keypress.hack."
"use_legacy_keycode_and_charcode") ||
principal->IsURIInPrefList(
"dom.keyboardevent.keypress.hack."
"use_legacy_keycode_and_charcode.addl");
}
}
if (mPresShell->mForceDispatchKeyPressEventsForNonPrintableKeys) {
@ -8699,11 +8683,9 @@ nsresult PresShell::EventHandler::DispatchEventToDOM(
GetDocumentPrincipalToCompareWithBlacklist(*mPresShell);
if (principal) {
bool isInPrefList = false;
principal->IsURIInPrefList(
"dom.mouseevent.click.hack.use_legacy_non-primary_dispatch",
&isInPrefList);
mPresShell->mForceUseLegacyNonPrimaryDispatch = isInPrefList;
mPresShell->mForceUseLegacyNonPrimaryDispatch =
principal->IsURIInPrefList(
"dom.mouseevent.click.hack.use_legacy_non-primary_dispatch");
}
}
if (mPresShell->mForceUseLegacyNonPrimaryDispatch) {