Changeset 86070 in webkit


Ignore:
Timestamp:
May 9, 2011 11:20:35 AM (13 years ago)
Author:
kevino@webkit.org
Message:

Reviewed by Kevin Ollivier.

[wx] Make sure other controls adjust the rect to handle transforms, and turn off the
adjustment in 2.9.2+ where it is handled internally by wx.

Also add a couple drawing and focus handling fixes for text fields and menulist controls.

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

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r86069 r86070  
     12011-05-09  Robin Dunn  <robin@alldunn.com>
     2
     3        Reviewed by Kevin Ollivier.
     4
     5        [wx] Make sure other controls adjust the rect to handle transforms, and turn off the
     6        adjustment in 2.9.2+ where it is handled internally by wx.
     7       
     8        Also add a couple drawing and focus handling fixes for text fields and menulist controls.
     9       
     10        https://bugs.webkit.org/show_bug.cgi?id=60481
     11
     12        * platform/wx/RenderThemeWx.cpp:
     13        (WebCore::getAdjustedRect):
     14        (WebCore::RenderThemeWx::supportsFocus):
     15        (WebCore::RenderThemeWx::paintButton):
     16        (WebCore::RenderThemeWx::adjustTextFieldStyle):
     17        (WebCore::RenderThemeWx::paintTextField):
     18        (WebCore::RenderThemeWx::adjustMenuListStyle):
     19        (WebCore::RenderThemeWx::paintMenuList):
     20        (WebCore::RenderThemeWx::paintMenuListButton):
     21
    1222011-05-09  Tony Gentilcore  <tonyg@chromium.org>
    223
  • trunk/Source/WebCore/platform/wx/RenderThemeWx.cpp

    r77392 r86070  
    4646namespace WebCore {
    4747
     48IntRect getAdjustedRect(wxDC* dc, const IntRect& r)
     49{
     50    IntRect rect = r;
     51// On Mac, wxGraphicsContext and wxDC share the same native implementation,
     52// and so transformations are available.
     53// On Win and Linux, however, this is not true and transforms are lost,
     54// so we need to restore them here.
     55#if !wxCHECK_VERSION(2, 9, 2) && USE(WXGC) && !defined(__WXMAC__)
     56    LOG_ERROR("Rect is (%d, %d)\n", rect.x(), rect.y());
     57    double xtrans = 0;
     58    double ytrans = 0;
     59   
     60    wxGCDC* gcdc = static_cast<wxGCDC*>(dc);
     61    wxGraphicsContext* gc = gcdc->GetGraphicsContext();
     62    gc->GetTransform().TransformPoint(&xtrans, &ytrans);
     63    rect.setX(r.x() + (int)xtrans);
     64    rect.setY(r.y() + (int)ytrans);
     65    LOG_ERROR("Transform is (%f, %f), (%d, %d)\n", xtrans, ytrans, rect.x(), rect.y());
     66#endif
     67
     68    return rect;
     69}
     70
    4871class RenderThemeWx : public RenderTheme {
    4972private:
     
    250273        case ButtonPart:
    251274        case TextFieldPart:
     275        case MenulistPart:
    252276            return true;
    253277        default: // No for all others...
     
    267291    int flags = 0;
    268292   
    269     IntRect rect = r;
    270 
    271 // On Mac, wxGraphicsContext and wxDC share the same native implementation,
    272 // and so transformations are available.
    273 // On Win and Linux, however, this is not true and transforms are lost,
    274 // so we need to restore them here.
    275 #if USE(WXGC) && !defined(__WXMAC__)
    276     double xtrans = 0;
    277     double ytrans = 0;
    278    
    279     wxGCDC* gcdc = static_cast<wxGCDC*>(dc);
    280     wxGraphicsContext* gc = gcdc->GetGraphicsContext();
    281     gc->GetTransform().TransformPoint(&xtrans, &ytrans);
    282     rect.setX(r.x() + (int)xtrans);
    283     rect.setY(r.y() + (int)ytrans);
    284 #endif
     293    IntRect rect = getAdjustedRect(dc, r);
    285294
    286295    if (!isEnabled(o))
     
    317326void RenderThemeWx::adjustTextFieldStyle(CSSStyleSelector*, RenderStyle* style, Element*) const
    318327{
    319    
     328
    320329}
    321330
     
    324333    wxWindow* window = nativeWindowForRenderObject(o);
    325334    wxDC* dc = static_cast<wxDC*>(i.context->platformContext());
     335    int flags = 0;
     336   
     337    IntRect rect = getAdjustedRect(dc, r);
     338
     339    ControlPart part = o->style()->appearance();
     340    if (supportsFocus(part) && isFocused(o))
     341        flags |= wxCONTROL_FOCUSED;
     342
    326343#if wxCHECK_VERSION(2,9,0)
    327     wxRendererNative::Get().DrawTextCtrl(window, *dc, r, 0);
     344    wxRendererNative::Get().DrawTextCtrl(window, *dc, rect, flags);
    328345#else
    329346    wxRenderer_DrawTextCtrl(window, *dc, r, 0);
     
    340357void RenderThemeWx::adjustMenuListStyle(CSSStyleSelector*, RenderStyle* style, Element*) const
    341358{
     359     style->resetBorder();
     360
     361    // Height is locked to auto.
     362    style->setHeight(Length(Auto));
     363   
     364    style->setPaddingTop(Length(2, Fixed));
     365    style->setPaddingBottom(Length(2, Fixed));
    342366}
    343367   
     
    346370    wxWindow* window = nativeWindowForRenderObject(o);
    347371    wxDC* dc = static_cast<wxDC*>(i.context->platformContext());
    348    
     372 
     373    IntRect rect = getAdjustedRect(dc, r);
     374
    349375    int flags = 0;     
    350376    if (!isEnabled(o))
     
    358384
    359385#if wxCHECK_VERSION(2,9,0)
    360     wxRendererNative::Get().DrawChoice(window, *dc, r, flags);
    361 #else
    362     wxRenderer_DrawChoice(window, *dc, r, flags);
     386    wxRendererNative::Get().DrawChoice(window, *dc, rect, flags);
     387#else
     388    wxRenderer_DrawChoice(window, *dc, rect, flags);
    363389#endif
    364390
     
    375401    wxWindow* window = nativeWindowForRenderObject(o);
    376402    wxDC* dc = static_cast<wxDC*>(i.context->platformContext());
    377    
     403
     404    IntRect rect = getAdjustedRect(dc, r);
     405
    378406    int flags = 0;     
    379407    if (!isEnabled(o))
     
    386414        flags |= wxCONTROL_PRESSED;
    387415
    388     wxRendererNative::Get().DrawComboBoxDropButton(window, *dc, r, flags);
     416    wxRendererNative::Get().DrawComboBoxDropButton(window, *dc, rect, flags);
    389417           
    390418    return false;
Note: See TracChangeset for help on using the changeset viewer.