Monday, November 15, 2004

Shitcock!

Okay, now you have to hear about some computer shit because I am proud of it. So you know how I was writing a constraint-based layout engine? Well, here's my algorithm, which Mike Bell can probably prove inefficient and wrong. You start by building a tree of elements that need to be rendered, some of which may specify their size explicitly, some of which may specify their size unreasonably, and some of which may not specify size at all. Here's how you decide how big they get to be:
  • At every node in the tree, ask your children how much space they need to render themselves; offer each child node the maximum space available to you
  • If the aggregate of requested sizes from your children exceeds one or both dimensions of your maximum size, scale all children to fit proportionally
  • Set your size to the minimum between the aggregate of your child node requested sizes and the maximum space available to you
To calculate your own size requirements, do the following:
  • If you have any text content, size the text according to a line-break-aware text-sizing algorithm (too boring to describe here)
  • If you have child nodes, take the maximum width and the aggregate height (or vice versa, if you're orienting your elements horizontally) of your children
  • If you have a specified min-width or min-height, ensure that your requested width and height are at least equal to these lower bounds; if you have a specified max-width or max-height, these should establish a cap for both dimensions
Here's a piece of good news -- I was getting really frustrated because I was running my renderer on a bit of sample XUL and getting a layout I didn't understand. So I got kind of depressed and figured I'd dick around with the built-in XUL renderer in Firefox. I run it on my sample XUL, and I get the same output as my renderer! So my renderer appears to work, even though I have no idea why it's doing what it's doing. Now it's more or less a question of figuring out how to render all of the elements, like checkboxes and radio buttons, etc.

Here's a piece of bad news. It turns out the reason that KeySpan's been asking us to pay $60 a month for cooking gas is that there's a gas leak in the building somewhere between our apartment and the incoming gas line in the basement. The KeySpan guy shut off the gas to our apartment and the landlord's got a plumber coming on Thursday, but it's not super clear when we're gonna have gas again.

In a moment of nostalgia, I went searching for this story that Bill and I had found on Stile Project a while back. I remember Billy originally remarking on it as a pretty dead-on characterization of how depressing and shitty (literally!) suburban life sounds -- it doesn't disappoint.

I'm on vacation on Thursday and Friday! Suck a dick, employers!

No comments: