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

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

Issue 2142653003: DevTools: move functionality away from ElementsPanel for better DOM tree control reuse. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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) 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 this._stylesPopoverHelper = new WebInspector.StylesPopoverHelper(); 43 this._stylesPopoverHelper = new WebInspector.StylesPopoverHelper();
44 this._linkifier = new WebInspector.Linkifier(new WebInspector.Linkifier.Defa ultCSSFormatter()); 44 this._linkifier = new WebInspector.Linkifier(new WebInspector.Linkifier.Defa ultCSSFormatter());
45 45
46 this.element.classList.add("styles-pane"); 46 this.element.classList.add("styles-pane");
47 this.element.addEventListener("mousemove", this._mouseMovedOverElement.bind( this), false); 47 this.element.addEventListener("mousemove", this._mouseMovedOverElement.bind( this), false);
48 this._keyDownBound = this._keyDown.bind(this); 48 this._keyDownBound = this._keyDown.bind(this);
49 this._keyUpBound = this._keyUp.bind(this); 49 this._keyUpBound = this._keyUp.bind(this);
50 50
51 /** @type {!Array<!WebInspector.SectionBlock>} */ 51 /** @type {!Array<!WebInspector.SectionBlock>} */
52 this._sectionBlocks = []; 52 this._sectionBlocks = [];
53 WebInspector.StylesSidebarPane._instance = this;
53 54
54 WebInspector.targetManager.addModelListener(WebInspector.CSSModel, WebInspec tor.CSSModel.Events.LayoutEditorChange, this._onLayoutEditorChange, this); 55 WebInspector.targetManager.addModelListener(WebInspector.CSSModel, WebInspec tor.CSSModel.Events.LayoutEditorChange, this._onLayoutEditorChange, this);
55 } 56 }
56 57
57 /** 58 /**
58 * @param {!WebInspector.CSSProperty} property 59 * @param {!WebInspector.CSSProperty} property
59 * @return {!Element} 60 * @return {!Element}
60 */ 61 */
61 WebInspector.StylesSidebarPane.createExclamationMark = function(property) 62 WebInspector.StylesSidebarPane.createExclamationMark = function(property)
62 { 63 {
(...skipping 3054 matching lines...) Expand 10 before | Expand all | Expand 10 after
3117 else if (this._node) 3118 else if (this._node)
3118 hrefUrl = this._node.resolveURL(url); 3119 hrefUrl = this._node.resolveURL(url);
3119 var hasResource = hrefUrl && !!WebInspector.resourceForURL(hrefUrl); 3120 var hasResource = hrefUrl && !!WebInspector.resourceForURL(hrefUrl);
3120 // FIXME: WebInspector.linkifyURLAsNode() should really use baseURI. 3121 // FIXME: WebInspector.linkifyURLAsNode() should really use baseURI.
3121 container.appendChild(WebInspector.linkifyURLAsNode(hrefUrl || url, url, undefined, !hasResource)); 3122 container.appendChild(WebInspector.linkifyURLAsNode(hrefUrl || url, url, undefined, !hasResource));
3122 container.createTextChild(")"); 3123 container.createTextChild(")");
3123 return container; 3124 return container;
3124 } 3125 }
3125 } 3126 }
3126 3127
3128 /**
3129 * @constructor
3130 * @implements {WebInspector.ToolbarItem.Provider}
3131 */
3132 WebInspector.StylesSidebarPane.ButtonProvider = function()
3133 {
3134 this._button = new WebInspector.ToolbarButton(WebInspector.UIString("New Sty le Rule"), "add-toolbar-item");
3135 this._button.addEventListener("click", this._clicked, this);
3136 this._button.element.createChild("div", "long-click-glyph toolbar-button-the me");
3137 new WebInspector.LongClickController(this._button.element, this._longClicked .bind(this));
3138 WebInspector.context.addFlavorChangeListener(WebInspector.DOMNode, onNodeCha nged.bind(this));
3139 onNodeChanged.call(this);
3127 3140
3128 /** 3141 /**
3129 * @return {!WebInspector.ToolbarItem} 3142 * @this {WebInspector.StylesSidebarPane.ButtonProvider}
3130 */ 3143 */
3131 WebInspector.StylesSidebarPane.createAddNewRuleButton = function(stylesSidebarPa ne)
3132 {
3133 var button = new WebInspector.ToolbarButton(WebInspector.UIString("New Style Rule"), "add-toolbar-item");
3134 button.addEventListener("click", stylesSidebarPane._createNewRuleInViaInspec torStyleSheet, stylesSidebarPane);
3135 button.element.createChild("div", "long-click-glyph toolbar-button-theme");
3136 new WebInspector.LongClickController(button.element, stylesSidebarPane._onAd dButtonLongClick.bind(stylesSidebarPane));
3137 WebInspector.context.addFlavorChangeListener(WebInspector.DOMNode, onNodeCha nged);
3138 onNodeChanged();
3139 return button;
3140
3141 function onNodeChanged() 3144 function onNodeChanged()
3142 { 3145 {
3143 var node = WebInspector.context.flavor(WebInspector.DOMNode); 3146 var node = WebInspector.context.flavor(WebInspector.DOMNode);
3144 button.setEnabled(!!node); 3147 node = node ? node.enclosingElementOrSelf() : null;
3148 this._button.setEnabled(!!node);
3145 } 3149 }
3146 } 3150 }
3151
3152 WebInspector.StylesSidebarPane.ButtonProvider.prototype = {
3153 _clicked: function()
3154 {
3155 WebInspector.StylesSidebarPane._instance._createNewRuleInViaInspectorSty leSheet();
3156 },
3157
3158 /**
3159 * @param {!Event} e
3160 */
3161 _longClicked: function(e)
3162 {
3163 WebInspector.StylesSidebarPane._instance._onAddButtonLongClick(e);
3164 },
3165
3166 /**
3167 * @override
3168 * @return {!WebInspector.ToolbarItem}
3169 */
3170 item: function()
3171 {
3172 return this._button;
3173 }
3174 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698