blob: 3fd86bd8998db2df546e1e3b177f233e4f1dbf22 [file] [log] [blame] [view]
Kristyn Hamasaki3be83c7eb2019-07-16 06:23:211# UI DevTools Overview
2
Wei Lidf2bd702021-03-10 21:28:223UI DevTools allows UI developers to inspect the Chrome desktop UI system like
4a webpage using the frontend DevTools Inspector. It is
5currently supported on all desktop platforms including Linux, Windows, Mac,
6and ChromeOS.
Kristyn Hamasaki3be83c7eb2019-07-16 06:23:217
8## How to run
9
Wei Lidf2bd702021-03-10 21:28:2210There are two ways to enable UI DevTools:
Kristyn Hamasaki3be83c7eb2019-07-16 06:23:2111
Wei Lidf2bd702021-03-10 21:28:22121. Run Chromium with default port 9223 and start Chromium with UI DevTools
13 command line flag:
Kristyn Hamasaki3be83c7eb2019-07-16 06:23:2114
Wei Lidf2bd702021-03-10 21:28:2215 ```shell
16 $ out/Default/chrome --enable-ui-devtools
17 ```
18
19 * If you want to use a different port, add the port number in the flag
20 `--enable-ui-devtools=<port>`.
21
222. Enable `ui-debug-tools` feature flag from `chrome://flags`
23
24Once enabled, go to `chrome://inspect#native-ui` and click the `Inspect Native UI`
25button to launch the DevTools front-end in a separate tab.
26
27![launch UIDevTools]
Kristyn Hamasaki3be83c7eb2019-07-16 06:23:2128
29
Kristyn Hamasaki0f6e4252019-08-16 22:13:1130## How to Use
Kristyn Hamasaki3be83c7eb2019-07-16 06:23:2131
Kristyn Hamasaki0f6e4252019-08-16 22:13:1132### Elements Tree
33
34View, Window, and Widget elements are displayed in the hierarchal elements tree. To expand the elements
35tree, right click the root element and then select Expand Recursively from the context menu.
36Then, to inspect an element's properties, click on its elements node.
37
38![expand elements]
39
40### Views Property Inspection
41
42When an element in the elements tree is selected, the property panel on the right side displays the
43element's properties. All elements have the basic properties (height, width, x, y, visibility).
44For Window and View elements, if that element has Layer properties, they will be displayed in
45a separate section.
46
47![browser frame properties]
48
49For View elements with Metadata properties, each parent class's properties from the Metadata
50will be displayed in an additional section.
51
52![image view properties]
53
54Elements' basic properties can be modified from the properties panel and changes will be shown.
55
56![edit property]
57
58### Inspect Mode
59
60To enter inspect mode, click the inspect icon at top left corner of UI Devtools.
61
62![inspector button]
63
64Hovering over a UI element highlights that element with a blue rectangular border and reveals
65the element's node in the elements tree.
66
67![hovering over elements]
68
69Clicking on a highlighted element will pin that element. Clicking the corresponding node
70in the elements tree will reveal that element's properties.
71
72![hover and inspect]
73
74When an element is pinned, hovering over other elements will reveal the vertical and horizontal
75distance between the two elements.
76
77![hovering distances]
78
79To exit inspect mode, either click the inspect icon again or press the Esc key.
80
81### Sources Panel
82
83In the properties panel, each section has a source link in the upper right corner. When right-clicked,
84the context menu shows the option to "Open in new tab," which opens the class's header file in Chromium
85code search.
86
87![properties panel right click link]
88
89If the link is simply clicked, it will open the source code in the sources panel of UI DevTools, which
90is read in from local files.
91
92![sources panel]
93
94### View Bounds Highlighting
95
96Red border rectangles around each View element can be drawn using the command Ctrl+R (Meta+R for mac).
97The rectangles can be toggled off and on using the same command.
98
99![debug bounds rectangles]
100
101### Bubble Locking
102
103In order to inspect a bubble, the command Ctrl+Shift+R (Meta+Shift+R for mac) locks bubbles to prevent
104them from dismissing upon losing focus. This allows a bubble's inner elements to be inspected. Bubble
105locking can be toggled off and on using the same command.
106
107![lock and inspect bubble]
108
Andrew Lee11cbca62019-08-21 16:39:08109### UI Element Tree Search
110
111In the elements panel, Ctrl+F to open the search bar at the bottom. The search functionality allows
112developers to search the UI element tree quickly by name, tag <>, and style properties.
113The search can do substring matches or exact matches (specified with quotations). The search returns
114all matches and highlights the specific nodes on the tree that are matched. The up and down arrows
115on the right of the search bar or ENTER are used to traverse through the matches.
116
117![ui element tree search]
118
119The search feature can also search the element's style properties in the UI element tree. The special
120key word 'style:' must be typed in the search bar.
121
122![search style]
123
Wei Lidf2bd702021-03-10 21:28:22124[launch UIDevTools]: images/launch_tools.png
Kristyn Hamasaki0f6e4252019-08-16 22:13:11125[expand elements]: images/expand_elements.gif
126[browser frame properties]: images/browser_frame_properties.png
127[image view properties]: images/image_view_properties.png
128[edit property]: images/edit_property.gif
129[inspector button]: images/inspector_button.png
130[hovering over elements]: images/hovering_over_elements.gif
131[hover and inspect]: images/hover_and_inspect.gif
132[hovering distances]: images/hovering_distances.gif
133[properties panel right click link]: images/properties_panel_right_click_link.png
134[sources panel]: images/sources_panel.png
135[debug bounds rectangles]: images/debug_bounds_rectangles.png
136[lock and inspect bubble]: images/lock_and_inspect_bubble.gif
Andrew Lee11cbca62019-08-21 16:39:08137[ui element tree search]: images/ui_element_tree_search.gif
138[search style]: images/search_style.png
Wei Lidf2bd702021-03-10 21:28:22139
140### References
141
142* [Old Ash Doc](https://www.chromium.org/developers/how-tos/inspecting-ash) (obsolete)
143* [Backend Source Code](https://cs.chromium.org/chromium/src/components/ui_devtools/)
144* [Inspector Frontend Source Code](https://chromium.googlesource.com/devtools/devtools-frontend)