Changeset 114520 in webkit
- Timestamp:
- Apr 18, 2012 10:05:11 AM (12 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r114519 r114520 1 2012-04-18 Levi Weintraub <leviw@chromium.org> 2 3 Convert ShadowData and DropShadowFilterOperation to use IntPoint 4 https://bugs.webkit.org/show_bug.cgi?id=84098 5 6 Reviewed by Eric Seidel. 7 8 Shadows do not flow with the page, so sub-pixel layout doesn't actually offer any benefit that 9 couldn't have been attained before that conversion. With that in mind, this patch reverts 10 drop shadow offsets to integers, but also cleans up the code by switching the x/y location pair 11 to be an IntPoint. 12 13 No new tests. No change in behavior. 14 15 * css/CSSComputedStyleDeclaration.cpp: 16 (WebCore::CSSComputedStyleDeclaration::valueForFilter): 17 * css/CSSStyleSelector.cpp: 18 (WebCore::CSSStyleSelector::collectMatchingRulesForList): 19 * css/SVGCSSStyleSelector.cpp: 20 (WebCore::CSSStyleSelector::applySVGProperty): 21 * page/animation/AnimationBase.cpp: 22 (WebCore::blendFunc): 23 (WebCore::shadowForBlending): 24 * platform/animation/AnimationUtilities.h: 25 (WebCore::blend): New blend function that operates on IntPoints. 26 (WebCore): 27 * platform/chromium/support/WebFilterOperations.cpp: 28 (WebKit::WebDropShadowFilterOperation): 29 * platform/graphics/filters/FilterOperation.cpp: 30 (WebCore::DropShadowFilterOperation::blend): 31 * platform/graphics/filters/FilterOperation.h: 32 (WebCore::DropShadowFilterOperation::clone): 33 (WebCore::DropShadowFilterOperation::x): 34 (WebCore::DropShadowFilterOperation::y): 35 (WebCore::DropShadowFilterOperation::location): Preserved the comment about lengths. 36 (WebCore::DropShadowFilterOperation::operator==): 37 (WebCore::DropShadowFilterOperation::DropShadowFilterOperation): 38 (DropShadowFilterOperation): 39 * rendering/RenderBoxModelObject.cpp: 40 (WebCore::areaCastingShadowInHole): Reverted to integers since this operates on the IntRect from 41 a RoundedRect. 42 (WebCore::RenderBoxModelObject::paintBoxShadow): Reduced the complexity and unnecessary conversion 43 between LayoutUnits and integers by using all integers after we calculate the pixel-snapped 44 RoundedRect that we use for painting. 45 * rendering/style/RenderStyle.cpp: 46 (WebCore::RenderStyle::getShadowExtent): 47 (WebCore::RenderStyle::getShadowHorizontalExtent): 48 (WebCore::RenderStyle::getShadowVerticalExtent): 49 * rendering/style/ShadowData.cpp: 50 (WebCore::ShadowData::ShadowData): 51 (WebCore::ShadowData::operator==): 52 (WebCore::calculateShadowExtent): 53 (WebCore::ShadowData::adjustRectForShadow): 54 * rendering/style/ShadowData.h: 55 (WebCore::ShadowData::ShadowData): 56 (WebCore::ShadowData::x): 57 (WebCore::ShadowData::y): 58 (WebCore::ShadowData::location): 59 (ShadowData): 60 1 61 2012-04-17 Kentaro Hara <haraken@chromium.org> 2 62 -
trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp
r114470 r114520 826 826 filterValue = WebKitCSSFilterValue::create(WebKitCSSFilterValue::DropShadowFilterOperation); 827 827 // We want our computed style to look like that of a text shadow (has neither spread nor inset style). 828 ShadowData shadowData = ShadowData(dropShadowOperation-> x(), dropShadowOperation->y(), dropShadowOperation->stdDeviation(), 0, Normal, false, dropShadowOperation->color());828 ShadowData shadowData = ShadowData(dropShadowOperation->location(), dropShadowOperation->stdDeviation(), 0, Normal, false, dropShadowOperation->color()); 829 829 filterValue->append(valueForShadow(&shadowData, CSSPropertyTextShadow, style)); 830 830 break; -
trunk/Source/WebCore/css/CSSStyleSelector.cpp
r113922 r114520 3451 3451 color = m_style->color(); 3452 3452 3453 OwnPtr<ShadowData> shadowData = adoptPtr(new ShadowData( x, y, blur, spread, shadowStyle, id == CSSPropertyWebkitBoxShadow, color.isValid() ? color : Color::transparent));3453 OwnPtr<ShadowData> shadowData = adoptPtr(new ShadowData(IntPoint(x, y), blur, spread, shadowStyle, id == CSSPropertyWebkitBoxShadow, color.isValid() ? color : Color::transparent)); 3454 3454 if (id == CSSPropertyTextShadow) 3455 3455 m_style->setTextShadow(shadowData.release(), i.index()); // add to the list if this is not the first entry … … 5715 5715 5716 5716 ShadowValue* item = static_cast<ShadowValue*>(cssValue); 5717 int x = item->x->computeLength<int>(style, rootStyle, zoomFactor);5718 int y = item->y->computeLength<int>(style, rootStyle, zoomFactor);5717 IntPoint location(item->x->computeLength<int>(style, rootStyle, zoomFactor), 5718 item->y->computeLength<int>(style, rootStyle, zoomFactor)); 5719 5719 int blur = item->blur ? item->blur->computeLength<int>(style, rootStyle, zoomFactor) : 0; 5720 5720 Color color; … … 5722 5722 color = colorFromPrimitiveValue(item->color.get()); 5723 5723 5724 operations.operations().append(DropShadowFilterOperation::create( x, y, blur, color.isValid() ? color : Color::transparent, operationType));5724 operations.operations().append(DropShadowFilterOperation::create(location, blur, color.isValid() ? color : Color::transparent, operationType)); 5725 5725 break; 5726 5726 } -
trunk/Source/WebCore/css/SVGCSSStyleSelector.cpp
r113031 r114520 572 572 return; 573 573 ShadowValue* item = static_cast<ShadowValue*>(firstValue); 574 int x = item->x->computeLength<int>(style(), m_rootElementStyle);575 int y = item->y->computeLength<int>(style(), m_rootElementStyle);574 IntPoint location(item->x->computeLength<int>(style(), m_rootElementStyle), 575 item->y->computeLength<int>(style(), m_rootElementStyle)); 576 576 int blur = item->blur ? item->blur->computeLength<int>(style(), m_rootElementStyle) : 0; 577 577 Color color; … … 583 583 ASSERT(!item->style); 584 584 585 OwnPtr<ShadowData> shadowData = adoptPtr(new ShadowData( x, y, blur, 0, Normal, false, color.isValid() ? color : Color::transparent));585 OwnPtr<ShadowData> shadowData = adoptPtr(new ShadowData(location, blur, 0, Normal, false, color.isValid() ? color : Color::transparent)); 586 586 svgstyle->setShadow(shadowData.release()); 587 587 return; -
trunk/Source/WebCore/page/animation/AnimationBase.cpp
r114437 r114520 136 136 return adoptPtr(new ShadowData(*to)); 137 137 138 return adoptPtr(new ShadowData(blend(from->x(), to->x(), progress), 139 blend(from->y(), to->y(), progress), 138 return adoptPtr(new ShadowData(blend(from->location(), to->location(), progress), 140 139 blend(from->blur(), to->blur(), progress), 141 140 blend(from->spread(), to->spread(), progress), … … 495 494 static inline const ShadowData* shadowForBlending(const ShadowData* srcShadow, const ShadowData* otherShadow) 496 495 { 497 DEFINE_STATIC_LOCAL(ShadowData, defaultShadowData, ( 0, 0, 0, 0, Normal, false, Color::transparent));498 DEFINE_STATIC_LOCAL(ShadowData, defaultInsetShadowData, ( 0, 0, 0, 0, Inset, false, Color::transparent));499 500 DEFINE_STATIC_LOCAL(ShadowData, defaultWebKitBoxShadowData, ( 0, 0, 0, 0, Normal, true, Color::transparent));501 DEFINE_STATIC_LOCAL(ShadowData, defaultInsetWebKitBoxShadowData, ( 0, 0, 0, 0, Inset, true, Color::transparent));496 DEFINE_STATIC_LOCAL(ShadowData, defaultShadowData, (IntPoint(), 0, 0, Normal, false, Color::transparent)); 497 DEFINE_STATIC_LOCAL(ShadowData, defaultInsetShadowData, (IntPoint(), 0, 0, Inset, false, Color::transparent)); 498 499 DEFINE_STATIC_LOCAL(ShadowData, defaultWebKitBoxShadowData, (IntPoint(), 0, 0, Normal, true, Color::transparent)); 500 DEFINE_STATIC_LOCAL(ShadowData, defaultInsetWebKitBoxShadowData, (IntPoint(), 0, 0, Inset, true, Color::transparent)); 502 501 503 502 if (srcShadow) -
trunk/Source/WebCore/platform/animation/AnimationUtilities.h
r111362 r114520 28 28 29 29 #include "FractionalLayoutUnit.h" 30 #include "IntPoint.h" 30 31 #include <wtf/MathExtras.h> 31 32 … … 57 58 } 58 59 60 inline IntPoint blend(const IntPoint& from, const IntPoint& to, double progress) 61 { 62 return IntPoint(blend(from.x(), to.x(), progress), 63 blend(from.y(), to.y(), progress)); 64 } 65 59 66 } // namespace WebCore 60 67 -
trunk/Source/WebCore/platform/chromium/support/WebFilterOperation.cpp
r114343 r114520 51 51 PassRefPtr<WebCore::FilterOperation> WebDropShadowFilterOperation::toFilterOperation() const 52 52 { 53 return DropShadowFilterOperation::create( x, y, stdDeviation, color, FilterOperation::DROP_SHADOW);53 return DropShadowFilterOperation::create(IntPoint(x, y), stdDeviation, color, FilterOperation::DROP_SHADOW); 54 54 } 55 55 -
trunk/Source/WebCore/platform/graphics/filters/FilterOperation.cpp
r103586 r114520 134 134 if (blendToPassthrough) 135 135 return DropShadowFilterOperation::create( 136 WebCore::blend(m_x, 0, progress), 137 WebCore::blend(m_y, 0, progress), 136 WebCore::blend(m_location, IntPoint(), progress), 138 137 WebCore::blend(m_stdDeviation, 0, progress), 139 138 WebCore::blend(m_color, Color(Color::transparent), progress), … … 141 140 142 141 const DropShadowFilterOperation* fromOp = static_cast<const DropShadowFilterOperation*>(from); 143 int fromX = fromOp ? fromOp->x() : 0; 144 int fromY = fromOp ? fromOp->y() : 0; 142 IntPoint fromLocation = fromOp ? fromOp->location() : IntPoint(); 145 143 int fromStdDeviation = fromOp ? fromOp->stdDeviation() : 0; 146 144 Color fromColor = fromOp ? fromOp->color() : Color(Color::transparent); 147 145 148 146 return DropShadowFilterOperation::create( 149 WebCore::blend(fromX, m_x, progress), 150 WebCore::blend(fromY, m_y, progress), 147 WebCore::blend(fromLocation, m_location, progress), 151 148 WebCore::blend(fromStdDeviation, m_stdDeviation, progress), 152 149 WebCore::blend(fromColor, m_color, progress), m_type); -
trunk/Source/WebCore/platform/graphics/filters/FilterOperation.h
r112187 r114520 339 339 class DropShadowFilterOperation : public FilterOperation { 340 340 public: 341 static PassRefPtr<DropShadowFilterOperation> create(int x, int y, int stdDeviation, Color color, OperationType type) 342 { 343 return adoptRef(new DropShadowFilterOperation(x, y, stdDeviation, color, type)); 344 } 345 346 virtual PassRefPtr<FilterOperation> clone() const 347 { 348 return adoptRef(new DropShadowFilterOperation(m_x, m_y, m_stdDeviation, m_color, m_type)); 349 } 350 351 int x() const { return m_x; } 352 int y() const { return m_y; } 341 static PassRefPtr<DropShadowFilterOperation> create(const IntPoint& location, int stdDeviation, Color color, OperationType type) 342 { 343 return adoptRef(new DropShadowFilterOperation(location, stdDeviation, color, type)); 344 } 345 346 virtual PassRefPtr<FilterOperation> clone() const 347 { 348 return adoptRef(new DropShadowFilterOperation(m_location, m_stdDeviation, m_color, m_type)); 349 } 350 351 int x() const { return m_location.x(); } 352 int y() const { return m_location.y(); } 353 IntPoint location() const { return m_location; } 353 354 int stdDeviation() const { return m_stdDeviation; } 354 355 Color color() const { return m_color; } … … 366 367 return false; 367 368 const DropShadowFilterOperation* other = static_cast<const DropShadowFilterOperation*>(&o); 368 return m_x == other->m_x && m_y == other->m_y && m_stdDeviation == other->m_stdDeviation && m_color == other->m_color; 369 } 370 371 DropShadowFilterOperation(int x, int y, int stdDeviation, Color color, OperationType type) 372 : FilterOperation(type) 373 , m_x(x) 374 , m_y(y) 369 return m_location == other->m_location && m_stdDeviation == other->m_stdDeviation && m_color == other->m_color; 370 } 371 372 DropShadowFilterOperation(const IntPoint& location, int stdDeviation, Color color, OperationType type) 373 : FilterOperation(type) 374 , m_location(location) 375 375 , m_stdDeviation(stdDeviation) 376 376 , m_color(color) … … 378 378 } 379 379 380 int m_x; // FIXME: x and y should be Lengths? 381 int m_y; 380 IntPoint m_location; // FIXME: should location be in Lengths? 382 381 int m_stdDeviation; 383 382 Color m_color; -
trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp
r114470 r114520 2815 2815 } 2816 2816 2817 static inline LayoutRect areaCastingShadowInHole(const LayoutRect& holeRect, int shadowBlur, int shadowSpread, const LayoutSize& shadowOffset)2818 { 2819 LayoutRect bounds(holeRect);2817 static inline IntRect areaCastingShadowInHole(const IntRect& holeRect, int shadowBlur, int shadowSpread, const IntSize& shadowOffset) 2818 { 2819 IntRect bounds(holeRect); 2820 2820 2821 2821 bounds.inflate(shadowBlur); … … 2824 2824 bounds.inflate(-shadowSpread); 2825 2825 2826 LayoutRect offsetBounds = bounds;2826 IntRect offsetBounds = bounds; 2827 2827 offsetBounds.move(-shadowOffset); 2828 2828 return unionRect(bounds, offsetBounds); … … 2847 2847 continue; 2848 2848 2849 LayoutSize shadowOffset(shadow->x(), shadow->y());2850 LayoutUnit shadowBlur = shadow->blur();2851 LayoutUnit shadowSpread = shadow->spread();2849 IntSize shadowOffset(shadow->x(), shadow->y()); 2850 int shadowBlur = shadow->blur(); 2851 int shadowSpread = shadow->spread(); 2852 2852 2853 2853 if (shadowOffset.isZero() && !shadowBlur && !shadowSpread) … … 2862 2862 continue; 2863 2863 2864 LayoutRect shadowRect(border.rect());2864 IntRect shadowRect(border.rect()); 2865 2865 shadowRect.inflate(shadowBlur + shadowSpread); 2866 2866 shadowRect.move(shadowOffset); … … 2871 2871 // Move the fill just outside the clip, adding 1 pixel separation so that the fill does not 2872 2872 // bleed in (due to antialiasing) if the context is transformed. 2873 LayoutSize extraOffset(paintRect.width() + max<LayoutUnit>(0, shadowOffset.width()) + shadowBlur + 2 * shadowSpread + 1, 0);2873 IntSize extraOffset(paintRect.pixelSnappedWidth() + max(0, shadowOffset.width()) + shadowBlur + 2 * shadowSpread + 1, 0); 2874 2874 shadowOffset -= extraOffset; 2875 2875 fillRect.move(extraOffset); … … 2902 2902 } 2903 2903 } else { 2904 LayoutRect rectToClipOut = border.rect();2904 IntRect rectToClipOut = border.rect(); 2905 2905 2906 2906 // If the box is opaque, it is unnecessary to clip it out. However, doing so saves time … … 2917 2917 2918 2918 if (!rectToClipOut.isEmpty()) 2919 context->clipOut( pixelSnappedIntRect(rectToClipOut));2919 context->clipOut(rectToClipOut); 2920 2920 context->fillRect(fillRect.rect(), Color::black, s->colorSpace()); 2921 2921 } 2922 2922 } else { 2923 2923 // Inset shadow. 2924 LayoutRect holeRect(border.rect());2924 IntRect holeRect(border.rect()); 2925 2925 holeRect.inflate(-shadowSpread); 2926 2926 … … 2935 2935 if (!includeLogicalLeftEdge) { 2936 2936 if (isHorizontal) { 2937 holeRect.move(-max <LayoutUnit>(shadowOffset.width(), 0) - shadowBlur, 0);2938 holeRect.setWidth(holeRect.width() + max <LayoutUnit>(shadowOffset.width(), 0) + shadowBlur);2937 holeRect.move(-max(shadowOffset.width(), 0) - shadowBlur, 0); 2938 holeRect.setWidth(holeRect.width() + max(shadowOffset.width(), 0) + shadowBlur); 2939 2939 } else { 2940 holeRect.move(0, -max <LayoutUnit>(shadowOffset.height(), 0) - shadowBlur);2941 holeRect.setHeight(holeRect.height() + max <LayoutUnit>(shadowOffset.height(), 0) + shadowBlur);2940 holeRect.move(0, -max(shadowOffset.height(), 0) - shadowBlur); 2941 holeRect.setHeight(holeRect.height() + max(shadowOffset.height(), 0) + shadowBlur); 2942 2942 } 2943 2943 } … … 2951 2951 Color fillColor(shadowColor.red(), shadowColor.green(), shadowColor.blue(), 255); 2952 2952 2953 LayoutRect outerRect = areaCastingShadowInHole(border.rect(), shadowBlur, shadowSpread, shadowOffset);2954 RoundedRect roundedHole( pixelSnappedIntRect(holeRect), border.radii());2953 IntRect outerRect = areaCastingShadowInHole(border.rect(), shadowBlur, shadowSpread, shadowOffset); 2954 RoundedRect roundedHole(holeRect, border.radii()); 2955 2955 2956 2956 GraphicsContextStateSaver stateSaver(*context); … … 2963 2963 context->clip(border.rect()); 2964 2964 2965 LayoutSize extraOffset(2 * paintRect.width() + max<LayoutUnit>(0, shadowOffset.width()) + shadowBlur - 2 * shadowSpread + 1, 0);2965 IntSize extraOffset(2 * paintRect.pixelSnappedWidth() + max(0, shadowOffset.width()) + shadowBlur - 2 * shadowSpread + 1, 0); 2966 2966 context->translate(extraOffset.width(), extraOffset.height()); 2967 2967 shadowOffset -= extraOffset; … … 2972 2972 context->setShadow(shadowOffset, shadowBlur, shadowColor, s->colorSpace()); 2973 2973 2974 context->fillRectWithRoundedHole( pixelSnappedIntRect(outerRect), roundedHole, fillColor, s->colorSpace());2974 context->fillRectWithRoundedHole(outerRect, roundedHole, fillColor, s->colorSpace()); 2975 2975 } 2976 2976 } -
trunk/Source/WebCore/rendering/style/RenderStyle.cpp
r114470 r114520 1170 1170 int blurAndSpread = shadow->blur() + shadow->spread(); 1171 1171 1172 top = min (top, shadow->y() - blurAndSpread);1173 right = max (right, shadow->x() + blurAndSpread);1174 bottom = max (bottom, shadow->y() + blurAndSpread);1175 left = min (left, shadow->x() - blurAndSpread);1172 top = min<LayoutUnit>(top, shadow->y() - blurAndSpread); 1173 right = max<LayoutUnit>(right, shadow->x() + blurAndSpread); 1174 bottom = max<LayoutUnit>(bottom, shadow->y() + blurAndSpread); 1175 left = min<LayoutUnit>(left, shadow->x() - blurAndSpread); 1176 1176 } 1177 1177 } … … 1187 1187 int blurAndSpread = shadow->blur() + shadow->spread(); 1188 1188 1189 left = min (left, shadow->x() - blurAndSpread);1190 right = max (right, shadow->x() + blurAndSpread);1189 left = min<LayoutUnit>(left, shadow->x() - blurAndSpread); 1190 right = max<LayoutUnit>(right, shadow->x() + blurAndSpread); 1191 1191 } 1192 1192 } … … 1202 1202 int blurAndSpread = shadow->blur() + shadow->spread(); 1203 1203 1204 top = min (top, shadow->y() - blurAndSpread);1205 bottom = max (bottom, shadow->y() + blurAndSpread);1204 top = min<LayoutUnit>(top, shadow->y() - blurAndSpread); 1205 bottom = max<LayoutUnit>(bottom, shadow->y() + blurAndSpread); 1206 1206 } 1207 1207 } -
trunk/Source/WebCore/rendering/style/ShadowData.cpp
r113222 r114520 28 28 29 29 ShadowData::ShadowData(const ShadowData& o) 30 : m_x(o.m_x) 31 , m_y(o.m_y) 30 : m_location(o.m_location) 32 31 , m_blur(o.m_blur) 33 32 , m_spread(o.m_spread) … … 45 44 return false; 46 45 47 return m_x == o.m_x 48 && m_y == o.m_y 46 return m_location == o.m_location 49 47 && m_blur == o.m_blur 50 48 && m_spread == o.m_spread … … 54 52 } 55 53 56 static inline void calculateShadowExtent(const ShadowData* shadow, int additionalOutlineSize, LayoutUnit& shadowLeft, LayoutUnit& shadowRight, LayoutUnit& shadowTop, LayoutUnit& shadowBottom)54 static inline void calculateShadowExtent(const ShadowData* shadow, int additionalOutlineSize, int& shadowLeft, int& shadowRight, int& shadowTop, int& shadowBottom) 57 55 { 58 56 do { … … 71 69 void ShadowData::adjustRectForShadow(LayoutRect& rect, int additionalOutlineSize) const 72 70 { 73 LayoutUnit shadowLeft = 0;74 LayoutUnit shadowRight = 0;75 LayoutUnit shadowTop = 0;76 LayoutUnit shadowBottom = 0;71 int shadowLeft = 0; 72 int shadowRight = 0; 73 int shadowTop = 0; 74 int shadowBottom = 0; 77 75 calculateShadowExtent(this, additionalOutlineSize, shadowLeft, shadowRight, shadowTop, shadowBottom); 78 76 … … 84 82 void ShadowData::adjustRectForShadow(FloatRect& rect, int additionalOutlineSize) const 85 83 { 86 LayoutUnit shadowLeft = 0;87 LayoutUnit shadowRight = 0;88 LayoutUnit shadowTop = 0;89 LayoutUnit shadowBottom = 0;84 int shadowLeft = 0; 85 int shadowRight = 0; 86 int shadowTop = 0; 87 int shadowBottom = 0; 90 88 calculateShadowExtent(this, additionalOutlineSize, shadowLeft, shadowRight, shadowTop, shadowBottom); 91 89 -
trunk/Source/WebCore/rendering/style/ShadowData.h
r113222 r114520 41 41 public: 42 42 ShadowData() 43 : m_x(0) 44 , m_y(0) 45 , m_blur(0) 43 : m_blur(0) 46 44 , m_spread(0) 47 45 , m_style(Normal) … … 50 48 } 51 49 52 ShadowData(LayoutUnit x, LayoutUnit y, int blur, int spread, ShadowStyle style, bool isWebkitBoxShadow, const Color& color) 53 : m_x(x) 54 , m_y(y) 50 ShadowData(const IntPoint& location, int blur, int spread, ShadowStyle style, bool isWebkitBoxShadow, const Color& color) 51 : m_location(location) 55 52 , m_blur(blur) 56 53 , m_spread(spread) … … 69 66 } 70 67 71 LayoutUnit x() const { return m_x; } 72 LayoutUnit y() const { return m_y; } 68 int x() const { return m_location.x(); } 69 int y() const { return m_location.y(); } 70 IntPoint location() const { return m_location; } 73 71 int blur() const { return m_blur; } 74 72 int spread() const { return m_spread; } … … 84 82 85 83 private: 86 LayoutUnit m_x; 87 LayoutUnit m_y; 84 IntPoint m_location; 88 85 int m_blur; 89 86 int m_spread;
Note: See TracChangeset
for help on using the changeset viewer.