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

Side by Side Diff: Source/WebCore/platform/chromium/ScrollbarOverlayUtilitiesChromiumMac.mm

Issue 7134051: Merge 88396 - 2011-06-08 Sailesh Agrawal <sail@chromium.org> (Closed) Base URL: http://svn.webkit.org/repository/webkit/branches/chromium/782/
Patch Set: Created 9 years, 6 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2008, 2011 Apple Inc. All Rights Reserved. 2 * Copyright (C) 2008, 2011 Apple Inc. All Rights Reserved.
3 * Copyright (C) 2011 Google Inc. All Rights Reserved. 3 * Copyright (C) 2011 Google Inc. All Rights Reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 @interface NSScrollerImp : NSObject 53 @interface NSScrollerImp : NSObject
54 54
55 + (id)scrollerImpWithStyle:(NSScrollerStyle)style 55 + (id)scrollerImpWithStyle:(NSScrollerStyle)style
56 controlSize:(NSControlSize)size 56 controlSize:(NSControlSize)size
57 horizontal:(BOOL)horizontal 57 horizontal:(BOOL)horizontal
58 replacingScrollerImp:(id)scroller; 58 replacingScrollerImp:(id)scroller;
59 59
60 @property CGFloat knobAlpha; 60 @property CGFloat knobAlpha;
61 @property CGFloat trackAlpha; 61 @property CGFloat trackAlpha;
62 @property CGFloat knobProportion; 62 @property CGFloat knobProportion;
63 @property NSInteger knobStyle;
63 @property(getter=isEnabled) BOOL enabled; 64 @property(getter=isEnabled) BOOL enabled;
64 @property(getter=isHorizontal) BOOL horizontal; 65 @property(getter=isHorizontal) BOOL horizontal;
65 @property double doubleValue; 66 @property double doubleValue;
66 @property(assign) id delegate; 67 @property(assign) id delegate;
67 68
68 - (CGFloat)knobMinLength; 69 - (CGFloat)knobMinLength;
69 - (CGFloat)trackBoxWidth; 70 - (CGFloat)trackBoxWidth;
70 - (CGFloat)trackWidth; 71 - (CGFloat)trackWidth;
71 - (void)setBoundsSize:(NSSize)size; 72 - (void)setBoundsSize:(NSSize)size;
72 - (void)drawKnobSlotInRect:(NSRect)rect 73 - (void)drawKnobSlotInRect:(NSRect)rect
73 highlight:(BOOL)flag; 74 highlight:(BOOL)flag;
74 - (void)drawKnob; 75 - (void)drawKnob;
75 - (void)setOverlayScrollerState:(NSScrollerStyle)state 76 - (void)setOverlayScrollerState:(NSScrollerStyle)state
76 forceImmediately:(BOOL)flag; 77 forceImmediately:(BOOL)flag;
77 - (void)setDelegate:(id)delegate; 78 - (void)setDelegate:(id)delegate;
79 - (NSRect)rectForPart:(NSUInteger)arg1;
78 80
79 @end 81 @end
80 82
81 // These are private APIs to manage overlay scrollbars. 83 // These are private APIs to manage overlay scrollbars.
82 @interface NSScrollerImpPair : NSObject 84 @interface NSScrollerImpPair : NSObject
83 85
84 @property NSScrollerStyle scrollerStyle; 86 @property NSScrollerStyle scrollerStyle;
85 @property(retain) NSScrollerImp *horizontalScrollerImp; 87 @property(retain) NSScrollerImp *horizontalScrollerImp;
86 @property(retain) NSScrollerImp *verticalScrollerImp; 88 @property(retain) NSScrollerImp *verticalScrollerImp;
87 @property(assign) id delegate; 89 @property(assign) id delegate;
(...skipping 27 matching lines...) Expand all
115 return result; 117 return result;
116 } 118 }
117 119
118 static NSControlSize scrollbarControlSizeToNSControlSize(int controlSize) 120 static NSControlSize scrollbarControlSizeToNSControlSize(int controlSize)
119 { 121 {
120 return controlSize == WebCore::RegularScrollbar ? NSRegularControlSize : NSS mallControlSize; 122 return controlSize == WebCore::RegularScrollbar ? NSRegularControlSize : NSS mallControlSize;
121 } 123 }
122 124
123 static NSScrollerStyle preferredScrollerStyle() 125 static NSScrollerStyle preferredScrollerStyle()
124 { 126 {
127 // TODO(sail): Disable overlay scrollbars for now until the following issues are fixed:
128 // #1: Invalidation issues causes the scrollbar to leave trailing artifacts.
129 // #2: Find tick marks need to be drawn on the scrollbar track.
130 return NSScrollerStyleLegacy;
131
125 if ([NSScroller respondsToSelector:@selector(preferredScrollerStyle)]) 132 if ([NSScroller respondsToSelector:@selector(preferredScrollerStyle)])
126 return [NSScroller preferredScrollerStyle]; 133 return [NSScroller preferredScrollerStyle];
127 return NSScrollerStyleLegacy; 134 return NSScrollerStyleLegacy;
128 } 135 }
129 136
130 bool wkScrollbarPainterUsesOverlayScrollers(void) 137 bool wkScrollbarPainterUsesOverlayScrollers(void)
131 { 138 {
132 return preferredScrollerStyle() == NSScrollerStyleOverlay; 139 return preferredScrollerStyle() == NSScrollerStyleOverlay;
133 } 140 }
134 141
(...skipping 17 matching lines...) Expand all
152 { 159 {
153 [painter setEnabled:enabled]; 160 [painter setEnabled:enabled];
154 [painter setBoundsSize:frameRect.size]; 161 [painter setBoundsSize:frameRect.size];
155 [painter setDoubleValue:value]; 162 [painter setDoubleValue:value];
156 [painter setKnobProportion:proportion]; 163 [painter setKnobProportion:proportion];
157 164
158 if ([painter isHorizontal]) 165 if ([painter isHorizontal])
159 frameRect.size.height = [painter trackWidth]; 166 frameRect.size.height = [painter trackWidth];
160 else 167 else
161 frameRect.size.width = [painter trackWidth]; 168 frameRect.size.width = [painter trackWidth];
169 frameRect.origin = NSZeroPoint;
162 170
163 [painter drawKnobSlotInRect:frameRect highlight:NO]; 171 [painter drawKnobSlotInRect:frameRect highlight:NO];
164 [painter drawKnob]; 172 [painter drawKnob];
165 } 173 }
166 174
167 int wkScrollbarMinimumThumbLength(WKScrollbarPainterRef painter) 175 int wkScrollbarMinimumThumbLength(WKScrollbarPainterRef painter)
168 { 176 {
169 return [painter knobMinLength]; 177 return [painter knobMinLength];
170 } 178 }
171 179
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 [controller setVerticalScrollerImp:painter]; 231 [controller setVerticalScrollerImp:painter];
224 } 232 }
225 233
226 void wkSetScrollbarPainterControllerStyle(WKScrollbarPainterControllerRef painte r, int newStyle) 234 void wkSetScrollbarPainterControllerStyle(WKScrollbarPainterControllerRef painte r, int newStyle)
227 { 235 {
228 [painter setScrollerStyle:newStyle]; 236 [painter setScrollerStyle:newStyle];
229 } 237 }
230 238
231 CGRect wkScrollbarPainterKnobRect(WKScrollbarPainterRef painter) 239 CGRect wkScrollbarPainterKnobRect(WKScrollbarPainterRef painter)
232 { 240 {
233 return NSRectToCGRect(NSZeroRect); 241 return NSRectToCGRect([painter rectForPart:NSScrollerKnob]);
234 } 242 }
235 243
236 void wkSetScrollbarPainterKnobAlpha(WKScrollbarPainterRef painter, CGFloat alpha ) 244 void wkSetScrollbarPainterKnobAlpha(WKScrollbarPainterRef painter, CGFloat alpha )
237 { 245 {
238 [painter setKnobAlpha:alpha]; 246 [painter setKnobAlpha:alpha];
239 } 247 }
240 248
241 void wkSetScrollbarPainterTrackAlpha(WKScrollbarPainterRef painter, CGFloat alph a) 249 void wkSetScrollbarPainterTrackAlpha(WKScrollbarPainterRef painter, CGFloat alph a)
242 { 250 {
243 [painter setTrackAlpha:alpha]; 251 [painter setTrackAlpha:alpha];
244 } 252 }
245 253
246 void wkSetScrollbarPainterKnobStyle(WKScrollbarPainterRef painter, wkScrollerKno bStyle style) 254 void wkSetScrollbarPainterKnobStyle(WKScrollbarPainterRef painter, wkScrollerKno bStyle style)
247 { 255 {
248 // TODO(sail): A knob style API doesn't exist in the seeds currently availab le. 256 [painter setKnobStyle:style];
249 } 257 }
250 258
251 WKScrollbarPainterControllerRef wkMakeScrollbarPainterController(id painterContr ollerDelegate) 259 WKScrollbarPainterControllerRef wkMakeScrollbarPainterController(id painterContr ollerDelegate)
252 { 260 {
253 if (!isScrollbarOverlayAPIAvailable()) 261 if (!isScrollbarOverlayAPIAvailable())
254 return nil; 262 return nil;
255 NSScrollerImpPair* controller = [[[lookUpNSScrollerImpPairClass() alloc] ini t] autorelease]; 263 NSScrollerImpPair* controller = [[[lookUpNSScrollerImpPairClass() alloc] ini t] autorelease];
256 [controller setDelegate:painterControllerDelegate]; 264 [controller setDelegate:painterControllerDelegate];
257 [controller setScrollerStyle:preferredScrollerStyle()]; 265 [controller setScrollerStyle:preferredScrollerStyle()];
258 return controller; 266 return controller;
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 [controller endScrollGesture]; 326 [controller endScrollGesture];
319 } 327 }
320 328
321 void wkScrollbarPainterForceFlashScrollers(WKScrollbarPainterControllerRef contr oller) 329 void wkScrollbarPainterForceFlashScrollers(WKScrollbarPainterControllerRef contr oller)
322 { 330 {
323 [controller flashScrollers]; 331 [controller flashScrollers];
324 } 332 }
325 333
326 bool isScrollbarOverlayAPIAvailable() 334 bool isScrollbarOverlayAPIAvailable()
327 { 335 {
328 // TODO(sail): Disable overlay scrollbars for now until the following issues are fixed:
329 // #1: Invalidation issues causes the scrollbar to leave trailing artifacts.
330 // #2: Various messages such as live resize started/ended need to be piped f rom the UI.
331 // #3: Find tick marks need to be drawn on the scrollbar track.
332 // #4: Need to have the theme engine draw the thumb.
333 return false;
334
335 static bool apiAvailable = [lookUpNSScrollerImpClass() respondsToSelector:@s elector(scrollerImpWithStyle:controlSize:horizontal:replacingScrollerImp:)] && 336 static bool apiAvailable = [lookUpNSScrollerImpClass() respondsToSelector:@s elector(scrollerImpWithStyle:controlSize:horizontal:replacingScrollerImp:)] &&
336 [lookUpNSScrollerImpPairClass() instancesRespondT oSelector:@selector(scrollerStyle)]; 337 [lookUpNSScrollerImpPairClass() instancesRespondT oSelector:@selector(scrollerStyle)];
337 return apiAvailable; 338 return apiAvailable;
338 } 339 }
339 340
340 #endif // USE(WK_SCROLLBAR_PAINTER) 341 #endif // USE(WK_SCROLLBAR_PAINTER)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698