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

Side by Side Diff: Source/devtools/front_end/ui_lazy/OverviewGrid.js

Issue 1183483011: DevTools: Support popover on timeline overview. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 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 are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * 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 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 18 matching lines...) Expand all
29 */ 29 */
30 30
31 /** 31 /**
32 * @constructor 32 * @constructor
33 * @param {string} prefix 33 * @param {string} prefix
34 */ 34 */
35 WebInspector.OverviewGrid = function(prefix) 35 WebInspector.OverviewGrid = function(prefix)
36 { 36 {
37 this.element = createElement("div"); 37 this.element = createElement("div");
38 this.element.id = prefix + "-overview-container"; 38 this.element.id = prefix + "-overview-container";
39 this._enabled = false;
caseq 2015/06/16 14:14:49 What is not enabled here?
alph 2015/06/17 09:17:08 The cursor. Renamed.
39 40
40 this._grid = new WebInspector.TimelineGrid(); 41 this._grid = new WebInspector.TimelineGrid();
41 this._grid.element.id = prefix + "-overview-grid"; 42 this._grid.element.id = prefix + "-overview-grid";
42 this._grid.setScrollTop(0); 43 this._grid.setScrollTop(0);
43
44 this.element.appendChild(this._grid.element); 44 this.element.appendChild(this._grid.element);
45 45
46 this._window = new WebInspector.OverviewGrid.Window(this.element, this._grid .dividersLabelBarElement); 46 this._window = new WebInspector.OverviewGrid.Window(this.element, this._grid .dividersLabelBarElement);
47
48 this._currentPositionElement = this.element.createChild("div", "overview-gri d-current-position");
49 this.element.addEventListener("mousemove", this._onMouseMove.bind(this), tru e);
50 this.element.addEventListener("mouseout", this._hideCurrentPosition.bind(thi s), true);
47 } 51 }
48 52
49 WebInspector.OverviewGrid.prototype = { 53 WebInspector.OverviewGrid.prototype = {
50 /** 54 /**
55 * @return {!Element}
56 */
57 cursorElement: function()
caseq 2015/06/16 14:14:49 This looks like a weird interface.
alph 2015/06/17 09:17:08 Changed.
58 {
59 return this._currentPositionElement;
60 },
61
62 _hideCurrentPosition: function()
63 {
64 this._currentPositionElement.style.visibility = "hidden";
65 },
66
67 /**
68 * @param {!Event} event
69 */
70 _onMouseMove: function(event)
71 {
72 if (!this._enabled)
73 return;
74 var x = event.offsetX + event.target.offsetLeft;
75 this._currentPositionElement.style.left = x + "px";
76 this._currentPositionElement.style.visibility = "visible";
77 },
78
79 /**
51 * @return {number} 80 * @return {number}
52 */ 81 */
53 clientWidth: function() 82 clientWidth: function()
54 { 83 {
55 return this.element.clientWidth; 84 return this.element.clientWidth;
56 }, 85 },
57 86
58 /** 87 /**
59 * @param {!WebInspector.TimelineGrid.Calculator} calculator 88 * @param {!WebInspector.TimelineGrid.Calculator} calculator
60 */ 89 */
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 { 153 {
125 this._window._zoom(zoomFactor, referencePoint); 154 this._window._zoom(zoomFactor, referencePoint);
126 }, 155 },
127 156
128 /** 157 /**
129 * @param {boolean} enabled 158 * @param {boolean} enabled
130 */ 159 */
131 setResizeEnabled: function(enabled) 160 setResizeEnabled: function(enabled)
132 { 161 {
133 this._window.setEnabled(!!enabled); 162 this._window.setEnabled(!!enabled);
163 this._enabled = !!enabled;
caseq 2015/06/16 14:14:49 nit: we don't coerce to boolean parameters that ar
alph 2015/06/17 09:17:08 Done.
164 this._hideCurrentPosition();
134 } 165 }
135 } 166 }
136 167
137 168
138 WebInspector.OverviewGrid.MinSelectableSize = 14; 169 WebInspector.OverviewGrid.MinSelectableSize = 14;
139 170
140 WebInspector.OverviewGrid.WindowScrollSpeedFactor = .3; 171 WebInspector.OverviewGrid.WindowScrollSpeedFactor = .3;
141 172
142 WebInspector.OverviewGrid.ResizerOffset = 3.5; // half pixel because offset valu es are not rounded but ceiled 173 WebInspector.OverviewGrid.ResizerOffset = 3.5; // half pixel because offset valu es are not rounded but ceiled
143 174
(...skipping 15 matching lines...) Expand all
159 this.windowRight = 1.0; 190 this.windowRight = 1.0;
160 191
161 this._parentElement.addEventListener("mousewheel", this._onMouseWheel.bind(t his), true); 192 this._parentElement.addEventListener("mousewheel", this._onMouseWheel.bind(t his), true);
162 this._parentElement.addEventListener("dblclick", this._resizeWindowMaximum.b ind(this), true); 193 this._parentElement.addEventListener("dblclick", this._resizeWindowMaximum.b ind(this), true);
163 194
164 this._overviewWindowElement = parentElement.createChild("div", "overview-gri d-window"); 195 this._overviewWindowElement = parentElement.createChild("div", "overview-gri d-window");
165 this._overviewWindowElement.appendChild(WebInspector.Widget.createStyleEleme nt("ui_lazy/overviewGrid.css")); 196 this._overviewWindowElement.appendChild(WebInspector.Widget.createStyleEleme nt("ui_lazy/overviewGrid.css"));
166 this._overviewWindowBordersElement = parentElement.createChild("div", "overv iew-grid-window-rulers"); 197 this._overviewWindowBordersElement = parentElement.createChild("div", "overv iew-grid-window-rulers");
167 parentElement.createChild("div", "overview-grid-dividers-background"); 198 parentElement.createChild("div", "overview-grid-dividers-background");
168 199
169 this._currentPositionElement = parentElement.createChild("div", "overview-gr id-current-position");
170 this._currentPositionArea = parentElement.createChild("div", "overview-grid- window-area");
171 this._currentPositionArea.addEventListener("mousemove", this._onMouseMove.bi nd(this), true);
caseq 2015/06/16 14:14:49 So how does this work for code that directly uses
alph 2015/06/17 09:17:09 What code? Anyway moved the cursor stuff to Timeli
172 this._currentPositionArea.addEventListener("mouseout", this._hideCurrentPosi tion.bind(this), true);
173
174 this._leftResizeElement = parentElement.createChild("div", "overview-grid-wi ndow-resizer"); 200 this._leftResizeElement = parentElement.createChild("div", "overview-grid-wi ndow-resizer");
175 this._leftResizeElement.style.left = 0; 201 this._leftResizeElement.style.left = 0;
176 WebInspector.installDragHandle(this._leftResizeElement, this._resizerElement StartDragging.bind(this), this._leftResizeElementDragging.bind(this), null, "ew- resize"); 202 WebInspector.installDragHandle(this._leftResizeElement, this._resizerElement StartDragging.bind(this), this._leftResizeElementDragging.bind(this), null, "ew- resize");
177 203
178 this._rightResizeElement = parentElement.createChild("div", "overview-grid-w indow-resizer overview-grid-window-resizer-right"); 204 this._rightResizeElement = parentElement.createChild("div", "overview-grid-w indow-resizer overview-grid-window-resizer-right");
179 this._rightResizeElement.style.right = 0; 205 this._rightResizeElement.style.right = 0;
180 WebInspector.installDragHandle(this._rightResizeElement, this._resizerElemen tStartDragging.bind(this), this._rightResizeElementDragging.bind(this), null, "e w-resize"); 206 WebInspector.installDragHandle(this._rightResizeElement, this._resizerElemen tStartDragging.bind(this), this._rightResizeElementDragging.bind(this), null, "e w-resize");
181 this.setEnabled(true); 207 this.setEnabled(true);
182 } 208 }
183 209
(...skipping 15 matching lines...) Expand all
199 this._leftResizeElement.style.left = "0%"; 225 this._leftResizeElement.style.left = "0%";
200 this._rightResizeElement.style.left = "100%"; 226 this._rightResizeElement.style.left = "100%";
201 this.setEnabled(true); 227 this.setEnabled(true);
202 }, 228 },
203 229
204 /** 230 /**
205 * @param {boolean} enabled 231 * @param {boolean} enabled
206 */ 232 */
207 setEnabled: function(enabled) 233 setEnabled: function(enabled)
208 { 234 {
209 enabled = !!enabled; 235 this._enabled = !!enabled;
caseq 2015/06/16 14:14:50 nit: drop !!, we don't coerce to boolean whatever
alph 2015/06/17 09:17:08 Done.
210 if (this._enabled === enabled)
211 return;
212 this._enabled = enabled;
213 this._currentPositionArea.style.cursor = enabled ? "text" : "";
214 if (!enabled)
215 this._hideCurrentPosition();
216 },
217
218 _hideCurrentPosition: function()
219 {
220 this._currentPositionElement.style.visibility = "hidden";
221 }, 236 },
222 237
223 /** 238 /**
224 * @param {!Event} event
225 */
226 _onMouseMove: function(event)
227 {
228 if (!this._enabled)
229 return;
230 var x = event.offsetX + event.target.offsetLeft;
231 this._currentPositionElement.style.left = x + "px";
232 this._currentPositionElement.style.visibility = "visible";
233 },
234
235 /**
236 * @param {!Event} event 239 * @param {!Event} event
237 */ 240 */
238 _resizerElementStartDragging: function(event) 241 _resizerElementStartDragging: function(event)
239 { 242 {
240 if (!this._enabled) 243 if (!this._enabled)
241 return false; 244 return false;
242 this._resizerParentOffsetLeft = event.pageX - event.offsetX - event.targ et.offsetLeft; 245 this._resizerParentOffsetLeft = event.pageX - event.offsetX - event.targ et.offsetLeft;
243 event.preventDefault(); 246 event.preventDefault();
244 return true; 247 return true;
245 }, 248 },
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
494 position = Math.max(0, Math.min(position, this._width)); 497 position = Math.max(0, Math.min(position, this._width));
495 if (position < this._startPosition) { 498 if (position < this._startPosition) {
496 this._windowSelector.style.left = position + "px"; 499 this._windowSelector.style.left = position + "px";
497 this._windowSelector.style.right = this._width - this._startPosition + "px"; 500 this._windowSelector.style.right = this._width - this._startPosition + "px";
498 } else { 501 } else {
499 this._windowSelector.style.left = this._startPosition + "px"; 502 this._windowSelector.style.left = this._startPosition + "px";
500 this._windowSelector.style.right = this._width - position + "px"; 503 this._windowSelector.style.right = this._width - position + "px";
501 } 504 }
502 } 505 }
503 } 506 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698