chrome-devtools-frontend 1.0.1524741 → 1.0.1525561

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -479,12 +479,23 @@ export class Tooltip extends HTMLElement {
479
479
  }
480
480
  };
481
481
 
482
+ #globalKeyDown = (event: KeyboardEvent): void => {
483
+ if (!this.open || event.key !== 'Escape') {
484
+ return;
485
+ }
486
+
487
+ this.#openedViaHotkey = false;
488
+ this.toggle();
489
+ event.consume(true);
490
+ };
491
+
482
492
  #keyDown = (event: KeyboardEvent): void => {
483
- // There are two scenarios when we care about keydown:
484
- // 1. The tooltip is open, and the user presses ESC
485
- // 2. "use-hotkey" is set, and the user presses Alt+ArrowDown.
486
- const shouldToggleVisibility =
487
- (event.key === 'Escape' && this.open) || (this.useHotkey && event.altKey && event.key === 'ArrowDown');
493
+ // This supports the scenario where the user uses Alt+ArrowDown in hotkey
494
+ // mode to toggle the visibility.
495
+ // Note that the "Escape to close" scenario is handled in the global
496
+ // keydown function so we capture Escape presses even if the tooltip does
497
+ // not have focus.
498
+ const shouldToggleVisibility = (this.useHotkey && event.altKey && event.key === 'ArrowDown');
488
499
 
489
500
  if (shouldToggleVisibility) {
490
501
  this.#openedViaHotkey = !this.open;
@@ -494,6 +505,7 @@ export class Tooltip extends HTMLElement {
494
505
  };
495
506
 
496
507
  #registerEventListeners(): void {
508
+ document.body.addEventListener('keydown', this.#globalKeyDown);
497
509
  if (this.#anchor) {
498
510
  // We bind the keydown listener regardless of if use-hotkey is enabled
499
511
  // as we always want to support ESC to close.
@@ -525,6 +537,11 @@ export class Tooltip extends HTMLElement {
525
537
  if (this.#timeout) {
526
538
  window.clearTimeout(this.#timeout);
527
539
  }
540
+
541
+ // Should always exist when this component is used, but in test
542
+ // environments on Chromium this isn't always the case, hence the body? check.
543
+ document.body?.removeEventListener('keydown', this.#globalKeyDown);
544
+
528
545
  if (this.#anchor) {
529
546
  this.#anchor.removeEventListener('click', this.toggle);
530
547
  this.#anchor.removeEventListener('mouseenter', this.showTooltip);
@@ -16,20 +16,22 @@ const MEMORY_TRANSFER_MIN_CHUNK_SIZE = 1000;
16
16
  * known upfront.
17
17
  */
18
18
  class LinearMemoryInspectorView extends UI.Widget.VBox {
19
- #memory = new Uint8Array([0]);
19
+ #memory: Uint8Array = new Uint8Array([0]);
20
20
  #address = 0;
21
21
  #inspector = new LinearMemoryInspectorComponents.LinearMemoryInspector.LinearMemoryInspector();
22
22
 
23
23
  constructor() {
24
24
  super();
25
- this.#inspector.addEventListener(
25
+ this.#inspector.contentElement.addEventListener(
26
26
  LinearMemoryInspectorComponents.LinearMemoryInspector.MemoryRequestEvent.eventName,
27
- this.#memoryRequested.bind(this));
28
- this.#inspector.addEventListener(
29
- LinearMemoryInspectorComponents.LinearMemoryInspector.AddressChangedEvent.eventName, event => {
27
+ (event: LinearMemoryInspectorComponents.LinearMemoryInspector.MemoryRequestEvent) =>
28
+ this.#memoryRequested(event));
29
+ this.#inspector.contentElement.addEventListener(
30
+ LinearMemoryInspectorComponents.LinearMemoryInspector.AddressChangedEvent.eventName,
31
+ (event: LinearMemoryInspectorComponents.LinearMemoryInspector.AddressChangedEvent) => {
30
32
  this.#address = event.data;
31
33
  });
32
- this.contentElement.appendChild(this.#inspector);
34
+ this.#inspector.show(this.contentElement);
33
35
  }
34
36
 
35
37
  override wasShown(): void {
@@ -51,13 +53,11 @@ class LinearMemoryInspectorView extends UI.Widget.VBox {
51
53
  const memoryChunkStart = Math.max(0, this.#address - MEMORY_TRANSFER_MIN_CHUNK_SIZE / 2);
52
54
  const memoryChunkEnd = memoryChunkStart + MEMORY_TRANSFER_MIN_CHUNK_SIZE;
53
55
  const memory = this.#memory.slice(memoryChunkStart, memoryChunkEnd);
54
- this.#inspector.data = {
55
- memory,
56
- address: this.#address,
57
- memoryOffset: memoryChunkStart,
58
- outerMemoryLength: this.#memory.length,
59
- hideValueInspector: true,
60
- };
56
+ this.#inspector.memory = memory;
57
+ this.#inspector.address = this.#address;
58
+ this.#inspector.memoryOffset = memoryChunkStart;
59
+ this.#inspector.outerMemoryLength = this.#memory.length;
60
+ this.#inspector.hideValueInspector = true;
61
61
  }
62
62
 
63
63
  #memoryRequested(event: LinearMemoryInspectorComponents.LinearMemoryInspector.MemoryRequestEvent): void {
@@ -80,13 +80,11 @@ class LinearMemoryInspectorView extends UI.Widget.VBox {
80
80
  const chunkEnd = Math.max(end, start + MEMORY_TRANSFER_MIN_CHUNK_SIZE);
81
81
  const memory = this.#memory.slice(start, chunkEnd);
82
82
 
83
- this.#inspector.data = {
84
- memory,
85
- address,
86
- memoryOffset: start,
87
- outerMemoryLength: this.#memory.length,
88
- hideValueInspector: true,
89
- };
83
+ this.#inspector.memory = memory;
84
+ this.#inspector.address = address;
85
+ this.#inspector.memoryOffset = start;
86
+ this.#inspector.outerMemoryLength = this.#memory.length;
87
+ this.#inspector.hideValueInspector = true;
90
88
  }
91
89
  }
92
90
 
package/package.json CHANGED
@@ -102,5 +102,5 @@
102
102
  "@eslint/core": "0.15.1"
103
103
  }
104
104
  },
105
- "version": "1.0.1524741"
105
+ "version": "1.0.1525561"
106
106
  }