コード例 #1
0
HTMLAreaElement* HitTestResult::imageAreaForImage() const
{
    ASSERT(m_innerNode);
    HTMLImageElement* imageElement = nullptr;
    if (isHTMLImageElement(m_innerNode)) {
        imageElement = toHTMLImageElement(m_innerNode);
    } else if (m_innerNode->isInShadowTree()) {
        if (m_innerNode->containingShadowRoot()->type() == ShadowRootType::UserAgent) {
            if (isHTMLImageElement(m_innerNode->shadowHost()))
                imageElement = toHTMLImageElement(m_innerNode->shadowHost());
        }
    }

    if (!imageElement || !imageElement->layoutObject() || !imageElement->layoutObject()->isBox())
        return nullptr;

    HTMLMapElement* map = imageElement->treeScope().getImageMap(imageElement->fastGetAttribute(usemapAttr));
    if (!map)
        return nullptr;

    LayoutBox* box = toLayoutBox(imageElement->layoutObject());
    LayoutRect contentBox = box->contentBoxRect();
    float scaleFactor = 1 / box->style()->effectiveZoom();
    LayoutPoint location = localPoint();
    location.scale(scaleFactor, scaleFactor);

    return map->areaForPoint(location, contentBox.size());
}
コード例 #2
0
bool HTMLAreaElement::layoutObjectIsFocusable() const
{
    HTMLImageElement* image = imageElement();
    if (!image || !image->layoutObject() || image->layoutObject()->style()->visibility() != VISIBLE)
        return false;

    return supportsFocus() && Element::tabIndex() >= 0;
}
コード例 #3
0
void HTMLAreaElement::setFocus(bool shouldBeFocused)
{
    if (focused() == shouldBeFocused)
        return;

    HTMLAnchorElement::setFocus(shouldBeFocused);

    HTMLImageElement* imageElement = this->imageElement();
    if (!imageElement)
        return;

    LayoutObject* layoutObject = imageElement->layoutObject();
    if (!layoutObject || !layoutObject->isImage())
        return;

    toLayoutImage(layoutObject)->areaElementFocusChanged(this);
}