| 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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 | 107 |
| 108 if (!hasButtons(scrollbar)) | 108 if (!hasButtons(scrollbar)) |
| 109 trackInfo.enableState = kThemeTrackNothingToScroll; | 109 trackInfo.enableState = kThemeTrackNothingToScroll; |
| 110 trackInfo.trackInfo.scrollbar.pressState = scrollbarPartToHIPressedState(scr
ollbar->pressedPart()); | 110 trackInfo.trackInfo.scrollbar.pressState = scrollbarPartToHIPressedState(scr
ollbar->pressedPart()); |
| 111 | 111 |
| 112 SkCanvas* canvas = context->canvas(); | 112 SkCanvas* canvas = context->canvas(); |
| 113 CGAffineTransform currentCTM = gfx::SkMatrixToCGAffineTransform(canvas->getT
otalMatrix()); | 113 CGAffineTransform currentCTM = gfx::SkMatrixToCGAffineTransform(canvas->getT
otalMatrix()); |
| 114 | 114 |
| 115 // The Aqua scrollbar is buggy when rotated and scaled. We will just draw i
nto a bitmap if we detect a scale or rotation. | 115 // The Aqua scrollbar is buggy when rotated and scaled. We will just draw i
nto a bitmap if we detect a scale or rotation. |
| 116 bool canDrawDirectly = currentCTM.a == 1.0f && currentCTM.b == 0.0f && curre
ntCTM.c == 0.0f && (currentCTM.d == 1.0f || currentCTM.d == -1.0f); | 116 bool canDrawDirectly = currentCTM.a == 1.0f && currentCTM.b == 0.0f && curre
ntCTM.c == 0.0f && (currentCTM.d == 1.0f || currentCTM.d == -1.0f); |
| 117 GraphicsContext* drawingContext = context; | |
| 118 OwnPtr<ImageBuffer> imageBuffer; | 117 OwnPtr<ImageBuffer> imageBuffer; |
| 118 SkCanvas* drawingCanvas; |
| 119 if (!canDrawDirectly) { | 119 if (!canDrawDirectly) { |
| 120 trackInfo.bounds = IntRect(IntPoint(), scrollbar->frameRect().size()); | 120 trackInfo.bounds = IntRect(IntPoint(), scrollbar->frameRect().size()); |
| 121 | 121 |
| 122 IntRect bufferRect(scrollbar->frameRect()); | 122 IntRect bufferRect(scrollbar->frameRect()); |
| 123 bufferRect.intersect(damageRect); | 123 bufferRect.intersect(damageRect); |
| 124 bufferRect.move(-scrollbar->frameRect().x(), -scrollbar->frameRect().y()
); | 124 bufferRect.move(-scrollbar->frameRect().x(), -scrollbar->frameRect().y()
); |
| 125 | 125 |
| 126 imageBuffer = ImageBuffer::create(bufferRect.size()); | 126 imageBuffer = ImageBuffer::create(bufferRect.size()); |
| 127 if (!imageBuffer) | 127 if (!imageBuffer) |
| 128 return true; | 128 return true; |
| 129 | 129 |
| 130 drawingContext = imageBuffer->context(); | 130 drawingCanvas = imageBuffer->canvas(); |
| 131 } else { |
| 132 drawingCanvas = canvas; |
| 131 } | 133 } |
| 132 | 134 |
| 133 // Draw the track and its thumb. | 135 // Draw the track and its thumb. |
| 134 gfx::SkiaBitLocker bitLocker( | 136 gfx::SkiaBitLocker bitLocker( |
| 135 drawingContext->canvas(), | 137 drawingCanvas, |
| 136 ThemeMac::inflateRectForAA(scrollbar->frameRect()), | 138 ThemeMac::inflateRectForAA(scrollbar->frameRect()), |
| 137 drawingContext->deviceScaleFactor()); | 139 canDrawDirectly ? context->deviceScaleFactor() : 1.0f); |
| 138 CGContextRef cgContext = bitLocker.cgContext(); | 140 CGContextRef cgContext = bitLocker.cgContext(); |
| 139 HIThemeDrawTrack(&trackInfo, 0, cgContext, kHIThemeOrientationNormal); | 141 HIThemeDrawTrack(&trackInfo, 0, cgContext, kHIThemeOrientationNormal); |
| 140 | 142 |
| 141 IntRect tickmarkTrackRect = trackRect(scrollbar, false); | 143 IntRect tickmarkTrackRect = trackRect(scrollbar, false); |
| 142 if (!canDrawDirectly) { | 144 if (!canDrawDirectly) { |
| 143 tickmarkTrackRect.setX(0); | 145 tickmarkTrackRect.setX(0); |
| 144 tickmarkTrackRect.setY(0); | 146 tickmarkTrackRect.setY(0); |
| 145 } | 147 } |
| 146 // The ends are rounded and the thumb doesn't go there. | 148 // The ends are rounded and the thumb doesn't go there. |
| 147 tickmarkTrackRect.inflateY(-tickmarkTrackRect.width()); | 149 tickmarkTrackRect.inflateY(-tickmarkTrackRect.width()); |
| 148 // Inset a bit. | 150 // Inset a bit. |
| 149 tickmarkTrackRect.setX(tickmarkTrackRect.x() + 2); | 151 tickmarkTrackRect.setX(tickmarkTrackRect.x() + 2); |
| 150 tickmarkTrackRect.setWidth(tickmarkTrackRect.width() - 5); | 152 tickmarkTrackRect.setWidth(tickmarkTrackRect.width() - 5); |
| 151 paintGivenTickmarks(drawingContext, scrollbar, tickmarkTrackRect, tickmarks)
; | 153 paintGivenTickmarks(drawingCanvas, scrollbar, tickmarkTrackRect, tickmarks); |
| 152 | 154 |
| 153 if (!canDrawDirectly) { | 155 if (!canDrawDirectly) { |
| 154 ASSERT(imageBuffer); | 156 ASSERT(imageBuffer); |
| 155 context->drawImageBuffer(imageBuffer.get(), | 157 context->drawImageBuffer(imageBuffer.get(), |
| 156 FloatRect(scrollbar->frameRect().location(), imageBuffer->size())); | 158 FloatRect(scrollbar->frameRect().location(), imageBuffer->size())); |
| 157 } | 159 } |
| 158 | 160 |
| 159 return true; | 161 return true; |
| 160 } | 162 } |
| 161 | 163 |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 313 return IntRect(scrollbar->x() + startWidth, scrollbar->y(), scrollbar->w
idth() - totalWidth, thickness); | 315 return IntRect(scrollbar->x() + startWidth, scrollbar->y(), scrollbar->w
idth() - totalWidth, thickness); |
| 314 return IntRect(scrollbar->x(), scrollbar->y() + startWidth, thickness, scrol
lbar->height() - totalWidth); | 316 return IntRect(scrollbar->x(), scrollbar->y() + startWidth, thickness, scrol
lbar->height() - totalWidth); |
| 315 } | 317 } |
| 316 | 318 |
| 317 int ScrollbarThemeMacNonOverlayAPI::minimumThumbLength(ScrollbarThemeClient* scr
ollbar) | 319 int ScrollbarThemeMacNonOverlayAPI::minimumThumbLength(ScrollbarThemeClient* scr
ollbar) |
| 318 { | 320 { |
| 319 return cThumbMinLength[scrollbar->controlSize()]; | 321 return cThumbMinLength[scrollbar->controlSize()]; |
| 320 } | 322 } |
| 321 | 323 |
| 322 } | 324 } |
| OLD | NEW |