Chromium Code Reviews| 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 WebInspector.StylesSidebarPane._instance = this; |
| 54 | 54 |
| 55 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); |
| 56 WebInspector.context.addFlavorChangeListener(WebInspector.DOMNode, this.onUn doOrRedoHappened, this); | |
|
lushnikov
2016/07/14 00:58:15
s/onUndoOrRedoHappened/forceUpdate will make it ea
pfeldman
2016/07/14 17:26:12
Done.
| |
| 56 } | 57 } |
| 57 | 58 |
| 58 /** | 59 /** |
| 59 * @param {!WebInspector.CSSProperty} property | 60 * @param {!WebInspector.CSSProperty} property |
| 60 * @return {!Element} | 61 * @return {!Element} |
| 61 */ | 62 */ |
| 62 WebInspector.StylesSidebarPane.createExclamationMark = function(property) | 63 WebInspector.StylesSidebarPane.createExclamationMark = function(property) |
| 63 { | 64 { |
| 64 var exclamationElement = createElement("label", "dt-icon-label"); | 65 var exclamationElement = createElement("label", "dt-icon-label"); |
| 65 exclamationElement.className = "exclamation-mark"; | 66 exclamationElement.className = "exclamation-mark"; |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 128 */ | 129 */ |
| 129 revealProperty: function(cssProperty) | 130 revealProperty: function(cssProperty) |
| 130 { | 131 { |
| 131 this._decorator = new WebInspector.PropertyRevealHighlighter(this, cssPr operty); | 132 this._decorator = new WebInspector.PropertyRevealHighlighter(this, cssPr operty); |
| 132 this._decorator.perform(); | 133 this._decorator.perform(); |
| 133 this.update(); | 134 this.update(); |
| 134 }, | 135 }, |
| 135 | 136 |
| 136 onUndoOrRedoHappened: function() | 137 onUndoOrRedoHappened: function() |
| 137 { | 138 { |
| 138 this.setNode(this.node()); | 139 this._stylesPopoverHelper.hide(); |
| 140 this._resetCache(); | |
| 141 this.update(); | |
| 139 }, | 142 }, |
| 140 | 143 |
| 141 /** | 144 /** |
| 142 * @param {!Event} event | 145 * @param {!Event} event |
| 143 */ | 146 */ |
| 144 _onAddButtonLongClick: function(event) | 147 _onAddButtonLongClick: function(event) |
| 145 { | 148 { |
| 146 var cssModel = this.cssModel(); | 149 var cssModel = this.cssModel(); |
| 147 if (!cssModel) | 150 if (!cssModel) |
| 148 return; | 151 return; |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 194 /** | 197 /** |
| 195 * @param {?RegExp} regex | 198 * @param {?RegExp} regex |
| 196 */ | 199 */ |
| 197 onFilterChanged: function(regex) | 200 onFilterChanged: function(regex) |
| 198 { | 201 { |
| 199 this._filterRegex = regex; | 202 this._filterRegex = regex; |
| 200 this._updateFilter(); | 203 this._updateFilter(); |
| 201 }, | 204 }, |
| 202 | 205 |
| 203 /** | 206 /** |
| 204 * @override | |
| 205 * @param {?WebInspector.DOMNode} node | |
| 206 */ | |
| 207 setNode: function(node) | |
| 208 { | |
| 209 this._stylesPopoverHelper.hide(); | |
| 210 node = node ? node.enclosingElementOrSelf() : null; | |
| 211 | |
| 212 this._resetCache(); | |
| 213 WebInspector.ElementsSidebarPane.prototype.setNode.call(this, node); | |
| 214 }, | |
| 215 | |
| 216 /** | |
| 217 * @param {!WebInspector.StylePropertiesSection=} editedSection | 207 * @param {!WebInspector.StylePropertiesSection=} editedSection |
| 218 */ | 208 */ |
| 219 _refreshUpdate: function(editedSection) | 209 _refreshUpdate: function(editedSection) |
| 220 { | 210 { |
| 221 var node = this.node(); | 211 var node = this.node(); |
| 222 if (!node) | 212 if (!node) |
| 223 return; | 213 return; |
| 224 | 214 |
| 225 var fullRefresh = Runtime.experiments.isEnabled("liveSASS"); | 215 var fullRefresh = Runtime.experiments.isEnabled("liveSASS"); |
| 226 for (var section of this.allSections()) { | 216 for (var section of this.allSections()) { |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 284 this.element.classList.toggle("is-editing-style", editing); | 274 this.element.classList.toggle("is-editing-style", editing); |
| 285 this._isEditingStyle = editing; | 275 this._isEditingStyle = editing; |
| 286 }, | 276 }, |
| 287 | 277 |
| 288 /** | 278 /** |
| 289 * @override | 279 * @override |
| 290 * @param {!WebInspector.Event=} event | 280 * @param {!WebInspector.Event=} event |
| 291 */ | 281 */ |
| 292 onCSSModelChanged: function(event) | 282 onCSSModelChanged: function(event) |
| 293 { | 283 { |
| 294 var edit = event && event.data ? /** @type {?WebInspector.CSSModel.Edit} */(event.data.edit) : null; | 284 var edit = event && event.data && event.data.data ? /** @type {?WebInspe ctor.CSSModel.Edit} */(event.data.data.edit) : null; |
| 295 if (edit) { | 285 if (edit) { |
| 296 for (var section of this.allSections()) | 286 for (var section of this.allSections()) |
| 297 section._styleSheetEdited(edit); | 287 section._styleSheetEdited(edit); |
| 298 return; | 288 return; |
| 299 } | 289 } |
| 300 | 290 |
| 301 if (this._userOperation || this._isEditingStyle) | 291 if (this._userOperation || this._isEditingStyle) |
| 302 return; | 292 return; |
| 303 | 293 |
| 304 this._resetCache(); | 294 this._resetCache(); |
| 305 this.update(); | 295 this.update(); |
| 306 }, | 296 }, |
| 307 | 297 |
| 308 /** | 298 /** |
| 309 * @override | |
| 310 */ | |
| 311 onFrameResizedThrottled: function() | |
| 312 { | |
| 313 this.onCSSModelChanged(); | |
| 314 }, | |
| 315 | |
| 316 /** | |
| 317 * @override | |
| 318 * @param {!WebInspector.DOMNode} node | |
| 319 */ | |
| 320 onDOMModelChanged: function(node) | |
| 321 { | |
| 322 // Any attribute removal or modification can affect the styles of "relat ed" nodes. | |
| 323 // Do not touch the styles if they are being edited. | |
| 324 if (this._isEditingStyle || this._userOperation) | |
| 325 return; | |
| 326 | |
| 327 if (!this._canAffectCurrentStyles(node)) | |
| 328 return; | |
| 329 | |
| 330 this._resetCache(); | |
| 331 this.update(); | |
| 332 }, | |
| 333 | |
| 334 /** | |
| 335 * @param {?WebInspector.DOMNode} node | |
| 336 */ | |
| 337 _canAffectCurrentStyles: function(node) | |
| 338 { | |
| 339 var currentNode = this.node(); | |
| 340 return currentNode && (currentNode === node || node.parentNode === curre ntNode.parentNode || node.isAncestor(currentNode)); | |
| 341 }, | |
| 342 | |
| 343 /** | |
| 344 * @param {?WebInspector.CSSMatchedStyles} matchedStyles | 299 * @param {?WebInspector.CSSMatchedStyles} matchedStyles |
| 345 */ | 300 */ |
| 346 _innerRebuildUpdate: function(matchedStyles) | 301 _innerRebuildUpdate: function(matchedStyles) |
| 347 { | 302 { |
| 348 this._linkifier.reset(); | 303 this._linkifier.reset(); |
| 349 this._sectionsContainer.removeChildren(); | 304 this._sectionsContainer.removeChildren(); |
| 350 this._sectionBlocks = []; | 305 this._sectionBlocks = []; |
| 351 | 306 |
| 352 var node = this.node(); | 307 var node = this.node(); |
| 353 if (!matchedStyles || !node) | 308 if (!matchedStyles || !node) |
| (...skipping 1029 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1383 if (success) { | 1338 if (success) { |
| 1384 this._matchedStyles.resetActiveProperties(); | 1339 this._matchedStyles.resetActiveProperties(); |
| 1385 this._parentPane._refreshUpdate(this); | 1340 this._parentPane._refreshUpdate(this); |
| 1386 } | 1341 } |
| 1387 delete this._parentPane._userOperation; | 1342 delete this._parentPane._userOperation; |
| 1388 this._editingMediaTextCommittedForTest(); | 1343 this._editingMediaTextCommittedForTest(); |
| 1389 } | 1344 } |
| 1390 | 1345 |
| 1391 // This gets deleted in finishOperation(), which is called both on succe ss and failure. | 1346 // This gets deleted in finishOperation(), which is called both on succe ss and failure. |
| 1392 this._parentPane._userOperation = true; | 1347 this._parentPane._userOperation = true; |
| 1393 this._parentPane._cssModel.setMediaText(media.styleSheetId, media.range, newContent) | 1348 this._parentPane.cssModel().setMediaText(media.styleSheetId, media.range , newContent) |
| 1394 .then(userCallback.bind(this)); | 1349 .then(userCallback.bind(this)); |
| 1395 }, | 1350 }, |
| 1396 | 1351 |
| 1397 _editingMediaTextCommittedForTest: function() { }, | 1352 _editingMediaTextCommittedForTest: function() { }, |
| 1398 | 1353 |
| 1399 /** | 1354 /** |
| 1400 * @param {!Event} event | 1355 * @param {!Event} event |
| 1401 */ | 1356 */ |
| 1402 _handleSelectorClick: function(event) | 1357 _handleSelectorClick: function(event) |
| 1403 { | 1358 { |
| 1404 if (WebInspector.KeyboardShortcut.eventHasCtrlOrMeta(/** @type {!MouseEv ent} */(event)) && this.navigable && event.target.classList.contains("simple-sel ector")) { | 1359 if (WebInspector.KeyboardShortcut.eventHasCtrlOrMeta(/** @type {!MouseEv ent} */(event)) && this.navigable && event.target.classList.contains("simple-sel ector")) { |
| 1405 this._navigateToSelectorSource(event.target._selectorIndex, true); | 1360 this._navigateToSelectorSource(event.target._selectorIndex, true); |
| 1406 event.consume(true); | 1361 event.consume(true); |
| 1407 return; | 1362 return; |
| 1408 } | 1363 } |
| 1409 this._startEditingOnMouseEvent(); | 1364 this._startEditingOnMouseEvent(); |
| 1410 event.consume(true); | 1365 event.consume(true); |
| 1411 }, | 1366 }, |
| 1412 | 1367 |
| 1413 /** | 1368 /** |
| 1414 * @param {number} index | 1369 * @param {number} index |
| 1415 * @param {boolean} focus | 1370 * @param {boolean} focus |
| 1416 */ | 1371 */ |
| 1417 _navigateToSelectorSource: function(index, focus) | 1372 _navigateToSelectorSource: function(index, focus) |
| 1418 { | 1373 { |
| 1419 var cssModel = this._parentPane._cssModel; | 1374 var cssModel = this._parentPane.cssModel(); |
| 1420 var rule = this._style.parentRule; | 1375 var rule = this._style.parentRule; |
| 1421 var header = cssModel.styleSheetHeaderForId(/** @type {string} */(rule.s tyleSheetId)); | 1376 var header = cssModel.styleSheetHeaderForId(/** @type {string} */(rule.s tyleSheetId)); |
| 1422 if (!header) | 1377 if (!header) |
| 1423 return; | 1378 return; |
| 1424 var rawLocation = new WebInspector.CSSLocation(header, rule.lineNumberIn Source(index), rule.columnNumberInSource(index)); | 1379 var rawLocation = new WebInspector.CSSLocation(header, rule.lineNumberIn Source(index), rule.columnNumberInSource(index)); |
| 1425 var uiLocation = WebInspector.cssWorkspaceBinding.rawLocationToUILocatio n(rawLocation); | 1380 var uiLocation = WebInspector.cssWorkspaceBinding.rawLocationToUILocatio n(rawLocation); |
| 1426 if (uiLocation) | 1381 if (uiLocation) |
| 1427 WebInspector.Revealer.reveal(uiLocation, !focus); | 1382 WebInspector.Revealer.reveal(uiLocation, !focus); |
| 1428 }, | 1383 }, |
| 1429 | 1384 |
| (...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1652 * @extends {WebInspector.StylePropertiesSection} | 1607 * @extends {WebInspector.StylePropertiesSection} |
| 1653 * @param {!WebInspector.StylesSidebarPane} stylesPane | 1608 * @param {!WebInspector.StylesSidebarPane} stylesPane |
| 1654 * @param {!WebInspector.CSSMatchedStyles} matchedStyles | 1609 * @param {!WebInspector.CSSMatchedStyles} matchedStyles |
| 1655 * @param {string} defaultSelectorText | 1610 * @param {string} defaultSelectorText |
| 1656 * @param {string} styleSheetId | 1611 * @param {string} styleSheetId |
| 1657 * @param {!WebInspector.TextRange} ruleLocation | 1612 * @param {!WebInspector.TextRange} ruleLocation |
| 1658 * @param {!WebInspector.CSSStyleDeclaration} insertAfterStyle | 1613 * @param {!WebInspector.CSSStyleDeclaration} insertAfterStyle |
| 1659 */ | 1614 */ |
| 1660 WebInspector.BlankStylePropertiesSection = function(stylesPane, matchedStyles, d efaultSelectorText, styleSheetId, ruleLocation, insertAfterStyle) | 1615 WebInspector.BlankStylePropertiesSection = function(stylesPane, matchedStyles, d efaultSelectorText, styleSheetId, ruleLocation, insertAfterStyle) |
| 1661 { | 1616 { |
| 1662 var rule = WebInspector.CSSStyleRule.createDummyRule(stylesPane._cssModel, d efaultSelectorText); | 1617 var cssModel = /** @type {!WebInspector.CSSModel} */(stylesPane.cssModel()); |
| 1618 var rule = WebInspector.CSSStyleRule.createDummyRule(cssModel, defaultSelect orText); | |
| 1663 WebInspector.StylePropertiesSection.call(this, stylesPane, matchedStyles, ru le.style); | 1619 WebInspector.StylePropertiesSection.call(this, stylesPane, matchedStyles, ru le.style); |
| 1664 this._ruleLocation = ruleLocation; | 1620 this._ruleLocation = ruleLocation; |
| 1665 this._styleSheetId = styleSheetId; | 1621 this._styleSheetId = styleSheetId; |
| 1666 this._selectorRefElement.removeChildren(); | 1622 this._selectorRefElement.removeChildren(); |
| 1667 this._selectorRefElement.appendChild(WebInspector.StylePropertiesSection._li nkifyRuleLocation(this._parentPane._cssModel, this._parentPane._linkifier, style SheetId, this._actualRuleLocation())); | 1623 this._selectorRefElement.appendChild(WebInspector.StylePropertiesSection._li nkifyRuleLocation(cssModel, this._parentPane._linkifier, styleSheetId, this._act ualRuleLocation())); |
| 1668 if (insertAfterStyle && insertAfterStyle.parentRule) | 1624 if (insertAfterStyle && insertAfterStyle.parentRule) |
| 1669 this._createMediaList(insertAfterStyle.parentRule.media); | 1625 this._createMediaList(insertAfterStyle.parentRule.media); |
| 1670 this.element.classList.add("blank-section"); | 1626 this.element.classList.add("blank-section"); |
| 1671 } | 1627 } |
| 1672 | 1628 |
| 1673 WebInspector.BlankStylePropertiesSection.prototype = { | 1629 WebInspector.BlankStylePropertiesSection.prototype = { |
| 1674 /** | 1630 /** |
| 1675 * @return {!WebInspector.TextRange} | 1631 * @return {!WebInspector.TextRange} |
| 1676 */ | 1632 */ |
| 1677 _actualRuleLocation: function() | 1633 _actualRuleLocation: function() |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1749 this._editingSelectorEnded(); | 1705 this._editingSelectorEnded(); |
| 1750 this._markSelectorMatches(); | 1706 this._markSelectorMatches(); |
| 1751 | 1707 |
| 1752 this._editingSelectorCommittedForTest(); | 1708 this._editingSelectorCommittedForTest(); |
| 1753 } | 1709 } |
| 1754 | 1710 |
| 1755 if (newContent) | 1711 if (newContent) |
| 1756 newContent = newContent.trim(); | 1712 newContent = newContent.trim(); |
| 1757 this._parentPane._userOperation = true; | 1713 this._parentPane._userOperation = true; |
| 1758 | 1714 |
| 1759 var cssModel = this._parentPane._cssModel; | 1715 var cssModel = this._parentPane.cssModel(); |
| 1760 var ruleText = this._rulePrefix() + newContent + " {}"; | 1716 var ruleText = this._rulePrefix() + newContent + " {}"; |
| 1761 cssModel.addRule(this._styleSheetId, ruleText, this._ruleLocation) | 1717 cssModel.addRule(this._styleSheetId, ruleText, this._ruleLocation) |
| 1762 .then(onRuleAdded.bind(this)); | 1718 .then(onRuleAdded.bind(this)); |
| 1763 }, | 1719 }, |
| 1764 | 1720 |
| 1765 editingSelectorCancelled: function() | 1721 editingSelectorCancelled: function() |
| 1766 { | 1722 { |
| 1767 delete this._parentPane._userOperation; | 1723 delete this._parentPane._userOperation; |
| 1768 if (!this.isBlank) { | 1724 if (!this.isBlank) { |
| 1769 WebInspector.StylePropertiesSection.prototype.editingSelectorCancell ed.call(this); | 1725 WebInspector.StylePropertiesSection.prototype.editingSelectorCancell ed.call(this); |
| (...skipping 1383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3153 | 3109 |
| 3154 /** | 3110 /** |
| 3155 * @override | 3111 * @override |
| 3156 * @return {!WebInspector.ToolbarItem} | 3112 * @return {!WebInspector.ToolbarItem} |
| 3157 */ | 3113 */ |
| 3158 item: function() | 3114 item: function() |
| 3159 { | 3115 { |
| 3160 return this._button; | 3116 return this._button; |
| 3161 } | 3117 } |
| 3162 } | 3118 } |
| OLD | NEW |