Skip to content

Commit

Permalink
Show picker for temporal input elements on Android
Browse files Browse the repository at this point in the history
This CL makes sure the showPicker() method actually shows the picker
on Android. It wasn't the case with the previous CL[1] because
MultipleFieldsTemporalInputTypeView is only supported on Desktop.
ChooserOnlyTemporalInputTypeView is the class to update to add support
for showPicker() on Android.

[1] https://chromium-review.googlesource.com/c/chromium/src/+/3056920

Change-Id: Ibab81e7d54c6c8e5442aef1d60f4b1cde3dba2c6
Test: https://show-picker.glitch.me/
Spec: whatwg/html#6909
Bug: 939561
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3263866
Commit-Queue: François Beaufort <beaufort.francois@gmail.com>
Reviewed-by: Mason Freed <masonf@chromium.org>
Cr-Commit-Position: refs/heads/main@{#938980}
NOKEYCHECK=True
GitOrigin-RevId: 43f41a8d8039ce72ca983f5892c4484e16d364d1
  • Loading branch information
beaufortfrancois authored and copybara-github committed Nov 6, 2021
1 parent 353917b commit ba50b3d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,19 +63,27 @@ void ChooserOnlyTemporalInputTypeView::HandleDOMActivateEvent(Event& event) {

if (date_time_chooser_)
return;
if (!document.IsActive())
return;
DateTimeChooserParameters parameters;
if (!GetElement().SetupDateTimeChooserParameters(parameters))
// SetupDateTimeChooserParameters() in OpenPopupView() early-outs if we
// don't have a View, so do the same here just to avoid adding to the
// use counter.
if (!document.IsActive() || !document.View())
return;
UseCounter::Count(
document,
(event.UnderlyingEvent() && event.UnderlyingEvent()->isTrusted())
? WebFeature::kTemporalInputTypeChooserByTrustedClick
: WebFeature::kTemporalInputTypeChooserByUntrustedClick);
date_time_chooser_ =
document.GetPage()->GetChromeClient().OpenDateTimeChooser(
document.GetFrame(), this, parameters);
OpenPopupView();
}

void ChooserOnlyTemporalInputTypeView::OpenPopupView() {
DateTimeChooserParameters parameters;
if (GetElement().SetupDateTimeChooserParameters(parameters)) {
Document& document = GetElement().GetDocument();
date_time_chooser_ =
document.GetPage()->GetChromeClient().OpenDateTimeChooser(
document.GetFrame(), this, parameters);
}
}

void ChooserOnlyTemporalInputTypeView::CreateShadowSubtree() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ class ChooserOnlyTemporalInputTypeView final
void ValueAttributeChanged() override;
void DidSetValue(const String&, bool value_changed) override;
void HandleDOMActivateEvent(Event&) override;
void OpenPopupView() override;
void UpdateView() override;

// DateTimeChooserClient functions:
Expand Down

0 comments on commit ba50b3d

Please sign in to comment.