Commit d93811a3 authored by Juanmi Huertas's avatar Juanmi Huertas Committed by Commit Bot

Adding a didDraw if imageRendering changed in the Style

When changing ImageRendering, there are some cases where it is needed to
check if there is something changing in the canvas.
Adding a DidDraw as a change of imageRendering can produce a redraw of
the canvas.


Bug: 1106978
Change-Id: Icdc6b57eaa94e33279f9eb08c2b3cd807d4a1665
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2391727Reviewed-by: default avatarFernando Serboncini <fserb@chromium.org>
Commit-Queue: Juanmi Huertas <juanmihd@chromium.org>
Cr-Commit-Position: refs/heads/master@{#804255}
parent e53cc606
......@@ -1270,11 +1270,25 @@ void HTMLCanvasElement::ContextDestroyed() {
context_->Stop();
}
bool HTMLCanvasElement::StyleChangeNeedsDidDraw(
const ComputedStyle* old_style,
const ComputedStyle& new_style) {
// It will only need to redraw for a style change, if the new imageRendering
// is different than the previous one, and only if one of the two ir
// pixelated.
return old_style &&
old_style->ImageRendering() != new_style.ImageRendering() &&
(old_style->ImageRendering() == EImageRendering::kPixelated ||
new_style.ImageRendering() == EImageRendering::kPixelated);
}
void HTMLCanvasElement::StyleDidChange(const ComputedStyle* old_style,
const ComputedStyle& new_style) {
UpdateFilterQuality(FilterQualityFromStyle(&new_style));
if (context_)
context_->StyleDidChange(old_style, new_style);
if (StyleChangeNeedsDidDraw(old_style, new_style))
DidDraw();
}
void HTMLCanvasElement::LayoutObjectDestroyed() {
......
......@@ -248,6 +248,8 @@ class CORE_EXPORT HTMLCanvasElement final
static void RegisterRenderingContextFactory(
std::unique_ptr<CanvasRenderingContextFactory>);
bool StyleChangeNeedsDidDraw(const ComputedStyle* old_style,
const ComputedStyle& new_style);
void StyleDidChange(const ComputedStyle* old_style,
const ComputedStyle& new_style);
void LayoutObjectDestroyed();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment