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:
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@53857
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2010-01-26 Chris Fleizach <cfleizach@apple.com>
+
+ Reviewed by Darin Adler.
+
+ Add ability for image maps to be focused via tabbing
+ https://bugs.webkit.org/show_bug.cgi?id=17513
+
+ * 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:
+
2010-01-26 Simon Hausmann <simon.hausmann@nokia.com>
Reviewed by Holger Freyther.
var failedTestCount = 0;
var tagNamesAlwaysFocused = ["A",
+ "AREA",
"BUTTON",
"IFRAME",
"INPUT",
var tagNamesTransferFocused = ["LABEL"]; // labels always transfer focus to the labeled element
+var noDisplayTagNamesWithFocus = ["AREA"]; // AREA elements can get focus, but are not displayed.
+
function printToConsole(str)
{
if (!consoleOutput) {
var homeBase = window.frames[1].document.getElementsByClassName('homebase');
homeBase[0].focus();
- var resultSummary = focusCount+" focus / "+blurCount+" blur events dispatched, and should be 329 / 329 ";
+ var resultSummary = focusCount+" focus / "+blurCount+" blur events dispatched, and should be 337 / 337 ";
resultSummary += (focusCount==blurCount) ? "<span style='color:green'>PASSED</span><br>" : "<span style='color:red'>FAILED</span><br>";
resultSummary += "Total of "+failedTestCount+" focus test(s) failed.";
if (failedTestCount)
elemThatShouldFocus = elem;
else if (tagNamesAlwaysFocused.find(elem.tagName)) // special case form elements and other controls that are always focusable
elemThatShouldFocus = elem;
-
+
// Hidden elements should not be focusable. https://bugs.webkit.org/show_bug.cgi?id=27099
- if (document.defaultView.getComputedStyle(elem).display == "none")
+ if (document.defaultView.getComputedStyle(elem).display == "none" && !noDisplayTagNamesWithFocus.find(elem.tagName))
elemThatShouldFocus = null;
if (tagNamesTransferFocused.find(elem.tagName)) {
--- /dev/null
+
+This tests that links in a image map are able to be reached through keyboard access and tabbing.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS document.activeElement.id is 'area1'
+PASS document.activeElement.id is 'area2'
+PASS document.activeElement.id is 'area3'
+PASS document.activeElement.id is 'area5'
+PASS document.activeElement.id is 'area6'
+PASS document.activeElement.id is 'area1'
+
--- /dev/null
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<link rel="stylesheet" href="../js/resources/js-test-style.css">
+<script>
+var successfullyParsed = false;
+</script>
+<script src="../js/resources/js-test-pre.js"></script>
+<body id="body">
+
+<map name="mymap">
+<area id="area1" shape="circle" coords="70,84,51" href="1">
+<area id="area2" shape="rect" coords="25,180,125,280" href="2">
+<area id="area3" shape="poly" coords="153,106,186,225,340,193,315,81,304,167" href="3">
+<area id="area4" shape="rect" coords="420,19,478,278" nohref>
+<area id="area5" shape="circle" coords="220,150,100" href="4">
+<area id="area6" shape="default" coords="0,0,500,300" href="5">
+<area id="area7" shape="rect" coords="1, 1, 10, 10" tabindex=-1 href="6">
+</map>
+
+<img src="resources/abe.png" width="500" height="300" alt="Image Map" usemap="#mymap" ismap>
+
+
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+
+ description("This tests that links in a image map are able to be reached through keyboard access and tabbing.");
+
+ eventSender.keyDown('\t');
+ shouldBe("document.activeElement.id", "'area1'");
+
+ eventSender.keyDown('\t');
+ shouldBe("document.activeElement.id", "'area2'");
+
+ eventSender.keyDown('\t');
+ shouldBe("document.activeElement.id", "'area3'");
+
+ // We'll skip over area4 because its nohref
+ eventSender.keyDown('\t');
+ shouldBe("document.activeElement.id", "'area5'");
+
+ eventSender.keyDown('\t');
+ shouldBe("document.activeElement.id", "'area6'");
+
+ // We'll skip over area7 because its tabindex=-1
+ eventSender.keyDown('\t');
+ shouldBe("document.activeElement.id", "'area1'");
+
+ successfullyParsed = true;
+</script>
+
+<script src="../fast/js/resources/js-test-post.js"></script>
+</body>
+</html>
-329 focus / 329 blur events dispatched, and should be 329 / 329 PASSED
+337 focus / 337 blur events dispatched, and should be 337 / 337 PASSED
Total of 0 focus test(s) failed. PASSED
+2010-01-26 Chris Fleizach <cfleizach@apple.com>
+
+ Reviewed by Darin Adler.
+
+ Add ability for image maps to be focused via tabbing
+ https://bugs.webkit.org/show_bug.cgi?id=17513
+
+ 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:
+
2010-01-26 Pavel Feldman <pfeldman@chromium.org>
Reviewed by Timothy Hatcher.
#include "AccessibilityTableRow.h"
#include "FocusController.h"
#include "Frame.h"
+#include "HTMLAreaElement.h"
+#include "HTMLImageElement.h"
#include "HTMLNames.h"
#if ENABLE(VIDEO)
#include "MediaControlElements.h"
}
}
+AccessibilityObject* AXObjectCache::focusedImageMapUIElement(HTMLAreaElement* areaElement)
+{
+ // Find the corresponding accessibility object for the HTMLAreaElement. This should be
+ // in the list of children for its corresponding image.
+ if (!areaElement)
+ return 0;
+
+ HTMLImageElement* imageElement = areaElement->imageElement();
+ if (!imageElement)
+ return 0;
+
+ AccessibilityObject* axRenderImage = areaElement->document()->axObjectCache()->getOrCreate(imageElement->renderer());
+ if (!axRenderImage)
+ return 0;
+
+ AccessibilityObject::AccessibilityChildrenVector imageChildren = axRenderImage->children();
+ unsigned count = imageChildren.size();
+ for (unsigned k = 0; k < count; ++k) {
+ AccessibilityObject* child = imageChildren[k].get();
+ if (!child->isImageMapLink())
+ continue;
+
+ if (static_cast<AccessibilityImageMapLink*>(child)->areaElement() == areaElement)
+ return child;
+ }
+
+ return 0;
+}
+
AccessibilityObject* AXObjectCache::focusedUIElementForPage(const Page* page)
{
// get the focused node in the page
if (!focusedNode)
focusedNode = focusedDocument;
+ if (focusedNode->hasTagName(areaTag))
+ return focusedImageMapUIElement(static_cast<HTMLAreaElement*>(focusedNode));
+
RenderObject* focusedNodeRenderer = focusedNode->renderer();
if (!focusedNodeRenderer)
return 0;
namespace WebCore {
+class HTMLAreaElement;
class Node;
class Page;
class RenderObject;
Vector<pair<RefPtr<AccessibilityObject>, AXNotification> > m_notificationsToPost;
void notificationPostTimerFired(Timer<AXObjectCache>*);
+ static AccessibilityObject* focusedImageMapUIElement(HTMLAreaElement*);
+
AXID getAXID(AccessibilityObject*);
bool nodeIsAriaType(Node*, String role);
};
virtual ~AccessibilityImageMapLink();
void setHTMLAreaElement(HTMLAreaElement* element) { m_areaElement = element; }
+ HTMLAreaElement* areaElement() const { return m_areaElement; }
+
void setHTMLMapElement(HTMLMapElement* element) { m_mapElement = element; }
+ HTMLMapElement* mapElement() const { return m_mapElement; }
+
void setParent(AccessibilityObject* parent) { m_parent = parent; }
virtual AccessibilityRole roleValue() const;
virtual bool accessibilityIsIgnored() const { return false; }
virtual bool isEnabled() const { return true; }
-
+
virtual AccessibilityObject* parentObject() const;
virtual Element* anchorElement() const;
virtual Element* actionElement() const;
HTMLAreaElement* m_areaElement;
HTMLMapElement* m_mapElement;
AccessibilityObject* m_parent;
+
+ virtual bool isImageMapLink() const { return true; }
};
} // namespace WebCore
virtual bool isFieldset() const { return false; }
virtual bool isGroup() const { return false; }
virtual bool isARIATreeGridRow() const { return false; }
+ virtual bool isImageMapLink() const { return false; }
virtual bool isMenuList() const { return false; }
virtual bool isMenuListPopup() const { return false; }
virtual bool isMenuListOption() const { return false; }
AccessibilityObject* AccessibilityRenderObject::accessibilityParentForImageMap(HTMLMapElement* map) const
{
// find an image that is using this map
- if (!m_renderer || !map)
+ if (!map)
return 0;
- String mapName = map->getName().string().lower();
- RefPtr<HTMLCollection> coll = m_renderer->document()->images();
- for (Node* curr = coll->firstItem(); curr; curr = coll->nextItem()) {
- RenderObject* obj = curr->renderer();
- if (!obj || !curr->hasTagName(imgTag))
- continue;
-
- // The HTMLImageElement's useMap() value includes the '#' symbol at the beginning,
- // which has to be stripped off
- String useMapName = static_cast<HTMLImageElement*>(curr)->getAttribute(usemapAttr).string().substring(1).lower();
- if (useMapName == mapName)
- return axObjectCache()->getOrCreate(obj);
- }
+ HTMLImageElement* imageElement = map->imageElement();
+ if (!imageElement)
+ return 0;
- return 0;
+ return axObjectCache()->getOrCreate(imageElement->renderer());
}
void AccessibilityRenderObject::getDocumentLinks(AccessibilityChildrenVector& result)
#include "config.h"
#include "HTMLAreaElement.h"
+#include "HTMLImageElement.h"
+#include "HTMLMapElement.h"
#include "HTMLNames.h"
#include "HitTestResult.h"
#include "MappedAttribute.h"
return true;
}
-IntRect HTMLAreaElement::getRect(RenderObject* obj) const
+Path HTMLAreaElement::getPath(RenderObject* obj) const
{
+ if (!obj)
+ return Path();
+
// FIXME: This doesn't work correctly with transforms.
FloatPoint absPos = obj->localToAbsolute();
- Path p = getRegion(m_lastSize);
+
+ // Default should default to the size of the containing object.
+ IntSize size = m_lastSize;
+ if (m_shape == Default)
+ size = obj->absoluteOutlineBounds().size();
+
+ Path p = getRegion(size);
p.translate(absPos - FloatPoint());
- return enclosingIntRect(p.boundingRect());
+ return p;
+}
+
+IntRect HTMLAreaElement::getRect(RenderObject* obj) const
+{
+ return enclosingIntRect(getPath(obj).boundingRect());
}
Path HTMLAreaElement::getRegion(const IntSize& size) const
{
setAttribute(nohrefAttr, noHref ? "" : 0);
}
+
+HTMLImageElement* HTMLAreaElement::imageElement() const
+{
+ Node* mapElement = parent();
+ if (!mapElement->hasTagName(mapTag))
+ return 0;
+
+ return static_cast<HTMLMapElement*>(mapElement)->imageElement();
+}
+bool HTMLAreaElement::isKeyboardFocusable(KeyboardEvent*) const
+{
+ return supportsFocus();
+}
+
+bool HTMLAreaElement::isFocusable() const
+{
+ return supportsFocus();
+}
+
+void HTMLAreaElement::dispatchBlurEvent()
+{
+ HTMLAnchorElement::dispatchBlurEvent();
+
+ // On a blur, we might need to remove our focus rings by repainting.
+ updateFocusAppearance(false);
+}
+
+void HTMLAreaElement::updateFocusAppearance(bool restorePreviousSelection)
+{
+ Node* parent = parentNode();
+ if (!parent || !parent->hasTagName(mapTag))
+ return;
+
+ HTMLImageElement* imageElement = static_cast<HTMLMapElement*>(parent)->imageElement();
+ if (!imageElement)
+ return;
+
+ // This will handle scrolling to the image if necessary.
+ imageElement->updateFocusAppearance(restorePreviousSelection);
+
+ RenderObject* imageRenderer = imageElement->renderer();
+ if (imageRenderer)
+ imageRenderer->setNeedsLayout(true);
+}
+
bool HTMLAreaElement::supportsFocus() const
{
- // Skip HTMLAnchorElements isLink() check.
- return HTMLElement::supportsFocus();
+ // If the AREA element was a link, it should support focus.
+ // The inherited method is not used because it assumes that a render object must exist
+ // for the element to support focus. AREA elements do not have render objects.
+ return isLink();
}
String HTMLAreaElement::target() const
namespace WebCore {
class HitTestResult;
+class HTMLImageElement;
class Path;
class HTMLAreaElement : public HTMLAnchorElement {
bool mapMouseEvent(int x, int y, const IntSize&, HitTestResult&);
IntRect getRect(RenderObject*) const;
-
+ Path getPath(RenderObject*) const;
+
+ // Convenience method to get the parent map's image.
+ HTMLImageElement* imageElement() const;
+
KURL href() const;
bool noHref() const;
virtual void parseMappedAttribute(MappedAttribute*);
virtual bool supportsFocus() const;
virtual String target() const;
-
+ virtual bool isKeyboardFocusable(KeyboardEvent*) const;
+ virtual bool isFocusable() const;
+ virtual void updateFocusAppearance(bool /*restorePreviousSelection*/);
+ virtual void dispatchBlurEvent();
+
enum Shape { Default, Poly, Rect, Circle, Unknown };
Path getRegion(const IntSize&) const;
#include "Document.h"
#include "HTMLAreaElement.h"
#include "HTMLCollection.h"
+#include "HTMLImageElement.h"
#include "HTMLNames.h"
#include "HitTestResult.h"
#include "IntSize.h"
#include "MappedAttribute.h"
+#include "RenderObject.h"
using namespace std;
return defaultArea;
}
+HTMLImageElement* HTMLMapElement::imageElement() const
+{
+ RefPtr<HTMLCollection> coll = renderer()->document()->images();
+ for (Node* curr = coll->firstItem(); curr; curr = coll->nextItem()) {
+ if (!curr->hasTagName(imgTag))
+ continue;
+
+ // The HTMLImageElement's useMap() value includes the '#' symbol at the beginning,
+ // which has to be stripped off.
+ HTMLImageElement* imageElement = static_cast<HTMLImageElement*>(curr);
+ String useMapName = imageElement->getAttribute(usemapAttr).string().substring(1);
+ if (equalIgnoringCase(useMapName, m_name))
+ return imageElement;
+ }
+
+ return 0;
+}
+
void HTMLMapElement::parseMappedAttribute(MappedAttribute* attr)
{
const QualifiedName& attrName = attr->name();
class IntSize;
class HitTestResult;
-
+class HTMLImageElement;
+
class HTMLMapElement : public HTMLElement {
public:
HTMLMapElement(const QualifiedName&, Document*);
virtual void parseMappedAttribute(MappedAttribute*);
bool mapMouseEvent(int x, int y, const IntSize&, HitTestResult&);
-
+
+ HTMLImageElement* imageElement() const;
PassRefPtr<HTMLCollection> areas();
String name() const;
void clearShadow();
void drawFocusRing(const Vector<IntRect>&, int width, int offset, const Color&);
+ void drawFocusRing(const Vector<Path>&, int width, int offset, const Color&);
void setLineCap(LineCap);
void setLineDash(const DashArray&, float dashOffset);
cairo_clip(cr);
}
+void GraphicsContext::drawFocusRing(const Vector<Path>& paths, int width, int offset, const Color& color)
+{
+ // FIXME: implement
+}
+
void GraphicsContext::drawFocusRing(const Vector<IntRect>& rects, int width, int /* offset */, const Color& color)
{
if (paintingDisabled())
m_data->m_view->ConstrainClippingRegion(®ion);
}
+void GraphicsContext::drawFocusRing(const Vector<Path>& paths, int width, int offset, const Color& color)
+{
+ // FIXME: implement
+}
+
void GraphicsContext::drawFocusRing(const Vector<IntRect>& rects, int /* width */, int /* offset */, const Color& color)
{
if (paintingDisabled())
// calls in this file are all exception-safe, so we don't block
// exceptions for those.
+static void drawFocusRingToContext(CGContextRef context, RetainPtr<CGPathRef> focusRingPath, RetainPtr<CGColorRef> colorRef, int radius)
+{
+#ifdef BUILDING_ON_TIGER
+ CGContextBeginTransparencyLayer(context, 0);
+#endif
+ CGContextBeginPath(context);
+ CGContextAddPath(context, focusRingPath.get());
+ wkDrawFocusRing(context, colorRef.get(), radius);
+#ifdef BUILDING_ON_TIGER
+ CGContextEndTransparencyLayer(context);
+#endif
+}
+
+void GraphicsContext::drawFocusRing(const Vector<Path>& paths, int width, int offset, const Color& color)
+{
+ if (paintingDisabled())
+ return;
+
+ int radius = (width - 1) / 2;
+ offset += radius;
+ RetainPtr<CGColorRef> colorRef;
+ if (color.isValid())
+ colorRef.adoptCF(createCGColor(color));
+
+ RetainPtr<CGMutablePathRef> focusRingPath(AdoptCF, CGPathCreateMutable());
+ unsigned pathCount = paths.size();
+ for (unsigned i = 0; i < pathCount; i++)
+ CGPathAddPath(focusRingPath.get(), 0, paths[i].platformPath());
+
+ drawFocusRingToContext(platformContext(), focusRingPath, colorRef, radius);
+}
+
void GraphicsContext::drawFocusRing(const Vector<IntRect>& rects, int width, int offset, const Color& color)
{
if (paintingDisabled())
for (unsigned i = 0; i < rectCount; i++)
CGPathAddRect(focusRingPath.get(), 0, CGRectInset(rects[i], -offset, -offset));
- CGContextRef context = platformContext();
-#ifdef BUILDING_ON_TIGER
- CGContextBeginTransparencyLayer(context, NULL);
-#endif
- CGContextBeginPath(context);
- CGContextAddPath(context, focusRingPath.get());
- wkDrawFocusRing(context, colorRef.get(), radius);
-#ifdef BUILDING_ON_TIGER
- CGContextEndTransparencyLayer(context);
-#endif
+ drawFocusRingToContext(platformContext(), focusRingPath, colorRef, radius);
}
#ifdef BUILDING_ON_TIGER // Post-Tiger's setCompositeOperation() is defined in GraphicsContextCG.cpp.
p->setClipPath(newPath);
}
+void GraphicsContext::drawFocusRing(const Vector<Path>& paths, int width, int offset, const Color& color)
+{
+ // FIXME: implement
+}
+
/**
* Focus ring handling is not handled here. Qt style in
* RenderTheme handles drawing focus on widgets which
}
}
+void GraphicsContext::drawFocusRing(const Vector<Path>& paths, int width, int offset, const Color& color)
+{
+ // FIXME: implement
+}
+
void GraphicsContext::drawFocusRing(const Vector<IntRect>& rects, int /* width */, int /* offset */, const Color& color)
{
if (paintingDisabled())
CGContextDrawImage(m_data->m_cgContext.get(), CGRectMake(point.x(), point.y(), image->size().width(), image->size().height()), cgImage.get());
}
+void GraphicsContext::drawFocusRing(const Vector<Path>& paths, int width, int offset, const Color& color)
+{
+ // FIXME: implement
+}
+
void GraphicsContext::drawFocusRing(const Vector<IntRect>& rects, int width, int offset, const Color& color)
{
if (paintingDisabled())
ExcludeClipRect(m_data->m_dc, trRect.x(), trRect.y(), trRect.right(), trRect.bottom());
}
+void GraphicsContext::drawFocusRing(const Vector<Path>& paths, int width, int offset, const Color& color)
+{
+ // FIXME: implement
+}
+
void GraphicsContext::drawFocusRing(const Vector<IntRect>& rects, int width, int offset, const Color& color)
{
if (!m_data->m_opacity || paintingDisabled())
notImplemented();
}
+void GraphicsContext::drawFocusRing(const Vector<Path>& paths, int width, int offset, const Color& color)
+{
+ // FIXME: implement
+}
+
void GraphicsContext::drawFocusRing(const Vector<IntRect>& rects, int width, int offset, const Color& color)
{
if (paintingDisabled())
#include "config.h"
#include "RenderImage.h"
+#include "Frame.h"
#include "GraphicsContext.h"
+#include "HTMLAreaElement.h"
+#include "HTMLCollection.h"
#include "HTMLImageElement.h"
#include "HTMLInputElement.h"
#include "HTMLMapElement.h"
#include "HTMLNames.h"
#include "HitTestResult.h"
#include "Page.h"
+#include "RenderTheme.h"
#include "RenderView.h"
+#include "SelectionController.h"
#include <wtf/CurrentTime.h>
#include <wtf/UnusedParam.h>
}
}
+void RenderImage::paint(PaintInfo& paintInfo, int tx, int ty)
+{
+ RenderReplaced::paint(paintInfo, tx, ty);
+
+ if (paintInfo.phase == PaintPhaseOutline)
+ paintFocusRings(paintInfo, style());
+}
+
+void RenderImage::paintFocusRings(PaintInfo& paintInfo, const RenderStyle* style)
+{
+ // Don't draw focus rings if printing.
+ if (document()->printing() || !document()->frame()->selection()->isFocusedAndActive())
+ return;
+
+ if (paintInfo.context->paintingDisabled() && !paintInfo.context->updatingControlTints())
+ return;
+
+ HTMLMapElement* mapElement = imageMap();
+ if (!mapElement)
+ return;
+
+ Document* document = mapElement->document();
+ if (!document)
+ return;
+
+ Node* focusedNode = document->focusedNode();
+ if (!focusedNode)
+ return;
+
+ RefPtr<HTMLCollection> areas = mapElement->areas();
+ unsigned numAreas = areas->length();
+
+ // FIXME: Clip the paths to the image bounding box.
+ for (unsigned k = 0; k < numAreas; ++k) {
+ HTMLAreaElement* areaElement = static_cast<HTMLAreaElement*>(areas->item(k));
+ if (focusedNode != areaElement)
+ continue;
+
+ Vector<Path> focusRingPaths;
+ focusRingPaths.append(areaElement->getPath(this));
+ paintInfo.context->drawFocusRing(focusRingPaths, style->outlineWidth(), style->outlineOffset(), style->outlineColor());
+ break;
+ }
+}
+
void RenderImage::paintIntoRect(GraphicsContext* context, const IntRect& rect)
{
if (!hasImage() || errorOccurred() || rect.width() <= 0 || rect.height() <= 0)
return errorOccurred() ? intrinsicSize().height() : 0;
}
-HTMLMapElement* RenderImage::imageMap()
+HTMLMapElement* RenderImage::imageMap() const
{
HTMLImageElement* i = node() && node()->hasTagName(imgTag) ? static_cast<HTMLImageElement*>(node()) : 0;
return i ? i->document()->getImageMap(i->getAttribute(usemapAttr)) : 0;
void setCachedImage(CachedImage*);
CachedImage* cachedImage() const { return m_cachedImage.get(); }
- HTMLMapElement* imageMap();
+ HTMLMapElement* imageMap() const;
void resetAnimation();
virtual void imageChanged(WrappedImagePtr, const IntRect* = 0);
virtual void paintIntoRect(GraphicsContext*, const IntRect&);
+ void paintFocusRings(PaintInfo&, const RenderStyle*);
+ virtual void paint(PaintInfo&, int tx, int ty);
bool isWidthSpecified() const;
bool isHeightSpecified() const;
void setIntrinsicSize(const IntSize&);
virtual void intrinsicSizeChanged();
+ virtual void paint(PaintInfo&, int tx, int ty);
bool shouldPaint(PaintInfo&, int& tx, int& ty);
void adjustOverflowForBoxShadowAndReflect();
IntRect localSelectionRect(bool checkWhetherSelected = true) const;
virtual int minimumReplacedHeight() const { return 0; }
- virtual void paint(PaintInfo&, int tx, int ty);
virtual void paintReplaced(PaintInfo&, int /*tx*/, int /*ty*/) { }
virtual IntRect clippedOverflowRectForRepaint(RenderBoxModelObject* repaintContainer);