Fix several issues related to caret and structural navigation in Gecko