Changeset 217911 in webkit
- Timestamp:
- Jun 7, 2017 4:53:10 PM (7 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r217910 r217911 1 2017-06-07 Devin Rousso <drousso@apple.com> 2 3 Web Inspector: Allow user to choose stylesheet when creating new rules 4 https://bugs.webkit.org/show_bug.cgi?id=172487 5 6 Reviewed by Joseph Pecoraro. 7 8 * inspector/css/add-rule-expected.html: Added. 9 * inspector/css/add-rule.html: Added. 10 1 11 2017-06-07 Youenn Fablet <youenn@apple.com> 2 12 -
trunk/Source/WebCore/ChangeLog
r217910 r217911 1 2017-06-07 Devin Rousso <drousso@apple.com> 2 3 Web Inspector: Allow user to choose stylesheet when creating new rules 4 https://bugs.webkit.org/show_bug.cgi?id=172487 5 6 Reviewed by Joseph Pecoraro. 7 8 New test: inspector/css/add-rule.html 9 10 * inspector/InspectorStyleSheet.cpp: 11 (WebCore::InspectorStyleSheet::addRule): 12 Reparse the content when a new rule is added to a non-inspector origin stylesheet. 13 1 14 2017-06-07 Youenn Fablet <youenn@apple.com> 2 15 -
trunk/Source/WebCore/inspector/InspectorStyleSheet.cpp
r216426 r217911 930 930 return text.releaseException(); 931 931 932 StringBuilder styleSheetText;933 styleSheetText.append(text.releaseReturnValue());934 935 932 auto addRuleResult = m_pageStyleSheet->addRule(selector, emptyString(), std::nullopt); 936 933 if (addRuleResult.hasException()) 937 934 return addRuleResult.releaseException(); 935 936 StringBuilder styleSheetText; 937 styleSheetText.append(text.releaseReturnValue()); 938 939 if (!styleSheetText.isEmpty()) 940 styleSheetText.append('\n'); 941 942 styleSheetText.append(selector); 943 styleSheetText.appendLiteral(" {}"); 944 945 // Using setText() as this operation changes the stylesheet rule set. 946 setText(styleSheetText.toString()); 947 948 // Inspector Style Sheets are always treated as though their parsed data is ready. 949 if (m_origin == Inspector::Protocol::CSS::StyleSheetOrigin::Inspector) 950 fireStyleSheetChanged(); 951 else 952 reparseStyleSheet(styleSheetText.toString()); 953 938 954 ASSERT(m_pageStyleSheet->length()); 939 955 unsigned lastRuleIndex = m_pageStyleSheet->length() - 1; … … 948 964 return Exception { SYNTAX_ERR }; 949 965 } 950 951 if (!styleSheetText.isEmpty())952 styleSheetText.append('\n');953 954 styleSheetText.append(selector);955 styleSheetText.appendLiteral(" {}");956 // Using setText() as this operation changes the stylesheet rule set.957 setText(styleSheetText.toString());958 959 fireStyleSheetChanged();960 966 961 967 return styleRule; -
trunk/Source/WebInspectorUI/ChangeLog
r217843 r217911 1 2017-06-07 Devin Rousso <drousso@apple.com> 2 3 Web Inspector: Allow user to choose stylesheet when creating new rules 4 https://bugs.webkit.org/show_bug.cgi?id=172487 5 6 Reviewed by Joseph Pecoraro. 7 8 * Localizations/en.lproj/localizedStrings.js: 9 * UserInterface/Models/DOMNodeStyles.js: 10 (WebInspector.DOMNodeStyles.prototype.addRule.inspectorStyleSheetAvailable): 11 (WebInspector.DOMNodeStyles.prototype.addRule): 12 * UserInterface/Views/CSSStyleDetailsSidebarPanel.js: 13 (WebInspector.CSSStyleDetailsSidebarPanel.prototype.initialLayout): 14 (WebInspector.CSSStyleDetailsSidebarPanel.prototype._newRuleButtonContextMenu): 15 * UserInterface/Views/RulesStyleDetailsPanel.js: 16 (WebInspector.RulesStyleDetailsPanel.prototype.newRuleButtonClicked): 17 (WebInspector.RulesStyleDetailsPanel.prototype.newRuleButtonContextMenu): 18 * UserInterface/Views/VisualStyleSelectorSection.js: 19 (WebInspector.VisualStyleSelectorSection): 20 (WebInspector.VisualStyleSelectorSection.prototype._addNewRuleContextMenu): 21 (WebInspector.VisualStyleSelectorSection.prototype._addNewRule): Renamed _addNewRuleClick. 22 1 23 2017-06-06 Joseph Pecoraro <pecoraro@apple.com> 2 24 -
trunk/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js
r217733 r217911 113 113 localizedStrings["Automatically continue after evaluating"] = "Automatically continue after evaluating"; 114 114 localizedStrings["Automatically insert newline"] = "Automatically insert newline"; 115 localizedStrings["Available Style Sheets"] = "Available Style Sheets"; 115 116 localizedStrings["Average Time"] = "Average Time"; 116 117 localizedStrings["Back (%s)"] = "Back (%s)"; -
trunk/Source/WebInspectorUI/UserInterface/Models/DOMNodeStyles.js
r217258 r217911 264 264 } 265 265 266 addRule(selector, text )266 addRule(selector, text, styleSheetId) 267 267 { 268 268 selector = selector || this._node.appropriateSelectorFor(true); … … 303 303 function inspectorStyleSheetAvailable(styleSheet) 304 304 { 305 if (!styleSheet) 306 return; 307 305 308 CSSAgent.addRule(styleSheet.id, selector, addedRule.bind(this)); 306 309 } 307 310 308 WebInspector.cssStyleManager.preferredInspectorStyleSheetForFrame(this._node.frame, inspectorStyleSheetAvailable.bind(this)); 311 if (styleSheetId) 312 inspectorStyleSheetAvailable.call(this, WebInspector.cssStyleManager.styleSheetForIdentifier(styleSheetId)); 313 else 314 WebInspector.cssStyleManager.preferredInspectorStyleSheetForFrame(this._node.frame, inspectorStyleSheetAvailable.bind(this)); 309 315 } 310 316 -
trunk/Source/WebInspectorUI/UserInterface/Views/CSSStyleDetailsSidebarPanel.js
r215192 r217911 171 171 newRuleButton.title = WebInspector.UIString("Add new rule"); 172 172 newRuleButton.addEventListener("click", this._newRuleButtonClicked.bind(this)); 173 newRuleButton.addEventListener("contextmenu", this._newRuleButtonContextMenu.bind(this)); 173 174 174 175 this._filterBar = new WebInspector.FilterBar; … … 321 322 if (this._selectedPanel && typeof this._selectedPanel.newRuleButtonClicked === "function") 322 323 this._selectedPanel.newRuleButtonClicked(); 324 } 325 326 _newRuleButtonContextMenu(event) 327 { 328 if (this._selectedPanel && typeof this._selectedPanel.newRuleButtonContextMenu === "function") 329 this._selectedPanel.newRuleButtonContextMenu(event); 323 330 } 324 331 -
trunk/Source/WebInspectorUI/UserInterface/Views/RulesStyleDetailsPanel.js
r217266 r217911 398 398 } 399 399 400 newRuleButtonContextMenu(event) 401 { 402 if (this.nodeStyles.node.isInUserAgentShadowTree()) 403 return; 404 405 let styleSheets = WebInspector.cssStyleManager.styleSheets.filter(styleSheet => styleSheet.hasInfo() && !styleSheet.isInlineStyleTag() && !styleSheet.isInlineStyleAttributeStyleSheet()); 406 if (!styleSheets.length) 407 return; 408 409 const justSelector = true; 410 let selector = this.nodeStyles.node.appropriateSelectorFor(justSelector); 411 412 let contextMenu = WebInspector.ContextMenu.createFromEvent(event); 413 414 const handler = null; 415 const disabled = true; 416 contextMenu.appendItem(WebInspector.UIString("Available Style Sheets"), handler, disabled); 417 418 for (let styleSheet of styleSheets) { 419 contextMenu.appendItem(styleSheet.displayName, () => { 420 const text = ""; 421 this.nodeStyles.addRule(selector, text, styleSheet.id); 422 }); 423 } 424 } 425 400 426 sectionForStyle(style) 401 427 { -
trunk/Source/WebInspectorUI/UserInterface/Views/VisualStyleSelectorSection.js
r211462 r217911 61 61 62 62 let addGlyphElement = useSVGSymbol("Images/Plus13.svg", "visual-style-selector-section-add-rule", WebInspector.UIString("Add new rule")); 63 addGlyphElement.addEventListener("click", this._addNewRule.bind(this)); 63 addGlyphElement.addEventListener("click", this._addNewRuleClick.bind(this)); 64 addGlyphElement.addEventListener("contextmenu", this._addNewRuleContextMenu.bind(this)); 64 65 controlElement.appendChild(addGlyphElement); 65 66 … … 257 258 } 258 259 259 _addNewRule (event)260 _addNewRuleClick(event) 260 261 { 261 262 if (!this._nodeStyles || this._nodeStyles.node.isInUserAgentShadowTree()) … … 271 272 this._newInspectorRuleSelector = selector; 272 273 this._nodeStyles.addRule(selector); 274 } 275 276 _addNewRuleContextMenu(event) 277 { 278 if (!this._nodeStyles || this._nodeStyles.node.isInUserAgentShadowTree()) 279 return; 280 281 let styleSheets = WebInspector.cssStyleManager.styleSheets.filter(styleSheet => styleSheet.hasInfo() && !styleSheet.isInlineStyleTag() && !styleSheet.isInlineStyleAttributeStyleSheet()); 282 if (!styleSheets.length) 283 return; 284 285 let contextMenu = WebInspector.ContextMenu.createFromEvent(event); 286 287 const handler = null; 288 const disabled = true; 289 contextMenu.appendItem(WebInspector.UIString("Available Style Sheets"), handler, disabled); 290 291 for (let styleSheet of styleSheets) { 292 contextMenu.appendItem(styleSheet.displayName, () => { 293 const text = ""; 294 this._nodeStyles.addRule(this.currentStyle().selectorText, text, styleSheet.id); 295 }); 296 } 273 297 } 274 298
Note: See TracChangeset
for help on using the changeset viewer.