Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(504)

Side by Side Diff: Source/platform/scroll/ScrollbarThemeMacNonOverlayAPI.mm

Issue 544913002: Fix scrollbar rendering on Mac 10.6 impl-side painting (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase and drop scroll-descendant-with-cached-cliprects.html b/c already has rebaseline needed Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « LayoutTests/TestExpectations ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 gButtonPlacement = ScrollbarButtonsSingle; 64 gButtonPlacement = ScrollbarButtonsSingle;
65 else if ([buttonPlacement isEqualToString:@"DoubleMin"]) 65 else if ([buttonPlacement isEqualToString:@"DoubleMin"])
66 gButtonPlacement = ScrollbarButtonsDoubleStart; 66 gButtonPlacement = ScrollbarButtonsDoubleStart;
67 else if ([buttonPlacement isEqualToString:@"DoubleBoth"]) 67 else if ([buttonPlacement isEqualToString:@"DoubleBoth"])
68 gButtonPlacement = ScrollbarButtonsDoubleBoth; 68 gButtonPlacement = ScrollbarButtonsDoubleBoth;
69 else { 69 else {
70 gButtonPlacement = ScrollbarButtonsDoubleEnd; 70 gButtonPlacement = ScrollbarButtonsDoubleEnd;
71 } 71 }
72 } 72 }
73 73
74 static blink::WebThemeEngine::State scrollbarStateToThemeState(ScrollbarThemeCli ent* scrollbar)
75 {
76 if (!scrollbar->enabled())
77 return blink::WebThemeEngine::StateDisabled;
78 if (!scrollbar->isScrollableAreaActive())
79 return blink::WebThemeEngine::StateInactive;
80 if (scrollbar->pressedPart() == ThumbPart)
81 return blink::WebThemeEngine::StatePressed;
82
83 return blink::WebThemeEngine::StateActive;
84 }
85
86 // Override ScrollbarThemeMacCommon::paint() to add support for the following: 74 // Override ScrollbarThemeMacCommon::paint() to add support for the following:
87 // - drawing using WebThemeEngine functions 75 // - drawing using WebThemeEngine functions
88 // - drawing tickmarks 76 // - drawing tickmarks
89 // - Skia specific changes 77 // - Skia specific changes
90 bool ScrollbarThemeMacNonOverlayAPI::paint(ScrollbarThemeClient* scrollbar, Grap hicsContext* context, const IntRect& damageRect) 78 bool ScrollbarThemeMacNonOverlayAPI::paint(ScrollbarThemeClient* scrollbar, Grap hicsContext* context, const IntRect& damageRect)
91 { 79 {
92 // Get the tickmarks for the frameview. 80 // Get the tickmarks for the frameview.
93 Vector<IntRect> tickmarks; 81 Vector<IntRect> tickmarks;
94 scrollbar->getTickmarks(tickmarks); 82 scrollbar->getTickmarks(tickmarks);
95 83
96 HIThemeTrackDrawInfo trackInfo; 84 HIThemeTrackDrawInfo trackInfo;
97 trackInfo.version = 0; 85 trackInfo.version = 0;
98 trackInfo.kind = scrollbar->controlSize() == RegularScrollbar ? kThemeMedium ScrollBar : kThemeSmallScrollBar; 86 trackInfo.kind = scrollbar->controlSize() == RegularScrollbar ? kThemeMedium ScrollBar : kThemeSmallScrollBar;
99 trackInfo.bounds = scrollbar->frameRect(); 87 trackInfo.bounds = scrollbar->frameRect();
100 trackInfo.min = 0; 88 trackInfo.min = 0;
101 trackInfo.max = scrollbar->maximum(); 89 trackInfo.max = scrollbar->maximum();
102 trackInfo.value = scrollbar->currentPos(); 90 trackInfo.value = scrollbar->currentPos();
103 trackInfo.trackInfo.scrollbar.viewsize = scrollbar->visibleSize(); 91 trackInfo.trackInfo.scrollbar.viewsize = scrollbar->visibleSize();
104 trackInfo.attributes = 0; 92 trackInfo.attributes = hasThumb(scrollbar) ? kThemeTrackShowThumb : 0;
93
105 if (scrollbar->orientation() == HorizontalScrollbar) 94 if (scrollbar->orientation() == HorizontalScrollbar)
106 trackInfo.attributes |= kThemeTrackHorizontal; 95 trackInfo.attributes |= kThemeTrackHorizontal;
107 96
108 if (!scrollbar->enabled()) 97 if (!scrollbar->enabled())
109 trackInfo.enableState = kThemeTrackDisabled; 98 trackInfo.enableState = kThemeTrackDisabled;
110 else 99 else
111 trackInfo.enableState = scrollbar->isScrollableAreaActive() ? kThemeTrac kActive : kThemeTrackInactive; 100 trackInfo.enableState = scrollbar->isScrollableAreaActive() ? kThemeTrac kActive : kThemeTrackInactive;
112 101
113 if (!hasButtons(scrollbar)) 102 if (!hasButtons(scrollbar))
114 trackInfo.enableState = kThemeTrackNothingToScroll; 103 trackInfo.enableState = kThemeTrackNothingToScroll;
(...skipping 13 matching lines...) Expand all
128 bufferRect.intersect(damageRect); 117 bufferRect.intersect(damageRect);
129 bufferRect.move(-scrollbar->frameRect().x(), -scrollbar->frameRect().y() ); 118 bufferRect.move(-scrollbar->frameRect().x(), -scrollbar->frameRect().y() );
130 119
131 imageBuffer = ImageBuffer::create(bufferRect.size()); 120 imageBuffer = ImageBuffer::create(bufferRect.size());
132 if (!imageBuffer) 121 if (!imageBuffer)
133 return true; 122 return true;
134 123
135 drawingContext = imageBuffer->context(); 124 drawingContext = imageBuffer->context();
136 } 125 }
137 126
138 // Draw thumbless. 127 // Draw the track and its thumb.
139 gfx::SkiaBitLocker bitLocker(drawingContext->canvas(), ThemeMac::inflateRect ForAA(scrollbar->frameRect())); 128 gfx::SkiaBitLocker bitLocker(drawingContext->canvas(), ThemeMac::inflateRect ForAA(scrollbar->frameRect()));
140 CGContextRef cgContext = bitLocker.cgContext(); 129 CGContextRef cgContext = bitLocker.cgContext();
141 HIThemeDrawTrack(&trackInfo, 0, cgContext, kHIThemeOrientationNormal); 130 HIThemeDrawTrack(&trackInfo, 0, cgContext, kHIThemeOrientationNormal);
142 131
143 IntRect tickmarkTrackRect = trackRect(scrollbar, false); 132 IntRect tickmarkTrackRect = trackRect(scrollbar, false);
144 if (!canDrawDirectly) { 133 if (!canDrawDirectly) {
145 tickmarkTrackRect.setX(0); 134 tickmarkTrackRect.setX(0);
146 tickmarkTrackRect.setY(0); 135 tickmarkTrackRect.setY(0);
147 } 136 }
148 // The ends are rounded and the thumb doesn't go there. 137 // The ends are rounded and the thumb doesn't go there.
149 tickmarkTrackRect.inflateY(-tickmarkTrackRect.width()); 138 tickmarkTrackRect.inflateY(-tickmarkTrackRect.width());
150 // Inset a bit. 139 // Inset a bit.
151 tickmarkTrackRect.setX(tickmarkTrackRect.x() + 2); 140 tickmarkTrackRect.setX(tickmarkTrackRect.x() + 2);
152 tickmarkTrackRect.setWidth(tickmarkTrackRect.width() - 5); 141 tickmarkTrackRect.setWidth(tickmarkTrackRect.width() - 5);
153 paintGivenTickmarks(drawingContext, scrollbar, tickmarkTrackRect, tickmarks) ; 142 paintGivenTickmarks(drawingContext, scrollbar, tickmarkTrackRect, tickmarks) ;
154 143
155 if (hasThumb(scrollbar)) {
156 blink::WebThemeEngine::ScrollbarInfo scrollbarInfo;
157 scrollbarInfo.orientation = scrollbar->orientation() == HorizontalScroll bar ? blink::WebThemeEngine::ScrollbarOrientationHorizontal : blink::WebThemeEng ine::ScrollbarOrientationVertical;
158 scrollbarInfo.parent = scrollbar->isScrollViewScrollbar() ? blink::WebTh emeEngine::ScrollbarParentScrollView : blink::WebThemeEngine::ScrollbarParentRen derLayer;
159 scrollbarInfo.maxValue = scrollbar->maximum();
160 scrollbarInfo.currentValue = scrollbar->currentPos();
161 scrollbarInfo.visibleSize = scrollbar->visibleSize();
162 scrollbarInfo.totalSize = scrollbar->totalSize();
163
164 blink::WebCanvas* webCanvas = drawingContext->canvas();
165 blink::Platform::current()->themeEngine()->paintScrollbarThumb(
166 webCanvas,
167 scrollbarStateToThemeState(scrollbar),
168 scrollbar->controlSize() == RegularScrollbar ? blink::WebThemeEngine ::SizeRegular : blink::WebThemeEngine::SizeSmall,
169 blink::WebRect(scrollbar->frameRect()),
170 scrollbarInfo);
171 }
172
173 if (!canDrawDirectly) { 144 if (!canDrawDirectly) {
174 ASSERT(imageBuffer); 145 ASSERT(imageBuffer);
175 context->drawImageBuffer(imageBuffer.get(), 146 context->drawImageBuffer(imageBuffer.get(),
176 FloatRect(scrollbar->frameRect().location(), imageBuffer->size())); 147 FloatRect(scrollbar->frameRect().location(), imageBuffer->size()));
177 } 148 }
178 149
179 return true; 150 return true;
180 } 151 }
181 152
182 int ScrollbarThemeMacNonOverlayAPI::scrollbarThickness(ScrollbarControlSize cont rolSize) 153 int ScrollbarThemeMacNonOverlayAPI::scrollbarThickness(ScrollbarControlSize cont rolSize)
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 return IntRect(scrollbar->x() + startWidth, scrollbar->y(), scrollbar->w idth() - totalWidth, thickness); 304 return IntRect(scrollbar->x() + startWidth, scrollbar->y(), scrollbar->w idth() - totalWidth, thickness);
334 return IntRect(scrollbar->x(), scrollbar->y() + startWidth, thickness, scrol lbar->height() - totalWidth); 305 return IntRect(scrollbar->x(), scrollbar->y() + startWidth, thickness, scrol lbar->height() - totalWidth);
335 } 306 }
336 307
337 int ScrollbarThemeMacNonOverlayAPI::minimumThumbLength(ScrollbarThemeClient* scr ollbar) 308 int ScrollbarThemeMacNonOverlayAPI::minimumThumbLength(ScrollbarThemeClient* scr ollbar)
338 { 309 {
339 return cThumbMinLength[scrollbar->controlSize()]; 310 return cThumbMinLength[scrollbar->controlSize()];
340 } 311 }
341 312
342 } 313 }
OLDNEW
« no previous file with comments | « LayoutTests/TestExpectations ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698