static v8::Handle<v8::Value> areasAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
{
    INC_STATS("DOM.HTMLMapElement.areas._get");
    HTMLMapElement* imp = V8HTMLMapElement::toNative(info.Holder());
	if (!R_check(imp)) return v8::Handle<v8::Value>(v8::Undefined());
    return toV8(imp->areas());
}
Exemple #2
0
HTMLMapElement* TreeScope::getImageMap(const String& url) const {
  if (url.isNull())
    return nullptr;
  if (!m_imageMapsByName)
    return nullptr;
  size_t hashPos = url.find('#');
  String name = hashPos == kNotFound ? url : url.substring(hashPos + 1);
  HTMLMapElement* map = toHTMLMapElement(
      rootNode().document().isHTMLDocument()
          ? m_imageMapsByName->getElementByLowercasedMapName(
                AtomicString(name.lower()), this)
          : m_imageMapsByName->getElementByMapName(AtomicString(name), this));
  if (!map || !rootNode().document().isHTMLDocument())
    return map;
  const AtomicString& nameValue = map->fastGetAttribute(nameAttr);
  if (nameValue.isNull())
    return map;
  String strippedName = nameValue;
  if (strippedName.startsWith('#'))
    strippedName = strippedName.substring(1);
  if (strippedName == name)
    UseCounter::count(rootNode().document(), UseCounter::MapNameMatchingStrict);
  else if (equalIgnoringASCIICase(strippedName, name))
    UseCounter::count(rootNode().document(),
                      UseCounter::MapNameMatchingASCIICaseless);
  else
    UseCounter::count(rootNode().document(),
                      UseCounter::MapNameMatchingUnicodeLower);
  return map;
}
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());
}
void TreeScope::removeImageMap(HTMLMapElement& imageMap)
{
    if (!m_imageMapsByName)
        return;
    AtomicStringImpl* name = imageMap.getName().impl();
    if (!name)
        return;
    m_imageMapsByName->remove(*name, imageMap);
}
void TreeScope::addImageMap(HTMLMapElement& imageMap)
{
    AtomicStringImpl* name = imageMap.getName().impl();
    if (!name)
        return;
    if (!m_imageMapsByName)
        m_imageMapsByName = std::make_unique<DocumentOrderedMap>();
    m_imageMapsByName->add(*name, imageMap, *this);
}
Exemple #6
0
bool RenderImage::nodeAtPoint(const HitTestRequest& request, HitTestResult& result, int _x, int _y, int _tx, int _ty, HitTestAction hitTestAction)
{
    bool inside = RenderReplaced::nodeAtPoint(request, result, _x, _y, _tx, _ty, hitTestAction);

    if (inside && element()) {
        int tx = _tx + m_x;
        int ty = _ty + m_y;
        
        HTMLMapElement* map = imageMap();
        if (map) {
            // we're a client side image map
            inside = map->mapMouseEvent(_x - tx, _y - ty, IntSize(contentWidth(), contentHeight()), result);
            result.setInnerNonSharedNode(element());
        }
    }

    return inside;
}
Exemple #7
0
void TreeScope::addImageMap(HTMLMapElement& imageMap)
{
    AtomicStringImpl* name = imageMap.getName().impl();
    if (!name)
        return;
    if (!m_imageMapsByName)
        m_imageMapsByName = adoptPtr(new DocumentOrderedMap);
    m_imageMapsByName->add(*name, imageMap, *this);
}
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;
    }
}
static v8::Handle<v8::Value> areasAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
{
    HTMLMapElement* imp = V8HTMLMapElement::toNative(info.Holder());
    return toV8Fast(imp->areas(), info, imp);
}