It is not the presence or absence of a legal visa before the marriage that matters, but her presence in the UK.
If she was abroad at the time of the marriage, the clock for both of you will start ticking from the time she arrived in the UK.
If she was already resident in the UK, the clock would start ticking from the date of the marriage.
Essentially, both conditions need to be met, family membership of an EEA citizen AND residency in the UK. The clock starts ticking when the latter of the two conditions is met.