首页 > 代码库 > 浏览器应用开发常用知识

浏览器应用开发常用知识

1、浏览器生成默认UA

Android浏览器的UA的生成实在android.webview.WebSettingsClassic.getCurrentUserAgent()中,会根据Build.VERSION.RELEASE,Build.MODEL等来生成系统版本和机型等信息来组装生成UA

2、Android WebView打印dom树和render树

1、使用WebViewClassic.dumpDomTree(boolean toFile)、WebViewClassic.dumpRenderTree(boolean toFile)和WebViewClassic.dumpDisplayTree()
2、在Source/WebKit/android/AndroidLog.h中把ANDROID_DOM_LOGGING开关打开
3、调用WebViewClassic.fromWebView(webview).dumpDomTree(true)...
domTree.txt

*#document	0x77e3af80
	html	0x77b10650
	HTML	0x77e3c098
		HEAD	0x7816f850
		BODY	0x7816f8a8
			VIDEO	0x77e3b8b8
				#text	0x77afc0f8 "\nYour browser does not support the video tag.\n"

renderTree.txt

layer at (0,0) size 980x1325
  RenderView at (0,0) size 980x1325
layer at (0,0) size 980x220
  RenderBlock {HTML} at (0,0) size 980x220
    RenderBody {BODY} at (8,8) size 964x204
      RenderText {#text} at (0,0) size 0x0
layer at (8,8) size 320x200
  RenderVideo {VIDEO} at (0,0) size 320x200
layer at (8,8) size 320x200
  RenderBlock (relative positioned) {DIV} at (0,0) size 320x200
layer at (8,160) size 320x48
  RenderFlexibleBox (positioned) {DIV} at (0,152) size 320x48
    RenderButton {INPUT} at (0,0) size 48x48
    RenderFlexibleBox {DIV} at (48,0) size 224x48
      RenderSlider {INPUT} at (0,0) size 224x48
        RenderBlock {DIV} at (0,8) size 32x32
    RenderButton {INPUT} at (272,0) size 48x48


浏览器应用开发常用知识