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

Side by Side Diff: LayoutTests/fast/scroll-behavior/resources/scroll-behavior-test.js

Issue 802383003: Run CSSOM smooth scroll animations on the compositor when possible (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Add comment Created 5 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // A ScrollBehaviorTest runs a set of ScrollBehaviorTestCases. The only 1 // A ScrollBehaviorTest runs a set of ScrollBehaviorTestCases. The only
2 // ScrollBehaviorTest method that should be called by external code is run(). 2 // ScrollBehaviorTest method that should be called by external code is run().
3 3
4 // Creates a ScrollBehaviorTest with arguments: 4 // Creates a ScrollBehaviorTest with arguments:
5 // scrollElement - Element being scrolled. 5 // scrollElement - Element being scrolled.
6 // scrollEventTarget - Target for scroll events for |scrollElement|. 6 // scrollEventTarget - Target for scroll events for |scrollElement|.
7 // testsCases - Array of ScrollBehaviorTestCases. 7 // testsCases - Array of ScrollBehaviorTestCases.
8 // getEndPosition - Callback that takes a test case and start position, and 8 // getEndPosition - Callback that takes a test case and start position, and
9 // returns the corresponding end position (where positions 9 // returns the corresponding end position (where positions
10 // are dictionaries with x and y fields). 10 // are dictionaries with x and y fields).
(...skipping 18 matching lines...) Expand all
29 ScrollBehaviorTest.prototype.scrollListener = function(testCase) { 29 ScrollBehaviorTest.prototype.scrollListener = function(testCase) {
30 if (testCase.waitForEnd) { 30 if (testCase.waitForEnd) {
31 if (this.scrollElement.scrollLeft == testCase.endX && this.scrollElement .scrollTop == testCase.endY) 31 if (this.scrollElement.scrollLeft == testCase.endX && this.scrollElement .scrollTop == testCase.endY)
32 this.testCaseComplete(); 32 this.testCaseComplete();
33 return; 33 return;
34 } 34 }
35 35
36 // Wait for an intermediate frame, then instant-scroll to the end state. 36 // Wait for an intermediate frame, then instant-scroll to the end state.
37 if ((this.scrollElement.scrollLeft != testCase.startX || this.scrollElement. scrollTop != testCase.startY) && 37 if ((this.scrollElement.scrollLeft != testCase.startX || this.scrollElement. scrollTop != testCase.startY) &&
38 (this.scrollElement.scrollLeft != testCase.endX || this.scrollElement.sc rollTop != testCase.endY)) { 38 (this.scrollElement.scrollLeft != testCase.endX || this.scrollElement.sc rollTop != testCase.endY)) {
39 // Instant scroll, and then wait for the next scroll event. This allows
40 // the instant scroll to propagate to the compositor (when using
41 // composited scrolling) so that the next smooth scroll starts at this
42 // position (the compositor always starts smooth scrolls at the current
43 // scroll position on the compositor thread).
39 this.scrollElement.scrollTo({left: testCase.endX, top: testCase.endY, be havior: "instant"}); 44 this.scrollElement.scrollTo({left: testCase.endX, top: testCase.endY, be havior: "instant"});
40 this.testCaseComplete(); 45 testCase.waitForEnd = true;
41 } 46 }
42 }; 47 };
43 48
44 ScrollBehaviorTest.prototype.startNextTestCase = function() { 49 ScrollBehaviorTest.prototype.startNextTestCase = function() {
45 if (this.currentTestCase >= this.testCases.length) { 50 if (this.currentTestCase >= this.testCases.length) {
46 this.allTestCasesComplete(); 51 this.allTestCasesComplete();
47 return; 52 return;
48 } 53 }
49 var testCase = this.testCases[this.currentTestCase]; 54 var testCase = this.testCases[this.currentTestCase];
50 var isSmoothTest = (testCase.js == "smooth" || (testCase.css == "smooth" && testCase.js != "instant")); 55 var isSmoothTest = (testCase.js == "smooth" || (testCase.css == "smooth" && testCase.js != "instant"));
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 if (currentScrollListener) { 93 if (currentScrollListener) {
89 this.scrollEventTarget.removeEventListener("scroll", currentScrollListen er); 94 this.scrollEventTarget.removeEventListener("scroll", currentScrollListen er);
90 } 95 }
91 this.asyncTest.done(); 96 this.asyncTest.done();
92 97
93 this.currentTestCase++; 98 this.currentTestCase++;
94 this.startNextTestCase(); 99 this.startNextTestCase();
95 } 100 }
96 101
97 ScrollBehaviorTest.prototype.run = function() { 102 ScrollBehaviorTest.prototype.run = function() {
98 setup({explicit_done: true}); 103 setup({explicit_done: true, explicit_timeout: true});
99 this.startNextTestCase(); 104 this.startNextTestCase();
100 } 105 }
101 106
102 ScrollBehaviorTest.prototype.allTestCasesComplete = function() { 107 ScrollBehaviorTest.prototype.allTestCasesComplete = function() {
103 done(); 108 done();
104 } 109 }
105 110
106 111
107 // A ScrollBehaviorTestCase represents a single scroll. 112 // A ScrollBehaviorTestCase represents a single scroll.
108 // 113 //
(...skipping 14 matching lines...) Expand all
123 128
124 ScrollBehaviorTestCase.prototype.setStartPosition = function(startPosition) { 129 ScrollBehaviorTestCase.prototype.setStartPosition = function(startPosition) {
125 this.startX = startPosition.x; 130 this.startX = startPosition.x;
126 this.startY = startPosition.y; 131 this.startY = startPosition.y;
127 } 132 }
128 133
129 ScrollBehaviorTestCase.prototype.setEndPosition = function(endPosition) { 134 ScrollBehaviorTestCase.prototype.setEndPosition = function(endPosition) {
130 this.endX = endPosition.x; 135 this.endX = endPosition.x;
131 this.endY = endPosition.y; 136 this.endY = endPosition.y;
132 } 137 }
OLDNEW
« no previous file with comments | « LayoutTests/VirtualTestSuites ('k') | LayoutTests/fast/scroll-behavior/resources/scroll-interruption-test.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698