Added Top logic as in Webkit. We should improve it!