There's code very similar to this in HTMLUtils.findStyleBlocks().  Should we consolidate?