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

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

Issue 1206833003: Devtools[LayoutEditor]: Pass data about property change from InspectorOverlayPage (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Address pfeldman's comment Created 5 years, 6 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 | « Source/core/inspector/InspectorOverlayHost.idl ('k') | Source/core/inspector/LayoutEditor.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 f075a7f2e7f45f68f3b405c76fbf80811fc0109d..9f790a7414214ae89a4ed134a8de9a9738b22a85 100644
--- a/Source/core/inspector/InspectorOverlayPage.html
+++ b/Source/core/inspector/InspectorOverlayPage.html
@@ -657,9 +657,53 @@ function createAnchor(anchorInfo)
anchorElement.className = "editor-anchor";
anchorElement.style.left = anchorInfo.x - handleWidth + "px";
anchorElement.style.top = anchorInfo.y - handleWidth + "px";
+ anchorElement.addEventListener("mousedown", onAnchorMouseDown.bind(null, anchorInfo));
return anchorElement;
}
+function calculateDelta(deltaVector, moveDelta)
+{
+ return (deltaVector.x * moveDelta.x + deltaVector.y * moveDelta.y) / Math.sqrt(deltaVector.x * deltaVector.x + deltaVector.y * deltaVector.y);
+}
+
+function onAnchorMouseDown(anchorInfo, event)
+{
+ // Only drag upon left button. Right will likely cause a context menu. So will ctrl-click on mac.
+ if (event.button || (window.platform == "mac" && event.ctrlKey))
+ return;
+
+ event.preventDefault();
+ window.boundDragMove = onDragMove.bind(null, new Point(event.screenX, event.screenY), anchorInfo.deltaVector);
+ document.addEventListener("mousemove", boundDragMove);
+ document.addEventListener("mouseup", onDragEnd);
+ InspectorOverlayHost.startPropertyChange(anchorInfo.propertyName);
+}
+
+function onDragMove(mouseDownPoint, deltaVector, event)
+{
+ if (event.buttons !== 1) {
+ onDragEnd(event);
+ return;
+ }
+ event.preventDefault();
+ InspectorOverlayHost.changeProperty(calculateDelta(deltaVector, new Point(event.screenX - mouseDownPoint.x, event.screenY - mouseDownPoint.y)));
+}
+
+function onDragEnd(event)
+{
+ document.removeEventListener("mousemove", boundDragMove);
+ delete window.boundDragMove;
+ document.removeEventListener("mouseup", onDragEnd);
+ event.preventDefault();
+ InspectorOverlayHost.endPropertyChange();
+}
+
+function Point(x, y)
+{
+ this.x = x;
+ this.y = y;
+}
+
window.addEventListener("DOMContentLoaded", onLoaded);
document.addEventListener("keydown", onDocumentKeyDown);
« no previous file with comments | « Source/core/inspector/InspectorOverlayHost.idl ('k') | Source/core/inspector/LayoutEditor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698