static void InjectClosingCommandInBetween(RenderChain renderChain, RenderChainCommand cmd, ref RenderChainCommand prev, ref RenderChainCommand next) { Debug.Assert(cmd.closing); if (prev != null) { cmd.prev = prev; prev.next = cmd; } if (next != null) { cmd.next = next; next.prev = cmd; } VisualElement ve = cmd.owner; ve.renderChainData.lastClosingCommand = cmd; if (ve.renderChainData.firstClosingCommand == null) { ve.renderChainData.firstClosingCommand = cmd; } renderChain.OnRenderCommandAdded(cmd); // Adjust the pointers as a facility for later injections prev = cmd; next = cmd.next; }