Changeset 53857 in webkit


Ignore:
Timestamp:
Jan 26, 2010 10:06:41 AM (14 years ago)
Author:
Chris Fleizach
Message:

Add ability for image maps to be focused via tabbing
https://bugs.webkit.org/show_bug.cgi?id=17513

Reviewed by Darin Adler.

WebCore:

Test: fast/events/tab-imagemap.html

  • accessibility/AXObjectCache.cpp:

(WebCore::AXObjectCache::focusedImageMapUIElement):
(WebCore::AXObjectCache::focusedUIElementForPage):

  • accessibility/AXObjectCache.h:
  • accessibility/AccessibilityImageMapLink.h:

(WebCore::AccessibilityImageMapLink::areaElement):
(WebCore::AccessibilityImageMapLink::mapElement):
(WebCore::AccessibilityImageMapLink::isImageMapLink):

  • accessibility/AccessibilityObject.h:

(WebCore::AccessibilityObject::isImageMapLink):

  • accessibility/AccessibilityRenderObject.cpp:

(WebCore::AccessibilityRenderObject::accessibilityParentForImageMap):

  • html/HTMLAreaElement.cpp:

(WebCore::HTMLAreaElement::getPath):
(WebCore::HTMLAreaElement::getRect):
(WebCore::HTMLAreaElement::imageElement):
(WebCore::HTMLAreaElement::isKeyboardFocusable):
(WebCore::HTMLAreaElement::isFocusable):
(WebCore::HTMLAreaElement::dispatchBlurEvent):
(WebCore::HTMLAreaElement::updateFocusAppearance):
(WebCore::HTMLAreaElement::supportsFocus):

  • html/HTMLAreaElement.h:
  • html/HTMLMapElement.cpp:

(WebCore::HTMLMapElement::imageElement):

  • html/HTMLMapElement.h:
  • platform/graphics/GraphicsContext.h:
  • platform/graphics/cairo/GraphicsContextCairo.cpp:

(WebCore::GraphicsContext::drawFocusRing):

  • platform/graphics/haiku/GraphicsContextHaiku.cpp:

(WebCore::GraphicsContext::drawFocusRing):

  • platform/graphics/mac/GraphicsContextMac.mm:

(WebCore::drawFocusRingToContext):
(WebCore::GraphicsContext::drawFocusRing):

  • platform/graphics/qt/GraphicsContextQt.cpp:

(WebCore::GraphicsContext::drawFocusRing):

  • platform/graphics/skia/GraphicsContextSkia.cpp:

(WebCore::GraphicsContext::drawFocusRing):

  • platform/graphics/win/GraphicsContextCGWin.cpp:

(WebCore::GraphicsContext::drawFocusRing):

  • platform/graphics/wince/GraphicsContextWince.cpp:

(WebCore::GraphicsContext::drawFocusRing):

  • platform/graphics/wx/GraphicsContextWx.cpp:

(WebCore::GraphicsContext::drawFocusRing):

  • rendering/RenderImage.cpp:

(WebCore::RenderImage::paint):
(WebCore::RenderImage::paintFocusRings):
(WebCore::RenderImage::imageMap):

  • rendering/RenderImage.h:
  • rendering/RenderReplaced.h:

LayoutTests:

  • fast/events/resources/tabindex-focus-blur-all.js:

(test):
(testProgrammaticFocus):

  • fast/events/tab-imagemap-expected.txt: Added.
  • fast/events/tab-imagemap.html: Added.
  • fast/events/tabindex-focus-blur-all-expected.txt:
