Assuming $a<0$ and $b>0$. Spit the integral into, (this is the same as breaking up signed areas into two)
$$\int_{a}^{0} x dx+\int_{0}^{b} x dx$$
The first is going to be negative as it is below the $y$ axis, but it will in magnitude represent a triangle with base $a$ and height $a$. The second is going to be positive and represent a triangle with base $b$ and height $b$. So the integral is,
$$-\frac{1}{2}(a)(a)+\frac{1}{2}(b)(b)=\frac{1}{2}b^2-\frac{1}{2}a^2$$
There are a couple more cases to check $a,b>0$ which results in a trapezoid with base $b-a$ and average height $\frac{b+a}{2}$. So again we get $(b-a)\frac{b+a}{2}=\frac{1}{2}(b^2-a^2)$. Then the case $a,b<0$ is going to be similar to this. And the case $a>0, b<0$ is going to be similar to the very first case we considered.