#############################################
HTMLInputStream m_input; // We hold m_token here because it might be partially complete. HTMLToken m_token; OwnPtr<HTMLTokenizer> m_tokenizer; OwnPtr<HTMLScriptRunner> m_scriptRunner; OwnPtr<HTMLTreeBuilder> m_treeBuilder; OwnPtr<HTMLPreloadScanner> m_preloadScanner; OwnPtr<HTMLParserScheduler> m_parserScheduler; HTMLSourceTracker m_sourceTracker; HTMLConstructionSite& m_tree;
enum InsertionMode { InitialMode, BeforeHTMLMode, BeforeHeadMode, InHeadMode, InHeadNoscriptMode, AfterHeadMode, InBodyMode, TextMode, InTableMode, InTableTextMode, InCaptionMode, InColumnGroupMode, InTableBodyMode, InRowMode, InCellMode, InSelectMode, InSelectInTableMode, InForeignContentMode, AfterBodyMode, InFramesetMode, AfterFramesetMode, AfterAfterBodyMode, AfterAfterFramesetMode, };
void HTMLConstructionSite::insertHTMLElement(AtomicHTMLToken& token) { m_openElements.push(attachToCurrent(createHTMLElement(token))); }
PassRefPtr<HTMLElement> HTMLElementFactory::createHTMLElement(const QualifiedName& qName, Document* document, HTMLFormElement* formElement, bool createdByParser) { if (!document) return 0; if (!gFunctionMap) createFunctionMap(); if (ConstructorFunction function = gFunctionMap->get(qName.localName().impl())) return function(qName, document, formElement, createdByParser); return HTMLElement::create(qName, document); }
if (isWaitingForScripts()) { ASSERT(m_tokenizer->state() == HTMLTokenizer::DataState); if (!m_preloadScanner) { m_preloadScanner.set(new HTMLPreloadScanner(document())); m_preloadScanner->appendToEnd(m_input.current()); } m_preloadScanner->scan(); }
void HTMLPreloadScanner::scan() { // FIXME: We should save and re-use these tokens in HTMLDocumentParser if // the pending script doesn't end up calling document.write. while (m_tokenizer->nextToken(m_source, m_token)) { processToken(); m_token.clear(); } }
preload中的操作其实很简单: void preload(Document* document, bool scanningBody) { if (m_urlToLoad.isEmpty()) return; CachedResourceLoader* cachedResourceLoader = document->cachedResourceLoader(); if (m_tagName == scriptTag) cachedResourceLoader->preload(CachedResource::Script, m_urlToLoad, m_charset, scanningBody); else if (m_tagName == imgTag || (m_tagName == inputTag && m_inputIsImage)) cachedResourceLoader->preload(CachedResource::ImageResource, m_urlToLoad, String(), scanningBody); else if (m_tagName == linkTag && m_linkIsStyleSheet && m_linkMediaAttributeIsScreen) cachedResourceLoader->preload(CachedResource::CSSStyleSheet, m_urlToLoad, m_charset, scanningBody); }
E/external/webkit/Source/WebCore/loader/cache/CachedResourceLoader.cpp( 701): url = http://m.baidu.com/static/img/webapp/pkg/aio_729bf5aa.css E/external/webkit/Source/WebCore/loader/cache/CachedResourceLoader.cpp( 701): url = http://m.baidu.com/static/img/webapp/pkg/aio_1d339828.js
#0 WebCore::ImageLoader::updateFromElement (this=0x2acef4ec) at external/webkit/Source/WebCore/loader/ImageLoader.cpp:163 #1 0x48d2dc6c in WebCore::HTMLImageElement::parseMappedAttribute (this=0x2acef4b0, attr=0x2ab94720) at external/webkit/Source/WebCore/html/HTMLImageElement.cpp:108 #2 0x48efb706 in WebCore::StyledElement::attributeChanged (this=0x2acef4b0, attr=0x2ab94720, preserveDecls=<value optimized out>) at external/webkit/Source/WebCore/dom/StyledElement.cpp:187 #3 0x48ef0d4a in WebCore::Element::setAttributeMap (this=0x2acef4b0, list=<value optimized out>, scriptingPermission=<value optimized out>) at external/webkit/Source/WebCore/dom/Element.cpp:844 #4 0x48fc5f7a in WebCore::HTMLConstructionSite::createHTMLElement (this=0x2ab4b60c, token=...) at external/webkit/Source/WebCore/html/parser/HTMLConstructionSite.cpp:380 #5 0x48fc6476 in WebCore::HTMLConstructionSite::insertSelfClosingHTMLElement (this=0x2ab4b60c, token=<value optimized out>) at external/webkit/Source/WebCore/html/parser/HTMLConstructionSite.cpp:296 #6 0x48f2f908 in WebCore::HTMLTreeBuilder::processStartTagForInBody (this=0x2ab4b5f8, token=...) at external/webkit/Source/WebCore/html/parser/HTMLTreeBuilder.cpp:929 #7 0x48f30c5a in WebCore::HTMLTreeBuilder::processStartTag (this=0x2ab4b5f8, token=...) at external/webkit/Source/WebCore/html/parser/HTMLTreeBuilder.cpp:1335 #8 0x48f323d4 in WebCore::HTMLTreeBuilder::constructTreeFromAtomicToken (this=0x2ab4b5f8, token=<value optimized out>) at external/webkit/Source/WebCore/html/parser/HTMLTreeBuilder.cpp:461 #9 0x48f3250a in WebCore::HTMLTreeBuilder::constructTreeFromToken (this=0x2ab4b5f8, rawToken=...) at external/webkit/Source/WebCore/html/parser/HTMLTreeBuilder.cpp:451 #10 0x48f26aba in WebCore::HTMLDocumentParser::pumpTokenizer (this=0x2ab94770, mode=WebCore::HTMLDocumentParser::AllowYield) at external/webkit/Source/WebCore/html/parser/HTMLDocumentParser.cpp:276 #11 0x48f26b4e in WebCore::HTMLDocumentParser::resumeParsingAfterYield (this=0x2ab94770) at external/webkit/Source/WebCore/html/parser/HTMLDocumentParser.cpp:192
void ImageLoader::updateFromElement() { .... //重要:获取 src属性的值 AtomicString attr = client()->sourceElement()->getAttribute(client()->sourceElement()->imageSourceAttributeName()); ... // Do not load any image if the 'src' attribute is missing or if it is // an empty string. CachedResourceHandle<CachedImage> newImage = 0; if (!attr.isNull() && !stripLeadingAndTrailingHTMLSpaces(attr).isEmpty()) { //重要:根据url(attr的值),创建一个request,通过该request获取图片 CachedResourceRequest request(ResourceRequest(document()->completeURL(sourceURI(attr)))); request.setInitiator(client()->sourceElement()); ..... if (m_loadManually) { bool autoLoadOtherImages = document()->cachedResourceLoader()->autoLoadImages(); <strong> </strong>document()->cachedResourceLoader()->setAutoLoadImages(false); newImage = new CachedImage(request.resourceRequest()); //创建image对象 newImage->setLoading(true); newImage->setOwningCachedResourceLoader(document()->cachedResourceLoader()); document()->cachedResourceLoader()->m_documentResources.set(newImage->url(), newImage.get()); document()->cachedResourceLoader()->setAutoLoadImages(autoLoadOtherImages); } else newImage = document()->cachedResourceLoader()->requestImage(request); //直接获取一个cached的image对象 .... }