XHTML rendering timeline different from HTML in WebKit? -
i'm working on project went xhtml html xhtml , there definite behavioral changes going regards page rendering before css loads , scripts read styles reading them before css loads. can shed light on why following happening , can done it?
basically, have page following structure:
<body> <!-- content source --> <link href="http://a.example.com/style.css" /> <header>...</header> <!-- content source b --> <link href="http://b.example.com/style.css" /> <div>...</div> <!-- content source --> <footer>...</footer> <script src="http://a.example.com/script.js"> /* e.g. */ alert($('header').offset().height); </script> </body>
when in html rendering mode, page blocks rendering @ expected points. when hit source css, rendering pauses (blank screen); when hit source b css, rendering pauses (header visible). when hit source javascript, rendering pauses (full page shown) , script reads element styles rendered state. (in reality, of course, webkit doesn't stop parsing dom or executing javascript while css loads, halt execution @ first point script needs read style.)
when in xhtml mode, page doesn't halt rendering @ , render entire page unstyled. after that, appears process scripts , stylesheets in order loaded, or rather executes scripts in order doesn't wait stylesheet load before executing loaded script. means page render 3 times (unformatted, 1 stylesheet, , 2 stylesheets) , script may infer inaccurate values element sizes.
can shed light on this? happening in webkit browsers i've tested, including chrome 17, mobile safari 5, , android browser 2.1. there way ensure html render ordering without resorting text/html
mime type?
webkit uses libxml2 handle xml, sends parsed xhtml webcore , javascriptcore css rendering , javascript execution.
stylesheet , script tags link what's called external entity in xml terminology. means processed last. xml spec says:
except when standalone="yes", must not process entity declarations or attribute-list declarations encountered after reference parameter entity not read, since entity may have contained overriding declarations; when standalone="yes", processors must process these declarations.
since standalone="yes"
specifies xml document should validated dtd, triggers different processing model.
link tags handled differently xml-stylesheet processing-instructions. xml stylesheet spec says:
any links style sheets specified externally document (e.g. link headers in versions of http [rfc2068]) considered create associations occur before associations specified xml-stylesheet processing instructions. application responsible taking associations , determining how, if @ all, order affects processing.
try commenting out script tags , converting link tags xml-stylesheet instructions. also, try adding standalone="yes" xml declaration:
<?xml version="1.0" encoding="utf-8" standalone="yes"?> <?xml-stylesheet href="foo.css"?>
in addition, use of special characters, entities, , xslt can further complicate picture, since processing model differs between html , xml dialect xhtml:
the range of allowed chars in xml defined xml spec, , range checked libxml2. not concern, unless parse example html parser , give preparsed tree libxml2 serialize back. hope you're not doing xslt xml language , must parsed xml parser.
Comments
Post a Comment