Changeset 154400 in webkit
- Timestamp:
- Aug 21, 2013 11:04:42 AM (11 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r154399 r154400 1 2013-08-21 Simon Fraser <simon.fraser@apple.com> 2 3 Allow opacity to apply to custom scrollbars 4 https://bugs.webkit.org/show_bug.cgi?id=120104 5 6 Reviewed by David Hyatt. 7 8 Ref test for custom scrollbars with opacity on the bar itself, 9 and on the thumb. 10 11 * scrollbars/scrollbar-parts-opacity-expected.html: Added. 12 * scrollbars/scrollbar-parts-opacity.html: Added. 13 1 14 2013-08-21 Robert Hogan <robert@webkit.org> 2 15 -
trunk/Source/WebCore/ChangeLog
r154399 r154400 1 2013-08-21 Simon Fraser <simon.fraser@apple.com> 2 3 Allow opacity to apply to custom scrollbars 4 https://bugs.webkit.org/show_bug.cgi?id=120104 5 6 Reviewed by David Hyatt. 7 8 Opacity was ignored custom scrollbar pseudoelements because custom scrollbar 9 renderers never create layers, and opacity is normally handled by the RenderLayer code. 10 11 Fix by having RenderScrollbarTheme and RenderScrollbarPart do the transparency 12 layers necessary for opacity. RenderScrollbarPart handles opacity for individual 13 parts. 14 15 Because ScrollbarThemeComposite::paint() renders the parts on after another (with 16 no nesting), opacity handling for the entire scrollbar needs special-casing. 17 This is done by willPaintScrollbar()/didPaintScrollbar() on the theme. 18 RenderScrollbarTheme consults the opacity the scrollbar (which we get from 19 the ScrollbarBGPart renderer) to decide whether to set up a transparency layer. 20 21 Test: scrollbars/scrollbar-parts-opacity.html 22 23 * platform/ScrollbarThemeComposite.cpp: 24 (WebCore::ScrollbarThemeComposite::paint): 25 * platform/ScrollbarThemeComposite.h: 26 (WebCore::ScrollbarThemeComposite::willPaintScrollbar): 27 (WebCore::ScrollbarThemeComposite::didPaintScrollbar): 28 * rendering/RenderScrollbar.cpp: 29 (WebCore::RenderScrollbar::opacity): 30 * rendering/RenderScrollbar.h: 31 * rendering/RenderScrollbarPart.cpp: 32 (WebCore::RenderScrollbarPart::paintIntoRect): 33 * rendering/RenderScrollbarTheme.cpp: 34 (WebCore::RenderScrollbarTheme::willPaintScrollbar): 35 (WebCore::RenderScrollbarTheme::didPaintScrollbar): 36 * rendering/RenderScrollbarTheme.h: 37 1 38 2013-08-21 Robert Hogan <robert@webkit.org> 2 39 -
trunk/Source/WebCore/platform/ScrollbarThemeComposite.cpp
r148967 r154400 76 76 } 77 77 78 willPaintScrollbar(graphicsContext, scrollbar); 79 78 80 // Paint the scrollbar background (only used by custom CSS scrollbars). 79 81 paintScrollbarBackground(graphicsContext, scrollbar); … … 106 108 paintThumb(graphicsContext, scrollbar, thumbRect); 107 109 110 didPaintScrollbar(graphicsContext, scrollbar); 108 111 return true; 109 112 } -
trunk/Source/WebCore/platform/ScrollbarThemeComposite.h
r134965 r154400 56 56 virtual int minimumThumbLength(ScrollbarThemeClient*); 57 57 58 virtual void willPaintScrollbar(GraphicsContext*, ScrollbarThemeClient*) { } 59 virtual void didPaintScrollbar(GraphicsContext*, ScrollbarThemeClient*) { } 60 58 61 virtual void paintScrollbarBackground(GraphicsContext*, ScrollbarThemeClient*) { } 59 62 virtual void paintTrackBackground(GraphicsContext*, ScrollbarThemeClient*, const IntRect&) { } -
trunk/Source/WebCore/rendering/RenderScrollbar.cpp
r143848 r154400 358 358 } 359 359 360 } 360 float RenderScrollbar::opacity() 361 { 362 RenderScrollbarPart* partRenderer = m_parts.get(ScrollbarBGPart); 363 if (!partRenderer) 364 return 1; 365 366 return partRenderer->style()->opacity(); 367 } 368 369 } -
trunk/Source/WebCore/rendering/RenderScrollbar.h
r145399 r154400 60 60 virtual bool isOverlayScrollbar() const { return false; } 61 61 62 float opacity(); 63 62 64 private: 63 65 virtual void setParent(ScrollView*); -
trunk/Source/WebCore/rendering/RenderScrollbarPart.cpp
r148536 r154400 182 182 setHeight(rect.height()); 183 183 184 if (graphicsContext->paintingDisabled()) 185 return; 186 184 if (graphicsContext->paintingDisabled() || !style()->opacity()) 185 return; 186 187 // We don't use RenderLayers for scrollbar parts, so we need to handle opacity here. 188 // Opacity for ScrollbarBGPart is handled by RenderScrollbarTheme::willPaintScrollbar(). 189 bool needsTransparencyLayer = m_part != ScrollbarBGPart && style()->opacity() < 1; 190 if (needsTransparencyLayer) { 191 graphicsContext->save(); 192 graphicsContext->clip(rect); 193 graphicsContext->beginTransparencyLayer(style()->opacity()); 194 } 195 187 196 // Now do the paint. 188 197 PaintInfo paintInfo(graphicsContext, pixelSnappedIntRect(rect), PaintPhaseBlockBackground, PaintBehaviorNormal); … … 196 205 paintInfo.phase = PaintPhaseOutline; 197 206 paint(paintInfo, paintOffset); 207 208 if (needsTransparencyLayer) { 209 graphicsContext->endTransparencyLayer(); 210 graphicsContext->restore(); 211 } 198 212 } 199 213 -
trunk/Source/WebCore/rendering/RenderScrollbarTheme.cpp
r123418 r154400 108 108 } 109 109 110 void RenderScrollbarTheme::willPaintScrollbar(GraphicsContext* context, ScrollbarThemeClient* scrollbar) 111 { 112 float opacity = toRenderScrollbar(scrollbar)->opacity(); 113 if (opacity != 1) { 114 context->save(); 115 context->clip(scrollbar->frameRect()); 116 context->beginTransparencyLayer(opacity); 117 } 118 } 119 120 void RenderScrollbarTheme::didPaintScrollbar(GraphicsContext* context, ScrollbarThemeClient* scrollbar) 121 { 122 float opacity = toRenderScrollbar(scrollbar)->opacity(); 123 if (opacity != 1) { 124 context->endTransparencyLayer(); 125 context->restore(); 126 } 127 } 128 110 129 void RenderScrollbarTheme::paintScrollCorner(ScrollView*, GraphicsContext* context, const IntRect& cornerRect) 111 130 { -
trunk/Source/WebCore/rendering/RenderScrollbarTheme.h
r123418 r154400 68 68 virtual IntRect forwardButtonRect(ScrollbarThemeClient*, ScrollbarPart, bool painting = false); 69 69 virtual IntRect trackRect(ScrollbarThemeClient*, bool painting = false); 70 71 virtual void willPaintScrollbar(GraphicsContext*, ScrollbarThemeClient*) OVERRIDE; 72 virtual void didPaintScrollbar(GraphicsContext*, ScrollbarThemeClient*) OVERRIDE; 70 73 71 74 virtual void paintScrollbarBackground(GraphicsContext*, ScrollbarThemeClient*);
Note: See TracChangeset
for help on using the changeset viewer.