Changeset 51065 in webkit


Ignore:
Timestamp:
Nov 16, 2009 9:50:52 PM (14 years ago)
Author:
kevino@webkit.org
Message:

Reviewed by Kevin Ollivier.

Make sure wx scrollbar drawing code factors in transforms when switching backends,
fix calcs for scrollbar length, and tweak the Mac scrollbar tracking rects.

https://bugs.webkit.org/show_bug.cgi?id=31570

Location:
trunk/WebCore
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r51063 r51065  
     12009-11-16  Robin Dunn  <robin@alldunn.com>
     2
     3        Reviewed by Kevin Ollivier.
     4
     5        Make sure wx scrollbar drawing code factors in transforms when switching backends,
     6        fix calcs for scrollbar length, and tweak the Mac scrollbar tracking rects.
     7       
     8        https://bugs.webkit.org/show_bug.cgi?id=31570
     9
     10        * platform/wx/ScrollbarThemeWx.cpp:
     11        (WebCore::ScrollbarThemeWx::minimumThumbLength):
     12        (WebCore::ScrollbarThemeWx::splitTrack):
     13        (WebCore::ScrollbarThemeWx::forwardButtonRect):
     14        * platform/wx/ScrollbarThemeWx.h:
     15        * platform/wx/wxcode/gtk/scrollbar_render.cpp:
     16        (wxRenderer_DrawScrollbar):
     17        * platform/wx/wxcode/scrollbar_render.h:
     18        (calcThumbStartAndLength):
     19        * platform/wx/wxcode/win/scrollbar_render.cpp:
     20        (wxRenderer_DrawScrollbar):
     21
    1222009-11-16  Kent Tamura  <tkent@chromium.org>
    223
  • trunk/WebCore/platform/wx/ScrollbarThemeWx.cpp

    r48511 r51065  
    2929#include "HostWindow.h"
    3030#include "NotImplemented.h"
     31#include "PlatformMouseEvent.h"
    3132#include "Scrollbar.h"
    3233#include "ScrollbarClient.h"
     
    7172}
    7273
     74int ScrollbarThemeWx::minimumThumbLength(Scrollbar* scrollbar)
     75{
     76    return 20;
     77}
     78
    7379IntSize ScrollbarThemeWx::buttonSize(Scrollbar*)
    7480{
     
    8086}
    8187
     88void ScrollbarThemeWx::splitTrack(Scrollbar* scrollbar, const IntRect& unconstrainedTrackRect, IntRect& beforeThumbRect, IntRect& thumbRect, IntRect& afterThumbRect)
     89{
     90    ScrollbarThemeComposite::splitTrack(scrollbar, unconstrainedTrackRect, beforeThumbRect, thumbRect, afterThumbRect);
     91#ifdef __WXMAC__
     92    // on Mac, there are a few pixels drawn above the actual track and so adjust
     93    // the hit testing rects accordingly
     94    int trackStart = 10;
     95    if (scrollbar->orientation() == HorizontalScrollbar) {
     96        thumbRect.setX(thumbRect.x() + trackStart);
     97        afterThumbRect.setX(afterThumbRect.x() - trackStart);
     98    } else {
     99        thumbRect.setY(thumbRect.y() + trackStart);
     100        afterThumbRect.setY(afterThumbRect.y() - trackStart);
     101    }
     102#endif
     103}
    82104
    83105IntRect ScrollbarThemeWx::backButtonRect(Scrollbar* scrollbar, ScrollbarPart part, bool)
     
    112134    int x, y;
    113135    if (scrollbar->orientation() == HorizontalScrollbar) {
     136#ifdef __WXMAC__
     137        size.setWidth(size.width() + cMacButtonOverlap);
     138#endif
    114139        x = scrollbar->x() + scrollbar->width() - size.width();
    115140        y = scrollbar->y();
    116141    } else {
    117142        x = scrollbar->x();
     143#ifdef __WXMAC__
     144        size.setHeight(size.height() + cMacButtonOverlap);
     145#endif
    118146        y = scrollbar->y() + scrollbar->height() - size.height();
    119147    }
  • trunk/WebCore/platform/wx/ScrollbarThemeWx.h

    r48029 r51065  
    4949    virtual IntRect forwardButtonRect(Scrollbar*, ScrollbarPart, bool painting = false);
    5050    virtual IntRect trackRect(Scrollbar*, bool painting = false);
     51
     52    virtual void splitTrack(Scrollbar*, const IntRect& track, IntRect& startTrack, IntRect& thumb, IntRect& endTrack);
     53   
     54    virtual int minimumThumbLength(Scrollbar*);
    5155};
    5256
  • trunk/WebCore/platform/wx/wxcode/gtk/scrollbar_render.cpp

    r48472 r51065  
    117117    dc.DrawRectangle(rect.x, rect.y, rect.width, rect.height);
    118118
     119    // when going from Cairo -> Gdk, any Cairo context transformations are lost
     120    // so we need to alter the coordinates to reflect their transformed point.
     121    double xtrans = 0;
     122    double ytrans = 0;
     123   
     124    wxGCDC* gcdc = wxDynamicCast(&dc, wxGCDC);
     125    wxGraphicsContext* gc = gcdc->GetGraphicsContext();
     126    gc->GetTransform().TransformPoint(&xtrans, &ytrans);
     127
    119128    wxRendererNative& renderer = wxRendererNative::Get();
    120     int x = rect.x;
    121     int y = rect.y;
     129    int x = rect.x + (int)xtrans;
     130    int y = rect.y + (int)ytrans;
    122131
    123132    int buttonLength = 16;
     
    139148    int thumbStart = 0;
    140149    int thumbLength = 0;
    141     calcThumbStartAndLength(physicalLength, max + step, current, step, &thumbStart, &thumbLength);
     150    calcThumbStartAndLength(physicalLength, max, current, step, &thumbStart, &thumbLength);
    142151
    143152    if (horiz) {
    144         buttonRect.x = thumbStart + buttonLength;
     153        buttonRect.x = x + thumbStart + buttonLength;
     154        buttonRect.y = y;
    145155        buttonRect.width = thumbLength;
    146156    } else {
    147         buttonRect.y = thumbStart + buttonLength;
     157        buttonRect.x = x;
     158        buttonRect.y = y + thumbStart + buttonLength;
    148159        buttonRect.height = thumbLength;
    149160    }
  • trunk/WebCore/platform/wx/wxcode/scrollbar_render.h

    r48029 r51065  
    5151                                       int max, int step, int flags=0);
    5252
    53 inline void calcThumbStartAndLength(int physicalLength, int virtualLength, int current,
     53inline void calcThumbStartAndLength(int physicalLength, int max, int current,
    5454                                int step, int *thumbStart, int *thumbLength)
    5555{
    56         float proportion = (float)physicalLength / virtualLength;
    57         float scale = (float)virtualLength / physicalLength;
    58         int thumbSize = proportion * physicalLength;
    59         int currentPos = current / scale;
    60        
     56        float proportion = ((float)physicalLength - 8)/ (max + step);
     57        float thumbSize =  proportion * (float)physicalLength;
     58        if (thumbSize < 20)
     59            thumbSize = 20;
     60
     61        float thumbPos = ((float)current / (float)max) * ((float)physicalLength - thumbSize);
    6162        if (thumbStart)
    62             *thumbStart = currentPos;
     63            *thumbStart = thumbPos;
    6364       
    6465        if (thumbLength)
  • trunk/WebCore/platform/wx/wxcode/win/scrollbar_render.cpp

    r48029 r51065  
    3131
    3232#include <wx/dc.h>
     33#include <wx/dcgraph.h>
     34#include <wx/graphics.h>
    3335#include <wx/renderer.h>
    3436#include <wx/window.h>
     
    132134
    133135    int xpState = TS_NORMAL;
     136    wxRect transRect = rect;
     137
     138#if USE(WXGC)
     139    // when going from GdiPlus -> Gdi, any GdiPlus transformations are lost
     140    // so we need to alter the coordinates to reflect their transformed point.
     141    double xtrans = 0;
     142    double ytrans = 0;
     143   
     144    wxGCDC* gcdc = wxDynamicCast(&dc, wxGCDC);
     145    wxGraphicsContext* gc = gcdc->GetGraphicsContext();
     146    gc->GetTransform().TransformPoint(&xtrans, &ytrans);
     147
     148    transRect.x += (int)xtrans;
     149    transRect.y += (int)ytrans;
     150#endif
     151
    134152    RECT r;
    135     wxCopyRectToRECT(rect, r);
     153    wxCopyRectToRECT(transRect, r);
    136154
    137155    // Unlike Mac, on MSW you draw the scrollbar piece by piece.
     
    164182        int thumbStart = 0;
    165183        int thumbLength = 0;
    166         calcThumbStartAndLength(physicalLength, max + step,
     184        calcThumbStartAndLength(physicalLength, max,
    167185                            current, step, &thumbStart, &thumbLength);
    168186        buttonRect = r;
    169187        if (horiz) {
    170             buttonRect.left = thumbStart + buttonSize;
     188            buttonRect.left = buttonRect.left + thumbStart + buttonSize;
    171189            buttonRect.right = buttonRect.left + thumbLength;
    172190        } else {
    173             buttonRect.top = thumbStart + buttonSize;
     191            buttonRect.top = buttonRect.top + thumbStart + buttonSize;
    174192            buttonRect.bottom = buttonRect.top + thumbLength;
    175193        }
Note: See TracChangeset for help on using the changeset viewer.