webkit在win32下的编译规则(八)

来源:互联网 发布:iphone专业拍照软件 编辑:程序博客网 时间:2024/05/23 05:09

HTMLElementFactory.cpp和HTMLNames.cpp是由如下规则生成的:

ifdef HTML_FLAGS

HTMLElementFactory.cpp HTMLNames.cpp : dom/make_names.pl html/HTMLTagNames.in html/HTMLAttributeNames.in
    perl -I $(WebCore)/bindings/scripts $< --tags $(WebCore)/html/HTMLTagNames.in --attrs $(WebCore)/html/HTMLAttributeNames.in --factory --wrapperFactory --extraDefines "$(HTML_FLAGS)"

else

HTMLElementFactory.cpp HTMLNames.cpp : dom/make_names.pl html/HTMLTagNames.in html/HTMLAttributeNames.in
    perl -I $(WebCore)/bindings/scripts $< --tags $(WebCore)/html/HTMLTagNames.in --attrs $(WebCore)/html/HTMLAttributeNames.in --factory --wrapperFactory

endif

可以看出HTMLElementFactory.cpp和HTMLNames.cpp是由make_names.pl处理HTMLTagNames.in和HTMLAttributeNames.in生成的。HTMLTagNames.in(D:/tools/cygwin/home/xufan/WebKit/Source/WebCore/html/HTMLTagNames.in)定义了所有的html tag name,里面还有html tag对应webkit处理类的名字,例如a interfaceName=HTMLAnchorElement表明a标签是由HTMLAnchorElement这个类处理的。HTMLAttributeNames.in(D:/tools/cygwin/home/xufan/WebKit/Source/WebCore/html/HTMLAttributeNames.in )定义了所有的html Attribute name, 例如href,style,onclick等.

HTMLEntityTable.cpp是由如下规则生成:

HTMLEntityTable.cpp : html/parser/HTMLEntityNames.in $(WebCore)/html/parser/create-html-entity-table
    python $(WebCore)/html/parser/create-html-entity-table -o HTMLEntityTable.cpp $(WebCore)/html/parser/HTMLEntityNames.in

可以看出HTMLEntityTable.cpp是用create-html-entity-table(D:/tools/cygwin/home/xufan/WebKit/Source/WebCore/html/parser/create-html-entity-table)这个python脚本处理HTMLEntityNames.in(D:/tools/cygwin/home/xufan/WebKit/Source/WebCore/html/parser/HTMLEntityNames.in )生成的。html entity是什么东西呢?html entity的中文翻译一般为HTML 字符实体,指的是那些HTML 中拥有特殊的含义的字符,这些字符的显示就是用html entity表示的。字符实体有三部分:一个和号 (&),一个实体名称,或者 # 和一个实体编号,以及一个分号 (;),例如<(小于号)在html就要写< 或<。在HTMLEntityNames.in里面,小于号的表示为:"LT;","U+0003C" (3c的十进制值为60)。对于小于号和&等符号,最后的分号是可以去掉的,即<和&也是可以的,因为HTMLEntityNames.in对这种符号定义了两个,一个有分号,一个没分号。HTMLEntityNames.in里面还有一些不常用的html entry,例如·(显示为·)。关于html entry更详细的介绍可以参考http://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references和http://www.w3.org/TR/html4/sgml/entities.html。html entry可以做一些很有趣的事情,例如http://www.beijing-time.org/wannianli.htm(用ie打开)里面的世界地图,或者你建立一个网页,输入如下内容<FONT style="FONT-SIZE: 120pt; COLOR: green; FONT-FAMILY: Webdings">&ucirc;</FONT>,在浏览器打开就可以看见一个世界地图。

image

WMLElementFactory.cpp和WMLNames.cpp是由如下规则生成:

ifeq ($(findstring ENABLE_WML,$(FEATURE_DEFINES)), ENABLE_WML)

WMLElementFactory.cpp WMLNames.cpp : dom/make_names.pl wml/WMLTagNames.in wml/WMLAttributeNames.in
    perl -I $(WebCore)/bindings/scripts $< --tags $(WebCore)/wml/WMLTagNames.in --attrs $(WebCore)/wml/WMLAttributeNames.in --factory --wrapperFactory

else

WMLElementFactory.cpp :
    echo > $@

WMLNames.cpp :
    echo > $@

endif

