| OLD | NEW |
| 1 /* | 1 /* |
| 2 Copyright (C) 1998 Lars Knoll (knoll@mpi-hd.mpg.de) | 2 Copyright (C) 1998 Lars Knoll (knoll@mpi-hd.mpg.de) |
| 3 Copyright (C) 2001 Dirk Mueller (mueller@kde.org) | 3 Copyright (C) 2001 Dirk Mueller (mueller@kde.org) |
| 4 Copyright (C) 2002 Waldo Bastian (bastian@kde.org) | 4 Copyright (C) 2002 Waldo Bastian (bastian@kde.org) |
| 5 Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com) | 5 Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com) |
| 6 Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved. | 6 Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved. |
| 7 | 7 |
| 8 This library is free software; you can redistribute it and/or | 8 This library is free software; you can redistribute it and/or |
| 9 modify it under the terms of the GNU Library General Public | 9 modify it under the terms of the GNU Library General Public |
| 10 License as published by the Free Software Foundation; either | 10 License as published by the Free Software Foundation; either |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 | 23 |
| 24 #include "config.h" | 24 #include "config.h" |
| 25 #include "core/fetch/ImageResource.h" | 25 #include "core/fetch/ImageResource.h" |
| 26 | 26 |
| 27 #include "core/fetch/ImageResourceClient.h" | 27 #include "core/fetch/ImageResourceClient.h" |
| 28 #include "core/fetch/MemoryCache.h" | 28 #include "core/fetch/MemoryCache.h" |
| 29 #include "core/fetch/ResourceClient.h" | 29 #include "core/fetch/ResourceClient.h" |
| 30 #include "core/fetch/ResourceClientWalker.h" | 30 #include "core/fetch/ResourceClientWalker.h" |
| 31 #include "core/fetch/ResourceFetcher.h" | 31 #include "core/fetch/ResourceFetcher.h" |
| 32 #include "core/frame/FrameView.h" | 32 #include "core/frame/FrameView.h" |
| 33 #include "core/rendering/RenderObject.h" | 33 #include "core/layout/LayoutObject.h" |
| 34 #include "core/svg/graphics/SVGImage.h" | 34 #include "core/svg/graphics/SVGImage.h" |
| 35 #include "platform/Logging.h" | 35 #include "platform/Logging.h" |
| 36 #include "platform/RuntimeEnabledFeatures.h" | 36 #include "platform/RuntimeEnabledFeatures.h" |
| 37 #include "platform/SharedBuffer.h" | 37 #include "platform/SharedBuffer.h" |
| 38 #include "platform/TraceEvent.h" | 38 #include "platform/TraceEvent.h" |
| 39 #include "platform/graphics/BitmapImage.h" | 39 #include "platform/graphics/BitmapImage.h" |
| 40 #include "wtf/CurrentTime.h" | 40 #include "wtf/CurrentTime.h" |
| 41 #include "wtf/StdLibExtras.h" | 41 #include "wtf/StdLibExtras.h" |
| 42 | 42 |
| 43 namespace blink { | 43 namespace blink { |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 // when they need the real, deviceScaleFactor-appropriate broken image i
con. | 187 // when they need the real, deviceScaleFactor-appropriate broken image i
con. |
| 188 return brokenImage(1).first; | 188 return brokenImage(1).first; |
| 189 } | 189 } |
| 190 | 190 |
| 191 if (m_image) | 191 if (m_image) |
| 192 return m_image.get(); | 192 return m_image.get(); |
| 193 | 193 |
| 194 return blink::Image::nullImage(); | 194 return blink::Image::nullImage(); |
| 195 } | 195 } |
| 196 | 196 |
| 197 blink::Image* ImageResource::imageForRenderer(const RenderObject* renderer) | 197 blink::Image* ImageResource::imageForRenderer(const LayoutObject* renderer) |
| 198 { | 198 { |
| 199 ASSERT(!isPurgeable()); | 199 ASSERT(!isPurgeable()); |
| 200 | 200 |
| 201 if (errorOccurred()) { | 201 if (errorOccurred()) { |
| 202 // Returning the 1x broken image is non-ideal, but we cannot reliably ac
cess the appropriate | 202 // Returning the 1x broken image is non-ideal, but we cannot reliably ac
cess the appropriate |
| 203 // deviceScaleFactor from here. It is critical that callers use ImageRes
ource::brokenImage() | 203 // deviceScaleFactor from here. It is critical that callers use ImageRes
ource::brokenImage() |
| 204 // when they need the real, deviceScaleFactor-appropriate broken image i
con. | 204 // when they need the real, deviceScaleFactor-appropriate broken image i
con. |
| 205 return brokenImage(1).first; | 205 return brokenImage(1).first; |
| 206 } | 206 } |
| 207 | 207 |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 252 } | 252 } |
| 253 | 253 |
| 254 bool ImageResource::imageHasRelativeHeight() const | 254 bool ImageResource::imageHasRelativeHeight() const |
| 255 { | 255 { |
| 256 if (m_image) | 256 if (m_image) |
| 257 return m_image->hasRelativeHeight(); | 257 return m_image->hasRelativeHeight(); |
| 258 | 258 |
| 259 return false; | 259 return false; |
| 260 } | 260 } |
| 261 | 261 |
| 262 LayoutSize ImageResource::imageSizeForRenderer(const RenderObject* renderer, flo
at multiplier, SizeType sizeType) | 262 LayoutSize ImageResource::imageSizeForRenderer(const LayoutObject* renderer, flo
at multiplier, SizeType sizeType) |
| 263 { | 263 { |
| 264 ASSERT(!isPurgeable()); | 264 ASSERT(!isPurgeable()); |
| 265 | 265 |
| 266 if (!m_image) | 266 if (!m_image) |
| 267 return LayoutSize(); | 267 return LayoutSize(); |
| 268 | 268 |
| 269 LayoutSize imageSize; | 269 LayoutSize imageSize; |
| 270 | 270 |
| 271 if (m_image->isBitmapImage() && (renderer && renderer->shouldRespectImageOri
entation() == RespectImageOrientation)) | 271 if (m_image->isBitmapImage() && (renderer && renderer->shouldRespectImageOri
entation() == RespectImageOrientation)) |
| 272 imageSize = LayoutSize(toBitmapImage(m_image.get())->sizeRespectingOrien
tation()); | 272 imageSize = LayoutSize(toBitmapImage(m_image.get())->sizeRespectingOrien
tation()); |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 491 } | 491 } |
| 492 } | 492 } |
| 493 | 493 |
| 494 void ImageResource::changedInRect(const blink::Image* image, const IntRect& rect
) | 494 void ImageResource::changedInRect(const blink::Image* image, const IntRect& rect
) |
| 495 { | 495 { |
| 496 if (!image || image != m_image) | 496 if (!image || image != m_image) |
| 497 return; | 497 return; |
| 498 notifyObservers(&rect); | 498 notifyObservers(&rect); |
| 499 } | 499 } |
| 500 | 500 |
| 501 bool ImageResource::currentFrameKnownToBeOpaque(const RenderObject* renderer) | 501 bool ImageResource::currentFrameKnownToBeOpaque(const LayoutObject* renderer) |
| 502 { | 502 { |
| 503 blink::Image* image = imageForRenderer(renderer); | 503 blink::Image* image = imageForRenderer(renderer); |
| 504 if (image->isBitmapImage()) { | 504 if (image->isBitmapImage()) { |
| 505 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "PaintImage
", "data", InspectorPaintImageEvent::data(renderer, *this)); | 505 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "PaintImage
", "data", InspectorPaintImageEvent::data(renderer, *this)); |
| 506 image->nativeImageForCurrentFrame(); // force decode | 506 image->nativeImageForCurrentFrame(); // force decode |
| 507 } | 507 } |
| 508 return image->currentFrameKnownToBeOpaque(); | 508 return image->currentFrameKnownToBeOpaque(); |
| 509 } | 509 } |
| 510 | 510 |
| 511 bool ImageResource::isAccessAllowed(ExecutionContext* context, SecurityOrigin* s
ecurityOrigin) | 511 bool ImageResource::isAccessAllowed(ExecutionContext* context, SecurityOrigin* s
ecurityOrigin) |
| 512 { | 512 { |
| 513 if (response().wasFetchedViaServiceWorker()) | 513 if (response().wasFetchedViaServiceWorker()) |
| 514 return response().serviceWorkerResponseType() != WebServiceWorkerRespons
eTypeOpaque; | 514 return response().serviceWorkerResponseType() != WebServiceWorkerRespons
eTypeOpaque; |
| 515 if (!image()->currentFrameHasSingleSecurityOrigin()) | 515 if (!image()->currentFrameHasSingleSecurityOrigin()) |
| 516 return false; | 516 return false; |
| 517 if (passesAccessControlCheck(context, securityOrigin)) | 517 if (passesAccessControlCheck(context, securityOrigin)) |
| 518 return true; | 518 return true; |
| 519 return !securityOrigin->taintsCanvas(response().url()); | 519 return !securityOrigin->taintsCanvas(response().url()); |
| 520 } | 520 } |
| 521 | 521 |
| 522 } // namespace blink | 522 } // namespace blink |
| OLD | NEW |