Changeset 185720 in webkit
- Timestamp:
- Jun 18, 2015, 1:44:01 PM (11 years ago)
- Location:
- trunk/Source/WebInspectorUI
- Files:
-
- 3 edited
-
ChangeLog (modified) (1 diff)
-
Localizations/en.lproj/localizedStrings.js (modified) (1 diff)
-
UserInterface/Views/CSSStyleDeclarationSection.js (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebInspectorUI/ChangeLog
r185716 r185720 1 2015-06-18 Devin Rousso <drousso@apple.com> 2 3 Web Inspector: Ability to Copy entire CSS Rule from Styles Sidebar 4 https://bugs.webkit.org/show_bug.cgi?id=138812 5 6 Reviewed by Timothy Hatcher. 7 8 * Localizations/en.lproj/localizedStrings.js: 9 * UserInterface/Views/CSSStyleDeclarationSection.js: 10 (WebInspector.CSSStyleDeclarationSection): Right clicking on the header of a rule will replcae the default context menu to allow copying of the entire rule to the clipboard. 11 (WebInspector.CSSStyleDeclarationSection.prototype._handleContextMenuEvent): Creates a new context menu to copy the entire CSS rule. 12 (WebInspector.CSSStyleDeclarationSection.prototype._generateCSSRuleString): Generates a string representing the formatted CSS rule. 13 1 14 2015-06-18 Joseph Pecoraro <pecoraro@apple.com> 2 15 -
trunk/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js
r185255 r185720 128 128 localizedStrings["Copy Path to Property"] = "Copy Path to Property"; 129 129 localizedStrings["Copy Row"] = "Copy Row"; 130 localizedStrings["Copy as HTML"] = "Copy as HTML"; 130 localizedStrings["Copy gs["New TaCopy = "New Tab"; 131 localizedStrCopy as HTML"] = "Copy as HTML"; 131 132 localizedStrings["Could not fetch properties. Object may no longer exist."] = "Could not fetch properties. Object may no longer exist."; 132 133 localizedStrings["Create a new tab"] = "Create a new tab"; -
trunk/Source/WebInspectorUI/UserInterface/Views/CSSStyleDeclarationSection.js
r185279 r185720 107 107 108 108 this.refresh(); 109 110 this._headerElement.addEventListener("contextmenu", this._handleContextMenuEvent.bind(this)); 109 111 }; 110 112 … … 291 293 // Private 292 294 295 _handleContextMenuEvent: function(event) 296 { 297 if (window.getSelection().toString().length) 298 return; 299 300 var contextMenu = new WebInspector.ContextMenu(event); 301 302 contextMenu.appendItem(WebInspector.UIString("Copy Rule"), function() { 303 InspectorFrontendHost.copyText(this._generateCSSRuleString()); 304 }.bind(this)); 305 306 contextMenu.show(); 307 }, 308 309 _generateCSSRuleString: function() 310 { 311 var numMediaQueries = 0; 312 var styleText = ""; 313 314 if (this._style.ownerRule) { 315 var mediaList = this._style.ownerRule.mediaList; 316 if (mediaList.length) { 317 numMediaQueries = mediaList.length; 318 319 for (var i = numMediaQueries - 1; i >= 0; --i) 320 styleText += " ".repeat(numMediaQueries - i - 1) + "@media " + mediaList[i].text + " {\n"; 321 } 322 323 styleText += " ".repeat(numMediaQueries) + this._style.ownerRule.selectorText; 324 } else 325 styleText += this._selectorElement.textContent; 326 327 styleText += " {\n"; 328 329 for (var property of this._style.properties) { 330 styleText += " ".repeat(numMediaQueries + 1) + property.text.trim(); 331 332 if (!styleText.endsWith(";")) 333 styleText += ";"; 334 335 styleText += "\n"; 336 } 337 338 for (var i = numMediaQueries; i > 0; --i) 339 styleText += " ".repeat(i) + "}\n"; 340 341 styleText += "}"; 342 343 return styleText; 344 }, 345 293 346 _commitSelector: function(mutations) 294 347 {
Note:
See TracChangeset
for help on using the changeset viewer.