Reflux and redraw
When the size, layout, and other changes render the hidden elements in the tree occurred on rebuilding needs. When the page layout and geometry attributes change needs to reflux.
When the render tree some elements update properties, but the properties only affect the appearance and style, it will not affect the layout, such as background-color.
It will trigger a page relocation of property
- Box model related properties
- Locate the relevant property
- Changing internal factors node
Box Model | Locate | Writing |
---|---|---|
width | top | text-align |
height | bottom | overflow-y |
padding | left | font-weight |
margin | right | overflow |
display | position | font-family |
border-width | float | line-height |
border | clear | vertival-align |
min-height | white-space | |
font-size |
Only trigger redraw property
Only redraw property |
---|
color |
border-radius |
visibility |
text-decoration |
background |
background-image |
background-position |
background-repeat |
background-size |
outline-color |
outline |
outline-style |
outline-width |
box-shadow |
Chrome layer to create the conditions
- 3D or perspective transformation (perspective transform) CSS properties
- Video decoding acceleration using a node
- 2D context node has 3D (WebGL) context or accelerated
- CSS opacity do on their own animation or use webkit transform an animated element
- It has accelerated CSS filter element
- There is a descendant element node contains composite layer (one element has a child element, the child elements in its own layer in)
- A lower element comprising a composite layer and a z-index sibling elements (in other words, the above elements are rendered in the composite layer)
New DOM process
- After obtaining the plurality of layers is divided into a DOM
- Style calculation results for each node of layer (Recalculate style- style weight)
- And generating pattern position (Layout- relayout reflux) for each node
- Each node is filled into a layer drawn bitmap (Paint Setup and redraw Paint-
- Layers uploaded to the GPU as a texture
- In line with multiple layers to generate the final screen image (Composite Layers- recombination layer) onto the page
The practical application of optimization points
- Alternatively translate top with change
- Alternative visibility with opacity
- Do not modify the DOM one by one style, pre-defined class, and then modify the DOM className
- After modifying the DOM offline, such as: first DOM to display: none (once Reflow), and then you modify 100 times, then put it up display
- Do not attribute value DOM nodes in a loop as a loop in the variable
- Do not use table layouts, may be small, a small change will result in re-layout of the entire table
- Select the animation speed to achieve
- For the new layer animation
- Enable GPU hardware acceleration