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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « no previous file | Source/web/ChromeClientImpl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 <!-- 1 <!--
2 Copyright (C) 2012 Google Inc. All rights reserved. 2 Copyright (C) 2012 Google Inc. All rights reserved.
3 3
4 Redistribution and use in source and binary forms, with or without 4 Redistribution and use in source and binary forms, with or without
5 modification, are permitted provided that the following conditions 5 modification, are permitted provided that the following conditions
6 are met: 6 are met:
7 7
8 1. Redistributions of source code must retain the above copyright 8 1. Redistributions of source code must retain the above copyright
9 notice, this list of conditions and the following disclaimer. 9 notice, this list of conditions and the following disclaimer.
10 2. Redistributions in binary form must reproduce the above copyright 10 2. Redistributions in binary form must reproduce the above copyright
(...skipping 828 matching lines...) Expand 10 before | Expand all | Expand 10 after
839 anchorElement.style.left = anchorInfo.x - handleWidth + "px"; 839 anchorElement.style.left = anchorInfo.x - handleWidth + "px";
840 anchorElement.style.top = anchorInfo.y - handleWidth + "px"; 840 anchorElement.style.top = anchorInfo.y - handleWidth + "px";
841 if (anchorInfo.propertyValue.mutable) 841 if (anchorInfo.propertyValue.mutable)
842 anchorElement.addEventListener("mousedown", onAnchorMouseDown.bind(null, anchorInfo)); 842 anchorElement.addEventListener("mousedown", onAnchorMouseDown.bind(null, anchorInfo));
843 anchorElement.addEventListener("mousemove", onAnchorMouseMove.bind(null, anc horInfo)); 843 anchorElement.addEventListener("mousemove", onAnchorMouseMove.bind(null, anc horInfo));
844 return anchorElement; 844 return anchorElement;
845 } 845 }
846 846
847 function calculateDelta(deltaVector, moveDelta) 847 function calculateDelta(deltaVector, moveDelta)
848 { 848 {
849 return (deltaVector.x * moveDelta.x + deltaVector.y * moveDelta.y) / Math.sq rt(deltaVector.x * deltaVector.x + deltaVector.y * deltaVector.y); 849 return scalarProduct(deltaVector, moveDelta) / Math.sqrt(scalarProduct(delta Vector, deltaVector));
850 } 850 }
851 851
852 function onAnchorMouseDown(anchorInfo, event) 852 function onAnchorMouseDown(anchorInfo, event)
853 { 853 {
854 // Only drag upon left button. Right will likely cause a context menu. So wi ll ctrl-click on mac. 854 // Only drag upon left button. Right will likely cause a context menu. So wi ll ctrl-click on mac.
855 if (event.button || (window.platform == "mac" && event.ctrlKey)) 855 if (event.button || (window.platform == "mac" && event.ctrlKey))
856 return; 856 return;
857 857
858 event.preventDefault(); 858 event.preventDefault();
859 window.boundDragMove = onDragMove.bind(null, new Point(event.screenX, event. screenY), anchorInfo.deltaVector); 859 window.boundDragMove = onDragMove.bind(null, new Point(event.screenX, event. screenY), anchorInfo.deltaVector);
860 document.addEventListener("mousemove", boundDragMove); 860 document.addEventListener("mousemove", boundDragMove);
861 document.addEventListener("mouseup", onDragEnd); 861 document.addEventListener("mouseup", onDragEnd);
862 InspectorOverlayHost.startPropertyChange(anchorInfo.propertyName); 862 InspectorOverlayHost.startPropertyChange(anchorInfo.propertyName);
863 window.draggedPropertyName = anchorInfo.propertyName; 863 window.draggedPropertyName = anchorInfo.propertyName;
864 showLabels(anchorInfo.type, anchorInfo.propertyName); 864 showLabels(anchorInfo.type, anchorInfo.propertyName);
865 } 865 }
866 866
867 function onDragMove(mouseDownPoint, deltaVector, event) 867 function onDragMove(mouseDownPoint, deltaVector, event)
868 { 868 {
869 if (event.buttons !== 1) { 869 if (event.buttons !== 1) {
870 onDragEnd(event); 870 onDragEnd(event);
871 return; 871 return;
872 } 872 }
873 event.preventDefault(); 873 event.preventDefault();
874 InspectorOverlayHost.changeProperty(calculateDelta(deltaVector, new Point(ev ent.screenX - mouseDownPoint.x, event.screenY - mouseDownPoint.y))); 874 InspectorOverlayHost.changeProperty(calculateDelta(deltaVector, new Point(ev ent.screenX - mouseDownPoint.x, event.screenY - mouseDownPoint.y)));
875 } 875 }
876 876
877 function onDragEnd(event)
878 {
879 document.removeEventListener("mousemove", boundDragMove);
880 delete window.boundDragMove;
881 delete window.draggedPropertyName;
882 document.removeEventListener("mouseup", onDragEnd);
883 event.preventDefault();
884 InspectorOverlayHost.endPropertyChange();
885 resetLabelCanvas();
886 }
887
877 function showLabel(anchorInfo, showLongDescription) 888 function showLabel(anchorInfo, showLongDescription)
878 { 889 {
879 var context = labelsCanvas.getContext("2d"); 890 var context = labelsCanvas.getContext("2d");
880 var secondaryColor = "rgba(255, 255, 255, 0.7)"; 891 var secondaryColor = "rgba(255, 255, 255, 0.7)";
881 var labelColor = labelColorForProperty(anchorInfo); 892 var labelColor = labelColorForProperty(anchorInfo);
882 var textDescription = [ 893 var textDescription = [
883 {string: String(parseFloat(anchorInfo.propertyValue.value.toFixed(2))), color: "white" }, 894 {string: String(parseFloat(anchorInfo.propertyValue.value.toFixed(2))), color: "white" },
884 {string: "\u2009" + anchorInfo.propertyValue.unit, color: secondaryColor } 895 {string: "\u2009" + anchorInfo.propertyValue.unit, color: secondaryColor }
885 ]; 896 ];
886 897
(...skipping 14 matching lines...) Expand all
901 window.labelCanvasState = {type: type, fullLabelName: fullLabelName}; 912 window.labelCanvasState = {type: type, fullLabelName: fullLabelName};
902 var anchors = anchorsByType.get(type) || []; 913 var anchors = anchorsByType.get(type) || [];
903 var selectedAnchorInfo = null; 914 var selectedAnchorInfo = null;
904 for (var anchorInfo of anchors) { 915 for (var anchorInfo of anchors) {
905 if (fullLabelName !== anchorInfo.propertyName) 916 if (fullLabelName !== anchorInfo.propertyName)
906 showLabel(anchorInfo, false); 917 showLabel(anchorInfo, false);
907 else 918 else
908 selectedAnchorInfo = anchorInfo; 919 selectedAnchorInfo = anchorInfo;
909 } 920 }
910 921
911 if (selectedAnchorInfo) 922 if (!selectedAnchorInfo)
912 showLabel(selectedAnchorInfo, true); 923 return;
913 }
914 924
915 function onDragEnd(event) 925 showLabel(selectedAnchorInfo, true);
916 { 926 document.body.style.cursor = chooseAnchorPointer(selectedAnchorInfo.deltaVec tor);
917 document.removeEventListener("mousemove", boundDragMove);
918 delete window.boundDragMove;
919 delete window.draggedPropertyName;
920 document.removeEventListener("mouseup", onDragEnd);
921 event.preventDefault();
922 InspectorOverlayHost.endPropertyChange();
923 resetLabelCanvas();
924 } 927 }
925 928
926 function onAnchorMouseMove(anchorInfo) 929 function onAnchorMouseMove(anchorInfo)
927 { 930 {
928 if (window.draggedPropertyName) 931 if (window.draggedPropertyName)
929 return; 932 return;
930 event.preventDefault(); 933 event.preventDefault();
931 event.stopPropagation(); 934 event.stopPropagation();
932 showLabels(anchorInfo.type, anchorInfo.propertyName); 935 showLabels(anchorInfo.type, anchorInfo.propertyName);
933 } 936 }
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
1065 1068
1066 function consumeEvent(event) 1069 function consumeEvent(event)
1067 { 1070 {
1068 event.preventDefault(); 1071 event.preventDefault();
1069 } 1072 }
1070 1073
1071 function resetLabelCanvas() 1074 function resetLabelCanvas()
1072 { 1075 {
1073 delete window.labelCanvasState; 1076 delete window.labelCanvasState;
1074 resetCanvas(labelsCanvas); 1077 resetCanvas(labelsCanvas);
1078 if (!window.draggedPropertyName && document.body.style.cursor)
1079 document.body.style.cursor = "";
1080 }
1081
1082 function scalarProduct(v1, v2)
1083 {
1084 return v1.x * v2.x + v1.y * v2.y;
1085 }
1086
1087 var pointers = [ {name: "ns-resize", vector: new Point(0, -1)}, {name: "ew-resiz e", vector: new Point(-1, 0)},
1088 {name: "ns-resize", vector: new Point(0, 1)}, {name: "ew-resize", vector: ne w Point(1, 0)}];
1089
1090 function chooseAnchorPointer(direction)
1091 {
1092 var maxValue = scalarProduct(direction, pointers[0].vector);
1093 var maxIndex = 0;
1094 for (var i = 1; i < pointers.length; ++i) {
1095 var currentValue = scalarProduct(direction, pointers[i].vector);
1096 if (currentValue > maxValue) {
1097 maxValue = currentValue;
1098 maxIndex = i;
1099 }
1100 }
1101 return pointers[maxIndex].name;
1075 } 1102 }
1076 1103
1077 window.addEventListener("DOMContentLoaded", onLoaded); 1104 window.addEventListener("DOMContentLoaded", onLoaded);
1078 document.addEventListener("keydown", onDocumentKeyDown); 1105 document.addEventListener("keydown", onDocumentKeyDown);
1079 1106
1080 </script> 1107 </script>
1081 </head> 1108 </head>
1082 <body class="fill"> 1109 <body class="fill">
1083 <div class="controls-line"> 1110 <div class="controls-line">
1084 <div class="message-box"><div id="paused-in-debugger"></div></div> 1111 <div class="message-box"><div id="paused-in-debugger"></div></div>
1085 <div class="button" id="resume-button" title="Resume script execution (F8)." ><div class="glyph"></div></div> 1112 <div class="button" id="resume-button" title="Resume script execution (F8)." ><div class="glyph"></div></div>
1086 <div class="button" id="step-over-button" title="Step over next function cal l (F10)."><div class="glyph"></div></div> 1113 <div class="button" id="step-over-button" title="Step over next function cal l (F10)."><div class="glyph"></div></div>
1087 </div> 1114 </div>
1088 </body> 1115 </body>
1089 <canvas id="canvas" class="fill"></canvas> 1116 <canvas id="canvas" class="fill"></canvas>
1090 <canvas id="labels-canvas" class="fill"></canvas> 1117 <canvas id="labels-canvas" class="fill"></canvas>
1091 <div id="element-title"> 1118 <div id="element-title">
1092 <span id="tag-name"></span><span id="node-id"></span><span id="class-name"></s pan> 1119 <span id="tag-name"></span><span id="node-id"></span><span id="class-name"></s pan>
1093 <span id="node-width"></span><span class="px">px</span><span class="px"> &#xD7 ; </span><span id="node-height"></span><span class="px">px</span> 1120 <span id="node-width"></span><span class="px">px</span><span class="px"> &#xD7 ; </span><span id="node-height"></span><span class="px">px</span>
1094 </div> 1121 </div>
1095 <div id="tooltip-container" class="hidden"> 1122 <div id="tooltip-container" class="hidden">
1096 <div id="element-tooltip"> 1123 <div id="element-tooltip">
1097 <div id="element-description" class="monospace"><span id="material-tag-nam e"></span><span id="material-node-id"></span><span id="material-class-name"></sp an></div> 1124 <div id="element-description" class="monospace"><span id="material-tag-nam e"></span><span id="material-node-id"></span><span id="material-class-name"></sp an></div>
1098 <div id="dimensions"><span id="material-node-width"></span>&#xD7;<span id= "material-node-height"></span></div> 1125 <div id="dimensions"><span id="material-node-width"></span>&#xD7;<span id= "material-node-height"></span></div>
1099 </div> 1126 </div>
1100 <div id="element-tooltip-arrow"></div> 1127 <div id="element-tooltip-arrow"></div>
1101 <div id="editor" class="fill"></div> 1128 <div id="editor" class="fill"></div>
1102 <div id="log"></div> 1129 <div id="log"></div>
1103 </html> 1130 </html>
OLDNEW
« 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