Changeset 37521 in webkit


Ignore:
Timestamp:
Oct 11, 2008 11:50:21 PM (16 years ago)
Author:
alp@webkit.org
Message:

2008-10-11 Alp Toker <alp@nuanti.com>

Reviewed by Darin Adler.

https://bugs.webkit.org/show_bug.cgi?id=20592
The focus ring is not shown while navigating on some pages

Fix drawFocusRing() so it doesn't depend on the current graphics
state, thus matching other platforms which already work this way.

This patch provides two code paths: one using straight Cairo and
one specialised for the GTK+ port with a more conventional appearance.

Also change focusRingColor() to return a null color, allowing the
focus ring to pick up the style's current color if it isn't overridden
with CSS.

  • platform/graphics/cairo/GraphicsContextCairo.cpp: (WebCore::GraphicsContext::drawFocusRing):
  • platform/gtk/TemporaryLinkStubs.cpp: (WebCore::focusRingColor):
Location:
trunk/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r37519 r37521  
     12008-10-11  Alp Toker  <alp@nuanti.com>
     2
     3        Reviewed by Darin Adler.
     4
     5        https://bugs.webkit.org/show_bug.cgi?id=20592
     6        The focus ring is not shown while navigating on some pages
     7
     8        Fix drawFocusRing() so it doesn't depend on the current graphics
     9        state, thus matching other platforms which already work this way.
     10
     11        This patch provides two code paths: one using straight Cairo and
     12        one specialised for the GTK+ port with a more conventional appearance.
     13
     14        Also change focusRingColor() to return a null color, allowing the
     15        focus ring to pick up the style's current color if it isn't overridden
     16        with CSS.
     17
     18        * platform/graphics/cairo/GraphicsContextCairo.cpp:
     19        (WebCore::GraphicsContext::drawFocusRing):
     20        * platform/gtk/TemporaryLinkStubs.cpp:
     21        (WebCore::focusRingColor):
     22
    1232008-10-11  Dan Bernstein  <mitz@apple.com>
    224
  • trunk/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp

    r37456 r37521  
    33 * Copyright (C) 2007 Alp Toker <alp@atoker.com>
    44 * Copyright (C) 2008 Dirk Schulze <vbs85@gmx.de>
     5 * Copyright (C) 2008 Nuanti Ltd.
    56 *
    67 * Redistribution and use in source and binary forms, with or without
     
    530531        return;
    531532
    532     int radius = (focusRingWidth() - 1) / 2;
    533     int offset = radius + focusRingOffset();
    534 
    535533    const Vector<IntRect>& rects = focusRingRects();
    536534    unsigned rectCount = rects.size();
    537     IntRect finalFocusRect;
     535
     536    cairo_t* cr = m_data->cr;
     537    cairo_save(cr);
     538    cairo_push_group(cr);
     539    cairo_new_path(cr);
     540
     541#if PLATFORM(GTK)
     542    GdkRegion* reg = gdk_region_new();
    538543    for (unsigned i = 0; i < rectCount; i++) {
    539         IntRect focusRect = rects[i];
    540         focusRect.inflate(offset);
    541         finalFocusRect.unite(focusRect);
    542     }
    543 
    544     cairo_t* cr = m_data->cr;
    545     cairo_save(cr);
    546     // FIXME: These rects should be rounded
    547     cairo_rectangle(cr, finalFocusRect.x(), finalFocusRect.y(), finalFocusRect.width(), finalFocusRect.height());
     544        GdkRectangle rect = rects[i];
     545        gdk_region_union_with_rect(reg, &rect);
     546    }
     547    gdk_cairo_region(cr, reg);
     548    gdk_region_destroy(reg);
     549
     550    setColor(cr, color);
     551    cairo_set_line_width(cr, 2.0f);
     552    setPlatformStrokeStyle(DottedStroke);
     553#else
     554    int radius = (focusRingWidth() - 1) / 2;
     555    for (unsigned i = 0; i < rectCount; i++)
     556        addPath(Path::createRoundedRectangle(rects[i], FloatSize(radius, radius)));
    548557
    549558    // Force the alpha to 50%.  This matches what the Mac does with outline rings.
    550559    Color ringColor(color.red(), color.green(), color.blue(), 127);
    551560    setColor(cr, ringColor);
    552     cairo_stroke(cr);
     561    cairo_set_line_width(cr, focusRingWidth());
     562    setPlatformStrokeStyle(SolidStroke);
     563#endif
     564
     565    cairo_set_operator(cr, CAIRO_OPERATOR_OVER);
     566    cairo_stroke_preserve(cr);
     567
     568    cairo_set_operator(cr, CAIRO_OPERATOR_CLEAR);
     569    cairo_set_fill_rule(cr, CAIRO_FILL_RULE_WINDING);
     570    cairo_fill(cr);
     571
     572    cairo_pop_group_to_source(cr);
     573    cairo_set_operator(cr, CAIRO_OPERATOR_OVER);
     574    cairo_paint(cr);
    553575    cairo_restore(cr);
    554576}
  • trunk/WebCore/platform/gtk/TemporaryLinkStubs.cpp

    r37301 r37521  
    5959void PluginView::invalidateRegion(NPRegion) { notImplemented(); }
    6060
    61 Color WebCore::focusRingColor() { return 0xFF0000FF; }
     61Color WebCore::focusRingColor() { return Color(); }
    6262void WebCore::setFocusRingColorChangeFunction(void (*)()) { }
    6363
Note: See TracChangeset for help on using the changeset viewer.