Index: Source/core/svg/graphics/SVGImage.cpp |
diff --git a/Source/core/svg/graphics/SVGImage.cpp b/Source/core/svg/graphics/SVGImage.cpp |
index 136d923c531bc7daccf949761a0e53e128bc5c59..b58c885eaf61914e783e9d557bb2a6b5c29fb788 100644 |
--- a/Source/core/svg/graphics/SVGImage.cpp |
+++ b/Source/core/svg/graphics/SVGImage.cpp |
@@ -116,13 +116,20 @@ bool SVGImage::currentFrameHasSingleSecurityOrigin() const |
return true; |
} |
+static SVGSVGElement* svgRootElement(Page* page) |
+{ |
+ if (!page) |
+ return 0; |
+ LocalFrame* frame = page->mainFrame(); |
+ return toSVGDocument(frame->document())->rootElement(); |
+} |
+ |
void SVGImage::setContainerSize(const IntSize& size) |
{ |
- if (!m_page || !usesContainerSize()) |
+ if (!usesContainerSize()) |
return; |
- LocalFrame* frame = m_page->mainFrame(); |
- SVGSVGElement* rootElement = toSVGDocument(frame->document())->rootElement(); |
+ SVGSVGElement* rootElement = svgRootElement(m_page.get()); |
if (!rootElement) |
return; |
@@ -137,10 +144,7 @@ void SVGImage::setContainerSize(const IntSize& size) |
IntSize SVGImage::containerSize() const |
{ |
- if (!m_page) |
- return IntSize(); |
- LocalFrame* frame = m_page->mainFrame(); |
- SVGSVGElement* rootElement = toSVGDocument(frame->document())->rootElement(); |
+ SVGSVGElement* rootElement = svgRootElement(m_page.get()); |
if (!rootElement) |
return IntSize(); |
@@ -291,10 +295,7 @@ void SVGImage::draw(GraphicsContext* context, const FloatRect& dstRect, const Fl |
RenderBox* SVGImage::embeddedContentBox() const |
{ |
- if (!m_page) |
- return 0; |
- LocalFrame* frame = m_page->mainFrame(); |
- SVGSVGElement* rootElement = toSVGDocument(frame->document())->rootElement(); |
+ SVGSVGElement* rootElement = svgRootElement(m_page.get()); |
if (!rootElement) |
return 0; |
return toRenderBox(rootElement->renderer()); |
@@ -310,10 +311,7 @@ FrameView* SVGImage::frameView() const |
bool SVGImage::hasRelativeWidth() const |
{ |
- if (!m_page) |
- return false; |
- LocalFrame* frame = m_page->mainFrame(); |
- SVGSVGElement* rootElement = toSVGDocument(frame->document())->rootElement(); |
+ SVGSVGElement* rootElement = svgRootElement(m_page.get()); |
if (!rootElement) |
return false; |
return rootElement->intrinsicWidth().isPercent(); |
@@ -321,10 +319,7 @@ bool SVGImage::hasRelativeWidth() const |
bool SVGImage::hasRelativeHeight() const |
{ |
- if (!m_page) |
- return false; |
- LocalFrame* frame = m_page->mainFrame(); |
- SVGSVGElement* rootElement = toSVGDocument(frame->document())->rootElement(); |
+ SVGSVGElement* rootElement = svgRootElement(m_page.get()); |
if (!rootElement) |
return false; |
return rootElement->intrinsicHeight().isPercent(); |
@@ -332,10 +327,7 @@ bool SVGImage::hasRelativeHeight() const |
void SVGImage::computeIntrinsicDimensions(Length& intrinsicWidth, Length& intrinsicHeight, FloatSize& intrinsicRatio) |
{ |
- if (!m_page) |
- return; |
- LocalFrame* frame = m_page->mainFrame(); |
- SVGSVGElement* rootElement = toSVGDocument(frame->document())->rootElement(); |
+ SVGSVGElement* rootElement = svgRootElement(m_page.get()); |
if (!rootElement) |
return; |
@@ -352,10 +344,7 @@ void SVGImage::computeIntrinsicDimensions(Length& intrinsicWidth, Length& intrin |
// FIXME: support catchUpIfNecessary. |
void SVGImage::startAnimation(bool /* catchUpIfNecessary */) |
{ |
- if (!m_page) |
- return; |
- LocalFrame* frame = m_page->mainFrame(); |
- SVGSVGElement* rootElement = toSVGDocument(frame->document())->rootElement(); |
+ SVGSVGElement* rootElement = svgRootElement(m_page.get()); |
if (!rootElement || !rootElement->animationsPaused()) |
return; |
rootElement->unpauseAnimations(); |
@@ -363,10 +352,7 @@ void SVGImage::startAnimation(bool /* catchUpIfNecessary */) |
void SVGImage::stopAnimation() |
{ |
- if (!m_page) |
- return; |
- LocalFrame* frame = m_page->mainFrame(); |
- SVGSVGElement* rootElement = toSVGDocument(frame->document())->rootElement(); |
+ SVGSVGElement* rootElement = svgRootElement(m_page.get()); |
if (!rootElement) |
return; |
rootElement->pauseAnimations(); |
@@ -374,10 +360,7 @@ void SVGImage::stopAnimation() |
void SVGImage::resetAnimation() |
{ |
- if (!m_page) |
- return; |
- LocalFrame* frame = m_page->mainFrame(); |
- SVGSVGElement* rootElement = toSVGDocument(frame->document())->rootElement(); |
+ SVGSVGElement* rootElement = svgRootElement(m_page.get()); |
if (!rootElement) |
return; |
rootElement->pauseAnimations(); |
@@ -386,13 +369,10 @@ void SVGImage::resetAnimation() |
bool SVGImage::hasAnimations() const |
{ |
- if (!m_page) |
- return false; |
- LocalFrame* frame = m_page->mainFrame(); |
- SVGSVGElement* rootElement = toSVGDocument(frame->document())->rootElement(); |
+ SVGSVGElement* rootElement = svgRootElement(m_page.get()); |
if (!rootElement) |
return false; |
- return rootElement->timeContainer()->hasAnimations() || frame->document()->timeline().hasPendingUpdates(); |
+ return rootElement->timeContainer()->hasAnimations() || m_page->mainFrame()->document()->timeline().hasPendingUpdates(); |
} |
bool SVGImage::dataChanged(bool allDataReceived) |