从上面可以看出,WMLElementFactory.cpp和WMLNames.cpp只有在编译选项中包含ENABLE_WML才会有内容,否则就是一个空文件。ENABLE_WML在win32平台上默认是关闭的,因为pc上不会去访问WML网页。如果大家需要编译手机上的webkit浏览器,记得要将这个编译选项打开,否则编译出来的浏览器是无法浏览wap网站上面的网页。WMLTagNames.in (D:/tools/cygwin/home/xufan/WebKit/Source/WebCore/wml/WMLTagNames.in )和WMLAttributeNames.in(D:/tools/cygwin/home/xufan/WebKit/Source/WebCore/wml/WMLAttributeNames.in )的规则与HTMLTagNames.in和HTMLAttributeNames.in基本一样,只是标签和属性少了很多。

SVGElementFactory.cpp和SVGNames.cpp由如下规则生成:

ifdef SVG_FLAGS

SVGElementFactory.cpp SVGNames.cpp : dom/make_names.pl svg/svgtags.in svg/svgattrs.in
    perl -I $(WebCore)/bindings/scripts $< --tags $(WebCore)/svg/svgtags.in --attrs $(WebCore)/svg/svgattrs.in --extraDefines "$(SVG_FLAGS)" --factory --wrapperFactory
else

SVGElementFactory.cpp SVGNames.cpp : dom/make_names.pl svg/svgtags.in svg/svgattrs.in
    perl -I $(WebCore)/bindings/scripts $< --tags $(WebCore)/svg/svgtags.in --attrs $(WebCore)/svg/svgattrs.in --factory --wrapperFactory

endif

SVGElementFactory.cpp和SVGNames.cpp只有定义了SVG_FLAGS 才会生成,与WMLElementFactory.cpp和WMLNames.cpp等的处理差不多,都是调用make_names.pl(D:/tools/cygwin/home/xufan/WebKit/Source/WebCore/dom/make_names.pl)生成的。

UserAgentStyleSheets.h由如下规则生成:

USER_AGENT_STYLE_SHEETS = $(WebCore)/css/html.css $(WebCore)/css/quirks.css $(WebCore)/css/view-source.css $(WebCore)/css/themeWin.css $(WebCore)/css/themeWinQuirks.css

……………

UserAgentStyleSheets.h : css/make-css-file-arrays.pl $(USER_AGENT_STYLE_SHEETS)
    perl $< $@ UserAgentStyleSheetsData.cpp $(USER_AGENT_STYLE_SHEETS)

从上面可以看到,UserAgentStyleSheets.h由make-css-file-arrays.pl(D:/tools/cygwin/home/xufan/WebKit/Source/WebCore/css/make-css-file-arrays.pl )处理html.css,quirks.css,view-source.css等文件而产生。html.css(D:/tools/cygwin/home/xufan/WebKit/Source/WebCore/css/html.css)等文件里面定义了webkit的一些tag的默认css属性,例如下面的body,p和h1:

body {
    display: block;
    margin: 8px
}

p {
    display: block;
   -webkit-margin-before: 1__qem;
    -webkit-margin-after: 1__qem;
    -webkit-margin-start: 0;
    -webkit-margin-end: 0;
}

…………

h1 {
    display: block;
   font-size: 2em;
    -webkit-margin-before: 0.67__qem;
    -webkit-margin-after: 0.67em;
    -webkit-margin-start: 0;
    -webkit-margin-end: 0;
    font-weight: bold
}

我想大家看了上面的css,应该对浏览器的一些默认显示有所了解了吧。关于body margin的在各个浏览器上的默认值可以参考:http://shuaigg-babysky.javaeye.com/blog/865245,http://meiert.com/en/blog/20070922/user-agent-style-sheets/,http://css-class.com/test/css/defaults/UA-style-sheet-defaults.htm和http://www.iecss.com/。

XLinkNames.cpp由如下规则生成:

XLinkNames.cpp : dom/make_names.pl svg/xlinkattrs.in
    perl -I $(WebCore)/bindings/scripts $< --attrs $(WebCore)/svg/xlinkattrs.in

xlinkattrs.in里面定义了xlink里面的支持的属性。XLink 是 XML 链接语言(XML Linking Language)的缩写,用于在 XML 文档中创建超级链接的语言,其更加详细的介绍可以参考http://www.w3.org/TR/xlink/和http://www.w3school.com.cn/xlink/index.asp。webkit里面的xlink主要用于svg。

