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

Side by Side Diff: Source/core/inspector/InspectorOverlayPage.html

Issue 1311783003: Devtools[LayoutEditor]: Rework layout-editor workflow (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@resize
Patch Set: Address comments 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 | « Source/core/inspector/InspectorOverlayHost.idl ('k') | Source/core/inspector/LayoutEditor.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 429 matching lines...) Expand 10 before | Expand all | Expand 10 after
440 window.canvasHeight = viewportSize.height; 440 window.canvasHeight = viewportSize.height;
441 441
442 window._controlsVisible = false; 442 window._controlsVisible = false;
443 document.querySelector(".controls-line").style.visibility = "hidden"; 443 document.querySelector(".controls-line").style.visibility = "hidden";
444 document.getElementById("element-title").style.visibility = "hidden"; 444 document.getElementById("element-title").style.visibility = "hidden";
445 document.getElementById("tooltip-container").classList.add("hidden"); 445 document.getElementById("tooltip-container").classList.add("hidden");
446 var editor = document.getElementById("editor"); 446 var editor = document.getElementById("editor");
447 editor.style.visibility = "hidden"; 447 editor.style.visibility = "hidden";
448 editor.textContent = ""; 448 editor.textContent = "";
449 document.body.classList.remove("dimmed"); 449 document.body.classList.remove("dimmed");
450 document.removeEventListener("mousemove", onGlobalMouseMove); 450 document.removeEventListener("mousedown", consumeEvent);
451 document.removeEventListener("mousemove", onLayoutEditorMouseMove);
452 document.removeEventListener("mouseup", consumeEvent);
453 document.removeEventListener("click", onLayoutEditorClick);
454 document.removeEventListener("keydown", onLayoutEditorKeyDown);
455
451 delete window.hoverableAreas; 456 delete window.hoverableAreas;
452 delete window.anchorsByType; 457 delete window.anchorsByType;
453 window._gridPainted = false; 458 window._gridPainted = false;
454 } 459 }
455 460
456 function _drawElementTitle(elementInfo, bounds) 461 function _drawElementTitle(elementInfo, bounds)
457 { 462 {
458 document.getElementById("tag-name").textContent = elementInfo.tagName; 463 document.getElementById("tag-name").textContent = elementInfo.tagName;
459 document.getElementById("node-id").textContent = elementInfo.idValue ? "#" + elementInfo.idValue : ""; 464 document.getElementById("node-id").textContent = elementInfo.idValue ? "#" + elementInfo.idValue : "";
460 var className = elementInfo.className; 465 var className = elementInfo.className;
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
803 anchorsByType.set(anchorInfo.type, []); 808 anchorsByType.set(anchorInfo.type, []);
804 anchorsByType.get(anchorInfo.type).push(anchorInfo); 809 anchorsByType.get(anchorInfo.type).push(anchorInfo);
805 editorElement.appendChild(createAnchor(anchorInfo)); 810 editorElement.appendChild(createAnchor(anchorInfo));
806 if (anchorInfo.propertyName === window.draggedPropertyName) 811 if (anchorInfo.propertyName === window.draggedPropertyName)
807 selectedAnchorInfo = anchorInfo; 812 selectedAnchorInfo = anchorInfo;
808 } 813 }
809 814
810 if (selectedAnchorInfo) 815 if (selectedAnchorInfo)
811 showLabels(selectedAnchorInfo.type, selectedAnchorInfo.propertyName); 816 showLabels(selectedAnchorInfo.type, selectedAnchorInfo.propertyName);
812 817
813 document.addEventListener("mousemove", onGlobalMouseMove); 818 document.addEventListener("mousedown", consumeEvent);
819 document.addEventListener("mousemove", onLayoutEditorMouseMove);
820 document.addEventListener("mouseup", consumeEvent);
821 document.addEventListener("click", onLayoutEditorClick);
822 document.addEventListener("keydown", onLayoutEditorKeyDown);
814 } 823 }
815 824
816 function createAnchor(anchorInfo) 825 function createAnchor(anchorInfo)
817 { 826 {
818 var handleWidth = 5; 827 var handleWidth = 5;
819 context.save(); 828 context.save();
820 context.shadowColor = "rgba(0, 0, 0, 0.34)"; 829 context.shadowColor = "rgba(0, 0, 0, 0.34)";
821 context.shadowBlur = 2; 830 context.shadowBlur = 2;
822 context.fillStyle = anchorColorForProperty(anchorInfo); 831 context.fillStyle = anchorColorForProperty(anchorInfo);
823 context.beginPath(); 832 context.beginPath();
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
1013 // TODO: find a better color 1022 // TODO: find a better color
1014 if (!anchorInfo.propertyValue.mutable) 1023 if (!anchorInfo.propertyValue.mutable)
1015 return "rgb(159, 188, 191)"; 1024 return "rgb(159, 188, 191)";
1016 1025
1017 var propertyName = anchorInfo.propertyName; 1026 var propertyName = anchorInfo.propertyName;
1018 if (propertyName.startsWith("margin")) 1027 if (propertyName.startsWith("margin"))
1019 return "rgb(246, 167, 35)"; 1028 return "rgb(246, 167, 35)";
1020 return "rgb(107, 213, 0)"; 1029 return "rgb(107, 213, 0)";
1021 } 1030 }
1022 1031
1023 function onGlobalMouseMove(event) 1032 function onLayoutEditorMouseMove(event)
1024 { 1033 {
1034 event.preventDefault();
1025 if (!window.hoverableAreas) 1035 if (!window.hoverableAreas)
1026 return; 1036 return;
1027 var types = ["padding", "margin"]; 1037 var types = ["padding", "margin"];
1028 for (var type of types) { 1038 for (var type of types) {
1029 var path = hoverableAreas.get(type); 1039 var path = hoverableAreas.get(type);
1030 if (path && context.isPointInPath(path, deviceScaleFactor * event.x, dev iceScaleFactor * event.y)) { 1040 if (path && context.isPointInPath(path, deviceScaleFactor * event.x, dev iceScaleFactor * event.y)) {
1031 showLabels(type); 1041 showLabels(type);
1032 break; 1042 return;
1033 } 1043 }
1034 } 1044 }
1045 resetLabelCanvas();
1046 }
1047
1048 function onLayoutEditorClick(event)
1049 {
1050 event.preventDefault();
1051 InspectorOverlayHost.clearSelection(true);
1052 }
1053
1054 function onLayoutEditorKeyDown(event)
1055 {
1056 if (window.draggedPropertyName)
1057 return;
1058
1059 // Clear selection on Esc.
1060 if (event.keyIdentifier === "U+001B") {
1061 event.preventDefault();
1062 InspectorOverlayHost.clearSelection(false);
1063 }
1035 } 1064 }
1036 1065
1066 function consumeEvent(event)
1067 {
1068 event.preventDefault();
1069 }
1070
1037 function resetLabelCanvas() 1071 function resetLabelCanvas()
1038 { 1072 {
1039 delete window.labelCanvasState; 1073 delete window.labelCanvasState;
1040 resetCanvas(labelsCanvas); 1074 resetCanvas(labelsCanvas);
1041 } 1075 }
1042 1076
1043 window.addEventListener("DOMContentLoaded", onLoaded); 1077 window.addEventListener("DOMContentLoaded", onLoaded);
1044 document.addEventListener("keydown", onDocumentKeyDown); 1078 document.addEventListener("keydown", onDocumentKeyDown);
1045 1079
1046 </script> 1080 </script>
(...skipping 13 matching lines...) Expand all
1060 </div> 1094 </div>
1061 <div id="tooltip-container" class="hidden"> 1095 <div id="tooltip-container" class="hidden">
1062 <div id="element-tooltip"> 1096 <div id="element-tooltip">
1063 <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> 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>
1064 <div id="dimensions"><span id="material-node-width"></span>&#xD7;<span id= "material-node-height"></span></div> 1098 <div id="dimensions"><span id="material-node-width"></span>&#xD7;<span id= "material-node-height"></span></div>
1065 </div> 1099 </div>
1066 <div id="element-tooltip-arrow"></div> 1100 <div id="element-tooltip-arrow"></div>
1067 <div id="editor" class="fill"></div> 1101 <div id="editor" class="fill"></div>
1068 <div id="log"></div> 1102 <div id="log"></div>
1069 </html> 1103 </html>
OLDNEW
« 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