The best defense is a good offense.

Attacking doesn't always beat defense and vice versa. There's a fine line there. But this would be assuming that Djokovic only plays defense and never offense which isn't exactly correct. Giving the edge to Federer on medium surfaces is pushing it really. They are basically even there. The best way to compare Djokovic and Federer hypothetically is to look at their matches from 2007 Canada until 2012 WTF because their primes and peaks overlapped and they both were within the top 3 players in the world during this time. Federer won 6 Slams during this time and Djokovic won 5.
Slow hardcourt(AO, IW, Miami)/4-0 Djokovic
Fast hardcourt(USO, Cincy, Basel, Dubai, Shanghai)/7-4 Federer
Medium hardcourt(Canada, WTF)/2-2
Clay--3-2 Djokovic
Grass--1-0 Federer
Overall--13-12 Djokovic
Apart from their stomping grounds of slow and fast hardcourt, it's pretty even which I think this rivalry would have been if their peaks overlapped. They have been virtually even for a long time.
Looking further ahead, out of the 13 sets they have played at Wimbledon, Djokovic has had set points in 10 of them. Federer has done so in 7. Now this wasn't peak Federer but a Federer good enough to add 2 more Wimby titles in that time frame. This suggests that Djokovic would have been a handful for Federer to deal with at his peak. No way does he beat Djokovic 7 out of 10 times at Wimbledon.