XMLNSNames.cpp由如下规则生成:

XMLNSNames.cpp : dom/make_names.pl xml/xmlnsattrs.in
    perl -I $(WebCore)/bindings/scripts $< --attrs $(WebCore)/xml/xmlnsattrs.in

xmlnsattrs.in里面定义了xml namsapce这个属性的名字:xmlns。

XMLNames.cpp由如下规则生成:

XMLNames.cpp : dom/make_names.pl xml/xmlattrs.in
    perl -I $(WebCore)/bindings/scripts $< --attrs $(WebCore)/xml/xmlattrs.in

xmlattrs.in里面定义了xml一些属性的名字:base,lang,space。


MathMLElementFactory.cpp和MathMLNames.cpp由如下规则生成:

MathMLElementFactory.cpp MathMLNames.cpp : dom/make_names.pl mathml/mathtags.in mathml/mathattrs.in
    perl -I $(WebCore)/bindings/scripts $< --tags $(WebCore)/mathml/mathtags.in --attrs $(WebCore)/mathml/mathattrs.in --factory –wrapperFactory

mathtags.in和mathattrs.in里面定义了用于MathML的标签名和属性。MathML‎(Mathematical Markup Language‎)即数学置标语言是一种基于XML的标准,用来在互联网上书写数学符号和公式的置标语言。MathML的介绍可以参考http://www.webkit.org/blog/1366/announcing%E2%80%A6mathml/和http://www.webkit.org/demos/mathml/MathMLDemo.xhtml。


XPathGrammar.cpp 由如下规则生成:

XPathGrammar.cpp : xml/XPathGrammar.y $(PROJECT_FILE)
    bison -d -p xpathyy $< -o $@
    touch XPathGrammar.cpp.h
    touch XPathGrammar.hpp
    echo '#ifndef XPathGrammar_h' > XPathGrammar.h
    echo '#define XPathGrammar_h' >> XPathGrammar.h
    cat XPathGrammar.cpp.h XPathGrammar.hpp >> XPathGrammar.h
    echo '#endif' >> XPathGrammar.h
    rm -f XPathGrammar.cpp.h XPathGrammar.hpp

从上可以看到,XPathGrammar.cpp是通过bison处理XPathGrammar.y生成的。从这里也可以看出,webkit对于有点规则的都在用bison等工具自动生成代码来处理,而不是从头开始写(可以将xpath理解成一种DSL)。不知道XPath是什么的可以自己去Google。


tokenizer.cpp 由如下规则生成:

tokenizer.cpp : css/tokenizer.flex css/maketokenizer
    flex -t $< | perl $(WebCore)/css/maketokenizer > $@

tokenizer.cpp由flex 处理D:/tools/cygwin/home/xufan/WebKit/Source/WebCore/css/tokenizer.flex这个文件,然后在调用D:/tools/cygwin/home/xufan/WebKit/Source/WebCore/css/maketokenizer这个perl脚本做后续处理。又来一种工具:flex ,看来维护webkit还真得学不少工具和语言啊。这里的flex不是adobe的,而是linux上的一个Lexical Analyzer,主页在http://flex.sourceforge.net/。tokenizer.flex定义了css的词法规则。

在DerivedSources.make里面,有一个技巧是用gcc -E选项展开宏和做预处理:

ifeq ($(shell gcc -E -P -dM $(FRAMEWORK_FLAGS) WebCore/ForwardingHeaders/wtf/Platform.h | grep ENABLE_DASHBOARD_SUPPORT | cut -d' ' -f3), 1)
    ENABLE_DASHBOARD_SUPPORT = 1
else
    ENABLE_DASHBOARD_SUPPORT = 0
endif

gcc的命令选项可以参考:http://gcc.gnu.org/onlinedocs/gcc-3.4.4/gcc/Overall-Options.html#Overall-Options,-E的解释如下:

 

-E       Stop after the preprocessing stage; do not run the compiler proper. The output is in the form of preprocessed source code, which is sent to the standard output.

 

Input files which don't require preprocessing are ignored.

至此,WebCoreGenerated里面的规则已基本介绍完了,NMake后面的的一些步骤基本是拷贝文件,就不介绍了。

顺便提一下,有一个blog:http://blog.csdn.net/wzm012/category/717768.aspx也在介绍webkit,大家可以去看一下,blog的作者好像在研究owb(http://strohmayer.org/owb/)。