| OLD | NEW |
| 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 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 } | 126 } |
| 127 | 127 |
| 128 void ScrollbarThemeMacOverlayAPI::setNewPainterForScrollbar(ScrollbarThemeClient
* scrollbar, ScrollbarPainter newPainter) | 128 void ScrollbarThemeMacOverlayAPI::setNewPainterForScrollbar(ScrollbarThemeClient
* scrollbar, ScrollbarPainter newPainter) |
| 129 { | 129 { |
| 130 RetainPtr<WebCoreScrollbarObserver> observer = [[WebCoreScrollbarObserver al
loc] initWithScrollbar:scrollbar painter:newPainter]; | 130 RetainPtr<WebCoreScrollbarObserver> observer = [[WebCoreScrollbarObserver al
loc] initWithScrollbar:scrollbar painter:newPainter]; |
| 131 scrollbarPainterMap()->set(scrollbar, observer); | 131 scrollbarPainterMap()->set(scrollbar, observer); |
| 132 updateEnabledState(scrollbar); | 132 updateEnabledState(scrollbar); |
| 133 updateScrollbarOverlayStyle(scrollbar); | 133 updateScrollbarOverlayStyle(scrollbar); |
| 134 } | 134 } |
| 135 | 135 |
| 136 ScrollbarPainter ScrollbarThemeMacOverlayAPI::painterForScrollbar(const Scrollba
rThemeClient* scrollbar) | 136 ScrollbarPainter ScrollbarThemeMacOverlayAPI::painterForScrollbar(const Scrollba
rThemeClient* scrollbar) const |
| 137 { | 137 { |
| 138 return [scrollbarPainterMap()->get(const_cast<ScrollbarThemeClient*>(scrollb
ar)).get() painter]; | 138 return [scrollbarPainterMap()->get(const_cast<ScrollbarThemeClient*>(scrollb
ar)).get() painter]; |
| 139 } | 139 } |
| 140 | 140 |
| 141 void ScrollbarThemeMacOverlayAPI::paintTrackBackground(GraphicsContext* context,
const ScrollbarThemeClient* scrollbar, const IntRect& rect) { | 141 void ScrollbarThemeMacOverlayAPI::paintTrackBackground(GraphicsContext* context,
const ScrollbarThemeClient* scrollbar, const IntRect& rect) { |
| 142 if (DrawingRecorder::useCachedDrawingIfPossible(*context, *scrollbar, Displa
yItem::ScrollbarTrackBackground)) | 142 if (DrawingRecorder::useCachedDrawingIfPossible(*context, *scrollbar, Displa
yItem::ScrollbarTrackBackground)) |
| 143 return; | 143 return; |
| 144 | 144 |
| 145 DrawingRecorder recorder(*context, *scrollbar, DisplayItem::ScrollbarTrackBa
ckground, rect); | 145 DrawingRecorder recorder(*context, *scrollbar, DisplayItem::ScrollbarTrackBa
ckground, rect); |
| 146 | 146 |
| 147 ASSERT(isOverlayAPIAvailable()); | 147 ASSERT(isOverlayAPIAvailable()); |
| 148 | 148 |
| 149 GraphicsContextStateSaver stateSaver(*context); | 149 GraphicsContextStateSaver stateSaver(*context); |
| 150 context->translate(rect.x(), rect.y()); | 150 context->translate(rect.x(), rect.y()); |
| 151 LocalCurrentGraphicsContext localContext(context, IntRect(IntPoint(), rect.s
ize())); | 151 LocalCurrentGraphicsContext localContext(context, IntRect(IntPoint(), rect.s
ize())); |
| 152 | 152 |
| 153 CGRect frameRect = scrollbar->frameRect(); | 153 CGRect frameRect = scrollbar->frameRect(); |
| 154 ScrollbarPainter scrollbarPainter = painterForScrollbar(scrollbar); | 154 ScrollbarPainter scrollbarPainter = painterForScrollbar(scrollbar); |
| 155 [scrollbarPainter setEnabled:scrollbar->enabled()]; | 155 [scrollbarPainter setEnabled:scrollbar->enabled()]; |
| 156 [scrollbarPainter setBoundsSize: NSSizeFromCGSize(frameRect.size)]; | 156 [scrollbarPainter setBoundsSize: NSSizeFromCGSize(frameRect.size)]; |
| 157 | |
| 158 NSRect trackRect = NSMakeRect(0, 0, frameRect.size.width, frameRect.size.hei
ght); | 157 NSRect trackRect = NSMakeRect(0, 0, frameRect.size.width, frameRect.size.hei
ght); |
| 159 [scrollbarPainter drawKnobSlotInRect:trackRect highlight:NO]; | 158 [scrollbarPainter drawKnobSlotInRect:trackRect highlight:NO]; |
| 160 } | 159 } |
| 161 | 160 |
| 162 void ScrollbarThemeMacOverlayAPI::paintThumb(GraphicsContext* context, const Scr
ollbarThemeClient* scrollbar, const IntRect& rect) { | 161 void ScrollbarThemeMacOverlayAPI::paintThumb(GraphicsContext* context, const Scr
ollbarThemeClient* scrollbar, const IntRect& rect) { |
| 163 if (DrawingRecorder::useCachedDrawingIfPossible(*context, *scrollbar, Displa
yItem::ScrollbarThumb)) | 162 if (DrawingRecorder::useCachedDrawingIfPossible(*context, *scrollbar, Displa
yItem::ScrollbarThumb)) |
| 164 return; | 163 return; |
| 165 | 164 |
| 166 // Expand dirty rect to allow for scroll thumb anti-aliasing in minimum thum
b size case. | 165 // Expand dirty rect to allow for scroll thumb anti-aliasing in minimum thum
b size case. |
| 167 IntRect dirtyRect = IntRect(rect); | 166 IntRect dirtyRect = IntRect(rect); |
| 168 dirtyRect.inflate(1); | 167 dirtyRect.inflate(1); |
| 169 DrawingRecorder recorder(*context, *scrollbar, DisplayItem::ScrollbarThumb,
dirtyRect); | 168 DrawingRecorder recorder(*context, *scrollbar, DisplayItem::ScrollbarThumb,
dirtyRect); |
| 170 | 169 |
| 171 ASSERT(isOverlayAPIAvailable()); | 170 ASSERT(isOverlayAPIAvailable()); |
| 172 | 171 |
| 173 GraphicsContextStateSaver stateSaver(*context); | 172 GraphicsContextStateSaver stateSaver(*context); |
| 174 context->translate(rect.x(), rect.y()); | 173 context->translate(rect.x(), rect.y()); |
| 175 LocalCurrentGraphicsContext localContext(context, IntRect(IntPoint(), rect.s
ize())); | 174 LocalCurrentGraphicsContext localContext(context, IntRect(IntPoint(), rect.s
ize())); |
| 176 | 175 |
| 177 ScrollbarPainter scrollbarPainter = painterForScrollbar(scrollbar); | 176 ScrollbarPainter scrollbarPainter = painterForScrollbar(scrollbar); |
| 178 [scrollbarPainter setEnabled:scrollbar->enabled()]; | 177 [scrollbarPainter setEnabled:scrollbar->enabled()]; |
| 179 [scrollbarPainter setBoundsSize:NSSizeFromCGSize(rect.size())]; | 178 [scrollbarPainter setBoundsSize:NSSizeFromCGSize(rect.size())]; |
| 180 [scrollbarPainter setDoubleValue:0]; | 179 [scrollbarPainter setDoubleValue:0]; |
| 181 [scrollbarPainter setKnobProportion:1]; | 180 [scrollbarPainter setKnobProportion:1]; |
| 181 |
| 182 CGFloat oldKnobAlpha = [scrollbarPainter knobAlpha]; |
| 183 [scrollbarPainter setKnobAlpha:1]; |
| 184 |
| 182 if (scrollbar->enabled()) | 185 if (scrollbar->enabled()) |
| 183 [scrollbarPainter drawKnob]; | 186 [scrollbarPainter drawKnob]; |
| 184 | 187 |
| 185 // If this state is not set, then moving the cursor over the scrollbar area
will only cause the | 188 // If this state is not set, then moving the cursor over the scrollbar area
will only cause the |
| 186 // scrollbar to engorge when moved over the top of the scrollbar area. | 189 // scrollbar to engorge when moved over the top of the scrollbar area. |
| 187 [scrollbarPainter setBoundsSize: NSSizeFromCGSize(scrollbar->frameRect().siz
e())]; | 190 [scrollbarPainter setBoundsSize: NSSizeFromCGSize(scrollbar->frameRect().siz
e())]; |
| 191 [scrollbarPainter setKnobAlpha:oldKnobAlpha]; |
| 188 } | 192 } |
| 189 | 193 |
| 190 int ScrollbarThemeMacOverlayAPI::scrollbarThickness(ScrollbarControlSize control
Size) | 194 int ScrollbarThemeMacOverlayAPI::scrollbarThickness(ScrollbarControlSize control
Size) |
| 191 { | 195 { |
| 192 NSControlSize nsControlSize = static_cast<NSControlSize>(controlSize); | 196 NSControlSize nsControlSize = static_cast<NSControlSize>(controlSize); |
| 193 ScrollbarPainter scrollbarPainter = [NSClassFromString(@"NSScrollerImp") scr
ollerImpWithStyle:recommendedScrollerStyle() controlSize:nsControlSize horizonta
l:NO replacingScrollerImp:nil]; | 197 ScrollbarPainter scrollbarPainter = [NSClassFromString(@"NSScrollerImp") scr
ollerImpWithStyle:recommendedScrollerStyle() controlSize:nsControlSize horizonta
l:NO replacingScrollerImp:nil]; |
| 194 BOOL wasExpanded = NO; | 198 BOOL wasExpanded = NO; |
| 195 if (supportsExpandedScrollbars()) { | 199 if (supportsExpandedScrollbars()) { |
| 196 wasExpanded = [scrollbarPainter isExpanded]; | 200 wasExpanded = [scrollbarPainter isExpanded]; |
| 197 [scrollbarPainter setExpanded:YES]; | 201 [scrollbarPainter setExpanded:YES]; |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 259 int ScrollbarThemeMacOverlayAPI::minimumThumbLength(const ScrollbarThemeClient*
scrollbar) | 263 int ScrollbarThemeMacOverlayAPI::minimumThumbLength(const ScrollbarThemeClient*
scrollbar) |
| 260 { | 264 { |
| 261 return [painterForScrollbar(scrollbar) knobMinLength]; | 265 return [painterForScrollbar(scrollbar) knobMinLength]; |
| 262 } | 266 } |
| 263 | 267 |
| 264 void ScrollbarThemeMacOverlayAPI::updateEnabledState(const ScrollbarThemeClient*
scrollbar) | 268 void ScrollbarThemeMacOverlayAPI::updateEnabledState(const ScrollbarThemeClient*
scrollbar) |
| 265 { | 269 { |
| 266 [painterForScrollbar(scrollbar) setEnabled:scrollbar->enabled()]; | 270 [painterForScrollbar(scrollbar) setEnabled:scrollbar->enabled()]; |
| 267 } | 271 } |
| 268 | 272 |
| 273 float ScrollbarThemeMacOverlayAPI::thumbOpacity(const ScrollbarThemeClient* scro
llbar) const { |
| 274 ScrollbarPainter scrollbarPainter = painterForScrollbar(scrollbar); |
| 275 return [scrollbarPainter knobAlpha]; |
| 276 } |
| 277 |
| 269 } // namespace blink | 278 } // namespace blink |
| 270 | 279 |
| OLD | NEW |