| 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 18 matching lines...) Expand all Loading... |
| 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 "wtf/OwnPtr.h" | 35 #include "wtf/OwnPtr.h" |
| 36 | 36 |
| 37 namespace blink { | 37 namespace blink { |
| 38 | 38 |
| 39 static inline void calculateShadowExtent(const ShadowList* shadowList, float add
itionalOutlineSize, float& shadowLeft, float& shadowRight, float& shadowTop, flo
at& shadowBottom) | 39 static inline void calculateShadowExtent(const ShadowList* shadowList, float& sh
adowLeft, float& shadowRight, float& shadowTop, float& shadowBottom) |
| 40 { | 40 { |
| 41 ASSERT(shadowList); | 41 ASSERT(shadowList); |
| 42 size_t shadowCount = shadowList->shadows().size(); | 42 size_t shadowCount = shadowList->shadows().size(); |
| 43 for (size_t i = 0; i < shadowCount; ++i) { | 43 for (size_t i = 0; i < shadowCount; ++i) { |
| 44 const ShadowData& shadow = shadowList->shadows()[i]; | 44 const ShadowData& shadow = shadowList->shadows()[i]; |
| 45 if (shadow.style() == Inset) | 45 if (shadow.style() == Inset) |
| 46 continue; | 46 continue; |
| 47 float blurAndSpread = shadow.blur() + shadow.spread() + additionalOutlin
eSize; | 47 float blurAndSpread = shadow.blur() + shadow.spread(); |
| 48 shadowLeft = std::min(shadow.x() - blurAndSpread, shadowLeft); | 48 shadowLeft = std::min(shadow.x() - blurAndSpread, shadowLeft); |
| 49 shadowRight = std::max(shadow.x() + blurAndSpread, shadowRight); | 49 shadowRight = std::max(shadow.x() + blurAndSpread, shadowRight); |
| 50 shadowTop = std::min(shadow.y() - blurAndSpread, shadowTop); | 50 shadowTop = std::min(shadow.y() - blurAndSpread, shadowTop); |
| 51 shadowBottom = std::max(shadow.y() + blurAndSpread, shadowBottom); | 51 shadowBottom = std::max(shadow.y() + blurAndSpread, shadowBottom); |
| 52 } | 52 } |
| 53 } | 53 } |
| 54 | 54 |
| 55 void ShadowList::adjustRectForShadow(LayoutRect& rect, float additionalOutlineSi
ze) const | 55 void ShadowList::adjustRectForShadow(LayoutRect& rect) const |
| 56 { | 56 { |
| 57 FloatRect floatRect(rect); | 57 FloatRect floatRect(rect); |
| 58 adjustRectForShadow(floatRect); | 58 adjustRectForShadow(floatRect); |
| 59 rect = LayoutRect(floatRect); | 59 rect = LayoutRect(floatRect); |
| 60 } | 60 } |
| 61 | 61 |
| 62 void ShadowList::adjustRectForShadow(FloatRect& rect, float additionalOutlineSiz
e) const | 62 void ShadowList::adjustRectForShadow(FloatRect& rect) const |
| 63 { | 63 { |
| 64 float shadowLeft = 0; | 64 float shadowLeft = 0; |
| 65 float shadowRight = 0; | 65 float shadowRight = 0; |
| 66 float shadowTop = 0; | 66 float shadowTop = 0; |
| 67 float shadowBottom = 0; | 67 float shadowBottom = 0; |
| 68 calculateShadowExtent(this, additionalOutlineSize, shadowLeft, shadowRight,
shadowTop, shadowBottom); | 68 calculateShadowExtent(this, shadowLeft, shadowRight, shadowTop, shadowBottom
); |
| 69 | 69 |
| 70 rect.move(shadowLeft, shadowTop); | 70 rect.move(shadowLeft, shadowTop); |
| 71 rect.setWidth(rect.width() - shadowLeft + shadowRight); | 71 rect.setWidth(rect.width() - shadowLeft + shadowRight); |
| 72 rect.setHeight(rect.height() - shadowTop + shadowBottom); | 72 rect.setHeight(rect.height() - shadowTop + shadowBottom); |
| 73 } | 73 } |
| 74 | 74 |
| 75 PassRefPtr<ShadowList> ShadowList::blend(const ShadowList* from, const ShadowLis
t* to, double progress) | 75 PassRefPtr<ShadowList> ShadowList::blend(const ShadowList* from, const ShadowLis
t* to, double progress) |
| 76 { | 76 { |
| 77 size_t fromLength = from ? from->shadows().size() : 0; | 77 size_t fromLength = from ? from->shadows().size() : 0; |
| 78 size_t toLength = to ? to->shadows().size() : 0; | 78 size_t toLength = to ? to->shadows().size() : 0; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 106 float shadowX = isHorizontal ? shadow.x() : shadow.y(); | 106 float shadowX = isHorizontal ? shadow.x() : shadow.y(); |
| 107 float shadowY = isHorizontal ? shadow.y() : -shadow.x(); | 107 float shadowY = isHorizontal ? shadow.y() : -shadow.x(); |
| 108 drawLooperBuilder->addShadow(FloatSize(shadowX, shadowY), shadow.blur(),
shadow.color(), | 108 drawLooperBuilder->addShadow(FloatSize(shadowX, shadowY), shadow.blur(),
shadow.color(), |
| 109 DrawLooperBuilder::ShadowRespectsTransforms, alphaMode); | 109 DrawLooperBuilder::ShadowRespectsTransforms, alphaMode); |
| 110 } | 110 } |
| 111 drawLooperBuilder->addUnmodifiedContent(); | 111 drawLooperBuilder->addUnmodifiedContent(); |
| 112 return drawLooperBuilder.release(); | 112 return drawLooperBuilder.release(); |
| 113 } | 113 } |
| 114 | 114 |
| 115 } // namespace blink | 115 } // namespace blink |
| OLD | NEW |