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