Changeset 89073 in webkit
- Timestamp:
- Jun 16, 2011 3:08:11 PM (13 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r89069 r89073 1 2011-06-16 Sailesh Agrawal <sail@chromium.org> 2 3 Reviewed by Mihai Parparita. 4 5 [Chromium] Draw search tickmarks on overlay scrollbars 6 https://bugs.webkit.org/show_bug.cgi?id=62783 7 8 This change adds search tickmark support for overlay scrollbars. Tickmarks are only drawn when the scroll track is visible. 9 10 * platform/chromium/ScrollbarOverlayUtilitiesChromiumMac.h:Split the scrollbar drawing code into a track and knob version. 11 * platform/chromium/ScrollbarOverlayUtilitiesChromiumMac.mm: 12 (wkScrollbarPainterPaint): 13 (wkScrollbarPainterPaintTrack): 14 (wkScrollbarPainterPaintKnob): 15 * platform/chromium/ScrollbarThemeChromiumMac.h: 16 * platform/chromium/ScrollbarThemeChromiumMac.mm:Factor out the paint tickmark code and call it from the overlay scrollbar drawing code. 17 (WebCore::ScrollbarThemeChromiumMac::paint): 18 (WebCore::ScrollbarThemeChromiumMac::paintTickmarks): 19 1 20 2011-06-16 Geoffrey Garen <ggaren@apple.com> 2 21 -
trunk/Source/WebCore/platform/chromium/ScrollbarOverlayUtilitiesChromiumMac.h
r89066 r89073 58 58 void wkScrollbarPainterSetOverlayState(WKScrollbarPainterRef, int overlayScrollerState); 59 59 void wkScrollbarPainterPaint(WKScrollbarPainterRef, bool enabled, double value, CGFloat proportion, NSRect frameRect); 60 void wkScrollbarPainterPaintTrack(WKScrollbarPainterRef, bool enabled, double value, CGFloat proportion, NSRect frameRect); 61 void wkScrollbarPainterPaintKnob(WKScrollbarPainterRef); 60 62 int wkScrollbarMinimumThumbLength(WKScrollbarPainterRef); 61 63 void wkScrollbarPainterSetDelegate(WKScrollbarPainterRef, id scrollbarPainterDelegate); -
trunk/Source/WebCore/platform/chromium/ScrollbarOverlayUtilitiesChromiumMac.mm
r89066 r89073 153 153 void wkScrollbarPainterPaint(WKScrollbarPainterRef painter, bool enabled, double value, CGFloat proportion, NSRect frameRect) 154 154 { 155 wkScrollbarPainterPaintTrack(painter, enabled, value, proportion, frameRect); 156 wkScrollbarPainterPaintKnob(painter); 157 } 158 159 void wkScrollbarPainterPaintTrack(WKScrollbarPainterRef painter, bool enabled, double value, CGFloat proportion, NSRect frameRect) 160 { 155 161 [painter setEnabled:enabled]; 156 162 [painter setBoundsSize:frameRect.size]; … … 165 171 166 172 [painter drawKnobSlotInRect:frameRect highlight:NO]; 173 } 174 175 void wkScrollbarPainterPaintKnob(WKScrollbarPainterRef painter) 176 { 167 177 [painter drawKnob]; 168 178 } -
trunk/Source/WebCore/platform/chromium/ScrollbarThemeChromiumMac.h
r88396 r89073 72 72 virtual bool shouldDragDocumentInsteadOfThumb(Scrollbar*, const PlatformMouseEvent&); 73 73 74 void paintTickmarks(Scrollbar*, GraphicsContext* drawingContext, bool canDrawDirectly, float alpha); 75 74 76 public: 75 77 void preferencesChanged(); -
trunk/Source/WebCore/platform/chromium/ScrollbarThemeChromiumMac.mm
r88396 r89073 480 480 context->translate(scrollbar->frameRect().x(), scrollbar->frameRect().y()); 481 481 LocalCurrentGraphicsContext localContext(context); 482 wkScrollbarPainterPaint(scrollbarMap()->get(scrollbar).get(), 483 scrollbar->enabled(), 484 value, 485 (static_cast<CGFloat>(scrollbar->visibleSize()) - overhang) / scrollbar->totalSize(), 486 scrollbar->frameRect()); 482 WKScrollbarPainterRef scrollbarPainter = scrollbarMap()->get(scrollbar).get(); 483 wkScrollbarPainterPaintTrack(scrollbarPainter, 484 scrollbar->enabled(), 485 value, 486 (static_cast<CGFloat>(scrollbar->visibleSize()) - overhang) / scrollbar->totalSize(), 487 scrollbar->frameRect()); 488 CGFloat trackAlpha = wkScrollbarPainterTrackAlpha(scrollbarPainter); 489 if (trackAlpha >= 0.0) 490 paintTickmarks(scrollbar, context, false, trackAlpha); 491 wkScrollbarPainterPaintKnob(scrollbarPainter); 487 492 488 493 scrollAnimator->setIsDrawingIntoLayer(false); … … 545 550 HIThemeDrawTrack(&trackInfo, 0, cgContext, kHIThemeOrientationNormal); 546 551 547 Vector<IntRect> tickmarks; 548 scrollbar->scrollableArea()->getTickmarks(tickmarks); 549 if (scrollbar->orientation() == VerticalScrollbar && tickmarks.size()) { 550 drawingContext->save(); 551 drawingContext->setShouldAntialias(false); 552 drawingContext->setStrokeColor(Color(0xCC, 0xAA, 0x00, 0xFF), ColorSpaceDeviceRGB); 553 drawingContext->setFillColor(Color(0xFF, 0xDD, 0x00, 0xFF), ColorSpaceDeviceRGB); 554 555 IntRect thumbArea = trackRect(scrollbar, false); 556 if (!canDrawDirectly) { 557 thumbArea.setX(0); 558 thumbArea.setY(0); 559 } 560 // The ends are rounded and the thumb doesn't go there. 561 thumbArea.inflateY(-thumbArea.width()); 562 563 for (Vector<IntRect>::const_iterator i = tickmarks.begin(); i != tickmarks.end(); ++i) { 564 // Calculate how far down (in %) the tick-mark should appear. 565 const float percent = static_cast<float>(i->y()) / scrollbar->totalSize(); 566 if (percent < 0.0 || percent > 1.0) 567 continue; 568 569 // Calculate how far down (in pixels) the tick-mark should appear. 570 const int yPos = static_cast<int>((thumbArea.y() + (thumbArea.height() * percent))) & ~1; 571 572 // Paint. 573 const int indent = 2; 574 FloatRect tickRect(thumbArea.x() + indent, yPos, thumbArea.width() - 2 * indent - 1, 2); 575 drawingContext->fillRect(tickRect); 576 drawingContext->strokeRect(tickRect, 1); 577 } 578 579 drawingContext->restore(); 580 } 552 paintTickmarks(scrollbar, drawingContext, canDrawDirectly, 1.0); 581 553 582 554 if (hasThumb(scrollbar)) { … … 603 575 } 604 576 605 } 577 void ScrollbarThemeChromiumMac::paintTickmarks(Scrollbar* scrollbar, GraphicsContext* drawingContext, bool canDrawDirectly, float alpha) { 578 Vector<IntRect> tickmarks; 579 scrollbar->scrollableArea()->getTickmarks(tickmarks); 580 if (scrollbar->orientation() == VerticalScrollbar && tickmarks.size()) { 581 drawingContext->save(); 582 drawingContext->setShouldAntialias(false); 583 int alphaInt = 0xFF * alpha; 584 drawingContext->setStrokeColor(Color(0xCC, 0xAA, 0x00, alphaInt), ColorSpaceDeviceRGB); 585 drawingContext->setFillColor(Color(0xFF, 0xDD, 0x00, alphaInt), ColorSpaceDeviceRGB); 586 587 IntRect thumbArea = trackRect(scrollbar, false); 588 if (!canDrawDirectly) { 589 thumbArea.setX(0); 590 thumbArea.setY(0); 591 } 592 // The ends are rounded and the thumb doesn't go there. 593 thumbArea.inflateY(-thumbArea.width()); 594 595 for (Vector<IntRect>::const_iterator i = tickmarks.begin(); i != tickmarks.end(); ++i) { 596 // Calculate how far down (in %) the tick-mark should appear. 597 const float percent = static_cast<float>(i->y()) / scrollbar->totalSize(); 598 if (percent < 0.0 || percent > 1.0) 599 continue; 600 601 // Calculate how far down (in pixels) the tick-mark should appear. 602 const int yPos = static_cast<int>((thumbArea.y() + (thumbArea.height() * percent))) & ~1; 603 604 // Paint. 605 const int indent = 2; 606 FloatRect tickRect(thumbArea.x() + indent, yPos, thumbArea.width() - 2 * indent - 1, 2); 607 drawingContext->fillRect(tickRect); 608 drawingContext->strokeRect(tickRect, 1); 609 } 610 611 drawingContext->restore(); 612 } 613 } 614 615 }
Note: See TracChangeset
for help on using the changeset viewer.