Exemplo n.º 1
0
bool CSSCursorImageValue::updateIfSVGCursorIsUsed(Element* element)
{
#if !ENABLE(SVG)
    UNUSED_PARAM(element);
#else
    if (!element || !element->isSVGElement())
        return false;

    const String& url = getStringValue();
    if (!isSVGCursorIdentifier(url))
        return false;

    if (SVGCursorElement* cursorElement = resourceReferencedByCursorElement(url, element->document())) {
        float x = roundf(cursorElement->x().value(0));
        m_hotspot.setX(static_cast<int>(x));

        float y = roundf(cursorElement->y().value(0));
        m_hotspot.setY(static_cast<int>(y));

        if (cachedImageURL() != element->document()->completeURL(cursorElement->href()))
            clearCachedImage();

        SVGElement* svgElement = static_cast<SVGElement*>(element);
        m_referencedElements.add(svgElement);
        svgElement->setCursorImageValue(this);
        cursorElement->addClient(svgElement);
        return true;
    }
#endif

    return false;
}
Exemplo n.º 2
0
bool CSSCursorImageValue::updateIfSVGCursorIsUsed(Element* element)
{
#if !ENABLE(SVG)
    UNUSED_PARAM(element);
#else
    if (!element || !element->isSVGElement())
        return false;

    if (!isSVGCursorIdentifier(url()))
        return false;

    if (SVGCursorElement* cursorElement = resourceReferencedByCursorElement(url(), element->document())) {
        // FIXME: This will override hot spot specified in CSS, which is probably incorrect.
        SVGLengthContext lengthContext(0);
        float x = roundf(cursorElement->x().value(lengthContext));
        m_hotSpot.setX(static_cast<int>(x));

        float y = roundf(cursorElement->y().value(lengthContext));
        m_hotSpot.setY(static_cast<int>(y));

        if (cachedImageURL() != element->document()->completeURL(cursorElement->href()))
            clearCachedImage();

        SVGElement* svgElement = static_cast<SVGElement*>(element);
        m_referencedElements.add(svgElement);
        svgElement->setCursorImageValue(this);
        cursorElement->addClient(svgElement);
        return true;
    }
#endif

    return false;
}
Exemplo n.º 3
0
StyleCachedImage* CSSCursorImageValue::cachedImage(Element* element, CachedResourceLoader* loader)
{
#if ENABLE(SVG)
    if (isSVGCursorIdentifier(url()) && loader && loader->document()) {
        // FIXME: This will fail if the <cursor> element is in a shadow DOM (bug 59827)
        if (SVGCursorElement* cursorElement = resourceReferencedByCursorElement(url(), loader->document()))
            return CSSImageValue::cachedImage(loader, cursorElement->href());
    }
#endif

    return CSSImageValue::cachedImage(element, loader, url());
}
Exemplo n.º 4
0
StyleCachedImage* CSSCursorImageValue::cachedImage(DocLoader* loader)
{
    String url = getStringValue();

#if ENABLE(SVG) 
    if (isSVGCursorIdentifier(url) && loader && loader->doc()) {
        if (SVGCursorElement* cursorElement = resourceReferencedByCursorElement(url, loader->doc()))
            url = cursorElement->href();
    }
#endif

    return CSSImageValue::cachedImage(loader, url);
}
Exemplo n.º 5
0
CSSCursorImageValue::~CSSCursorImageValue()
{
#if ENABLE(SVG)
    if (!isSVGCursorIdentifier(url()))
        return;

    HashSet<SVGElement*>::const_iterator it = m_referencedElements.begin();
    HashSet<SVGElement*>::const_iterator end = m_referencedElements.end();

    for (; it != end; ++it) {
        SVGElement* referencedElement = *it;
        referencedElement->cursorImageValueRemoved();
        if (SVGCursorElement* cursorElement = resourceReferencedByCursorElement(url(), referencedElement->document()))
            cursorElement->removeClient(referencedElement);
    }
#endif
}