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.
@@ -1,7 +1,6 @@
1
1
  // Copyright 2020 The Chromium Authors
2
2
  // Use of this source code is governed by a BSD-style license that can be
3
3
  // found in the LICENSE file.
4
- /* eslint-disable rulesdir/no-lit-render-outside-of-view */
5
4
 
6
5
  import './LinearMemoryValueInterpreter.js';
7
6
  import './LinearMemoryHighlightChipList.js';
@@ -9,6 +8,7 @@ import './LinearMemoryViewer.js';
9
8
 
10
9
  import * as Common from '../../../core/common/common.js';
11
10
  import * as i18n from '../../../core/i18n/i18n.js';
11
+ import * as UI from '../../../ui/legacy/legacy.js';
12
12
  import {html, nothing, render} from '../../../ui/lit/lit.js';
13
13
 
14
14
  import type {DeleteMemoryHighlightEvent, JumpToHighlightedMemoryEvent} from './LinearMemoryHighlightChipList.js';
@@ -119,8 +119,151 @@ class AddressHistoryEntry implements Common.SimpleHistoryManager.HistoryEntry {
119
119
  }
120
120
  }
121
121
 
122
- export class LinearMemoryInspector extends HTMLElement {
123
- readonly #shadow = this.attachShadow({mode: 'open'});
122
+ export interface ViewInput {
123
+ memory: Uint8Array;
124
+ address: number;
125
+ memoryOffset: number;
126
+ outerMemoryLength: number;
127
+ valueTypes: Set<ValueType>;
128
+ valueTypeModes: Map<ValueType, ValueTypeMode>;
129
+ endianness: Endianness;
130
+ highlightInfo?: HighlightInfo;
131
+ hideValueInspector: boolean;
132
+ currentNavigatorMode: Mode;
133
+ currentNavigatorAddressLine: string;
134
+ canGoBackInHistory: boolean;
135
+ canGoForwardInHistory: boolean;
136
+ onRefreshRequest: () => void;
137
+ onAddressChange: (e: AddressInputChangedEvent) => void;
138
+ onNavigatePage: (e: PageNavigationEvent) => void;
139
+ onNavigateHistory: (e: HistoryNavigationEvent) => boolean;
140
+ onJumpToAddress: (e: JumpToPointerAddressEvent|JumpToHighlightedMemoryEvent) => void;
141
+ onByteSelected: (e: ByteSelectedEvent) => void;
142
+ onResize: (e: ResizeEvent) => void;
143
+ onValueTypeToggled: (e: ValueTypeToggledEvent) => void;
144
+ onValueTypeModeChanged: (e: ValueTypeModeChangedEvent) => void;
145
+ onEndiannessChanged: (e: EndiannessChangedEvent) => void;
146
+ memorySlice: Uint8Array<ArrayBuffer>;
147
+ viewerStart: number;
148
+ }
149
+
150
+ export const DEFAULT_VIEW = (input: ViewInput, _output: Record<string, unknown>, target: HTMLElement): void => {
151
+ const navigatorAddressToShow =
152
+ input.currentNavigatorMode === Mode.SUBMITTED ? formatAddress(input.address) : input.currentNavigatorAddressLine;
153
+ const navigatorAddressIsValid = isValidAddress(navigatorAddressToShow, input.outerMemoryLength);
154
+
155
+ const invalidAddressMsg = i18nString(
156
+ UIStrings.addressHasToBeANumberBetweenSAnd, {PH1: formatAddress(0), PH2: formatAddress(input.outerMemoryLength)});
157
+
158
+ const errorMsg = navigatorAddressIsValid ? undefined : invalidAddressMsg;
159
+
160
+ const highlightedMemoryAreas = input.highlightInfo ? [input.highlightInfo] : [];
161
+ const focusedMemoryHighlight = getSmallestEnclosingMemoryHighlight(highlightedMemoryAreas, input.address);
162
+ // Disabled until https://crbug.com/1079231 is fixed.
163
+ // clang-format off
164
+ render(html`
165
+ <style>${linearMemoryInspectorStyles}</style>
166
+ <div class="view">
167
+ <devtools-linear-memory-inspector-navigator
168
+ .data=${
169
+ {
170
+ address: navigatorAddressToShow,
171
+ valid: navigatorAddressIsValid,
172
+ mode: input.currentNavigatorMode,
173
+ error: errorMsg,
174
+ canGoBackInHistory: input.canGoBackInHistory,
175
+ canGoForwardInHistory: input.canGoForwardInHistory,
176
+ }}
177
+ @refreshrequested=${input.onRefreshRequest}
178
+ @addressinputchanged=${input.onAddressChange}
179
+ @pagenavigation=${input.onNavigatePage}
180
+ @historynavigation=${input.onNavigateHistory}></devtools-linear-memory-inspector-navigator>
181
+ <devtools-linear-memory-highlight-chip-list
182
+ .data=${{highlightInfos: highlightedMemoryAreas, focusedMemoryHighlight}}
183
+ @jumptohighlightedmemory=${input.onJumpToAddress}>
184
+ </devtools-linear-memory-highlight-chip-list>
185
+ <devtools-linear-memory-inspector-viewer
186
+ .data=${
187
+ {
188
+ memory: input.memorySlice,
189
+ address: input.address,
190
+ memoryOffset: input.viewerStart,
191
+ focus: input.currentNavigatorMode === Mode.SUBMITTED,
192
+ highlightInfo: input.highlightInfo,
193
+ focusedMemoryHighlight,
194
+ }}
195
+ @byteselected=${input.onByteSelected}
196
+ @resize=${input.onResize}>
197
+ </devtools-linear-memory-inspector-viewer>
198
+ </div>
199
+ ${
200
+ input.hideValueInspector ? nothing : html`
201
+ <div class="value-interpreter">
202
+ <devtools-linear-memory-inspector-interpreter
203
+ .data=${
204
+ {
205
+ value: input.memory
206
+ .slice(
207
+ input.address - input.memoryOffset,
208
+ input.address + VALUE_INTEPRETER_MAX_NUM_BYTES,
209
+ )
210
+ .buffer,
211
+ valueTypes: input.valueTypes,
212
+ valueTypeModes: input.valueTypeModes,
213
+ endianness: input.endianness,
214
+ memoryLength: input.outerMemoryLength,
215
+ }}
216
+ @valuetypetoggled=${input.onValueTypeToggled}
217
+ @valuetypemodechanged=${input.onValueTypeModeChanged}
218
+ @endiannesschanged=${input.onEndiannessChanged}
219
+ @jumptopointeraddress=${input.onJumpToAddress}
220
+ >
221
+ </devtools-linear-memory-inspector-interpreter/>
222
+ </div>`}
223
+ `,
224
+ target);
225
+ // clang-format on
226
+ };
227
+
228
+ function getPageRangeForAddress(
229
+ address: number, numBytesPerPage: number, outerMemoryLength: number): {start: number, end: number} {
230
+ const pageNumber = Math.floor(address / numBytesPerPage);
231
+ const pageStartAddress = pageNumber * numBytesPerPage;
232
+ const pageEndAddress = Math.min(pageStartAddress + numBytesPerPage, outerMemoryLength);
233
+ return {start: pageStartAddress, end: pageEndAddress};
234
+ }
235
+
236
+ function isValidAddress(address: string, outerMemoryLength: number): boolean {
237
+ const newAddress = parseAddress(address);
238
+ return newAddress !== undefined && newAddress >= 0 && newAddress < outerMemoryLength;
239
+ }
240
+
241
+ // Returns the highlightInfo with the smallest size property that encloses the provided address.
242
+ // If there are multiple smallest enclosing highlights, we pick the one appearing the earliest in highlightedMemoryAreas.
243
+ // If no such highlightInfo exists, it returns undefined.
244
+ //
245
+ // Selecting the smallest enclosing memory highlight is a heuristic that aims to pick the
246
+ // most specific highlight given a provided address. This way, objects contained in other objects are
247
+ // potentially still accessible.
248
+ function getSmallestEnclosingMemoryHighlight(highlightedMemoryAreas: HighlightInfo[], address: number): HighlightInfo|
249
+ undefined {
250
+ let smallestEnclosingHighlight;
251
+ for (const highlightedMemory of highlightedMemoryAreas) {
252
+ if (highlightedMemory.startAddress <= address &&
253
+ address < highlightedMemory.startAddress + highlightedMemory.size) {
254
+ if (!smallestEnclosingHighlight) {
255
+ smallestEnclosingHighlight = highlightedMemory;
256
+ } else if (highlightedMemory.size < smallestEnclosingHighlight.size) {
257
+ smallestEnclosingHighlight = highlightedMemory;
258
+ }
259
+ }
260
+ }
261
+ return smallestEnclosingHighlight;
262
+ }
263
+
264
+ export type View = typeof DEFAULT_VIEW;
265
+
266
+ export class LinearMemoryInspector extends UI.Widget.Widget {
124
267
  readonly #history = new Common.SimpleHistoryManager.SimpleHistoryManager(10);
125
268
 
126
269
  #memory = new Uint8Array();
@@ -140,102 +283,109 @@ export class LinearMemoryInspector extends HTMLElement {
140
283
  #endianness = Endianness.LITTLE;
141
284
 
142
285
  #hideValueInspector = false;
286
+ #view: View;
143
287
 
144
- set data(data: LinearMemoryInspectorData) {
145
- if (data.address < data.memoryOffset || data.address > data.memoryOffset + data.memory.length || data.address < 0) {
146
- throw new Error('Address is out of bounds.');
288
+ constructor(element?: HTMLElement, view?: View) {
289
+ super(element);
290
+ this.#view = view ?? DEFAULT_VIEW;
291
+ }
292
+
293
+ set memory(value: Uint8Array<ArrayBuffer>) {
294
+ this.#memory = value;
295
+ void this.requestUpdate();
296
+ }
297
+
298
+ set memoryOffset(value: number) {
299
+ this.#memoryOffset = value;
300
+ void this.requestUpdate();
301
+ }
302
+
303
+ set outerMemoryLength(value: number) {
304
+ this.#outerMemoryLength = value;
305
+ void this.requestUpdate();
306
+ }
307
+
308
+ set highlightInfo(value: HighlightInfo|undefined) {
309
+ this.#highlightInfo = value;
310
+ void this.requestUpdate();
311
+ }
312
+
313
+ set valueTypeModes(value: Map<ValueType, ValueTypeMode>) {
314
+ this.#valueTypeModes = value;
315
+ void this.requestUpdate();
316
+ }
317
+
318
+ set valueTypes(value: Set<ValueType>) {
319
+ this.#valueTypes = value;
320
+ void this.requestUpdate();
321
+ }
322
+
323
+ set endianness(value: Endianness) {
324
+ this.#endianness = value;
325
+ void this.requestUpdate();
326
+ }
327
+
328
+ set hideValueInspector(value: boolean) {
329
+ this.#hideValueInspector = value;
330
+ void this.requestUpdate();
331
+ }
332
+
333
+ get hideValueInspector(): boolean {
334
+ return this.#hideValueInspector;
335
+ }
336
+
337
+ override performUpdate(): void {
338
+ const {start, end} = getPageRangeForAddress(this.#address, this.#numBytesPerPage, this.#outerMemoryLength);
339
+
340
+ if (start < this.#memoryOffset || end > this.#memoryOffset + this.#memory.length) {
341
+ this.contentElement.dispatchEvent(new MemoryRequestEvent(start, end, this.#address));
342
+ return;
147
343
  }
148
344
 
149
- if (data.memoryOffset < 0) {
150
- throw new Error('Memory offset has to be greater or equal to zero.');
345
+ if (this.#address < this.#memoryOffset || this.#address > this.#memoryOffset + this.#memory.length ||
346
+ this.#address < 0) {
347
+ throw new Error('Address is out of bounds.');
151
348
  }
152
349
 
153
- if (data.highlightInfo) {
154
- if (data.highlightInfo.size < 0) {
350
+ if (this.#highlightInfo) {
351
+ if (this.#highlightInfo.size < 0) {
352
+ this.#highlightInfo = undefined;
155
353
  throw new Error('Object size has to be greater than or equal to zero');
156
354
  }
157
- if (data.highlightInfo.startAddress < 0 || data.highlightInfo.startAddress >= data.outerMemoryLength) {
355
+ if (this.#highlightInfo.startAddress < 0 || this.#highlightInfo.startAddress >= this.#outerMemoryLength) {
356
+ this.#highlightInfo = undefined;
158
357
  throw new Error('Object start address is out of bounds.');
159
358
  }
160
359
  }
161
360
 
162
- this.#memory = data.memory;
163
- this.#memoryOffset = data.memoryOffset;
164
- this.#outerMemoryLength = data.outerMemoryLength;
165
- this.#valueTypeModes = data.valueTypeModes || this.#valueTypeModes;
166
- this.#valueTypes = data.valueTypes || this.#valueTypes;
167
- this.#endianness = data.endianness || this.#endianness;
168
- this.#highlightInfo = data.highlightInfo;
169
- this.#hideValueInspector = data.hideValueInspector ?? this.#hideValueInspector;
170
- this.#setAddress(data.address);
171
- this.#render();
172
- }
173
-
174
- #render(): void {
175
- const {start, end} = this.#getPageRangeForAddress(this.#address, this.#numBytesPerPage);
176
-
177
- const navigatorAddressToShow = this.#currentNavigatorMode === Mode.SUBMITTED ? formatAddress(this.#address) :
178
- this.#currentNavigatorAddressLine;
179
- const navigatorAddressIsValid = this.#isValidAddress(navigatorAddressToShow);
180
-
181
- const invalidAddressMsg = i18nString(
182
- UIStrings.addressHasToBeANumberBetweenSAnd,
183
- {PH1: formatAddress(0), PH2: formatAddress(this.#outerMemoryLength)});
184
-
185
- const errorMsg = navigatorAddressIsValid ? undefined : invalidAddressMsg;
186
-
187
- const canGoBackInHistory = this.#history.canRollback();
188
- const canGoForwardInHistory = this.#history.canRollover();
189
-
190
- const highlightedMemoryAreas = this.#highlightInfo ? [this.#highlightInfo] : [];
191
- const focusedMemoryHighlight = this.#getSmallestEnclosingMemoryHighlight(highlightedMemoryAreas, this.#address);
192
- // Disabled until https://crbug.com/1079231 is fixed.
193
- // clang-format off
194
- render(html`
195
- <style>${linearMemoryInspectorStyles}</style>
196
- <div class="view">
197
- <devtools-linear-memory-inspector-navigator
198
- .data=${{address: navigatorAddressToShow, valid: navigatorAddressIsValid, mode: this.#currentNavigatorMode, error: errorMsg, canGoBackInHistory, canGoForwardInHistory}}
199
- @refreshrequested=${this.#onRefreshRequest}
200
- @addressinputchanged=${this.#onAddressChange}
201
- @pagenavigation=${this.#navigatePage}
202
- @historynavigation=${this.#navigateHistory}></devtools-linear-memory-inspector-navigator>
203
- <devtools-linear-memory-highlight-chip-list
204
- .data=${{highlightInfos: highlightedMemoryAreas, focusedMemoryHighlight }}
205
- @jumptohighlightedmemory=${this.#onJumpToAddress}>
206
- </devtools-linear-memory-highlight-chip-list>
207
- <devtools-linear-memory-inspector-viewer
208
- .data=${{
209
- memory: this.#memory.slice(start - this.#memoryOffset,
210
- end - this.#memoryOffset),
211
- address: this.#address, memoryOffset: start,
212
- focus: this.#currentNavigatorMode === Mode.SUBMITTED,
213
- highlightInfo: this.#highlightInfo,
214
- focusedMemoryHighlight }}
215
- @byteselected=${this.#onByteSelected}
216
- @resize=${this.#resize}>
217
- </devtools-linear-memory-inspector-viewer>
218
- </div>
219
- ${this.#hideValueInspector ? nothing : html`
220
- <div class="value-interpreter">
221
- <devtools-linear-memory-inspector-interpreter
222
- .data=${{
223
- value: this.#memory.slice(this.#address - this.#memoryOffset, this.#address + VALUE_INTEPRETER_MAX_NUM_BYTES).buffer,
224
- valueTypes: this.#valueTypes,
225
- valueTypeModes: this.#valueTypeModes,
226
- endianness: this.#endianness,
227
- memoryLength: this.#outerMemoryLength }}
228
- @valuetypetoggled=${this.#onValueTypeToggled}
229
- @valuetypemodechanged=${this.#onValueTypeModeChanged}
230
- @endiannesschanged=${this.#onEndiannessChanged}
231
- @jumptopointeraddress=${this.#onJumpToAddress}
232
- >
233
- </devtools-linear-memory-inspector-interpreter/>
234
- </div>`}
235
- `, this.#shadow, {
236
- host: this,
237
- });
238
- // clang-format on
361
+ const viewInput: ViewInput = {
362
+ memory: this.#memory,
363
+ address: this.#address,
364
+ memoryOffset: this.#memoryOffset,
365
+ outerMemoryLength: this.#outerMemoryLength,
366
+ valueTypes: this.#valueTypes,
367
+ valueTypeModes: this.#valueTypeModes,
368
+ endianness: this.#endianness,
369
+ highlightInfo: this.#highlightInfo,
370
+ hideValueInspector: this.#hideValueInspector,
371
+ currentNavigatorMode: this.#currentNavigatorMode,
372
+ currentNavigatorAddressLine: this.#currentNavigatorAddressLine,
373
+ canGoBackInHistory: this.#history.canRollback(),
374
+ canGoForwardInHistory: this.#history.canRollover(),
375
+ onRefreshRequest: this.#onRefreshRequest.bind(this),
376
+ onAddressChange: this.#onAddressChange.bind(this),
377
+ onNavigatePage: this.#navigatePage.bind(this),
378
+ onNavigateHistory: this.#navigateHistory.bind(this),
379
+ onJumpToAddress: this.#onJumpToAddress.bind(this),
380
+ onByteSelected: this.#onByteSelected.bind(this),
381
+ onResize: this.#resize.bind(this),
382
+ onValueTypeToggled: this.#onValueTypeToggled.bind(this),
383
+ onValueTypeModeChanged: this.#onValueTypeModeChanged.bind(this),
384
+ onEndiannessChanged: this.#onEndiannessChanged.bind(this),
385
+ memorySlice: this.#memory.slice(start - this.#memoryOffset, end - this.#memoryOffset),
386
+ viewerStart: start,
387
+ };
388
+ this.#view(viewInput, {}, this.contentElement);
239
389
  }
240
390
 
241
391
  #onJumpToAddress(e: JumpToPointerAddressEvent|JumpToHighlightedMemoryEvent): void {
@@ -247,8 +397,8 @@ export class LinearMemoryInspector extends HTMLElement {
247
397
  }
248
398
 
249
399
  #onRefreshRequest(): void {
250
- const {start, end} = this.#getPageRangeForAddress(this.#address, this.#numBytesPerPage);
251
- this.dispatchEvent(new MemoryRequestEvent(start, end, this.#address));
400
+ const {start, end} = getPageRangeForAddress(this.#address, this.#numBytesPerPage, this.#outerMemoryLength);
401
+ this.contentElement.dispatchEvent(new MemoryRequestEvent(start, end, this.#address));
252
402
  }
253
403
 
254
404
  #onByteSelected(e: ByteSelectedEvent): void {
@@ -263,18 +413,13 @@ export class LinearMemoryInspector extends HTMLElement {
263
413
 
264
414
  #onEndiannessChanged(e: EndiannessChangedEvent): void {
265
415
  this.#endianness = e.data;
266
- this.dispatchEvent(new SettingsChangedEvent(this.#createSettings()));
267
- this.#render();
268
- }
269
-
270
- #isValidAddress(address: string): boolean {
271
- const newAddress = parseAddress(address);
272
- return newAddress !== undefined && newAddress >= 0 && newAddress < this.#outerMemoryLength;
416
+ this.contentElement.dispatchEvent(new SettingsChangedEvent(this.#createSettings()));
417
+ void this.requestUpdate();
273
418
  }
274
419
 
275
420
  #onAddressChange(e: AddressInputChangedEvent): void {
276
421
  const {address, mode} = e.data;
277
- const isValid = this.#isValidAddress(address);
422
+ const isValid = isValidAddress(address, this.#outerMemoryLength);
278
423
  const newAddress = parseAddress(address);
279
424
  this.#currentNavigatorAddressLine = address;
280
425
 
@@ -290,7 +435,7 @@ export class LinearMemoryInspector extends HTMLElement {
290
435
  this.#currentNavigatorMode = Mode.EDIT;
291
436
  }
292
437
 
293
- this.#render();
438
+ void this.requestUpdate();
294
439
  }
295
440
 
296
441
  #onValueTypeToggled(e: ValueTypeToggledEvent): void {
@@ -300,16 +445,16 @@ export class LinearMemoryInspector extends HTMLElement {
300
445
  } else {
301
446
  this.#valueTypes.delete(type);
302
447
  }
303
- this.dispatchEvent(new SettingsChangedEvent(this.#createSettings()));
304
- this.#render();
448
+ this.contentElement.dispatchEvent(new SettingsChangedEvent(this.#createSettings()));
449
+ void this.requestUpdate();
305
450
  }
306
451
 
307
452
  #onValueTypeModeChanged(e: ValueTypeModeChangedEvent): void {
308
453
  e.stopImmediatePropagation();
309
454
  const {type, mode} = e.data;
310
455
  this.#valueTypeModes.set(type, mode);
311
- this.dispatchEvent(new SettingsChangedEvent(this.#createSettings()));
312
- this.#render();
456
+ this.contentElement.dispatchEvent(new SettingsChangedEvent(this.#createSettings()));
457
+ void this.requestUpdate();
313
458
  }
314
459
 
315
460
  #navigateHistory(e: HistoryNavigationEvent): boolean {
@@ -328,32 +473,16 @@ export class LinearMemoryInspector extends HTMLElement {
328
473
  console.warn(`Specified address is out of bounds: ${address}`);
329
474
  return;
330
475
  }
331
- this.#setAddress(address);
332
- this.#update();
333
- }
334
-
335
- #getPageRangeForAddress(address: number, numBytesPerPage: number): {start: number, end: number} {
336
- const pageNumber = Math.floor(address / numBytesPerPage);
337
- const pageStartAddress = pageNumber * numBytesPerPage;
338
- const pageEndAddress = Math.min(pageStartAddress + numBytesPerPage, this.#outerMemoryLength);
339
- return {start: pageStartAddress, end: pageEndAddress};
476
+ this.address = address;
477
+ void this.requestUpdate();
340
478
  }
341
479
 
342
480
  #resize(event: ResizeEvent): void {
343
481
  this.#numBytesPerPage = event.data;
344
- this.#update();
345
- }
346
-
347
- #update(): void {
348
- const {start, end} = this.#getPageRangeForAddress(this.#address, this.#numBytesPerPage);
349
- if (start < this.#memoryOffset || end > this.#memoryOffset + this.#memory.length) {
350
- this.dispatchEvent(new MemoryRequestEvent(start, end, this.#address));
351
- } else {
352
- this.#render();
353
- }
482
+ void this.requestUpdate();
354
483
  }
355
484
 
356
- #setAddress(address: number): void {
485
+ set address(address: number) {
357
486
  // If we are already showing the address that is requested, no need to act upon it.
358
487
  if (this.#address === address) {
359
488
  return;
@@ -361,40 +490,12 @@ export class LinearMemoryInspector extends HTMLElement {
361
490
  const historyEntry = new AddressHistoryEntry(address, () => this.#jumpToAddress(address));
362
491
  this.#history.push(historyEntry);
363
492
  this.#address = address;
364
- this.dispatchEvent(new AddressChangedEvent(this.#address));
365
- }
366
-
367
- // Returns the highlightInfo with the smallest size property that encloses the provided address.
368
- // If there are multiple smallest enclosing highlights, we pick the one appearing the earliest in highlightedMemoryAreas.
369
- // If no such highlightInfo exists, it returns undefined.
370
- //
371
- // Selecting the smallest enclosing memory highlight is a heuristic that aims to pick the
372
- // most specific highlight given a provided address. This way, objects contained in other objects are
373
- // potentially still accessible.
374
- #getSmallestEnclosingMemoryHighlight(highlightedMemoryAreas: HighlightInfo[], address: number): HighlightInfo
375
- |undefined {
376
- let smallestEnclosingHighlight;
377
- for (const highlightedMemory of highlightedMemoryAreas) {
378
- if (highlightedMemory.startAddress <= address &&
379
- address < highlightedMemory.startAddress + highlightedMemory.size) {
380
- if (!smallestEnclosingHighlight) {
381
- smallestEnclosingHighlight = highlightedMemory;
382
- } else if (highlightedMemory.size < smallestEnclosingHighlight.size) {
383
- smallestEnclosingHighlight = highlightedMemory;
384
- }
385
- }
386
- }
387
- return smallestEnclosingHighlight;
493
+ this.contentElement.dispatchEvent(new AddressChangedEvent(this.#address));
494
+ void this.requestUpdate();
388
495
  }
389
496
  }
390
497
 
391
- customElements.define('devtools-linear-memory-inspector-inspector', LinearMemoryInspector);
392
-
393
498
  declare global {
394
- interface HTMLElementTagNameMap {
395
- 'devtools-linear-memory-inspector-inspector': LinearMemoryInspector;
396
- }
397
-
398
499
  interface HTMLElementEventMap {
399
500
  memoryrequest: MemoryRequestEvent;
400
501
  addresschanged: AddressChangedEvent;
@@ -4,29 +4,36 @@
4
4
  * found in the LICENSE file.
5
5
  */
6
6
 
7
- :host {
8
- flex: auto;
9
- display: flex;
10
- }
7
+ @scope to (devtools-widget > *) {
8
+ :scope {
9
+ flex: auto;
10
+ display: flex;
11
+ }
11
12
 
12
- .view {
13
- width: 100%;
14
- display: flex;
15
- flex: 1;
16
- flex-direction: column;
17
- font-family: var(--monospace-font-family);
18
- font-size: var(--monospace-font-size);
19
- padding: 9px 12px 9px 7px;
20
- }
13
+ * {
14
+ min-width: unset;
15
+ box-sizing: content-box;
16
+ }
21
17
 
22
- devtools-linear-memory-inspector-viewer {
23
- justify-content: center;
24
- }
18
+ .view {
19
+ width: 100%;
20
+ display: flex;
21
+ flex: 1;
22
+ flex-direction: column;
23
+ font-family: var(--monospace-font-family);
24
+ font-size: var(--monospace-font-size);
25
+ padding: 9px 12px 9px 7px;
26
+ }
25
27
 
26
- devtools-linear-memory-inspector-navigator + devtools-linear-memory-inspector-viewer {
27
- margin-top: 12px;
28
- }
28
+ devtools-linear-memory-inspector-viewer {
29
+ justify-content: center;
30
+ }
31
+
32
+ devtools-linear-memory-inspector-navigator + devtools-linear-memory-inspector-viewer {
33
+ margin-top: 12px;
34
+ }
29
35
 
30
- .value-interpreter {
31
- display: flex;
36
+ .value-interpreter {
37
+ display: flex;
38
+ }
32
39
  }
@@ -1,7 +1,7 @@
1
1
  Name: Dependencies sourced from the upstream `chromium` repository
2
2
  URL: https://source.chromium.org/chromium/chromium/src/+/main:components/variations/proto/devtools/
3
3
  Version: N/A
4
- Revision: a30399d46b7914d6e069850de11a91944acf37b1
4
+ Revision: 21c0e9d79181fd991f782bb74b0eb1c8bce10209
5
5
  Update Mechanism: Manual (https://crbug.com/428069060)
6
6
  License: BSD-3-Clause
7
7
  License File: LICENSE
@@ -4,11 +4,16 @@
4
4
 
5
5
  import * as LinearMemoryInspectorComponents from '../../../../panels/linear_memory_inspector/components/components.js';
6
6
  import * as FrontendHelpers from '../../../../testing/EnvironmentHelpers.js';
7
+ import * as UI from '../../../legacy/legacy.js';
8
+ import * as Lit from '../../../lit/lit.js';
7
9
  import * as ComponentHelpers from '../../helpers/helpers.js';
8
10
 
9
11
  await ComponentHelpers.ComponentServerSetup.setup();
10
12
  await FrontendHelpers.initializeGlobalVars();
11
13
 
14
+ const {render, html} = Lit;
15
+ const {widgetConfig} = UI.Widget;
16
+
12
17
  const array = [];
13
18
  const string = 'Hello this is a string from the memory buffer!';
14
19
 
@@ -21,12 +26,19 @@ for (let i = -1000; i < 1000; ++i) {
21
26
  }
22
27
 
23
28
  const memory = new Uint8Array(array);
24
- const memoryInspector = new LinearMemoryInspectorComponents.LinearMemoryInspector.LinearMemoryInspector();
25
- document.getElementById('container')?.appendChild(memoryInspector);
26
-
27
- memoryInspector.data = {
28
- memory,
29
- address: 0,
30
- memoryOffset: 0,
31
- outerMemoryLength: memory.length,
32
- };
29
+
30
+ const container = document.getElementById('container');
31
+ if (container) {
32
+ render(
33
+ html`
34
+ <devtools-widget .widgetConfig=${
35
+ widgetConfig(LinearMemoryInspectorComponents.LinearMemoryInspector.LinearMemoryInspector, {
36
+ memory,
37
+ address: 0,
38
+ memoryOffset: 0,
39
+ outerMemoryLength: memory.length,
40
+ })}>
41
+ </devtools-widget>
42
+ `,
43
+ container);
44
+ }
@@ -10,7 +10,15 @@ export class RangeWalker {
10
10
  #eof: boolean;
11
11
 
12
12
  constructor(readonly root: Node) {
13
- this.#treeWalker = document.createTreeWalker(root, NodeFilter.SHOW_TEXT);
13
+ const nodeFilter = {
14
+ acceptNode(node: Node): number {
15
+ if (['STYLE', 'SCRIPT'].includes(node.parentNode?.nodeName ?? '')) {
16
+ return NodeFilter.FILTER_REJECT;
17
+ }
18
+ return NodeFilter.FILTER_ACCEPT;
19
+ },
20
+ };
21
+ this.#treeWalker = document.createTreeWalker(root, NodeFilter.SHOW_TEXT, nodeFilter);
14
22
  this.#eof = !this.#treeWalker.firstChild();
15
23
  }
16
24
 
@@ -57,6 +65,18 @@ export class RangeWalker {
57
65
  range.setEnd(endNode, offsetInEndNode);
58
66
  return range;
59
67
  }
68
+
69
+ goToTextNode(node: Text): void {
70
+ while (this.#treeWalker.currentNode !== node) {
71
+ if (!this.#next()) {
72
+ return;
73
+ }
74
+ }
75
+ }
76
+
77
+ get offset(): number {
78
+ return this.#offset;
79
+ }
60
80
  }
61
81
 
62
82
  export const HIGHLIGHT_REGISTRY = 'highlighted-search-result';