Brazil's Supreme Court has voted overwhelmingly in favor of allowing same-sex couples the same legal rights as married heterosexuals.