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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 #include "core/svg/graphics/SVGImage.h" | 47 #include "core/svg/graphics/SVGImage.h" |
48 #include "platform/Logging.h" | 48 #include "platform/Logging.h" |
49 #include "platform/weborigin/SecurityOrigin.h" | 49 #include "platform/weborigin/SecurityOrigin.h" |
50 #include "platform/weborigin/SecurityPolicy.h" | 50 #include "platform/weborigin/SecurityPolicy.h" |
51 #include "public/platform/WebURLRequest.h" | 51 #include "public/platform/WebURLRequest.h" |
52 | 52 |
53 namespace blink { | 53 namespace blink { |
54 | 54 |
55 static ImageEventSender& loadEventSender() | 55 static ImageEventSender& loadEventSender() |
56 { | 56 { |
57 DEFINE_STATIC_LOCAL(OwnPtrWillBePersistent<ImageEventSender>, sender, (Image
EventSender::create(EventTypeNames::load))); | 57 DEFINE_STATIC_LOCAL(Persistent<ImageEventSender>, sender, (ImageEventSender:
:create(EventTypeNames::load))); |
58 return *sender; | 58 return *sender; |
59 } | 59 } |
60 | 60 |
61 static ImageEventSender& errorEventSender() | 61 static ImageEventSender& errorEventSender() |
62 { | 62 { |
63 DEFINE_STATIC_LOCAL(OwnPtrWillBePersistent<ImageEventSender>, sender, (Image
EventSender::create(EventTypeNames::error))); | 63 DEFINE_STATIC_LOCAL(Persistent<ImageEventSender>, sender, (ImageEventSender:
:create(EventTypeNames::error))); |
64 return *sender; | 64 return *sender; |
65 } | 65 } |
66 | 66 |
67 static inline bool pageIsBeingDismissed(Document* document) | 67 static inline bool pageIsBeingDismissed(Document* document) |
68 { | 68 { |
69 return document->pageDismissalEventBeingDispatched() != Document::NoDismissa
l; | 69 return document->pageDismissalEventBeingDispatched() != Document::NoDismissa
l; |
70 } | 70 } |
71 | 71 |
72 static ImageLoader::BypassMainWorldBehavior shouldBypassMainWorldCSP(ImageLoader
* loader) | 72 static ImageLoader::BypassMainWorldBehavior shouldBypassMainWorldCSP(ImageLoader
* loader) |
73 { | 73 { |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 m_loader = nullptr; | 130 m_loader = nullptr; |
131 m_scriptState.clear(); | 131 m_scriptState.clear(); |
132 } | 132 } |
133 | 133 |
134 WeakPtr<Task> createWeakPtr() | 134 WeakPtr<Task> createWeakPtr() |
135 { | 135 { |
136 return m_weakFactory.createWeakPtr(); | 136 return m_weakFactory.createWeakPtr(); |
137 } | 137 } |
138 | 138 |
139 private: | 139 private: |
140 RawPtrWillBeWeakPersistent<ImageLoader> m_loader; | 140 WeakPersistent<ImageLoader> m_loader; |
141 BypassMainWorldBehavior m_shouldBypassMainWorldCSP; | 141 BypassMainWorldBehavior m_shouldBypassMainWorldCSP; |
142 UpdateFromElementBehavior m_updateBehavior; | 142 UpdateFromElementBehavior m_updateBehavior; |
143 RefPtr<ScriptState> m_scriptState; | 143 RefPtr<ScriptState> m_scriptState; |
144 WeakPtrFactory<Task> m_weakFactory; | 144 WeakPtrFactory<Task> m_weakFactory; |
145 ReferrerPolicy m_referrerPolicy; | 145 ReferrerPolicy m_referrerPolicy; |
146 int m_operationId; | 146 int m_operationId; |
147 }; | 147 }; |
148 | 148 |
149 ImageLoader::ImageLoader(Element* element) | 149 ImageLoader::ImageLoader(Element* element) |
150 : m_element(element) | 150 : m_element(element) |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
291 // Make sure to only decrement the count when we exit this function | 291 // Make sure to only decrement the count when we exit this function |
292 OwnPtr<IncrementLoadEventDelayCount> loadDelayCounter; | 292 OwnPtr<IncrementLoadEventDelayCount> loadDelayCounter; |
293 loadDelayCounter.swap(m_loadDelayCounter); | 293 loadDelayCounter.swap(m_loadDelayCounter); |
294 | 294 |
295 Document& document = m_element->document(); | 295 Document& document = m_element->document(); |
296 if (!document.isActive()) | 296 if (!document.isActive()) |
297 return; | 297 return; |
298 | 298 |
299 AtomicString imageSourceURL = m_element->imageSourceURL(); | 299 AtomicString imageSourceURL = m_element->imageSourceURL(); |
300 KURL url = imageSourceToKURL(imageSourceURL); | 300 KURL url = imageSourceToKURL(imageSourceURL); |
301 RefPtrWillBeRawPtr<ImageResource> newImage = nullptr; | 301 RawPtr<ImageResource> newImage = nullptr; |
302 RefPtrWillBeRawPtr<Element> protectElement(m_element.get()); | 302 RawPtr<Element> protectElement(m_element.get()); |
303 if (!url.isNull()) { | 303 if (!url.isNull()) { |
304 // Unlike raw <img>, we block mixed content inside of <picture> or <img
srcset>. | 304 // Unlike raw <img>, we block mixed content inside of <picture> or <img
srcset>. |
305 ResourceLoaderOptions resourceLoaderOptions = ResourceFetcher::defaultRe
sourceOptions(); | 305 ResourceLoaderOptions resourceLoaderOptions = ResourceFetcher::defaultRe
sourceOptions(); |
306 ResourceRequest resourceRequest(url); | 306 ResourceRequest resourceRequest(url); |
307 if (updateBehavior == UpdateForcedReload) { | 307 if (updateBehavior == UpdateForcedReload) { |
308 resourceRequest.setCachePolicy(ResourceRequestCachePolicy::Bypassing
Cache); | 308 resourceRequest.setCachePolicy(ResourceRequestCachePolicy::Bypassing
Cache); |
309 resourceRequest.setLoFiState(WebURLRequest::LoFiOff); | 309 resourceRequest.setLoFiState(WebURLRequest::LoFiOff); |
310 // ImageLoader defers the load of images when in an ImageDocument. | 310 // ImageLoader defers the load of images when in an ImageDocument. |
311 // Don't defer this load on a forced reload. | 311 // Don't defer this load on a forced reload. |
312 m_loadingImageDocument = false; | 312 m_loadingImageDocument = false; |
(...skipping 27 matching lines...) Expand all Loading... |
340 clearFailedLoadURL(); | 340 clearFailedLoadURL(); |
341 } | 341 } |
342 } else { | 342 } else { |
343 if (!imageSourceURL.isNull()) { | 343 if (!imageSourceURL.isNull()) { |
344 // Fire an error event if the url string is not empty, but the KURL
is. | 344 // Fire an error event if the url string is not empty, but the KURL
is. |
345 dispatchErrorEvent(); | 345 dispatchErrorEvent(); |
346 } | 346 } |
347 noImageResourceToLoad(); | 347 noImageResourceToLoad(); |
348 } | 348 } |
349 | 349 |
350 RefPtrWillBeRawPtr<ImageResource> oldImage = m_image.get(); | 350 RawPtr<ImageResource> oldImage = m_image.get(); |
351 if (updateBehavior == UpdateSizeChanged && m_element->layoutObject() && m_el
ement->layoutObject()->isImage() && newImage == oldImage) { | 351 if (updateBehavior == UpdateSizeChanged && m_element->layoutObject() && m_el
ement->layoutObject()->isImage() && newImage == oldImage) { |
352 toLayoutImage(m_element->layoutObject())->intrinsicSizeChanged(); | 352 toLayoutImage(m_element->layoutObject())->intrinsicSizeChanged(); |
353 } else { | 353 } else { |
354 if (m_hasPendingLoadEvent) { | 354 if (m_hasPendingLoadEvent) { |
355 loadEventSender().cancelEvent(this); | 355 loadEventSender().cancelEvent(this); |
356 m_hasPendingLoadEvent = false; | 356 m_hasPendingLoadEvent = false; |
357 } | 357 } |
358 | 358 |
359 // Cancel error events that belong to the previous load, which is now ca
ncelled by changing the src attribute. | 359 // Cancel error events that belong to the previous load, which is now ca
ncelled by changing the src attribute. |
360 // If newImage is null and m_hasPendingErrorEvent is true, we know the e
rror event has been just posted by | 360 // If newImage is null and m_hasPendingErrorEvent is true, we know the e
rror event has been just posted by |
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
636 | 636 |
637 void ImageLoader::elementDidMoveToNewDocument() | 637 void ImageLoader::elementDidMoveToNewDocument() |
638 { | 638 { |
639 if (m_loadDelayCounter) | 639 if (m_loadDelayCounter) |
640 m_loadDelayCounter->documentChanged(m_element->document()); | 640 m_loadDelayCounter->documentChanged(m_element->document()); |
641 clearFailedLoadURL(); | 641 clearFailedLoadURL(); |
642 setImage(0); | 642 setImage(0); |
643 } | 643 } |
644 | 644 |
645 } // namespace blink | 645 } // namespace blink |
OLD | NEW |