Only trigger invalidate styles or layout if needed

To aid in performance, check if the CSS styles have changed before
touching the DOM element. Without this we get a consistent flood of style invalidations and re-layouts.