Fixing visibility check for elements in parent overflow. Fixes issue 5518