Good Afternoon!
I quite agree with Stig and Sven-Ove (but not with Hans) that this pattern has been a very strong institution in the swedish namegiving tradition. It was, I would say, the main priciple for name-giving in all the social groups from kings to crofters and beggars until the period ca 1850-90, when the industrialism and urbanization more or less totally changed our social and cultural way of life.
In the same period the tradition of patronymica disappered, and was replaced by family names, that often was the previous generation´s patronymicon unchanched.
There was, however, some exeptions from the general pattern:
1) If the paternal grandfather was still alive, when the first son was born, one could instead chose the maternal grandfather´s name, or (rather often) the paternal great-grandfather´s name (the result is similar to the ex. Kristina is refering to). And of course, the same thing goes for the grandmother´s name. The original principle was that only dead persons could be renamed, but this became more and more disregarded.
2) If the father or the mother had been married before, the first daugther or son of the second marriage was often named after the late wife/husband.
3) If the father (or the family) had remarkably changed the social position, f.ex. was graduated or was nobilited, a finer or more suitible name could be given. But the chosen name could often have a or the same origin as the grandfather´s / grandmother´s name., f.ex. the latinized form Nicolaus instead of Nils.
4) If the grandfather/grandmother had a very old-fashioned name; f.ex. the archaic nordish names, like the ones we can find on the Rune-stones, another, more modern name could be chosen, but, even in this case, the chosen name had often a certain resemblance to the refused one, or beginning with the same letter.