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

Side by Side Diff: third_party/WebKit/Source/core/style/StyleFetchedImage.cpp

Issue 1756763004: Merge image sizing algorithms (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Extend test to cover svg and non-svg case Created 4 years, 9 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2000 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 2000 Lars Knoll (knoll@kde.org)
3 * (C) 2000 Antti Koivisto (koivisto@kde.org) 3 * (C) 2000 Antti Koivisto (koivisto@kde.org)
4 * (C) 2000 Dirk Mueller (mueller@kde.org) 4 * (C) 2000 Dirk Mueller (mueller@kde.org)
5 * Copyright (C) 2003, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. 5 * Copyright (C) 2003, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
6 * 6 *
7 * This library is free software; you can redistribute it and/or 7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public 8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either 9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version. 10 * version 2 of the License, or (at your option) any later version.
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 bool StyleFetchedImage::isLoaded() const 84 bool StyleFetchedImage::isLoaded() const
85 { 85 {
86 return m_image->isLoaded(); 86 return m_image->isLoaded();
87 } 87 }
88 88
89 bool StyleFetchedImage::errorOccurred() const 89 bool StyleFetchedImage::errorOccurred() const
90 { 90 {
91 return m_image->errorOccurred(); 91 return m_image->errorOccurred();
92 } 92 }
93 93
94 LayoutSize StyleFetchedImage::imageSize(const LayoutObject* layoutObject, float multiplier) const 94 LayoutSize StyleFetchedImage::imageSize(const LayoutObject* layoutObject, float multiplier, const LayoutSize& defaultObjectSize) const
95 { 95 {
96 return m_image->imageSize(LayoutObject::shouldRespectImageOrientation(layout Object), multiplier); 96 if (m_image->image() && m_image->image()->isSVGImage()) {
97 FloatSize unzoomedDefaultObjectSize(defaultObjectSize);
98 unzoomedDefaultObjectSize.scale(1 / multiplier);
99 LayoutSize concreteObjectSize(toSVGImage(m_image->image())->calculateCon creteObjectSize(unzoomedDefaultObjectSize));
100
101 // Don't let images that have a width/height >= 1 shrink below 1 when zo omed.
fs 2016/03/03 15:22:53 Maybe we could put this sequence as a helper on St
davve 2016/03/04 06:49:43 Yes, that probably good. Even prior to this, there
102 LayoutSize minimumSize(concreteObjectSize.width() > LayoutUnit() ? Layou tUnit(1) : LayoutUnit(),
103 concreteObjectSize.height() > LayoutUnit() ? LayoutUnit(1) : LayoutU nit());
104 concreteObjectSize.scale(multiplier);
105 concreteObjectSize.clampToMinimumSize(minimumSize);
106 return concreteObjectSize;
107 }
108
109 // Image orientation should only be respected for content images,
110 // not decorative ones as StyleImage carries (backgrounds,
111 // border-image, etc.)
112 const RespectImageOrientationEnum shouldRespectImageOrientation = DoNotRespe ctImageOrientation;
fs 2016/03/03 15:22:53 Nit: Fold this into the call? (Comment alone seems
davve 2016/03/04 06:49:43 Done.
113
114 return m_image->imageSize(shouldRespectImageOrientation, multiplier);
97 } 115 }
98 116
99 bool StyleFetchedImage::imageHasRelativeSize() const 117 bool StyleFetchedImage::imageHasRelativeSize() const
100 { 118 {
101 return m_image->imageHasRelativeSize(); 119 return m_image->imageHasRelativeSize();
102 } 120 }
103 121
104 void StyleFetchedImage::computeIntrinsicDimensions(const LayoutObject*, FloatSiz e& intrinsicSize, FloatSize& intrinsicRatio) 122 void StyleFetchedImage::computeIntrinsicDimensions(const LayoutObject*, FloatSiz e& intrinsicSize, FloatSize& intrinsicRatio)
105 { 123 {
106 m_image->computeIntrinsicDimensions(intrinsicSize, intrinsicRatio); 124 m_image->computeIntrinsicDimensions(intrinsicSize, intrinsicRatio);
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 } 162 }
145 163
146 DEFINE_TRACE(StyleFetchedImage) 164 DEFINE_TRACE(StyleFetchedImage)
147 { 165 {
148 visitor->trace(m_image); 166 visitor->trace(m_image);
149 visitor->trace(m_document); 167 visitor->trace(m_document);
150 StyleImage::trace(visitor); 168 StyleImage::trace(visitor);
151 } 169 }
152 170
153 } // namespace blink 171 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698