Recalculate raster scales whenever the desired raster scale changes

Previous change for moving directly composited images from Blink to cc
missed the cases where the bounds changed in such a way that didn't trip
the code to recalculate raster scale. This means we were re-rastering
with an out of date scale, which can cause visible artifacts around
the edges of the images.

This change removes the misguided attempt to track raster scale aspect
ratio and instead uses the desired raster scale to determine when we
need to recalculate.

Additionally, the check for whether we should directly
composite was taking place too early. The decision can be made only
after the ideal source scale is taken into account. The check moves to
RecalculateRasterScales, and we fall back to the normal recalculation
if the image cannot be directly composited (i.e. doing so would result
in rendering artifacts).

Bug:1075911

Change-Id: Iff0802429aee235ac4a557b181df9ec60a964ed6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2171921
Commit-Queue: Daniel Libby <dlibby@microsoft.com>
Reviewed-by: Philip Rogers <pdr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#765234}
diff --git a/html/semantics/embedded-content/the-img-element/image-compositing-change-ref.html b/html/semantics/embedded-content/the-img-element/image-compositing-change-ref.html
new file mode 100644
index 0000000..ea80d8b
--- /dev/null
+++ b/html/semantics/embedded-content/the-img-element/image-compositing-change-ref.html
@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<html>
+<style>
+#change {
+  height:75px;
+  width:75px;
+}
+</style>
+<img id="change" src="/images/green-16x16.png"></img>
+<img src="/images/green-16x16.png"></img>
diff --git a/html/semantics/embedded-content/the-img-element/image-compositing-change.html b/html/semantics/embedded-content/the-img-element/image-compositing-change.html
new file mode 100644
index 0000000..592720a
--- /dev/null
+++ b/html/semantics/embedded-content/the-img-element/image-compositing-change.html
@@ -0,0 +1,30 @@
+<!DOCTYPE html>
+<html class="reftest-wait">
+<title>Composited images correctly re-raster when the image and bounds change</title>
+<meta charset="utf-8">
+<link rel="match" href="image-compositing-change-ref.html"/>
+<link rel="help" href="https://html.spec.whatwg.org/multipage/#the-img-element">
+<style>
+#change {
+  will-change:transform;
+  height:426px; width:426px;
+}
+</style>
+<img id="change" src="image.png"></img>
+<img id="original" src="../../../../images/green-16x16.png"></img>
+<script>
+window.onload = () => {
+  requestAnimationFrame(() => {
+    requestAnimationFrame(() => {
+      let image = document.querySelector('#change');
+      image.style.width = image.style.height = "75px";
+      image.src = original.src;
+
+      requestAnimationFrame(() => {
+        document.documentElement.classList.remove("reftest-wait");
+      });
+    });
+  });
+}
+</script>
+
diff --git a/html/semantics/embedded-content/the-img-element/resources/blue-10.png b/html/semantics/embedded-content/the-img-element/resources/blue-10.png
new file mode 100644
index 0000000..62949e0
--- /dev/null
+++ b/html/semantics/embedded-content/the-img-element/resources/blue-10.png
Binary files differ