When + ing / While + ing 意思與不同

Toma saw the cute dog while walking outside.

A shorthand of “while Toma was walking” understood as Toma saw the cute dog during the walking activity

Toma saw the cute dog when walking out of the door.

A shorthand of “when Toma walked” understood as Toma saw the cute dog at the point he had just walked out of the door.