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 | 4 * Copyright (C) 2004, 2005, 2006, 2007, 2009, 2010 Apple Inc. All rights |
5 * reserved. | 5 * reserved. |
6 * | 6 * |
7 * This library is free software; you can redistribute it and/or | 7 * This library is free software; you can redistribute it and/or |
8 * modify it under the terms of the GNU Library General Public | 8 * modify it under the terms of the GNU Library General Public |
9 * License as published by the Free Software Foundation; either | 9 * License as published by the Free Software Foundation; either |
10 * version 2 of the License, or (at your option) any later version. | 10 * version 2 of the License, or (at your option) any later version. |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 element_is_protected_(false), | 164 element_is_protected_(false), |
165 suppress_error_events_(false) { | 165 suppress_error_events_(false) { |
166 RESOURCE_LOADING_DVLOG(1) << "new ImageLoader " << this; | 166 RESOURCE_LOADING_DVLOG(1) << "new ImageLoader " << this; |
167 } | 167 } |
168 | 168 |
169 ImageLoader::~ImageLoader() {} | 169 ImageLoader::~ImageLoader() {} |
170 | 170 |
171 void ImageLoader::Dispose() { | 171 void ImageLoader::Dispose() { |
172 RESOURCE_LOADING_DVLOG(1) | 172 RESOURCE_LOADING_DVLOG(1) |
173 << "~ImageLoader " << this | 173 << "~ImageLoader " << this |
174 << "; m_hasPendingLoadEvent=" << has_pending_load_event_ | 174 << "; has_pending_load_event_=" << has_pending_load_event_ |
175 << ", m_hasPendingErrorEvent=" << has_pending_error_event_; | 175 << ", has_pending_error_event_=" << has_pending_error_event_; |
176 | 176 |
177 if (image_) { | 177 if (image_) { |
178 image_->RemoveObserver(this); | 178 image_->RemoveObserver(this); |
179 image_ = nullptr; | 179 image_ = nullptr; |
180 } | 180 } |
181 } | 181 } |
182 | 182 |
183 DEFINE_TRACE(ImageLoader) { | 183 DEFINE_TRACE(ImageLoader) { |
184 visitor->Trace(image_); | 184 visitor->Trace(image_); |
185 visitor->Trace(image_resource_for_image_document_); | 185 visitor->Trace(image_resource_for_image_document_); |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
272 UpdateFromElementBehavior update_behavior, | 272 UpdateFromElementBehavior update_behavior, |
273 const KURL& url, | 273 const KURL& url, |
274 ReferrerPolicy referrer_policy) { | 274 ReferrerPolicy referrer_policy) { |
275 // FIXME: According to | 275 // FIXME: According to |
276 // http://www.whatwg.org/specs/web-apps/current-work/multipage/embedded-conten
t.html#the-img-element:the-img-element-55 | 276 // http://www.whatwg.org/specs/web-apps/current-work/multipage/embedded-conten
t.html#the-img-element:the-img-element-55 |
277 // When "update image" is called due to environment changes and the load | 277 // When "update image" is called due to environment changes and the load |
278 // fails, onerror should not be called. That is currently not the case. | 278 // fails, onerror should not be called. That is currently not the case. |
279 // | 279 // |
280 // We don't need to call clearLoader here: Either we were called from the | 280 // We don't need to call clearLoader here: Either we were called from the |
281 // task, or our caller updateFromElement cleared the task's loader (and set | 281 // task, or our caller updateFromElement cleared the task's loader (and set |
282 // m_pendingTask to null). | 282 // pending_task_ to null). |
283 pending_task_.reset(); | 283 pending_task_.reset(); |
284 // Make sure to only decrement the count when we exit this function | 284 // Make sure to only decrement the count when we exit this function |
285 std::unique_ptr<IncrementLoadEventDelayCount> load_delay_counter; | 285 std::unique_ptr<IncrementLoadEventDelayCount> load_delay_counter; |
286 load_delay_counter.swap(load_delay_counter_); | 286 load_delay_counter.swap(load_delay_counter_); |
287 | 287 |
288 Document& document = element_->GetDocument(); | 288 Document& document = element_->GetDocument(); |
289 if (!document.IsActive()) | 289 if (!document.IsActive()) |
290 return; | 290 return; |
291 | 291 |
292 AtomicString image_source_url = element_->ImageSourceURL(); | 292 AtomicString image_source_url = element_->ImageSourceURL(); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
340 element_->GetLayoutObject()->IsImage() && new_image == old_image) { | 340 element_->GetLayoutObject()->IsImage() && new_image == old_image) { |
341 ToLayoutImage(element_->GetLayoutObject())->IntrinsicSizeChanged(); | 341 ToLayoutImage(element_->GetLayoutObject())->IntrinsicSizeChanged(); |
342 } else { | 342 } else { |
343 if (has_pending_load_event_) { | 343 if (has_pending_load_event_) { |
344 LoadEventSender().CancelEvent(this); | 344 LoadEventSender().CancelEvent(this); |
345 has_pending_load_event_ = false; | 345 has_pending_load_event_ = false; |
346 } | 346 } |
347 | 347 |
348 // Cancel error events that belong to the previous load, which is now | 348 // Cancel error events that belong to the previous load, which is now |
349 // cancelled by changing the src attribute. If newImage is null and | 349 // cancelled by changing the src attribute. If newImage is null and |
350 // m_hasPendingErrorEvent is true, we know the error event has been just | 350 // has_pending_error_event_ is true, we know the error event has been just |
351 // posted by this load and we should not cancel the event. | 351 // posted by this load and we should not cancel the event. |
352 // FIXME: If both previous load and this one got blocked with an error, we | 352 // FIXME: If both previous load and this one got blocked with an error, we |
353 // can receive one error event instead of two. | 353 // can receive one error event instead of two. |
354 if (has_pending_error_event_ && new_image) { | 354 if (has_pending_error_event_ && new_image) { |
355 ErrorEventSender().CancelEvent(this); | 355 ErrorEventSender().CancelEvent(this); |
356 has_pending_error_event_ = false; | 356 has_pending_error_event_ = false; |
357 } | 357 } |
358 | 358 |
359 image_ = new_image; | 359 image_ = new_image; |
360 has_pending_load_event_ = new_image; | 360 has_pending_load_event_ = new_image; |
(...skipping 27 matching lines...) Expand all Loading... |
388 | 388 |
389 if (update_behavior == kUpdateIgnorePreviousError) | 389 if (update_behavior == kUpdateIgnorePreviousError) |
390 ClearFailedLoadURL(); | 390 ClearFailedLoadURL(); |
391 | 391 |
392 if (!failed_load_url_.IsEmpty() && image_source_url == failed_load_url_) | 392 if (!failed_load_url_.IsEmpty() && image_source_url == failed_load_url_) |
393 return; | 393 return; |
394 | 394 |
395 // Prevent the creation of a ResourceLoader (and therefore a network request) | 395 // Prevent the creation of a ResourceLoader (and therefore a network request) |
396 // for ImageDocument loads. In this case, the image contents have already been | 396 // for ImageDocument loads. In this case, the image contents have already been |
397 // requested as a main resource and ImageDocumentParser will take care of | 397 // requested as a main resource and ImageDocumentParser will take care of |
398 // funneling the main resource bytes into m_image, so just create an | 398 // funneling the main resource bytes into image_, so just create an |
399 // ImageResource to be populated later. | 399 // ImageResource to be populated later. |
400 if (loading_image_document_ && update_behavior != kUpdateForcedReload) { | 400 if (loading_image_document_ && update_behavior != kUpdateForcedReload) { |
401 ImageResource* image_resource = ImageResource::Create( | 401 ImageResource* image_resource = ImageResource::Create( |
402 ResourceRequest(ImageSourceToKURL(element_->ImageSourceURL()))); | 402 ResourceRequest(ImageSourceToKURL(element_->ImageSourceURL()))); |
403 image_resource->SetStatus(ResourceStatus::kPending); | 403 image_resource->SetStatus(ResourceStatus::kPending); |
404 image_resource->NotifyStartLoad(); | 404 image_resource->NotifyStartLoad(); |
405 image_resource_for_image_document_ = image_resource; | 405 image_resource_for_image_document_ = image_resource; |
406 SetImage(image_resource->GetContent()); | 406 SetImage(image_resource->GetContent()); |
407 return; | 407 return; |
408 } | 408 } |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
466 url, element_->GetDocument().Fetcher()->GetCacheIdentifier()); | 466 url, element_->GetDocument().Fetcher()->GetCacheIdentifier()); |
467 if (resource && !resource->ErrorOccurred()) | 467 if (resource && !resource->ErrorOccurred()) |
468 return true; | 468 return true; |
469 } | 469 } |
470 return (isHTMLObjectElement(element_) || isHTMLEmbedElement(element_)); | 470 return (isHTMLObjectElement(element_) || isHTMLEmbedElement(element_)); |
471 } | 471 } |
472 | 472 |
473 void ImageLoader::ImageNotifyFinished(ImageResourceContent* resource) { | 473 void ImageLoader::ImageNotifyFinished(ImageResourceContent* resource) { |
474 RESOURCE_LOADING_DVLOG(1) | 474 RESOURCE_LOADING_DVLOG(1) |
475 << "ImageLoader::imageNotifyFinished " << this | 475 << "ImageLoader::imageNotifyFinished " << this |
476 << "; m_hasPendingLoadEvent=" << has_pending_load_event_; | 476 << "; has_pending_load_event_=" << has_pending_load_event_; |
477 | 477 |
478 DCHECK(failed_load_url_.IsEmpty()); | 478 DCHECK(failed_load_url_.IsEmpty()); |
479 DCHECK_EQ(resource, image_.Get()); | 479 DCHECK_EQ(resource, image_.Get()); |
480 | 480 |
481 image_complete_ = true; | 481 image_complete_ = true; |
482 | 482 |
483 // Update ImageAnimationPolicy for m_image. | 483 // Update ImageAnimationPolicy for image_. |
484 if (image_) | 484 if (image_) |
485 image_->UpdateImageAnimationPolicy(); | 485 image_->UpdateImageAnimationPolicy(); |
486 | 486 |
487 UpdateLayoutObject(); | 487 UpdateLayoutObject(); |
488 | 488 |
489 if (image_ && image_->GetImage() && image_->GetImage()->IsSVGImage()) | 489 if (image_ && image_->GetImage() && image_->GetImage()->IsSVGImage()) |
490 ToSVGImage(image_->GetImage()) | 490 ToSVGImage(image_->GetImage()) |
491 ->UpdateUseCounters(GetElement()->GetDocument()); | 491 ->UpdateUseCounters(GetElement()->GetDocument()); |
492 | 492 |
493 if (!has_pending_load_event_) | 493 if (!has_pending_load_event_) |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
636 } | 636 } |
637 | 637 |
638 void ImageLoader::ElementDidMoveToNewDocument() { | 638 void ImageLoader::ElementDidMoveToNewDocument() { |
639 if (load_delay_counter_) | 639 if (load_delay_counter_) |
640 load_delay_counter_->DocumentChanged(element_->GetDocument()); | 640 load_delay_counter_->DocumentChanged(element_->GetDocument()); |
641 ClearFailedLoadURL(); | 641 ClearFailedLoadURL(); |
642 SetImage(0); | 642 SetImage(0); |
643 } | 643 } |
644 | 644 |
645 } // namespace blink | 645 } // namespace blink |
OLD | NEW |