| OLD | NEW |
| 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 this._sectionsContainer = this.element.createChild("div"); | 42 this._sectionsContainer = this.element.createChild("div"); |
| 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 WebInspector.targetManager.addModelListener(WebInspector.CSSModel, WebInspec
tor.CSSModel.Events.LayoutEditorChange, this._onLayoutEditorChange, this); | 51 WebInspector.targetManager.addModelListener(WebInspector.CSSModel, WebInspec
tor.CSSModel.Events.LayoutEditorChange, this._onLayoutEditorChange, this); |
| 52 WebInspector.targetManager.addModelListener(WebInspector.CSSModel, WebInspec
tor.CSSModel.Events.SourceMapAttached, this._onSourceMapAttachedOrDetached, this
); |
| 53 WebInspector.targetManager.addModelListener(WebInspector.CSSModel, WebInspec
tor.CSSModel.Events.SourceMapDetached, this._onSourceMapAttachedOrDetached, this
); |
| 52 } | 54 } |
| 53 | 55 |
| 54 /** | 56 /** |
| 55 * @param {!WebInspector.CSSProperty} property | 57 * @param {!WebInspector.CSSProperty} property |
| 56 * @return {!Element} | 58 * @return {!Element} |
| 57 */ | 59 */ |
| 58 WebInspector.StylesSidebarPane.createExclamationMark = function(property) | 60 WebInspector.StylesSidebarPane.createExclamationMark = function(property) |
| 59 { | 61 { |
| 60 var exclamationElement = createElement("label", "dt-icon-label"); | 62 var exclamationElement = createElement("label", "dt-icon-label"); |
| 61 exclamationElement.className = "exclamation-mark"; | 63 exclamationElement.className = "exclamation-mark"; |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 if (hasUnknownVendorPrefix(value)) | 104 if (hasUnknownVendorPrefix(value)) |
| 103 return true; | 105 return true; |
| 104 | 106 |
| 105 return false; | 107 return false; |
| 106 } | 108 } |
| 107 | 109 |
| 108 WebInspector.StylesSidebarPane.prototype = { | 110 WebInspector.StylesSidebarPane.prototype = { |
| 109 /** | 111 /** |
| 110 * @param {!WebInspector.Event} event | 112 * @param {!WebInspector.Event} event |
| 111 */ | 113 */ |
| 114 _onSourceMapAttachedOrDetached: function(event) |
| 115 { |
| 116 var header = /** @type {!WebInspector.CSSStyleSheetHeader} */(event.data
); |
| 117 var sourceMap = header.cssModel().sourceMapForHeader(header); |
| 118 if (!sourceMap || sourceMap.editable()) |
| 119 this.update(); |
| 120 }, |
| 121 |
| 122 /** |
| 123 * @param {!WebInspector.Event} event |
| 124 */ |
| 112 _onLayoutEditorChange: function(event) | 125 _onLayoutEditorChange: function(event) |
| 113 { | 126 { |
| 114 var cssModel = /** @type {!WebInspector.CSSModel} */(event.target); | 127 var cssModel = /** @type {!WebInspector.CSSModel} */(event.target); |
| 115 var styleSheetId = event.data["id"]; | 128 var styleSheetId = event.data["id"]; |
| 116 var sourceRange = /** @type {!CSSAgent.SourceRange} */(event.data["range
"]); | 129 var sourceRange = /** @type {!CSSAgent.SourceRange} */(event.data["range
"]); |
| 117 var range = WebInspector.TextRange.fromObject(sourceRange); | 130 var range = WebInspector.TextRange.fromObject(sourceRange); |
| 118 this._decorator = new WebInspector.PropertyChangeHighlighter(this, cssMo
del, styleSheetId, range); | 131 this._decorator = new WebInspector.PropertyChangeHighlighter(this, cssMo
del, styleSheetId, range); |
| 119 this.update(); | 132 this.update(); |
| 120 }, | 133 }, |
| 121 | 134 |
| (...skipping 688 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 810 // Prevent editing the user agent and user rules. | 823 // Prevent editing the user agent and user rules. |
| 811 if (rule.isUserAgent() || rule.isInjected()) { | 824 if (rule.isUserAgent() || rule.isInjected()) { |
| 812 this.editable = false; | 825 this.editable = false; |
| 813 } else { | 826 } else { |
| 814 // Check this is a real CSSRule, not a bogus object coming from WebI
nspector.BlankStylePropertiesSection. | 827 // Check this is a real CSSRule, not a bogus object coming from WebI
nspector.BlankStylePropertiesSection. |
| 815 if (rule.styleSheetId) | 828 if (rule.styleSheetId) |
| 816 this.navigable = !!rule.resourceURL(); | 829 this.navigable = !!rule.resourceURL(); |
| 817 } | 830 } |
| 818 } | 831 } |
| 819 | 832 |
| 833 this._isSASSStyle = false; |
| 834 var header = style.styleSheetId ? style.cssModel().styleSheetHeaderForId(sty
le.styleSheetId) : null; |
| 835 if (header) { |
| 836 var sourceMap = header.cssModel().sourceMapForHeader(header); |
| 837 this._isSASSStyle = sourceMap ? sourceMap.editable() : false; |
| 838 } |
| 839 this.element.classList.toggle("sass-style", this._isSASSStyle); |
| 840 |
| 820 this._mediaListElement = this._titleElement.createChild("div", "media-list m
edia-matches"); | 841 this._mediaListElement = this._titleElement.createChild("div", "media-list m
edia-matches"); |
| 821 this._selectorRefElement = this._titleElement.createChild("div", "styles-sec
tion-subtitle"); | 842 this._selectorRefElement = this._titleElement.createChild("div", "styles-sec
tion-subtitle"); |
| 822 this._updateMediaList(); | 843 this._updateMediaList(); |
| 823 this._updateRuleOrigin(); | 844 this._updateRuleOrigin(); |
| 824 this._titleElement.appendChild(selectorContainer); | 845 this._titleElement.appendChild(selectorContainer); |
| 825 this._selectorContainer = selectorContainer; | 846 this._selectorContainer = selectorContainer; |
| 826 | 847 |
| 827 if (this.navigable) | 848 if (this.navigable) |
| 828 this.element.classList.add("navigable"); | 849 this.element.classList.add("navigable"); |
| 829 | 850 |
| (...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1295 event.consume(true); | 1316 event.consume(true); |
| 1296 return; | 1317 return; |
| 1297 } | 1318 } |
| 1298 var uiLocation = WebInspector.cssWorkspaceBinding.rawLocationToUILoc
ation(location); | 1319 var uiLocation = WebInspector.cssWorkspaceBinding.rawLocationToUILoc
ation(location); |
| 1299 if (uiLocation) | 1320 if (uiLocation) |
| 1300 WebInspector.Revealer.reveal(uiLocation); | 1321 WebInspector.Revealer.reveal(uiLocation); |
| 1301 event.consume(true); | 1322 event.consume(true); |
| 1302 return; | 1323 return; |
| 1303 } | 1324 } |
| 1304 | 1325 |
| 1326 if (!this.editable || this._isSASSStyle) |
| 1327 return; |
| 1328 |
| 1305 var config = new WebInspector.InplaceEditor.Config(this._editingMediaCom
mitted.bind(this, media), this._editingMediaCancelled.bind(this, element), undef
ined, this._editingMediaBlurHandler.bind(this)); | 1329 var config = new WebInspector.InplaceEditor.Config(this._editingMediaCom
mitted.bind(this, media), this._editingMediaCancelled.bind(this, element), undef
ined, this._editingMediaBlurHandler.bind(this)); |
| 1306 WebInspector.InplaceEditor.startEditing(element, config); | 1330 WebInspector.InplaceEditor.startEditing(element, config); |
| 1307 | 1331 |
| 1308 element.getComponentSelection().setBaseAndExtent(element, 0, element, 1)
; | 1332 element.getComponentSelection().setBaseAndExtent(element, 0, element, 1)
; |
| 1309 this._parentPane.setEditingStyle(true); | 1333 this._parentPane.setEditingStyle(true); |
| 1310 var parentMediaElement = element.enclosingNodeOrSelfWithClass("media"); | 1334 var parentMediaElement = element.enclosingNodeOrSelfWithClass("media"); |
| 1311 parentMediaElement.classList.add("editing-media"); | 1335 parentMediaElement.classList.add("editing-media"); |
| 1312 | 1336 |
| 1313 event.consume(true); | 1337 event.consume(true); |
| 1314 }, | 1338 }, |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1402 WebInspector.Revealer.reveal(uiLocation); | 1426 WebInspector.Revealer.reveal(uiLocation); |
| 1403 event.consume(true); | 1427 event.consume(true); |
| 1404 return; | 1428 return; |
| 1405 } | 1429 } |
| 1406 this._startEditingOnMouseEvent(); | 1430 this._startEditingOnMouseEvent(); |
| 1407 event.consume(true); | 1431 event.consume(true); |
| 1408 }, | 1432 }, |
| 1409 | 1433 |
| 1410 _startEditingOnMouseEvent: function() | 1434 _startEditingOnMouseEvent: function() |
| 1411 { | 1435 { |
| 1412 if (!this.editable) | 1436 if (!this.editable || this._isSASSStyle) |
| 1413 return; | 1437 return; |
| 1414 | 1438 |
| 1415 var rule = this._style.parentRule; | 1439 var rule = this._style.parentRule; |
| 1416 if (!rule && !this.propertiesTreeOutline.rootElement().childCount()) { | 1440 if (!rule && !this.propertiesTreeOutline.rootElement().childCount()) { |
| 1417 this.addNewBlankProperty().startEditing(); | 1441 this.addNewBlankProperty().startEditing(); |
| 1418 return; | 1442 return; |
| 1419 } | 1443 } |
| 1420 | 1444 |
| 1421 if (!rule) | 1445 if (!rule) |
| 1422 return; | 1446 return; |
| (...skipping 1667 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3090 WebInspector.context.addFlavorChangeListener(WebInspector.DOMNode, onNodeCha
nged); | 3114 WebInspector.context.addFlavorChangeListener(WebInspector.DOMNode, onNodeCha
nged); |
| 3091 onNodeChanged(); | 3115 onNodeChanged(); |
| 3092 return button; | 3116 return button; |
| 3093 | 3117 |
| 3094 function onNodeChanged() | 3118 function onNodeChanged() |
| 3095 { | 3119 { |
| 3096 var node = WebInspector.context.flavor(WebInspector.DOMNode); | 3120 var node = WebInspector.context.flavor(WebInspector.DOMNode); |
| 3097 button.setEnabled(!!node); | 3121 button.setEnabled(!!node); |
| 3098 } | 3122 } |
| 3099 } | 3123 } |
| OLD | NEW |