Android webkit image的加载过程解析
#############################################
本文为极度寒冰原创,转载请注明出处#############################################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对象 ....}