Changeset 89073 in webkit


Ignore:
Timestamp:
Jun 16, 2011 3:08:11 PM (13 years ago)
Author:
commit-queue@webkit.org
Message:

2011-06-16 Sailesh Agrawal <sail@chromium.org>

Reviewed by Mihai Parparita.

[Chromium] Draw search tickmarks on overlay scrollbars
https://bugs.webkit.org/show_bug.cgi?id=62783

This change adds search tickmark support for overlay scrollbars. Tickmarks are only drawn when the scroll track is visible.

  • platform/chromium/ScrollbarOverlayUtilitiesChromiumMac.h:Split the scrollbar drawing code into a track and knob version.
  • platform/chromium/ScrollbarOverlayUtilitiesChromiumMac.mm: (wkScrollbarPainterPaint): (wkScrollbarPainterPaintTrack): (wkScrollbarPainterPaintKnob):
  • platform/chromium/ScrollbarThemeChromiumMac.h:
  • platform/chromium/ScrollbarThemeChromiumMac.mm:Factor out the paint tickmark code and call it from the overlay scrollbar drawing code. (WebCore::ScrollbarThemeChromiumMac::paint): (WebCore::ScrollbarThemeChromiumMac::paintTickmarks):
Location:
trunk/Source/WebCore
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r89069 r89073  
     12011-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
    1202011-06-16  Geoffrey Garen  <ggaren@apple.com>
    221
  • trunk/Source/WebCore/platform/chromium/ScrollbarOverlayUtilitiesChromiumMac.h

    r89066 r89073  
    5858void wkScrollbarPainterSetOverlayState(WKScrollbarPainterRef, int overlayScrollerState);
    5959void wkScrollbarPainterPaint(WKScrollbarPainterRef, bool enabled, double value, CGFloat proportion, NSRect frameRect);
     60void wkScrollbarPainterPaintTrack(WKScrollbarPainterRef, bool enabled, double value, CGFloat proportion, NSRect frameRect);
     61void wkScrollbarPainterPaintKnob(WKScrollbarPainterRef);
    6062int wkScrollbarMinimumThumbLength(WKScrollbarPainterRef);
    6163void wkScrollbarPainterSetDelegate(WKScrollbarPainterRef, id scrollbarPainterDelegate);
  • trunk/Source/WebCore/platform/chromium/ScrollbarOverlayUtilitiesChromiumMac.mm

    r89066 r89073  
    153153void wkScrollbarPainterPaint(WKScrollbarPainterRef painter, bool enabled, double value, CGFloat proportion, NSRect frameRect)
    154154{
     155    wkScrollbarPainterPaintTrack(painter, enabled, value, proportion, frameRect);
     156    wkScrollbarPainterPaintKnob(painter);
     157}
     158
     159void wkScrollbarPainterPaintTrack(WKScrollbarPainterRef painter, bool enabled, double value, CGFloat proportion, NSRect frameRect)
     160{
    155161    [painter setEnabled:enabled];
    156162    [painter setBoundsSize:frameRect.size];
     
    165171
    166172    [painter drawKnobSlotInRect:frameRect highlight:NO];
     173}
     174
     175void wkScrollbarPainterPaintKnob(WKScrollbarPainterRef painter)
     176{
    167177    [painter drawKnob];
    168178}
  • trunk/Source/WebCore/platform/chromium/ScrollbarThemeChromiumMac.h

    r88396 r89073  
    7272    virtual bool shouldDragDocumentInsteadOfThumb(Scrollbar*, const PlatformMouseEvent&);
    7373
     74    void paintTickmarks(Scrollbar*, GraphicsContext* drawingContext, bool canDrawDirectly, float alpha);
     75
    7476public:
    7577    void preferencesChanged();
  • trunk/Source/WebCore/platform/chromium/ScrollbarThemeChromiumMac.mm

    r88396 r89073  
    480480        context->translate(scrollbar->frameRect().x(), scrollbar->frameRect().y());
    481481        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);
    487492
    488493        scrollAnimator->setIsDrawingIntoLayer(false);
     
    545550    HIThemeDrawTrack(&trackInfo, 0, cgContext, kHIThemeOrientationNormal);
    546551
    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);
    581553
    582554    if (hasThumb(scrollbar)) {
     
    603575}
    604576
    605 }
     577void 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.