This is a real issue else I wouldn't have brought it up - one can see this by reading the code.  ANIM_STATE_APPLIED can be set directly from the Animate() routine above at the end of (for instance) a visible/hidden animation.  Thus, UpdateStates() will change the control to hidden, yet Animate() will return true as the area the control is rendered in may have changed.  We must mark as dirty in this case, yet with your change we don't.

Thus, you need to move the checking for dirty and updating of dirty regions out of the IsVisible() block.