Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(102)

Unified Diff: third_party/WebKit/ManualTests/compositor-worker/scroll-animation.js

Issue 1547893003: WIP - compositor worker mega patch. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/ManualTests/compositor-worker/scroll-animation.js
diff --git a/third_party/WebKit/ManualTests/compositor-worker/scroll-animation.js b/third_party/WebKit/ManualTests/compositor-worker/scroll-animation.js
new file mode 100644
index 0000000000000000000000000000000000000000..b05eab6cbc83c8366b90af78eba2b266ba6ceeda
--- /dev/null
+++ b/third_party/WebKit/ManualTests/compositor-worker/scroll-animation.js
@@ -0,0 +1,45 @@
+(function(scope) {
+ "use strict";
+
+ scope.isMain = function() {
+ return scope.window;
+ };
+
+ scope.tick = function(timestamp) {
+ var newOffset = (Math.sin(timestamp ) + 1) * 500;
+ scroller.scrollTop = newOffset;
+ scope.requestAnimationFrame(tick);
+ };
+
+ scope.initWorker = function() {
+ console.log("init worker");
+ self.onmessage = function(e) {
+ console.log("onmessage");
+ scope.scroller = e.data[0];
+ scope.requestAnimationFrame(tick);
+ };
+ };
+
+ scope.initMain = function() {
+ console.log("init main");
+
+ scope.worker = new CompositorWorker("scroll-animation.js");
+ var scrollElement = document.getElementById("scroller");
+ scope.scroller = new CompositorProxy(scrollElement, ['scrollTop']);
+ scrollElement.addEventListener("scroll", function(e) {
+ this.style.top = (910 - e.target.scrollTop) + "px";
+ var start = new Date();
+ while (true) {
+ var now = new Date();
+ if (now.getTime() - start.getTime() > 200)
+ break;
+ }
+ }.bind(document.getElementById("thingy")));
+ worker.postMessage([scroller]);
+ };
+
+ if (isMain())
+ initMain();
+ else
+ initWorker();
+})(self);

Powered by Google App Engine
This is Rietveld 408576698