Changeset 82252 in webkit
- Timestamp:
- Mar 29, 2011 8:09:55 AM (13 years ago)
- Location:
- trunk
- Files:
-
- 3 added
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r82250 r82252 1 2011-03-29 Alexander Pavlov <apavlov@chromium.org> 2 3 Reviewed by Pavel Feldman. 4 5 Web Inspector: Fix handling of the CSSAgent.setStyleSheetText() results in CSSStyleModel.js 6 https://bugs.webkit.org/show_bug.cgi?id=56310 7 8 * inspector/styles/get-set-stylesheet-text-expected.txt: Added. 9 * inspector/styles/get-set-stylesheet-text.html: Added. 10 * inspector/styles/resources/get-set-stylesheet-text.css: Added. 11 (body): 12 (/* comment before selector */body.main1/* comment after selector */): 13 (body.main2): 14 * inspector/styles/styles-add-blank-property.html: Tentatively fix flakiness by waiting for pending dispatches to finish 15 * inspector/styles/styles-new-API.html: 16 1 17 2011-03-29 Jeremy Moskovich <jeremy@chromium.org> 2 18 -
trunk/LayoutTests/inspector/styles/styles-add-blank-property.html
r80416 r82252 8 8 { 9 9 WebInspector.showPanel("elements"); 10 InspectorTest.selectNodeWithId("inspected", step 1);10 InspectorTest.selectNodeWithId("inspected", step0); 11 11 12 12 var treeElement; 13 var section; 14 15 function step0() 16 { 17 InspectorTest.addResult("Before append:"); 18 InspectorTest.dumpSelectedElementStyles(true); 19 section = WebInspector.panels.elements.sidebarPanes.styles.sections[0][1]; 20 section.expand(); 21 InspectorTest.runAfterPendingDispatches(step1); 22 } 13 23 14 24 function step1() 15 25 { 16 InspectorTest.addResult("Before append:");17 InspectorTest.dumpSelectedElementStyles(true);18 19 var section = WebInspector.panels.elements.sidebarPanes.styles.sections[0][1];20 section.expand();21 22 26 // Create and increment. 23 27 treeElement = section.addNewBlankProperty(); -
trunk/LayoutTests/inspector/styles/styles-new-API.html
r81957 r82252 103 103 } 104 104 105 function styleSheetI dsLoaded(error, ids)105 function styleSheetInfosLoaded(error, infos) 106 106 { 107 107 if (error) { … … 111 111 InspectorTest.addResult(""); 112 112 InspectorTest.addResult("=== All stylesheets ==="); 113 for (var i = 0; i < i ds.length; ++i)114 loadAndDumpStyleSheet(i ds[i], (i < ids.length - 1) ? null : patchStyleSheet);115 } 116 CSSAgent.getAllStyle s(styleSheetIdsLoaded);113 for (var i = 0; i < infos.length; ++i) 114 loadAndDumpStyleSheet(infos[i].styleSheetId, (i < infos.length - 1) ? null : patchStyleSheet); 115 } 116 CSSAgent.getAllStyleSheets(styleSheetInfosLoaded); 117 117 } 118 118 … … 297 297 { 298 298 if (error) { 299 InspectorTest.add Record("error: " + error);299 InspectorTest.addError("error: " + error); 300 300 return; 301 301 } 302 302 303 function styleSheetLoaded(error, styleSheet) 303 304 { 304 305 if (error) { 305 InspectorTest.add Record("error: " + error);306 InspectorTest.addError("error: " + error); 306 307 return; 307 308 } … … 321 322 Covered API methods: 322 323 - getStylesForNode 323 - getAllStyle s324 - getAllStyleSheets 324 325 - getStyleSheet 325 326 - setStyleSheetText -
trunk/Source/WebCore/ChangeLog
r82250 r82252 1 2011-03-29 Alexander Pavlov <apavlov@chromium.org> 2 3 Reviewed by Pavel Feldman. 4 5 Web Inspector: Fix handling of the CSSAgent.setStyleSheetText() results in CSSStyleModel.js 6 https://bugs.webkit.org/show_bug.cgi?id=56310 7 8 Instead of stylesheet ids, CSSAgent.getAllStyleSheets() now returns metainfo objects containing 9 "styleSheetId", "sourceURL", "disabled", and "title" fields. The latter three are not returned 10 by CSSAgent.getStyleSheet() anymore. 11 12 Test: inspector/styles/get-set-stylesheet-text.html 13 14 * inspector/Inspector.json: 15 * inspector/InspectorCSSAgent.cpp: 16 (WebCore::InspectorCSSAgent::getAllStyleSheets): 17 * inspector/InspectorCSSAgent.h: 18 * inspector/InspectorStyleSheet.cpp: 19 (WebCore::InspectorStyleSheet::buildObjectForStyleSheet): 20 (WebCore::InspectorStyleSheet::buildObjectForStyleSheetInfo): 21 * inspector/InspectorStyleSheet.h: 22 * inspector/front-end/AuditRules.js: 23 (WebInspector.AuditRules.UnusedCssRule.prototype.doRun.styleSheetCallback): 24 (WebInspector.AuditRules.UnusedCssRule.prototype.doRun.allStylesCallback): 25 (WebInspector.AuditRules.UnusedCssRule.prototype.doRun): 26 * inspector/front-end/CSSStyleModel.js: 27 (WebInspector.CSSStyleModel.prototype._styleSheetChanged.callback): 28 (WebInspector.CSSStyleModel.prototype._styleSheetChanged): 29 (WebInspector.CSSStyleModel.prototype._onRevert): 30 (WebInspector.CSSStyleSheet): 31 (WebInspector.CSSStyleSheet.prototype.setText): 32 1 33 2011-03-29 Jeremy Moskovich <jeremy@chromium.org> 2 34 -
trunk/Source/WebCore/inspector/Inspector.json
r82239 r82252 938 938 }, 939 939 { 940 "name": "getAllStyle s",941 "returns": [ 942 { "name": "styleSheetI ds", "type": "array", "items": { "type": "string" } }940 "name": "getAllStyleSheets", 941 "returns": [ 942 { "name": "styleSheetInfos", "type": "array", "items": { "$ref": "CSSStyleSheetInfo" } } 943 943 ] 944 944 }, -
trunk/Source/WebCore/inspector/InspectorCSSAgent.cpp
r81957 r82252 105 105 // } 106 106 // 107 // cssStyleSheetInfo = { 108 // styleSheetId : <number> 109 // sourceURL : <string> 110 // title : <string> 111 // disabled : <boolean> 112 // } 113 // 107 114 // cssStyleSheet = { 108 // styleSheetId : <number> 109 // sourceURL : <string> 110 // title : <string> 111 // disabled : <boolean> 112 // rules : [ 113 // #cssRule, 114 // ... 115 // #cssRule 116 // ] 117 // text : <string> // Optional - whenever the text is available for a text-based stylesheet 115 // styleSheetId : <number> 116 // rules : [ 117 // #cssRule, 118 // ... 119 // #cssRule 120 // ] 121 // text : <string> // Optional - whenever the text is available for a text-based stylesheet 118 122 // } 119 123 … … 251 255 } 252 256 253 void InspectorCSSAgent::getAllStyle s(ErrorString*, RefPtr<InspectorArray>* styles)257 void InspectorCSSAgent::getAllStyleSheets(ErrorString*, RefPtr<InspectorArray>* styleInfos) 254 258 { 255 259 Vector<Document*> documents = m_domAgent->documents(); … … 260 264 if (styleSheet->isCSSStyleSheet()) { 261 265 InspectorStyleSheet* inspectorStyleSheet = bindStyleSheet(static_cast<CSSStyleSheet*>(styleSheet)); 262 (*style s)->pushString(inspectorStyleSheet->id());266 (*styleInfos)->pushObject(inspectorStyleSheet->buildObjectForStyleSheetInfo()); 263 267 } 264 268 } -
trunk/Source/WebCore/inspector/InspectorCSSAgent.h
r81957 r82252 65 65 void getInlineStyleForNode(ErrorString*, int nodeId, RefPtr<InspectorObject>* style); 66 66 void getComputedStyleForNode(ErrorString*, int nodeId, RefPtr<InspectorObject>* style); 67 void getAllStyle s(ErrorString*, RefPtr<InspectorArray>* styles);67 void getAllStyleSheets(ErrorString*, RefPtr<InspectorArray>* styleSheetInfos); 68 68 void getStyleSheet(ErrorString*, const String& styleSheetId, RefPtr<InspectorObject>* result); 69 69 void getStyleSheetText(ErrorString*, const String& styleSheetId, String* url, String* result); -
trunk/Source/WebCore/inspector/InspectorStyleSheet.cpp
r82106 r82252 709 709 710 710 RefPtr<InspectorObject> result = InspectorObject::create(); 711 result->setBoolean("disabled", styleSheet->disabled()); 712 result->setString("sourceURL", finalURL()); 713 result->setString("title", styleSheet->title()); 711 result->setString("styleSheetId", id()); 714 712 RefPtr<CSSRuleList> cssRuleList = CSSRuleList::create(styleSheet, true); 715 713 RefPtr<InspectorArray> cssRules = buildArrayForRuleList(cssRuleList.get()); … … 721 719 result->setString("text", styleSheetText); 722 720 721 return result.release(); 722 } 723 724 PassRefPtr<InspectorObject> InspectorStyleSheet::buildObjectForStyleSheetInfo() 725 { 726 CSSStyleSheet* styleSheet = pageStyleSheet(); 727 if (!styleSheet) 728 return 0; 729 730 RefPtr<InspectorObject> result = InspectorObject::create(); 723 731 result->setString("styleSheetId", id()); 724 732 result->setBoolean("disabled", styleSheet->disabled()); 733 result->setString("sourceURL", finalURL()); 734 result->setString("title", styleSheet->title()); 725 735 return result.release(); 726 736 } -
trunk/Source/WebCore/inspector/InspectorStyleSheet.h
r81957 r82252 169 169 CSSStyleRule* ruleForId(const InspectorCSSId&) const; 170 170 PassRefPtr<InspectorObject> buildObjectForStyleSheet(); 171 PassRefPtr<InspectorObject> buildObjectForStyleSheetInfo(); 171 172 PassRefPtr<InspectorObject> buildObjectForRule(CSSStyleRule*); 172 173 PassRefPtr<InspectorObject> buildObjectForStyle(CSSStyleDeclaration*); -
trunk/Source/WebCore/inspector/front-end/AuditRules.js
r81957 r82252 378 378 } 379 379 380 function styleSheetCallback(styleSheets, continuation, styleSheet) 381 { 382 if (styleSheet) 380 function styleSheetCallback(styleSheets, sourceURL, continuation, styleSheet) 381 { 382 if (styleSheet) { 383 styleSheet.sourceURL = sourceURL; 383 384 styleSheets.push(styleSheet); 385 } 384 386 if (continuation) 385 387 continuation(styleSheets); 386 388 } 387 389 388 function allStylesCallback(error, styleSheetI ds)389 { 390 if (error || !styleSheetI ds || !styleSheetIds.length)390 function allStylesCallback(error, styleSheetInfos) 391 { 392 if (error || !styleSheetInfos || !styleSheetInfos.length) 391 393 return evalCallback([]); 392 394 var styleSheets = []; 393 for (var i = 0; i < styleSheetIds.length; ++i) 394 WebInspector.CSSStyleSheet.createForId(styleSheetIds[i], styleSheetCallback.bind(null, styleSheets, i == styleSheetIds.length - 1 ? evalCallback : null)); 395 } 396 397 CSSAgent.getAllStyles(allStylesCallback); 395 for (var i = 0; i < styleSheetInfos.length; ++i) { 396 var info = styleSheetInfos[i]; 397 WebInspector.CSSStyleSheet.createForId(info.styleSheetId, styleSheetCallback.bind(null, styleSheets, info.sourceURL, i == styleSheetInfos.length - 1 ? evalCallback : null)); 398 } 399 } 400 401 CSSAgent.getAllStyleSheets(allStylesCallback); 398 402 } 399 403 } -
trunk/Source/WebCore/inspector/front-end/CSSStyleModel.js
r81957 r82252 169 169 return; 170 170 var resource = WebInspector.resourceForURL(href); 171 if (resource && resource.type === WebInspector.Resource.Type.Stylesheet) 171 if (resource && resource.type === WebInspector.Resource.Type.Stylesheet) { 172 172 resource.setContent(content, this._onRevert.bind(this, styleSheetId)); 173 this.dispatchEventToListeners("stylesheet changed"); 174 } 173 175 } 174 176 CSSAgent.getStyleSheetText(styleSheetId, callback.bind(this)); … … 182 184 return; 183 185 this._styleSheetChanged(styleSheetId, true); 184 this.dispatchEventToListeners("stylesheet changed");185 186 } 186 187 CSSAgent.setStyleSheetText(styleSheetId, contentToRevertTo, callback.bind(this)); … … 538 539 { 539 540 this.id = payload.styleSheetId; 540 this.sourceURL = payload.sourceURL;541 this.title = payload.title;542 this.disabled = payload.disabled;543 541 this.rules = []; 544 542 this.styles = {}; … … 573 571 setText: function(newText, userCallback) 574 572 { 575 function callback(error, styleSheetPayload) 576 { 577 if (error) 578 userCallback(null); 579 else { 580 userCallback(new WebInspector.CSSStyleSheet(styleSheetPayload)); 581 WebInspector.cssModel._styleSheetChanged(this.id, true); 582 } 573 function callback(error, isChangeSuccessful) 574 { 575 if (userCallback) 576 userCallback(isChangeSuccessful); 577 if (isChangeSuccessful) 578 WebInspector.cssModel._styleSheetChanged(this.id, true); 583 579 } 584 580
Note: See TracChangeset
for help on using the changeset viewer.