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(); }
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()); }
// 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); }
void SVGImage::stopAnimation() { if (!m_page) return; Frame* frame = m_page->mainFrame(); SVGSVGElement* rootElement = toSVGDocument(frame->document())->rootElement(); if (!rootElement) return; rootElement->pauseAnimations(); }
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); }
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; }
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)); }
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; }
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)); }