Notebook List View Cell rendering.

This commit is contained in:
rebornix 2021-11-17 12:35:35 -08:00
parent e9ca473f62
commit af87dc4a82
No known key found for this signature in database
GPG key ID: 181FC90D15393C20

View file

@ -4,9 +4,27 @@ The notebook editor is a virtualized list view rendered in two contexts (mainfra
## Notebook model resolution
![arch](https://user-images.githubusercontent.com/876920/141845889-abe0384e-0093-4b08-831a-04424a4b8101.png)
## Viewport rendering
The rendering of notebook list view is a "guess and validate" process. It will calcuate how many cells/rows it can render within the viewport, have them all rendered, and then ask for their real dimension, and based on the cell/row dimensions it will decide if it needs to render more cells (if there are still some room in the viewport) or remove a few.
For short, the process is more or less
* Render cell/row (DOM write)
* Read dimensions (DOM read)
The catch here is while rendering a cell/row, if we happen to perform any DOM read operation between DOM write, it will trigger forced reflow and block the UI. To prevent this we would batch all DOM read operatiosn and postpone them untill the list view requests them.
The worflow of rendering a code cell with a text output is like below and all operations are synchronous
![render in the core](https://user-images.githubusercontent.com/876920/142256110-a1c5800f-be46-4bd2-bbff-077c1c73e1fd.png)
When the notebook document contains markdown cells or rich outputs, the workflow is a bit more complex and become asynchornously partially due to the fact the markdown and rich outputs are rendered in a separate webview/iframe. While the list view renders the cell/row, it will send requests to the webview for output rendering, the rendering result (like dimensions of the output elements) won't come back in current frame. Once we receive the output rendering results from the webview (say next frame), we would ask the list view to adjust the position/dimension of the cell and ones below.
![render outputs in the webview/iframe](https://user-images.githubusercontent.com/876920/142276957-f73a155e-70cb-4066-b5cc-5f451c1c91c8.png)
## Cell rendering