the possessor's gender may impact the choice of the possessive pronoun. here it does. she's feminine, so její.
the possessee's gender may impact the ending of that possessive pronoun. here it does. he's (singular) masculine, so in locative, it needs to be "jejím".
now more generally:
the choice of the possessive pronoun depends on the possessor's person (1st, 2nd, 3rd), number (sg., pl.), and (in 3rd person sg.) gender.
the ending may depend on the possessee's number (sg., pl.), case (7 to pick from), and gender.
there are degenerate combinations.
if the possessor is 3rd person sg. masculine or neuter, the pronoun is invariably just "jeho" no matter the possessee's parameters.
likewise, we get the invariable "jejich" for 3rd person plural possessors of all genders and no matter the possessee's parameters.
possessor's gender does not matter in 1st and 2nd persons, but then we get the full impact of the possessee's parameters.