现在的位置: 首页 > 综合 > 正文

DOM and Script

2014年03月27日 ⁄ 综合 ⁄ 共 3907字 ⁄ 字号 评论关闭

script

1.DOM object in js
Windows object, the biggest object.
Screen,Navigaor,Location,History
2.document.frames[0]
document.frames[1]
return the frame of the Document.

(to be continued)

webkit

1.HTMLDocumentPareser's membership

OwnPtr<HTMLTokenizer> m_tokenizer;
OwnPtr<HTMLScriptRunner> m_scriptRunner;
OwnPtr<HTMLTreeBuilder> m_treeBuilder;
OwnPtr<HTMLPreloadScanner> m_preloadScanner;
OwnPtr<HTMLParserScheduler> m_parserScheduler;
2.Script Parese call stack
a.HTMLDocumentParser::runScriptsForPausedTreeBuilder
b.HTMLScriptRunner::execute
c.HTMLScriptRunner::runScript
d.ScriptElement::executeScript
e.ScriptController::executeScript
3.Frame has a ScriptController
Frame will pass itself to the ScriptController.

//current it will be js or V8.

2.construct a ScriptSourceCode
DocumentWriter::end()
DocumentWriter::endIfNotLoadingMainResource()
DocumentWriter::addData
DecodedDataDocumentParser::appendBytes
HTMLDocumentParser::append()
HTMLDocumentParser::pumpTokenizerIfPossible()
HTMLDocumentParser::pumpTokenizer
HTMLDocumentParser::runScriptsForPausedTreeBuilder()
HTMLScriptRunner::execute
HTMLScriptRunner::runScript
ScriptSourceCode::ScriptSourceCode

3.str in a ScriptSourceCode
ScriptSourceCode.(SourceCode m_code).(<SourceProvider> m_provider).(UString m_source).(<StringImpl> m_impl)
every sourcecode has a url

4. js's classes

MSVCBugWorkaround<--JSCell<--JSObject<--JSDOMWindowShell
JSObject<--JSVariableObject<--JSGlobalObject<--JSDOMGlobalObject<--JSDOMWindowBase<--JSDOMWindow

3.execute a script (honey js)

1)From DocumentParser to JS Engine
a.HTMLDocumentParser::runScriptsForPausedTreeBuilder
b.HTMLScriptRunner::execute
c.HTMLScriptRunner::runScript
d.ScriptElement::executeScript
e.ScriptController::executeScript(ScriptControllerBase.cpp)
f.ScriptController::evaluate
g.ScriptController::evaluateInWorld
in this
JSDOMWindowShell* shell = windowShell(world);
ExecState* exec = shell->window()->globalExec(); (ExecState was defined in CallFrame.h)
h.JSMainThreadExecState::evaluate
i.JSC::Completion evaluate (JSMainThreadExecState.h)
j.JSC::evaluate (Completion.cpp)
k.Interpreter::execute

.... to js engine

2)js engine return to DOM

take "document.write("abc")" for example

a. ....js engine ...

b.jsHTMLDocumentPrototypeFunctionWrite (JSHTMLDocument.cpp)

c.JSHTMLDocument::write(JSHTMLDocumentCustom.cpp)

d.documentWrite.write(JSHTMLDocumentCustom.cpp)

e.Document::write

3)external script's request process

jsNodePrototypeFunctionAppendChild(JSC::ExecState * exec=0x065400e8)
JSNode::appendChild(JSC::ExecState * exec=0x065400e8)  
Node::appendChild(WTF::PassRefPtr<WebCore::Node> newChild={...}, int & ec=0, bool shouldLazyAttach=true)
ContainerNode::appendChild(WTF::PassRefPtr<WebCore::Node> newChild={...}, int & ec=0, bool shouldLazyAttach=true)
notifyChildInserted(WebCore::Node * child=0x08b91cd8) 
HTMLScriptElement::insertedIntoDocument()
ScriptElement::insertedIntoDocument()
ScriptElement::prepareScript(const WTF::TextPosition<WTF::OneBasedNumber> & scriptStartPosition={...}, ScriptElement::LegacyTypeSupport supportLegacyTypes=DisallowLegacyTypeInTypeAttribute) 
ScriptElement::requestScript(const WTF::String & sourceUrl={...})

4) external script's notify process

jsNodePrototypeFunctionAppendChild(JSC::ExecState * exec=0x065400e8)
JSNode::appendChild(JSC::ExecState * exec=0x065400e8) 
Node::appendChild(WTF::PassRefPtr<WebCore::Node> newChild={...}, int & ec=0, bool shouldLazyAttach=true) 
ContainerNode::appendChild(WTF::PassRefPtr<WebCore::Node> newChild={...}, int & ec=0, bool shouldLazyAttach=true)
notifyChildInserted(WebCore::Node * child=0x08b91cd8)
HTMLScriptElement::insertedIntoDocument()
ScriptElement::insertedIntoDocument()
ScriptElement::prepareScript(const WTF::TextPosition<WTF::OneBasedNumber> & scriptStartPosition={...}, 
LegacyTypeSupport supportLegacyTypes=DisallowLegacyTypeInTypeAttribute)
CachedResource::addClient(WebCore::CachedResourceClient * client=0x08b91d1c)
CachedScript::didAddClient(WebCore::CachedResourceClient * c=0x08b91d1c)
CachedResource::didAddClient(WebCore::CachedResourceClient * c=0x08b91d1c)
ScriptElement::notifyFinished(WebCore::CachedResource * o=0x069f8ac0)

抱歉!评论已关闭.