W3C home > Mailing lists > Public > www-style@w3.org > January 2011

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

From: Jeff Walden <jwalden@MIT.EDU>
Date: Thu, 13 Jan 2011 03:30:58 -0600
Message-ID: <4D2EC652.7040003@mit.edu>
To: "Tab Atkins Jr." <jackalmage@gmail.com>
CC: www-style@w3.org
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.  :-)

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

This archive was generated by hypermail 2.3.1 : Monday, 2 May 2016 14:38:42 UTC