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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/main/RenderingOptions.js

Issue 2839413002: DevTools: add rendering overlay options to command menu (Closed)
Patch Set: ac Created 3 years, 7 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
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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 Common.UIString('FPS Meter'), 47 Common.UIString('FPS Meter'),
48 Common.UIString('Plots frames per second, frame rate distribution, and G PU memory'), 48 Common.UIString('Plots frames per second, frame rate distribution, and G PU memory'),
49 Common.moduleSetting('showFPSCounter')); 49 Common.moduleSetting('showFPSCounter'));
50 this._appendCheckbox( 50 this._appendCheckbox(
51 Common.UIString('Scrolling Performance Issues'), 51 Common.UIString('Scrolling Performance Issues'),
52 Common.UIString( 52 Common.UIString(
53 'Highlights elements (teal) that can slow down scrolling, including touch & wheel event handlers and other main-thread scrolling situations.'), 53 'Highlights elements (teal) that can slow down scrolling, including touch & wheel event handlers and other main-thread scrolling situations.'),
54 Common.moduleSetting('showScrollBottleneckRects')); 54 Common.moduleSetting('showScrollBottleneckRects'));
55 this.contentElement.createChild('div').classList.add('panel-section-separato r'); 55 this.contentElement.createChild('div').classList.add('panel-section-separato r');
56 56
57 var cssMediaSubtitle = Common.UIString('Forces media type for testing print and screen styles'); 57 this._mediaSetting = Common.moduleSetting('emulateCSSMedia');
58 var checkboxLabel = UI.CheckboxLabel.create(Common.UIString('Emulate CSS Med ia'), false, cssMediaSubtitle); 58 this._mediaSetting.addChangeListener(this._mediaChanged.bind(this));
59 this._mediaCheckbox = checkboxLabel.checkboxElement; 59 var emulateMediaExtension = self.runtime.extensions('setting').find(
60 this._mediaCheckbox.addEventListener('click', this._mediaToggled.bind(this), false); 60 extension => extension.descriptor()['settingName'] === 'emulateCSSMedia' );
61 this.contentElement.appendChild(checkboxLabel); 61 if (emulateMediaExtension) {
62 62 var mediaSelect = UI.SettingsUI.settingExtensionToControl(emulateMediaExte nsion);
63 var mediaRow = this.contentElement.createChild('div', 'media-row'); 63 if (mediaSelect) {
64 this._mediaSelect = mediaRow.createChild('select', 'chrome-select'); 64 var mediaRow = this.contentElement.createChild('span', 'media-row');
65 this._mediaSelect.appendChild(new Option(Common.UIString('print'), 'print')) ; 65 mediaRow.createChild('label').textContent = Common.UIString('Emulate CSS Media');
66 this._mediaSelect.appendChild(new Option(Common.UIString('screen'), 'screen' )); 66 mediaRow.createChild('p').textContent =
67 this._mediaSelect.addEventListener('change', this._mediaToggled.bind(this), false); 67 Common.UIString('Forces media type for testing print and screen styl es');
68 this._mediaSelect.disabled = true; 68 mediaRow.appendChild(mediaSelect);
69 }
70 }
69 71
70 SDK.targetManager.observeModels(SDK.EmulationModel, this); 72 SDK.targetManager.observeModels(SDK.EmulationModel, this);
71 } 73 }
72 74
73 /** 75 /**
74 * @param {string} label 76 * @param {string} label
75 * @param {string} subtitle 77 * @param {string} subtitle
76 * @param {!Common.Setting} setting 78 * @param {!Common.Setting} setting
77 */ 79 */
78 _appendCheckbox(label, subtitle, setting) { 80 _appendCheckbox(label, subtitle, setting) {
79 var checkboxLabel = UI.CheckboxLabel.create(label, false, subtitle); 81 var checkboxLabel = UI.CheckboxLabel.create(label, false, subtitle);
80 UI.SettingsUI.bindCheckbox(checkboxLabel.checkboxElement, setting); 82 UI.SettingsUI.bindCheckbox(checkboxLabel.checkboxElement, setting);
81 this.contentElement.appendChild(checkboxLabel); 83 this.contentElement.appendChild(checkboxLabel);
82 } 84 }
83 85
84 /** 86 /**
85 * @override 87 * @override
86 * @param {!SDK.EmulationModel} emulationModel 88 * @param {!SDK.EmulationModel} emulationModel
87 */ 89 */
88 modelAdded(emulationModel) { 90 modelAdded(emulationModel) {
89 if (this._mediaCheckbox.checked) 91 var mediaValue = this._mediaSetting.get() === 'none' ? null : this._mediaSet ting.get();
90 emulationModel.emulateCSSMedia(this._mediaSelect.value); 92 emulationModel.emulateCSSMedia(mediaValue);
91 } 93 }
92 94
93 _mediaToggled() { 95 _mediaChanged() {
94 this._mediaSelect.disabled = !this._mediaCheckbox.checked; 96 var mediaValue = this._mediaSetting.get() === 'none' ? null : this._mediaSet ting.get();
95 var media = this._mediaCheckbox.checked ? this._mediaSelect.value : null;
96 for (var emulationModel of SDK.targetManager.models(SDK.EmulationModel)) 97 for (var emulationModel of SDK.targetManager.models(SDK.EmulationModel))
97 emulationModel.emulateCSSMedia(media); 98 emulationModel.emulateCSSMedia(mediaValue);
98 } 99 }
99 100
100 /** 101 /**
101 * @override 102 * @override
102 * @param {!SDK.EmulationModel} emulationModel 103 * @param {!SDK.EmulationModel} emulationModel
103 */ 104 */
104 modelRemoved(emulationModel) { 105 modelRemoved(emulationModel) {
105 } 106 }
106 }; 107 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698