Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #include "config.h" | 31 #include "config.h" |
| 32 #include "core/rendering/style/ShadowList.h" | 32 #include "core/rendering/style/ShadowList.h" |
| 33 | 33 |
| 34 #include "platform/geometry/FloatRect.h" | 34 #include "platform/geometry/FloatRect.h" |
| 35 #include "platform/geometry/LayoutRect.h" | |
| 36 | 35 |
| 37 namespace WebCore { | 36 namespace WebCore { |
| 38 | 37 |
| 39 static inline void calculateShadowExtent(const ShadowList* shadowList, int addit ionalOutlineSize, int& shadowLeft, int& shadowRight, int& shadowTop, int& shadow Bottom) | 38 static inline void calculateShadowExtent(const ShadowList* shadowList, float add itionalOutlineSize, float& shadowLeft, float& shadowRight, float& shadowTop, flo at& shadowBottom) |
| 40 { | 39 { |
| 41 ASSERT(shadowList); | 40 ASSERT(shadowList); |
| 42 size_t shadowCount = shadowList->shadows().size(); | 41 size_t shadowCount = shadowList->shadows().size(); |
| 43 for (size_t i = 0; i < shadowCount; ++i) { | 42 for (size_t i = 0; i < shadowCount; ++i) { |
| 44 const ShadowData& shadow = shadowList->shadows()[i]; | 43 const ShadowData& shadow = shadowList->shadows()[i]; |
| 45 if (shadow.style() == Inset) | 44 if (shadow.style() == Inset) |
| 46 continue; | 45 continue; |
| 47 int blurAndSpread = shadow.blur() + shadow.spread() + additionalOutlineS ize; | 46 float blurAndSpread = shadow.blur() + shadow.spread() + additionalOutlin eSize; |
| 48 shadowLeft = std::min(shadow.x() - blurAndSpread, shadowLeft); | 47 shadowLeft = std::min(shadow.x() - blurAndSpread, shadowLeft); |
| 49 shadowRight = std::max(shadow.x() + blurAndSpread, shadowRight); | 48 shadowRight = std::max(shadow.x() + blurAndSpread, shadowRight); |
| 50 shadowTop = std::min(shadow.y() - blurAndSpread, shadowTop); | 49 shadowTop = std::min(shadow.y() - blurAndSpread, shadowTop); |
| 51 shadowBottom = std::max(shadow.y() + blurAndSpread, shadowBottom); | 50 shadowBottom = std::max(shadow.y() + blurAndSpread, shadowBottom); |
| 52 } | 51 } |
| 53 } | 52 } |
| 54 | 53 |
| 55 void ShadowList::adjustRectForShadow(LayoutRect& rect, int additionalOutlineSize ) const | 54 void ShadowList::adjustRectForShadow(LayoutRect& rect, LayoutUnit additionalOutl ineSize) const |
|
cbiesinger
2014/01/15 21:27:40
Turns out we do need both versions; rendering/svg/
| |
| 56 { | 55 { |
| 57 int shadowLeft = 0; | 56 float shadowLeft = 0; |
| 58 int shadowRight = 0; | 57 float shadowRight = 0; |
| 59 int shadowTop = 0; | 58 float shadowTop = 0; |
| 60 int shadowBottom = 0; | 59 float shadowBottom = 0; |
| 61 calculateShadowExtent(this, additionalOutlineSize, shadowLeft, shadowRight, shadowTop, shadowBottom); | 60 calculateShadowExtent(this, additionalOutlineSize, shadowLeft, shadowRight, shadowTop, shadowBottom); |
| 62 | 61 |
| 63 rect.move(shadowLeft, shadowTop); | 62 rect.move(shadowLeft, shadowTop); |
| 64 rect.setWidth(rect.width() - shadowLeft + shadowRight); | 63 rect.setWidth(rect.width() - shadowLeft + shadowRight); |
|
leviw_travelin_and_unemployed
2014/01/14 22:28:35
This seems to just treat the LayoutUnits like floa
cbiesinger
2014/01/15 21:27:40
Changed.
| |
| 65 rect.setHeight(rect.height() - shadowTop + shadowBottom); | 64 rect.setHeight(rect.height() - shadowTop + shadowBottom); |
| 66 } | 65 } |
| 67 | 66 |
| 68 void ShadowList::adjustRectForShadow(FloatRect& rect, int additionalOutlineSize) const | 67 void ShadowList::adjustRectForShadow(FloatRect& rect, float additionalOutlineSiz e) const |
| 69 { | 68 { |
| 70 int shadowLeft = 0; | 69 float shadowLeft = 0; |
| 71 int shadowRight = 0; | 70 float shadowRight = 0; |
| 72 int shadowTop = 0; | 71 float shadowTop = 0; |
| 73 int shadowBottom = 0; | 72 float shadowBottom = 0; |
| 74 calculateShadowExtent(this, additionalOutlineSize, shadowLeft, shadowRight, shadowTop, shadowBottom); | 73 calculateShadowExtent(this, additionalOutlineSize, shadowLeft, shadowRight, shadowTop, shadowBottom); |
| 75 | 74 |
| 76 rect.move(shadowLeft, shadowTop); | 75 rect.move(shadowLeft, shadowTop); |
| 77 rect.setWidth(rect.width() - shadowLeft + shadowRight); | 76 rect.setWidth(rect.width() - shadowLeft + shadowRight); |
| 78 rect.setHeight(rect.height() - shadowTop + shadowBottom); | 77 rect.setHeight(rect.height() - shadowTop + shadowBottom); |
| 79 } | 78 } |
| 80 | 79 |
| 81 PassRefPtr<ShadowList> ShadowList::blend(const ShadowList* from, const ShadowLis t* to, double progress) | 80 PassRefPtr<ShadowList> ShadowList::blend(const ShadowList* from, const ShadowLis t* to, double progress) |
| 82 { | 81 { |
| 83 size_t fromLength = from ? from->shadows().size() : 0; | 82 size_t fromLength = from ? from->shadows().size() : 0; |
| 84 size_t toLength = to ? to->shadows().size() : 0; | 83 size_t toLength = to ? to->shadows().size() : 0; |
| 85 if (!fromLength && !toLength) | 84 if (!fromLength && !toLength) |
| 86 return 0; | 85 return 0; |
| 87 | 86 |
| 88 ShadowDataVector shadows; | 87 ShadowDataVector shadows; |
| 89 | 88 |
| 90 DEFINE_STATIC_LOCAL(ShadowData, defaultShadowData, (IntPoint(), 0, 0, Normal , Color::transparent)); | 89 DEFINE_STATIC_LOCAL(ShadowData, defaultShadowData, (FloatPoint(), 0, 0, Norm al, Color::transparent)); |
| 91 DEFINE_STATIC_LOCAL(ShadowData, defaultInsetShadowData, (IntPoint(), 0, 0, I nset, Color::transparent)); | 90 DEFINE_STATIC_LOCAL(ShadowData, defaultInsetShadowData, (FloatPoint(), 0, 0, Inset, Color::transparent)); |
| 92 | 91 |
| 93 size_t maxLength = std::max(fromLength, toLength); | 92 size_t maxLength = std::max(fromLength, toLength); |
| 94 for (size_t i = 0; i < maxLength; ++i) { | 93 for (size_t i = 0; i < maxLength; ++i) { |
| 95 const ShadowData* fromShadow = i < fromLength ? &from->shadows()[i] : 0; | 94 const ShadowData* fromShadow = i < fromLength ? &from->shadows()[i] : 0; |
| 96 const ShadowData* toShadow = i < toLength ? &to->shadows()[i] : 0; | 95 const ShadowData* toShadow = i < toLength ? &to->shadows()[i] : 0; |
| 97 if (!fromShadow) | 96 if (!fromShadow) |
| 98 fromShadow = toShadow->style() == Inset ? &defaultInsetShadowData : &defaultShadowData; | 97 fromShadow = toShadow->style() == Inset ? &defaultInsetShadowData : &defaultShadowData; |
| 99 else if (!toShadow) | 98 else if (!toShadow) |
| 100 toShadow = fromShadow->style() == Inset ? &defaultInsetShadowData : &defaultShadowData; | 99 toShadow = fromShadow->style() == Inset ? &defaultInsetShadowData : &defaultShadowData; |
| 101 shadows.append(toShadow->blend(*fromShadow, progress)); | 100 shadows.append(toShadow->blend(*fromShadow, progress)); |
| 102 } | 101 } |
| 103 | 102 |
| 104 return ShadowList::adopt(shadows); | 103 return ShadowList::adopt(shadows); |
| 105 } | 104 } |
| 106 | 105 |
| 107 } // namespace WebCore | 106 } // namespace WebCore |
| OLD | NEW |