Commit log viewer repaints too frequently after r198499
authorrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 22 Mar 2016 02:58:19 +0000 (02:58 +0000)
committerrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 22 Mar 2016 02:58:19 +0000 (02:58 +0000)
https://bugs.webkit.org/show_bug.cgi?id=155732

Reviewed by Joseph Pecoraro.

The bug was caused by InteractiveTimeSeriesChart invoking onchange callback whenever mouse moved even
if the current point didn't change. Fixed the bug by avoiding the work if the indicator hadn't changed
and avoiding work in the commit log viewer when the requested repository and the revision range were
the same as those of the last request.

* public/v3/components/commit-log-viewer.js:
(CommitLogViewer):
(CommitLogViewer.prototype.currentRepository): Exit early when repository and the revision range are
identical to the one we already have to avoid repaints and issuing multiple network requests.
* public/v3/components/interactive-time-series-chart.js:
(InteractiveTimeSeriesChart.prototype._mouseMove): Don't invoke _notifyIndicatorChanged if the current
indicator hadn't changed.
* public/v3/pages/chart-pane.js:
(ChartPane.prototype._indicatorDidChange): Fixed the bug that unlocking the indicator wouldn't update
the URL. We need to check whether the lock state had changed. The old condition was also redundant
since _mainChartIndicatorWasLocked is always identically equal to isLocked per the prior assignment.

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

Websites/perf.webkit.org/ChangeLog
Websites/perf.webkit.org/public/v3/components/commit-log-viewer.js
Websites/perf.webkit.org/public/v3/components/interactive-time-series-chart.js
Websites/perf.webkit.org/public/v3/pages/chart-pane.js

index 46baeb8..0681535 100644 (file)
@@ -1,5 +1,29 @@
 2016-03-21  Ryosuke Niwa  <rniwa@webkit.org>
 
+        Commit log viewer repaints too frequently after r198499
+        https://bugs.webkit.org/show_bug.cgi?id=155732
+
+        Reviewed by Joseph Pecoraro.
+
+        The bug was caused by InteractiveTimeSeriesChart invoking onchange callback whenever mouse moved even
+        if the current point didn't change. Fixed the bug by avoiding the work if the indicator hadn't changed
+        and avoiding work in the commit log viewer when the requested repository and the revision range were
+        the same as those of the last request.
+
+        * public/v3/components/commit-log-viewer.js:
+        (CommitLogViewer):
+        (CommitLogViewer.prototype.currentRepository): Exit early when repository and the revision range are
+        identical to the one we already have to avoid repaints and issuing multiple network requests.
+        * public/v3/components/interactive-time-series-chart.js:
+        (InteractiveTimeSeriesChart.prototype._mouseMove): Don't invoke _notifyIndicatorChanged if the current
+        indicator hadn't changed.
+        * public/v3/pages/chart-pane.js:
+        (ChartPane.prototype._indicatorDidChange): Fixed the bug that unlocking the indicator wouldn't update
+        the URL. We need to check whether the lock state had changed. The old condition was also redundant
+        since _mainChartIndicatorWasLocked is always identically equal to isLocked per the prior assignment.
+
+2016-03-21  Ryosuke Niwa  <rniwa@webkit.org>
+
         Fix A/B testing after r198503.
 
         * public/include/build-requests-fetcher.php:
index 47ea457..0e9de05 100644 (file)
@@ -7,13 +7,21 @@ class CommitLogViewer extends ComponentBase {
         this._repository = null;
         this._fetchingPromise = null;
         this._commits = null;
+        this._from = null;
+        this._to = null;
     }
 
     currentRepository() { return this._repository; }
 
     view(repository, from, to)
     {
+        if (this._repository == repository && this._from == from && this._to == to)
+            return Promise.resolve(null);
+
         this._commits = null;
+        this._repository = repository;
+        this._from = from;
+        this._to = to;
 
         if (!repository) {
             this._fetchingPromise = null;
@@ -21,8 +29,6 @@ class CommitLogViewer extends ComponentBase {
             return Promise.resolve(null);
         }
 
-        this._repository = repository;
-
         if (!to) {
             this._fetchingPromise = null;
             this.render();
index 03103bd..7c06f7f 100644 (file)
@@ -175,13 +175,21 @@ class InteractiveTimeSeriesChart extends TimeSeriesChart {
 
         var oldIndicatorID = this._indicatorID;
 
-        this._currentAnnotation = this._findAnnotation(cursorLocation);
+        var newAnnotation = this._findAnnotation(cursorLocation);
+        var newIndicatorID = null;
         if (this._currentAnnotation)
-            this._indicatorID = null;
+            newIndicatorID = null;
         else
-            this._indicatorID = this._findClosestPoint(cursorLocation);
+            newIndicatorID = this._findClosestPoint(cursorLocation);
 
         this._forceRender = true;
+
+        if (this._currentAnnotation == newAnnotation && this._indicatorID == newIndicatorID)
+            return;
+
+        this._currentAnnotation = newAnnotation;
+        this._indicatorID = newIndicatorID;
+
         this._notifyIndicatorChanged();
     }
 
index a47cfa2..ba043f0 100644 (file)
@@ -82,8 +82,8 @@ class ChartPane extends ChartPaneBase {
 
     _indicatorDidChange(indicatorID, isLocked)
     {
+        this._chartsPage.mainChartIndicatorDidChange(this, isLocked != this._mainChartIndicatorWasLocked);
         this._mainChartIndicatorWasLocked = isLocked;
-        this._chartsPage.mainChartIndicatorDidChange(this, isLocked || this._mainChartIndicatorWasLocked);
         super._indicatorDidChange(indicatorID, isLocked);
     }