Use enum classes and OptionSets for PaintPhase and PaintBehavior
[WebKit-https.git] / Source / WebCore / rendering / RenderHTMLCanvas.cpp
index e218544..5a3086e 100644 (file)
 #include "GraphicsContext.h"
 #include "HTMLCanvasElement.h"
 #include "HTMLNames.h"
 #include "GraphicsContext.h"
 #include "HTMLCanvasElement.h"
 #include "HTMLNames.h"
+#include "ImageQualityController.h"
 #include "Page.h"
 #include "PaintInfo.h"
 #include "RenderView.h"
 #include "Page.h"
 #include "PaintInfo.h"
 #include "RenderView.h"
+#include <wtf/IsoMallocInlines.h>
 
 namespace WebCore {
 
 using namespace HTMLNames;
 
 
 namespace WebCore {
 
 using namespace HTMLNames;
 
-RenderHTMLCanvas::RenderHTMLCanvas(HTMLCanvasElement& element, Ref<RenderStyle>&& style)
-    : RenderReplaced(element, WTF::move(style), element.size())
+WTF_MAKE_ISO_ALLOCATED_IMPL(RenderHTMLCanvas);
+
+RenderHTMLCanvas::RenderHTMLCanvas(HTMLCanvasElement& element, RenderStyle&& style)
+    : RenderReplaced(element, WTFMove(style), element.size())
 {
     // Actual size is not known yet, report the default intrinsic size.
     view().frameView().incrementVisuallyNonEmptyPixelCount(roundedIntSize(intrinsicSize()));
 {
     // Actual size is not known yet, report the default intrinsic size.
     view().frameView().incrementVisuallyNonEmptyPixelCount(roundedIntSize(intrinsicSize()));
@@ -66,26 +70,24 @@ bool RenderHTMLCanvas::requiresLayer() const
 
 void RenderHTMLCanvas::paintReplaced(PaintInfo& paintInfo, const LayoutPoint& paintOffset)
 {
 
 void RenderHTMLCanvas::paintReplaced(PaintInfo& paintInfo, const LayoutPoint& paintOffset)
 {
-    GraphicsContext* context = paintInfo.context;
+    GraphicsContext& context = paintInfo.context();
 
 
-    LayoutRect contentRect = contentBoxRect();
-    contentRect.moveBy(paintOffset);
-    LayoutRect paintRect = replacedContentRect(intrinsicSize());
-    paintRect.moveBy(paintOffset);
+    LayoutRect contentBoxRect = this->contentBoxRect();
+    contentBoxRect.moveBy(paintOffset);
+    LayoutRect replacedContentRect = this->replacedContentRect();
+    replacedContentRect.moveBy(paintOffset);
 
     // Not allowed to overflow the content box.
 
     // Not allowed to overflow the content box.
-    bool clip = !contentRect.contains(paintRect);
-    GraphicsContextStateSaver stateSaver(*paintInfo.context, clip);
+    bool clip = !contentBoxRect.contains(replacedContentRect);
+    GraphicsContextStateSaver stateSaver(paintInfo.context(), clip);
     if (clip)
     if (clip)
-        paintInfo.context->clip(snappedIntRect(contentRect));
+        paintInfo.context().clip(snappedIntRect(contentBoxRect));
 
 
-    if (Page* page = frame().page()) {
-        if (paintInfo.phase == PaintPhaseForeground)
-            page->addRelevantRepaintedObject(this, intersection(paintRect, contentRect));
-    }
+    if (paintInfo.phase == PaintPhase::Foreground)
+        page().addRelevantRepaintedObject(this, intersection(replacedContentRect, contentBoxRect));
 
 
-    bool useLowQualityScale = style().imageRendering() == ImageRenderingCrispEdges || style().imageRendering() == ImageRenderingOptimizeSpeed;
-    canvasElement().paint(context, paintRect, useLowQualityScale);
+    InterpolationQualityMaintainer interpolationMaintainer(context, ImageQualityController::interpolationQualityFromStyle(style()));
+    canvasElement().paint(context, replacedContentRect);
 }
 
 void RenderHTMLCanvas::canvasSizeChanged()
 }
 
 void RenderHTMLCanvas::canvasSizeChanged()
@@ -100,18 +102,7 @@ void RenderHTMLCanvas::canvasSizeChanged()
 
     if (!parent())
         return;
 
     if (!parent())
         return;
-
-    if (!preferredLogicalWidthsDirty())
-        setPreferredLogicalWidthsDirty(true);
-
-    LayoutSize oldSize = size();
-    updateLogicalWidth();
-    updateLogicalHeight();
-    if (oldSize == size())
-        return;
-
-    if (!selfNeedsLayout())
-        setNeedsLayout();
+    setNeedsLayoutIfNeededAfterIntrinsicSizeChange();
 }
 
 } // namespace WebCore
 }
 
 } // namespace WebCore