- From: Tab Atkins Jr. <jackalmage@gmail.com>
- Date: Wed, 23 Feb 2011 10:59:37 -0800
- To: "L. David Baron" <dbaron@dbaron.org>
- Cc: Sylvain Galineau <sylvaing@microsoft.com>, www-style list <www-style@w3.org>
On Wed, Feb 23, 2011 at 9:44 AM, Tab Atkins Jr. <jackalmage@gmail.com> wrote: > On Wed, Feb 23, 2011 at 9:40 AM, L. David Baron <dbaron@dbaron.org> wrote: >> On Monday 2011-02-14 10:56 -0800, Tab Atkins Jr. wrote: >>> | 1. If the image has an intrinsic width or height, >>> | then that intrinsic width/height becomes the image's >>> | used width/height. >>> | >>> | 2. If the image has an intrinsic ratio, and either an >>> | intrinsic width or an intrinsic height, calculate the >>> | missing dimension from the provided dimension and the >>> | ratio. >>> | >>> | 3. If the image has no intrinsic ratio and no intrinsic >>> | width, the used width is 1em. >>> | >>> | 4. If the image has no intrinsic ratio and no intrinsic >>> | height, the used height is 1em. >> >> I think steps (3) and (4) here aren't quite right, since if the >> image has an intrinsic ratio, but neither an intrinsic width nor an >> intrinsic height, then these rules don't define a result. >> >> It might be better to revert these to the wording used before, in >> step 5: >> >>> # 5. If the image's height cannot be resolved from the rules >>> # above, then the image's height is assumed to be 1em. > > The rules weren't meant to be exclusive - they're meant to be applied > one-by-one. I'm fine with using your suggested wording to make it > more explicit, though. I missed the implication of your statement above: you were pointing out that I'm missing the case where an image has an intrinsic ratio but no intrinsic dimensions. Here's an edited proposal, somewhat rearranged for added clarity. Now, each step "finishes" an image - as soon as you hit the one that you pass the condition for, you can abort with a properly-sized image. | 1. If the image has a intrinsic width and height, the | used width and height are the same. | | 2. Otherwise, if the image has an intrinsic ratio and | either an intrinsic width or an intrinsic height, the | used width/height is the same as the provided intrinsic | width/height, and the used value of the missing dimension | is calculated from the provided dimension and the ratio. | | 3. Otherwise, if the image has an intrinsic ratio, the used | width is 1em and the used height is calculated from this width | and the intrinsic ratio. If this would produce a height larger | than 1em, then the used height is instead set to 1em and the | used width is calculated from this height and the intrinsic | ratio. | | 4. Otherwise, the image's used width is its intrinsic width | if it has one, or else 1em. The image's used height is its | intrinsic height if it has one, or else 1em. (Step 1 isn't strictly necessary, as images that match step 1 would also match step 4 and be handled correctly, but I think it makes it clearer if you quickly abort for raster images, and it makes the phrasing of step 2 less ambiguous. Damn English's lack of an unambiguous xor.) These should now cover all 8 possible combinations of width/height/ratio presence: 1. No dimensions. Caught by case 4, sized to 1em by 1em. 2. Only intrinsic width. Caught by case 4, given a 1em height. 3. Only intrinsic height. Caught by case 4, given a 1em width. 4. Only intrinsic ratio. Caught by case 3, size calculated to preserve ratio and contain the image in a 1em by 1em square. 5. Only intrinsic ratio and intrinsic width. Caught by case 2, height calculated from ratio. 6. Only intrinsic ratio and intrinsic height. Caught by case 2, width calculated from ratio. 7. Only intrinsic width and height. Caught by case 1, no change. 8. Intrinsic width, height, and ratio. Caught be case 1, no change. These behaviors match the Image Values algorithm (plug in a specified size with no dimensions and a default object size of 1em by 1em) and match the Opera/Chrome behavior (if you pretend that Chrome's default object size here is 1em by 1em instead of a smaller square for some reason). ~TJ
Received on Wednesday, 23 February 2011 19:01:33 UTC