Bug 1936113 - Hook up :open to details, select, dialog, and input elements. r=webidl,emilio

Most of these elements are simple to support.

One slightly tricky item was <input type=date>, as testing indicates that the
front-end code usually (consistently?) hides the picker using setPickerState(),
which does not end up calling closeDateTimePicker() as might be expected.
So to properly track the open/closed state, I had to add a SetDateTimePickerState
webidl method, rather than just patching into the existing Open/Close calls.

Differential Revision: https://phabricator.services.mozilla.com/D234093
This commit is contained in:
Jonathan Kew
2025-01-17 09:17:28 +00:00
parent f2ff4b0233
commit a4d8e36aff
8 changed files with 39 additions and 2 deletions

View File

@@ -768,6 +768,7 @@ nsresult HTMLInputElement::InitColorPicker() {
rv = colorPicker->Open(callback);
if (NS_SUCCEEDED(rv)) {
mPickerRunning = true;
SetStates(ElementState::OPEN, true);
}
return rv;
@@ -876,6 +877,7 @@ nsresult HTMLInputElement::InitFilePicker(FilePickerType aType) {
rv = filePicker->Open(callback);
if (NS_SUCCEEDED(rv)) {
mPickerRunning = true;
SetStates(ElementState::OPEN, true);
}
return rv;
@@ -884,6 +886,7 @@ nsresult HTMLInputElement::InitFilePicker(FilePickerType aType) {
HTMLInputElement::gUploadLastDir->FetchDirectoryAndDisplayPicker(
doc, filePicker, callback);
mPickerRunning = true;
SetStates(ElementState::OPEN, true);
return NS_OK;
}
@@ -2280,6 +2283,10 @@ void HTMLInputElement::CloseDateTimePicker() {
CanBubble::eYes, Cancelable::eYes);
}
void HTMLInputElement::SetDateTimePickerState(bool aIsOpen) {
SetStates(ElementState::OPEN, aIsOpen);
}
void HTMLInputElement::SetFocusState(bool aIsFocused) {
if (NS_WARN_IF(!IsDateTimeInputType(mType))) {
return;
@@ -7416,7 +7423,10 @@ void HTMLInputElement::UpdateHasRange(bool aNotify) {
UpdateInRange(aNotify);
}
void HTMLInputElement::PickerClosed() { mPickerRunning = false; }
void HTMLInputElement::PickerClosed() {
mPickerRunning = false;
SetStates(ElementState::OPEN, false);
}
JSObject* HTMLInputElement::WrapNode(JSContext* aCx,
JS::Handle<JSObject*> aGivenProto) {