| 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 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 ASSERT(resourceToRevalidate()->isImage()); | 117 ASSERT(resourceToRevalidate()->isImage()); |
| 118 // Pending container size requests need to be transferred to the revalidated
resource. | 118 // Pending container size requests need to be transferred to the revalidated
resource. |
| 119 if (!m_pendingContainerSizeRequests.isEmpty()) { | 119 if (!m_pendingContainerSizeRequests.isEmpty()) { |
| 120 // A copy of pending size requests is needed as they are deleted during
Resource::switchClientsToRevalidateResouce(). | 120 // A copy of pending size requests is needed as they are deleted during
Resource::switchClientsToRevalidateResouce(). |
| 121 ContainerSizeRequests switchContainerSizeRequests; | 121 ContainerSizeRequests switchContainerSizeRequests; |
| 122 for (ContainerSizeRequests::iterator it = m_pendingContainerSizeRequests
.begin(); it != m_pendingContainerSizeRequests.end(); ++it) | 122 for (ContainerSizeRequests::iterator it = m_pendingContainerSizeRequests
.begin(); it != m_pendingContainerSizeRequests.end(); ++it) |
| 123 switchContainerSizeRequests.set(it->key, it->value); | 123 switchContainerSizeRequests.set(it->key, it->value); |
| 124 Resource::switchClientsToRevalidatedResource(); | 124 Resource::switchClientsToRevalidatedResource(); |
| 125 ImageResource* revalidatedImageResource = toImageResource(resourceToReva
lidate()); | 125 ImageResource* revalidatedImageResource = toImageResource(resourceToReva
lidate()); |
| 126 for (ContainerSizeRequests::iterator it = switchContainerSizeRequests.be
gin(); it != switchContainerSizeRequests.end(); ++it) | 126 for (ContainerSizeRequests::iterator it = switchContainerSizeRequests.be
gin(); it != switchContainerSizeRequests.end(); ++it) |
| 127 revalidatedImageResource->setContainerSizeForRenderer(it->key, it->v
alue.first, it->value.second); | 127 revalidatedImageResource->setContainerSizeForRenderer(it->key, it->v
alue); |
| 128 return; | 128 return; |
| 129 } | 129 } |
| 130 | 130 |
| 131 Resource::switchClientsToRevalidatedResource(); | 131 Resource::switchClientsToRevalidatedResource(); |
| 132 } | 132 } |
| 133 | 133 |
| 134 bool ImageResource::isSafeToUnlock() const | 134 bool ImageResource::isSafeToUnlock() const |
| 135 { | 135 { |
| 136 // Note that |m_image| holds a reference to |m_data| in addition to the one
held by the Resource parent class. | 136 // Note that |m_image| holds a reference to |m_data| in addition to the one
held by the Resource parent class. |
| 137 return !m_image || (m_image->hasOneRef() && m_data->refCount() == 2); | 137 return !m_image || (m_image->hasOneRef() && m_data->refCount() == 2); |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 // when they need the real, deviceScaleFactor-appropriate broken image i
con. | 198 // when they need the real, deviceScaleFactor-appropriate broken image i
con. |
| 199 return brokenImage(1).first; | 199 return brokenImage(1).first; |
| 200 } | 200 } |
| 201 | 201 |
| 202 if (!m_image) | 202 if (!m_image) |
| 203 return blink::Image::nullImage(); | 203 return blink::Image::nullImage(); |
| 204 | 204 |
| 205 return m_image.get(); | 205 return m_image.get(); |
| 206 } | 206 } |
| 207 | 207 |
| 208 void ImageResource::setContainerSizeForRenderer(const ImageResourceClient* rende
rer, const IntSize& containerSize, float containerZoom) | 208 void ImageResource::setContainerSizeForRenderer(const ImageResourceClient* rende
rer, const IntSize& containerSize) |
| 209 { | 209 { |
| 210 if (containerSize.isEmpty()) | 210 if (containerSize.isEmpty()) |
| 211 return; | 211 return; |
| 212 ASSERT(renderer); | 212 ASSERT(renderer); |
| 213 ASSERT(containerZoom); | |
| 214 if (!m_image) { | 213 if (!m_image) { |
| 215 m_pendingContainerSizeRequests.set(renderer, SizeAndZoom(containerSize,
containerZoom)); | 214 m_pendingContainerSizeRequests.set(renderer, containerSize); |
| 216 return; | 215 return; |
| 217 } | 216 } |
| 218 | 217 |
| 219 m_image->setContainerSize(containerSize); | 218 m_image->setContainerSize(containerSize); |
| 220 } | 219 } |
| 221 | 220 |
| 222 bool ImageResource::usesImageContainerSize() const | 221 bool ImageResource::usesImageContainerSize() const |
| 223 { | 222 { |
| 224 if (m_image) | 223 if (m_image) |
| 225 return m_image->usesContainerSize(); | 224 return m_image->usesContainerSize(); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 236 } | 235 } |
| 237 | 236 |
| 238 bool ImageResource::imageHasRelativeHeight() const | 237 bool ImageResource::imageHasRelativeHeight() const |
| 239 { | 238 { |
| 240 if (m_image) | 239 if (m_image) |
| 241 return m_image->hasRelativeHeight(); | 240 return m_image->hasRelativeHeight(); |
| 242 | 241 |
| 243 return false; | 242 return false; |
| 244 } | 243 } |
| 245 | 244 |
| 246 LayoutSize ImageResource::imageSizeForRenderer(const RenderObject* renderer, flo
at multiplier, SizeType sizeType) | 245 LayoutSize ImageResource::imageSizeForRenderer(const RenderObject* renderer, Siz
eType sizeType) |
| 247 { | 246 { |
| 248 ASSERT(!isPurgeable()); | 247 ASSERT(!isPurgeable()); |
| 249 | 248 |
| 250 if (!m_image) | 249 if (!m_image) |
| 251 return IntSize(); | 250 return IntSize(); |
| 252 | 251 |
| 253 LayoutSize imageSize; | 252 if (m_image->isBitmapImage() && (renderer && renderer->shouldRespectImageOri
entation() == RespectImageOrientation)) |
| 253 return toBitmapImage(m_image.get())->sizeRespectingOrientation(); |
| 254 | 254 |
| 255 if (m_image->isBitmapImage() && (renderer && renderer->shouldRespectImageOri
entation() == RespectImageOrientation)) | 255 return m_image->size(); |
| 256 imageSize = toBitmapImage(m_image.get())->sizeRespectingOrientation(); | |
| 257 else | |
| 258 imageSize = m_image->size(); | |
| 259 | |
| 260 if (multiplier == 1.0f) | |
| 261 return imageSize; | |
| 262 | |
| 263 // Don't let images that have a width/height >= 1 shrink below 1 when zoomed
. | |
| 264 float widthScale = m_image->hasRelativeWidth() ? 1.0f : multiplier; | |
| 265 float heightScale = m_image->hasRelativeHeight() ? 1.0f : multiplier; | |
| 266 LayoutSize minimumSize(imageSize.width() > 0 ? 1 : 0, imageSize.height() > 0
? 1 : 0); | |
| 267 imageSize.scale(widthScale, heightScale); | |
| 268 imageSize.clampToMinimumSize(minimumSize); | |
| 269 ASSERT(multiplier != 1.0f || (imageSize.width().fraction() == 0.0f && imageS
ize.height().fraction() == 0.0f)); | |
| 270 return imageSize; | |
| 271 } | 256 } |
| 272 | 257 |
| 273 void ImageResource::computeIntrinsicDimensions(Length& intrinsicWidth, Length& i
ntrinsicHeight, FloatSize& intrinsicRatio) | 258 void ImageResource::computeIntrinsicDimensions(Length& intrinsicWidth, Length& i
ntrinsicHeight, FloatSize& intrinsicRatio) |
| 274 { | 259 { |
| 275 if (m_image) | 260 if (m_image) |
| 276 m_image->computeIntrinsicDimensions(intrinsicWidth, intrinsicHeight, int
rinsicRatio); | 261 m_image->computeIntrinsicDimensions(intrinsicWidth, intrinsicHeight, int
rinsicRatio); |
| 277 } | 262 } |
| 278 | 263 |
| 279 void ImageResource::notifyObservers(const IntRect* changeRect) | 264 void ImageResource::notifyObservers(const IntRect* changeRect) |
| 280 { | 265 { |
| (...skipping 21 matching lines...) Expand all Loading... |
| 302 // Create the image if it doesn't yet exist. | 287 // Create the image if it doesn't yet exist. |
| 303 if (m_image) | 288 if (m_image) |
| 304 return; | 289 return; |
| 305 | 290 |
| 306 m_image = BitmapImage::create(this); | 291 m_image = BitmapImage::create(this); |
| 307 | 292 |
| 308 if (m_image) { | 293 if (m_image) { |
| 309 // Send queued container size requests. | 294 // Send queued container size requests. |
| 310 if (m_image->usesContainerSize()) { | 295 if (m_image->usesContainerSize()) { |
| 311 for (ContainerSizeRequests::iterator it = m_pendingContainerSizeRequ
ests.begin(); it != m_pendingContainerSizeRequests.end(); ++it) | 296 for (ContainerSizeRequests::iterator it = m_pendingContainerSizeRequ
ests.begin(); it != m_pendingContainerSizeRequests.end(); ++it) |
| 312 setContainerSizeForRenderer(it->key, it->value.first, it->value.
second); | 297 setContainerSizeForRenderer(it->key, it->value); |
| 313 } | 298 } |
| 314 m_pendingContainerSizeRequests.clear(); | 299 m_pendingContainerSizeRequests.clear(); |
| 315 } | 300 } |
| 316 } | 301 } |
| 317 | 302 |
| 318 inline void ImageResource::clearImage() | 303 inline void ImageResource::clearImage() |
| 319 { | 304 { |
| 320 // If our Image has an observer, it's always us so we need to clear the back
pointer | 305 // If our Image has an observer, it's always us so we need to clear the back
pointer |
| 321 // before dropping our reference. | 306 // before dropping our reference. |
| 322 if (m_image) | 307 if (m_image) |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 442 | 427 |
| 443 bool ImageResource::currentFrameKnownToBeOpaque(const RenderObject* renderer) | 428 bool ImageResource::currentFrameKnownToBeOpaque(const RenderObject* renderer) |
| 444 { | 429 { |
| 445 blink::Image* image = imageForRenderer(renderer); | 430 blink::Image* image = imageForRenderer(renderer); |
| 446 if (image->isBitmapImage()) | 431 if (image->isBitmapImage()) |
| 447 image->nativeImageForCurrentFrame(); // force decode | 432 image->nativeImageForCurrentFrame(); // force decode |
| 448 return image->currentFrameKnownToBeOpaque(); | 433 return image->currentFrameKnownToBeOpaque(); |
| 449 } | 434 } |
| 450 | 435 |
| 451 } // namespace blink | 436 } // namespace blink |
| OLD | NEW |