Location:
trunk
Files:
2 added
25 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r53845 r53857  
     12010-01-26  Chris Fleizach  <cfleizach@apple.com>
     2
     3        Reviewed by Darin Adler.
     4
     5        Add ability for image maps to be focused via tabbing
     6        https://bugs.webkit.org/show_bug.cgi?id=17513
     7
     8        * fast/events/resources/tabindex-focus-blur-all.js:
     9        (test):
     10        (testProgrammaticFocus):
     11        * fast/events/tab-imagemap-expected.txt: Added.
     12        * fast/events/tab-imagemap.html: Added.
     13        * fast/events/tabindex-focus-blur-all-expected.txt:
     14
    1152010-01-26  Simon Hausmann  <simon.hausmann@nokia.com>
    216
  • trunk/LayoutTests/fast/events/resources/tabindex-focus-blur-all.js

    r48257 r53857  
    1212
    1313var tagNamesAlwaysFocused = ["A",
     14                             "AREA",
    1415                             "BUTTON",
    1516                             "IFRAME",
     
    2021
    2122var tagNamesTransferFocused = ["LABEL"]; // labels always transfer focus to the labeled element
     23
     24var noDisplayTagNamesWithFocus = ["AREA"];  // AREA elements can get focus, but are not displayed.
    2225
    2326function printToConsole(str)
     
    5053    homeBase[0].focus();
    5154
    52     var resultSummary = focusCount+" focus / "+blurCount+" blur events dispatched, and should be 329 / 329 ";
     55    var resultSummary = focusCount+" focus / "+blurCount+" blur events dispatched, and should be 337 / 337 ";
    5356    resultSummary += (focusCount==blurCount) ? "<span style='color:green'>PASSED</span><br>" : "<span style='color:red'>FAILED</span><br>";
    5457    resultSummary += "Total of "+failedTestCount+" focus test(s) failed.";
     
    103106    else if (tagNamesAlwaysFocused.find(elem.tagName)) // special case form elements and other controls that are always focusable
    104107        elemThatShouldFocus = elem;
    105    
     108
    106109    // Hidden elements should not be focusable. https://bugs.webkit.org/show_bug.cgi?id=27099
    107     if (document.defaultView.getComputedStyle(elem).display == "none")
     110    if (document.defaultView.getComputedStyle(elem).display == "none" && !noDisplayTagNamesWithFocus.find(elem.tagName))
    108111        elemThatShouldFocus = null;
    109112
  • trunk/LayoutTests/fast/events/tabindex-focus-blur-all-expected.txt

    r48257 r53857  
    1 329 focus / 329 blur events dispatched, and should be 329 / 329 PASSED
     1337 focus / 337 blur events dispatched, and should be 337 / 337 PASSED
    22Total of 0 focus test(s) failed. PASSED
  • trunk/WebCore/ChangeLog

    r53856 r53857  
     12010-01-26  Chris Fleizach  <cfleizach@apple.com>
     2
     3        Reviewed by Darin Adler.
     4
     5        Add ability for image maps to be focused via tabbing
     6        https://bugs.webkit.org/show_bug.cgi?id=17513
     7
     8        Test: fast/events/tab-imagemap.html
     9
     10        * accessibility/AXObjectCache.cpp:
     11        (WebCore::AXObjectCache::focusedImageMapUIElement):
     12        (WebCore::AXObjectCache::focusedUIElementForPage):
     13        * accessibility/AXObjectCache.h:
     14        * accessibility/AccessibilityImageMapLink.h:
     15        (WebCore::AccessibilityImageMapLink::areaElement):
     16        (WebCore::AccessibilityImageMapLink::mapElement):
     17        (WebCore::AccessibilityImageMapLink::isImageMapLink):
     18        * accessibility/AccessibilityObject.h:
     19        (WebCore::AccessibilityObject::isImageMapLink):
     20        * accessibility/AccessibilityRenderObject.cpp:
     21        (WebCore::AccessibilityRenderObject::accessibilityParentForImageMap):
     22        * html/HTMLAreaElement.cpp:
     23        (WebCore::HTMLAreaElement::getPath):
     24        (WebCore::HTMLAreaElement::getRect):
     25        (WebCore::HTMLAreaElement::imageElement):
     26        (WebCore::HTMLAreaElement::isKeyboardFocusable):
     27        (WebCore::HTMLAreaElement::isFocusable):
     28        (WebCore::HTMLAreaElement::dispatchBlurEvent):
     29        (WebCore::HTMLAreaElement::updateFocusAppearance):
     30        (WebCore::HTMLAreaElement::supportsFocus):
     31        * html/HTMLAreaElement.h:
     32        * html/HTMLMapElement.cpp:
     33        (WebCore::HTMLMapElement::imageElement):
     34        * html/HTMLMapElement.h:
     35        * platform/graphics/GraphicsContext.h:
     36        * platform/graphics/cairo/GraphicsContextCairo.cpp:
     37        (WebCore::GraphicsContext::drawFocusRing):
     38        * platform/graphics/haiku/GraphicsContextHaiku.cpp:
     39        (WebCore::GraphicsContext::drawFocusRing):
     40        * platform/graphics/mac/GraphicsContextMac.mm:
     41        (WebCore::drawFocusRingToContext):
     42        (WebCore::GraphicsContext::drawFocusRing):
     43        * platform/graphics/qt/GraphicsContextQt.cpp:
     44        (WebCore::GraphicsContext::drawFocusRing):
     45        * platform/graphics/skia/GraphicsContextSkia.cpp:
     46        (WebCore::GraphicsContext::drawFocusRing):
     47        * platform/graphics/win/GraphicsContextCGWin.cpp:
     48        (WebCore::GraphicsContext::drawFocusRing):
     49        * platform/graphics/wince/GraphicsContextWince.cpp:
     50        (WebCore::GraphicsContext::drawFocusRing):
     51        * platform/graphics/wx/GraphicsContextWx.cpp:
     52        (WebCore::GraphicsContext::drawFocusRing):
     53        * rendering/RenderImage.cpp:
     54        (WebCore::RenderImage::paint):
     55        (WebCore::RenderImage::paintFocusRings):
     56        (WebCore::RenderImage::imageMap):
     57        * rendering/RenderImage.h:
     58        * rendering/RenderReplaced.h:
     59
    1602010-01-26  Pavel Feldman  <pfeldman@chromium.org>
    261
  • trunk/WebCore/accessibility/AXObjectCache.cpp

    r53644 r53857  
    5151#include "FocusController.h"
    5252#include "Frame.h"
     53#include "HTMLAreaElement.h"
     54#include "HTMLImageElement.h"
    5355#include "HTMLNames.h"
    5456#if ENABLE(VIDEO)
     
    8587}
    8688
     89AccessibilityObject* AXObjectCache::focusedImageMapUIElement(HTMLAreaElement* areaElement)
     90{
     91    // Find the corresponding accessibility object for the HTMLAreaElement. This should be
     92    // in the list of children for its corresponding image.
     93    if (!areaElement)
     94        return 0;
     95   
     96    HTMLImageElement* imageElement = areaElement->imageElement();
     97    if (!imageElement)
     98        return 0;
     99   
     100    AccessibilityObject* axRenderImage = areaElement->document()->axObjectCache()->getOrCreate(imageElement->renderer());
     101    if (!axRenderImage)
     102        return 0;
     103   
     104    AccessibilityObject::AccessibilityChildrenVector imageChildren = axRenderImage->children();
     105    unsigned count = imageChildren.size();
     106    for (unsigned k = 0; k < count; ++k) {
     107        AccessibilityObject* child = imageChildren[k].get();
     108        if (!child->isImageMapLink())
     109            continue;
     110       
     111        if (static_cast<AccessibilityImageMapLink*>(child)->areaElement() == areaElement)
     112            return child;
     113    }   
     114   
     115    return 0;
     116}
     117   
    87118AccessibilityObject* AXObjectCache::focusedUIElementForPage(const Page* page)
    88119{
     
    93124        focusedNode = focusedDocument;
    94125
     126    if (focusedNode->hasTagName(areaTag))
     127        return focusedImageMapUIElement(static_cast<HTMLAreaElement*>(focusedNode));
     128   
    95129    RenderObject* focusedNodeRenderer = focusedNode->renderer();
    96130    if (!focusedNodeRenderer)
  • trunk/WebCore/accessibility/AXObjectCache.h

    r53644 r53857  
    4343namespace WebCore {
    4444
     45class HTMLAreaElement;
    4546class Node;
    4647class Page;
     
    136137    void notificationPostTimerFired(Timer<AXObjectCache>*);
    137138   
     139    static AccessibilityObject* focusedImageMapUIElement(HTMLAreaElement*);
     140   
    138141    AXID getAXID(AccessibilityObject*);
    139142    bool nodeIsAriaType(Node*, String role);
  • trunk/WebCore/accessibility/AccessibilityImageMapLink.h

    r51195 r53857  
    4545   
    4646    void setHTMLAreaElement(HTMLAreaElement* element) { m_areaElement = element; }
     47    HTMLAreaElement* areaElement() const { return m_areaElement; }
     48   
    4749    void setHTMLMapElement(HTMLMapElement* element) { m_mapElement = element; }   
     50    HTMLMapElement* mapElement() const { return m_mapElement; }
     51   
    4852    void setParent(AccessibilityObject* parent) { m_parent = parent; }
    4953       
     
    5155    virtual bool accessibilityIsIgnored() const { return false; }
    5256    virtual bool isEnabled() const { return true; }
    53 
     57   
    5458    virtual AccessibilityObject* parentObject() const;
    5559    virtual Element* anchorElement() const;
     
    7175    HTMLMapElement* m_mapElement;
    7276    AccessibilityObject* m_parent;
     77   
     78    virtual bool isImageMapLink() const { return true; }
    7379};
    7480   
  • trunk/WebCore/accessibility/AccessibilityObject.h

    r53512 r53857  
    286286    virtual bool isGroup() const { return false; }
    287287    virtual bool isARIATreeGridRow() const { return false; }
     288    virtual bool isImageMapLink() const { return false; }
    288289    virtual bool isMenuList() const { return false; }
    289290    virtual bool isMenuListPopup() const { return false; }
  • trunk/WebCore/accessibility/AccessibilityRenderObject.cpp

    r53573 r53857  
    20502050{
    20512051    // find an image that is using this map
    2052     if (!m_renderer || !map)
    2053         return 0;
    2054 
    2055     String mapName = map->getName().string().lower();
    2056     RefPtr<HTMLCollection> coll = m_renderer->document()->images();
    2057     for (Node* curr = coll->firstItem(); curr; curr = coll->nextItem()) {
    2058         RenderObject* obj = curr->renderer();
    2059         if (!obj || !curr->hasTagName(imgTag))
    2060             continue;
    2061        
    2062         // The HTMLImageElement's useMap() value includes the '#' symbol at the beginning,
    2063         // which has to be stripped off
    2064         String useMapName = static_cast<HTMLImageElement*>(curr)->getAttribute(usemapAttr).string().substring(1).lower();
    2065         if (useMapName == mapName)
    2066             return axObjectCache()->getOrCreate(obj);
    2067     }
    2068    
    2069     return 0;
     2052    if (!map)
     2053        return 0;
     2054
     2055    HTMLImageElement* imageElement = map->imageElement();
     2056    if (!imageElement)
     2057        return 0;
     2058   
     2059    return axObjectCache()->getOrCreate(imageElement->renderer());
    20702060}
    20712061   
  • trunk/WebCore/html/HTMLAreaElement.cpp

    r48106 r53857  
    2323#include "HTMLAreaElement.h"
    2424
     25#include "HTMLImageElement.h"
     26#include "HTMLMapElement.h"
    2527#include "HTMLNames.h"
    2628#include "HitTestResult.h"
     
    8385}
    8486
    85 IntRect HTMLAreaElement::getRect(RenderObject* obj) const
    86 {
     87Path HTMLAreaElement::getPath(RenderObject* obj) const
     88{
     89    if (!obj)
     90        return Path();
     91   
    8792    // FIXME: This doesn't work correctly with transforms.
    8893    FloatPoint absPos = obj->localToAbsolute();
    89     Path p = getRegion(m_lastSize);
     94
     95    // Default should default to the size of the containing object.
     96    IntSize size = m_lastSize;
     97    if (m_shape == Default)
     98        size = obj->absoluteOutlineBounds().size();
     99   
     100    Path p = getRegion(size);
    90101    p.translate(absPos - FloatPoint());
    91     return enclosingIntRect(p.boundingRect());
     102    return p;
     103}
     104   
     105IntRect HTMLAreaElement::getRect(RenderObject* obj) const
     106{
     107    return enclosingIntRect(getPath(obj).boundingRect());
    92108}
    93109
     
    162178    setAttribute(nohrefAttr, noHref ? "" : 0);
    163179}
    164 
     180   
     181HTMLImageElement* HTMLAreaElement::imageElement() const
     182{
     183    Node* mapElement = parent();
     184    if (!mapElement->hasTagName(mapTag))
     185        return 0;
     186   
     187    return static_cast<HTMLMapElement*>(mapElement)->imageElement();
     188}
     189
     190bool HTMLAreaElement::isKeyboardFocusable(KeyboardEvent*) const
     191{
     192    return supportsFocus();
     193}
     194
     195bool HTMLAreaElement::isFocusable() const
     196{
     197    return supportsFocus();
     198}
     199   
     200void HTMLAreaElement::dispatchBlurEvent()
     201{
     202    HTMLAnchorElement::dispatchBlurEvent();
     203   
     204    // On a blur, we might need to remove our focus rings by repainting.
     205    updateFocusAppearance(false);
     206}
     207   
     208void HTMLAreaElement::updateFocusAppearance(bool restorePreviousSelection)
     209{
     210    Node* parent = parentNode();
     211    if (!parent || !parent->hasTagName(mapTag))
     212        return;
     213   
     214    HTMLImageElement* imageElement = static_cast<HTMLMapElement*>(parent)->imageElement();
     215    if (!imageElement)
     216        return;
     217   
     218    // This will handle scrolling to the image if necessary.
     219    imageElement->updateFocusAppearance(restorePreviousSelection);
     220   
     221    RenderObject* imageRenderer = imageElement->renderer();
     222    if (imageRenderer)
     223        imageRenderer->setNeedsLayout(true);
     224}
     225   
    165226bool HTMLAreaElement::supportsFocus() const
    166227{
    167     // Skip HTMLAnchorElements isLink() check.
    168     return HTMLElement::supportsFocus();
     228    // If the AREA element was a link, it should support focus.
     229    // The inherited method is not used because it assumes that a render object must exist
     230    // for the element to support focus. AREA elements do not have render objects.
     231    return isLink();
    169232}
    170233
  • trunk/WebCore/html/HTMLAreaElement.h

    r48106 r53857  
    3131
    3232class HitTestResult;
     33class HTMLImageElement;
    3334class Path;
    3435
     
    4243
    4344    IntRect getRect(RenderObject*) const;
    44 
     45    Path getPath(RenderObject*) const;
     46   
     47    // Convenience method to get the parent map's image.
     48    HTMLImageElement* imageElement() const;
     49   
    4550    KURL href() const;
    4651
     
    5661    virtual bool supportsFocus() const;
    5762    virtual String target() const;
    58 
     63    virtual bool isKeyboardFocusable(KeyboardEvent*) const;
     64    virtual bool isFocusable() const;
     65    virtual void updateFocusAppearance(bool /*restorePreviousSelection*/);
     66    virtual void dispatchBlurEvent();
     67   
    5968    enum Shape { Default, Poly, Rect, Circle, Unknown };
    6069    Path getRegion(const IntSize&) const;
  • trunk/WebCore/html/HTMLMapElement.cpp

    r52312 r53857  
    2626#include "HTMLAreaElement.h"
    2727#include "HTMLCollection.h"
     28#include "HTMLImageElement.h"
    2829#include "HTMLNames.h"
    2930#include "HitTestResult.h"
    3031#include "IntSize.h"
    3132#include "MappedAttribute.h"
     33#include "RenderObject.h"
    3234
    3335using namespace std;
     
    7678}
    7779
     80HTMLImageElement* HTMLMapElement::imageElement() const
     81{
     82    RefPtr<HTMLCollection> coll = renderer()->document()->images();
     83    for (Node* curr = coll->firstItem(); curr; curr = coll->nextItem()) {
     84        if (!curr->hasTagName(imgTag))
     85            continue;
     86       
     87        // The HTMLImageElement's useMap() value includes the '#' symbol at the beginning,
     88        // which has to be stripped off.
     89        HTMLImageElement* imageElement = static_cast<HTMLImageElement*>(curr);
     90        String useMapName = imageElement->getAttribute(usemapAttr).string().substring(1);
     91        if (equalIgnoringCase(useMapName, m_name))
     92            return imageElement;
     93    }
     94   
     95    return 0;   
     96}
     97   
    7898void HTMLMapElement::parseMappedAttribute(MappedAttribute* attr)
    7999{
  • trunk/WebCore/html/HTMLMapElement.h

    r39007 r53857  
    3030class IntSize;
    3131class HitTestResult;
    32 
     32class HTMLImageElement;
     33   
    3334class HTMLMapElement : public HTMLElement {
    3435public:
     
    4546
    4647    bool mapMouseEvent(int x, int y, const IntSize&, HitTestResult&);
    47 
     48   
     49    HTMLImageElement* imageElement() const;
    4850    PassRefPtr<HTMLCollection> areas();
    4951
  • trunk/WebCore/platform/graphics/GraphicsContext.h

    r53637 r53857  
    264264
    265265        void drawFocusRing(const Vector<IntRect>&, int width, int offset, const Color&);
     266        void drawFocusRing(const Vector<Path>&, int width, int offset, const Color&);
    266267
    267268        void setLineCap(LineCap);
  • trunk/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp

    r52632 r53857  
    605605    cairo_set_fill_rule(cr, clipRule == RULE_EVENODD ? CAIRO_FILL_RULE_EVEN_ODD : CAIRO_FILL_RULE_WINDING);
    606606    cairo_clip(cr);
     607}
     608
     609void GraphicsContext::drawFocusRing(const Vector<Path>& paths, int width, int offset, const Color& color)
     610{
     611    // FIXME: implement
    607612}
    608613
  • trunk/WebCore/platform/graphics/haiku/GraphicsContextHaiku.cpp

    r52632 r53857  
    205205}
    206206
     207void GraphicsContext::drawFocusRing(const Vector<Path>& paths, int width, int offset, const Color& color)
     208{
     209    // FIXME: implement
     210}
     211
    207212void GraphicsContext::drawFocusRing(const Vector<IntRect>& rects, int /* width */, int /* offset */, const Color& color)
    208213{
  • trunk/WebCore/platform/graphics/mac/GraphicsContextMac.mm

    r52632 r53857  
    4444// exceptions for those.
    4545
     46static void drawFocusRingToContext(CGContextRef context, RetainPtr<CGPathRef> focusRingPath, RetainPtr<CGColorRef> colorRef, int radius)
     47{
     48#ifdef BUILDING_ON_TIGER
     49    CGContextBeginTransparencyLayer(context, 0);
     50#endif
     51    CGContextBeginPath(context);
     52    CGContextAddPath(context, focusRingPath.get());
     53    wkDrawFocusRing(context, colorRef.get(), radius);
     54#ifdef BUILDING_ON_TIGER
     55    CGContextEndTransparencyLayer(context);
     56#endif
     57}
     58
     59void GraphicsContext::drawFocusRing(const Vector<Path>& paths, int width, int offset, const Color& color)
     60{
     61    if (paintingDisabled())
     62        return;
     63   
     64    int radius = (width - 1) / 2;
     65    offset += radius;
     66    RetainPtr<CGColorRef> colorRef;
     67    if (color.isValid())
     68        colorRef.adoptCF(createCGColor(color));
     69   
     70    RetainPtr<CGMutablePathRef> focusRingPath(AdoptCF, CGPathCreateMutable());
     71    unsigned pathCount = paths.size();
     72    for (unsigned i = 0; i < pathCount; i++)
     73        CGPathAddPath(focusRingPath.get(), 0, paths[i].platformPath());
     74   
     75    drawFocusRingToContext(platformContext(), focusRingPath, colorRef, radius);
     76}   
     77   
    4678void GraphicsContext::drawFocusRing(const Vector<IntRect>& rects, int width, int offset, const Color& color)
    4779{
     
    6092        CGPathAddRect(focusRingPath.get(), 0, CGRectInset(rects[i], -offset, -offset));
    6193
    62     CGContextRef context = platformContext();
    63 #ifdef BUILDING_ON_TIGER
    64     CGContextBeginTransparencyLayer(context, NULL);
    65 #endif
    66     CGContextBeginPath(context);
    67     CGContextAddPath(context, focusRingPath.get());
    68     wkDrawFocusRing(context, colorRef.get(), radius);
    69 #ifdef BUILDING_ON_TIGER
    70     CGContextEndTransparencyLayer(context);
    71 #endif
     94    drawFocusRingToContext(platformContext(), focusRingPath, colorRef, radius);
    7295}
    7396
  • trunk/WebCore/platform/graphics/qt/GraphicsContextQt.cpp

    r53325 r53857  
    796796}
    797797
     798void GraphicsContext::drawFocusRing(const Vector<Path>& paths, int width, int offset, const Color& color)
     799{
     800    // FIXME: implement
     801}
     802
    798803/**
    799804 * Focus ring handling is not handled here. Qt style in
  • trunk/WebCore/platform/graphics/skia/GraphicsContextSkia.cpp

    r53600 r53857  
    502502}
    503503
     504void GraphicsContext::drawFocusRing(const Vector<Path>& paths, int width, int offset, const Color& color)
     505{
     506    // FIXME: implement
     507}
     508
    504509void GraphicsContext::drawFocusRing(const Vector<IntRect>& rects, int /* width */, int /* offset */, const Color& color)
    505510{
  • trunk/WebCore/platform/graphics/win/GraphicsContextCGWin.cpp

    r52632 r53857  
    125125}
    126126
     127void GraphicsContext::drawFocusRing(const Vector<Path>& paths, int width, int offset, const Color& color)
     128{
     129    // FIXME: implement
     130}
     131
    127132void GraphicsContext::drawFocusRing(const Vector<IntRect>& rects, int width, int offset, const Color& color)
    128133{
  • trunk/WebCore/platform/graphics/wince/GraphicsContextWince.cpp

    r52632 r53857  
    10011001
    10021002    ExcludeClipRect(m_data->m_dc, trRect.x(), trRect.y(), trRect.right(), trRect.bottom());
     1003}
     1004
     1005void GraphicsContext::drawFocusRing(const Vector<Path>& paths, int width, int offset, const Color& color)
     1006{
     1007    // FIXME: implement
    10031008}
    10041009
  • trunk/WebCore/platform/graphics/wx/GraphicsContextWx.cpp

    r52791 r53857  
    271271}
    272272
     273void GraphicsContext::drawFocusRing(const Vector<Path>& paths, int width, int offset, const Color& color)
     274{
     275    // FIXME: implement
     276}
     277
    273278void GraphicsContext::drawFocusRing(const Vector<IntRect>& rects, int width, int offset, const Color& color)
    274279{
  • trunk/WebCore/rendering/RenderImage.cpp

    r53146 r53857  
    2727#include "RenderImage.h"
    2828
     29#include "Frame.h"
    2930#include "GraphicsContext.h"
     31#include "HTMLAreaElement.h"
     32#include "HTMLCollection.h"
    3033#include "HTMLImageElement.h"
    3134#include "HTMLInputElement.h"
     
    3437#include "HitTestResult.h"
    3538#include "Page.h"
     39#include "RenderTheme.h"
    3640#include "RenderView.h"
     41#include "SelectionController.h"
    3742#include <wtf/CurrentTime.h>
    3843#include <wtf/UnusedParam.h>
     
    426431}
    427432
     433void RenderImage::paint(PaintInfo& paintInfo, int tx, int ty)
     434{
     435    RenderReplaced::paint(paintInfo, tx, ty);
     436   
     437    if (paintInfo.phase == PaintPhaseOutline)
     438        paintFocusRings(paintInfo, style());
     439}
     440   
     441void RenderImage::paintFocusRings(PaintInfo& paintInfo, const RenderStyle* style)
     442{
     443    // Don't draw focus rings if printing.
     444    if (document()->printing() || !document()->frame()->selection()->isFocusedAndActive())
     445        return;
     446   
     447    if (paintInfo.context->paintingDisabled() && !paintInfo.context->updatingControlTints())
     448        return;
     449
     450    HTMLMapElement* mapElement = imageMap();
     451    if (!mapElement)
     452        return;
     453   
     454    Document* document = mapElement->document();
     455    if (!document)
     456        return;
     457   
     458    Node* focusedNode = document->focusedNode();
     459    if (!focusedNode)
     460        return;
     461   
     462    RefPtr<HTMLCollection> areas = mapElement->areas();
     463    unsigned numAreas = areas->length();
     464   
     465    // FIXME: Clip the paths to the image bounding box.
     466    for (unsigned k = 0; k < numAreas; ++k) {
     467        HTMLAreaElement* areaElement = static_cast<HTMLAreaElement*>(areas->item(k));
     468        if (focusedNode != areaElement)
     469            continue;
     470       
     471        Vector<Path> focusRingPaths;
     472        focusRingPaths.append(areaElement->getPath(this));
     473        paintInfo.context->drawFocusRing(focusRingPaths, style->outlineWidth(), style->outlineOffset(), style->outlineColor());
     474        break;
     475    }
     476}
     477   
    428478void RenderImage::paintIntoRect(GraphicsContext* context, const IntRect& rect)
    429479{
     
    446496}
    447497
    448 HTMLMapElement* RenderImage::imageMap()
     498HTMLMapElement* RenderImage::imageMap() const
    449499{
    450500    HTMLImageElement* i = node() && node()->hasTagName(imgTag) ? static_cast<HTMLImageElement*>(node()) : 0;
  • trunk/WebCore/rendering/RenderImage.h

    r53146 r53857  
    4444    CachedImage* cachedImage() const { return m_cachedImage.get(); }
    4545
    46     HTMLMapElement* imageMap();
     46    HTMLMapElement* imageMap() const;
    4747
    4848    void resetAnimation();
     
    5959
    6060    virtual void paintIntoRect(GraphicsContext*, const IntRect&);
     61    void paintFocusRings(PaintInfo&, const RenderStyle*);
     62    virtual void paint(PaintInfo&, int tx, int ty);
    6163
    6264    bool isWidthSpecified() const;
  • trunk/WebCore/rendering/RenderReplaced.h

    r47440 r53857  
    4747    virtual void intrinsicSizeChanged();
    4848
     49    virtual void paint(PaintInfo&, int tx, int ty);
    4950    bool shouldPaint(PaintInfo&, int& tx, int& ty);
    5051    void adjustOverflowForBoxShadowAndReflect();
     
    6364    virtual int minimumReplacedHeight() const { return 0; }
    6465
    65     virtual void paint(PaintInfo&, int tx, int ty);
    6666    virtual void paintReplaced(PaintInfo&, int /*tx*/, int /*ty*/) { }
    6767
Note: See TracChangeset for help on using the changeset viewer.