Changeset 217258 in webkit
- Timestamp:
- May 22, 2017 4:44:49 PM (7 years ago)
- Location:
- trunk/Source/WebInspectorUI
- Files:
-
- 1 added
- 18 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebInspectorUI/ChangeLog
r217248 r217258 1 2017-05-22 Devin Rousso <drousso@apple.com> 2 3 Web Inspector: New CSS Rules should go into a new Stylesheet Resource that can be viewed/edited/saved 4 https://bugs.webkit.org/show_bug.cgi?id=138810 5 6 Reviewed by Joseph Pecoraro. 7 8 * Localizations/en.lproj/localizedStrings.js: 9 10 * UserInterface/Controllers/CSSStyleManager.js: 11 (WebInspector.CSSStyleManager): 12 (WebInspector.CSSStyleManager.prototype.preferredInspectorStyleSheetForFrame): 13 (WebInspector.CSSStyleManager.prototype._updateResourceContent.fetchedStyleSheetContent): 14 Manually dispatch a change event for modifications to CSSStyleSheet objects since they are 15 not covered by the listener for Resource changes. 16 17 * UserInterface/Main.html: 18 Include WebInspector.CSSStyleSheetTreeElement. 19 20 * UserInterface/Models/Collection.js: 21 (WebInspector.Collection.TypeVerifier): 22 * UserInterface/Models/ResourceCollection.js: 23 (WebInspector.ResourceCollection.TypeVerifier.Stylesheet): 24 Add TypeVerifier for CSSStyleSheet. 25 26 * UserInterface/Models/DOMNodeStyles.js: 27 (WebInspector.DOMNodeStyles.prototype._parseRulePayload): 28 Manually create a SourceCodeLocation object for Inspector Style Sheets. 29 30 * UserInterface/Views/CSSStyleSheetTreeElement.js: Added. 31 (WebInspector.CSSStyleSheetTreeElement): 32 33 * UserInterface/Views/ResourceIcons.css: 34 (:matches(.resource-icon.resource-type-stylesheet, .stylessheet-icon) .icon): 35 36 * UserInterface/Views/FrameTreeElement.js: 37 (WebInspector.FrameTreeElement.forwardingConstructor): 38 (WebInspector.FrameTreeElement): 39 (WebInspector.FrameTreeElement.prototype.onattach): 40 (WebInspector.FrameTreeElement.prototype.ondetach): 41 (WebInspector.FrameTreeElement.prototype.onpopulate): 42 (WebInspector.FrameTreeElement.prototype._styleSheetAdded): 43 * UserInterface/Views/ResourceSidebarPanel.js: 44 (WebInspector.ResourceSidebarPanel): 45 (WebInspector.ResourceSidebarPanel.prototype._styleSheetAdded): 46 (WebInspector.ResourceSidebarPanel.prototype._treeSelectionDidChange): 47 Listen for the creation of CSSStyleSheet objects and add them to the sidebar if they are an 48 Inspector Style Sheet. Regular style sheets are added via their respective resources. 49 50 * UserInterface/Views/NavigationSidebarPanel.js: 51 (WebInspector.NavigationSidebarPanel.prototype._isTreeElementWithoutRepresentedObject): 52 Prevent CSSStyleSheetTreeElement instances from attempting to save state to a cookie. 53 54 * UserInterface/Base/Main.js: 55 (WebInspector.tabContentViewClassForRepresentedObject): 56 (WebInspector.createSourceCodeLocationLink): 57 * UserInterface/Views/ContentView.js: 58 (WebInspector.ContentView.createFromRepresentedObject): 59 (WebInspector.ContentView.isViewable): 60 * UserInterface/Views/CSSStyleDeclarationSection.js: 61 (WebInspector.CSSStyleDeclarationSection.prototype.refresh): 62 * UserInterface/Views/ResourcesTabContentView.js: 63 (WebInspector.ResourcesTabContentView.prototype.canShowRepresentedObject): 64 * UserInterface/Views/ResourceContentView.js: 65 (WebInspector.ResourceContentView): 66 * UserInterface/Views/SourceCodeTextEditor.js: 67 (WebInspector.SourceCodeTextEditor.prototype._prepareEditorForInitialContent): 68 (WebInspector.SourceCodeTextEditor.prototype._looselyMatchesSourceCodeLocation): 69 (WebInspector.SourceCodeTextEditor.prototype._matchesSourceCodeLocation): 70 * UserInterface/Views/TextResourceContentView.js: 71 (WebInspector.TextResourceContentView): 72 (WebInspector.TextResourceContentView.prototype.get supportsSave): 73 (WebInspector.TextResourceContentView.prototype.get saveData): 74 (WebInspector.TextResourceContentView.prototype._contentWillPopulate): 75 (WebInspector.TextResourceContentView.prototype._shouldBeEditable): 76 Support editing and saving an Inspector Style Sheet via its CSSStyleSheet object. 77 1 78 2017-05-22 Brian Burg <bburg@apple.com> 2 79 -
trunk/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js
r216629 r217258 461 461 localizedStrings["Input: "] = "Input: "; 462 462 localizedStrings["Inset"] = "Inset"; 463 localizedStrings["Inspector Style Sheet"] = "Inspector Style Sheet"; 463 464 localizedStrings["Instances"] = "Instances"; 464 465 localizedStrings["Invalid"] = "Invalid"; -
trunk/Source/WebInspectorUI/UserInterface/Base/Main.js
r217248 r217258 1126 1126 } 1127 1127 1128 if (representedObject instanceof WebInspector.Frame || representedObject instanceof WebInspector.Resource || representedObject instanceof WebInspector.Script) 1128 if (representedObject instanceof WebInspector.Frame 1129 || representedObject instanceof WebInspector.Resource 1130 || representedObject instanceof WebInspector.Script 1131 || representedObject instanceof WebInspector.StyleSheet) 1129 1132 return WebInspector.ResourcesTabContentView; 1130 1133 … … 2314 2317 linkElement.appendChild(WebInspector.createGoToArrowButton()); 2315 2318 else 2316 sourceCodeLocation.populateLiveDisplayLocationString(linkElement, "textContent" );2319 sourceCodeLocation.populateLiveDisplayLocationString(linkElement, "textContent", options.columnStyle, options.nameStyle, options.prefix); 2317 2320 2318 2321 if (options.dontFloat) -
trunk/Source/WebInspectorUI/UserInterface/Controllers/CSSStyleManager.js
r208779 r217258 168 168 } 169 169 170 preferredInspectorStyleSheetForFrame(frame, callback )170 preferredInspectorStyleSheetForFrame(frame, callback, doNotCreateIfMissing) 171 171 { 172 172 var inspectorStyleSheets = this._inspectorStyleSheetsForFrame(frame); … … 177 177 } 178 178 } 179 180 if (doNotCreateIfMissing) 181 return; 179 182 180 183 if (CSSAgent.createStyleSheet) { … … 495 498 function fetchedStyleSheetContent(parameters) 496 499 { 497 var styleSheet = parameters.sourceCode; 498 var content = parameters.content; 499 500 styleSheet.__pendingChangeTimeout = undefined; 501 502 console.assert(styleSheet.url); 503 if (!styleSheet.url) 504 return; 505 506 var resource = styleSheet.parentFrame.resourceForURL(styleSheet.url); 507 if (!resource) 508 return; 509 510 // Only try to update stylesheet resources. Other resources, like documents, can contain 511 // multiple stylesheets and we don't have the source ranges to update those. 512 if (resource.type !== WebInspector.Resource.Type.Stylesheet) 513 return; 514 515 if (resource.__ignoreNextUpdateResourceContent) { 516 resource.__ignoreNextUpdateResourceContent = false; 517 return; 518 } 519 520 this._ignoreResourceContentDidChangeEventForResource = resource; 521 WebInspector.branchManager.currentBranch.revisionForRepresentedObject(resource).content = content; 500 let representedObject = parameters.sourceCode; 501 representedObject.__pendingChangeTimeout = undefined; 502 503 console.assert(representedObject.url); 504 if (!representedObject.url) 505 return; 506 507 if (!styleSheet.isInspectorStyleSheet()) { 508 representedObject = representedObject.parentFrame.resourceForURL(representedObject.url); 509 if (!representedObject) 510 return; 511 512 // Only try to update stylesheet resources. Other resources, like documents, can contain 513 // multiple stylesheets and we don't have the source ranges to update those. 514 if (representedObject.type !== WebInspector.Resource.Type.Stylesheet) 515 return; 516 } 517 518 if (representedObject.__ignoreNextUpdateResourceContent) { 519 representedObject.__ignoreNextUpdateResourceContent = false; 520 return; 521 } 522 523 this._ignoreResourceContentDidChangeEventForResource = representedObject; 524 525 let revision = WebInspector.branchManager.currentBranch.revisionForRepresentedObject(representedObject); 526 if (styleSheet.isInspectorStyleSheet()) { 527 revision.content = representedObject.content; 528 styleSheet.dispatchEventToListeners(WebInspector.SourceCode.Event.ContentDidChange); 529 } else 530 revision.content = parameters.content; 531 522 532 this._ignoreResourceContentDidChangeEventForResource = null; 523 533 } -
trunk/Source/WebInspectorUI/UserInterface/Main.html
r216147 r217258 507 507 <script src="Views/CSSStyleDeclarationTextEditor.js"></script> 508 508 <script src="Views/CSSStyleDetailsSidebarPanel.js"></script> 509 <script src="Views/CSSStyleSheetTreeElement.js"></script> 509 510 <script src="Views/CallFrameTreeElement.js"></script> 510 511 <script src="Views/CallFrameView.js"></script> -
trunk/Source/WebInspectorUI/UserInterface/Models/Collection.js
r208246 r217258 117 117 Resource: (object) => object instanceof WebInspector.Resource, 118 118 Script: (object) => object instanceof WebInspector.Script, 119 CSSStyleSheet: (object) => object instanceof WebInspector.CSSStyleSheet, 119 120 }; -
trunk/Source/WebInspectorUI/UserInterface/Models/DOMNodeStyles.js
r213961 r217258 766 766 } 767 767 768 if (styleSheet) 768 if (styleSheet) { 769 if (!sourceCodeLocation && styleSheet.isInspectorStyleSheet()) 770 sourceCodeLocation = styleSheet.createSourceCodeLocation(sourceRange.startLine, sourceRange.startColumn) 771 769 772 sourceCodeLocation = styleSheet.offsetSourceCodeLocation(sourceCodeLocation); 773 } 770 774 771 775 var mediaList = []; -
trunk/Source/WebInspectorUI/UserInterface/Models/ResourceCollection.js
r209629 r217258 189 189 WebInspector.ResourceCollection.TypeVerifier = { 190 190 Document: (object) => WebInspector.Collection.TypeVerifier.Resource(object) && object.type === WebInspector.Resource.Type.Document, 191 Stylesheet: (object) => WebInspector.Collection.TypeVerifier.Resource(object) && object.type === WebInspector.Resource.Type.Stylesheet, 191 Stylesheet: (object) => { 192 if (WebInspector.Collection.TypeVerifier.CSSStyleSheet(object)) 193 return true; 194 return WebInspector.Collection.TypeVerifier.Resource(object) && object.type === WebInspector.Resource.Type.Stylesheet 195 }, 192 196 Image: (object) => WebInspector.Collection.TypeVerifier.Resource(object) && object.type === WebInspector.Resource.Type.Image, 193 197 Font: (object) => WebInspector.Collection.TypeVerifier.Resource(object) && object.type === WebInspector.Resource.Type.Font, -
trunk/Source/WebInspectorUI/UserInterface/Views/CSSStyleDeclarationSection.js
r216692 r217258 249 249 250 250 if (this._style.ownerRule.sourceCodeLocation) { 251 const options = {251 let options = { 252 252 dontFloat: true, 253 253 ignoreNetworkTab: true, 254 254 ignoreSearchTab: true, 255 255 }; 256 if (this._style.ownerStyleSheet.isInspectorStyleSheet()) { 257 options.nameStyle = WebInspector.SourceCodeLocation.NameStyle.None; 258 options.prefix = WebInspector.UIString("Inspector Style Sheet") + ":"; 259 } 260 256 261 let sourceCodeLink = WebInspector.createSourceCodeLocationLink(this._style.ownerRule.sourceCodeLocation, options); 257 262 this._originElement.appendChild(sourceCodeLink); -
trunk/Source/WebInspectorUI/UserInterface/Views/ContentView.js
r216147 r217258 55 55 return new WebInspector.ScriptContentView(representedObject, extraArguments); 56 56 57 if (representedObject instanceof WebInspector.CSSStyleSheet) 58 return new WebInspector.TextResourceContentView(representedObject, extraArguments); 59 57 60 if (representedObject instanceof WebInspector.TimelineRecording) 58 61 return new WebInspector.TimelineRecordingContentView(representedObject, extraArguments); … … 235 238 if (representedObject instanceof WebInspector.Script) 236 239 return true; 240 if (representedObject instanceof WebInspector.CSSStyleSheet) 241 return true; 237 242 if (representedObject instanceof WebInspector.TimelineRecording) 238 243 return true; -
trunk/Source/WebInspectorUI/UserInterface/Views/FrameTreeElement.js
r214354 r217258 54 54 this.registerFolderizeSettings("extra-scripts", WebInspector.UIString("Extra Scripts"), this._frame.extraScriptCollection, WebInspector.ScriptTreeElement); 55 55 56 function forwardingConstructor(representedObject, ...extraArguments) { 57 if (representedObject instanceof WebInspector.CSSStyleSheet) 58 return new WebInspector.CSSStyleSheetTreeElement(representedObject, ...extraArguments); 59 return new WebInspector.ResourceTreeElement(representedObject, ...extraArguments); 60 } 61 56 62 for (let [key, value] of Object.entries(WebInspector.Resource.Type)) { 57 63 let folderName = WebInspector.Resource.displayNameForType(value, true); 58 64 59 let treeElementConstructor = WebInspector.ResourceTreeElement;65 let treeElementConstructor = forwardingConstructor; 60 66 if (value === WebInspector.Resource.Type.WebSocket) 61 67 treeElementConstructor = WebInspector.WebSocketResourceTreeElement; 62 68 63 this.registerFolderizeSettings(key, folderName, this._frame.resourceCollectionForType(value), treeElementConstructor);69 this.registerFolderizeSettings(key, folderName, this._frame.resourceCollectionForType(value), forwardingConstructor); 64 70 } 65 71 … … 114 120 // Immediate superclasses are skipped, since Frames handle their own SourceMapResources. 115 121 WebInspector.GeneralTreeElement.prototype.onattach.call(this); 122 123 WebInspector.cssStyleManager.addEventListener(WebInspector.CSSStyleManager.Event.StyleSheetAdded, this._styleSheetAdded, this); 124 } 125 126 ondetach() 127 { 128 WebInspector.cssStyleManager.removeEventListener(WebInspector.CSSStyleManager.Event.StyleSheetAdded, this._styleSheetAdded, this); 129 130 super.ondetach(); 116 131 } 117 132 … … 171 186 this.addChildForRepresentedObject(extraScript); 172 187 } 188 189 const doNotCreateIfMissing = true; 190 WebInspector.cssStyleManager.preferredInspectorStyleSheetForFrame(this._frame, this.addRepresentedObjectToNewChildQueue.bind(this), doNotCreateIfMissing); 173 191 } 174 192 … … 254 272 this._frame.domTree.requestContentFlowList(); 255 273 } 274 275 _styleSheetAdded(event) 276 { 277 if (!event.data.styleSheet.isInspectorStyleSheet()) 278 return; 279 280 this.addRepresentedObjectToNewChildQueue(event.data.styleSheet); 281 } 256 282 }; -
trunk/Source/WebInspectorUI/UserInterface/Views/NavigationSidebarPanel.js
r215113 r217258 646 646 || treeElement instanceof WebInspector.DOMBreakpointTreeElement 647 647 || treeElement instanceof WebInspector.XHRBreakpointTreeElement 648 || treeElement instanceof WebInspector.CSSStyleSheetTreeElement 648 649 || typeof treeElement.representedObject === "string" 649 650 || treeElement.representedObject instanceof String; -
trunk/Source/WebInspectorUI/UserInterface/Views/ResourceContentView.js
r216138 r217258 28 28 constructor(resource, styleClassName) 29 29 { 30 console.assert(resource instanceof WebInspector.Resource , resource);30 console.assert(resource instanceof WebInspector.Resource || resource instanceof WebInspector.CSSStyleSheet, resource); 31 31 console.assert(typeof styleClassName === "string"); 32 32 -
trunk/Source/WebInspectorUI/UserInterface/Views/ResourceIcons.css
r217067 r217258 40 40 } 41 41 42 .resource-icon.resource-type-stylesheet.icon {42 :matches(.resource-icon.resource-type-stylesheet, .stylesheet-icon) .icon { 43 43 content: image-set(url(../Images/DocumentCSS.png) 1x, url(../Images/DocumentCSS@2x.png) 2x); 44 44 } -
trunk/Source/WebInspectorUI/UserInterface/Views/ResourceSidebarPanel.js
r215630 r217258 64 64 WebInspector.debuggerManager.addEventListener(WebInspector.DebuggerManager.Event.ScriptsCleared, this._scriptsCleared, this); 65 65 66 WebInspector.cssStyleManager.addEventListener(WebInspector.CSSStyleManager.Event.StyleSheetAdded, this._styleSheetAdded, this); 67 66 68 WebInspector.targetManager.addEventListener(WebInspector.TargetManager.Event.TargetRemoved, this._targetRemoved, this); 67 69 … … 393 395 } 394 396 397 _styleSheetAdded(event) 398 { 399 let styleSheet = event.data.styleSheet; 400 if (!styleSheet.isInspectorStyleSheet()) 401 return; 402 403 let frameTreeElement = this.treeElementForRepresentedObject(styleSheet.parentFrame); 404 if (!frameTreeElement) 405 return; 406 407 frameTreeElement.addRepresentedObjectToNewChildQueue(styleSheet); 408 } 409 395 410 _addTargetWithMainResource(target) 396 411 { … … 422 437 || treeElement instanceof WebInspector.ResourceTreeElement 423 438 || treeElement instanceof WebInspector.ScriptTreeElement 439 || treeElement instanceof WebInspector.CSSStyleSheetTreeElement 424 440 || treeElement instanceof WebInspector.ContentFlowTreeElement) { 425 441 const cookie = null; -
trunk/Source/WebInspectorUI/UserInterface/Views/ResourcesTabContentView.js
r212400 r217258 65 65 || representedObject instanceof WebInspector.Resource 66 66 || representedObject instanceof WebInspector.Script 67 || representedObject instanceof WebInspector.CSSStyleSheet 67 68 || representedObject instanceof WebInspector.ContentFlow 68 69 || representedObject instanceof WebInspector.Collection; -
trunk/Source/WebInspectorUI/UserInterface/Views/SourceCodeTextEditor.js
r215630 r217258 517 517 else if (this._sourceCode instanceof WebInspector.Script) 518 518 this.mimeType = "text/javascript"; 519 else if (this._sourceCode instanceof WebInspector.CSSStyleSheet) 520 this.mimeType = "text/css"; 519 521 520 522 // Decide to automatically format the content if it looks minified and it can be formatted. … … 970 972 if (this._sourceCode instanceof WebInspector.SourceMapResource) 971 973 return sourceCodeLocation.displaySourceCode === this._sourceCode; 972 if (this._sourceCode instanceof WebInspector.Resource || this._sourceCode instanceof WebInspector.Script )974 if (this._sourceCode instanceof WebInspector.Resource || this._sourceCode instanceof WebInspector.Script || this._sourceCode instanceof WebInspector.CSSStyleSheet) 973 975 return sourceCodeLocation.sourceCode.url === this._sourceCode.url; 974 976 return false; … … 979 981 if (this._sourceCode instanceof WebInspector.SourceMapResource) 980 982 return sourceCodeLocation.displaySourceCode === this._sourceCode; 981 if (this._sourceCode instanceof WebInspector.Resource )983 if (this._sourceCode instanceof WebInspector.Resource || this._sourceCode instanceof WebInspector.CSSStyleSheet) 982 984 return sourceCodeLocation.sourceCode.url === this._sourceCode.url; 983 985 if (this._sourceCode instanceof WebInspector.Script) -
trunk/Source/WebInspectorUI/UserInterface/Views/TextResourceContentView.js
r214133 r217258 39 39 this._textEditor.addEventListener(WebInspector.SourceCodeTextEditor.Event.ContentWillPopulate, this._contentWillPopulate, this); 40 40 this._textEditor.addEventListener(WebInspector.SourceCodeTextEditor.Event.ContentDidPopulate, this._contentDidPopulate, this); 41 this._textEditor.readOnly = !this._shouldBeEditable(); 41 42 42 43 WebInspector.probeManager.addEventListener(WebInspector.ProbeManager.Event.ProbeSetAdded, this._probeSetsChanged, this); … … 127 128 } 128 129 130 get supportsSave() 131 { 132 return super.supportsSave || this.resource instanceof WebInspector.CSSStyleSheet; 133 } 134 129 135 get saveData() 130 136 { 137 if (this.resource instanceof WebInspector.CSSStyleSheet) 138 return {url: "web-inspector:///InspectorStyleSheet.css", content: this._textEditor.string, forceSaveAs: true}; 131 139 return {url: this.resource.url, content: this._textEditor.string}; 132 140 } … … 183 191 if (this._textEditor.parentView === this) 184 192 return; 185 186 // Check the MIME-type for CSS since Resource.Type.Stylesheet also includes XSL, which we can't edit yet.187 if (this.resource.type === WebInspector.Resource.Type.Stylesheet && this.resource.syntheticMIMEType === "text/css")188 this._textEditor.readOnly = false;189 190 // Allow editing any local file since edits can be saved and reloaded right from the Inspector.191 if (this.resource.urlComponents.scheme === "file")192 this._textEditor.readOnly = false;193 193 194 194 this.element.removeChildren(); … … 275 275 this.dispatchEventToListeners(WebInspector.ContentView.Event.SupplementalRepresentedObjectsDidChange); 276 276 } 277 278 _shouldBeEditable() 279 { 280 if (this.resource instanceof WebInspector.CSSStyleSheet) 281 return true; 282 283 // Check the MIME-type for CSS since Resource.Type.Stylesheet also includes XSL, which we can't edit yet. 284 if (this.resource.type === WebInspector.Resource.Type.Stylesheet && this.resource.syntheticMIMEType === "text/css") 285 return true; 286 287 // Allow editing any local file since edits can be saved and reloaded right from the Inspector. 288 if (this.resource.urlComponents.scheme === "file") 289 return true; 290 291 return false; 292 } 277 293 };
Note: See TracChangeset
for help on using the changeset viewer.