Bug 1899559, remove unusued addManuallyManagedState and removeManuallyManagedState, r=dom-core,peterv

Differential Revision: https://phabricator.services.mozilla.com/D212000
This commit is contained in:
Neil Deakin 2024-06-10 23:57:47 +00:00
Родитель 3f1ad2c924
Коммит 1d9100c912
11 изменённых файлов: 8 добавлений и 87 удалений

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

@ -4287,61 +4287,6 @@ struct StateTableEntry {
ElementState mState;
};
static constexpr StateTableEntry kManuallyManagedStates[] = {
{"autofill", ElementState::AUTOFILL},
// :-moz-autofill-preview implies :autofill.
{"-moz-autofill-preview",
ElementState::AUTOFILL_PREVIEW | ElementState::AUTOFILL},
{nullptr, ElementState()},
};
static_assert(!kManuallyManagedStates[ArrayLength(kManuallyManagedStates) - 1]
.mStateString,
"last kManuallyManagedStates entry must be a sentinel with "
"mStateString == nullptr");
static ElementState GetEventStateForString(const nsAString& aStateString) {
for (const StateTableEntry* entry = kManuallyManagedStates;
entry->mStateString; ++entry) {
if (aStateString.EqualsASCII(entry->mStateString)) {
return entry->mState;
}
}
return ElementState();
}
NS_IMETHODIMP
nsDOMWindowUtils::AddManuallyManagedState(Element* aElement,
const nsAString& aStateString) {
if (!aElement) {
return NS_ERROR_INVALID_ARG;
}
ElementState state = GetEventStateForString(aStateString);
if (state.IsEmpty()) {
return NS_ERROR_INVALID_ARG;
}
aElement->AddStates(state);
return NS_OK;
}
NS_IMETHODIMP
nsDOMWindowUtils::RemoveManuallyManagedState(Element* aElement,
const nsAString& aStateString) {
if (!aElement) {
return NS_ERROR_INVALID_ARG;
}
ElementState state = GetEventStateForString(aStateString);
if (state.IsEmpty()) {
return NS_ERROR_INVALID_ARG;
}
aElement->RemoveStates(state);
return NS_OK;
}
NS_IMETHODIMP
nsDOMWindowUtils::GetStorageUsage(Storage* aStorage, int64_t* aRetval) {
if (!aStorage) {

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

@ -2070,26 +2070,6 @@ interface nsIDOMWindowUtils : nsISupports {
*/
readonly attribute int32_t gpuProcessPid;
/**
* Adds an ElementState bit to the element.
*
* The state string must be one of the following:
* * (none yet; but for example "higlighted" for ElementState::HIGHLIGHTED)
*
* The supported state strings are defined in kManuallyManagedStates
* in nsDOMWindowUtils.cpp.
*/
void addManuallyManagedState(in Element element,
in AString state);
/**
* Removes the specified ElementState bits from the element.
*
* See above for the strings that can be passed for |state|.
*/
void removeManuallyManagedState(in Element element,
in AString state);
/**
* Returns usage data for a given storage object.
*

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

@ -5,5 +5,5 @@
SpecialPowers.Cc["@mozilla.org/satchel/form-fill-controller;1"].getService(SpecialPowers.Ci.nsIFormFillController).markAsAutoCompletableField(input);
input.getBoundingClientRect(); // previewValue setter depends on the reframe posted by markAsAutoCompletableField() having being processed...
input.previewValue = "Autofill";
SpecialPowers.wrap(window).windowUtils.addManuallyManagedState(input, "-moz-autofill-preview");
input.autofillState = "preview";
</script>

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

@ -4,5 +4,5 @@
let input = SpecialPowers.wrap(document.querySelector("input"));
SpecialPowers.Cc["@mozilla.org/satchel/form-fill-controller;1"].getService(SpecialPowers.Ci.nsIFormFillController).markAsAutoCompletableField(input);
input.getBoundingClientRect();
SpecialPowers.wrap(window).windowUtils.addManuallyManagedState(input, "autofill");
input.autofillState = "autofill";
</script>

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

@ -5,5 +5,5 @@
<input value="Autofill">
<script>
let input = SpecialPowers.wrap(document.querySelector("input"));
SpecialPowers.wrap(window).windowUtils.addManuallyManagedState(input, "autofill");
input.autofillState = "autofill";
</script>

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

@ -5,5 +5,5 @@
SpecialPowers.Cc["@mozilla.org/satchel/form-fill-controller;1"].getService(SpecialPowers.Ci.nsIFormFillController).markAsAutoCompletableField(input);
input.getBoundingClientRect(); // previewValue setter depends on the reframe posted by markAsAutoCompletableField() having being processed...
input.previewValue = "Autofill";
SpecialPowers.wrap(window).windowUtils.addManuallyManagedState(input, "-moz-autofill-preview");
input.autofillState = "preview";
</script>

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

@ -4,5 +4,5 @@
let input = SpecialPowers.wrap(document.querySelector("input"));
SpecialPowers.Cc["@mozilla.org/satchel/form-fill-controller;1"].getService(SpecialPowers.Ci.nsIFormFillController).markAsAutoCompletableField(input);
input.getBoundingClientRect();
SpecialPowers.wrap(window).windowUtils.addManuallyManagedState(input, "-moz-autofill-preview");
input.autofillState = "preview";
</script>

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

@ -8,5 +8,5 @@
SpecialPowers.Cc["@mozilla.org/satchel/form-fill-controller;1"].getService(SpecialPowers.Ci.nsIFormFillController).markAsAutoCompletableField(input);
input.getBoundingClientRect(); // previewValue setter depends on the reframe posted by markAsAutoCompletableField() having being processed...
input.previewValue = "Autofill";
SpecialPowers.wrap(window).windowUtils.addManuallyManagedState(input, "-moz-autofill-preview");
input.autofillState = "preview";
</script>

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

@ -5,5 +5,5 @@
SpecialPowers.Cc["@mozilla.org/satchel/form-fill-controller;1"].getService(SpecialPowers.Ci.nsIFormFillController).markAsAutoCompletableField(input);
input.getBoundingClientRect(); // previewValue setter depends on the reframe posted by markAsAutoCompletableField() having being processed...
input.previewValue = "Autofill";
SpecialPowers.wrap(window).windowUtils.addManuallyManagedState(input, "-moz-autofill-preview");
input.autofillState = "preview";
</script>

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

@ -5,5 +5,5 @@
SpecialPowers.Cc["@mozilla.org/satchel/form-fill-controller;1"].getService(SpecialPowers.Ci.nsIFormFillController).markAsAutoCompletableField(input);
input.getBoundingClientRect(); // previewValue setter depends on the reframe posted by markAsAutoCompletableField() having being processed...
input.previewValue = "Autofill";
SpecialPowers.wrap(window).windowUtils.addManuallyManagedState(input, "autofill");
input.autofillState = "autofill";
</script>

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

@ -59,10 +59,6 @@ export const MockDocument = {
mockOwnerGlobalProperty(aElement) {
Object.defineProperty(aElement, "ownerGlobal", {
value: {
windowUtils: {
addManuallyManagedState() {},
removeManuallyManagedState() {},
},
UIEvent: Event,
Event,
},