OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2006 Eric Seidel <eric@webkit.org> | 2 * Copyright (C) 2006 Eric Seidel <eric@webkit.org> |
3 * Copyright (C) 2008, 2009 Apple Inc. All rights reserved. | 3 * Copyright (C) 2008, 2009 Apple Inc. All rights reserved. |
4 * Copyright (C) Research In Motion Limited 2011. All rights reserved. | 4 * Copyright (C) Research In Motion Limited 2011. All rights reserved. |
5 * | 5 * |
6 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
7 * modification, are permitted provided that the following conditions | 7 * modification, are permitted provided that the following conditions |
8 * are met: | 8 * are met: |
9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 return FloatSize(defaultObjectSize.width(), intrinsicSizingInfo.size
.height()); | 205 return FloatSize(defaultObjectSize.width(), intrinsicSizingInfo.size
.height()); |
206 | 206 |
207 return FloatSize(resolveWidthForRatio(intrinsicSizingInfo.size.height(),
intrinsicSizingInfo.aspectRatio), intrinsicSizingInfo.size.height()); | 207 return FloatSize(resolveWidthForRatio(intrinsicSizingInfo.size.height(),
intrinsicSizingInfo.aspectRatio), intrinsicSizingInfo.size.height()); |
208 } | 208 } |
209 | 209 |
210 if (!intrinsicSizingInfo.aspectRatio.isEmpty()) { | 210 if (!intrinsicSizingInfo.aspectRatio.isEmpty()) { |
211 // "A contain constraint is resolved by setting the concrete object size
to the largest | 211 // "A contain constraint is resolved by setting the concrete object size
to the largest |
212 // rectangle that has the object's intrinsic aspect ratio and additiona
lly has neither | 212 // rectangle that has the object's intrinsic aspect ratio and additiona
lly has neither |
213 // width nor height larger than the constraint rectangle's width and he
ight, respectively." | 213 // width nor height larger than the constraint rectangle's width and he
ight, respectively." |
214 float solutionWidth = resolveWidthForRatio(defaultObjectSize.height(), i
ntrinsicSizingInfo.aspectRatio); | 214 float solutionWidth = resolveWidthForRatio(defaultObjectSize.height(), i
ntrinsicSizingInfo.aspectRatio); |
| 215 if (solutionWidth <= defaultObjectSize.width()) |
| 216 return FloatSize(solutionWidth, defaultObjectSize.height()); |
| 217 |
215 float solutionHeight = resolveHeightForRatio(defaultObjectSize.width(),
intrinsicSizingInfo.aspectRatio); | 218 float solutionHeight = resolveHeightForRatio(defaultObjectSize.width(),
intrinsicSizingInfo.aspectRatio); |
216 if (solutionWidth <= defaultObjectSize.width()) { | |
217 if (solutionHeight <= defaultObjectSize.height()) { | |
218 float areaOne = solutionWidth * defaultObjectSize.height(); | |
219 float areaTwo = defaultObjectSize.width() * solutionHeight; | |
220 if (areaOne < areaTwo) | |
221 return FloatSize(defaultObjectSize.width(), solutionHeight); | |
222 return FloatSize(solutionWidth, defaultObjectSize.height()); | |
223 } | |
224 | |
225 return FloatSize(solutionWidth, defaultObjectSize.height()); | |
226 } | |
227 | |
228 ASSERT(solutionHeight <= defaultObjectSize.height()); | |
229 return FloatSize(defaultObjectSize.width(), solutionHeight); | 219 return FloatSize(defaultObjectSize.width(), solutionHeight); |
230 } | 220 } |
231 | 221 |
232 return defaultObjectSize; | 222 return defaultObjectSize; |
233 } | 223 } |
234 | 224 |
235 void SVGImage::drawForContainer(SkCanvas* canvas, const SkPaint& paint, const Fl
oatSize containerSize, float zoom, const FloatRect& dstRect, | 225 void SVGImage::drawForContainer(SkCanvas* canvas, const SkPaint& paint, const Fl
oatSize containerSize, float zoom, const FloatRect& dstRect, |
236 const FloatRect& srcRect, const KURL& url) | 226 const FloatRect& srcRect, const KURL& url) |
237 { | 227 { |
238 if (!m_page) | 228 if (!m_page) |
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
588 | 578 |
589 return m_page ? SizeAvailable : SizeUnavailable; | 579 return m_page ? SizeAvailable : SizeUnavailable; |
590 } | 580 } |
591 | 581 |
592 String SVGImage::filenameExtension() const | 582 String SVGImage::filenameExtension() const |
593 { | 583 { |
594 return "svg"; | 584 return "svg"; |
595 } | 585 } |
596 | 586 |
597 } // namespace blink | 587 } // namespace blink |
OLD | NEW |