Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(62)

Side by Side Diff: third_party/WebKit/Source/core/svg/graphics/SVGImage.cpp

Issue 1704493002: Use Image::updateConcreteSize() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@add-image-updateconcretesize
Patch Set: Move test here from dependency CL. Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/WebKit/Source/core/style/StyleImage.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 } 201 }
202 202
203 if (intrinsicSizingInfo.hasHeight) { 203 if (intrinsicSizingInfo.hasHeight) {
204 if (intrinsicSizingInfo.aspectRatio.isEmpty()) 204 if (intrinsicSizingInfo.aspectRatio.isEmpty())
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 // TODO(davve): According to the specification, the concrete object size should resolve as a 211 // "A contain constraint is resolved by setting the concrete object size to the largest
212 // contain constraint against the default object size at this stage. Unt il the 212 // rectangle that has the object's intrinsic aspect ratio and additiona lly has neither
213 // defaultObjectSize is context sensitive - right now it's hard-coded to 300x150 - we have 213 // width nor height larger than the constraint rectangle's width and he ight, respectively."
214 // to preserve legacy behavior by returning the aspectRatio as the concr ete object size. 214 float solutionWidth = resolveWidthForRatio(defaultObjectSize.height(), i ntrinsicSizingInfo.aspectRatio);
215 return intrinsicSizingInfo.aspectRatio; 215 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);
216 } 230 }
217 231
218 return defaultObjectSize; 232 return defaultObjectSize;
219 } 233 }
220 234
221 void SVGImage::drawForContainer(SkCanvas* canvas, const SkPaint& paint, const Fl oatSize containerSize, float zoom, const FloatRect& dstRect, 235 void SVGImage::drawForContainer(SkCanvas* canvas, const SkPaint& paint, const Fl oatSize containerSize, float zoom, const FloatRect& dstRect,
222 const FloatRect& srcRect, const KURL& url) 236 const FloatRect& srcRect, const KURL& url)
223 { 237 {
224 if (!m_page) 238 if (!m_page)
225 return; 239 return;
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after
545 { 559 {
546 return "svg"; 560 return "svg";
547 } 561 }
548 562
549 void SVGImage::updateConcreteObjectSize(const LayoutSize& defaultObjectSize) 563 void SVGImage::updateConcreteObjectSize(const LayoutSize& defaultObjectSize)
550 { 564 {
551 m_concreteObjectSize = roundedIntSize(calculateConcreteObjectSize(FloatSize( defaultObjectSize))); 565 m_concreteObjectSize = roundedIntSize(calculateConcreteObjectSize(FloatSize( defaultObjectSize)));
552 } 566 }
553 567
554 } // namespace blink 568 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/style/StyleImage.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698