2009-01-23 David Hyatt <hyatt@apple.com>
[WebKit-https.git] / WebCore / rendering / RenderForeignObject.cpp
index f2a262d..fc12570 100644 (file)
  *
  * You should have received a copy of the GNU Library General Public License
  * along with this library; see the file COPYING.LIB.  If not, write to
- * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
  *
  */
 
 #include "config.h"
 
-#ifdef SVG_SUPPORT
-
+#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,40 +72,50 @@ 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()
 {
     ASSERT(needsLayout());
-    ASSERT(minMaxKnown());
+
+    // Arbitrary affine transforms are incompatible with LayoutState.
+    view()->disableLayoutState();
 
     IntRect oldBounds;
+    IntRect oldOutlineBox;
     bool checkForRepaint = checkForRepaintDuringLayout();
-    if (checkForRepaint)
+    if (checkForRepaint) {
         oldBounds = m_absoluteBounds;
-
+        oldOutlineBox = absoluteOutlineBounds();
+    }
+    
+    calculateLocalTransform();
+    
     RenderBlock::layout();
 
-    m_absoluteBounds = getAbsoluteRepaintRect();
+    m_absoluteBounds = absoluteClippedOverflowRect();
 
     if (checkForRepaint)
-        repaintAfterLayoutIfNeeded(oldBounds, oldBounds);
+        repaintAfterLayoutIfNeeded(oldBounds, oldOutlineBox);
 
+    view()->enableLayoutState();
     setNeedsLayout(false);
 }
 
 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);
@@ -113,4 +124,4 @@ bool RenderForeignObject::nodeAtPoint(const HitTestRequest& request, HitTestResu
 
 } // namespace WebCore
 
-#endif // SVG_SUPPORT
+#endif // ENABLE(SVG) && ENABLE(SVG_FOREIGN_OBJECT)