Eliminate a request for layout every time an item is added to the stage of the graphi...
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 14 Nov 2015 05:51:27 +0000 (05:51 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 14 Nov 2015 05:51:27 +0000 (05:51 +0000)
https://bugs.webkit.org/show_bug.cgi?id=151289

Patch by Said Abou-Hallawa <sabouhallawa@apple.com> on 2015-11-13
Reviewed by Simon Fraser.

Cache the stage size when it is created instead of requesting every time
an object is added via clientWidth and clientHeight.

* Animometer/resources/extensions.js:
(Insets.elementPadding):
* Animometer/tests/resources/stage.js:
(Stage):
(Stage.prototype.get size):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@192455 268f45cc-cd09-0410-ab3c-d52691b4dbfc

PerformanceTests/Animometer/resources/extensions.js
PerformanceTests/Animometer/tests/resources/stage.js
PerformanceTests/ChangeLog

index 35673bf..a090eca 100644 (file)
@@ -68,6 +68,16 @@ function Insets(top, right, bottom, left)
     this.left = left;
 }
 
+Insets.elementPadding = function(element)
+{
+    var styles = window.getComputedStyle(element);
+    return new Insets(
+        parseFloat(styles.paddingTop),
+        parseFloat(styles.paddingRight),
+        parseFloat(styles.paddingBottom),
+        parseFloat(styles.paddingTop));
+}
+
 Insets.prototype =
 {
     get width()
index 2bb49d5..08f39c9 100644 (file)
@@ -35,19 +35,14 @@ Rotater.prototype =
 function Stage(element, options)
 {
     this.element = element;
+    this._size = Point.elementClientSize(element).subtract(Insets.elementPadding(element).size);
 }
 
 Stage.prototype =
 {
     get size()
     {
-        var styles = window.getComputedStyle(this.element);
-        var padding = new Insets(
-            parseFloat(styles.paddingTop),
-            parseFloat(styles.paddingRight),
-            parseFloat(styles.paddingBottom),
-            parseFloat(styles.paddingTop));
-        return new Point(this.element.clientWidth - padding.width, this.element.clientHeight - padding.height);
+        return this._size
     },
     
     random: function(min, max)
index 2ea4ad2..583419f 100644 (file)
@@ -1,3 +1,19 @@
+2015-11-13  Said Abou-Hallawa  <sabouhallawa@apple.com>
+
+        Eliminate a request for layout every time an item is added to the stage of the graphics benchmark
+        https://bugs.webkit.org/show_bug.cgi?id=151289
+
+        Reviewed by Simon Fraser.
+        
+        Cache the stage size when it is created instead of requesting every time
+        an object is added via clientWidth and clientHeight.
+
+        * Animometer/resources/extensions.js:
+        (Insets.elementPadding):
+        * Animometer/tests/resources/stage.js:
+        (Stage):
+        (Stage.prototype.get size):
+
 2015-11-06  Said Abou-Hallawa  <sabouhallawa@apple.com>
 
         Initialize the graphics benchmark's Kalman filter with estimated 60 FPS