Ab initio investigation of hydrogen bonding and electronic structure of high-pressure phases of ice