| 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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 return sender; | 67 return sender; |
| 68 } | 68 } |
| 69 | 69 |
| 70 static inline bool pageIsBeingDismissed(Document* document) | 70 static inline bool pageIsBeingDismissed(Document* document) |
| 71 { | 71 { |
| 72 return document->pageDismissalEventBeingDispatched() != Document::NoDismissa
l; | 72 return document->pageDismissalEventBeingDispatched() != Document::NoDismissa
l; |
| 73 } | 73 } |
| 74 | 74 |
| 75 static ImageLoader::BypassMainWorldBehavior shouldBypassMainWorldCSP(ImageLoader
* loader) | 75 static ImageLoader::BypassMainWorldBehavior shouldBypassMainWorldCSP(ImageLoader
* loader) |
| 76 { | 76 { |
| 77 ASSERT(loader); | 77 DCHECK(loader); |
| 78 ASSERT(loader->element()); | 78 DCHECK(loader->element()); |
| 79 if (loader->element()->document().frame() && loader->element()->document().f
rame()->script().shouldBypassMainWorldCSP()) | 79 if (loader->element()->document().frame() && loader->element()->document().f
rame()->script().shouldBypassMainWorldCSP()) |
| 80 return ImageLoader::BypassMainWorldCSP; | 80 return ImageLoader::BypassMainWorldCSP; |
| 81 return ImageLoader::DoNotBypassMainWorldCSP; | 81 return ImageLoader::DoNotBypassMainWorldCSP; |
| 82 } | 82 } |
| 83 | 83 |
| 84 class ImageLoader::Task { | 84 class ImageLoader::Task { |
| 85 public: | 85 public: |
| 86 static std::unique_ptr<Task> create(ImageLoader* loader, UpdateFromElementBe
havior updateBehavior, ReferrerPolicy referrerPolicy) | 86 static std::unique_ptr<Task> create(ImageLoader* loader, UpdateFromElementBe
havior updateBehavior, ReferrerPolicy referrerPolicy) |
| 87 { | 87 { |
| 88 return wrapUnique(new Task(loader, updateBehavior, referrerPolicy)); | 88 return wrapUnique(new Task(loader, updateBehavior, referrerPolicy)); |
| 89 } | 89 } |
| 90 | 90 |
| 91 Task(ImageLoader* loader, UpdateFromElementBehavior updateBehavior, Referrer
Policy referrerPolicy) | 91 Task(ImageLoader* loader, UpdateFromElementBehavior updateBehavior, Referrer
Policy referrerPolicy) |
| 92 : m_loader(loader) | 92 : m_loader(loader) |
| 93 , m_shouldBypassMainWorldCSP(shouldBypassMainWorldCSP(loader)) | 93 , m_shouldBypassMainWorldCSP(shouldBypassMainWorldCSP(loader)) |
| 94 , m_updateBehavior(updateBehavior) | 94 , m_updateBehavior(updateBehavior) |
| 95 , m_weakFactory(this) | 95 , m_weakFactory(this) |
| 96 , m_referrerPolicy(referrerPolicy) | 96 , m_referrerPolicy(referrerPolicy) |
| 97 { | 97 { |
| 98 ExecutionContext& context = m_loader->element()->document(); | 98 ExecutionContext& context = m_loader->element()->document(); |
| 99 InspectorInstrumentation::asyncTaskScheduled(&context, "Image", this); | 99 InspectorInstrumentation::asyncTaskScheduled(&context, "Image", this); |
| 100 v8::Isolate* isolate = V8PerIsolateData::mainThreadIsolate(); | 100 v8::Isolate* isolate = V8PerIsolateData::mainThreadIsolate(); |
| 101 v8::HandleScope scope(isolate); | 101 v8::HandleScope scope(isolate); |
| 102 // If we're invoked from C++ without a V8 context on the stack, we shoul
d | 102 // If we're invoked from C++ without a V8 context on the stack, we shoul
d |
| 103 // run the microtask in the context of the element's document's main wor
ld. | 103 // run the microtask in the context of the element's document's main wor
ld. |
| 104 if (ScriptState::hasCurrentScriptState(isolate)) { | 104 if (ScriptState::hasCurrentScriptState(isolate)) { |
| 105 m_scriptState = ScriptState::current(isolate); | 105 m_scriptState = ScriptState::current(isolate); |
| 106 } else { | 106 } else { |
| 107 m_scriptState = ScriptState::forMainWorld(loader->element()->documen
t().frame()); | 107 m_scriptState = ScriptState::forMainWorld(loader->element()->documen
t().frame()); |
| 108 ASSERT(m_scriptState); | 108 DCHECK(m_scriptState); |
| 109 } | 109 } |
| 110 m_requestURL = loader->imageSourceToKURL(loader->element()->imageSourceU
RL()); | 110 m_requestURL = loader->imageSourceToKURL(loader->element()->imageSourceU
RL()); |
| 111 } | 111 } |
| 112 | 112 |
| 113 void run() | 113 void run() |
| 114 { | 114 { |
| 115 if (!m_loader) | 115 if (!m_loader) |
| 116 return; | 116 return; |
| 117 ExecutionContext& context = m_loader->element()->document(); | 117 ExecutionContext& context = m_loader->element()->document(); |
| 118 InspectorInstrumentation::AsyncTask asyncTask(&context, this); | 118 InspectorInstrumentation::AsyncTask asyncTask(&context, this); |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 { | 185 { |
| 186 setImageWithoutConsideringPendingLoadEvent(newImage); | 186 setImageWithoutConsideringPendingLoadEvent(newImage); |
| 187 | 187 |
| 188 // Only consider updating the protection ref-count of the Element immediatel
y before returning | 188 // Only consider updating the protection ref-count of the Element immediatel
y before returning |
| 189 // from this function as doing so might result in the destruction of this Im
ageLoader. | 189 // from this function as doing so might result in the destruction of this Im
ageLoader. |
| 190 updatedHasPendingEvent(); | 190 updatedHasPendingEvent(); |
| 191 } | 191 } |
| 192 | 192 |
| 193 void ImageLoader::setImageWithoutConsideringPendingLoadEvent(ImageResource* newI
mage) | 193 void ImageLoader::setImageWithoutConsideringPendingLoadEvent(ImageResource* newI
mage) |
| 194 { | 194 { |
| 195 ASSERT(m_failedLoadURL.isEmpty()); | 195 DCHECK(m_failedLoadURL.isEmpty()); |
| 196 ImageResource* oldImage = m_image.get(); | 196 ImageResource* oldImage = m_image.get(); |
| 197 if (newImage != oldImage) { | 197 if (newImage != oldImage) { |
| 198 m_image = newImage; | 198 m_image = newImage; |
| 199 if (m_hasPendingLoadEvent) { | 199 if (m_hasPendingLoadEvent) { |
| 200 loadEventSender().cancelEvent(this); | 200 loadEventSender().cancelEvent(this); |
| 201 m_hasPendingLoadEvent = false; | 201 m_hasPendingLoadEvent = false; |
| 202 } | 202 } |
| 203 if (m_hasPendingErrorEvent) { | 203 if (m_hasPendingErrorEvent) { |
| 204 errorEventSender().cancelEvent(this); | 204 errorEventSender().cancelEvent(this); |
| 205 m_hasPendingErrorEvent = false; | 205 m_hasPendingErrorEvent = false; |
| (...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 430 return true; | 430 return true; |
| 431 } | 431 } |
| 432 return (isHTMLObjectElement(m_element) || isHTMLEmbedElement(m_element) || u
rl.protocolIsData()); | 432 return (isHTMLObjectElement(m_element) || isHTMLEmbedElement(m_element) || u
rl.protocolIsData()); |
| 433 } | 433 } |
| 434 | 434 |
| 435 void ImageLoader::imageNotifyFinished(ImageResource* resource) | 435 void ImageLoader::imageNotifyFinished(ImageResource* resource) |
| 436 { | 436 { |
| 437 RESOURCE_LOADING_DVLOG(1) << "ImageLoader::imageNotifyFinished " << this | 437 RESOURCE_LOADING_DVLOG(1) << "ImageLoader::imageNotifyFinished " << this |
| 438 << "; m_hasPendingLoadEvent=" << m_hasPendingLoadEvent; | 438 << "; m_hasPendingLoadEvent=" << m_hasPendingLoadEvent; |
| 439 | 439 |
| 440 ASSERT(m_failedLoadURL.isEmpty()); | 440 DCHECK(m_failedLoadURL.isEmpty()); |
| 441 ASSERT(resource == m_image.get()); | 441 DCHECK_EQ(resource, m_image.get()); |
| 442 | 442 |
| 443 m_imageComplete = true; | 443 m_imageComplete = true; |
| 444 | 444 |
| 445 // Update ImageAnimationPolicy for m_image. | 445 // Update ImageAnimationPolicy for m_image. |
| 446 if (m_image) | 446 if (m_image) |
| 447 m_image->updateImageAnimationPolicy(); | 447 m_image->updateImageAnimationPolicy(); |
| 448 | 448 |
| 449 updateLayoutObject(); | 449 updateLayoutObject(); |
| 450 | 450 |
| 451 if (m_image && m_image->getImage() && m_image->getImage()->isSVGImage()) | 451 if (m_image && m_image->getImage() && m_image->getImage()->isSVGImage()) |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 527 m_elementIsProtected = m_hasPendingLoadEvent || m_hasPendingErrorEvent; | 527 m_elementIsProtected = m_hasPendingLoadEvent || m_hasPendingErrorEvent; |
| 528 if (wasProtected == m_elementIsProtected) | 528 if (wasProtected == m_elementIsProtected) |
| 529 return; | 529 return; |
| 530 | 530 |
| 531 if (m_elementIsProtected) { | 531 if (m_elementIsProtected) { |
| 532 if (m_derefElementTimer.isActive()) | 532 if (m_derefElementTimer.isActive()) |
| 533 m_derefElementTimer.stop(); | 533 m_derefElementTimer.stop(); |
| 534 else | 534 else |
| 535 m_keepAlive = m_element; | 535 m_keepAlive = m_element; |
| 536 } else { | 536 } else { |
| 537 ASSERT(!m_derefElementTimer.isActive()); | 537 DCHECK(!m_derefElementTimer.isActive()); |
| 538 m_derefElementTimer.startOneShot(0, BLINK_FROM_HERE); | 538 m_derefElementTimer.startOneShot(0, BLINK_FROM_HERE); |
| 539 } | 539 } |
| 540 } | 540 } |
| 541 | 541 |
| 542 void ImageLoader::timerFired(TimerBase*) | 542 void ImageLoader::timerFired(TimerBase*) |
| 543 { | 543 { |
| 544 m_keepAlive.clear(); | 544 m_keepAlive.clear(); |
| 545 } | 545 } |
| 546 | 546 |
| 547 void ImageLoader::dispatchPendingEvent(ImageEventSender* eventSender) | 547 void ImageLoader::dispatchPendingEvent(ImageEventSender* eventSender) |
| 548 { | 548 { |
| 549 RESOURCE_LOADING_DVLOG(1) << "ImageLoader::dispatchPendingEvent " << this; | 549 RESOURCE_LOADING_DVLOG(1) << "ImageLoader::dispatchPendingEvent " << this; |
| 550 ASSERT(eventSender == &loadEventSender() || eventSender == &errorEventSender
()); | 550 DCHECK(eventSender == &loadEventSender() || eventSender == &errorEventSender
()); |
| 551 const AtomicString& eventType = eventSender->eventType(); | 551 const AtomicString& eventType = eventSender->eventType(); |
| 552 if (eventType == EventTypeNames::load) | 552 if (eventType == EventTypeNames::load) |
| 553 dispatchPendingLoadEvent(); | 553 dispatchPendingLoadEvent(); |
| 554 if (eventType == EventTypeNames::error) | 554 if (eventType == EventTypeNames::error) |
| 555 dispatchPendingErrorEvent(); | 555 dispatchPendingErrorEvent(); |
| 556 } | 556 } |
| 557 | 557 |
| 558 void ImageLoader::dispatchPendingLoadEvent() | 558 void ImageLoader::dispatchPendingLoadEvent() |
| 559 { | 559 { |
| 560 if (!m_hasPendingLoadEvent) | 560 if (!m_hasPendingLoadEvent) |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 605 | 605 |
| 606 void ImageLoader::elementDidMoveToNewDocument() | 606 void ImageLoader::elementDidMoveToNewDocument() |
| 607 { | 607 { |
| 608 if (m_loadDelayCounter) | 608 if (m_loadDelayCounter) |
| 609 m_loadDelayCounter->documentChanged(m_element->document()); | 609 m_loadDelayCounter->documentChanged(m_element->document()); |
| 610 clearFailedLoadURL(); | 610 clearFailedLoadURL(); |
| 611 setImage(0); | 611 setImage(0); |
| 612 } | 612 } |
| 613 | 613 |
| 614 } // namespace blink | 614 } // namespace blink |
| OLD | NEW |