File: README.md

package info (click to toggle)
chromium 138.0.7204.183-1~deb12u1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm-proposed-updates
  • size: 6,080,960 kB
  • sloc: cpp: 34,937,079; ansic: 7,176,967; javascript: 4,110,704; python: 1,419,954; asm: 946,768; xml: 739,971; pascal: 187,324; sh: 89,623; perl: 88,663; objc: 79,944; sql: 50,304; cs: 41,786; fortran: 24,137; makefile: 21,811; php: 13,980; tcl: 13,166; yacc: 8,925; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (78 lines) | stat: -rw-r--r-- 5,389 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# Popups

The popup classes in this directory are used to display the following types of
data on Desktop platforms:
* Autofill profile data (i.e. addresses)
* Autocomplete data
* Payment data

Additionally, `PopupBaseView` is also re-used for the popup in which
password generation prompts are rendered.

## Class hierarchy

The main classes for the popup have the following hierarchy:
```
┌───────────────────────┐
│ PopupBaseView         │
└──▲────────────────────┘
   │ extends
┌──┴────────────────────┐
│ PopupViewViews        │
└──┬────────────────────┘
   │creates (via CreatePopupRowView()) and owns N
┌──▼────────────────────┐
│ PopupRowView          │
└──┬────────────────────┘
   │owns
┌──▼────────────────────┐
│ PopupRowContentView   │
└───────────────────────┘

┌───────────────────────┐
│ PopupRowView          │
└──▲────────────────────┘
   │ extends
┌──┴─────────────────────┐
│ PopupRowWithButtonView │
└────────────────────────┘
```

These classes serve the following purposes:
* [`PopupBaseView`](https://source.chromium.org/chromium/chromium/src/+/main:chrome/browser/ui/views/autofill/popup/popup_base_view.h): Serves as the common base class for both `PopupViewViews` and `PasswordGenerationPopupViewViews`.
  * It is responsible for creating a widget and setting itself as its content area.
  * It checks that there is enough space for showing the popup and creates a border with an arrow pointing to
    the HTML form field from which the popup was triggered.
* [`PopupViewViews`](https://source.chromium.org/chromium/chromium/src/+/main:chrome/browser/ui/views/autofill/popup/popup_view_views.h): Implements the `AutofillPopupView` interface that the `AutofillPopupController`
   interacts with.
   * It serves as a container for multiple popup rows (e.g. encapsulating the non-footer
   rows in a `ScrollView`). Rows with selectable cells are represented by `PopupRowView`, but `PopupViewViews` can
   also contain rows that cannot be selected (e.g. a `PopupSeparatorView`).
   * It is responsible for processing keyboard events that change the cell selection across rows (e.g. cursor down)
     for announcing selection changes to the accessibility system.
* [`PopupRowView`](https://source.chromium.org/chromium/chromium/src/+/main:chrome/browser/ui/views/autofill/popup/popup_row_view.h): Represents a single row in a `PopupViewViews`.
   * It accepts a `PopupRowContentView` in its constructor and takes ownership of it. This content
     view occupies the majority of the row view area and basically determines its appearance.
   * It handles native mouse events and keyboard events (that pass through `RenderWidgetHost`) to control suggestion selection (form
     preview) and acceptance (form filling).
   * It automatically adds an expanding control for suggestions with children. Note that
     the sub-popup is not controlled by the row, but in `PopupViewViews`
* [`PopupRowWithButtonView`](https://source.chromium.org/chromium/chromium/src/+/main:chrome/browser/ui/views/autofill/popup/popup_row_with_button_view.h): An extension of `PopupRowView` that supports
   a single button in the content view layout.
   * It supports the subtleties of having a control inside a row view, e.g. selection/unselection
     on button focusing.
   * An example of usage is the Autocomplete suggestion with a "Delete" button
* [`CreatePopupRowView()`](https://source.chromium.org/chromium/chromium/src/+/main:chrome/browser/ui/views/autofill/popup/popup_row_factory_utils.h): Row construction method.
   * It is the entry point for creating rows of different types. Based on the suggestion (mostly
     its `SuggestionType`) it instantiates a row class and its content view.


## Adding new popup content

There are currently about ~30 different `SuggestionType`s, that correspond to a different type of popup row. When a new type is added and it cannot be properly processed by `CreatePopupRowView()`, use the
following steps to support it by the popup UI:
* Create a new factory method for `PopupRowContentView` (or even for `PopupRowView` if needed, e.g. `CreateAutocompleteRowWithDeleteButton()`),
  e.g. `CreatePasswordPopupRowContentView()` in [popup_row_factory_utils.cc](https://source.chromium.org/chromium/chromium/src/+/main:chrome/browser/ui/views/autofill/popup/popup_row_factory_utils.cc).
* Call it when appropriate in [`CreatePopupRowView()`](https://source.chromium.org/chromium/chromium/src/+/main:chrome/browser/ui/views/autofill/popup/popup_row_factory_utils.cc).
* Add/update tests in `popup_row_factory_utils_unittest.cc` if some testable logic was affected.
* Add a pixel test to `popup_row_factory_utils_browsertest.cc`. In most cases adding the newly added suggestion type to `kSuggestions` will suffice.