The phrase swimming laps is used as C. subject complement of this sentence.
Since it is preceded by a linking verb is, it cannot be a direct object. And since the phrase my grandmother's favorite form of exercise is subject, it cannot be the subject either. There is no preposition before it, so it is not the object of a preposition.