Improve will-change:transform raster scale adjustment

This fixes the issue of too big scale for will-change:transform layers
by
- Partly reverting crrev.com/c/2447650 to apply the change on tiny
scales only. When the ideal scale is not tiny, use the original policy
to clamp minimum scale to the native scale.
- Increasing kMinScaleRatioForWillChangeTransform from 0.1 to 0.25 to
reduce memory and number of tiles when the scale is bigger than ideal,
from 100x to 16x in worst cases.

Bug: 1146393
Change-Id: Ida5720f5126648c2fad0b9921781714fa006d346
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2527733
Reviewed-by: vmpstr <vmpstr@chromium.org>
Commit-Queue: Xianzhu Wang <wangxianzhu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#825998}
diff --git a/css/css-transforms/change-scale-wide-range-ref.html b/css/css-transforms/change-scale-wide-range-ref.html
new file mode 100644
index 0000000..264c6b6
--- /dev/null
+++ b/css/css-transforms/change-scale-wide-range-ref.html
@@ -0,0 +1,3 @@
+<!DOCTYPE html>
+<div style="width: 200px; height: 200px; background: green; border: 10px solid blue"></div>
+
diff --git a/css/css-transforms/change-scale-wide-range.html b/css/css-transforms/change-scale-wide-range.html
new file mode 100644
index 0000000..ec41946
--- /dev/null
+++ b/css/css-transforms/change-scale-wide-range.html
@@ -0,0 +1,29 @@
+<!DOCTYPE html>
+<html class="reftest-wait">
+<title>Change scale to very big then back</title>
+<link rel="author" title="Xianzhu Wang" href="mailto:wangxianzhu@chromium.org">
+<link rel="help" href="https://crbug.com/1146393">
+<link rel="match" href="change-scale-wide-range-ref.html">
+<style>
+#target {
+  will-change: transform;
+  transform-origin: 0 0;
+  width: 200px;
+  height: 200px;
+  background: green;
+  border: 10px solid blue;
+}
+</style>
+<div id="target"></div>
+<script>
+requestAnimationFrame(() => {
+  requestAnimationFrame(() => {
+    target.style.transform = 'scale(100)';
+    requestAnimationFrame(() => {
+      target.style.transform = 'scale(1)';
+      document.documentElement.removeAttribute('class');
+    });
+  });
+});
+</script>
+
diff --git a/css/css-transforms/huge-length-tiny-scale-ref.html b/css/css-transforms/huge-length-tiny-scale-ref.html
new file mode 100644
index 0000000..f3f8abc
--- /dev/null
+++ b/css/css-transforms/huge-length-tiny-scale-ref.html
@@ -0,0 +1,2 @@
+<!DOCTYPE html>
+<div style="width: 200px; height: 200px; background: green; border: 10px solid blue"></div>
diff --git a/css/css-transforms/huge-length-tiny-scale.html b/css/css-transforms/huge-length-tiny-scale.html
new file mode 100644
index 0000000..53f4f7d
--- /dev/null
+++ b/css/css-transforms/huge-length-tiny-scale.html
@@ -0,0 +1,20 @@
+<!DOCTYPE html>
+<title>Huge lengths with tiny scale</title>
+<link rel="author" title="Xianzhu Wang" href="mailto:wangxianzhu@chromium.org">
+<link rel="help" href="https://crbug.com/1132991">
+<link rel="match" href="huge-length-tiny-scale-ref.html">
+<style>
+body {
+  overflow: hidden;
+}
+div {
+  will-change: transform;
+  transform: scale(0.005);
+  transform-origin: 0 0;
+  width: 40000px;
+  height: 40000px;
+  background: green;
+  border: 2000px solid blue;
+}
+</style>
+<div></div>