Changeset 196746 in webkit
- Timestamp:
- Feb 17, 2016 10:37:45 PM (8 years ago)
- Location:
- trunk/Source/WebInspectorUI
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebInspectorUI/ChangeLog
r196743 r196746 1 2016-02-17 Devin Rousso <dcrousso+webkit@gmail.com> 2 3 Web Inspector: In the styles sidebar, Option-clicking on --css-variable should jump to its definition 4 https://bugs.webkit.org/show_bug.cgi?id=154082 5 <rdar://problem/24593361> 6 7 Reviewed by Timothy Hatcher. 8 9 * UserInterface/Views/CSSStyleDeclarationTextEditor.js: 10 (WebInspector.CSSStyleDeclarationTextEditor.prototype.tokenTrackingControllerHighlightedRangeWasClicked.showRangeInSourceCode): 11 (WebInspector.CSSStyleDeclarationTextEditor.prototype.tokenTrackingControllerHighlightedRangeWasClicked): 12 Now tests to see if the highlighted token was a CSS variable and if 13 so, attempts to show the declaration of the CSS variable instead of 14 the location where it is used. 15 1 16 2016-02-17 Nikita Vasilyev <nvasilyev@apple.com> 2 17 -
trunk/Source/WebInspectorUI/UserInterface/Views/CSSStyleDeclarationTextEditor.js
r196184 r196746 1623 1623 tokenTrackingControllerHighlightedRangeWasClicked(tokenTrackingController) 1624 1624 { 1625 console.assert(this._style.ownerRule.sourceCodeLocation); 1626 if (!this._style.ownerRule.sourceCodeLocation) 1627 return; 1625 let sourceCodeLocation = this._style.ownerRule.sourceCodeLocation; 1626 console.assert(sourceCodeLocation); 1627 if (!sourceCodeLocation) 1628 return; 1629 1630 let candidate = tokenTrackingController.candidate; 1631 console.assert(candidate); 1632 if (!candidate) 1633 return; 1634 1635 let token = candidate.hoveredToken; 1628 1636 1629 1637 // Special case command clicking url(...) links. 1630 var token = this._tokenTrackingController.candidate.hoveredToken; 1631 if (/\blink\b/.test(token.type)) { 1632 var url = token.string; 1633 var baseURL = this._style.ownerRule.sourceCodeLocation.sourceCode.url; 1638 if (token && /\blink\b/.test(token.type)) { 1639 let url = token.string; 1640 let baseURL = sourceCodeLocation.sourceCode.url; 1634 1641 WebInspector.openURL(absoluteURL(url, baseURL)); 1635 1642 return; 1643 } 1644 1645 function showRangeInSourceCode(sourceCode, range) 1646 { 1647 if (!sourceCode || !range) 1648 return false; 1649 1650 WebInspector.showSourceCodeLocation(sourceCode.createSourceCodeLocation(range.startLine, range.startColumn)); 1651 return true; 1652 } 1653 1654 // Special case option clicking CSS variables. 1655 if (token && /\bvariable-2\b/.test(token.type)) { 1656 let property = this._style.nodeStyles.effectivePropertyForName(token.string); 1657 if (property && showRangeInSourceCode(property.ownerStyle.ownerRule.sourceCodeLocation.sourceCode, property.styleSheetTextRange)) 1658 return; 1636 1659 } 1637 1660 1638 1661 // Jump to the rule if we can't find a property. 1639 1662 // Find a better source code location from the property that was clicked. 1640 var sourceCodeLocation = this._style.ownerRule.sourceCodeLocation; 1641 var marks = this._codeMirror.findMarksAt(this._tokenTrackingController.candidate.hoveredTokenRange.start); 1642 for (var i = 0; i < marks.length; ++i) { 1643 var mark = marks[i]; 1644 var property = mark.__cssProperty; 1645 if (property) { 1646 var sourceCode = sourceCodeLocation.sourceCode; 1647 var styleSheetTextRange = property.styleSheetTextRange; 1648 sourceCodeLocation = sourceCode.createSourceCodeLocation(styleSheetTextRange.startLine, styleSheetTextRange.startColumn); 1649 } 1650 } 1651 1652 WebInspector.showSourceCodeLocation(sourceCodeLocation); 1663 let marks = this._codeMirror.findMarksAt(candidate.hoveredTokenRange.start); 1664 for (let mark of marks) { 1665 let property = mark.__cssProperty; 1666 if (property && showRangeInSourceCode(sourceCodeLocation.sourceCode, property.styleSheetTextRange)) 1667 return; 1668 } 1653 1669 } 1654 1670
Note: See TracChangeset
for help on using the changeset viewer.