OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
4 * Copyright (C) 2004, 2005, 2006, 2007, 2009, 2010 Apple Inc. All rights reserv
ed. | 4 * Copyright (C) 2004, 2005, 2006, 2007, 2009, 2010 Apple Inc. All rights reserv
ed. |
5 * | 5 * |
6 * This library is free software; you can redistribute it and/or | 6 * This library is free software; you can redistribute it and/or |
7 * modify it under the terms of the GNU Library General Public | 7 * modify it under the terms of the GNU Library General Public |
8 * License as published by the Free Software Foundation; either | 8 * License as published by the Free Software Foundation; either |
9 * version 2 of the License, or (at your option) any later version. | 9 * version 2 of the License, or (at your option) any later version. |
10 * | 10 * |
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
265 newImage = document.fetcher()->fetchImage(request); | 265 newImage = document.fetcher()->fetchImage(request); |
266 | 266 |
267 if (!newImage && !pageIsBeingDismissed(&document)) | 267 if (!newImage && !pageIsBeingDismissed(&document)) |
268 crossSiteOrCSPViolationOccured(imageSourceURL); | 268 crossSiteOrCSPViolationOccured(imageSourceURL); |
269 else | 269 else |
270 clearFailedLoadURL(); | 270 clearFailedLoadURL(); |
271 } else if (!imageSourceURL.isNull()) { | 271 } else if (!imageSourceURL.isNull()) { |
272 // Fire an error event if the url string is not empty, but the KURL is. | 272 // Fire an error event if the url string is not empty, but the KURL is. |
273 m_hasPendingErrorEvent = true; | 273 m_hasPendingErrorEvent = true; |
274 errorEventSender().dispatchEventSoon(this); | 274 errorEventSender().dispatchEventSoon(this); |
| 275 } else { |
| 276 noImageResourceToLoad(); |
275 } | 277 } |
276 | 278 |
| 279 |
277 ImageResource* oldImage = m_image.get(); | 280 ImageResource* oldImage = m_image.get(); |
278 if (newImage != oldImage) { | 281 if (newImage != oldImage) { |
279 sourceImageChanged(); | 282 sourceImageChanged(); |
280 | 283 |
281 if (m_hasPendingLoadEvent) { | 284 if (m_hasPendingLoadEvent) { |
282 loadEventSender().cancelEvent(this); | 285 loadEventSender().cancelEvent(this); |
283 m_hasPendingLoadEvent = false; | 286 m_hasPendingLoadEvent = false; |
284 } | 287 } |
285 | 288 |
286 // Cancel error events that belong to the previous load, which is now ca
ncelled by changing the src attribute. | 289 // Cancel error events that belong to the previous load, which is now ca
ncelled by changing the src attribute. |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
327 return; | 330 return; |
328 | 331 |
329 // If we have a pending task, we have to clear it -- either we're | 332 // If we have a pending task, we have to clear it -- either we're |
330 // now loading immediately, or we need to reset the task's state. | 333 // now loading immediately, or we need to reset the task's state. |
331 if (m_pendingTask) { | 334 if (m_pendingTask) { |
332 m_pendingTask->clearLoader(); | 335 m_pendingTask->clearLoader(); |
333 m_pendingTask.clear(); | 336 m_pendingTask.clear(); |
334 } | 337 } |
335 | 338 |
336 KURL url = imageSourceToKURL(imageSourceURL); | 339 KURL url = imageSourceToKURL(imageSourceURL); |
337 if (imageSourceURL.isNull() || url.isNull() || shouldLoadImmediately(url, lo
adType)) { | 340 if ((!imageSourceURL.isNull() && url.isNull()) || shouldLoadImmediately(url,
loadType)) { |
338 doUpdateFromElement(DoNotBypassMainWorldCSP, updateBehavior); | 341 doUpdateFromElement(DoNotBypassMainWorldCSP, updateBehavior); |
339 return; | 342 return; |
340 } | 343 } |
341 enqueueImageLoadingMicroTask(updateBehavior); | 344 enqueueImageLoadingMicroTask(updateBehavior); |
342 } | 345 } |
343 | 346 |
344 KURL ImageLoader::imageSourceToKURL(AtomicString imageSourceURL) const | 347 KURL ImageLoader::imageSourceToKURL(AtomicString imageSourceURL) const |
345 { | 348 { |
346 KURL url; | 349 KURL url; |
347 | 350 |
348 // Don't load images for inactive documents. We don't want to slow down the | 351 // Don't load images for inactive documents. We don't want to slow down the |
349 // raw HTML parsing case by loading images we don't intend to display. | 352 // raw HTML parsing case by loading images we don't intend to display. |
350 Document& document = m_element->document(); | 353 Document& document = m_element->document(); |
351 if (!document.isActive()) | 354 if (!document.isActive()) |
352 return url; | 355 return url; |
353 | 356 |
354 // Do not load any image if the 'src' attribute is missing or if it is | 357 // Do not load any image if the 'src' attribute is missing or if it is |
355 // an empty string. | 358 // an empty string. |
356 if (!imageSourceURL.isNull() && !stripLeadingAndTrailingHTMLSpaces(imageSour
ceURL).isEmpty()) | 359 if (!imageSourceURL.isNull() && !stripLeadingAndTrailingHTMLSpaces(imageSour
ceURL).isEmpty()) |
357 url = document.completeURL(sourceURI(imageSourceURL)); | 360 url = document.completeURL(sourceURI(imageSourceURL)); |
358 return url; | 361 return url; |
359 } | 362 } |
360 | 363 |
361 bool ImageLoader::shouldLoadImmediately(const KURL& url, LoadType loadType) cons
t | 364 bool ImageLoader::shouldLoadImmediately(const KURL& url, LoadType loadType) cons
t |
362 { | 365 { |
363 return (m_loadingImageDocument | 366 return (m_loadingImageDocument |
364 || isHTMLObjectElement(m_element) | 367 || isHTMLObjectElement(m_element) |
365 || isHTMLEmbedElement(m_element) | 368 || isHTMLEmbedElement(m_element) |
366 || url.protocolIsData() | 369 || url.protocolIsData() |
367 || memoryCache()->resourceForURL(url) | 370 || !element()->document().frame() |
| 371 || (!url.isNull() && memoryCache()->resourceForURL(url)) |
368 || loadType == ForceLoadImmediately); | 372 || loadType == ForceLoadImmediately); |
369 } | 373 } |
370 | 374 |
371 void ImageLoader::notifyFinished(Resource* resource) | 375 void ImageLoader::notifyFinished(Resource* resource) |
372 { | 376 { |
373 WTF_LOG(Timers, "ImageLoader::notifyFinished %p; m_hasPendingLoadEvent=%d", | 377 WTF_LOG(Timers, "ImageLoader::notifyFinished %p; m_hasPendingLoadEvent=%d", |
374 this, m_hasPendingLoadEvent); | 378 this, m_hasPendingLoadEvent); |
375 | 379 |
376 ASSERT(m_failedLoadURL.isEmpty()); | 380 ASSERT(m_failedLoadURL.isEmpty()); |
377 ASSERT(resource == m_image.get()); | 381 ASSERT(resource == m_image.get()); |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
571 } | 575 } |
572 | 576 |
573 #if ENABLE(OILPAN) | 577 #if ENABLE(OILPAN) |
574 ImageLoader::ImageLoaderClientRemover::~ImageLoaderClientRemover() | 578 ImageLoader::ImageLoaderClientRemover::~ImageLoaderClientRemover() |
575 { | 579 { |
576 m_loader.willRemoveClient(m_client); | 580 m_loader.willRemoveClient(m_client); |
577 } | 581 } |
578 #endif | 582 #endif |
579 | 583 |
580 } | 584 } |
OLD | NEW |