Title: [145894] trunk/Source/WebCore
- Revision
- 145894
- Author
- loi...@chromium.org
- Date
- 2013-03-15 03:46:10 -0700 (Fri, 15 Mar 2013)
Log Message
Web Inspector: Flame Chart. xOffset calculates incorrectly when chart width less that canvas.width.
https://bugs.webkit.org/show_bug.cgi?id=112423
Reviewed by Yury Semikhatsky.
I extracted xOffset assigment procedure into a separate function.
Drive by fix: size and posion of anchor element was adjusted.
Drive by fix: we will not paint item if it is not visible.
* inspector/front-end/FlameChart.js:
(WebInspector.FlameChart.prototype._maxXOffset):
(WebInspector.FlameChart.prototype._setXOffset):
(WebInspector.FlameChart.prototype._canvasDragging):
(WebInspector.FlameChart.prototype._onMouseMove):
(WebInspector.FlameChart.prototype._adjustXOffset):
(WebInspector.FlameChart.prototype._adjustXScale):
(WebInspector.FlameChart.prototype.draw):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (145893 => 145894)
--- trunk/Source/WebCore/ChangeLog 2013-03-15 10:40:29 UTC (rev 145893)
+++ trunk/Source/WebCore/ChangeLog 2013-03-15 10:46:10 UTC (rev 145894)
@@ -1,3 +1,24 @@
+2013-03-15 Ilya Tikhonovsky <loi...@chromium.org>
+
+ Web Inspector: Flame Chart. xOffset calculates incorrectly when chart width less that canvas.width.
+ https://bugs.webkit.org/show_bug.cgi?id=112423
+
+ Reviewed by Yury Semikhatsky.
+
+ I extracted xOffset assigment procedure into a separate function.
+
+ Drive by fix: size and posion of anchor element was adjusted.
+ Drive by fix: we will not paint item if it is not visible.
+
+ * inspector/front-end/FlameChart.js:
+ (WebInspector.FlameChart.prototype._maxXOffset):
+ (WebInspector.FlameChart.prototype._setXOffset):
+ (WebInspector.FlameChart.prototype._canvasDragging):
+ (WebInspector.FlameChart.prototype._onMouseMove):
+ (WebInspector.FlameChart.prototype._adjustXOffset):
+ (WebInspector.FlameChart.prototype._adjustXScale):
+ (WebInspector.FlameChart.prototype.draw):
+
2013-03-15 Noam Rosenthal <n...@webkit.org>
[Texmap] Change brightness filter to match new spec
Modified: trunk/Source/WebCore/inspector/front-end/FlameChart.js (145893 => 145894)
--- trunk/Source/WebCore/inspector/front-end/FlameChart.js 2013-03-15 10:40:29 UTC (rev 145893)
+++ trunk/Source/WebCore/inspector/front-end/FlameChart.js 2013-03-15 10:46:10 UTC (rev 145894)
@@ -74,20 +74,29 @@
return true;
},
- _canvasDragging: function(event)
+ _maxXOffset: function()
{
- this._xOffset = this._dragStartXOffset + this._dragStartPoint - event.pageX;
+ if (!this._timelineData)
+ return 0;
+ var maxXOffset = Math.floor(this._timelineData.totalTime * this._xScaleFactor - this._canvas.width);
+ return maxXOffset > 0 ? maxXOffset : 0;
+ },
- 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;
+ _setXOffset: function(xOffset)
+ {
+ xOffset = Number.constrain(xOffset, 0, this._maxXOffset());
+
+ if (xOffset !== this._xOffset) {
+ this._xOffset = xOffset;
+ this._scheduleUpdate();
}
- this._scheduleUpdate();
},
+ _canvasDragging: function(event)
+ {
+ this._setXOffset(this._dragStartXOffset + this._dragStartPoint - event.pageX);
+ },
+
_endCanvasDragging: function()
{
this._isDragging = false;
@@ -240,39 +249,35 @@
var timelineData = this._timelineData;
+ var anchorLeft = Math.floor(timelineData.startTimes[nodeIndex] * this._xScaleFactor - this._xOffset);
+ anchorLeft = Number.constrain(anchorLeft, 0, this._canvas.width);
+
+ var anchorWidth = Math.floor(timelineData.durations[nodeIndex] * this._xScaleFactor);
+ anchorWidth = Number.constrain(anchorWidth, 0, this._canvas.width - anchorLeft);
+
var style = this._anchorElement.style;
- style.width = Math.floor(timelineData.durations[nodeIndex] * this._xScaleFactor) + "px";
+ style.width = anchorWidth + "px";
style.height = this._barHeight + "px";
- style.left = Math.floor(timelineData.startTimes[nodeIndex] * this._xScaleFactor - this._xOffset) + "px";
+ style.left = anchorLeft + "px";
style.top = Math.floor(this._canvas.height - (timelineData.depths[nodeIndex] + 1) * this._barHeight) + "px";
},
_adjustXOffset: function(direction)
{
var step = this._xScaleFactor * 5;
- this._xOffset += direction > 0 ? step : -step;
- if (this._xOffset < 0)
- this._xOffset = 0;
+ this._setXOffset(this._xOffset + (direction > 0 ? step : -step));
},
_adjustXScale: function(direction, x)
{
var cursorTime = (x + this._xOffset) / this._xScaleFactor;
+
if (direction > 0)
this._xScaleFactor /= 2;
else
this._xScaleFactor *= 2;
- var absoluteX = Math.floor(cursorTime * this._xScaleFactor);
- var rightEndOfViewPort = absoluteX - x + this._canvas.width;
-
- var rightEndOfGraph = Math.floor(this._timelineData.totalTime * this._xScaleFactor);
- if (rightEndOfViewPort > rightEndOfGraph)
- rightEndOfViewPort = rightEndOfGraph;
-
- this._xOffset = rightEndOfViewPort - this._canvas.width;
- if (this._xOffset < 0)
- this._xOffset = 0;
+ this._setXOffset(Math.floor(cursorTime * this._xScaleFactor - x));
},
_onMouseWheel: function(e)
@@ -337,6 +342,8 @@
break;
var y = height - (timelineData.depths[i] + 1) * barHeight;
var barWidth = Math.floor(timelineData.durations[i] * xScaleFactor);
+ if (x + barWidth < 0)
+ continue;
if (barWidth < this._minWidth)
continue;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes