backgrounds with background-size, background-position and/or background-origin do not always lay out correctly. This problem is covered by the following existing layout tests:
Created attachment 8104 [details]
Here is a patch that fixes the problem. This patch generally re-arranges things so that the scaledImageWidth and scaledImageHeight are calculated at the beginning and taken into consideration when calculating cx, cy, cw, ch, sx, and sy. This means that we no longer have to scale the source point over in the image code and that we can remove some of the weird if-clauses that adjusted the c-values when the scale sizes were computed after the fact.
Comment on attachment 8104 [details]
I committed the fix.