Adjust PNG encoder color type to match what's read from gl2

This should fix images produced by the -o flag.
Add glfw window_refresh_callback, windows now redraw on linux

Fixes #941.
auto merge of #1414 : dhedlund/servo/issue_941, r=larsbergstrom

Moving another window on top of servo window, or switching screen would result in a blank window until the app was resized.  This was due to a missing glfw callback.

Fixes #941.
Drain compositor_chan on shutdown, causes deadlocks on constellation

Constellation blocks on SetId by sending a Port through the compositor
channel and waits for a response.  If the compositor is in the process of
shutting down, it will not look in the queue again.  The compositor
requires the constellation to be shut down first, so it sends a message
to shut down and blocks until the constellation finishes, deadlocking.

Only very short lived executions would've been likely to see this deadlock.
auto merge of #1415 : dhedlund/servo/constellation_deadlock, r=pcwalton

Constellation blocks on SetId by sending a Port through the compositor channel and waits for a response.  If the compositor is in the process of shutting down, it will not look in the queue again.  The compositor requires the constellation to be shut down first, so it sends a message to shut down and blocks until the constellation finishes, deadlocking.

Only very short lived executions would've been likely to see this deadlock.

_It is technically still possible to trigger a SetId message between when the compositor finishes running and when the constellation shuts down, but the window for exposure is greatly reduced.  I've only seen it with "-o" so far._
style: Reduce allocations in selector matching.

This is a 27% improvement in CSS selector matching performance.
auto merge of #1393 : pcwalton/servo/optimize-css, r=pcwalton

This is a 27% improvement in CSS selector matching performance.

r? @SimonSapin
auto merge of #1413 : dhedlund/servo/png_color_type, r=pcwalton

This should fix images produced by the -o flag.

The gl2::read_pixels call was asking for pixel data in RGB8 but was then telling the PNG encoder that the data was RGBA8.  The value was originally set correctly, but was changed when support was added for drawing transparent PNGs.

We could instead adjust the gl2::read_pixels call to return RGBA8 so we can write transparent screenshots, but I'm not sure if there's a use case for that.
Don't perform composite unless renderer has indicated it's idle

The rendergl::render_scene() function is being called more often than
it needs to be, sometimes before the renderer has finished.  This
could result in PNG images that are drawn before the frame trees set
in SetIds is rendered.
Ensure render and layout tasks get destructed before main thread finishes

Fixes #1097.
auto merge of #1411 : dhedlund/servo/_1097_2, r=pcwalton

Pipeline now blocks on `Pipeline.exit()` and waits for confirmation that RenderTask and LayoutTask were successfully destructed (they're created inside a block which ensures they go out of scope before the message is sent.

Other notable changes include:
* The blocking recv in main/servo.rc that waits for a constellation exit confirmation was moved out of the spawn and into the main thread.  `Constellation::start()` spawns a new task, so there's no need to block in that task once the ExitMsg is sent off.

* Application initialization was moved out of `run_compositor` and into `CompositorTask`, so it could be stored with the compositor task and not go out of scope until the program's main block finishes.

I had to use SharedPort<()> objects to work around the fact that pipelines get cloned, even though it feels like pipelines should probably be ref counted instead.  I went down that route for a few hours but got bogged down trying to wrap my head around some region/lifetime issues; I would be happy to work on that part again, but would need some mentoring to help me figure out what I was doing wrong and possibly why.  The current solution doesn't feel too bad though.

Fixes #1097.
Add comments and improve performance of a comparison
Track whether first render has run, not whether it's currently idle
auto merge of #1418 : dhedlund/servo/composite_when_ready, r=pcwalton

The rendergl::render_scene() function is being called more often than it needs to be, sometimes before the renderer has finished.  This could result in PNG images that are drawn before the frame trees set in SetIds is rendered.