my webkit FAQ

本文探讨了WebKit渲染过程中的12个paint phase及其顺序,并介绍了如何通过内容处置头控制资源下载时机。此外,还深入分析了JavaScript对网页加载的影响,以及浏览器如何确定MIME类型。

转载请注明出处:http://blog.youkuaiyun.com/awebkit

1 paint phase

In RenderObject.h there are 12 phases of painting. Please explain what do these mean and in which sequence they are called. If there is some documentation already (either in code or on the website), please give me a link. Thank you.

enum PaintPhase {
    PaintPhaseBlockBackground,
    PaintPhaseChildBlockBackground,
    PaintPhaseChildBlockBackgrounds,
    PaintPhaseFloat,
    PaintPhaseForeground,
    PaintPhaseOutline,
    PaintPhaseChildOutlines,
    PaintPhaseSelfOutline,
    PaintPhaseSelection,
    PaintPhaseCollapsedTableBorders,
    PaintPhaseTextClip,
    PaintPhaseMask
};
You should look at the CSS specifications. That defines the order
of painting the various layers in each block stacking context. The code
in WebKit follows each of the layers in the stack with one render pass
for each of them.

       There is a good video somewhere that Eric Seidel describes the
rendering inside WebKit that covers this.

2. 何时下载
content-disposition
IE资料
http://support.microsoft.com/kb/260519


google 文档
http://code.google.com/p/browsersec/wiki/Part2#Downloads_and_Content-Disposition


3. js对网页的影响
   因为JS脚本的一些执行结果可能会在后续的HTML中使用,所以浏览器在遇到script标签的时候,一定会查找对应的结束标签,然后下载并执行JS。也就是说,JS的执行不是异步的,这样,会影响到后续标签的解析。
   当显式的在script标签中加了defer后,js是不会执行的,但是下载还是顺序的。
   webkit在解析script标签的时候,会走到HTMLTokenizer.cpp中的SearchEnd,在这里会processToken,然后到HTMLParser::parseToken,然后是Element类的Element::setAttributeMap,通知attributeChanged。在这里StyledElement就开始接管了。


4. MIME那些事
firefox关于MIME的介绍
https://developer.mozilla.org/en/how_mozilla_determines_mime_types

我们要重点关注一下MIME探测。
我们注意这句话

Any HTTP/1.1 message containing an entity-body SHOULD include a Content-Type header field defining the media type of that body. If and only if the media type is not given by a Content-Type field, the recipient MAY attempt to guess the media type via inspection of its content and/or the name extension(s) of the URI used to identify the resource.

不过我们还是需要探测,即使给了Content-Type

这里讲解的更加详细

http://kb.mozillazine.org/File_types_and_download_actions

我们看看IE 的MIME 探测
http://netsecurity.51cto.com/art/200902/112190.htm

5. 旧博客文章





评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值