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 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
260 newImage = document.fetcher()->fetchImage(request); | 260 newImage = document.fetcher()->fetchImage(request); |
261 | 261 |
262 if (!newImage && !pageIsBeingDismissed(&document)) | 262 if (!newImage && !pageIsBeingDismissed(&document)) |
263 crossSiteOrCSPViolationOccured(imageSourceURL); | 263 crossSiteOrCSPViolationOccured(imageSourceURL); |
264 else | 264 else |
265 clearFailedLoadURL(); | 265 clearFailedLoadURL(); |
266 } else if (!imageSourceURL.isNull()) { | 266 } else if (!imageSourceURL.isNull()) { |
267 // Fire an error event if the url string is not empty, but the KURL is. | 267 // Fire an error event if the url string is not empty, but the KURL is. |
268 m_hasPendingErrorEvent = true; | 268 m_hasPendingErrorEvent = true; |
269 errorEventSender().dispatchEventSoon(this); | 269 errorEventSender().dispatchEventSoon(this); |
270 } else { | |
271 noImageResourceToLoad(); | |
270 } | 272 } |
271 | 273 |
274 | |
272 ImageResource* oldImage = m_image.get(); | 275 ImageResource* oldImage = m_image.get(); |
273 if (newImage != oldImage) { | 276 if (newImage != oldImage) { |
274 sourceImageChanged(); | 277 sourceImageChanged(); |
275 | 278 |
276 if (m_hasPendingLoadEvent) { | 279 if (m_hasPendingLoadEvent) { |
277 loadEventSender().cancelEvent(this); | 280 loadEventSender().cancelEvent(this); |
278 m_hasPendingLoadEvent = false; | 281 m_hasPendingLoadEvent = false; |
279 } | 282 } |
280 | 283 |
281 // Cancel error events that belong to the previous load, which is now ca ncelled by changing the src attribute. | 284 // 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... | |
322 return; | 325 return; |
323 | 326 |
324 // If we have a pending task, we have to clear it -- either we're | 327 // If we have a pending task, we have to clear it -- either we're |
325 // now loading immediately, or we need to reset the task's state. | 328 // now loading immediately, or we need to reset the task's state. |
326 if (m_pendingTask) { | 329 if (m_pendingTask) { |
327 m_pendingTask->clearLoader(); | 330 m_pendingTask->clearLoader(); |
328 m_pendingTask.clear(); | 331 m_pendingTask.clear(); |
329 } | 332 } |
330 | 333 |
331 KURL url = imageSourceToKURL(imageSourceURL); | 334 KURL url = imageSourceToKURL(imageSourceURL); |
332 if (imageSourceURL.isNull() || url.isNull() || shouldLoadImmediately(url, lo adType)) { | 335 if ((!imageSourceURL.isNull() && url.isNull()) || shouldLoadImmediately(url, loadType)) { |
esprehn
2014/09/05 00:47:52
Why did you change this?
rhogan
2014/09/08 19:52:42
This allows images with no src="" to go through th
| |
333 doUpdateFromElement(DoNotBypassMainWorldCSP, updateBehavior); | 336 doUpdateFromElement(DoNotBypassMainWorldCSP, updateBehavior); |
334 return; | 337 return; |
335 } | 338 } |
336 enqueueImageLoadingMicroTask(updateBehavior); | 339 enqueueImageLoadingMicroTask(updateBehavior); |
337 } | 340 } |
338 | 341 |
339 KURL ImageLoader::imageSourceToKURL(AtomicString imageSourceURL) const | 342 KURL ImageLoader::imageSourceToKURL(AtomicString imageSourceURL) const |
340 { | 343 { |
341 KURL url; | 344 KURL url; |
342 | 345 |
343 // Don't load images for inactive documents. We don't want to slow down the | 346 // Don't load images for inactive documents. We don't want to slow down the |
344 // raw HTML parsing case by loading images we don't intend to display. | 347 // raw HTML parsing case by loading images we don't intend to display. |
345 Document& document = m_element->document(); | 348 Document& document = m_element->document(); |
346 if (!document.isActive()) | 349 if (!document.isActive()) |
347 return url; | 350 return url; |
348 | 351 |
349 // Do not load any image if the 'src' attribute is missing or if it is | 352 // Do not load any image if the 'src' attribute is missing or if it is |
350 // an empty string. | 353 // an empty string. |
351 if (!imageSourceURL.isNull() && !stripLeadingAndTrailingHTMLSpaces(imageSour ceURL).isEmpty()) | 354 if (!imageSourceURL.isNull() && !stripLeadingAndTrailingHTMLSpaces(imageSour ceURL).isEmpty()) |
352 url = document.completeURL(sourceURI(imageSourceURL)); | 355 url = document.completeURL(sourceURI(imageSourceURL)); |
353 return url; | 356 return url; |
354 } | 357 } |
355 | 358 |
356 bool ImageLoader::shouldLoadImmediately(const KURL& url, LoadType loadType) cons t | 359 bool ImageLoader::shouldLoadImmediately(const KURL& url, LoadType loadType) cons t |
357 { | 360 { |
358 return (m_loadingImageDocument | 361 return (m_loadingImageDocument |
359 || isHTMLObjectElement(m_element) | 362 || isHTMLObjectElement(m_element) |
360 || isHTMLEmbedElement(m_element) | 363 || isHTMLEmbedElement(m_element) |
361 || url.protocolIsData() | 364 || url.protocolIsData() |
362 || memoryCache()->resourceForURL(url) | 365 || !element()->document().frame() |
esprehn
2014/09/05 00:47:52
What are you checking here? I think you mean docum
rhogan
2014/09/08 19:52:43
When creating the MicroTask there's an ASSERT(load
| |
366 || (!url.isNull() && memoryCache()->resourceForURL(url)) | |
363 || loadType == ForceLoadImmediately); | 367 || loadType == ForceLoadImmediately); |
364 } | 368 } |
365 | 369 |
366 void ImageLoader::notifyFinished(Resource* resource) | 370 void ImageLoader::notifyFinished(Resource* resource) |
367 { | 371 { |
368 WTF_LOG(Timers, "ImageLoader::notifyFinished %p; m_hasPendingLoadEvent=%d", | 372 WTF_LOG(Timers, "ImageLoader::notifyFinished %p; m_hasPendingLoadEvent=%d", |
369 this, m_hasPendingLoadEvent); | 373 this, m_hasPendingLoadEvent); |
370 | 374 |
371 ASSERT(m_failedLoadURL.isEmpty()); | 375 ASSERT(m_failedLoadURL.isEmpty()); |
372 ASSERT(resource == m_image.get()); | 376 ASSERT(resource == m_image.get()); |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
566 } | 570 } |
567 | 571 |
568 #if ENABLE(OILPAN) | 572 #if ENABLE(OILPAN) |
569 ImageLoader::ImageLoaderClientRemover::~ImageLoaderClientRemover() | 573 ImageLoader::ImageLoaderClientRemover::~ImageLoaderClientRemover() |
570 { | 574 { |
571 m_loader.willRemoveClient(m_client); | 575 m_loader.willRemoveClient(m_client); |
572 } | 576 } |
573 #endif | 577 #endif |
574 | 578 |
575 } | 579 } |
OLD | NEW |