How does this 'chain rule manipulation' work? PS- this is a "physics" question, but mathematical in nature... if I should ask on physics SE instead, please let me know
Looking back through my physics books, I found a derivation of Kinetic Energy, where it begins by defining work ($W$) as the integral of the sum of all forces acting on an object over the distance that the object moves: 
$$W = \int_{x_i}^{x_f}\sum\vec{F}\,\mathrm{d}x$$
It then goes through some manipulations (using Newton's second law ($F = ma$) and acceleration being the derivative of velocity) to perform the following: 
$$W = \int_{x_i}^{x_f}ma\,\mathrm{d}x = \int_{x_i}^{x_f}m\frac{\mathrm{d}v}{\mathrm{d}t}\,\mathrm{d}x $$
And then it claims that it uses "chain rule manipulations" to do this:
$$\int_{x_i}^{x_f}m\frac{\mathrm{d}v}{\mathrm{d}t}\,\mathrm{d}x = \int_{x_i}^{x_f}m\frac{\mathrm{d}v}{\mathrm{d}x}\frac{\mathrm{d}x}{\mathrm{d}t}\,\mathrm{d}x=\int_{v_i}^{v_f}mv\,\mathrm{d}v$$
What's going on here, exactly? 


*

*Why were they able to use the definition of the chain rule? (Under what conditions could you do this?)

*Why did the integrand compress into $v\,\mathrm{d}v$?

*Does the fact that $\frac{\mathrm{d}v}{\mathrm{d}t}$ became $\frac{\mathrm{d}v}{\mathrm{d}x}\frac{\mathrm{d}x}{\mathrm{d}t}$ tell us that $v$ is a function of $x$, and $x$ is a function of $t$?

*Why is there a change of variable in the limits of integration?

 A: This is just integration by substitution, which is inspired by the chain rule: $\frac{dv}{dt}=\frac{dv}{dx} \frac{dx}{dt}$, so that we can change the integration variable from $x$ to $v$, "morally" by saying $\frac{dv}{dx} dx = dv$. The real story uses the chain rule and the FTC, but this is the idea. Note that when you integrate by substitution, you really update the limits: that is, integration by substitution would suggest that $\int_a^b u(x) u'(x) dx = \int_{u(a)}^{u(b)} u du$ (abusing notation slightly in the latter expression).
This will only work provided $x$ is continuously differentiable and its derivative never changes sign. If that is violated, then you have to split the integral or perhaps even deal with a path integral in certain situations.
A: Starting from your third line they are breaking up $$ \frac{dv }{dt}$$ into
$$  \frac{dv }{dx}* \frac {dx}{dt} $$
notice that dx values cancel when they are multiplied together (essentially multiplying by $$ 1=\frac{dx}{dx}$$ From here the  right term $$ \frac{dx }{dt}$$ becomes velocity and the left term $$ \frac{dv}{dx}$$ cancels with the original dx from the integral to leave dv.
So essentially they multplied by 1 (dx/dx) to change the expression into mv rather than ma.  The chain rule always applies but we don't usually keep track of it.  For instance, if $y=x^2$ then $dy/dx=2x*dx/dx$ but $dx/dx=1$.
Maybe you already understood this and are asking something else, but if not I hope this helps.
