diff options
Diffstat (limited to 'chromium/third_party/blink/renderer/core/html/forms/text_field_input_type.cc')
-rw-r--r-- | chromium/third_party/blink/renderer/core/html/forms/text_field_input_type.cc | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/chromium/third_party/blink/renderer/core/html/forms/text_field_input_type.cc b/chromium/third_party/blink/renderer/core/html/forms/text_field_input_type.cc index f217138591e..d0e17f104c2 100644 --- a/chromium/third_party/blink/renderer/core/html/forms/text_field_input_type.cc +++ b/chromium/third_party/blink/renderer/core/html/forms/text_field_input_type.cc @@ -89,7 +89,13 @@ class DataListIndicatorElement final : public HTMLDivElement { } public: - DataListIndicatorElement(Document& document) : HTMLDivElement(document) { + explicit DataListIndicatorElement(Document& document) + : HTMLDivElement(document) {} + + // This function should be called after appending |this| to a UA ShadowRoot. + void InitializeInShadowTree() { + DCHECK(ContainingShadowRoot()); + DCHECK(ContainingShadowRoot()->IsUserAgent()); SetShadowPseudoId(AtomicString("-webkit-calendar-picker-indicator")); setAttribute(html_names::kIdAttr, shadow_element_names::kIdPickerIndicator); setAttribute(html_names::kStyleAttr, @@ -320,8 +326,9 @@ void TextFieldInputType::CreateShadowSubtree() { container->AppendChild(editing_view_port); if (should_have_data_list_indicator) { - container->AppendChild( - MakeGarbageCollected<DataListIndicatorElement>(document)); + auto* data_list = MakeGarbageCollected<DataListIndicatorElement>(document); + container->AppendChild(data_list); + data_list->InitializeInShadowTree(); } // FIXME: Because of a special handling for a spin button in // LayoutTextControlSingleLine, we need to put it to the last position. It's @@ -360,9 +367,10 @@ void TextFieldInputType::ListAttributeTargetChanged() { if (will_have_picker_indicator) { Document& document = GetElement().GetDocument(); if (Element* container = ContainerElement()) { - container->InsertBefore( - MakeGarbageCollected<DataListIndicatorElement>(document), - GetSpinButtonElement()); + auto* data_list = + MakeGarbageCollected<DataListIndicatorElement>(document); + container->InsertBefore(data_list, GetSpinButtonElement()); + data_list->InitializeInShadowTree(); } else { // FIXME: The following code is similar to createShadowSubtree(), // but they are different. We should simplify the code by making @@ -377,8 +385,10 @@ void TextFieldInputType::ListAttributeTargetChanged() { MakeGarbageCollected<EditingViewPortElement>(document); editing_view_port->AppendChild(inner_editor); rp_container->AppendChild(editing_view_port); - rp_container->AppendChild( - MakeGarbageCollected<DataListIndicatorElement>(document)); + auto* data_list = + MakeGarbageCollected<DataListIndicatorElement>(document); + rp_container->AppendChild(data_list); + data_list->InitializeInShadowTree(); if (GetElement().GetDocument().FocusedElement() == GetElement()) GetElement().UpdateFocusAppearance(SelectionBehaviorOnFocus::kRestore); } |