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

Side by Side Diff: Source/devtools/front_end/elements/StylesSidebarPane.js

Issue 648823004: DevTools: [SSP] fix memory leak through settings (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: add guards to prevent NPE Created 6 years, 2 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 | « no previous file | no next file » | 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) 2007 Apple Inc. All rights reserved. 2 * Copyright (C) 2007 Apple Inc. All rights reserved.
3 * Copyright (C) 2009 Joseph Pecoraro 3 * Copyright (C) 2009 Joseph Pecoraro
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 8 *
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 this._addButtonLongClickController = new WebInspector.LongClickController(ad dButton); 54 this._addButtonLongClickController = new WebInspector.LongClickController(ad dButton);
55 this._addButtonLongClickController.addEventListener(WebInspector.LongClickCo ntroller.Events.LongClick, this._onAddButtonLongClick.bind(this)); 55 this._addButtonLongClickController.addEventListener(WebInspector.LongClickCo ntroller.Events.LongClick, this._onAddButtonLongClick.bind(this));
56 this._addButtonLongClickController.enable(); 56 this._addButtonLongClickController.enable();
57 57
58 this._computedStylePane = computedStylePane; 58 this._computedStylePane = computedStylePane;
59 computedStylePane.setHostingPane(this); 59 computedStylePane.setHostingPane(this);
60 this._setPseudoClassCallback = setPseudoClassCallback; 60 this._setPseudoClassCallback = setPseudoClassCallback;
61 this.element.addEventListener("contextmenu", this._contextMenuEventFired.bin d(this), true); 61 this.element.addEventListener("contextmenu", this._contextMenuEventFired.bin d(this), true);
62 WebInspector.settings.colorFormat.addChangeListener(this._colorFormatSetting Changed.bind(this)); 62 WebInspector.settings.colorFormat.addChangeListener(this._colorFormatSetting Changed.bind(this));
63 WebInspector.settings.showUserAgentStyles.addChangeListener(this._showUserAg entStylesSettingChanged.bind(this)); 63 WebInspector.settings.showUserAgentStyles.addChangeListener(this._showUserAg entStylesSettingChanged.bind(this));
64 WebInspector.settings.showInheritedComputedStyleProperties.addChangeListener (this._showInheritedComputedStyleChanged.bind(this));
64 65
65 this._createElementStatePane(); 66 this._createElementStatePane();
66 this.bodyElement.appendChild(this._elementStatePane); 67 this.bodyElement.appendChild(this._elementStatePane);
67 this._sectionsContainer = createElement("div"); 68 this._sectionsContainer = createElement("div");
68 this.bodyElement.appendChild(this._sectionsContainer); 69 this.bodyElement.appendChild(this._sectionsContainer);
69 70
70 this._spectrumHelper = new WebInspector.SpectrumPopupHelper(); 71 this._spectrumHelper = new WebInspector.SpectrumPopupHelper();
71 this._linkifier = new WebInspector.Linkifier(new WebInspector.Linkifier.Defa ultCSSFormatter()); 72 this._linkifier = new WebInspector.Linkifier(new WebInspector.Linkifier.Defa ultCSSFormatter());
72 73
73 this.element.classList.add("styles-pane"); 74 this.element.classList.add("styles-pane");
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 // IE hack. 162 // IE hack.
162 if (value.endsWith("\9")) 163 if (value.endsWith("\9"))
163 return true; 164 return true;
164 if (hasUnknownVendorPrefix(value)) 165 if (hasUnknownVendorPrefix(value))
165 return true; 166 return true;
166 167
167 return false; 168 return false;
168 } 169 }
169 170
170 WebInspector.StylesSidebarPane.prototype = { 171 WebInspector.StylesSidebarPane.prototype = {
172 _showInheritedComputedStyleChanged: function()
173 {
174 if (!this.sections || !this.sections[0])
175 return;
176 for (var i = 0; i < this.sections[0].length; ++i) {
177 var section = this.sections[0][i];
178 if (section instanceof WebInspector.ComputedStylePropertiesSection)
179 section.onShowInheritedChanged();
180 }
181 },
182
171 /** 183 /**
172 * @param {!WebInspector.Event} event 184 * @param {!WebInspector.Event} event
173 */ 185 */
174 _onAddButtonLongClick: function(event) 186 _onAddButtonLongClick: function(event)
175 { 187 {
176 this._addButtonLongClickController.reset(); 188 this._addButtonLongClickController.reset();
177 var cssModel = this._target.cssModel; 189 var cssModel = this._target.cssModel;
178 var headers = cssModel.styleSheetHeaders().filter(styleSheetResourceHead er); 190 var headers = cssModel.styleSheetHeaders().filter(styleSheetResourceHead er);
179 191
180 /** @type {!Array.<{text: string, handler: function()}>} */ 192 /** @type {!Array.<{text: string, handler: function()}>} */
(...skipping 1714 matching lines...) Expand 10 before | Expand all | Expand 10 after
1895 * @param {!WebInspector.StylesSidebarPane} stylesPane 1907 * @param {!WebInspector.StylesSidebarPane} stylesPane
1896 * @param {!Object} styleRule 1908 * @param {!Object} styleRule
1897 * @param {!Object.<string, boolean>} usedProperties 1909 * @param {!Object.<string, boolean>} usedProperties
1898 */ 1910 */
1899 WebInspector.ComputedStylePropertiesSection = function(stylesPane, styleRule, us edProperties) 1911 WebInspector.ComputedStylePropertiesSection = function(stylesPane, styleRule, us edProperties)
1900 { 1912 {
1901 WebInspector.PropertiesSection.call(this, ""); 1913 WebInspector.PropertiesSection.call(this, "");
1902 this._hasFreshContent = false; 1914 this._hasFreshContent = false;
1903 this.element.className = "styles-section monospace read-only computed-style" ; 1915 this.element.className = "styles-section monospace read-only computed-style" ;
1904 1916
1905 var showInheritedCheckbox = WebInspector.SettingsUI.createSettingCheckbox(We bInspector.UIString("Show inherited properties"), WebInspector.settings.showInhe ritedComputedStyleProperties, true); 1917 this.headerElement.appendChild(WebInspector.ComputedStylePropertiesSection._ showInheritedCheckbox());
1906 showInheritedCheckbox.classList.add("checkbox-with-label"); 1918 this.onShowInheritedChanged();
1907 this.headerElement.appendChild(showInheritedCheckbox);
1908 WebInspector.settings.showInheritedComputedStyleProperties.addChangeListener (showInheritedChanged.bind(this));
1909 showInheritedChanged.call(this);
1910
1911 /**
1912 * @this {WebInspector.ComputedStylePropertiesSection}
1913 */
1914 function showInheritedChanged()
1915 {
1916 this.element.classList.toggle("styles-show-inherited", WebInspector.sett ings.showInheritedComputedStyleProperties.get());
1917 }
1918 1919
1919 this._stylesPane = stylesPane; 1920 this._stylesPane = stylesPane;
1920 this.styleRule = styleRule; 1921 this.styleRule = styleRule;
1921 this._usedProperties = usedProperties; 1922 this._usedProperties = usedProperties;
1922 this._alwaysShowComputedProperties = { "display": true, "height": true, "wid th": true }; 1923 this._alwaysShowComputedProperties = { "display": true, "height": true, "wid th": true };
1923 this.computedStyle = true; 1924 this.computedStyle = true;
1924 this._propertyTreeElements = {}; 1925 this._propertyTreeElements = {};
1925 this._expandedPropertyNames = {}; 1926 this._expandedPropertyNames = {};
1926 } 1927 }
1927 1928
1929 /**
1930 * @return {!Element}
1931 */
1932 WebInspector.ComputedStylePropertiesSection._showInheritedCheckbox = function()
1933 {
1934 if (!WebInspector.ComputedStylePropertiesSection._showInheritedCheckboxEleme nt) {
1935 WebInspector.ComputedStylePropertiesSection._showInheritedCheckboxElemen t = WebInspector.SettingsUI.createSettingCheckbox(WebInspector.UIString("Show in herited properties"), WebInspector.settings.showInheritedComputedStyleProperties , true);
1936 WebInspector.ComputedStylePropertiesSection._showInheritedCheckboxElemen t.classList.add("checkbox-with-label");
1937 }
1938 return WebInspector.ComputedStylePropertiesSection._showInheritedCheckboxEle ment;
1939 }
1940
1928 WebInspector.ComputedStylePropertiesSection.prototype = { 1941 WebInspector.ComputedStylePropertiesSection.prototype = {
1942 onShowInheritedChanged: function()
1943 {
1944 this.element.classList.toggle("styles-show-inherited", WebInspector.sett ings.showInheritedComputedStyleProperties.get());
1945 },
1946
1929 collapse: function(dontRememberState) 1947 collapse: function(dontRememberState)
1930 { 1948 {
1931 // Overriding with empty body. 1949 // Overriding with empty body.
1932 }, 1950 },
1933 1951
1934 _isPropertyInherited: function(propertyName) 1952 _isPropertyInherited: function(propertyName)
1935 { 1953 {
1936 var canonicalName = WebInspector.CSSMetadata.canonicalPropertyName(prope rtyName); 1954 var canonicalName = WebInspector.CSSMetadata.canonicalPropertyName(prope rtyName);
1937 return !(canonicalName in this._usedProperties) && !(canonicalName in th is._alwaysShowComputedProperties); 1955 return !(canonicalName in this._usedProperties) && !(canonicalName in th is._alwaysShowComputedProperties);
1938 }, 1956 },
(...skipping 1643 matching lines...) Expand 10 before | Expand all | Expand 10 after
3582 if (userEnteredText && (userEnteredText === userEnteredText.toUpperCase( ))) { 3600 if (userEnteredText && (userEnteredText === userEnteredText.toUpperCase( ))) {
3583 for (var i = 0; i < results.length; ++i) 3601 for (var i = 0; i < results.length; ++i)
3584 results[i] = results[i].toUpperCase(); 3602 results[i] = results[i].toUpperCase();
3585 } 3603 }
3586 var selectedIndex = this._cssCompletions.mostUsedOf(results); 3604 var selectedIndex = this._cssCompletions.mostUsedOf(results);
3587 completionsReadyCallback(results, selectedIndex); 3605 completionsReadyCallback(results, selectedIndex);
3588 }, 3606 },
3589 3607
3590 __proto__: WebInspector.TextPrompt.prototype 3608 __proto__: WebInspector.TextPrompt.prototype
3591 } 3609 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698