Title: [145874] trunk/Source/WebCore
Revision
145874
Author
loi...@chromium.org
Date
2013-03-14 22:26:33 -0700 (Thu, 14 Mar 2013)

Log Message

Web Inspector: Flame Chart. Support scrolling by dragging.
https://bugs.webkit.org/show_bug.cgi?id=112346

Reviewed by Yury Semikhatsky.

Drag hander was added. It seems that simple repaint works well.
When the user starts dragging we hide the popover, change offset
and do update for the new canvas image.
Drive by change: Due to new way of scrolling the canvas I changed
the behaiviour of the wheel events. Now wheel scrolls if Shift key pressed
and zooms if not.

* inspector/front-end/FlameChart.js:
(WebInspector.FlameChart):
(WebInspector.FlameChart.prototype._startCanvasDragging):
(WebInspector.FlameChart.prototype._canvasDragging):
(WebInspector.FlameChart.prototype._endCanvasDragging):
(WebInspector.FlameChart.prototype._onMouseWheel):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (145873 => 145874)


--- trunk/Source/WebCore/ChangeLog	2013-03-15 05:14:28 UTC (rev 145873)
+++ trunk/Source/WebCore/ChangeLog	2013-03-15 05:26:33 UTC (rev 145874)
@@ -1,3 +1,24 @@
+2013-03-14  Ilya Tikhonovsky  <loi...@chromium.org>
+
+        Web Inspector: Flame Chart. Support scrolling by dragging.
+        https://bugs.webkit.org/show_bug.cgi?id=112346
+
+        Reviewed by Yury Semikhatsky.
+
+        Drag hander was added. It seems that simple repaint works well.
+        When the user starts dragging we hide the popover, change offset
+        and do update for the new canvas image.
+        Drive by change: Due to new way of scrolling the canvas I changed
+        the behaiviour of the wheel events. Now wheel scrolls if Shift key pressed
+        and zooms if not.
+
+        * inspector/front-end/FlameChart.js:
+        (WebInspector.FlameChart):
+        (WebInspector.FlameChart.prototype._startCanvasDragging):
+        (WebInspector.FlameChart.prototype._canvasDragging):
+        (WebInspector.FlameChart.prototype._endCanvasDragging):
+        (WebInspector.FlameChart.prototype._onMouseWheel):
+
 2013-03-14  Hayato Ito  <hay...@chromium.org>
 
         [Shadow Dom]: Non Bubbling events in ShadowDOM dispatch in an incorrect order

Modified: trunk/Source/WebCore/inspector/front-end/FlameChart.js (145873 => 145874)


--- trunk/Source/WebCore/inspector/front-end/FlameChart.js	2013-03-15 05:14:28 UTC (rev 145873)
+++ trunk/Source/WebCore/inspector/front-end/FlameChart.js	2013-03-15 05:26:33 UTC (rev 145874)
@@ -40,6 +40,8 @@
 
     this.element.className = "flame-chart";
     this._canvas = this.element.createChild("canvas");
+    WebInspector.installDragHandle(this._canvas, this._startCanvasDragging.bind(this), this._canvasDragging.bind(this), this._endCanvasDragging.bind(this), "col-resize");
+
     this._cpuProfileView = cpuProfileView;
     this._xScaleFactor = 4.0;
     this._xOffset = 0;
@@ -61,6 +63,36 @@
 }
 
 WebInspector.FlameChart.prototype = {
+    _startCanvasDragging: function(event)
+    {
+        if (!this._timelineData)
+            return false;
+        this._isDragging = true;
+        this._dragStartPoint = event.pageX;
+        this._dragStartXOffset = this._xOffset;
+        this._hidePopover();
+        return true;
+    },
+
+    _canvasDragging: function(event)
+    {
+        this._xOffset = this._dragStartXOffset + this._dragStartPoint - event.pageX;
+
+        if (this._xOffset < 0)
+            this._xOffset = 0;
+        else {
+            var maxXOffset = this._timelineData.totalTime * this._xScaleFactor - this._canvas.width;
+            if (this._xOffset > maxXOffset)
+                this._xOffset = maxXOffset;
+        }
+        this._scheduleUpdate();
+    },
+
+    _endCanvasDragging: function()
+    {
+        this._isDragging = false;
+    },
+
     _nodeCount: function()
     {
         var nodes = this._cpuProfileView.profileHead.children.slice();
@@ -154,14 +186,18 @@
 
     _getPopoverAnchor: function()
     {
-        if (this._highlightedNodeIndex === -1)
+        if (this._highlightedNodeIndex === -1 || this._isDragging)
             return null;
         return this._anchorElement;
     },
 
     _showPopover: function(anchor, popover)
     {
+        if (this._isDragging)
+            return;
         var node = this._timelineData.nodes[this._highlightedNodeIndex];
+        if (!node)
+            return;
         var contentHelper = new WebInspector.PopoverContentHelper(node.functionName);
         contentHelper.appendTextRow(WebInspector.UIString("Total time"), Number.secondsToString(node.totalTime / 1000, true));
         contentHelper.appendTextRow(WebInspector.UIString("Self time"), Number.secondsToString(node.selfTime / 1000, true));
@@ -191,6 +227,8 @@
 
     _onMouseMove: function(e)
     {
+        if (this._isDragging)
+            return;
         var nodeIndex = this._coordinatesToNodeIndex(e.offsetX, e.offsetY);
         if (nodeIndex === this._highlightedNodeIndex)
             return;
@@ -227,7 +265,7 @@
 
     _onMouseWheel: function(e)
     {
-        if (e.shiftKey)
+        if (!e.shiftKey)
             this._adjustXScale(e.wheelDelta, e.x);
         else
             this._adjustXOffset(e.wheelDelta);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to