commit e2f8a1e1b5c0096cb0465a79e4f6c53d0d50e664 Author: Gregg Tavares Date: Fri Aug 11 00:32:19 2023 +0000 Tweak about:gpu * Make it so you can select all the text As it was, selection only worked on individual top level divs. Adding an enclosing parent div fixed this issue * Change "Copy Report to Clipboard" to "Download Report to File" The data here was almost always too big. Too big to paste into a chrome bug, too big to paste into chat. The user can still press Ctrl-A/Cmd-A or pick Select-All and do a text copy. * Add dark mode support Bug: 1470927 Change-Id: I82da29ae5b68106f204d02084e252d3f07373a69 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4764269 Commit-Queue: Gregg Tavares Reviewed-by: Kenneth Russell Reviewed-by: Kai Ninomiya Cr-Commit-Position: refs/heads/main@{#1182383} diff --git a/content/browser/resources/gpu/gpu_internals.html b/content/browser/resources/gpu/gpu_internals.html index d324f96798fd6..22322bb6ba7d8 100644 --- a/content/browser/resources/gpu/gpu_internals.html +++ b/content/browser/resources/gpu/gpu_internals.html @@ -9,13 +9,15 @@ found in the LICENSE file. GPU Internals +
- +

Graphics Feature Status

@@ -193,3 +184,4 @@ found in the LICENSE file.

Log Messages

    +
    \ No newline at end of file diff --git a/content/browser/resources/gpu/info_view.ts b/content/browser/resources/gpu/info_view.ts index 0b91cc130f46f..96c08f76e4bc7 100644 --- a/content/browser/resources/gpu/info_view.ts +++ b/content/browser/resources/gpu/info_view.ts @@ -12,6 +12,22 @@ import {getTemplate} from './info_view.html.js'; import {ArrayData, Data} from './info_view_table_row.js'; import {VulkanInfo} from './vulkan_info.js'; +/** + * Given a blob and a filename, prompts user to + * save as a file. + */ +const saveData = (function() { + const a = document.createElement('a'); + a.style.display = 'none'; + document.body.appendChild(a); + return function saveData(blob: Blob, fileName: string) { + const url = window.URL.createObjectURL(blob); + a.href = url; + a.download = fileName; + a.click(); + }; +}()); + /** * @fileoverview This view displays information on the current GPU * hardware. Its primary usefulness is to allow users to copy-paste @@ -33,19 +49,26 @@ export class InfoViewElement extends CustomElement { } connectedCallback() { - // Add handler to 'copy to clipboard' button - const copyButton = - this.shadowRoot!.querySelector('#copy-to-clipboard'); - assert(copyButton); - copyButton.onclick = (() => { + // Add handler to 'download report to clipboard' button + const downloadButton = + this.shadowRoot!.querySelector('#download-to-file')!; + assert(downloadButton); + downloadButton.onclick = (() => { // Make sure nothing is selected const s = window.getSelection()!; s.removeAllRanges(); + + // Select everything s.selectAllChildren(this.shadowRoot!); - document.execCommand('copy'); + const text = s.toString(); // And deselect everything at the end. window.getSelection()!.removeAllRanges(); + + const blob = new Blob([text], {type: 'text/text'}); + const filename = `about-gpu-${ + new Date().toISOString().replace(/[^a-z0-9-]/ig, '-')}.txt`; + saveData(blob, filename); }); }