chromium/third_party/blink/renderer/core/html/forms/html_select_element.cc

/*
 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
 * Copyright (C) 1999 Lars Knoll ([email protected])
 *           (C) 1999 Antti Koivisto ([email protected])
 *           (C) 2001 Dirk Mueller ([email protected])
 * Copyright (C) 2004, 2005, 2006, 2007, 2009, 2010, 2011 Apple Inc. All rights
 * reserved.
 *           (C) 2006 Alexey Proskuryakov ([email protected])
 * Copyright (C) 2010 Google Inc. All rights reserved.
 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved.
 * (http://www.torchmobile.com/)
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public License
 * along with this library; see the file COPYING.LIB.  If not, write to
 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 * Boston, MA 02110-1301, USA.
 *
 */

#include "third_party/blink/renderer/core/html/forms/html_select_element.h"

#include "build/build_config.h"
#include "third_party/blink/public/mojom/input/focus_type.mojom-blink.h"
#include "third_party/blink/public/platform/task_type.h"
#include "third_party/blink/public/strings/grit/blink_strings.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_union_htmlelement_long.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_union_htmloptgroupelement_htmloptionelement.h"
#include "third_party/blink/renderer/core/accessibility/ax_object_cache.h"
#include "third_party/blink/renderer/core/css/style_change_reason.h"
#include "third_party/blink/renderer/core/css/style_engine.h"
#include "third_party/blink/renderer/core/display_lock/display_lock_utilities.h"
#include "third_party/blink/renderer/core/dom/attribute.h"
#include "third_party/blink/renderer/core/dom/element_traversal.h"
#include "third_party/blink/renderer/core/dom/events/event_dispatch_forbidden_scope.h"
#include "third_party/blink/renderer/core/dom/events/scoped_event_queue.h"
#include "third_party/blink/renderer/core/dom/events/simulated_click_options.h"
#include "third_party/blink/renderer/core/dom/focus_params.h"
#include "third_party/blink/renderer/core/dom/node_computed_style.h"
#include "third_party/blink/renderer/core/dom/node_lists_node_data.h"
#include "third_party/blink/renderer/core/dom/node_traversal.h"
#include "third_party/blink/renderer/core/events/keyboard_event.h"
#include "third_party/blink/renderer/core/frame/local_frame.h"
#include "third_party/blink/renderer/core/html/forms/form_controller.h"
#include "third_party/blink/renderer/core/html/forms/form_data.h"
#include "third_party/blink/renderer/core/html/forms/html_button_element.h"
#include "third_party/blink/renderer/core/html/forms/html_data_list_element.h"
#include "third_party/blink/renderer/core/html/forms/html_form_element.h"
#include "third_party/blink/renderer/core/html/forms/html_opt_group_element.h"
#include "third_party/blink/renderer/core/html/forms/html_option_element.h"
#include "third_party/blink/renderer/core/html/forms/html_options_collection.h"
#include "third_party/blink/renderer/core/html/forms/html_selected_option_element.h"
#include "third_party/blink/renderer/core/html/forms/select_type.h"
#include "third_party/blink/renderer/core/html/html_hr_element.h"
#include "third_party/blink/renderer/core/html/html_slot_element.h"
#include "third_party/blink/renderer/core/html/parser/html_parser_idioms.h"
#include "third_party/blink/renderer/core/html_names.h"
#include "third_party/blink/renderer/core/inspector/console_message.h"
#include "third_party/blink/renderer/core/layout/flex/layout_flexible_box.h"
#include "third_party/blink/renderer/core/layout/hit_test_request.h"
#include "third_party/blink/renderer/core/layout/hit_test_result.h"
#include "third_party/blink/renderer/core/layout/layout_block_flow.h"
#include "third_party/blink/renderer/core/layout/layout_theme.h"
#include "third_party/blink/renderer/core/page/chrome_client.h"
#include "third_party/blink/renderer/core/page/page.h"
#include "third_party/blink/renderer/core/page/spatial_navigation.h"
#include "third_party/blink/renderer/platform/bindings/exception_state.h"
#include "third_party/blink/renderer/platform/heap/garbage_collected.h"
#include "third_party/blink/renderer/platform/instrumentation/tracing/trace_event.h"
#include "third_party/blink/renderer/platform/text/platform_locale.h"
#include "ui/base/ui_base_features.h"

