Beispiel #1
0
bool SVGImage::hasRelativeHeight() const
{
    if (!m_page)
        return false;
    Frame* frame = m_page->mainFrame();
    SVGSVGElement* rootElement = toSVGDocument(frame->document())->rootElement();
    if (!rootElement)
        return false;
    return rootElement->intrinsicHeight().isPercent();
}
Beispiel #2
0
RenderBox* SVGImage::embeddedContentBox() const
{
    if (!m_page)
        return 0;
    Frame* frame = m_page->mainFrame();
    SVGSVGElement* rootElement = toSVGDocument(frame->document())->rootElement();
    if (!rootElement)
        return 0;
    return toRenderBox(rootElement->renderer());
}
Beispiel #3
0
// FIXME: support catchUpIfNecessary.
void SVGImage::startAnimation(CatchUpAnimation)
{
    if (!m_page)
        return;
    SVGSVGElement* rootElement = toSVGDocument(m_page->mainFrame().document())->rootElement();
    if (!rootElement)
        return;
    rootElement->unpauseAnimations();
    rootElement->setCurrentTime(0);
}
Beispiel #4
0
void SVGImage::stopAnimation()
{
    if (!m_page)
        return;
    Frame* frame = m_page->mainFrame();
    SVGSVGElement* rootElement = toSVGDocument(frame->document())->rootElement();
    if (!rootElement)
        return;
    rootElement->pauseAnimations();
}
Beispiel #5
0
bool SVGImage::hasAnimations() const
{
    if (!m_page)
        return false;
    LocalFrame* frame = m_page->mainFrame();
    SVGSVGElement* rootElement = toSVGDocument(frame->document())->rootElement();
    if (!rootElement)
        return false;
    return rootElement->timeContainer()->hasAnimations() || frame->document()->timeline().hasPendingUpdates();
}
// FIXME: support catchUpIfNecessary.
void SVGImage::startAnimation(bool /* catchUpIfNecessary */)
{
    if (!m_page)
        return;
    Frame* frame = m_page->mainFrame();
    SVGSVGElement* rootElement = toSVGDocument(frame->document())->rootElement();
    if (!rootElement)
        return;
    rootElement->unpauseAnimations();
    rootElement->setCurrentTime(0);
}
Beispiel #7
0
v8::Handle<v8::Object> wrap(Document* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
{
    ASSERT(impl);
    if (impl->isHTMLDocument())
        return wrap(toHTMLDocument(impl), creationContext, isolate);
    if (impl->isSVGDocument())
        return wrap(toSVGDocument(impl), creationContext, isolate);
    v8::Handle<v8::Object> wrapper = V8Document::createWrapper(impl, creationContext, isolate);
    if (wrapper.IsEmpty())
        return wrapper;
    if (!isolatedWorldForEnteredContext()) {
        if (Frame* frame = impl->frame())
            frame->script()->windowShell(mainThreadNormalWorld())->updateDocumentWrapper(wrapper);
    }
    return wrapper;
}
Beispiel #8
0
void SVGImage::setContainerSize(const FloatSize& size)
{
    if (!m_page || !usesContainerSize())
        return;

    SVGSVGElement* rootElement = toSVGDocument(m_page->mainFrame().document())->rootElement();
    if (!rootElement)
        return;
    RenderSVGRoot* renderer = toRenderSVGRoot(rootElement->renderer());
    if (!renderer)
        return;

    FrameView* view = frameView();
    view->resize(this->containerSize());

    renderer->setContainerSize(IntSize(size));
}
Beispiel #9
0
bool SVGImage::hasSingleSecurityOrigin() const
{
    if (!m_page)
        return true;

    SVGSVGElement* rootElement = toSVGDocument(m_page->mainFrame().document())->rootElement();
    if (!rootElement)
        return true;

    // Don't allow foreignObject elements since they can leak information with arbitrary HTML (like spellcheck or control theme).
    if (descendantsOfType<SVGForeignObjectElement>(*rootElement).first())
        return false;

    // Because SVG image rendering disallows external resources and links,
    // these images effectively are restricted to a single security origin.
    return true;
}
Beispiel #10
0
void SVGImage::computeIntrinsicDimensions(Length& intrinsicWidth, Length& intrinsicHeight, FloatSize& intrinsicRatio)
{
    if (!m_page)
        return;
    SVGSVGElement* rootElement = toSVGDocument(m_page->mainFrame().document())->rootElement();
    if (!rootElement)
        return;

    intrinsicWidth = rootElement->intrinsicWidth();
    intrinsicHeight = rootElement->intrinsicHeight();
    if (rootElement->preserveAspectRatio().align() == SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_NONE)
        return;

    intrinsicRatio = rootElement->viewBox().size();
    if (intrinsicRatio.isEmpty() && intrinsicWidth.isFixed() && intrinsicHeight.isFixed())
        intrinsicRatio = FloatSize(floatValueForLength(intrinsicWidth, 0), floatValueForLength(intrinsicHeight, 0));
}