Re: [css3-background] Implementation tips concerning algorithm for computing sizes of background images lacking intrinsic dimensions?

I went back and took a second stab at this, and it didn't turn out nearly as complicated as I'd first envisioned it would be.  My first attempt started by trying to split on presence of a ratio first, then on have-width and have-height, then on the background-size value.  It turns out significantly better if you split on the overall background-size value, then (usually) split on have-width and have-height, then last on ratio or not.  There are also some cute fall-throughs you can add in a few places (I think -- they're untested still, need a few unrelated changes before I can do that) to help matters.  This implementation's only 107 lines of code, not including assertions and non-code lines.  It's far more reasonable, and even readable, than I'd first thought it would be.  So I think I'm actually good on this front now, but still, thanks for the offer.  I probably shouldn't have thrown in the towel so quickly as I did the first time around.  :-)

Jeff

Received on Thursday, 13 January 2011 09:32:01 UTC