日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

WebKit Page对象的分析

發(fā)布時間:2024/4/15 编程问答 22 豆豆
生活随笔 收集整理的這篇文章主要介紹了 WebKit Page对象的分析 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

?Page對象是webkit的核心對象之一,顧名思義,Page數(shù)據(jù)結(jié)構(gòu)就是描述覽器上我們打開的一個頁面,這樣一個頁面包括很多部分,比如菜單控制,拖拽控制,頁面顯示,以及一些參數(shù)設(shè)置等。所以webkit中的Page對象里面也對應(yīng)很多這樣相關(guān)的對象,下面是一張表示這些對象關(guān)系的類圖。

?

從上圖中可以看出,Page里面主要是一些對象的組合,Page自身的代碼并不是很多,里面的對象根據(jù)名字大概能夠猜出個一二,下面主要講一下兩個比較重要的對象.

1. Frame

Frame應(yīng)該是webcore里面最重要的一個核心對象,從page的角度上來看,頁面就是有眾多的Frame構(gòu)成,當然,一定會有一個主Frame,Page中持有的這個Frame就是主Frame,也就是RootFrame,這個對象比較復(fù)雜,后面我會單獨拿出來分析。

2. chrome

chrome是與顯示相關(guān)的一個對象,比如刷新頁面窗口,滾動窗口等,就會用到chrome中的接口,chrome也是連接webcore與webkit(指webkit的port部分)的核心對象。下面是一個關(guān)于chrome的類圖

?

大家看到,chrome是繼承自HostWindow,就是表示一個宿主窗口,這里貼出HostWindow的代碼

[cpp]?view plaincopy
  • class?HostWindow?:?public?Noncopyable?{??
  • public:??
  • ????virtual?~HostWindow()?{?}??
  • ??
  • ????//?Requests?the?host?invalidate?the?window,?not?the?contents.??If?immediate?is?true?do?so?synchronously,?otherwise?async.??
  • ????virtual?void?invalidateWindow(const?IntRect&?updateRect,?bool?immediate)?=?0;??
  • ??
  • ????//?Requests?the?host?invalidate?the?contents?and?the?window.??If?immediate?is?true?do?so?synchronously,?otherwise?async.??
  • ????virtual?void?invalidateContentsAndWindow(const?IntRect&?updateRect,?bool?immediate)?=?0;??
  • ??
  • ????//?Requests?the?host?scroll?backingstore?by?the?specified?delta,?rect?to?scroll,?and?clip?rect.??
  • ????virtual?void?scroll(const?IntSize&?scrollDelta,?const?IntRect&?rectToScroll,?const?IntRect&?clipRect)?=?0;??
  • ??
  • ????//?Requests?the?host?invalidate?the?contents,?not?the?window.??This?is?the?slow?path?for?scrolling.??
  • ????virtual?void?invalidateContentsForSlowScroll(const?IntRect&?updateRect,?bool?immediate)?=?0;??
  • ??
  • #if?ENABLE(TILED_BACKING_STORE)??
  • ????//?Requests?the?host?to?do?the?actual?scrolling.?This?is?only?used?in?combination?with?a?tiled?backing?store.??
  • ????virtual?void?delegatedScrollRequested(const?IntSize&?scrollDelta)?=?0;??
  • #endif??
  • ??
  • ????//?Methods?for?doing?coordinate?conversions?to?and?from?screen?coordinates.??
  • ????virtual?IntPoint?screenToWindow(const?IntPoint&)?const?=?0;??
  • ????virtual?IntRect?windowToScreen(const?IntRect&)?const?=?0;??
  • ??
  • ????//?Method?for?retrieving?the?native?client?of?the?page.??
  • ????virtual?PlatformPageClient?platformPageClient()?const?=?0;??
  • ??????
  • ????//?To?notify?WebKit?of?scrollbar?mode?changes.??
  • ????virtual?void?scrollbarsModeDidChange()?const?=?0;??
  • ??
  • ????//?Request?that?the?cursor?change.??
  • ????virtual?void?setCursor(const?Cursor&)?=?0;??
  • };??
  • ?chrome中有一個ChromeClient,這個chromeClient都是由客戶實現(xiàn),這樣webcore就能夠和外面交互

    附chrome代碼

    [cpp:collapse]?+ expand sourceview plaincopy

    其實chrome的大部分功能都是委托給chromeclient實現(xiàn)。

    ?

    chrome中有一個接口名如下:

    Page* Chrome::createWindow(Frame* frame, const FrameLoadRequest& request, const WindowFeatures& features, const NavigationAction& action) ;

    其實就是創(chuàng)建一個新的窗口,那么在什么時候會用到此接口,比如打開一個新的標簽頁,這時候就需要創(chuàng)建一個新的窗口,所以,從這個角度來說,chromeclient就是為webcore里需要顯示的內(nèi)容提供一個場所,對需要涉及到的顯示操作,提供一種實現(xiàn)。

    WebChromeClient提供一種ChromeClient的實現(xiàn),而實際的窗口相關(guān)的操作,都會定義在webview里面,所以不同的平臺應(yīng)該有不同WebView的實現(xiàn)。

    總結(jié)

    以上是生活随笔為你收集整理的WebKit Page对象的分析的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

    如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。