DOM and Script
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.execute a script (honey js)
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
4.str in a ScriptSourceCode
ScriptSourceCode.(SourceCode m_code).(<SourceProvider> m_provider).(UString m_source).(<StringImpl> m_impl)
every sourcecode has a url
5. js's class hierarchy
MSVCBugWorkaround<--JSCell<--JSObject<--JSDOMWindowShell
JSObject<--JSVariableObject<--JSGlobalObject<--JSDOMGlobalObject<--JSDOMWindowBase<--JSDOMWindow