Bug 1496242 - Part I, Simplify nsIDateTimeInputArea interface r=mconley,smaug

This patch simplifies the nsIDateTimeInputArea interface, implemented by the
datetimebox bindings, to a point that is easier to convert it to dispatch events,
by doing the following:

- hasBadInput() is re-implemented in C++ in nsIDateTimeControlFrame since
  C++ needs the return value synchronously.
- SetValueFromPicker() and SetPickerState() are avoided completed since they
  are simply called by HTMLInputElement methods exposed to the frame
  script. They are avoided by having the frame script access the NAC and call
  the nsIDateTimeInputArea methods directly.
- Merge setEditAttribute() and removeEditAttribute() to updateEditAttributes()
  which takes no arguments, and have the method access the attribute values by
  reading the values from <input>.

This patch is a scaled-down version of the patch proposed in bug 1456833.
The event approach is only usable in UA Widget version of datetimebox because
there is no way to avoid leaking events to the document without Shadow DOM.

Differential Revision: https://phabricator.services.mozilla.com/D9056
This commit is contained in:
Timothy Guan-tin Chien
2018-11-02 23:29:42 +00:00
parent 77f4653a7a
commit 00f30f1d00
8 changed files with 73 additions and 220 deletions

View File

@@ -2220,30 +2220,13 @@ void HTMLInputElement::GetDateTimeInputBoxValue(DateTimeValue& aValue)
aValue = *mDateTimeInputBoxValue;
}
void
HTMLInputElement::UpdateDateTimeInputBox(const DateTimeValue& aValue)
Element* HTMLInputElement::GetDateTimeBoxElement()
{
if (NS_WARN_IF(!IsDateTimeInputType(mType))) {
return;
}
nsDateTimeControlFrame* frame = do_QueryFrame(GetPrimaryFrame());
if (frame) {
frame->SetValueFromPicker(aValue);
}
}
void
HTMLInputElement::SetDateTimePickerState(bool aOpen)
{
if (NS_WARN_IF(!IsDateTimeInputType(mType))) {
return;
}
nsDateTimeControlFrame* frame = do_QueryFrame(GetPrimaryFrame());
if (frame) {
frame->SetPickerState(aOpen);
return frame->GetInputAreaContent()->AsElement();
}
return nullptr;
}
void