diff options
Diffstat (limited to 'src/3rdparty/webkit/WebCore/html/HTMLAreaElement.cpp')
-rw-r--r-- | src/3rdparty/webkit/WebCore/html/HTMLAreaElement.cpp | 73 |
1 files changed, 68 insertions, 5 deletions
diff --git a/src/3rdparty/webkit/WebCore/html/HTMLAreaElement.cpp b/src/3rdparty/webkit/WebCore/html/HTMLAreaElement.cpp index b202caea46..b862f69432 100644 --- a/src/3rdparty/webkit/WebCore/html/HTMLAreaElement.cpp +++ b/src/3rdparty/webkit/WebCore/html/HTMLAreaElement.cpp @@ -22,6 +22,8 @@ #include "config.h" #include "HTMLAreaElement.h" +#include "HTMLImageElement.h" +#include "HTMLMapElement.h" #include "HTMLNames.h" #include "HitTestResult.h" #include "MappedAttribute.h" @@ -82,13 +84,27 @@ bool HTMLAreaElement::mapMouseEvent(int x, int y, const IntSize& size, HitTestRe 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 @@ -161,11 +177,58 @@ void HTMLAreaElement::setNoHref(bool noHref) { 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 |