mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Prevent unnecessary DOM append call when canvas is reused (#17864)
This commit is contained in:
parent
18df41928a
commit
8d7071ea46
@ -130,7 +130,12 @@ class _CanvasPool extends _SaveStackTracking {
|
||||
if (isFirstChildElement) {
|
||||
_canvas.style.zIndex = '-1';
|
||||
}
|
||||
_rootElement.append(_canvas);
|
||||
// Before appending canvas, check if canvas is already on rootElement. This
|
||||
// optimization prevents DOM .append call when a PersistentSurface is
|
||||
// reused. Reading lastChild is faster than append call.
|
||||
if (_rootElement.lastChild != _canvas) {
|
||||
_rootElement.append(_canvas);
|
||||
}
|
||||
_context = _canvas.context2D;
|
||||
_contextHandle = ContextStateHandle(_context);
|
||||
_initializeViewport(requiresClearRect);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user