Changeset 84148 in webkit
- Timestamp:
- Apr 18, 2011 8:59:28 AM (13 years ago)
- Location:
- trunk
- Files:
-
- 3 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r84147 r84148 1 2011-04-18 Pavel Feldman <pfeldman@google.com> 2 3 Reviewed by Yury Semikhatsky. 4 5 Web Inspector: add test for CSS-resource binding. 6 https://bugs.webkit.org/show_bug.cgi?id=58786 7 8 * inspector/styles/resources/styles-history.css: Added. 9 (body): 10 * inspector/styles/styles-history-expecte.txt: Added. 11 * inspector/styles/styles-history.html: Added. 12 * inspector/styles/styles-source-offsets.html: 13 1 14 2011-04-18 Sheriff Bot <webkit.review.bot@gmail.com> 2 15 -
trunk/LayoutTests/inspector/styles/styles-source-offsets.html
r82578 r84148 2 2 <head> 3 3 4 <link rel="stylesheet" href="resources/styles-source-offsets.css" -->4 <link rel="stylesheet" href="resources/styles-source-offsets.css"> 5 5 6 6 <script src="../../http/tests/inspector/inspector-test.js"></script> -
trunk/Source/WebCore/ChangeLog
r84147 r84148 1 2011-04-18 Pavel Feldman <pfeldman@google.com> 2 3 Reviewed by Yury Semikhatsky. 4 5 Web Inspector: add test for CSS-resource binding. 6 https://bugs.webkit.org/show_bug.cgi?id=58786 7 8 Test: inspector/styles/styles-history.html 9 10 * inspector/InspectorCSSAgent.cpp: 11 (WebCore::InspectorCSSAgent::setPropertyText): 12 (WebCore::InspectorCSSAgent::toggleProperty): 13 * inspector/InspectorStyleSheet.cpp: 14 (WebCore::InspectorStyle::setPropertyText): 15 (WebCore::InspectorStyle::toggleProperty): 16 (WebCore::InspectorStyleSheet::setPropertyText): 17 (WebCore::InspectorStyleSheet::toggleProperty): 18 * inspector/InspectorStyleSheet.h: 19 * inspector/front-end/CSSStyleModel.js: 20 (WebInspector.CSSStyleModel.prototype._fireStyleSheetChanged.if): 21 (WebInspector.CSSStyleModel.prototype._fireStyleSheetChanged.mycallback): 22 (WebInspector.CSSStyleModel.prototype._fireStyleSheetChanged): 23 (WebInspector.CSSStyleModel.prototype.setStyleSheetText): 24 (WebInspector.CSSStyleDeclaration.prototype.insertPropertyAt): 25 (WebInspector.CSSProperty.prototype.setText.callback): 26 (WebInspector.CSSProperty.prototype.setText): 27 1 28 2011-04-18 Sheriff Bot <webkit.review.bot@gmail.com> 2 29 -
trunk/Source/WebCore/inspector/InspectorCSSAgent.cpp
r83962 r84148 303 303 inspectorStyleSheet->reparseStyleSheet(text); 304 304 else 305 *errorString = "Internal error setting style sheet text .";305 *errorString = "Internal error setting style sheet text"; 306 306 } 307 307 … … 315 315 return; 316 316 317 bool success = inspectorStyleSheet->setPropertyText( compoundId, propertyIndex, text, overwrite);317 bool success = inspectorStyleSheet->setPropertyText(errorString, compoundId, propertyIndex, text, overwrite); 318 318 if (success) 319 319 *result = inspectorStyleSheet->buildObjectForStyle(inspectorStyleSheet->styleForId(compoundId)); … … 329 329 return; 330 330 331 bool success = inspectorStyleSheet->toggleProperty( compoundId, propertyIndex, disable);331 bool success = inspectorStyleSheet->toggleProperty(errorString, compoundId, propertyIndex, disable); 332 332 if (success) 333 333 *result = inspectorStyleSheet->buildObjectForStyle(inspectorStyleSheet->styleForId(compoundId)); -
trunk/Source/WebCore/inspector/InspectorStyleSheet.cpp
r83441 r84148 181 181 // The propertyText (if not empty) is checked to be a valid style declaration (containing at least one property). If not, 182 182 // the method returns false (denoting an error). 183 bool InspectorStyle::setPropertyText( unsigned index, const String& propertyText, bool overwrite)183 bool InspectorStyle::setPropertyText(ErrorString* errorString, unsigned index, const String& propertyText, bool overwrite) 184 184 { 185 185 ASSERT(m_parentStyleSheet); 186 if (!m_parentStyleSheet->ensureParsedDataReady()) 187 return false; 186 if (!m_parentStyleSheet->ensureParsedDataReady()) { 187 *errorString = "Internal error: no stylesheet parsed data available"; 188 return false; 189 } 188 190 189 191 Vector<InspectorStyleProperty> allProperties; … … 202 204 203 205 // At least one property + the bogus property added just above should be present. 204 if (propertyCount < 2) 206 if (propertyCount < 2) { 207 *errorString = "Invalid property value"; 205 208 return false; 209 } 206 210 207 211 // Check for a proper propertyText termination (the parser could at least restore to the PROPERTY_NAME state). 208 if (propertyData.at(propertyCount - 1).name != "-webkit-boguz-propertee") 212 if (propertyData.at(propertyCount - 1).name != "-webkit-boguz-propertee") { 213 *errorString = "Invalid property value"; 209 214 return false; 215 } 210 216 } 211 217 … … 221 227 if (!property.disabled) { 222 228 bool success = replacePropertyInStyleText(property, propertyText); 223 if (!success) 229 if (!success) { 230 *errorString = "Internal error: could not replace property value"; 224 231 return false; 232 } 225 233 } else { 226 234 unsigned textLength = propertyText.length(); … … 240 248 // Insert at index. 241 249 RefPtr<CSSRuleSourceData> sourceData = m_parentStyleSheet->ruleSourceDataFor(m_style.get()); 242 if (!sourceData) 250 if (!sourceData) { 251 *errorString = "Internal error: no CSS rule source found"; 243 252 return false; 253 } 244 254 String text; 245 255 bool success = styleText(&text); 246 if (!success) 256 if (!success) { 257 *errorString = "Internal error: could not fetch style text"; 247 258 return false; 259 } 248 260 propertyLengthDelta = propertyText.length(); 249 261 … … 288 300 } 289 301 290 bool InspectorStyle::toggleProperty( unsigned index, bool disable)302 bool InspectorStyle::toggleProperty(ErrorString* errorString, unsigned index, bool disable) 291 303 { 292 304 ASSERT(m_parentStyleSheet); 293 if (!m_parentStyleSheet->ensureParsedDataReady()) 294 return false; // Can toggle only source-based properties. 305 if (!m_parentStyleSheet->ensureParsedDataReady()) { 306 *errorString = "Can toggle only source-based properties"; 307 return false; 308 } 295 309 RefPtr<CSSRuleSourceData> sourceData = m_parentStyleSheet->ruleSourceDataFor(m_style.get()); 296 if (!sourceData) 297 return false; // No source data for the style. 310 if (!sourceData) { 311 *errorString = "Internal error: No source data for the style found"; 312 return false; 313 } 298 314 299 315 Vector<InspectorStyleProperty> allProperties; 300 316 populateAllProperties(&allProperties); 301 if (index >= allProperties.size()) 302 return false; // Outside of property range. 317 if (index >= allProperties.size()) { 318 *errorString = "Property index is outside of property range"; 319 return false; 320 } 303 321 304 322 InspectorStyleProperty& property = allProperties.at(index); … … 806 824 } 807 825 808 bool InspectorStyleSheet::setPropertyText( const InspectorCSSId& id, unsigned propertyIndex, const String& text, bool overwrite)826 bool InspectorStyleSheet::setPropertyText(ErrorString* errorString, const InspectorCSSId& id, unsigned propertyIndex, const String& text, bool overwrite) 809 827 { 810 828 RefPtr<InspectorStyle> inspectorStyle = inspectorStyleForId(id); 811 if (!inspectorStyle) 812 return false; 813 814 return inspectorStyle->setPropertyText(propertyIndex, text, overwrite); 815 } 816 817 bool InspectorStyleSheet::toggleProperty(const InspectorCSSId& id, unsigned propertyIndex, bool disable) 829 if (!inspectorStyle) { 830 *errorString = "No style found for given id"; 831 return false; 832 } 833 834 return inspectorStyle->setPropertyText(errorString, propertyIndex, text, overwrite); 835 } 836 837 bool InspectorStyleSheet::toggleProperty(ErrorString* errorString, const InspectorCSSId& id, unsigned propertyIndex, bool disable) 818 838 { 819 839 RefPtr<InspectorStyle> inspectorStyle = inspectorStyleForId(id); 820 if (!inspectorStyle) 821 return false; 822 823 bool success = inspectorStyle->toggleProperty(propertyIndex, disable); 840 if (!inspectorStyle) { 841 *errorString = "No style found for given id"; 842 return false; 843 } 844 845 bool success = inspectorStyle->toggleProperty(errorString, propertyIndex, disable); 824 846 if (success) { 825 847 if (disable) -
trunk/Source/WebCore/inspector/InspectorStyleSheet.h
r82252 r84148 50 50 #if ENABLE(INSPECTOR) 51 51 52 typedef String ErrorString; 53 52 54 class InspectorCSSId { 53 55 public: … … 128 130 PassRefPtr<InspectorObject> buildObjectForStyle() const; 129 131 bool hasDisabledProperties() const { return !m_disabledProperties.isEmpty(); } 130 bool setPropertyText( unsigned index, const String& text, bool overwrite);131 bool toggleProperty( unsigned index, bool disable);132 bool setPropertyText(ErrorString*, unsigned index, const String& text, bool overwrite); 133 bool toggleProperty(ErrorString*, unsigned index, bool disable); 132 134 133 135 private: … … 172 174 PassRefPtr<InspectorObject> buildObjectForRule(CSSStyleRule*); 173 175 PassRefPtr<InspectorObject> buildObjectForStyle(CSSStyleDeclaration*); 174 bool setPropertyText( const InspectorCSSId&, unsigned propertyIndex, const String& text, bool overwrite);175 bool toggleProperty( const InspectorCSSId&, unsigned propertyIndex, bool disable);176 bool setPropertyText(ErrorString*, const InspectorCSSId&, unsigned propertyIndex, const String& text, bool overwrite); 177 bool toggleProperty(ErrorString*, const InspectorCSSId&, unsigned propertyIndex, bool disable); 176 178 177 179 virtual bool text(String* result) const; -
trunk/Source/WebCore/inspector/front-end/CSSStyleModel.js
r83969 r84148 167 167 }, 168 168 169 _fireStyleSheetChanged: function(styleSheetId, majorChange) 170 { 171 if (!majorChange || !styleSheetId) 169 _fireStyleSheetChanged: function(styleSheetId, majorChange, callback) 170 { 171 callback = callback || function() {}; 172 173 if (!majorChange || !styleSheetId || !this.hasEventListeners(WebInspector.CSSStyleModel.Events.StyleSheetChanged)) { 174 callback(); 172 175 return; 173 174 function callback(error, content) 175 {176 if (error)177 return;178 179 this.dispatchEventToListeners(WebInspector.CSSStyleModel.Events.StyleSheetChanged, { styleSheetId: styleSheetId, content: content, majorChange: majorChange });180 } 181 if (this.hasEventListeners(WebInspector.CSSStyleModel.Events.StyleSheetChanged)) 182 CSSAgent.getStyleSheetText(styleSheetId,callback.bind(this));176 } 177 178 function mycallback(error, content) 179 { 180 if (!error) 181 this.dispatchEventToListeners(WebInspector.CSSStyleModel.Events.StyleSheetChanged, { styleSheetId: styleSheetId, content: content, majorChange: majorChange }); 182 callback(); 183 } 184 185 CSSAgent.getStyleSheetText(styleSheetId, mycallback.bind(this)); 183 186 }, 184 187 … … 188 191 { 189 192 if (!error) 190 this._fireStyleSheetChanged(styleSheetId, majorChange); 191 192 if (userCallback) 193 userCallback(error); 193 this._fireStyleSheetChanged(styleSheetId, majorChange, userCallback ? userCallback.bind(this, error) : null); 194 194 } 195 195 CSSAgent.setStyleSheetText(styleSheetId, newText, callback.bind(this)); … … 367 367 return; 368 368 369 if (error) 369 if (error) { 370 console.error(JSON.stringify(error)); 370 371 userCallback(null); 371 else {372 } else { 372 373 userCallback(WebInspector.CSSStyleDeclaration.parsePayload(payload)); 373 374 WebInspector.cssModel._fireStyleSheetChanged(this.id.styleSheetId, true); … … 499 500 function callback(error, stylePayload) 500 501 { 501 if (!error && stylePayload) {502 if (!error) { 502 503 this.text = propertyText; 503 504 var style = WebInspector.CSSStyleDeclaration.parsePayload(stylePayload); … … 507 508 newProperty.setDisabled(false, enabledCallback); 508 509 return; 509 } else 510 WebInspector.cssModel._fireStyleSheetChanged(style.id.styleSheetId, majorChange); 511 if (userCallback) 512 userCallback(style); 510 } 511 512 WebInspector.cssModel._fireStyleSheetChanged(style.id.styleSheetId, majorChange, userCallback.bind(this, style)); 513 513 } else { 514 console.error(JSON.stringify(error)); 514 515 if (userCallback) 515 516 userCallback(null);
Note: See TracChangeset
for help on using the changeset viewer.