summaryrefslogtreecommitdiff
path: root/Source/WebCore/rendering/RenderHTMLCanvas.cpp
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@lorry>2017-06-27 06:07:23 +0000
committerLorry Tar Creator <lorry-tar-importer@lorry>2017-06-27 06:07:23 +0000
commit1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c (patch)
tree46dcd36c86e7fbc6e5df36deb463b33e9967a6f7 /Source/WebCore/rendering/RenderHTMLCanvas.cpp
parent32761a6cee1d0dee366b885b7b9c777e67885688 (diff)
downloadWebKitGtk-tarball-master.tar.gz
Diffstat (limited to 'Source/WebCore/rendering/RenderHTMLCanvas.cpp')
-rw-r--r--Source/WebCore/rendering/RenderHTMLCanvas.cpp50
1 files changed, 19 insertions, 31 deletions
diff --git a/Source/WebCore/rendering/RenderHTMLCanvas.cpp b/Source/WebCore/rendering/RenderHTMLCanvas.cpp
index 034f3788f..c88cb1354 100644
--- a/Source/WebCore/rendering/RenderHTMLCanvas.cpp
+++ b/Source/WebCore/rendering/RenderHTMLCanvas.cpp
@@ -10,10 +10,10 @@
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
@@ -33,6 +33,7 @@
#include "GraphicsContext.h"
#include "HTMLCanvasElement.h"
#include "HTMLNames.h"
+#include "ImageQualityController.h"
#include "Page.h"
#include "PaintInfo.h"
#include "RenderView.h"
@@ -41,8 +42,8 @@ namespace WebCore {
using namespace HTMLNames;
-RenderHTMLCanvas::RenderHTMLCanvas(HTMLCanvasElement& element, PassRef<RenderStyle> style)
- : RenderReplaced(element, std::move(style), element.size())
+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()));
@@ -50,7 +51,7 @@ RenderHTMLCanvas::RenderHTMLCanvas(HTMLCanvasElement& element, PassRef<RenderSty
HTMLCanvasElement& RenderHTMLCanvas::canvasElement() const
{
- return toHTMLCanvasElement(nodeForNonAnonymous());
+ return downcast<HTMLCanvasElement>(nodeForNonAnonymous());
}
bool RenderHTMLCanvas::requiresLayer() const
@@ -66,26 +67,24 @@ bool RenderHTMLCanvas::requiresLayer() const
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(intrinsicSize());
+ replacedContentRect.moveBy(paintOffset);
// 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)
- paintInfo.context->clip(pixelSnappedIntRect(contentRect));
+ paintInfo.context().clip(snappedIntRect(contentBoxRect));
- if (Page* page = frame().page()) {
- if (paintInfo.phase == PaintPhaseForeground)
- page->addRelevantRepaintedObject(this, intersection(paintRect, contentRect));
- }
+ if (paintInfo.phase == PaintPhaseForeground)
+ 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()
@@ -100,18 +99,7 @@ void RenderHTMLCanvas::canvasSizeChanged()
if (!parent())
return;
-
- if (!preferredLogicalWidthsDirty())
- setPreferredLogicalWidthsDirty(true);
-
- LayoutSize oldSize = size();
- updateLogicalWidth();
- updateLogicalHeight();
- if (oldSize == size())
- return;
-
- if (!selfNeedsLayout())
- setNeedsLayout();
+ setNeedsLayoutIfNeededAfterIntrinsicSizeChange();
}
} // namespace WebCore