Changeset 32406 in webkit
- Timestamp:
- Apr 22, 2008 2:40:35 PM (16 years ago)
- Location:
- trunk
- Files:
-
- 3 added
- 25 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r32402 r32406 1 2008-04-22 David Hyatt <hyatt@apple.com> 2 3 Add support for CSS alpha masks. Test cases. 4 5 Reviewed by Dan 6 7 * fast/backgrounds/repeat/mask-negative-offset-repeat.html: Added. 8 * fast/backgrounds/repeat/resources/white.gif: Added. 9 * fast/backgrounds/svg-as-mask.html: Added. 10 1 11 2008-04-22 Dan Bernstein <mitz@apple.com> 2 12 -
trunk/WebCore/ChangeLog
r32405 r32406 1 2008-04-22 David Hyatt <hyatt@apple.com> 2 3 Fix for <rdar://5589634>. 4 5 Implement CSS alpha masks. The syntax is very similar to that used for backgrounds. Multiple mask images 6 can be specified, and each one can be tiled, positioned, etc. The following new properties have been 7 added (all of which are analogous to their background-* counterparts). 8 9 mask, mask-image, mask-clip, mask-origin, mask-repeat, mask-attachment, mask-position 10 11 The alpha values in the final composite image are used to determine how the mask applies (alpha of 1 = show, 12 alpha of 0 = don't show). 13 14 SVG images and CSS gradients can also be used as masks. 15 16 Reviewed by Dan 17 18 Added fast/backgrounds/repeat/mask-negative-offset-repeat.html, fast/backgrounds/svg-as-mask.html 19 20 * css/CSSMutableStyleDeclaration.cpp: 21 (WebCore::CSSMutableStyleDeclaration::getPropertyValue): 22 (WebCore::initShorthandMap): 23 * css/CSSParser.cpp: 24 (WebCore::CSSParser::parseFillProperty): 25 (WebCore::CSSParser::parseTransformOrigin): 26 * css/CSSStyleSelector.cpp: 27 (WebCore::CSSStyleSelector::adjustRenderStyle): 28 (WebCore::CSSStyleSelector::applyProperty): 29 * rendering/InlineFlowBox.cpp: 30 (WebCore::InlineFlowBox::paint): 31 (WebCore::InlineFlowBox::paintFillLayers): 32 (WebCore::InlineFlowBox::paintFillLayer): 33 (WebCore::InlineFlowBox::paintBoxDecorations): 34 (WebCore::InlineFlowBox::paintMask): 35 * rendering/InlineFlowBox.h: 36 * rendering/RenderBlock.cpp: 37 (WebCore::RenderBlock::paint): 38 (WebCore::RenderBlock::paintObject): 39 * rendering/RenderBox.cpp: 40 (WebCore::RenderBox::paintRootBoxDecorations): 41 (WebCore::RenderBox::paintBoxDecorations): 42 (WebCore::RenderBox::paintMask): 43 (WebCore::RenderBox::paintFillLayers): 44 (WebCore::RenderBox::paintFillLayer): 45 (WebCore::RenderBox::paintFillLayerExtended): 46 * rendering/RenderBox.h: 47 * rendering/RenderFieldset.cpp: 48 (WebCore::RenderFieldset::paintBoxDecorations): 49 (WebCore::RenderFieldset::paintMask): 50 * rendering/RenderFieldset.h: 51 * rendering/RenderInline.cpp: 52 (WebCore::RenderInline::requiresLayer): 53 * rendering/RenderLayer.cpp: 54 (WebCore::RenderLayer::isTransparent): 55 (WebCore::RenderLayer::paintLayer): 56 * rendering/RenderObject.cpp: 57 (WebCore::RenderObject::requiresLayer): 58 (WebCore::mustRepaintFillLayers): 59 (WebCore::RenderObject::mustRepaintBackgroundOrBorder): 60 (WebCore::RenderObject::setStyle): 61 (WebCore::RenderObject::updateFillImages): 62 * rendering/RenderObject.h: 63 (WebCore::): 64 (WebCore::RenderObject::hasMask): 65 (WebCore::RenderObject::paintMask): 66 (WebCore::RenderObject::paintFillExtended): 67 * rendering/RenderReplaced.cpp: 68 (WebCore::RenderReplaced::paint): 69 * rendering/RenderStyle.cpp: 70 (WebCore::FillLayer::FillLayer): 71 (WebCore::StyleRareNonInheritedData::StyleRareNonInheritedData): 72 * rendering/RenderStyle.h: 73 (WebCore::FillLayer::initialFillComposite): 74 (WebCore::FillLayer::initialFillSize): 75 (WebCore::FillLayer::FillLayer): 76 (WebCore::RenderStyle::hasMask): 77 * rendering/RenderTable.cpp: 78 (WebCore::RenderTable::paint): 79 (WebCore::RenderTable::paintBoxDecorations): 80 (WebCore::RenderTable::paintMask): 81 * rendering/RenderTable.h: 82 * rendering/RenderTableCell.cpp: 83 (WebCore::RenderTableCell::requiresLayer): 84 (WebCore::RenderTableCell::paintBackgroundsBehindCell): 85 (WebCore::RenderTableCell::paintMask): 86 * rendering/RenderTableCell.h: 87 * rendering/RenderWidget.cpp: 88 (WebCore::RenderWidget::paint): 89 * svg/graphics/SVGImage.cpp: 90 (WebCore::SVGImage::draw): 91 (WebCore::SVGImage::dataChanged): 92 1 93 2008-04-22 Sam Weinig <sam@webkit.org> 2 94 -
trunk/WebCore/css/CSSMutableStyleDeclaration.cpp
r31993 r32406 88 88 } 89 89 case CSSPropertyBackground: { 90 const int properties[ 6] = { CSSPropertyBackgroundImage, CSSPropertyBackgroundRepeat,91 CSSPropertyBackgroundAttachment, CSSPropertyBackgroundPosition X,92 CSSProperty BackgroundPositionY, CSSPropertyBackgroundColor };93 return getLayeredShorthandValue(properties, 6);90 const int properties[7] = { CSSPropertyBackgroundImage, CSSPropertyBackgroundRepeat, 91 CSSPropertyBackgroundAttachment, CSSPropertyBackgroundPosition, CSSPropertyWebkitBackgroundClip, 92 CSSPropertyWebkitBackgroundOrigin, CSSPropertyBackgroundColor }; 93 return getLayeredShorthandValue(properties, 7); 94 94 } 95 95 case CSSPropertyBorder: { … … 152 152 CSSPropertyListStyleImage }; 153 153 return getShorthandValue(properties, 3); 154 } 155 case CSSPropertyWebkitMaskPosition: { 156 // FIXME: Is this correct? The code in cssparser.cpp is confusing 157 const int properties[2] = { CSSPropertyWebkitMaskPositionX, 158 CSSPropertyWebkitMaskPositionY }; 159 return getLayeredShorthandValue(properties, 2); 160 } 161 case CSSPropertyWebkitMask: { 162 const int properties[] = { CSSPropertyWebkitMaskImage, CSSPropertyWebkitMaskRepeat, 163 CSSPropertyWebkitMaskAttachment, CSSPropertyWebkitMaskPosition, CSSPropertyWebkitMaskClip, 164 CSSPropertyWebkitMaskOrigin }; 165 return getLayeredShorthandValue(properties, 6); 154 166 } 155 167 #if ENABLE(SVG) … … 387 399 static const int backgroundProperties[] = { 388 400 CSSPropertyBackgroundAttachment, 401 CSSPropertyWebkitBackgroundClip, 389 402 CSSPropertyBackgroundColor, 390 403 CSSPropertyBackgroundImage, 404 CSSPropertyWebkitBackgroundOrigin, 391 405 CSSPropertyBackgroundPositionX, 392 406 CSSPropertyBackgroundPositionY, 393 407 CSSPropertyBackgroundRepeat, 394 CSSPropertyWebkitBackgroundSize395 408 }; 396 409 SET_SHORTHAND_MAP_ENTRY(shorthandMap, CSSPropertyBackground, backgroundProperties); … … 417 430 SET_SHORTHAND_MAP_ENTRY(shorthandMap, CSSPropertyWebkitBorderRadius, borderRadiusProperties); 418 431 432 static const int maskPositionProperties[] = { CSSPropertyWebkitMaskPositionX, CSSPropertyWebkitMaskPositionY }; 433 SET_SHORTHAND_MAP_ENTRY(shorthandMap, CSSPropertyWebkitMaskPosition, maskPositionProperties); 434 435 static const int maskProperties[] = { 436 CSSPropertyWebkitMaskAttachment, 437 CSSPropertyWebkitMaskClip, 438 CSSPropertyWebkitMaskImage, 439 CSSPropertyWebkitMaskOrigin, 440 CSSPropertyWebkitMaskPositionX, 441 CSSPropertyWebkitMaskPositionY, 442 CSSPropertyWebkitMaskRepeat, 443 }; 444 SET_SHORTHAND_MAP_ENTRY(shorthandMap, CSSPropertyBackground, maskProperties); 445 419 446 #undef SET_SHORTHAND_MAP_ENTRY 420 447 } -
trunk/WebCore/css/CSSParser.cpp
r32362 r32406 2089 2089 propId1 = CSSPropertyBackgroundPositionX; 2090 2090 propId2 = CSSPropertyBackgroundPositionY; 2091 } else if (propId == CSSPropertyWebkitMaskPosition) { 2092 propId1 = CSSPropertyWebkitMaskPositionX; 2093 propId2 = CSSPropertyWebkitMaskPositionY; 2091 2094 } 2092 2095 … … 2115 2118 break; 2116 2119 case CSSPropertyBackgroundImage: 2117 case CSSPropertyWebkitMask :2120 case CSSPropertyWebkitMaskImage: 2118 2121 if (parseFillImage(currValue)) 2119 2122 valueList->next(); … … 3758 3761 case CSSPropertyWebkitTransformOrigin: 3759 3762 parseFillPosition(value, value2); 3760 // Unlike the other functions, parse BackgroundPosition advances the valueList pointer3763 // Unlike the other functions, parseFillPosition advances the valueList pointer 3761 3764 break; 3762 3765 case CSSPropertyWebkitTransformOriginX: { -
trunk/WebCore/css/CSSStyleSelector.cpp
r32348 r32406 168 168 HANDLE_FILL_LAYER_VALUE(background, Background, prop, Prop, value) 169 169 170 #define HANDLE_MASK_INHERIT_AND_INITIAL(prop, Prop) \ 171 HANDLE_FILL_LAYER_INHERIT_AND_INITIAL(mask, Mask, prop, Prop) 172 173 #define HANDLE_MASK_VALUE(prop, Prop, value) \ 174 HANDLE_FILL_LAYER_VALUE(mask, Mask, prop, Prop, value) 175 170 176 #define HANDLE_TRANSITION_INHERIT_AND_INITIAL(prop, Prop) \ 171 177 if (isInherit) { \ … … 1164 1170 1165 1171 // Make sure our z-index value is only applied if the object is positioned, 1166 // relatively positioned, transparent, or has a transform .1167 if (style->position() == StaticPosition && style->opacity() == 1.0f && !style->hasTransform() )1172 // relatively positioned, transparent, or has a transform/mask. 1173 if (style->position() == StaticPosition && style->opacity() == 1.0f && !style->hasTransform() && !style->hasMask()) 1168 1174 style->setHasAutoZIndex(); 1169 1175 1170 1176 // Auto z-index becomes 0 for the root element and transparent objects. This prevents 1171 1177 // cases where objects that should be blended as a single unit end up with a non-transparent 1172 // object wedged in between them. Auto z-index also becomes 0 for objects that specify transforms .1173 if (style->hasAutoZIndex() && ((e && e->document()->documentElement() == e) || style->opacity() < 1.0f || style->hasTransform() ))1178 // object wedged in between them. Auto z-index also becomes 0 for objects that specify transforms/masks. 1179 if (style->hasAutoZIndex() && ((e && e->document()->documentElement() == e) || style->opacity() < 1.0f || style->hasTransform() || style->hasMask())) 1174 1180 style->setZIndex(0); 1175 1181 … … 2341 2347 HANDLE_BACKGROUND_VALUE(size, Size, value) 2342 2348 return; 2349 case CSSPropertyWebkitMaskAttachment: 2350 HANDLE_MASK_VALUE(attachment, Attachment, value) 2351 return; 2352 case CSSPropertyWebkitMaskClip: 2353 HANDLE_MASK_VALUE(clip, Clip, value) 2354 return; 2355 case CSSPropertyWebkitMaskOrigin: 2356 HANDLE_MASK_VALUE(origin, Origin, value) 2357 return; 2358 case CSSPropertyWebkitMaskRepeat: 2359 HANDLE_MASK_VALUE(repeat, Repeat, value) 2360 return; 2361 case CSSPropertyWebkitMaskSize: 2362 HANDLE_MASK_VALUE(size, Size, value) 2363 return; 2343 2364 case CSSPropertyBorderCollapse: 2344 2365 HANDLE_INHERIT_AND_INITIAL(borderCollapse, BorderCollapse) … … 2669 2690 return; 2670 2691 } 2692 case CSSPropertyWebkitMaskPosition: 2693 HANDLE_MASK_INHERIT_AND_INITIAL(xPosition, XPosition); 2694 HANDLE_MASK_INHERIT_AND_INITIAL(yPosition, YPosition); 2695 return; 2696 case CSSPropertyWebkitMaskPositionX: { 2697 HANDLE_MASK_VALUE(xPosition, XPosition, value) 2698 return; 2699 } 2700 case CSSPropertyWebkitMaskPositionY: { 2701 HANDLE_MASK_VALUE(yPosition, YPosition, value) 2702 return; 2703 } 2671 2704 case CSSPropertyBorderSpacing: { 2672 2705 if (isInherit) { … … 2811 2844 case CSSPropertyBackgroundImage: 2812 2845 HANDLE_BACKGROUND_VALUE(image, Image, value) 2846 return; 2847 case CSSPropertyWebkitMaskImage: 2848 HANDLE_MASK_VALUE(image, Image, value) 2813 2849 return; 2814 2850 case CSSPropertyListStyleImage: … … 3650 3686 m_style->clearBackgroundLayers(); 3651 3687 m_style->setBackgroundColor(Color()); 3652 return;3653 3688 } 3654 3689 else if (isInherit) { … … 3657 3692 } 3658 3693 return; 3694 case CSSPropertyWebkitMask: 3695 if (isInitial) 3696 m_style->clearMaskLayers(); 3697 else if (isInherit) 3698 m_style->inheritMaskLayers(*m_parentStyle->maskLayers()); 3699 return; 3700 3659 3701 case CSSPropertyBorder: 3660 3702 case CSSPropertyBorderStyle: -
trunk/WebCore/rendering/InlineFlowBox.cpp
r32334 r32406 620 620 paintInfo.outlineObjects->add(flowObject()); 621 621 } 622 } else if (paintInfo.phase == PaintPhaseMask) { 623 paintMask(paintInfo, tx, ty); 624 return; 622 625 } else { 623 626 // 1. Paint our background, border and box-shadow. … … 628 631 } 629 632 } 633 634 if (paintInfo.phase == PaintPhaseMask) 635 return; 630 636 631 637 PaintPhase paintPhase = paintInfo.phase == PaintPhaseChildOutlines ? PaintPhaseOutline : paintInfo.phase; … … 647 653 } 648 654 649 void InlineFlowBox::paint Backgrounds(const RenderObject::PaintInfo& paintInfo, const Color& c, const FillLayer* bgLayer,650 651 { 652 if (! bgLayer)655 void InlineFlowBox::paintFillLayers(const RenderObject::PaintInfo& paintInfo, const Color& c, const FillLayer* fillLayer, 656 int my, int mh, int _tx, int _ty, int w, int h) 657 { 658 if (!fillLayer) 653 659 return; 654 paint Backgrounds(paintInfo, c, bgLayer->next(), my, mh, _tx, _ty, w, h);655 paint Background(paintInfo, c, bgLayer, my, mh, _tx, _ty, w, h);656 } 657 658 void InlineFlowBox::paint Background(const RenderObject::PaintInfo& paintInfo, const Color& c, const FillLayer* bgLayer,659 660 { 661 StyleImage* bg = bgLayer->image();662 bool has BackgroundImage = bg && bg->canRender(object()->style()->effectiveZoom());663 if ((!has BackgroundImage && !object()->style()->hasBorderRadius()) || (!prevLineBox() && !nextLineBox()) || !parent())664 object()->paint BackgroundExtended(paintInfo, c, bgLayer, my, mh, tx, ty, w, h, this);660 paintFillLayers(paintInfo, c, fillLayer->next(), my, mh, _tx, _ty, w, h); 661 paintFillLayer(paintInfo, c, fillLayer, my, mh, _tx, _ty, w, h); 662 } 663 664 void InlineFlowBox::paintFillLayer(const RenderObject::PaintInfo& paintInfo, const Color& c, const FillLayer* fillLayer, 665 int my, int mh, int tx, int ty, int w, int h) 666 { 667 StyleImage* img = fillLayer->image(); 668 bool hasFillImage = img && img->canRender(object()->style()->effectiveZoom()); 669 if ((!hasFillImage && !object()->style()->hasBorderRadius()) || (!prevLineBox() && !nextLineBox()) || !parent()) 670 object()->paintFillExtended(paintInfo, c, fillLayer, my, mh, tx, ty, w, h, this); 665 671 else { 666 // We have a backgroundimage that spans multiple lines.672 // We have a fill image that spans multiple lines. 667 673 // We need to adjust _tx and _ty by the width of all previous lines. 668 674 // Think of background painting on inlines as though you had one long line, a single continuous … … 681 687 paintInfo.context->save(); 682 688 paintInfo.context->clip(IntRect(tx, ty, width(), height())); 683 object()->paintBackgroundExtended(paintInfo, c, bgLayer, my, mh, startX, ty, 684 totalWidth, h, this); 689 object()->paintFillExtended(paintInfo, c, fillLayer, my, mh, startX, ty, totalWidth, h, this); 685 690 paintInfo.context->restore(); 686 691 } … … 728 733 729 734 Color c = styleToUse->backgroundColor(); 730 paint Backgrounds(paintInfo, c, styleToUse->backgroundLayers(), my, mh, tx, ty, w, h);735 paintFillLayers(paintInfo, c, styleToUse->backgroundLayers(), my, mh, tx, ty, w, h); 731 736 732 737 // :first-line cannot be used to put borders on a line. Always paint borders with our … … 767 772 } 768 773 774 void InlineFlowBox::paintMask(RenderObject::PaintInfo& paintInfo, int tx, int ty) 775 { 776 if (!object()->shouldPaintWithinRoot(paintInfo) || object()->style()->visibility() != VISIBLE || paintInfo.phase != PaintPhaseMask) 777 return; 778 779 // Move x/y to our coordinates. 780 tx += m_x; 781 ty += m_y; 782 783 int w = width(); 784 int h = height(); 785 786 int my = max(ty, paintInfo.rect.y()); 787 int mh; 788 if (ty < paintInfo.rect.y()) 789 mh = max(0, h - (paintInfo.rect.y() - ty)); 790 else 791 mh = min(paintInfo.rect.height(), h); 792 793 if (object()->hasMask()) 794 paintFillLayers(paintInfo, Color(), object()->style()->maskLayers(), my, mh, tx, ty, w, h); 795 } 796 769 797 static bool shouldDrawTextDecoration(RenderObject* obj) 770 798 { -
trunk/WebCore/rendering/InlineFlowBox.h
r32334 r32406 84 84 85 85 virtual void paintBoxDecorations(RenderObject::PaintInfo&, int tx, int ty); 86 void paintBackgrounds(const RenderObject::PaintInfo&, const Color&, const FillLayer*, 87 int my, int mh, int tx, int ty, int w, int h); 88 void paintBackground(const RenderObject::PaintInfo&, const Color&, const FillLayer*, 86 virtual void paintMask(RenderObject::PaintInfo&, int tx, int ty); 87 void paintFillLayers(const RenderObject::PaintInfo&, const Color&, const FillLayer*, 88 int my, int mh, int tx, int ty, int w, int h); 89 void paintFillLayer(const RenderObject::PaintInfo&, const Color&, const FillLayer*, 89 90 int my, int mh, int tx, int ty, int w, int h); 90 91 void paintBoxShadow(GraphicsContext*, RenderStyle*, int tx, int ty, int w, int h); -
trunk/WebCore/rendering/RenderBlock.cpp
r31876 r32406 1400 1400 } 1401 1401 1402 bool useControlClip = phase != PaintPhaseBlockBackground && phase != PaintPhaseSelfOutline && hasControlClip();1402 bool useControlClip = phase != PaintPhaseBlockBackground && phase != PaintPhaseSelfOutline && phase != PaintPhaseMask && hasControlClip(); 1403 1403 1404 1404 // Push a clip. … … 1571 1571 hasBoxDecorations() && style()->visibility() == VISIBLE) { 1572 1572 paintBoxDecorations(paintInfo, tx, ty); 1573 } 1574 1575 if (paintPhase == PaintPhaseMask && style()->visibility() == VISIBLE) { 1576 paintMask(paintInfo, tx, ty); 1577 return; 1573 1578 } 1574 1579 -
trunk/WebCore/rendering/RenderBox.cpp
r32334 r32406 357 357 int my = max(by, paintInfo.rect.y()); 358 358 359 paint Backgrounds(paintInfo, bgColor, bgLayer, my, paintInfo.rect.height(), bx, by, bw, bh);359 paintFillLayers(paintInfo, bgColor, bgLayer, my, paintInfo.rect.height(), bx, by, bw, bh); 360 360 361 361 if (style()->hasBorder() && style()->display() != INLINE) … … 400 400 // since the root could be inline and wrapped in an anonymous block. 401 401 if (!isBody() || !document()->isHTMLDocument() || document()->documentElement()->renderer()->style()->hasBackground()) 402 paint Backgrounds(paintInfo, style()->backgroundColor(), style()->backgroundLayers(), my, mh, tx, ty, w, h);402 paintFillLayers(paintInfo, style()->backgroundColor(), style()->backgroundLayers(), my, mh, tx, ty, w, h); 403 403 if (style()->hasAppearance()) 404 404 theme()->paintDecorations(this, paintInfo, IntRect(tx, ty, w, h)); … … 410 410 } 411 411 412 void RenderBox::paintBackgrounds(const PaintInfo& paintInfo, const Color& c, const FillLayer* bgLayer, 413 int clipY, int clipH, int tx, int ty, int width, int height) 414 { 415 if (!bgLayer) 412 void RenderBox::paintMask(PaintInfo& paintInfo, int tx, int ty) 413 { 414 if (!shouldPaintWithinRoot(paintInfo) || style()->visibility() != VISIBLE || paintInfo.phase != PaintPhaseMask) 416 415 return; 417 416 418 paintBackgrounds(paintInfo, c, bgLayer->next(), clipY, clipH, tx, ty, width, height); 419 paintBackground(paintInfo, c, bgLayer, clipY, clipH, tx, ty, width, height); 420 } 421 422 void RenderBox::paintBackground(const PaintInfo& paintInfo, const Color& c, const FillLayer* bgLayer, 417 int w = width(); 418 int h = height() + borderTopExtra() + borderBottomExtra(); 419 ty -= borderTopExtra(); 420 421 // border-fit can adjust where we paint our border and background. If set, we snugly fit our line box descendants. (The iChat 422 // balloon layout is an example of this). 423 borderFitAdjust(tx, w); 424 425 int my = max(ty, paintInfo.rect.y()); 426 int mh; 427 if (ty < paintInfo.rect.y()) 428 mh = max(0, h - (paintInfo.rect.y() - ty)); 429 else 430 mh = min(paintInfo.rect.height(), h); 431 432 paintFillLayers(paintInfo, Color(), style()->maskLayers(), my, mh, tx, ty, w, h); 433 } 434 435 void RenderBox::paintFillLayers(const PaintInfo& paintInfo, const Color& c, const FillLayer* fillLayer, 423 436 int clipY, int clipH, int tx, int ty, int width, int height) 424 437 { 425 paintBackgroundExtended(paintInfo, c, bgLayer, clipY, clipH, tx, ty, width, height); 438 if (!fillLayer) 439 return; 440 441 paintFillLayers(paintInfo, c, fillLayer->next(), clipY, clipH, tx, ty, width, height); 442 paintFillLayer(paintInfo, c, fillLayer, clipY, clipH, tx, ty, width, height); 443 } 444 445 void RenderBox::paintFillLayer(const PaintInfo& paintInfo, const Color& c, const FillLayer* fillLayer, 446 int clipY, int clipH, int tx, int ty, int width, int height) 447 { 448 paintFillLayerExtended(paintInfo, c, fillLayer, clipY, clipH, tx, ty, width, height); 426 449 } 427 450 … … 623 646 } 624 647 625 void RenderBox::paint BackgroundExtended(const PaintInfo& paintInfo, const Color& c, const FillLayer* bgLayer, int clipY, int clipH,626 648 void RenderBox::paintFillLayerExtended(const PaintInfo& paintInfo, const Color& c, const FillLayer* bgLayer, int clipY, int clipH, 649 int tx, int ty, int w, int h, InlineFlowBox* box) 627 650 { 628 651 GraphicsContext* context = paintInfo.context; -
trunk/WebCore/rendering/RenderBox.h
r32334 r32406 142 142 virtual IntRect caretRect(int offset, EAffinity = UPSTREAM, int* extraWidthToEndOfLine = 0); 143 143 144 virtual void paint BackgroundExtended(const PaintInfo&, const Color&, const FillLayer*, int clipY, int clipHeight,145 144 virtual void paintFillLayerExtended(const PaintInfo&, const Color&, const FillLayer*, int clipY, int clipHeight, 145 int tx, int ty, int width, int height, InlineFlowBox* = 0); 146 146 IntSize calculateBackgroundSize(const FillLayer*, int scaledWidth, int scaledHeight) const; 147 147 … … 155 155 156 156 virtual void paintBoxDecorations(PaintInfo&, int tx, int ty); 157 virtual void paintMask(PaintInfo& paintInfo, int tx, int ty); 157 158 virtual void imageChanged(WrappedImagePtr); 158 159 … … 166 167 167 168 protected: 168 void paint Background(const PaintInfo&, const Color&, const FillLayer*, int clipY, int clipHeight, int tx, int ty, int width, int height);169 void paint Backgrounds(const PaintInfo&, const Color&, const FillLayer*, int clipY, int clipHeight, int tx, int ty, int width, int height);169 void paintFillLayer(const PaintInfo&, const Color&, const FillLayer*, int clipY, int clipHeight, int tx, int ty, int width, int height); 170 void paintFillLayers(const PaintInfo&, const Color&, const FillLayer*, int clipY, int clipHeight, int tx, int ty, int width, int height); 170 171 171 172 #if PLATFORM(MAC) -
trunk/WebCore/rendering/RenderFieldset.cpp
r31200 r32406 130 130 paintBoxShadow(paintInfo.context, tx, ty, w, h, style()); 131 131 132 paint Background(paintInfo, style()->backgroundColor(), style()->backgroundLayers(), my, mh, tx, ty, w, h);132 paintFillLayers(paintInfo, style()->backgroundColor(), style()->backgroundLayers(), my, mh, tx, ty, w, h); 133 133 134 134 if (style()->hasBorder()) … … 136 136 } 137 137 138 void RenderFieldset::paintMask(PaintInfo& paintInfo, int tx, int ty) 139 { 140 if (style()->visibility() != VISIBLE || paintInfo.phase != PaintPhaseMask) 141 return; 142 143 int w = width(); 144 int h = height() + borderTopExtra() + borderBottomExtra(); 145 RenderObject* legend = findLegend(); 146 if (!legend) 147 return RenderBlock::paintMask(paintInfo, tx, ty); 148 149 int yOff = (legend->yPos() > 0) ? 0 : (legend->height() - borderTop()) / 2; 150 h -= yOff; 151 ty += yOff - borderTopExtra(); 152 153 int my = max(ty, paintInfo.rect.y()); 154 int end = min(paintInfo.rect.bottom(), ty + h); 155 int mh = end - my; 156 157 paintFillLayers(paintInfo, Color(), style()->maskLayers(), my, mh, tx, ty, w, h); 158 } 159 138 160 void RenderFieldset::paintBorderMinusLegend(GraphicsContext* graphicsContext, int tx, int ty, int w, int h, 139 161 const RenderStyle* style, int lx, int lw, int lb) -
trunk/WebCore/rendering/RenderFieldset.h
r25754 r32406 50 50 private: 51 51 virtual void paintBoxDecorations(PaintInfo&, int tx, int ty); 52 virtual void paintMask(PaintInfo& paintInfo, int tx, int ty); 52 53 void paintBorderMinusLegend(GraphicsContext*, int tx, int ty, int w, int h, const RenderStyle*, int lx, int lw, int lb); 53 54 RenderObject* findLegend() const; -
trunk/WebCore/rendering/RenderInline.cpp
r25754 r32406 302 302 bool RenderInline::requiresLayer() 303 303 { 304 return isRelPositioned() || style()->opacity() < 1.0f;304 return isRelPositioned() || isTransparent() || hasMask(); 305 305 } 306 306 -
trunk/WebCore/rendering/RenderLayer.cpp
r31604 r32406 435 435 return false; 436 436 #endif 437 return m_object->isTransparent() ;437 return m_object->isTransparent() || m_object->hasMask(); 438 438 } 439 439 … … 1626 1626 it[0]->paintLayer(rootLayer, p, paintDirtyRect, haveTransparency, paintRestriction, paintingRoot); 1627 1627 1628 if (renderer()->hasMask() && shouldPaint && !selectionOnly && !damageRect.isEmpty()) { 1629 setClip(p, paintDirtyRect, damageRect); 1630 1631 // Paint the mask. We have to use an extra image buffer to hold the mask. Multiple mask images need 1632 // to composite together using source-over so that they can then combine into a single unified mask that 1633 // can be composited with the content using destination-in. SVG images need to be able to set compositing modes 1634 // as they draw images contained inside their sub-document, so we paint all our images into a separate buffer 1635 // and composite that buffer as the mask. 1636 p->setCompositeOperation(CompositeDestinationIn); 1637 p->beginTransparencyLayer(1.0f); 1638 RenderObject::PaintInfo paintInfo(p, damageRect, PaintPhaseMask, false, paintingRootForRenderer, 0); 1639 renderer()->paint(paintInfo, tx, ty); 1640 p->endTransparencyLayer(); 1641 1642 // Restore the clip. 1643 restoreClip(p, paintDirtyRect, damageRect); 1644 } 1645 1628 1646 // End our transparency layer 1629 1647 if (isTransparent() && m_usedTransparency) { -
trunk/WebCore/rendering/RenderObject.cpp
r32334 r32406 500 500 bool RenderObject::requiresLayer() 501 501 { 502 return isRoot() || isPositioned() || isRelPositioned() || isTransparent() || hasOverflowClip() || hasTransform() ;502 return isRoot() || isPositioned() || isRelPositioned() || isTransparent() || hasOverflowClip() || hasTransform() || hasMask(); 503 503 } 504 504 … … 837 837 } 838 838 839 static bool mustRepaintFillLayers(const RenderObject* renderer, const FillLayer* layer) 840 { 841 // Nobody will use multiple layers without wanting fancy positioning. 842 if (layer->next()) 843 return true; 844 845 // Make sure we have a valid image. 846 StyleImage* img = layer->image(); 847 bool shouldPaintBackgroundImage = img && img->canRender(renderer->style()->effectiveZoom()); 848 849 // These are always percents or auto. 850 if (shouldPaintBackgroundImage && 851 (!layer->xPosition().isZero() || !layer->yPosition().isZero() || 852 layer->size().width.isPercent() || layer->size().height.isPercent())) 853 // The image will shift unpredictably if the size changes. 854 return true; 855 856 return false; 857 } 858 839 859 bool RenderObject::mustRepaintBackgroundOrBorder() const 840 860 { 841 // If we don't have a background/border, then nothing to do. 861 if (hasMask() && mustRepaintFillLayers(this, style()->maskLayers())) 862 return true; 863 864 // If we don't have a background/border/mask, then nothing to do. 842 865 if (!hasBoxDecorations()) 843 866 return false; 844 867 845 // Ok, let's check the background first. 846 const FillLayer* bgLayer = style()->backgroundLayers(); 847 848 // Nobody will use multiple background layers without wanting fancy positioning. 849 if (bgLayer->next()) 868 if (mustRepaintFillLayers(this, style()->backgroundLayers())) 850 869 return true; 851 852 // Make sure we have a valid background image. 853 StyleImage* bg = bgLayer->image(); 854 bool shouldPaintBackgroundImage = bg && bg->canRender(style()->effectiveZoom()); 855 856 // These are always percents or auto. 857 if (shouldPaintBackgroundImage && 858 (!bgLayer->xPosition().isZero() || !bgLayer->yPosition().isZero() || 859 bgLayer->size().width.isPercent() || bgLayer->size().height.isPercent())) 860 // The background image will shift unpredictably if the size changes. 861 return true; 862 863 // Background is ok. Let's check border. 870 871 // Our fill layers are ok. Let's check border. 864 872 if (style()->hasBorder()) { 865 873 // Border images are not ok. … … 2252 2260 m_style = style; 2253 2261 2254 updateBackgroundImages(oldStyle); 2262 updateFillImages(oldStyle ? oldStyle->backgroundLayers() : 0, m_style ? m_style->backgroundLayers() : 0); 2263 updateFillImages(oldStyle ? oldStyle->maskLayers() : 0, m_style ? m_style->maskLayers() : 0); 2264 2265 StyleImage* oldBorderImage = oldStyle ? oldStyle->borderImage().image() : 0; 2266 StyleImage* newBorderImage = m_style ? m_style->borderImage().image() : 0; 2267 if (oldBorderImage != newBorderImage) { 2268 if (oldBorderImage) 2269 oldBorderImage->removeClient(this); 2270 if (newBorderImage) 2271 newBorderImage->addClient(this); 2272 } 2255 2273 2256 2274 if (m_style) … … 2290 2308 } 2291 2309 2292 void RenderObject::update BackgroundImages(RenderStyle* oldStyle)2310 void RenderObject::updateFillImages(const FillLayer* oldLayers, const FillLayer* newLayers) 2293 2311 { 2294 2312 // FIXME: This will be slow when a large number of images is used. Fix by using a dict. 2295 const FillLayer* oldLayers = oldStyle ? oldStyle->backgroundLayers() : 0;2296 const FillLayer* newLayers = m_style ? m_style->backgroundLayers() : 0;2297 2313 for (const FillLayer* currOld = oldLayers; currOld; currOld = currOld->next()) { 2298 2314 if (currOld->image() && (!newLayers || !newLayers->containsImage(currOld->image()))) … … 2302 2318 if (currNew->image() && (!oldLayers || !oldLayers->containsImage(currNew->image()))) 2303 2319 currNew->image()->addClient(this); 2304 }2305 2306 StyleImage* oldBorderImage = oldStyle ? oldStyle->borderImage().image() : 0;2307 StyleImage* newBorderImage = m_style ? m_style->borderImage().image() : 0;2308 if (oldBorderImage != newBorderImage) {2309 if (oldBorderImage)2310 oldBorderImage->removeClient(this);2311 if (newBorderImage)2312 newBorderImage->addClient(this);2313 2320 } 2314 2321 } -
trunk/WebCore/rendering/RenderObject.h
r32334 r32406 81 81 PaintPhaseSelection, 82 82 PaintPhaseCollapsedTableBorders, 83 PaintPhaseTextClip 83 PaintPhaseTextClip, 84 PaintPhaseMask 84 85 }; 85 86 … … 365 366 bool hasTransform() const { return m_hasTransform; } 366 367 368 bool hasMask() const { return style() && style()->hasMask(); } 369 367 370 private: 368 371 bool includeVerticalScrollbarSize() const { return hasOverflowClip() && (style()->overflowY() == OSCROLL || style()->overflowY() == OAUTO); } … … 419 422 void scheduleRelayout(); 420 423 421 void update BackgroundImages(RenderStyle* oldStyle);424 void updateFillImages(const FillLayer*, const FillLayer*); 422 425 423 426 virtual InlineBox* createInlineBox(bool makePlaceHolderBox, bool isRootLineBox, bool isOnlyRun = false); … … 473 476 // RenderBox implements this. 474 477 virtual void paintBoxDecorations(PaintInfo&, int tx, int ty) { } 475 476 virtual void paint BackgroundExtended(const PaintInfo&, const Color&, const FillLayer*,477 478 478 virtual void paintMask(PaintInfo&, int tx, int ty) { } 479 virtual void paintFillExtended(const PaintInfo&, const Color&, const FillLayer*, 480 int clipy, int cliph, int tx, int ty, int width, int height, 481 InlineFlowBox* box = 0) { } 479 482 480 483 -
trunk/WebCore/rendering/RenderReplaced.cpp
r31155 r32406 108 108 ty += m_y; 109 109 110 if (hasBoxDecorations() && (paintInfo.phase == PaintPhaseForeground || paintInfo.phase == PaintPhaseSelection) )110 if (hasBoxDecorations() && (paintInfo.phase == PaintPhaseForeground || paintInfo.phase == PaintPhaseSelection) && style()->visibility() == VISIBLE) 111 111 paintBoxDecorations(paintInfo, tx, ty); 112 112 113 if (paintInfo.phase == PaintPhaseMask) { 114 paintMask(paintInfo, tx, ty); 115 return; 116 } 117 113 118 if ((paintInfo.phase == PaintPhaseOutline || paintInfo.phase == PaintPhaseSelfOutline) && style()->outlineWidth() && style()->visibility() == VISIBLE) 114 119 paintOutline(paintInfo.context, tx, ty, width(), height(), style()); -
trunk/WebCore/rendering/RenderStyle.cpp
r32348 r32406 239 239 , m_xPosSet(false) 240 240 , m_yPosSet(false) 241 , m_compositeSet( false)241 , m_compositeSet(type == MaskFillLayer) 242 242 , m_sizeSet(false) 243 243 , m_type(type) … … 786 786 , m_boxShadow(0) 787 787 , m_transition(0) 788 , m_mask( MaskFillLayer)788 , m_mask(FillLayer(MaskFillLayer)) 789 789 #if ENABLE(XBL) 790 790 , bindingURI(0) -
trunk/WebCore/rendering/RenderStyle.h
r32348 r32406 655 655 static EFillBox initialFillOrigin(EFillLayerType type) { return type == BackgroundFillLayer ? PaddingFillBox : BorderFillBox; } 656 656 static EFillRepeat initialFillRepeat(EFillLayerType) { return RepeatFill; } 657 static CompositeOperator initialFillComposite(EFillLayerType type) { return type == BackgroundFillLayer ? CompositeSourceOver : CompositeDestinationOut; }658 static LengthSize initialFillSize(EFillLayerType type) { return type == BackgroundFillLayer ? LengthSize() : LengthSize(Length(100.0, Percent), Length(100.0, Percent)); }657 static CompositeOperator initialFillComposite(EFillLayerType) { return CompositeSourceOver; } 658 static LengthSize initialFillSize(EFillLayerType) { return LengthSize(); } 659 659 static Length initialFillXPosition(EFillLayerType type) { return Length(0.0, Percent); } 660 660 static Length initialFillYPosition(EFillLayerType type) { return Length(0.0, Percent); } 661 661 static StyleImage* initialFillImage(EFillLayerType) { return 0; } 662 662 663 private: 664 FillLayer() { } 665 666 public: 663 667 RefPtr<StyleImage> m_image; 664 668 … … 670 674 unsigned m_origin : 2; // EFillBox 671 675 unsigned m_repeat : 2; // EFillRepeat 672 unsigned m_composite : 2; // CompositeOperator676 unsigned m_composite : 4; // CompositeOperator 673 677 674 678 LengthSize m_size; … … 2005 2009 bool hasTransform() const { return !rareNonInheritedData->m_transform->m_operations.isEmpty(); } 2006 2010 void applyTransform(AffineTransform&, const IntSize& borderBoxSize) const; 2011 bool hasMask() const { return rareNonInheritedData->m_mask.hasImage(); } 2007 2012 // End CSS3 Getters 2008 2013 -
trunk/WebCore/rendering/RenderTable.cpp
r31663 r32406 453 453 paintBoxDecorations(paintInfo, tx, ty); 454 454 455 if (paintPhase == PaintPhaseMask) { 456 paintMask(paintInfo, tx, ty); 457 return; 458 } 459 455 460 // We're done. We don't bother painting any children. 456 461 if (paintPhase == PaintPhaseBlockBackground) … … 513 518 paintBoxShadow(paintInfo.context, tx, ty, w, h, style()); 514 519 515 paint Background(paintInfo, style()->backgroundColor(), style()->backgroundLayers(), my, mh, tx, ty, w, h);520 paintFillLayers(paintInfo, style()->backgroundColor(), style()->backgroundLayers(), my, mh, tx, ty, w, h); 516 521 517 522 if (style()->hasBorder() && !collapseBorders()) 518 523 paintBorder(paintInfo.context, tx, ty, w, h, style()); 524 } 525 526 void RenderTable::paintMask(PaintInfo& paintInfo, int tx, int ty) 527 { 528 if (style()->visibility() != VISIBLE || paintInfo.phase != PaintPhaseMask) 529 return; 530 531 int w = width(); 532 int h = height(); 533 534 // Account for the caption. 535 if (m_caption) { 536 int captionHeight = (m_caption->height() + m_caption->marginBottom() + m_caption->marginTop()); 537 h -= captionHeight; 538 if (m_caption->style()->captionSide() != CAPBOTTOM) 539 ty += captionHeight; 540 } 541 542 int my = max(ty, paintInfo.rect.y()); 543 int mh; 544 if (ty < paintInfo.rect.y()) 545 mh = max(0, h - (paintInfo.rect.y() - ty)); 546 else 547 mh = min(paintInfo.rect.height(), h); 548 549 paintFillLayers(paintInfo, Color(), style()->maskLayers(), my, mh, tx, ty, w, h); 519 550 } 520 551 -
trunk/WebCore/rendering/RenderTable.h
r30415 r32406 99 99 virtual void paint(PaintInfo&, int tx, int ty); 100 100 virtual void paintBoxDecorations(PaintInfo&, int tx, int ty); 101 virtual void paintMask(PaintInfo& paintInfo, int tx, int ty); 101 102 virtual void layout(); 102 103 virtual void calcPrefWidths(); -
trunk/WebCore/rendering/RenderTableCell.cpp
r32334 r32406 251 251 bool RenderTableCell::requiresLayer() 252 252 { 253 return isPositioned() || isTransparent() || hasOverflowClip() || hasTransform() ;253 return isPositioned() || isTransparent() || hasOverflowClip() || hasTransform() || hasMask(); 254 254 } 255 255 … … 826 826 paintInfo.context->clip(clipRect); 827 827 } 828 paint Backgrounds(paintInfo, c, bgLayer, my, mh, tx, ty, w, h);828 paintFillLayers(paintInfo, c, bgLayer, my, mh, tx, ty, w, h); 829 829 if (shouldClip) 830 830 paintInfo.context->restore(); … … 854 854 } 855 855 856 void RenderTableCell::paintMask(PaintInfo& paintInfo, int tx, int ty) 857 { 858 if (style()->visibility() != VISIBLE || paintInfo.phase != PaintPhaseMask) 859 return; 860 861 RenderTable* tableElt = table(); 862 if (!tableElt->collapseBorders() && style()->emptyCells() == HIDE && !firstChild()) 863 return; 864 865 int w = width(); 866 int h = height() + borderTopExtra() + borderBottomExtra(); 867 868 int my = max(ty, paintInfo.rect.y()); 869 int end = min(paintInfo.rect.bottom(), ty + h); 870 int mh = end - my; 871 872 paintFillLayers(paintInfo, Color(), style()->maskLayers(), my, mh, tx, ty, w, h); 873 } 874 856 875 } // namespace WebCore -
trunk/WebCore/rendering/RenderTableCell.h
r30415 r32406 94 94 virtual void paint(PaintInfo&, int tx, int ty); 95 95 virtual void paintBoxDecorations(PaintInfo&, int tx, int ty); 96 virtual void paintMask(PaintInfo& paintInfo, int tx, int ty); 96 97 void paintCollapsedBorder(GraphicsContext*, int x, int y, int w, int h); 97 98 void paintBackgroundsBehindCell(PaintInfo&, int tx, int ty, RenderObject* backgroundObject); -
trunk/WebCore/rendering/RenderWidget.cpp
r30992 r32406 179 179 ty += m_y; 180 180 181 if (hasBoxDecorations() && paintInfo.phase != PaintPhaseOutline && paintInfo.phase != PaintPhaseSelfOutline)181 if (hasBoxDecorations() && (paintInfo.phase == PaintPhaseForeground || paintInfo.phase == PaintPhaseSelection)) 182 182 paintBoxDecorations(paintInfo, tx, ty); 183 184 if (paintInfo.phase == PaintPhaseMask) { 185 paintMask(paintInfo, tx, ty); 186 return; 187 } 183 188 184 189 if (!m_view || paintInfo.phase != PaintPhaseForeground || style()->visibility() != VISIBLE) -
trunk/WebCore/svg/graphics/SVGImage.cpp
r32231 r32406 146 146 147 147 context->save(); 148 context->setCompositeOperation(compositeOp); 148 149 context->clip(enclosingIntRect(dstRect)); 149 150 context->translate(dstRect.location().x(), dstRect.location().y()); … … 215 216 m_frame->loader()->write(m_data->data(), m_data->size()); 216 217 m_frame->loader()->end(); 218 m_frameView->setTransparent(true); // SVG Images are transparent. 217 219 } 218 220 return m_frameView;
Note: See TracChangeset
for help on using the changeset viewer.