-
Notifications
You must be signed in to change notification settings - Fork 49k
[DevTools] Use Popover API for TraceUpdates highlighting #32614
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 4 commits
ecb403f
a83589c
9215664
f7eb1c6
938ad0e
9c21b1e
6893d25
862826b
c950b0d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,8 +43,30 @@ function drawNative(nodeToData: Map<HostInstance, Data>, agent: Agent) { | |
} | ||
|
||
function drawWeb(nodeToData: Map<HostInstance, Data>) { | ||
// if there are no nodes to draw, detach from top layer | ||
if (nodeToData.size === 0) { | ||
if (canvas !== null) { | ||
try { | ||
if (canvas.matches(':popover-open')) { | ||
// $FlowFixMe[prop-missing] | ||
// $FlowFixMe[incompatible-use] | ||
canvas.hidePopover(); | ||
yongsk0066 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
} catch (e) {} | ||
} | ||
return; | ||
} | ||
|
||
if (canvas === null) { | ||
initialize(); | ||
} else { | ||
try { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as above, you don't need it to wrap it in try / catch, since we bumped minimum versions for the extension Please also check other calls below There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for pointing this out! I've removed all try/catch blocks around Popover API calls. |
||
if (!canvas.matches(':popover-open')) { | ||
// $FlowFixMe[prop-missing] | ||
// $FlowFixMe[incompatible-use] | ||
canvas.showPopover(); | ||
} | ||
} catch (e) {} | ||
} | ||
|
||
const dpr = window.devicePixelRatio || 1; | ||
|
@@ -191,7 +213,15 @@ function destroyNative(agent: Agent) { | |
|
||
function destroyWeb() { | ||
if (canvas !== null) { | ||
try { | ||
// $FlowFixMe[prop-missing] | ||
// $FlowFixMe[incompatible-use] | ||
canvas.hidePopover(); | ||
} catch (e) {} | ||
|
||
// $FlowFixMe[incompatible-use]: Flow doesn't recognize Popover API and loses canvas nullability tracking | ||
if (canvas.parentNode != null) { | ||
// $FlowFixMe[incompatible-call]: Flow doesn't track that canvas is non-null here | ||
canvas.parentNode.removeChild(canvas); | ||
} | ||
canvas = null; | ||
|
@@ -204,6 +234,9 @@ export function destroy(agent: Agent): void { | |
|
||
function initialize(): void { | ||
canvas = window.document.createElement('canvas'); | ||
// canvas.setAttribute('popover', 'manual'); | ||
yongsk0066 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
// $FlowFixMe[incompatible-use] | ||
canvas.style.cssText = ` | ||
xx-background-color: red; | ||
xx-opacity: 0.5; | ||
|
@@ -213,9 +246,18 @@ function initialize(): void { | |
position: fixed; | ||
right: 0; | ||
top: 0; | ||
z-index: 1000000000; | ||
background-color: transparent; | ||
outline: none; | ||
box-shadow: none; | ||
border: none; | ||
`; | ||
|
||
const root = window.document.documentElement; | ||
root.insertBefore(canvas, root.firstChild); | ||
|
||
try { | ||
// $FlowFixMe[prop-missing] | ||
// $FlowFixMe[incompatible-use] | ||
yongsk0066 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
canvas.showPopover(); | ||
} catch (e) {} | ||
} |
Uh oh!
There was an error while loading. Please reload this page.