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

Unified Diff: Source/core/inspector/InspectorOverlayPage.html

Issue 1310533007: Devtools[LayoutEditor]: show resizer cursor over anchors (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase Created 5 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | Source/web/ChromeClientImpl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/inspector/InspectorOverlayPage.html
diff --git a/Source/core/inspector/InspectorOverlayPage.html b/Source/core/inspector/InspectorOverlayPage.html
index 1ffa734b05b15182925ff12e3e58e639d2167124..1d6f0efb00d3b5b3c042836bb2559efc3f445f09 100644
--- a/Source/core/inspector/InspectorOverlayPage.html
+++ b/Source/core/inspector/InspectorOverlayPage.html
@@ -846,7 +846,7 @@ function createAnchor(anchorInfo)
function calculateDelta(deltaVector, moveDelta)
{
- return (deltaVector.x * moveDelta.x + deltaVector.y * moveDelta.y) / Math.sqrt(deltaVector.x * deltaVector.x + deltaVector.y * deltaVector.y);
+ return scalarProduct(deltaVector, moveDelta) / Math.sqrt(scalarProduct(deltaVector, deltaVector));
}
function onAnchorMouseDown(anchorInfo, event)
@@ -874,6 +874,17 @@ function onDragMove(mouseDownPoint, deltaVector, event)
InspectorOverlayHost.changeProperty(calculateDelta(deltaVector, new Point(event.screenX - mouseDownPoint.x, event.screenY - mouseDownPoint.y)));
}
+function onDragEnd(event)
+{
+ document.removeEventListener("mousemove", boundDragMove);
+ delete window.boundDragMove;
+ delete window.draggedPropertyName;
+ document.removeEventListener("mouseup", onDragEnd);
+ event.preventDefault();
+ InspectorOverlayHost.endPropertyChange();
+ resetLabelCanvas();
+}
+
function showLabel(anchorInfo, showLongDescription)
{
var context = labelsCanvas.getContext("2d");
@@ -908,19 +919,11 @@ function showLabels(type, fullLabelName)
selectedAnchorInfo = anchorInfo;
}
- if (selectedAnchorInfo)
- showLabel(selectedAnchorInfo, true);
-}
+ if (!selectedAnchorInfo)
+ return;
-function onDragEnd(event)
-{
- document.removeEventListener("mousemove", boundDragMove);
- delete window.boundDragMove;
- delete window.draggedPropertyName;
- document.removeEventListener("mouseup", onDragEnd);
- event.preventDefault();
- InspectorOverlayHost.endPropertyChange();
- resetLabelCanvas();
+ showLabel(selectedAnchorInfo, true);
+ document.body.style.cursor = chooseAnchorPointer(selectedAnchorInfo.deltaVector);
}
function onAnchorMouseMove(anchorInfo)
@@ -1072,6 +1075,30 @@ function resetLabelCanvas()
{
delete window.labelCanvasState;
resetCanvas(labelsCanvas);
+ if (!window.draggedPropertyName && document.body.style.cursor)
+ document.body.style.cursor = "";
+}
+
+function scalarProduct(v1, v2)
+{
+ return v1.x * v2.x + v1.y * v2.y;
+}
+
+var pointers = [ {name: "ns-resize", vector: new Point(0, -1)}, {name: "ew-resize", vector: new Point(-1, 0)},
+ {name: "ns-resize", vector: new Point(0, 1)}, {name: "ew-resize", vector: new Point(1, 0)}];
+
+function chooseAnchorPointer(direction)
+{
+ var maxValue = scalarProduct(direction, pointers[0].vector);
+ var maxIndex = 0;
+ for (var i = 1; i < pointers.length; ++i) {
+ var currentValue = scalarProduct(direction, pointers[i].vector);
+ if (currentValue > maxValue) {
+ maxValue = currentValue;
+ maxIndex = i;
+ }
+ }
+ return pointers[maxIndex].name;
}
window.addEventListener("DOMContentLoaded", onLoaded);
« no previous file with comments | « no previous file | Source/web/ChromeClientImpl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698