Webkit create frame and loadurl

来源:互联网 发布:图像平滑算法matlab 编辑:程序博客网 时间:2024/06/08 13:05



1. Creating Frame

in android, it begins in "WebCoreFrameBridge.cpp",CreateFrame()

static void CreateFrame(JNIEnv* env, jobject obj, jobject javaview,             jobject jAssetManager, jobject historyList)

it create many important classes for the browser,  in time order:

Page WebFrame FrameLoaderClientAndroid FrameWebViewCore FrameView andWebFrameView

blue color ones are classes for android only. black are common class for webkit.


one most class is Frame:

below is the diagram for Frame and the class created by it.

FrameloaderClient(created in the same function as frame)

Frame

|--FrameLoader(init, raw pointer, create in the constructor list)

           |--DocumentLoader  (RefPtr, assign by function)

                     |--MainResourceLoader (RefPtr ,startLoadingMainResource)

                     |--DocumentWriter(raw pointer, in the constructor list)

                               |--Document (passref begin, createDocument, return a document)


2. printf  KURL 

    KURL is the class used in webkit to present url.

    If we want to log the content of KURL, we should use code like this:

   LOG(Loading," url %s",url.string().utf8().data());
    

    Detail implement is below:

    a KURL is defined in WebCore/Platform/KURL.h, it has a member function string().

    b KURL.string(), return a class of String, which was defined in wtf/text/WTFString.h, it has a member function utf8()

    c String.utf8() return a class of CString , which was defined in wtf/text/CString.h, it has a member function data().

    d CString.data() return the type of char* , which can be printed directly.



3 LoadUrl

LoadProcess

FrameLoader->DocumentLoader->ResourceLoader->ResourceHandle(ResouceHanderInternal)->ResourceLoaderAndroid(WebUrlLoader)

->WebUrlLoaderClient->WebRequest(chromium's callback)


a.WebView.java 

loadUrl

b.WebViewCore.java

loadUrl

c.BrowserFrame.java 

loadUrl

nativeLoadUrl

d.WebCoreFrameBridge.cpp

LoadUrl

--pFrame->loader()->load(request, false);

e.FrameLoader

load(const ResourceRequest& request, bool lockHistory)

----FrameLoaderClient->createDocumentLoader()

load(DocumentLoader* newDocumentLoader)

----addExtraFieldsToMainResourceRequest

----loadWithDocumentLoader

callContinueLoadAfterNavigationPolicy()

continueLoadAfterWillSubmitForm()

f. DocumentLoader

startLoadingMainResource

g.MainResourceLoader

load

loadNow.

h.ResourceHandle

create

i.ResourceHandleAndroid.cpp

start

j.ResourceLoaderAndroid

start

k.WebUrlLoader

start

l.WebUrlLoaderClient

start.

......

to chromium stack.

also another imporant classes

ResourceRequest and ResourceResonse



 browser

from click to tab

TitleBarXlarge->onClick
TitleBarBase->onAction
Controller->handleNewIntent
IntentHandler->onNewIntent
Controller->openTabAndShow



from loadurl to network (apache stack)

a.WebView.java 

loadUrl

b.WebViewCore.java

loadUrl

c.BrowserFrame.java 

loadUrl

nativeLoadUrl

d.WebCoreFrameBridge.cpp

LoadUrl

--pFrame->loader()->load(request, false);

e.FrameLoader

load(const ResourceRequest& request, bool lockHistory)

----FrameLoaderClient->createDocumentLoader()

load(DocumentLoader* newDocumentLoader)

----addExtraFieldsToMainResourceRequest

----loadWithDocumentLoader

callContinueLoadAfterNavigationPolicy()

continueLoadAfterWillSubmitForm()

f. DocumentLoader

startLoadingMainResource

g.MainResourceLoader

load

loadNow.

h.ResourceHandle

create

i.ResourceHandleAndroid.cpp

start

j.ResourceLoaderAndroid

// from now same as chromium stack.

h. ResourceLoaderAndroid::start

i.WebCoreFrameBridge.startLoadingResource

j.BrowserFrame.java startLoadingResource

k.FrameLoader.java executeLoad

for local file

handleLocalFile.