Well, Margin is not accounted for in GetHeight, that is the root of problems.
I guess for your particular case, the metrics methods are sort of missing. However, if you look into ide AssistEditor::SyncAnnotationPopup() there is complete solution, you just need to account for margins...