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 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
234 } | 234 } |
235 | 235 |
236 bool ImageResource::imageHasRelativeHeight() const | 236 bool ImageResource::imageHasRelativeHeight() const |
237 { | 237 { |
238 if (m_image) | 238 if (m_image) |
239 return m_image->hasRelativeHeight(); | 239 return m_image->hasRelativeHeight(); |
240 | 240 |
241 return false; | 241 return false; |
242 } | 242 } |
243 | 243 |
244 void ImageResource::applyMultiplier(LayoutSize& imageSize, float multiplier) con st | |
245 { | |
246 if (multiplier == 1.0f) | |
247 return; | |
248 | |
249 // Don't let images that have a width/height >= 1 shrink below 1 when zoomed . | |
250 float widthScale = m_image->hasRelativeWidth() ? 1.0f : multiplier; | |
251 float heightScale = m_image->hasRelativeHeight() ? 1.0f : multiplier; | |
252 LayoutSize minimumSize(imageSize.width() > 0 ? 1 : 0, imageSize.height() > 0 ? 1 : 0); | |
253 imageSize.scale(widthScale, heightScale); | |
254 imageSize.clampToMinimumSize(minimumSize); | |
255 ASSERT(multiplier != 1.0f || (imageSize.width().fraction() == 0.0f && imageS ize.height().fraction() == 0.0f)); | |
256 } | |
257 | |
258 LayoutSize ImageResource::bitmapImageSizeRespectingOrientation(float multiplier) const | |
259 { | |
260 ASSERT(!isPurgeable()); | |
261 | |
262 if (!m_image || !m_image->isBitmapImage()) | |
263 return IntSize(); | |
abarth-chromium
2014/02/15 18:58:33
So, this won't work for SVG images? Should this b
| |
264 | |
265 LayoutSize imageSize = toBitmapImage(m_image.get())->sizeRespectingOrientati on(); | |
266 applyMultiplier(imageSize, multiplier); | |
267 return imageSize; | |
268 } | |
269 | |
244 LayoutSize ImageResource::imageSizeForRenderer(const RenderObject* renderer, flo at multiplier, SizeType sizeType) | 270 LayoutSize ImageResource::imageSizeForRenderer(const RenderObject* renderer, flo at multiplier, SizeType sizeType) |
245 { | 271 { |
246 ASSERT(!isPurgeable()); | 272 ASSERT(!isPurgeable()); |
247 | 273 |
248 if (!m_image) | 274 if (!m_image) |
249 return IntSize(); | 275 return IntSize(); |
250 | 276 |
251 LayoutSize imageSize; | 277 LayoutSize imageSize; |
252 | 278 |
253 if (m_image->isBitmapImage() && (renderer && renderer->shouldRespectImageOri entation() == RespectImageOrientation)) | 279 if (m_image->isBitmapImage() && (renderer && renderer->shouldRespectImageOri entation() == RespectImageOrientation)) |
254 imageSize = toBitmapImage(m_image.get())->sizeRespectingOrientation(); | 280 imageSize = toBitmapImage(m_image.get())->sizeRespectingOrientation(); |
255 else if (m_image->isSVGImage() && sizeType == NormalSize) | 281 else if (m_image->isSVGImage() && sizeType == NormalSize) |
256 imageSize = m_svgImageCache->imageSizeForRenderer(renderer); | 282 imageSize = m_svgImageCache->imageSizeForRenderer(renderer); |
257 else | 283 else |
258 imageSize = m_image->size(); | 284 imageSize = m_image->size(); |
259 | 285 |
260 if (multiplier == 1.0f) | 286 applyMultiplier(imageSize, multiplier); |
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; | 287 return imageSize; |
271 } | 288 } |
272 | 289 |
273 void ImageResource::computeIntrinsicDimensions(Length& intrinsicWidth, Length& i ntrinsicHeight, FloatSize& intrinsicRatio) | 290 void ImageResource::computeIntrinsicDimensions(Length& intrinsicWidth, Length& i ntrinsicHeight, FloatSize& intrinsicRatio) |
274 { | 291 { |
275 if (m_image) | 292 if (m_image) |
276 m_image->computeIntrinsicDimensions(intrinsicWidth, intrinsicHeight, int rinsicRatio); | 293 m_image->computeIntrinsicDimensions(intrinsicWidth, intrinsicHeight, int rinsicRatio); |
277 } | 294 } |
278 | 295 |
279 void ImageResource::notifyObservers(const IntRect* changeRect) | 296 void ImageResource::notifyObservers(const IntRect* changeRect) |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
462 bool ImageResource::isAccessAllowed(SecurityOrigin* securityOrigin) | 479 bool ImageResource::isAccessAllowed(SecurityOrigin* securityOrigin) |
463 { | 480 { |
464 if (!image()->currentFrameHasSingleSecurityOrigin()) | 481 if (!image()->currentFrameHasSingleSecurityOrigin()) |
465 return false; | 482 return false; |
466 if (passesAccessControlCheck(securityOrigin)) | 483 if (passesAccessControlCheck(securityOrigin)) |
467 return true; | 484 return true; |
468 return !securityOrigin->taintsCanvas(response().url()); | 485 return !securityOrigin->taintsCanvas(response().url()); |
469 } | 486 } |
470 | 487 |
471 } // namespace WebCore | 488 } // namespace WebCore |
OLD | NEW |