Followup 80dd016: avoid using XMLSerializer when not absolutely necessary

Because XMLSerializer is broken in Firefox: it URL-encodes hrefs.

Also move brokenness detection out of transformAttributes and into
parse/serializeXhtml.

Change-Id: I917944a16786040c57969c611f82192de29ee57b
Merge "Followup 80dd016: avoid using XMLSerializer when not absolutely necessary"