namespace blink {

FormControlType;

// https://html.spec.whatwg.org/#dom-htmloptionscollection-length
static const unsigned kMaxListItems =;

// Default size when the multiple attribute is present but size attribute is
// absent.
const int kDefaultListBoxSize =;

HTMLSelectElement::HTMLSelectElement(Document& document)
    :{}

HTMLSelectElement::~HTMLSelectElement() = default;

FormControlType HTMLSelectElement::FormControlType() const {}

const AtomicString& HTMLSelectElement::FormControlTypeAsString() const {}

bool HTMLSelectElement::HasPlaceholderLabelOption() const {}

String HTMLSelectElement::validationMessage() const {}

bool HTMLSelectElement::ValueMissing() const {}

String HTMLSelectElement::DefaultToolTip() const {}

void HTMLSelectElement::SelectMultipleOptionsByPopup(
    const Vector<int>& list_indices) {}

unsigned HTMLSelectElement::ListBoxSize() const {}

void HTMLSelectElement::UpdateUsesMenuList() {}

int HTMLSelectElement::ActiveSelectionEndListIndex() const {}

HTMLOptionElement* HTMLSelectElement::ActiveSelectionEnd() const {}

void HTMLSelectElement::add(
    const V8UnionHTMLOptGroupElementOrHTMLOptionElement* element,
    const V8UnionHTMLElementOrLong* before,
    ExceptionState& exception_state) {}

void HTMLSelectElement::remove(int option_index) {}

String HTMLSelectElement::Value() const {}

void HTMLSelectElement::setValueForBinding(const String& value) {}

void HTMLSelectElement::SetValue(const String& value,
                                 bool send_events,
                                 WebAutofillState autofill_state) {}

void HTMLSelectElement::SetAutofillValue(const String& value,
                                         WebAutofillState autofill_state) {}

String HTMLSelectElement::SuggestedValue() const {}

void HTMLSelectElement::SetSuggestedValue(const String& value) {}

bool HTMLSelectElement::IsPresentationAttribute(
    const QualifiedName& name) const {}

void HTMLSelectElement::ParseAttribute(
    const AttributeModificationParams& params) {}

bool HTMLSelectElement::MayTriggerVirtualKeyboard() const {}

bool HTMLSelectElement::ShouldHaveFocusAppearance() const {}

bool HTMLSelectElement::CanSelectAll() const {}

LayoutObject* HTMLSelectElement::CreateLayoutObject(
    const ComputedStyle& style) {}

HTMLCollection* HTMLSelectElement::selectedOptions() {}

HTMLOptionsCollection* HTMLSelectElement::options() {}

void HTMLSelectElement::OptionElementChildrenChanged(
    const HTMLOptionElement& option) {}

void HTMLSelectElement::AccessKeyAction(
    SimulatedClickCreationScope creation_scope) {}

HTMLOptionElement* HTMLSelectElement::namedItem(const AtomicString& name) {}

HTMLOptionElement* HTMLSelectElement::item(unsigned index) {}

void HTMLSelectElement::SetOption(unsigned index,
                                  HTMLOptionElement* option,
                                  ExceptionState& exception_state) {}

void HTMLSelectElement::setLength(unsigned new_len,
                                  ExceptionState& exception_state) {}

bool HTMLSelectElement::IsRequiredFormControl() const {}

HTMLOptionElement* HTMLSelectElement::OptionAtListIndex(int list_index) const {}

void HTMLSelectElement::SelectAll() {}

const HTMLSelectElement::ListItems& HTMLSelectElement::GetListItems() const {}

void HTMLSelectElement::InvalidateSelectedItems() {}

void HTMLSelectElement::SetRecalcListItems() {}

void HTMLSelectElement::RecalcListItems() const {}

void HTMLSelectElement::ResetToDefaultSelection(ResetReason reason) {}

HTMLOptionElement* HTMLSelectElement::SelectedOption() const {}

int HTMLSelectElement::selectedIndex() const {}

void HTMLSelectElement::setSelectedIndex(int index) {}

int HTMLSelectElement::SelectedListIndex() const {}

void HTMLSelectElement::SetSuggestedOption(HTMLOptionElement* option) {}

void HTMLSelectElement::OptionSelectionStateChanged(HTMLOptionElement* option,
                                                    bool option_is_selected) {}

void HTMLSelectElement::ChildrenChanged(const ChildrenChange& change) {}

bool HTMLSelectElement::ChildrenChangedAllChildrenRemovedNeedsList() const {}

void HTMLSelectElement::ElementInserted(Node& node) {}

void HTMLSelectElement::OptionInserted(HTMLOptionElement& option,
                                       bool option_is_selected) {}

void HTMLSelectElement::OptionRemoved(HTMLOptionElement& option) {}

void HTMLSelectElement::OptGroupInsertedOrRemoved(
    HTMLOptGroupElement& optgroup) {}

void HTMLSelectElement::HrInsertedOrRemoved(HTMLHRElement& hr) {}

// TODO(tkent): This function is not efficient.  It contains multiple O(N)
// operations. crbug.com/577989.
void HTMLSelectElement::SelectOption(HTMLOptionElement* element,
                                     SelectOptionFlags flags,
                                     WebAutofillState autofill_state) {}

bool HTMLSelectElement::DispatchFocusEvent(
    Element* old_focused_element,
    mojom::blink::FocusType type,
    InputDeviceCapabilities* source_capabilities) {}

void HTMLSelectElement::DispatchBlurEvent(
    Element* new_focused_element,
    mojom::blink::FocusType type,
    InputDeviceCapabilities* source_capabilities) {}

// Returns true if selection state of any OPTIONs is changed.
bool HTMLSelectElement::DeselectItemsWithoutValidation(
    HTMLOptionElement* exclude_element) {}

FormControlState HTMLSelectElement::SaveFormControlState() const {}

wtf_size_t HTMLSelectElement::SearchOptionsForValue(
    const String& value,
    wtf_size_t list_index_start,
    wtf_size_t list_index_end) const {}

void HTMLSelectElement::RestoreFormControlState(const FormControlState& state) {}

void HTMLSelectElement::ParseMultipleAttribute(const AtomicString& value) {}

void HTMLSelectElement::AppendToFormData(FormData& form_data) {}

void HTMLSelectElement::ResetImpl() {}

bool HTMLSelectElement::PopupIsVisible() const {}

int HTMLSelectElement::ListIndexForOption(const HTMLOptionElement& option) {}

AutoscrollController* HTMLSelectElement::GetAutoscrollController() const {}

LayoutBox* HTMLSelectElement::AutoscrollBox() {}

void HTMLSelectElement::StopAutoscroll() {}

void HTMLSelectElement::DefaultEventHandler(Event& event) {}

HTMLOptionElement* HTMLSelectElement::LastSelectedOption() const {}

int HTMLSelectElement::IndexOfSelectedOption() const {}

int HTMLSelectElement::OptionCount() const {}

String HTMLSelectElement::OptionAtIndex(int index) const {}

void HTMLSelectElement::TypeAheadFind(const KeyboardEvent& event) {}

void HTMLSelectElement::SelectOptionByAccessKey(HTMLOptionElement* option) {}

unsigned HTMLSelectElement::length() const {}

void HTMLSelectElement::FinishParsingChildren() {}

IndexedPropertySetterResult HTMLSelectElement::AnonymousIndexedSetter(
    unsigned index,
    HTMLOptionElement* value,
    ExceptionState& exception_state) {}

bool HTMLSelectElement::IsInteractiveContent() const {}

void HTMLSelectElement::Trace(Visitor* visitor) const {}

void HTMLSelectElement::DidAddUserAgentShadowRoot(ShadowRoot& root) {}

void HTMLSelectElement::ManuallyAssignSlots() {}

void HTMLSelectElement::UpdateUserAgentShadowTree(ShadowRoot& root) {}

Element& HTMLSelectElement::InnerElementForAppearanceAuto() const {}

AXObject* HTMLSelectElement::PopupRootAXObject() const {}

HTMLOptionElement* HTMLSelectElement::SpatialNavigationFocusedOption() {}

String HTMLSelectElement::ItemText(const Element& element) const {}

bool HTMLSelectElement::ItemIsDisplayNone(Element& element) const {}

const ComputedStyle* HTMLSelectElement::ItemComputedStyle(
    Element& element) const {}

LayoutUnit HTMLSelectElement::ClientPaddingLeft() const {}

LayoutUnit HTMLSelectElement::ClientPaddingRight() const {}

void HTMLSelectElement::PopupDidHide() {}

void HTMLSelectElement::SetIndexToSelectOnCancel(int list_index) {}

HTMLOptionElement* HTMLSelectElement::OptionToBeShown() const {}

void HTMLSelectElement::SelectOptionByPopup(int list_index) {}

void HTMLSelectElement::PopupDidCancel() {}

void HTMLSelectElement::ProvisionalSelectionChanged(unsigned list_index) {}

void HTMLSelectElement::ShowPopup() {}

void HTMLSelectElement::HidePopup() {}

PopupMenu* HTMLSelectElement::PopupForTesting() const {}

void HTMLSelectElement::DidRecalcStyle(const StyleRecalcChange change) {}

void HTMLSelectElement::AttachLayoutTree(AttachContext& context) {}

void HTMLSelectElement::DetachLayoutTree(bool performing_reattach) {}

void HTMLSelectElement::ResetTypeAheadSessionForTesting() {}

void HTMLSelectElement::CloneNonAttributePropertiesFrom(const Element& source,
                                                        NodeCloningData& data) {}

void HTMLSelectElement::ChangeRendering() {}

const ComputedStyle* HTMLSelectElement::OptionStyle() const {}

// Show the option list for this select element.
// https://html.spec.whatwg.org/multipage/input.html#dom-select-showpicker
void HTMLSelectElement::showPicker(ExceptionState& exception_state) {}

bool HTMLSelectElement::IsValidCommand(HTMLElement& invoker,
                                       CommandEventType command) {}

bool HTMLSelectElement::HandleCommandInternal(HTMLElement& invoker,
                                              CommandEventType command) {}

HTMLButtonElement* HTMLSelectElement::SlottedButton() const {}

HTMLButtonElement* HTMLSelectElement::DisplayedButton() const {}

HTMLElement* HTMLSelectElement::PopoverForAppearanceBase() const {}

bool HTMLSelectElement::IsAppearanceBaseSelect() const {}

void HTMLSelectElement::SelectedOptionElementInserted(
    HTMLSelectedOptionElement* selectedoption) {}

void HTMLSelectElement::SelectedOptionElementRemoved(
    HTMLSelectedOptionElement* selectedoption) {}

FocusableState HTMLSelectElement::SupportsFocus(
    UpdateBehavior update_behavior) const {}

HTMLSelectElement::SelectAutofillPreviewElement*
HTMLSelectElement::GetAutofillPreviewElement() const {}

HTMLSelectElement::SelectAutofillPreviewElement::SelectAutofillPreviewElement(
    Document& document,
    HTMLSelectElement* select)
    :{}

const ComputedStyle*
HTMLSelectElement::SelectAutofillPreviewElement::CustomStyleForLayoutObject(
    const StyleRecalcContext& style_recalc_context) {}

Node::InsertionNotificationRequest
HTMLSelectElement::SelectAutofillPreviewElement::InsertedInto(
    ContainerNode& container) {}

void HTMLSelectElement::SelectAutofillPreviewElement::RemovedFrom(
    ContainerNode& container) {}

void HTMLSelectElement::SelectAutofillPreviewElement::Trace(
    Visitor* visitor) const {}

HTMLSelectedOptionElement* HTMLSelectElement::selectedOptionElement() const {}

void HTMLSelectElement::setSelectedOptionElement(
    HTMLSelectedOptionElement* new_selectedoption) {}

HeapHashSet<Member<HTMLSelectedOptionElement>>
HTMLSelectElement::TargetSelectedOptions() const {}

}  // namespace blink