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.VBox} | 7 * @extends {WebInspector.VBox} |
8 * @implements {WebInspector.OverridesSupport.PageResizer} | 8 * @implements {WebInspector.OverridesSupport.PageResizer} |
9 * @implements {WebInspector.TargetManager.Observer} | 9 * @implements {WebInspector.TargetManager.Observer} |
10 * @param {!WebInspector.InspectedPagePlaceholder} inspectedPagePlaceholder | 10 * @param {!WebInspector.InspectedPagePlaceholder} inspectedPagePlaceholder |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
181 _availableDipSize: function() | 181 _availableDipSize: function() |
182 { | 182 { |
183 if (typeof this._availableSize === "undefined") { | 183 if (typeof this._availableSize === "undefined") { |
184 var zoomFactor = WebInspector.zoomManager.zoomFactor(); | 184 var zoomFactor = WebInspector.zoomManager.zoomFactor(); |
185 var rect = this._canvasContainer.element.getBoundingClientRect(); | 185 var rect = this._canvasContainer.element.getBoundingClientRect(); |
186 var mediaInspectorHeight = this._mediaInspector.element.offsetHeight ; | 186 var mediaInspectorHeight = this._mediaInspector.element.offsetHeight ; |
187 if (mediaInspectorHeight) | 187 if (mediaInspectorHeight) |
188 mediaInspectorHeight += WebInspector.ResponsiveDesignView.RulerB ottomHeight; | 188 mediaInspectorHeight += WebInspector.ResponsiveDesignView.RulerB ottomHeight; |
189 this._availableSize = new Size(Math.max(rect.width * zoomFactor - We bInspector.ResponsiveDesignView.RulerWidth, 1), | 189 this._availableSize = new Size(Math.max(rect.width * zoomFactor - We bInspector.ResponsiveDesignView.RulerWidth, 1), |
190 Math.max(rect.height * zoomFactor - m ediaInspectorHeight - WebInspector.ResponsiveDesignView.RulerHeight, 1)); | 190 Math.max(rect.height * zoomFactor - m ediaInspectorHeight - WebInspector.ResponsiveDesignView.RulerHeight, 1)); |
191 | |
191 } | 192 } |
192 return this._availableSize; | 193 return this._availableSize; |
193 }, | 194 }, |
194 | 195 |
195 /** | 196 /** |
196 * @param {!Element} element | 197 * @param {!Element} element |
197 * @param {boolean} vertical | 198 * @param {boolean} vertical |
198 * @return {!WebInspector.ResizerWidget} | 199 * @return {!WebInspector.ResizerWidget} |
199 */ | 200 */ |
200 _createResizer: function(element, vertical) | 201 _createResizer: function(element, vertical) |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
277 var deviceScaleFactor = window.devicePixelRatio; | 278 var deviceScaleFactor = window.devicePixelRatio; |
278 canvas.width = deviceScaleFactor * cssCanvasWidth; | 279 canvas.width = deviceScaleFactor * cssCanvasWidth; |
279 canvas.height = deviceScaleFactor * cssCanvasHeight; | 280 canvas.height = deviceScaleFactor * cssCanvasHeight; |
280 context.scale(canvas.width / dipCanvasWidth, canvas.height / dipCanvasHe ight); | 281 context.scale(canvas.width / dipCanvasWidth, canvas.height / dipCanvasHe ight); |
281 context.font = "11px " + WebInspector.fontFamily(); | 282 context.font = "11px " + WebInspector.fontFamily(); |
282 | 283 |
283 const backgroundColor = "rgb(102, 102, 102)"; | 284 const backgroundColor = "rgb(102, 102, 102)"; |
284 const lightLineColor = "rgb(132, 132, 132)"; | 285 const lightLineColor = "rgb(132, 132, 132)"; |
285 const darkLineColor = "rgb(114, 114, 114)"; | 286 const darkLineColor = "rgb(114, 114, 114)"; |
286 const rulerColor = "rgb(125, 125, 125)"; | 287 const rulerColor = "rgb(125, 125, 125)"; |
287 const rulerOverlayColor = "rgba(255, 255, 255, 0.4)"; | 288 const rulerOverlayColor = "rgba(255, 255, 255, 0.2)"; |
288 const textColor = "rgb(186, 186, 186)"; | 289 const textColor = "rgb(186, 186, 186)"; |
289 const contentsSizeColor = "rgba(0, 0, 0, 0.3)"; | 290 const contentsSizeColor = "rgba(0, 0, 0, 0.3)"; |
290 | 291 |
291 var scale = (this._scale || 1) * this._viewport.pageScaleFactor; | 292 var scale = (this._scale || 1) * this._viewport.pageScaleFactor; |
292 var rulerScale = 0.5; | 293 var rulerScale = 0.5; |
293 while (Math.abs(rulerScale * scale - 1) > Math.abs((rulerScale + 0.5) * scale - 1)) | 294 while (Math.abs(rulerScale * scale - 1) > Math.abs((rulerScale + 0.5) * scale - 1)) |
294 rulerScale += 0.5; | 295 rulerScale += 0.5; |
295 | 296 |
296 var gridStep = 50 * scale * rulerScale; | 297 var gridStep = 50 * scale * rulerScale; |
297 var gridSubStep = 10 * scale * rulerScale; | 298 var gridSubStep = 10 * scale * rulerScale; |
298 | 299 |
299 var rulerSubStep = 5 * scale * rulerScale; | 300 var rulerSubStep = 5 * scale * rulerScale; |
300 var rulerStepCount = 20; | 301 var rulerStepCount = 20; |
301 | 302 |
302 var rulerWidth = WebInspector.ResponsiveDesignView.RulerWidth; | 303 var rulerWidth = WebInspector.ResponsiveDesignView.RulerWidth; |
303 var rulerHeight = WebInspector.ResponsiveDesignView.RulerHeight; | 304 var rulerHeight = WebInspector.ResponsiveDesignView.RulerHeight; |
305 | |
304 if (dipMediaInspectorHeight) | 306 if (dipMediaInspectorHeight) |
305 rulerHeight += WebInspector.ResponsiveDesignView.RulerBottomHeight + dipMediaInspectorHeight; | 307 rulerHeight += WebInspector.ResponsiveDesignView.RulerBottomHeight + dipMediaInspectorHeight; |
308 | |
306 var dipGridWidth = dipCanvasWidth - rulerWidth; | 309 var dipGridWidth = dipCanvasWidth - rulerWidth; |
307 var dipGridHeight = dipCanvasHeight - rulerHeight; | 310 var dipGridHeight = dipCanvasHeight - rulerHeight; |
308 var dipScrollX = this._viewport.scrollX * scale; | 311 var dipScrollX = this._viewport.scrollX * scale; |
309 var dipScrollY = this._viewport.scrollY * scale; | 312 var dipScrollY = this._viewport.scrollY * scale; |
310 context.translate(rulerWidth, rulerHeight); | 313 context.translate(rulerWidth, rulerHeight); |
311 | 314 |
312 context.fillStyle = backgroundColor; | 315 context.fillStyle = backgroundColor; |
313 context.fillRect(0, 0, dipGridWidth, dipGridHeight); | 316 context.fillRect(0, 0, dipGridWidth, dipGridHeight); |
314 | 317 |
315 context.translate(0.5, 0.5); | 318 context.translate(0.5, 0.5); |
(...skipping 13 matching lines...) Expand all Loading... | |
329 if (minXIndex) { | 332 if (minXIndex) { |
330 context.beginPath(); | 333 context.beginPath(); |
331 context.moveTo(0, -rulerHeight); | 334 context.moveTo(0, -rulerHeight); |
332 context.lineTo(0, 0); | 335 context.lineTo(0, 0); |
333 context.stroke(); | 336 context.stroke(); |
334 } | 337 } |
335 | 338 |
336 context.translate(-dipScrollX, 0); | 339 context.translate(-dipScrollX, 0); |
337 for (var index = minXIndex; index <= maxXIndex; index++) { | 340 for (var index = minXIndex; index <= maxXIndex; index++) { |
338 var x = index * rulerSubStep; | 341 var x = index * rulerSubStep; |
342 | |
339 var y = -WebInspector.ResponsiveDesignView.RulerHeight * 0.25; | 343 var y = -WebInspector.ResponsiveDesignView.RulerHeight * 0.25; |
340 var copyHeight = WebInspector.ResponsiveDesignView.RulerHeight * 0.2 5; | 344 var copyHeight = WebInspector.ResponsiveDesignView.RulerHeight * 0.2 5; |
341 | 345 |
342 if (!(index % (rulerStepCount / 4))) | 346 if (!(index % (rulerStepCount / 4))) |
343 copyHeight = WebInspector.ResponsiveDesignView.RulerHeight * 0.5 ; | 347 copyHeight = WebInspector.ResponsiveDesignView.RulerHeight * 0.5 ; |
344 if (!(index % (rulerStepCount / 2))) { | 348 if (!(index % (rulerStepCount / 2))) { |
345 context.strokeStyle = rulerOverlayColor; | 349 context.strokeStyle = rulerOverlayColor; |
346 y = -rulerHeight + WebInspector.ResponsiveDesignView.RulerHeight * 0.25; | 350 y = -rulerHeight + WebInspector.ResponsiveDesignView.RulerHeight * 0.25; |
347 copyHeight = 0; | 351 copyHeight = 0; |
348 } | 352 } |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
485 var cssWidth = (this._dipWidth ? this._dipWidth : availableDip.width) / zoomFactor; | 489 var cssWidth = (this._dipWidth ? this._dipWidth : availableDip.width) / zoomFactor; |
486 var cssHeight = (this._dipHeight ? this._dipHeight : availableDip.height ) / zoomFactor; | 490 var cssHeight = (this._dipHeight ? this._dipHeight : availableDip.height ) / zoomFactor; |
487 if (this._cachedCssWidth !== cssWidth || this._cachedCssHeight !== cssHe ight) { | 491 if (this._cachedCssWidth !== cssWidth || this._cachedCssHeight !== cssHe ight) { |
488 this._slidersContainer.style.width = cssWidth + "px"; | 492 this._slidersContainer.style.width = cssWidth + "px"; |
489 this._slidersContainer.style.height = cssHeight + "px"; | 493 this._slidersContainer.style.height = cssHeight + "px"; |
490 this._inspectedPagePlaceholder.onResize(); | 494 this._inspectedPagePlaceholder.onResize(); |
491 } | 495 } |
492 | 496 |
493 var pageScaleVisible = cssWidth + WebInspector.ResponsiveDesignView.Page ScaleContainerWidth + WebInspector.ResponsiveDesignView.RulerWidth / zoomFactor <= rect.width || | 497 var pageScaleVisible = cssWidth + WebInspector.ResponsiveDesignView.Page ScaleContainerWidth + WebInspector.ResponsiveDesignView.RulerWidth / zoomFactor <= rect.width || |
494 cssHeight + WebInspector.ResponsiveDesignView.PageScaleContainerHeig ht + mediaInspectorHeight + rulerTotalHeight / zoomFactor <= rect.height; | 498 cssHeight + WebInspector.ResponsiveDesignView.PageScaleContainerHeig ht + mediaInspectorHeight + rulerTotalHeight / zoomFactor <= rect.height; |
499 | |
495 this._pageScaleContainer.classList.toggle("hidden", !pageScaleVisible); | 500 this._pageScaleContainer.classList.toggle("hidden", !pageScaleVisible); |
496 | 501 |
497 var viewportChanged = !this._cachedViewport | 502 var viewportChanged = !this._cachedViewport |
498 || this._cachedViewport.scrollX !== this._viewport.scrollX || this._ cachedViewport.scrollY !== this._viewport.scrollY | 503 || this._cachedViewport.scrollX !== this._viewport.scrollX || this._ cachedViewport.scrollY !== this._viewport.scrollY |
499 || this._cachedViewport.contentsWidth !== this._viewport.contentsWid th || this._cachedViewport.contentsHeight !== this._viewport.contentsHeight | 504 || this._cachedViewport.contentsWidth !== this._viewport.contentsWid th || this._cachedViewport.contentsHeight !== this._viewport.contentsHeight |
500 || this._cachedViewport.pageScaleFactor !== this._viewport.pageScale Factor | 505 || this._cachedViewport.pageScaleFactor !== this._viewport.pageScale Factor |
501 || this._cachedViewport.minimumPageScaleFactor !== this._viewport.mi nimumPageScaleFactor | 506 || this._cachedViewport.minimumPageScaleFactor !== this._viewport.mi nimumPageScaleFactor |
502 || this._cachedViewport.maximumPageScaleFactor !== this._viewport.ma ximumPageScaleFactor; | 507 || this._cachedViewport.maximumPageScaleFactor !== this._viewport.ma ximumPageScaleFactor; |
503 | 508 |
504 var canvasInvalidated = viewportChanged || this._drawContentsSize !== th is._cachedDrawContentsSize || this._cachedScale !== this._scale || | 509 var canvasInvalidated = viewportChanged || this._drawContentsSize !== th is._cachedDrawContentsSize || this._cachedScale !== this._scale || |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
540 this._inspectedPagePlaceholder.onResize(); | 545 this._inspectedPagePlaceholder.onResize(); |
541 }, | 546 }, |
542 | 547 |
543 _onZoomChanged: function() | 548 _onZoomChanged: function() |
544 { | 549 { |
545 this._updateUI(); | 550 this._updateUI(); |
546 }, | 551 }, |
547 | 552 |
548 _createToolbar: function() | 553 _createToolbar: function() |
549 { | 554 { |
550 this._toolbarElement = this._responsiveDesignContainer.element.createChi ld("div", "responsive-design-toolbar"); | 555 var toolbar = this._responsiveDesignContainer.element.createChild("div", "responsive-design-toolbar"); |
556 | |
557 // create a hbox that contains the left-hand buttons and the panels | |
558 this._toolbarHorizontalContainer = toolbar.createChild("div", "hbox flex -auto"); | |
dgozman
2014/09/08 11:44:26
Why change all this? I don't how this affects anyt
| |
559 | |
560 // put left hand buttons into a single vertical row | |
551 this._createButtonsSection(); | 561 this._createButtonsSection(); |
562 | |
563 // create a wrapper to place the rest in | |
564 this._toolbarWrapper = this._toolbarHorizontalContainer.createChild("div ", "responsive-design-toolbar-wrapper"); | |
565 this._toolbarPanelWrapper = this._toolbarWrapper.createChild("div", "hbo x"); | |
566 | |
552 this._createDeviceSection(); | 567 this._createDeviceSection(); |
553 this._toolbarElement.createChild("div", "responsive-design-separator"); | 568 this._toolbarPanelWrapper.createChild("div", "responsive-design-separato r"); |
554 this._createNetworkSection(); | 569 this._createNetworkSection(); |
555 this._toolbarElement.createChild("div", "responsive-design-separator"); | 570 this._toolbarPanelWrapper.createChild("div", "responsive-design-separato r"); |
556 | 571 |
557 var moreButtonContainer = this._toolbarElement.createChild("div", "respo nsive-design-more-button-container"); | 572 // create more button |
573 var moreButtonContainer = this._toolbarPanelWrapper.createChild("div", " responsive-design-more-button-container"); | |
558 var moreButton = moreButtonContainer.createChild("button", "responsive-d esign-more-button"); | 574 var moreButton = moreButtonContainer.createChild("button", "responsive-d esign-more-button"); |
559 moreButton.title = WebInspector.UIString("More overrides"); | 575 moreButton.title = WebInspector.UIString("More overrides"); |
560 moreButton.addEventListener("click", this._showEmulationInDrawer.bind(th is), false); | 576 moreButton.addEventListener("click", this._showEmulationInDrawer.bind(th is), false); |
561 moreButton.textContent = "\u2026"; | 577 moreButton.textContent = "\u2026"; |
578 | |
579 // Create media query inspector | |
580 this._mediaInspector = new WebInspector.MediaQueryInspector(); | |
dgozman
2014/09/08 11:44:26
You create media inspector here for the second tim
| |
581 this._mediaInspectorContainer = this._toolbarWrapper.createChild("div", "responsive-design-media-container"); | |
582 this._updateMediaQueryInspector(); | |
562 }, | 583 }, |
563 | 584 |
564 _createButtonsSection: function() | 585 _createButtonsSection: function() |
565 { | 586 { |
566 var buttonsSection = this._toolbarElement.createChild("div", "responsive -design-section responsive-design-section-buttons"); | 587 var buttonsSection = this._toolbarHorizontalContainer.createChild("div", "responsive-design-section responsive-design-section-buttons"); |
567 | 588 |
568 var resetButton = new WebInspector.StatusBarButton(WebInspector.UIString ("Reset all overrides."), "clear-status-bar-item"); | 589 var resetButton = new WebInspector.StatusBarButton(WebInspector.UIString ("Reset all overrides."), "clear-status-bar-item"); |
569 buttonsSection.appendChild(resetButton.element); | 590 buttonsSection.appendChild(resetButton.element); |
570 resetButton.addEventListener("click", WebInspector.overridesSupport.rese t, WebInspector.overridesSupport); | 591 resetButton.addEventListener("click", WebInspector.overridesSupport.rese t, WebInspector.overridesSupport); |
571 | 592 |
572 // Media Query Inspector. | 593 // Media Query Inspector. |
573 this._toggleMediaInspectorButton = new WebInspector.StatusBarButton(WebI nspector.UIString("Media queries not found"), "responsive-design-toggle-media-in spector"); | 594 this._toggleMediaInspectorButton = new WebInspector.StatusBarButton(WebI nspector.UIString("Media queries not found"), "responsive-design-toggle-media-in spector"); |
574 this._toggleMediaInspectorButton.toggled = WebInspector.settings.showMed iaQueryInspector.get(); | 595 this._toggleMediaInspectorButton.toggled = WebInspector.settings.showMed iaQueryInspector.get(); |
575 this._toggleMediaInspectorButton.setEnabled(false); | 596 this._toggleMediaInspectorButton.setEnabled(false); |
576 this._toggleMediaInspectorButton.addEventListener("click", this._onToggl eMediaInspectorButtonClick, this); | 597 this._toggleMediaInspectorButton.addEventListener("click", this._onToggl eMediaInspectorButtonClick, this); |
577 WebInspector.settings.showMediaQueryInspector.addChangeListener(this._up dateMediaQueryInspector, this); | 598 WebInspector.settings.showMediaQueryInspector.addChangeListener(this._up dateMediaQueryInspector, this); |
578 buttonsSection.appendChild(this._toggleMediaInspectorButton.element); | 599 buttonsSection.appendChild(this._toggleMediaInspectorButton.element); |
579 }, | 600 }, |
580 | 601 |
581 _createDeviceSection: function() | 602 _createDeviceSection: function() |
582 { | 603 { |
583 var deviceSection = this._toolbarElement.createChild("div", "responsive- design-section responsive-design-section-device"); | 604 var deviceSection = this._toolbarPanelWrapper.createChild("div", "respon sive-design-section responsive-design-section-device"); |
584 | 605 |
585 var separator = deviceSection.createChild("div", "responsive-design-sect ion-decorator"); | 606 var separator = deviceSection.createChild("div", "responsive-design-sect ion-decorator"); |
586 | 607 |
587 // Device. | 608 // Device. |
588 var deviceElement = deviceSection.createChild("div", "responsive-design- suite responsive-design-suite-top").createChild("div"); | 609 var deviceElement = deviceSection.createChild("div", "responsive-design- suite responsive-design-suite-top").createChild("div"); |
589 | 610 |
590 var fieldsetElement = deviceElement.createChild("fieldset"); | 611 var fieldsetElement = deviceElement.createChild("fieldset"); |
591 fieldsetElement.createChild("label").textContent = WebInspector.UIString ("Device"); | 612 fieldsetElement.createChild("label").textContent = WebInspector.UIString ("Device"); |
592 var deviceSelectElement = WebInspector.OverridesUI.createDeviceSelect(do cument); | 613 var deviceSelectElement = WebInspector.OverridesUI.createDeviceSelect(do cument); |
593 fieldsetElement.appendChild(deviceSelectElement); | 614 fieldsetElement.appendChild(deviceSelectElement); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
630 | 651 |
631 // Fit to window. | 652 // Fit to window. |
632 detailsElement.createChild("div", "responsive-design-suite-separator"); | 653 detailsElement.createChild("div", "responsive-design-suite-separator"); |
633 var fitToWindowElement = detailsElement.createChild("div", ""); | 654 var fitToWindowElement = detailsElement.createChild("div", ""); |
634 fieldsetElement = fitToWindowElement.createChild("fieldset"); | 655 fieldsetElement = fitToWindowElement.createChild("fieldset"); |
635 fieldsetElement.appendChild(WebInspector.SettingsUI.createSettingCheckbo x(WebInspector.UIString("Fit"), WebInspector.overridesSupport.settings.deviceFit Window, true, undefined, WebInspector.UIString("Zoom to fit available space"))); | 656 fieldsetElement.appendChild(WebInspector.SettingsUI.createSettingCheckbo x(WebInspector.UIString("Fit"), WebInspector.overridesSupport.settings.deviceFit Window, true, undefined, WebInspector.UIString("Zoom to fit available space"))); |
636 }, | 657 }, |
637 | 658 |
638 _createNetworkSection: function() | 659 _createNetworkSection: function() |
639 { | 660 { |
640 var networkSection = this._toolbarElement.createChild("div", "responsive -design-section responsive-design-section-network"); | 661 var networkSection = this._toolbarPanelWrapper.createChild("div", "respo nsive-design-section responsive-design-section-network"); |
641 | 662 |
642 var separator = networkSection.createChild("div", "responsive-design-sec tion-decorator"); | 663 var separator = networkSection.createChild("div", "responsive-design-sec tion-decorator"); |
643 | 664 |
644 // Bandwidth. | 665 // Bandwidth. |
645 var bandwidthElement = networkSection.createChild("div", "responsive-des ign-suite responsive-design-suite-top").createChild("div"); | 666 var bandwidthElement = networkSection.createChild("div", "responsive-des ign-suite responsive-design-suite-top").createChild("div"); |
646 var fieldsetElement = bandwidthElement.createChild("fieldset"); | 667 var fieldsetElement = bandwidthElement.createChild("fieldset"); |
647 var networkCheckbox = fieldsetElement.createChild("label"); | 668 var networkCheckbox = fieldsetElement.createChild("label"); |
648 networkCheckbox.textContent = WebInspector.UIString("Network"); | 669 networkCheckbox.textContent = WebInspector.UIString("Network"); |
649 fieldsetElement.appendChild(WebInspector.OverridesUI.createNetworkCondit ionsSelect(document)); | 670 fieldsetElement.appendChild(WebInspector.OverridesUI.createNetworkCondit ionsSelect(document)); |
650 | 671 |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
743 value = Math.min(this._viewport.maximumPageScaleFactor, value); | 764 value = Math.min(this._viewport.maximumPageScaleFactor, value); |
744 value = Math.max(this._viewport.minimumPageScaleFactor, value) | 765 value = Math.max(this._viewport.minimumPageScaleFactor, value) |
745 this._target.pageAgent().setPageScaleFactor(value); | 766 this._target.pageAgent().setPageScaleFactor(value); |
746 } | 767 } |
747 finishCallback(); | 768 finishCallback(); |
748 } | 769 } |
749 }, | 770 }, |
750 | 771 |
751 __proto__: WebInspector.VBox.prototype | 772 __proto__: WebInspector.VBox.prototype |
752 }; | 773 }; |
OLD | NEW |