Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 /** | 5 /** |
| 6 * @constructor | 6 * @constructor |
| 7 * @extends {WebInspector.View} | 7 * @extends {WebInspector.View} |
| 8 * @implements {WebInspector.TargetManager.Observer} | 8 * @implements {WebInspector.TargetManager.Observer} |
| 9 */ | 9 */ |
| 10 WebInspector.MediaQueryInspector = function() | 10 WebInspector.MediaQueryInspector = function() |
| (...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 306 return; | 306 return; |
| 307 } | 307 } |
| 308 } | 308 } |
| 309 this._highlightMarkerInContainer(null, mediaQueryMarkerContainer); | 309 this._highlightMarkerInContainer(null, mediaQueryMarkerContainer); |
| 310 }, | 310 }, |
| 311 | 311 |
| 312 /** | 312 /** |
| 313 * @param {?Element} marker | 313 * @param {?Element} marker |
| 314 * @param {!Element} container | 314 * @param {!Element} container |
| 315 */ | 315 */ |
| 316 _highlightMarkerInContainer: function(marker, container) | 316 _highlightMarkerInContainer: function(marker, container) |
|
dgozman
2014/09/19 08:41:25
This method can be greatly simplified:
container.c
pfeldman
2014/09/19 09:21:47
Why don't we use hover and remove it altogether?
dgozman
2014/09/19 09:25:21
I guess that works if you don't move the highlight
| |
| 317 { | 317 { |
| 318 var children = container.children; | 318 var children = container.children; |
| 319 var found = !marker; | 319 var found = !marker; |
| 320 for (var i = children.length - 1; i >= 0; --i) { | 320 for (var i = children.length - 1; i >= 0; --i) { |
| 321 if (found) { | 321 if (found) { |
| 322 children[i].classList.remove("media-inspector-marker-highlight") ; | 322 children[i].classList.remove("media-inspector-marker-highlight") ; |
| 323 children[i].classList.remove("media-inspector-marker-under-highl ighted"); | |
| 324 } else if (children[i] === marker) { | 323 } else if (children[i] === marker) { |
| 325 children[i].classList.add("media-inspector-marker-highlight"); | 324 children[i].classList.add("media-inspector-marker-highlight"); |
| 326 children[i].classList.remove("media-inspector-marker-under-highl ighted"); | |
| 327 found = true; | 325 found = true; |
| 328 } else { | 326 } else { |
| 329 children[i].classList.remove("media-inspector-marker-highlight") ; | 327 children[i].classList.remove("media-inspector-marker-highlight") ; |
| 330 children[i].classList.add("media-inspector-marker-under-highligh ted"); | |
| 331 } | 328 } |
| 332 } | 329 } |
| 333 }, | 330 }, |
| 334 | 331 |
| 335 /** | 332 /** |
| 336 * @return {number} | 333 * @return {number} |
| 337 */ | 334 */ |
| 338 _zoomFactor: function() | 335 _zoomFactor: function() |
| 339 { | 336 { |
| 340 return WebInspector.zoomManager.zoomFactor() / this._scale; | 337 return WebInspector.zoomManager.zoomFactor() / this._scale; |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 366 var widthPixelValue = null; | 363 var widthPixelValue = null; |
| 367 if (model.maxWidthExpression() && model.minWidthExpression()) | 364 if (model.maxWidthExpression() && model.minWidthExpression()) |
| 368 widthPixelValue = (model.maxWidthExpression().computedLength() - min WidthValue) / zoomFactor; | 365 widthPixelValue = (model.maxWidthExpression().computedLength() - min WidthValue) / zoomFactor; |
| 369 else if (model.maxWidthExpression()) | 366 else if (model.maxWidthExpression()) |
| 370 widthPixelValue = (model.maxWidthExpression().computedLength() - thi s._offset) / zoomFactor; | 367 widthPixelValue = (model.maxWidthExpression().computedLength() - thi s._offset) / zoomFactor; |
| 371 else | 368 else |
| 372 markerElement.style.right = "0"; | 369 markerElement.style.right = "0"; |
| 373 if (typeof widthPixelValue === "number") | 370 if (typeof widthPixelValue === "number") |
| 374 markerElement.style.width = widthPixelValue + "px"; | 371 markerElement.style.width = widthPixelValue + "px"; |
| 375 | 372 |
| 373 if (model.minWidthExpression()) { | |
| 374 var labelClass = model.section() === WebInspector.MediaQueryInspecto r.Section.MinMax ? "media-inspector-label-right" : "media-inspector-label-left"; | |
| 375 var labelContainer = markerElement.createChild("div", "media-inspect or-marker-label-container media-inspector-marker-label-container-left"); | |
| 376 labelContainer.createChild("span", "media-inspector-marker-label " + labelClass).textContent = model.minWidthExpression().computedLength() + "px"; | |
| 377 markerElement.title = model.minWidthExpression().computedLength() + "px"; | |
| 378 if (model.maxWidthExpression()) | |
| 379 markerElement.title += WebInspector.UIString(" \u2014 "); | |
| 380 } | |
| 381 | |
| 376 if (model.maxWidthExpression()) { | 382 if (model.maxWidthExpression()) { |
| 377 var labelClass = model.section() === WebInspector.MediaQueryInspecto r.Section.MinMax ? "media-inspector-label-left" : "media-inspector-label-right"; | 383 var labelClass = model.section() === WebInspector.MediaQueryInspecto r.Section.MinMax ? "media-inspector-label-left" : "media-inspector-label-right"; |
| 378 var labelContainer = markerElement.createChild("div", "media-inspect or-marker-label-container media-inspector-marker-label-container-right"); | 384 var labelContainer = markerElement.createChild("div", "media-inspect or-marker-label-container media-inspector-marker-label-container-right"); |
| 379 labelContainer.createChild("div", "media-inspector-marker-serif"); | |
| 380 labelContainer.createChild("span", "media-inspector-marker-label " + labelClass).textContent = model.maxWidthExpression().computedLength() + "px"; | 385 labelContainer.createChild("span", "media-inspector-marker-label " + labelClass).textContent = model.maxWidthExpression().computedLength() + "px"; |
| 381 } | 386 markerElement.title += model.maxWidthExpression().computedLength() + "px"; |
| 382 | |
| 383 if (model.minWidthExpression()) { | |
| 384 var labelClass = model.section() === WebInspector.MediaQueryInspecto r.Section.MinMax ? "media-inspector-label-right" : "media-inspector-label-left"; | |
| 385 var labelContainer = markerElement.createChild("div", "media-inspect or-marker-label-container media-inspector-marker-label-container-left"); | |
| 386 labelContainer.createChild("div", "media-inspector-marker-serif"); | |
| 387 labelContainer.createChild("span", "media-inspector-marker-label " + labelClass).textContent = model.minWidthExpression().computedLength() + "px"; | |
| 388 } | 387 } |
| 389 | 388 |
| 390 return markerElement; | 389 return markerElement; |
| 391 }, | 390 }, |
| 392 | 391 |
| 393 __proto__: WebInspector.View.prototype | 392 __proto__: WebInspector.View.prototype |
| 394 }; | 393 }; |
| 395 | 394 |
| 396 /** | 395 /** |
| 397 * @constructor | 396 * @constructor |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 536 }, | 535 }, |
| 537 | 536 |
| 538 /** | 537 /** |
| 539 * @return {boolean} | 538 * @return {boolean} |
| 540 */ | 539 */ |
| 541 active: function() | 540 active: function() |
| 542 { | 541 { |
| 543 return this._active; | 542 return this._active; |
| 544 } | 543 } |
| 545 } | 544 } |
| OLD | NEW |