webkit在win32下的編譯規則(八)

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_referenceshttp://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.htmhttp://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/)。

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章