chromium/chrome/browser/ui/views/autofill/popup/popup_row_view.cc

// Copyright 2023 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "chrome/browser/ui/views/autofill/popup/popup_row_view.h"

#include <memory>
#include <optional>
#include <string>
#include <utility>
#include <vector>

#include "base/check.h"
#include "base/check_op.h"
#include "base/feature_list.h"
#include "base/functional/bind.h"
#include "base/functional/callback_forward.h"
#include "base/i18n/rtl.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/weak_ptr.h"
#include "base/strings/string_util.h"
#include "base/time/time.h"
#include "chrome/browser/ui/autofill/autofill_popup_controller.h"
#include "chrome/browser/ui/views/autofill/popup/popup_cell_utils.h"
#include "chrome/browser/ui/views/autofill/popup/popup_row_content_view.h"
#include "chrome/browser/ui/views/autofill/popup/popup_row_with_button_view.h"
#include "chrome/browser/ui/views/autofill/popup/popup_view_utils.h"
#include "chrome/browser/ui/views/autofill/popup/popup_view_views.h"
#include "chrome/browser/ui/views/chrome_layout_provider.h"
#include "components/autofill/core/browser/filling_product.h"
#include "components/autofill/core/browser/ui/suggestion.h"
#include "components/autofill/core/browser/ui/suggestion_type.h"
#include "components/autofill/core/common/autofill_features.h"
#include "components/strings/grit/components_strings.h"
#include "third_party/blink/public/common/input/web_input_event.h"
#include "ui/accessibility/ax_enums.mojom.h"
#include "ui/accessibility/ax_node_data.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/metadata/base_type_conversion.h"
#include "ui/base/metadata/metadata_impl_macros.h"
#include "ui/color/color_id.h"
#include "ui/events/event_handler.h"
#include "ui/events/event_utils.h"
#include "ui/events/keycodes/keyboard_codes.h"
#include "ui/events/types/event_type.h"
#include "ui/gfx/geometry/insets.h"
#include "ui/gfx/geometry/outsets_f.h"
#include "ui/gfx/geometry/rect_f.h"
#include "ui/views/accessibility/view_accessibility.h"
#include "ui/views/background.h"
#include "ui/views/controls/image_view.h"
#include "ui/views/layout/box_layout.h"
#include "ui/views/layout/layout_provider.h"
#include "ui/views/view.h"
#include "ui/views/view_class_properties.h"

namespace autofill {

namespace {

// Utility event handler for mouse enter/exit and tap events.
class EnterExitHandler : public ui::EventHandler {};

constexpr int kExpandChildSuggestionsViewWidth =;
constexpr int kExpandChildSuggestionsIconWidth =;
constexpr int kExpandChildSuggestionsViewHorizontalPadding =;

// The suggestion is considered acceptable if the following is true:
// row view visible area >= total area * kAcceptingGuardVisibleAreaPortion.
// See how it is used in `PopupRowView::OnVisibleBoundsChanged()` for details.
constexpr float kAcceptingGuardVisibleAreaPortion =;

// Computes the position and set size of the suggestion at `suggestion_index` in
// `controller`'s suggestions ignoring `SuggestionType::kSeparator`s.
// Returns a pair of numbers: <position, size>. The position value is 1-base.
std::pair<int, int> ComputePositionInSet(
    base::WeakPtr<AutofillPopupController> controller,
    int suggestion_index) {}

std::u16string GetSuggestionA11yString(const Suggestion& suggestion,
                                       bool add_call_to_action_if_expandable) {}

// Returns whether the expand subpopup icon can have its visibility updated on
// hover/select. This method will return true when the following
// conditions are met:
// 1. The suggestion has children (otherwise a subpopup does not exist for it).
// 2. A suggestion is acceptable.
// 3. The `FillingProduct` is `FillingProduct::kAddress` (to avoid interfering
// with `FillingProduct::kCompose` suggestions).
// 4. The respective feature and feature param is enabled. This is currently
// done as part of an experiment arm to understand users behaviour.
//
// Note that when a suggestion is not acceptable, the only
// possible action the user can take is opening the subpopup and accepting a
// suggestion in it, therefore the icon is always visible in this case.
bool CanUpdateOpenSubPopupIconVisibilityOnHover(const Suggestion& suggestion) {}

}  // namespace

EnterExitHandler::EnterExitHandler(base::RepeatingClosure enter_callback,
                                   base::RepeatingClosure exit_callback)
    :{}

EnterExitHandler::~EnterExitHandler() = default;
void EnterExitHandler::OnEvent(ui::Event* event) {}

// static
int PopupRowView::GetHorizontalMargin() {}

PopupRowView::PopupRowView(
    AccessibilitySelectionDelegate& a11y_selection_delegate,
    SelectionDelegate& selection_delegate,
    base::WeakPtr<AutofillPopupController> controller,
    int line_number,
    std::unique_ptr<PopupRowContentView> content_view)
    :{}

PopupRowView::~PopupRowView() = default;

bool PopupRowView::OnMouseDragged(const ui::MouseEvent& event) {}

bool PopupRowView::OnMousePressed(const ui::MouseEvent& event) {}

void PopupRowView::OnMouseExited(const ui::MouseEvent& event) {}

void PopupRowView::OnMouseReleased(const ui::MouseEvent& event) {}

void PopupRowView::OnGestureEvent(ui::GestureEvent* event) {}

void PopupRowView::OnPaint(gfx::Canvas* canvas) {}

bool PopupRowView::GetNeedsNotificationWhenVisibleBoundsChange() const {}

void PopupRowView::OnVisibleBoundsChanged() {}

void PopupRowView::GetAccessibleNodeData(ui::AXNodeData* node_data) {}

void PopupRowView::OnViewFocused(views::View* view) {}

void PopupRowView::SetSelectedCell(std::optional<CellType> new_cell) {}

void PopupRowView::SetChildSuggestionsDisplayed(
    bool child_suggestions_displayed) {}

gfx::RectF PopupRowView::GetControlCellBounds() const {}

bool PopupRowView::HandleKeyPressEvent(
    const input::NativeWebKeyboardEvent& event) {}

bool PopupRowView::IsSelectable() const {}

void PopupRowView::UpdateUI() {}

void PopupRowView::UpdateBackground() {}

void PopupRowView::UpdateOpenSubPopupIconVisibility() {}

bool PopupRowView::IsViewVisibleEnough() const {}

BEGIN_METADATA()

}  // namespace autofill

DEFINE_ENUM_CONVERTERS()