Upstream version 10.39.225.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / core / rendering / RenderHTMLCanvas.cpp
index 8b1d87d..b454d89 100644 (file)
@@ -31,6 +31,7 @@
 #include "core/frame/FrameView.h"
 #include "core/frame/LocalFrame.h"
 #include "core/page/Page.h"
+#include "core/paint/HTMLCanvasPainter.h"
 #include "core/rendering/PaintInfo.h"
 #include "core/rendering/RenderView.h"
 
@@ -51,38 +52,7 @@ LayerType RenderHTMLCanvas::layerTypeRequired() const
 
 void RenderHTMLCanvas::paintReplaced(PaintInfo& paintInfo, const LayoutPoint& paintOffset)
 {
-    GraphicsContext* context = paintInfo.context;
-
-    LayoutRect contentRect = contentBoxRect();
-    contentRect.moveBy(paintOffset);
-    LayoutRect paintRect = replacedContentRect();
-    paintRect.moveBy(paintOffset);
-
-    bool clip = !contentRect.contains(paintRect);
-    if (clip) {
-        // Not allowed to overflow the content box.
-        paintInfo.context->save();
-        paintInfo.context->clip(pixelSnappedIntRect(contentRect));
-    }
-
-    // FIXME: InterpolationNone should be used if ImageRenderingOptimizeContrast is set.
-    // See bug for more details: crbug.com/353716.
-    InterpolationQuality interpolationQuality = style()->imageRendering() == ImageRenderingOptimizeContrast ? InterpolationLow : CanvasDefaultInterpolationQuality;
-
-    HTMLCanvasElement* canvas = toHTMLCanvasElement(node());
-    LayoutSize layoutSize = contentRect.size();
-    if (style()->imageRendering() == ImageRenderingPixelated
-        && (layoutSize.width() > canvas->width() || layoutSize.height() > canvas->height() || layoutSize == canvas->size())) {
-        interpolationQuality = InterpolationNone;
-    }
-
-    InterpolationQuality previousInterpolationQuality = context->imageInterpolationQuality();
-    context->setImageInterpolationQuality(interpolationQuality);
-    canvas->paint(context, paintRect);
-    context->setImageInterpolationQuality(previousInterpolationQuality);
-
-    if (clip)
-        context->restore();
+    HTMLCanvasPainter(*this).paintReplaced(paintInfo, paintOffset);
 }
 
 void RenderHTMLCanvas::canvasSizeChanged()