Changeset 46295 in webkit
- Timestamp:
- Jul 23, 2009, 4:00:41 PM (16 years ago)
- Location:
- trunk
- Files:
-
- 4 added
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r46290 r46295 1 2009-07-23 Dan Bernstein <mitz@apple.com> 2 3 Reviewed by Dave Hyatt. 4 5 [CSS3 Backgrounds and Borders] Add support for inset box shadows 6 https://bugs.webkit.org/show_bug.cgi?id=27582 7 8 * fast/box-shadow/inset.html: Added. 9 * platform/mac/fast/box-shadow/inset-expected.checksum: Added. 10 * platform/mac/fast/box-shadow/inset-expected.png: Added. 11 * platform/mac/fast/box-shadow/inset-expected.txt: Added. 12 1 13 2009-07-23 Mark Rowe <mrowe@apple.com> 2 14 -
trunk/WebCore/ChangeLog
r46293 r46295 1 2009-07-23 Dan Bernstein <mitz@apple.com> 2 3 Reviewed by Dave Hyatt. 4 5 [CSS3 Backgrounds and Borders] Add support for inset box shadows 6 https://bugs.webkit.org/show_bug.cgi?id=27582 7 8 Test: fast/box-shadow/inset.html 9 10 * css/CSSComputedStyleDeclaration.cpp: 11 (WebCore::valueForShadow): Set the ShadowValue’s shadow style to 'inset' 12 as needed. 13 14 * css/CSSParser.cpp: 15 (WebCore::ShadowParseContext::ShadowParseContext): Added style and allowStyle 16 members. Initialize the allowStyle member. 17 (WebCore::ShadowParseContext::commitValue): Pass the style value to the 18 ShadowValue constructor. Reset allowStyle. 19 (WebCore::ShadowParseContext::commitLength): Update allowStyle. 20 (WebCore::ShadowParseContext::commitColor): Ditto. 21 (WebCore::ShadowParseContext::commitStyle): Added. Sets the style member and 22 updates the state. 23 (WebCore::CSSParser::parseShadow): Parse the 'inset' keyword. 24 25 * css/CSSStyleSelector.cpp: 26 (WebCore::CSSStyleSelector::applyProperty): Get the style value from the 27 shadow value and pass it to the ShadowData constructor. 28 29 * css/ShadowValue.cpp: 30 (WebCore::ShadowValue::ShadowValue): Added style. 31 (WebCore::ShadowValue::cssText): Added style. 32 33 * css/ShadowValue.h: 34 (WebCore::ShadowValue::create): Added style. 35 36 * page/animation/AnimationBase.cpp: 37 (WebCore::blendFunc): Added a blend function for shadow styles. When blending 38 between normal and inset shadows, all intermediate values map to normal. 39 (WebCore::PropertyWrapperShadow::blend): Added normal style to the default 40 shadow. 41 42 * rendering/InlineFlowBox.cpp: 43 (WebCore::InlineFlowBox::paintBoxShadow): Added a shadow style parameter, 44 which is passed through to RenderBoxModelObject::paintBoxShadow(). 45 46 (WebCore::InlineFlowBox::paintBoxDecorations): Paint inset shadows on top of 47 the background. 48 49 * rendering/InlineFlowBox.h: 50 51 * rendering/RenderBox.cpp: 52 (WebCore::RenderBox::paintBoxDecorations): Paint inset shadows on top of the 53 background. 54 55 * rendering/RenderBoxModelObject.cpp: 56 (WebCore::RenderBoxModelObject::paintBoxShadow): Added a shadow style 57 parameter, and code to paint inset shadows. 58 59 * rendering/RenderBoxModelObject.h: 60 61 * rendering/RenderFieldset.cpp: 62 (WebCore::RenderFieldset::paintBoxDecorations): Paint inset shadows on top of 63 the background. 64 65 * rendering/RenderTable.cpp: 66 (WebCore::RenderTable::paintBoxDecorations): Ditto. 67 68 * rendering/RenderTableCell.cpp: 69 (WebCore::RenderTableCell::paintBoxDecorations): Ditto. 70 71 * rendering/style/ShadowData.h: 72 Added a ShadowStyle enum. 73 (WebCore::ShadowData::ShadowData): Add and initialize a style member. 74 1 75 2009-07-23 Simon Fraser <simon.fraser@apple.com> 2 76 -
trunk/WebCore/css/CSSComputedStyleDeclaration.cpp
r46285 r46295 276 276 RefPtr<CSSPrimitiveValue> blur = CSSPrimitiveValue::create(s->blur, CSSPrimitiveValue::CSS_PX); 277 277 RefPtr<CSSPrimitiveValue> spread = propertyID == CSSPropertyTextShadow ? 0 : CSSPrimitiveValue::create(s->spread, CSSPrimitiveValue::CSS_PX); 278 RefPtr<CSSPrimitiveValue> style = propertyID == CSSPropertyTextShadow || s->style == Normal ? 0 : CSSPrimitiveValue::createIdentifier(CSSValueInset); 278 279 RefPtr<CSSPrimitiveValue> color = CSSPrimitiveValue::createColor(s->color.rgb()); 279 list->prepend(ShadowValue::create(x.release(), y.release(), blur.release(), spread.release(), color.release()));280 list->prepend(ShadowValue::create(x.release(), y.release(), blur.release(), spread.release(), style.release(), color.release())); 280 281 } 281 282 return list.release(); -
trunk/WebCore/css/CSSParser.cpp
r46281 r46295 3487 3487 , allowSpread(false) 3488 3488 , allowColor(true) 3489 , allowStyle(prop == CSSPropertyBoxShadow) 3489 3490 , allowBreak(true) 3490 3491 { … … 3496 3497 { 3497 3498 // Handle the ,, case gracefully by doing nothing. 3498 if (x || y || blur || spread || color ) {3499 if (x || y || blur || spread || color || style) { 3499 3500 if (!values) 3500 3501 values = CSSValueList::createCommaSeparated(); 3501 3502 3502 3503 // Construct the current shadow value and add it to the list. 3503 values->append(ShadowValue::create(x.release(), y.release(), blur.release(), spread.release(), color.release()));3504 values->append(ShadowValue::create(x.release(), y.release(), blur.release(), spread.release(), style.release(), color.release())); 3504 3505 } 3505 3506 … … 3509 3510 blur = 0; 3510 3511 spread = 0; 3512 style = 0; 3511 3513 color = 0; 3512 3514 … … 3516 3518 allowY = false; 3517 3519 allowBlur = false; 3518 allowSpread = false; 3520 allowSpread = false; 3521 allowStyle = property == CSSPropertyBoxShadow; 3519 3522 } 3520 3523 … … 3528 3531 allowY = true; 3529 3532 allowColor = false; 3533 allowStyle = false; 3530 3534 allowBreak = false; 3531 3535 } else if (allowY) { … … 3534 3538 allowBlur = true; 3535 3539 allowColor = true; 3540 allowStyle = property == CSSPropertyBoxShadow; 3536 3541 allowBreak = true; 3537 3542 } else if (allowBlur) { … … 3549 3554 color = val; 3550 3555 allowColor = false; 3556 if (allowX) { 3557 allowStyle = false; 3558 allowBreak = false; 3559 } else { 3560 allowBlur = false; 3561 allowSpread = false; 3562 allowStyle = property == CSSPropertyBoxShadow; 3563 } 3564 } 3565 3566 void commitStyle(CSSParserValue* v) 3567 { 3568 style = CSSPrimitiveValue::createIdentifier(v->id); 3569 allowStyle = false; 3551 3570 if (allowX) 3552 3571 allowBreak = false; … … 3554 3573 allowBlur = false; 3555 3574 allowSpread = false; 3575 allowColor = false; 3556 3576 } 3557 3577 } … … 3564 3584 RefPtr<CSSPrimitiveValue> blur; 3565 3585 RefPtr<CSSPrimitiveValue> spread; 3586 RefPtr<CSSPrimitiveValue> style; 3566 3587 RefPtr<CSSPrimitiveValue> color; 3567 3588 … … 3571 3592 bool allowSpread; 3572 3593 bool allowColor; 3594 bool allowStyle; 3573 3595 bool allowBreak; 3574 3596 }; … … 3595 3617 // A length is allowed here. Construct the value and add it. 3596 3618 context.commitLength(val); 3619 } else if (val->id == CSSValueInset) { 3620 if (!context.allowStyle) 3621 return false; 3622 3623 context.commitStyle(val); 3597 3624 } else { 3598 3625 // The only other type of value that's ok is a color value. -
trunk/WebCore/css/CSSStyleSelector.cpp
r46281 r46295 3 3 * (C) 2004-2005 Allan Sandfeld Jensen (kde@carewolf.com) 4 4 * Copyright (C) 2006, 2007 Nicholas Shanks (webkit@nickshanks.com) 5 * Copyright (C) 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.5 * Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. 6 6 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> 7 7 * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org> … … 4543 4543 int blur = item->blur ? item->blur->computeLengthInt(style(), m_rootElementStyle, zoomFactor) : 0; 4544 4544 int spread = item->spread ? item->spread->computeLengthInt(style(), m_rootElementStyle, zoomFactor) : 0; 4545 ShadowStyle shadowStyle = item->style && item->style->getIdent() == CSSValueInset ? Inset : Normal; 4545 4546 Color color; 4546 4547 if (item->color) 4547 4548 color = getColorFromPrimitiveValue(item->color.get()); 4548 ShadowData* shadowData = new ShadowData(x, y, blur, spread, color.isValid() ? color : Color::transparent);4549 ShadowData* shadowData = new ShadowData(x, y, blur, spread, shadowStyle, color.isValid() ? color : Color::transparent); 4549 4550 if (id == CSSPropertyTextShadow) 4550 4551 m_style->setTextShadow(shadowData, i != 0); -
trunk/WebCore/css/ShadowValue.cpp
r46097 r46295 3 3 * 4 4 * (C) 1999-2003 Lars Knoll (knoll@kde.org) 5 * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc.5 * Copyright (C) 2004, 2005, 2006, 2009 Apple Computer, Inc. 6 6 * 7 7 * This library is free software; you can redistribute it and/or … … 33 33 PassRefPtr<CSSPrimitiveValue> _blur, 34 34 PassRefPtr<CSSPrimitiveValue> _spread, 35 PassRefPtr<CSSPrimitiveValue> _style, 35 36 PassRefPtr<CSSPrimitiveValue> _color) 36 37 : x(_x) … … 38 39 , blur(_blur) 39 40 , spread(_spread) 41 , style(_style) 40 42 , color(_color) 41 43 { … … 68 70 text += spread->cssText(); 69 71 } 72 if (style) { 73 if (!text.isEmpty()) 74 text += " "; 75 text += style->cssText(); 76 } 70 77 71 78 return text; -
trunk/WebCore/css/ShadowValue.h
r46097 r46295 1 1 /* 2 2 * (C) 1999-2003 Lars Knoll (knoll@kde.org) 3 * Copyright (C) 2004, 2005, 2006, 2008 Apple Inc. All rights reserved.3 * Copyright (C) 2004, 2005, 2006, 2008, 2009 Apple Inc. All rights reserved. 4 4 * 5 5 * This library is free software; you can redistribute it and/or … … 37 37 PassRefPtr<CSSPrimitiveValue> blur, 38 38 PassRefPtr<CSSPrimitiveValue> spread, 39 PassRefPtr<CSSPrimitiveValue> style, 39 40 PassRefPtr<CSSPrimitiveValue> color) 40 41 { 41 return adoptRef(new ShadowValue(x, y, blur, spread, color));42 return adoptRef(new ShadowValue(x, y, blur, spread, style, color)); 42 43 } 43 44 … … 48 49 RefPtr<CSSPrimitiveValue> blur; 49 50 RefPtr<CSSPrimitiveValue> spread; 51 RefPtr<CSSPrimitiveValue> style; 50 52 RefPtr<CSSPrimitiveValue> color; 51 53 … … 55 57 PassRefPtr<CSSPrimitiveValue> blur, 56 58 PassRefPtr<CSSPrimitiveValue> spread, 59 PassRefPtr<CSSPrimitiveValue> style, 57 60 PassRefPtr<CSSPrimitiveValue> color); 58 61 }; -
trunk/WebCore/page/animation/AnimationBase.cpp
r46274 r46295 1 1 /* 2 * Copyright (C) 2007 Apple Inc. All rights reserved.2 * Copyright (C) 2007, 2008, 2009 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 114 114 } 115 115 116 static inline ShadowStyle blendFunc(const AnimationBase* anim, ShadowStyle from, ShadowStyle to, double progress) 117 { 118 if (from == to) 119 return to; 120 121 double fromVal = from == Normal ? 1 : 0; 122 double toVal = to == Normal ? 1 : 0; 123 double result = blendFunc(anim, fromVal, toVal, progress); 124 return result > 0 ? Normal : Inset; 125 } 126 116 127 static inline ShadowData* blendFunc(const AnimationBase* anim, const ShadowData* from, const ShadowData* to, double progress) 117 128 { … … 119 130 return new ShadowData(blendFunc(anim, from->x, to->x, progress), blendFunc(anim, from->y, to->y, progress), 120 131 blendFunc(anim, from->blur, to->blur, progress), blendFunc(anim, from->spread, to->spread, progress), 121 blendFunc(anim, from-> color, to->color, progress));132 blendFunc(anim, from->style, to->style, progress), blendFunc(anim, from->color, to->color, progress)); 122 133 } 123 134 … … 302 313 ShadowData* shadowA = (a->*m_getter)(); 303 314 ShadowData* shadowB = (b->*m_getter)(); 304 ShadowData defaultShadowData(0, 0, 0, 0, Color::transparent);315 ShadowData defaultShadowData(0, 0, 0, 0, Normal, Color::transparent); 305 316 306 317 if (!shadowA) -
trunk/WebCore/rendering/InlineFlowBox.cpp
r46097 r46295 1 1 /* 2 * Copyright (C) 2003, 2004, 2005, 2006, 2007 Apple Inc. All rights reserved.2 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. 3 3 * 4 4 * This library is free software; you can redistribute it and/or … … 697 697 } 698 698 699 void InlineFlowBox::paintBoxShadow(GraphicsContext* context, RenderStyle* s, int tx, int ty, int w, int h)699 void InlineFlowBox::paintBoxShadow(GraphicsContext* context, RenderStyle* s, ShadowStyle shadowStyle, int tx, int ty, int w, int h) 700 700 { 701 701 if ((!prevLineBox() && !nextLineBox()) || !parent()) 702 boxModelObject()->paintBoxShadow(context, tx, ty, w, h, s );702 boxModelObject()->paintBoxShadow(context, tx, ty, w, h, s, shadowStyle); 703 703 else { 704 704 // FIXME: We can do better here in the multi-line case. We want to push a clip so that the shadow doesn't 705 705 // protrude incorrectly at the edges, and we want to possibly include shadows cast from the previous/following lines 706 boxModelObject()->paintBoxShadow(context, tx, ty, w, h, s, includeLeftEdge(), includeRightEdge());706 boxModelObject()->paintBoxShadow(context, tx, ty, w, h, s, shadowStyle, includeLeftEdge(), includeRightEdge()); 707 707 } 708 708 } … … 728 728 // Shadow comes first and is behind the background and border. 729 729 if (styleToUse->boxShadow()) 730 paintBoxShadow(context, styleToUse, tx, ty, w, h);730 paintBoxShadow(context, styleToUse, Normal, tx, ty, w, h); 731 731 732 732 Color c = styleToUse->backgroundColor(); 733 733 paintFillLayers(paintInfo, c, styleToUse->backgroundLayers(), tx, ty, w, h); 734 735 if (styleToUse->boxShadow()) 736 paintBoxShadow(context, styleToUse, Inset, tx, ty, w, h); 734 737 735 738 // :first-line cannot be used to put borders on a line. Always paint borders with our -
trunk/WebCore/rendering/InlineFlowBox.h
r45702 r46295 90 90 void paintFillLayers(const RenderObject::PaintInfo&, const Color&, const FillLayer*, int tx, int ty, int w, int h, CompositeOperator = CompositeSourceOver); 91 91 void paintFillLayer(const RenderObject::PaintInfo&, const Color&, const FillLayer*, int tx, int ty, int w, int h, CompositeOperator = CompositeSourceOver); 92 void paintBoxShadow(GraphicsContext*, RenderStyle*, int tx, int ty, int w, int h);92 void paintBoxShadow(GraphicsContext*, RenderStyle*, ShadowStyle, int tx, int ty, int w, int h); 93 93 virtual void paintTextDecorations(RenderObject::PaintInfo&, int tx, int ty, bool paintedChildren = false); 94 94 virtual void paint(RenderObject::PaintInfo&, int tx, int ty); -
trunk/WebCore/rendering/RenderBox.cpp
r45624 r46295 4 4 * (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com) 5 5 * (C) 2005, 2006 Samuel Weinig (sam.weinig@gmail.com) 6 * Copyright (C) 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.6 * Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. 7 7 * 8 8 * This library is free software; you can redistribute it and/or … … 608 608 // FIXME: Should eventually give the theme control over whether the box shadow should paint, since controls could have 609 609 // custom shadows of their own. 610 paintBoxShadow(paintInfo.context, tx, ty, w, h, style() );610 paintBoxShadow(paintInfo.context, tx, ty, w, h, style(), Normal); 611 611 612 612 // If we have a native theme appearance, paint that before painting our background. … … 622 622 theme()->paintDecorations(this, paintInfo, IntRect(tx, ty, w, h)); 623 623 } 624 paintBoxShadow(paintInfo.context, tx, ty, w, h, style(), Inset); 624 625 625 626 // The theme will tell us whether or not we should also paint the CSS border. -
trunk/WebCore/rendering/RenderBoxModelObject.cpp
r46281 r46295 1143 1143 } 1144 1144 1145 void RenderBoxModelObject::paintBoxShadow(GraphicsContext* context, int tx, int ty, int w, int h, const RenderStyle* s, bool begin, bool end)1145 void RenderBoxModelObject::paintBoxShadow(GraphicsContext* context, int tx, int ty, int w, int h, const RenderStyle* s, ShadowStyle shadowStyle, bool begin, bool end) 1146 1146 { 1147 1147 // FIXME: Deal with border-image. Would be great to use border-image as a mask. … … 1151 1151 1152 1152 IntRect rect(tx, ty, w, h); 1153 IntSize topLeft; 1154 IntSize topRight; 1155 IntSize bottomLeft; 1156 IntSize bottomRight; 1157 1153 1158 bool hasBorderRadius = s->hasBorderRadius(); 1159 if (hasBorderRadius && (begin || end)) { 1160 IntSize topLeftRadius, topRightRadius, bottomLeftRadius, bottomRightRadius; 1161 s->getBorderRadiiForRect(rect, topLeftRadius, topRightRadius, bottomLeftRadius, bottomRightRadius); 1162 1163 if (begin) { 1164 if (shadowStyle == Inset) { 1165 topLeftRadius.expand(-borderLeft(), -borderTop()); 1166 topLeftRadius.clampNegativeToZero(); 1167 bottomLeftRadius.expand(-borderLeft(), -borderBottom()); 1168 bottomLeftRadius.clampNegativeToZero(); 1169 } 1170 topLeft = topLeftRadius; 1171 bottomLeft = bottomLeftRadius; 1172 } 1173 if (end) { 1174 if (shadowStyle == Inset) { 1175 topRightRadius.expand(-borderRight(), -borderTop()); 1176 topRightRadius.clampNegativeToZero(); 1177 bottomRightRadius.expand(-borderRight(), -borderBottom()); 1178 bottomRightRadius.clampNegativeToZero(); 1179 } 1180 topRight = topRightRadius; 1181 bottomRight = bottomRightRadius; 1182 } 1183 } 1184 1185 if (shadowStyle == Inset) { 1186 rect.move(begin ? borderLeft() : 0, borderTop()); 1187 rect.setWidth(rect.width() - (begin ? borderLeft() : 0) - (end ? borderRight() : 0)); 1188 rect.setHeight(rect.height() - borderTop() - borderBottom()); 1189 } 1190 1154 1191 bool hasOpaqueBackground = s->backgroundColor().isValid() && s->backgroundColor().alpha() == 255; 1155 1192 for (ShadowData* shadow = s->boxShadow(); shadow; shadow = shadow->next) { 1193 if (shadow->style != shadowStyle) 1194 continue; 1195 1156 1196 IntSize shadowOffset(shadow->x, shadow->y); 1157 1197 int shadowBlur = shadow->blur; 1158 1198 int shadowSpread = shadow->spread; 1159 IntRect fillRect(rect); 1160 fillRect.inflate(shadowSpread); 1161 if (fillRect.isEmpty()) 1162 continue; 1163 1164 IntRect shadowRect(rect); 1165 shadowRect.inflate(shadowBlur + shadowSpread); 1166 shadowRect.move(shadowOffset); 1167 1168 context->save(); 1169 context->clip(shadowRect); 1170 1171 // Move the fill just outside the clip, adding 1 pixel separation so that the fill does not 1172 // bleed in (due to antialiasing) if the context is transformed. 1173 IntSize extraOffset(w + max(0, shadowOffset.width()) + shadowBlur + 2 * shadowSpread + 1, 0); 1174 shadowOffset -= extraOffset; 1175 fillRect.move(extraOffset); 1176 1177 context->setShadow(shadowOffset, shadowBlur, shadow->color); 1178 if (hasBorderRadius) { 1179 IntSize topLeftRadius, topRightRadius, bottomLeftRadius, bottomRightRadius; 1180 s->getBorderRadiiForRect(rect, topLeftRadius, topRightRadius, bottomLeftRadius, bottomRightRadius); 1181 1182 IntSize topLeft = begin ? topLeftRadius : IntSize(); 1183 IntSize topRight = end ? topRightRadius : IntSize(); 1184 IntSize bottomLeft = begin ? bottomLeftRadius : IntSize(); 1185 IntSize bottomRight = end ? bottomRightRadius : IntSize(); 1186 1187 IntRect rectToClipOut = rect; 1188 IntSize topLeftToClipOut = topLeft; 1189 IntSize topRightToClipOut = topRight; 1190 IntSize bottomLeftToClipOut = bottomLeft; 1191 IntSize bottomRightToClipOut = bottomRight; 1192 1193 if (shadowSpread < 0) { 1194 topLeft.expand(shadowSpread, shadowSpread); 1195 topLeft.clampNegativeToZero(); 1196 1197 topRight.expand(shadowSpread, shadowSpread); 1198 topRight.clampNegativeToZero(); 1199 1200 bottomLeft.expand(shadowSpread, shadowSpread); 1201 bottomLeft.clampNegativeToZero(); 1202 1203 bottomRight.expand(shadowSpread, shadowSpread); 1204 bottomRight.clampNegativeToZero(); 1205 } 1206 1207 // If the box is opaque, it is unnecessary to clip it out. However, doing so saves time 1208 // when painting the shadow. On the other hand, it introduces subpixel gaps along the 1209 // corners. Those are avoided by insetting the clipping path by one pixel. 1210 if (hasOpaqueBackground) { 1211 rectToClipOut.inflate(-1); 1212 1213 topLeftToClipOut.expand(-1, -1); 1214 topLeftToClipOut.clampNegativeToZero(); 1215 1216 topRightToClipOut.expand(-1, -1); 1217 topRightToClipOut.clampNegativeToZero(); 1218 1219 bottomLeftToClipOut.expand(-1, -1); 1220 bottomLeftToClipOut.clampNegativeToZero(); 1221 1222 bottomRightToClipOut.expand(-1, -1); 1223 bottomRightToClipOut.clampNegativeToZero(); 1224 } 1225 1226 if (!rectToClipOut.isEmpty()) 1227 context->clipOutRoundedRect(rectToClipOut, topLeftToClipOut, topRightToClipOut, bottomLeftToClipOut, bottomRightToClipOut); 1228 context->fillRoundedRect(fillRect, topLeft, topRight, bottomLeft, bottomRight, Color::black); 1199 Color& shadowColor = shadow->color; 1200 1201 if (shadow->style == Normal) { 1202 IntRect fillRect(rect); 1203 fillRect.inflate(shadowSpread); 1204 if (fillRect.isEmpty()) 1205 continue; 1206 1207 IntRect shadowRect(rect); 1208 shadowRect.inflate(shadowBlur + shadowSpread); 1209 shadowRect.move(shadowOffset); 1210 1211 context->save(); 1212 context->clip(shadowRect); 1213 1214 // Move the fill just outside the clip, adding 1 pixel separation so that the fill does not 1215 // bleed in (due to antialiasing) if the context is transformed. 1216 IntSize extraOffset(w + max(0, shadowOffset.width()) + shadowBlur + 2 * shadowSpread + 1, 0); 1217 shadowOffset -= extraOffset; 1218 fillRect.move(extraOffset); 1219 1220 context->setShadow(shadowOffset, shadowBlur, shadowColor); 1221 if (hasBorderRadius) { 1222 IntRect rectToClipOut = rect; 1223 IntSize topLeftToClipOut = topLeft; 1224 IntSize topRightToClipOut = topRight; 1225 IntSize bottomLeftToClipOut = bottomLeft; 1226 IntSize bottomRightToClipOut = bottomRight; 1227 1228 if (shadowSpread < 0) { 1229 topLeft.expand(shadowSpread, shadowSpread); 1230 topLeft.clampNegativeToZero(); 1231 1232 topRight.expand(shadowSpread, shadowSpread); 1233 topRight.clampNegativeToZero(); 1234 1235 bottomLeft.expand(shadowSpread, shadowSpread); 1236 bottomLeft.clampNegativeToZero(); 1237 1238 bottomRight.expand(shadowSpread, shadowSpread); 1239 bottomRight.clampNegativeToZero(); 1240 } 1241 1242 // If the box is opaque, it is unnecessary to clip it out. However, doing so saves time 1243 // when painting the shadow. On the other hand, it introduces subpixel gaps along the 1244 // corners. Those are avoided by insetting the clipping path by one pixel. 1245 if (hasOpaqueBackground) { 1246 rectToClipOut.inflate(-1); 1247 1248 topLeftToClipOut.expand(-1, -1); 1249 topLeftToClipOut.clampNegativeToZero(); 1250 1251 topRightToClipOut.expand(-1, -1); 1252 topRightToClipOut.clampNegativeToZero(); 1253 1254 bottomLeftToClipOut.expand(-1, -1); 1255 bottomLeftToClipOut.clampNegativeToZero(); 1256 1257 bottomRightToClipOut.expand(-1, -1); 1258 bottomRightToClipOut.clampNegativeToZero(); 1259 } 1260 1261 if (!rectToClipOut.isEmpty()) 1262 context->clipOutRoundedRect(rectToClipOut, topLeftToClipOut, topRightToClipOut, bottomLeftToClipOut, bottomRightToClipOut); 1263 context->fillRoundedRect(fillRect, topLeft, topRight, bottomLeft, bottomRight, Color::black); 1264 } else { 1265 IntRect rectToClipOut = rect; 1266 1267 // If the box is opaque, it is unnecessary to clip it out. However, doing so saves time 1268 // when painting the shadow. On the other hand, it introduces subpixel gaps along the 1269 // edges if they are not pixel-aligned. Those are avoided by insetting the clipping path 1270 // by one pixel. 1271 if (hasOpaqueBackground) { 1272 TransformationMatrix currentTransformation = context->getCTM(); 1273 if (currentTransformation.a() != 1 || (currentTransformation.d() != 1 && currentTransformation.d() != -1) 1274 || currentTransformation.b() || currentTransformation.c()) 1275 rectToClipOut.inflate(-1); 1276 } 1277 1278 if (!rectToClipOut.isEmpty()) 1279 context->clipOut(rectToClipOut); 1280 context->fillRect(fillRect, Color::black); 1281 } 1282 1283 context->restore(); 1229 1284 } else { 1230 IntRect rectToClipOut = rect; 1231 1232 // If the box is opaque, it is unnecessary to clip it out. However, doing so saves time 1233 // when painting the shadow. On the other hand, it introduces subpixel gaps along the 1234 // edges if they are not pixel-aligned. Those are avoided by insetting the clipping path 1235 // by one pixel. 1236 if (hasOpaqueBackground) { 1237 TransformationMatrix currentTransformation = context->getCTM(); 1238 if (currentTransformation.a() != 1 || (currentTransformation.d() != 1 && currentTransformation.d() != -1) 1239 || currentTransformation.b() || currentTransformation.c()) 1240 rectToClipOut.inflate(-1); 1241 } 1242 1243 if (!rectToClipOut.isEmpty()) 1244 context->clipOut(rectToClipOut); 1245 context->fillRect(fillRect, Color::black); 1246 } 1247 context->restore(); 1285 // Inset shadow. 1286 IntRect holeRect(rect); 1287 holeRect.inflate(-shadowSpread); 1288 1289 if (holeRect.isEmpty()) { 1290 if (hasBorderRadius) 1291 context->fillRoundedRect(rect, topLeft, topRight, bottomLeft, bottomRight, shadowColor); 1292 else 1293 context->fillRect(rect, shadowColor); 1294 continue; 1295 } 1296 if (!begin) { 1297 holeRect.move(-max(shadowOffset.width(), 0) - shadowBlur, 0); 1298 holeRect.setWidth(holeRect.width() + max(shadowOffset.width(), 0) + shadowBlur); 1299 } 1300 if (!end) 1301 holeRect.setWidth(holeRect.width() - min(shadowOffset.width(), 0) + shadowBlur); 1302 1303 Color fillColor(shadowColor.red(), shadowColor.green(), shadowColor.blue(), 255); 1304 1305 IntRect outerRect(rect); 1306 outerRect.inflateX(w - 2 * shadowSpread); 1307 outerRect.inflateY(h - 2 * shadowSpread); 1308 1309 context->save(); 1310 1311 if (hasBorderRadius) 1312 context->clip(Path::createRoundedRectangle(rect, topLeft, topRight, bottomLeft, bottomRight)); 1313 else 1314 context->clip(rect); 1315 1316 IntSize extraOffset(2 * w + max(0, shadowOffset.width()) + shadowBlur - 2 * shadowSpread + 1, 0); 1317 context->translate(extraOffset.width(), extraOffset.height()); 1318 shadowOffset -= extraOffset; 1319 1320 context->beginPath(); 1321 context->addPath(Path::createRectangle(outerRect)); 1322 1323 if (hasBorderRadius) { 1324 if (shadowSpread > 0) { 1325 topLeft.expand(-shadowSpread, -shadowSpread); 1326 topLeft.clampNegativeToZero(); 1327 1328 topRight.expand(-shadowSpread, -shadowSpread); 1329 topRight.clampNegativeToZero(); 1330 1331 bottomLeft.expand(-shadowSpread, -shadowSpread); 1332 bottomLeft.clampNegativeToZero(); 1333 1334 bottomRight.expand(-shadowSpread, -shadowSpread); 1335 bottomRight.clampNegativeToZero(); 1336 } 1337 context->addPath(Path::createRoundedRectangle(holeRect, topLeft, topRight, bottomLeft, bottomRight)); 1338 } else 1339 context->addPath(Path::createRectangle(holeRect)); 1340 1341 context->setFillRule(RULE_EVENODD); 1342 context->setFillColor(fillColor); 1343 context->setShadow(shadowOffset, shadowBlur, shadowColor); 1344 context->fillPath(); 1345 1346 context->restore(); 1347 } 1248 1348 } 1249 1349 } -
trunk/WebCore/rendering/RenderBoxModelObject.h
r45317 r46295 90 90 void paintBorder(GraphicsContext*, int tx, int ty, int w, int h, const RenderStyle*, bool begin = true, bool end = true); 91 91 bool paintNinePieceImage(GraphicsContext*, int tx, int ty, int w, int h, const RenderStyle*, const NinePieceImage&, CompositeOperator = CompositeSourceOver); 92 void paintBoxShadow(GraphicsContext*, int tx, int ty, int w, int h, const RenderStyle*, bool begin = true, bool end = true);92 void paintBoxShadow(GraphicsContext*, int tx, int ty, int w, int h, const RenderStyle*, ShadowStyle, bool begin = true, bool end = true); 93 93 void paintFillLayerExtended(const PaintInfo&, const Color&, const FillLayer*, int tx, int ty, int width, int height, InlineFlowBox* = 0, CompositeOperator = CompositeSourceOver); 94 94 -
trunk/WebCore/rendering/RenderFieldset.cpp
r45624 r46295 132 132 ty += yOff; 133 133 134 paintBoxShadow(paintInfo.context, tx, ty, w, h, style() );134 paintBoxShadow(paintInfo.context, tx, ty, w, h, style(), Normal); 135 135 136 136 paintFillLayers(paintInfo, style()->backgroundColor(), style()->backgroundLayers(), tx, ty, w, h); 137 paintBoxShadow(paintInfo.context, tx, ty, w, h, style(), Inset); 137 138 138 139 if (!style()->hasBorder()) -
trunk/WebCore/rendering/RenderTable.cpp
r45624 r46295 5 5 * (C) 1999 Lars Knoll (knoll@kde.org) 6 6 * (C) 1999 Antti Koivisto (koivisto@kde.org) 7 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.7 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. 8 8 * Copyright (C) 2006 Alexey Proskuryakov (ap@nypop.com) 9 9 * … … 515 515 } 516 516 517 paintBoxShadow(paintInfo.context, tx, ty, w, h, style() );517 paintBoxShadow(paintInfo.context, tx, ty, w, h, style(), Normal); 518 518 519 519 paintFillLayers(paintInfo, style()->backgroundColor(), style()->backgroundLayers(), tx, ty, w, h); 520 paintBoxShadow(paintInfo.context, tx, ty, w, h, style(), Inset); 520 521 521 522 if (style()->hasBorder() && !collapseBorders()) -
trunk/WebCore/rendering/RenderTableCell.cpp
r45317 r46295 5 5 * (C) 1999 Lars Knoll (knoll@kde.org) 6 6 * (C) 1999 Antti Koivisto (koivisto@kde.org) 7 * Copyright (C) 2003, 2004, 2005, 2006, 2007 Apple Inc. All rights reserved.7 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. 8 8 * 9 9 * This library is free software; you can redistribute it and/or … … 848 848 849 849 if (style()->boxShadow()) 850 paintBoxShadow(paintInfo.context, tx, ty, w, h, style() );850 paintBoxShadow(paintInfo.context, tx, ty, w, h, style(), Normal); 851 851 852 852 // Paint our cell background. 853 853 paintBackgroundsBehindCell(paintInfo, tx, ty, this); 854 if (style()->boxShadow()) 855 paintBoxShadow(paintInfo.context, tx, ty, w, h, style(), Inset); 854 856 855 857 if (!style()->hasBorder() || tableElt->collapseBorders()) -
trunk/WebCore/rendering/style/ShadowData.h
r46097 r46295 3 3 * (C) 2000 Antti Koivisto (koivisto@kde.org) 4 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, 2009 Apple Inc. All rights reserved. 6 6 * Copyright (C) 2006 Graham Dennis (graham.dennis@gmail.com) 7 7 * … … 30 30 namespace WebCore { 31 31 32 enum ShadowStyle { Normal, Inset }; 33 32 34 // This struct holds information about shadows for the text-shadow and box-shadow properties. 33 35 … … 38 40 , blur(0) 39 41 , spread(0) 42 , style(Normal) 40 43 , next(0) 41 44 { 42 45 } 43 46 44 ShadowData(int x, int y, int blur, int spread, const Color& color)47 ShadowData(int x, int y, int blur, int spread, ShadowStyle style, const Color& color) 45 48 : x(x) 46 49 , y(y) 47 50 , blur(blur) 48 51 , spread(spread) 52 , style(style) 49 53 , color(color) 50 54 , next(0) … … 66 70 int blur; 67 71 int spread; 72 ShadowStyle style; 68 73 Color color; 69 74 ShadowData* next;
Note:
See TracChangeset
for help on using the changeset viewer.