2009-01-23 David Hyatt <hyatt@apple.com>
[WebKit-https.git] / WebCore / rendering / RenderForeignObject.cpp
index 1cd0ec4..fc12570 100644 (file)
 
 #include "config.h"
 
-#if ENABLE(SVG)
+#if ENABLE(SVG) && ENABLE(SVG_FOREIGN_OBJECT)
 #include "RenderForeignObject.h"
 
 #include "GraphicsContext.h"
 #include "RenderView.h"
 #include "SVGForeignObjectElement.h"
 #include "SVGLength.h"
+#include "SVGTransformList.h"
 
 namespace WebCore {
 
@@ -37,10 +38,10 @@ RenderForeignObject::RenderForeignObject(SVGForeignObjectElement* node)
 {
 }
 
-AffineTransform RenderForeignObject::translationForAttributes()
+TransformationMatrix RenderForeignObject::translationForAttributes()
 {
     SVGForeignObjectElement* foreign = static_cast<SVGForeignObjectElement*>(element());
-    return AffineTransform().translate(foreign->x().value(), foreign->y().value());
+    return TransformationMatrix().translate(foreign->x().value(foreign), foreign->y().value(foreign));
 }
 
 void RenderForeignObject::paint(PaintInfo& paintInfo, int parentX, int parentY)
@@ -49,7 +50,7 @@ void RenderForeignObject::paint(PaintInfo& paintInfo, int parentX, int parentY)
         return;
 
     paintInfo.context->save();
-    paintInfo.context->concatCTM(AffineTransform().translate(parentX, parentY));
+    paintInfo.context->concatCTM(TransformationMatrix().translate(parentX, parentY));
     paintInfo.context->concatCTM(localTransform());
     paintInfo.context->concatCTM(translationForAttributes());
     paintInfo.context->clip(getClipRect(parentX, parentY));
@@ -71,15 +72,17 @@ void RenderForeignObject::paint(PaintInfo& paintInfo, int parentX, int parentY)
 
 void RenderForeignObject::computeAbsoluteRepaintRect(IntRect& r, bool f)
 {
-    AffineTransform transform = translationForAttributes() * localTransform();
+    TransformationMatrix transform = translationForAttributes() * localTransform();
     r = transform.mapRect(r);
 
     RenderBlock::computeAbsoluteRepaintRect(r, f);
 }
 
-bool RenderForeignObject::requiresLayer()
+bool RenderForeignObject::calculateLocalTransform()
 {
-    return false;
+    TransformationMatrix oldTransform = m_localTransform;
+    m_localTransform = static_cast<SVGForeignObjectElement*>(element())->animatedLocalTransform();
+    return (oldTransform != m_localTransform);
 }
 
 void RenderForeignObject::layout()
@@ -94,9 +97,11 @@ void RenderForeignObject::layout()
     bool checkForRepaint = checkForRepaintDuringLayout();
     if (checkForRepaint) {
         oldBounds = m_absoluteBounds;
-        oldOutlineBox = absoluteOutlineBox();
+        oldOutlineBox = absoluteOutlineBounds();
     }
-
+    
+    calculateLocalTransform();
+    
     RenderBlock::layout();
 
     m_absoluteBounds = absoluteClippedOverflowRect();
@@ -110,7 +115,7 @@ void RenderForeignObject::layout()
 
 bool RenderForeignObject::nodeAtPoint(const HitTestRequest& request, HitTestResult& result, int x, int y, int tx, int ty, HitTestAction hitTestAction)
 {
-    AffineTransform totalTransform = absoluteTransform();
+    TransformationMatrix totalTransform = absoluteTransform();
     totalTransform *= translationForAttributes();
     double localX, localY;
     totalTransform.inverse().map(x, y, &localX, &localY);
@@ -119,4 +124,4 @@ bool RenderForeignObject::nodeAtPoint(const HitTestRequest& request, HitTestResu
 
 } // namespace WebCore
 
-#endif // ENABLE(SVG)
+#endif // ENABLE(SVG) && ENABLE(SVG_FOREIGN_OBJECT)