-
Notifications
You must be signed in to change notification settings - Fork 0
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
[Canvas V2][1/n] Implement display of measures #31
Conversation
bb82a38
to
74d629c
Compare
src/canvas/renderCanvas.js
Outdated
hoveredEvent && hoveredEvent.measure === measure; | ||
const showGroupHighlight = | ||
hoveredEvent && | ||
hoveredEvent.measure !== null && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Next line will throw if hoveredEvent.measure === undefined
. Would probably just do a falsy check, or if there's a lot of this type of deep property munging ahead, use idx.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
idx
is interesting. Just too bad JS hasn't gotten the optional chaining operator yet.
Flow should already help to ensure that hoveredEvent.measure
is null | ReactMeasure
, but yeah a falsy check won't hurt. I'll change it
function renderSingleReactMarkOrMeasure({ | ||
baseY, | ||
canvasWidth, | ||
function renderSingleReactMeasure( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if these big functions would be better off using an object argument with destructuring to simulate named arguments?
For long args lists, named arguments are more readable than positional at the call site, and since these args are mostly primitive data types, it's easy to pass the wrong argument at wrong position and still pass flow check
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, IMO these functions would be easier to grok if we explicitly stated the input/output types, but I'm not married to that idea.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, these suggestions make sense. I'll do these for all the render* functions in a PR on top of 3/n so that we cover all the functions added after this PR and also so that we don't get too many rebase conflicts
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, this doesn't seem important enough to warrant the confusion of stacked PR shuffling, so I've added it as a task in #30 to be done in another PR at the top of the stack
src/canvas/renderCanvas.js
Outdated
|
||
const y = baseY - offsetY; | ||
|
||
// $FlowFixMe We know these won't be null |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This $FlowFixMe
doesn't actually reach to the ternary clauses because it only matches literally next code line.
I'd personally solve by throwing instead of console.warning on line 227, allowing flow to refine the types to always strings.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Few nits, but over all looking good.
For this type open source code base, where future contributors may not have the kind of time we have to familiarise themselves in the codebase, I'd like to see more comments. But these can be added at a later iteration if needed.
What's the rationale for data
and dataV2
? Are both to be supported in the long term, or are we deprecating data
?
@@ -488,9 +568,9 @@ export const renderCanvas = memoize( | |||
|
|||
renderBackgroundFills(context, canvasWidth, canvasHeight); | |||
|
|||
renderReactMarksAndMeasures( | |||
const schedulerAreaEndY = renderReactMarksAndMeasures( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's really quite unintuitive that renderReactMarksAndMeasures
returns its minY. I understand why that needs to be computed there, but it should be more visible, as I only realised this is what was happening while reviewing 2/n
renderReactMarksAndMeasuresAndReturnComputedLaneHeight
? 😜
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update from 3/n
, now that both renderReactEventRow
and renderReactMeasures
return a new Y, the "stacking" logic is much clearer than it was when it was just one function.
Wouldn't got as far as renaming them anymore, but I'd definitely annotate their function signatures with : number
to make it obvious from the start they return something, and add a comment explaining what they return.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, my idea was for all these render functions to report what they rendered so that we can lay everything out based on what was rendered.
I think this isn't super clear because we're rendering in overlapping layers, and not all layers have stacks. We're also stacking exclusively in the Y direction, but there's definitely a possibility of stacking in the X direction as well (e.g. for the old priority labels).
I'll add the : number
in this PR.
There's also the unrelated issue of having to recalculate all of these in the getHoveredEvent
util function. Ideally getHoveredEvent
will be able to reuse the calculations from these render functions so that we can be more confident that the returned hovered events are actually the ones rendered on screen.
Yeah, I had both |
74d629c
to
11f5207
Compare
Rebased on master and resolved most review comments |
b38d58c
to
2adb0e9
Compare
2adb0e9
to
f754719
Compare
Rebased on master and update |
Depends on #27, #28. Blocked by #29. Part of #30.
To be rebased on top of the #30's PR before merging.
Review notes
This PR is completed but will not compile without #29's PR.
Splitting #30 into a stack of PRs for easier review.
Test Plan