Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(367)

Side by Side Diff: Source/core/inspector/InspectorStyleSheet.cpp

Issue 18548003: Rename ExceptionCode constants to use the names in the spec (2/3) (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2010, Google Inc. All rights reserved. 2 * Copyright (C) 2010, Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 555 matching lines...) Expand 10 before | Expand all | Expand 10 after
566 RefPtr<MutableStylePropertySet> tempMutableStyle = MutableStylePropertyS et::create(); 566 RefPtr<MutableStylePropertySet> tempMutableStyle = MutableStylePropertyS et::create();
567 String declarationText = propertyText + " " + bogusPropertyName + ": non e"; 567 String declarationText = propertyText + " " + bogusPropertyName + ": non e";
568 RuleSourceDataList sourceData; 568 RuleSourceDataList sourceData;
569 StyleSheetHandler handler(declarationText, ownerDocument(), m_style->par entStyleSheet()->contents(), &sourceData); 569 StyleSheetHandler handler(declarationText, ownerDocument(), m_style->par entStyleSheet()->contents(), &sourceData);
570 createCSSParser(ownerDocument())->parseDeclaration(tempMutableStyle.get( ), declarationText, &handler, m_style->parentStyleSheet()->contents()); 570 createCSSParser(ownerDocument())->parseDeclaration(tempMutableStyle.get( ), declarationText, &handler, m_style->parentStyleSheet()->contents());
571 Vector<CSSPropertySourceData>& propertyData = sourceData.first()->styleS ourceData->propertyData; 571 Vector<CSSPropertySourceData>& propertyData = sourceData.first()->styleS ourceData->propertyData;
572 unsigned propertyCount = propertyData.size(); 572 unsigned propertyCount = propertyData.size();
573 573
574 // At least one property + the bogus property added just above should be present. 574 // At least one property + the bogus property added just above should be present.
575 if (propertyCount < 2) { 575 if (propertyCount < 2) {
576 ec = SYNTAX_ERR; 576 ec = SyntaxError;
577 return false; 577 return false;
578 } 578 }
579 579
580 // Check for the proper propertyText termination (the parser could at le ast restore to the PROPERTY_NAME state). 580 // Check for the proper propertyText termination (the parser could at le ast restore to the PROPERTY_NAME state).
581 if (propertyData.at(propertyCount - 1).name != bogusPropertyName) { 581 if (propertyData.at(propertyCount - 1).name != bogusPropertyName) {
582 ec = SYNTAX_ERR; 582 ec = SyntaxError;
583 return false; 583 return false;
584 } 584 }
585 } 585 }
586 586
587 RefPtr<CSSRuleSourceData> sourceData = extractSourceData(); 587 RefPtr<CSSRuleSourceData> sourceData = extractSourceData();
588 if (!sourceData) { 588 if (!sourceData) {
589 ec = NotFoundError; 589 ec = NotFoundError;
590 return false; 590 return false;
591 } 591 }
592 592
(...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after
1080 CSSSelectorList selectorList; 1080 CSSSelectorList selectorList;
1081 createCSSParser(document)->parseSelector(selector, selectorList); 1081 createCSSParser(document)->parseSelector(selector, selectorList);
1082 return selectorList.isValid(); 1082 return selectorList.isValid();
1083 } 1083 }
1084 1084
1085 CSSStyleRule* InspectorStyleSheet::addRule(const String& selector, ExceptionCode & ec) 1085 CSSStyleRule* InspectorStyleSheet::addRule(const String& selector, ExceptionCode & ec)
1086 { 1086 {
1087 if (!checkPageStyleSheet(ec)) 1087 if (!checkPageStyleSheet(ec))
1088 return 0; 1088 return 0;
1089 if (!checkStyleRuleSelector(m_pageStyleSheet->ownerDocument(), selector)) { 1089 if (!checkStyleRuleSelector(m_pageStyleSheet->ownerDocument(), selector)) {
1090 ec = SYNTAX_ERR; 1090 ec = SyntaxError;
1091 return 0; 1091 return 0;
1092 } 1092 }
1093 1093
1094 String text; 1094 String text;
1095 bool success = getText(&text); 1095 bool success = getText(&text);
1096 if (!success) { 1096 if (!success) {
1097 ec = NotFoundError; 1097 ec = NotFoundError;
1098 return 0; 1098 return 0;
1099 } 1099 }
1100 StringBuilder styleSheetText; 1100 StringBuilder styleSheetText;
1101 styleSheetText.append(text); 1101 styleSheetText.append(text);
1102 1102
1103 m_pageStyleSheet->addRule(selector, "", ec); 1103 m_pageStyleSheet->addRule(selector, "", ec);
1104 if (ec) 1104 if (ec)
1105 return 0; 1105 return 0;
1106 ASSERT(m_pageStyleSheet->length()); 1106 ASSERT(m_pageStyleSheet->length());
1107 unsigned lastRuleIndex = m_pageStyleSheet->length() - 1; 1107 unsigned lastRuleIndex = m_pageStyleSheet->length() - 1;
1108 CSSRule* rule = m_pageStyleSheet->item(lastRuleIndex); 1108 CSSRule* rule = m_pageStyleSheet->item(lastRuleIndex);
1109 ASSERT(rule); 1109 ASSERT(rule);
1110 1110
1111 CSSStyleRule* styleRule = InspectorCSSAgent::asCSSStyleRule(rule); 1111 CSSStyleRule* styleRule = InspectorCSSAgent::asCSSStyleRule(rule);
1112 if (!styleRule) { 1112 if (!styleRule) {
1113 // What we just added has to be a CSSStyleRule - we cannot handle other types of rules yet. 1113 // What we just added has to be a CSSStyleRule - we cannot handle other types of rules yet.
1114 // If it is not a style rule, pretend we never touched the stylesheet. 1114 // If it is not a style rule, pretend we never touched the stylesheet.
1115 m_pageStyleSheet->deleteRule(lastRuleIndex, ASSERT_NO_EXCEPTION); 1115 m_pageStyleSheet->deleteRule(lastRuleIndex, ASSERT_NO_EXCEPTION);
1116 ec = SYNTAX_ERR; 1116 ec = SyntaxError;
1117 return 0; 1117 return 0;
1118 } 1118 }
1119 1119
1120 if (!styleSheetText.isEmpty()) 1120 if (!styleSheetText.isEmpty())
1121 styleSheetText.append('\n'); 1121 styleSheetText.append('\n');
1122 1122
1123 styleSheetText.append(selector); 1123 styleSheetText.append(selector);
1124 styleSheetText.appendLiteral(" {}"); 1124 styleSheetText.appendLiteral(" {}");
1125 // Using setText() as this operation changes the style sheet rule set. 1125 // Using setText() as this operation changes the style sheet rule set.
1126 setText(styleSheetText.toString(), ASSERT_NO_EXCEPTION); 1126 setText(styleSheetText.toString(), ASSERT_NO_EXCEPTION);
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
1334 bool success = inspectorStyle->styleText(oldText); 1334 bool success = inspectorStyle->styleText(oldText);
1335 if (!success) { 1335 if (!success) {
1336 ec = NotFoundError; 1336 ec = NotFoundError;
1337 return false; 1337 return false;
1338 } 1338 }
1339 1339
1340 success = setStyleText(inspectorStyle->cssStyle(), text); 1340 success = setStyleText(inspectorStyle->cssStyle(), text);
1341 if (success) 1341 if (success)
1342 fireStyleSheetChanged(); 1342 fireStyleSheetChanged();
1343 else 1343 else
1344 ec = SYNTAX_ERR; 1344 ec = SyntaxError;
1345 return success; 1345 return success;
1346 } 1346 }
1347 1347
1348 bool InspectorStyleSheet::setPropertyText(const InspectorCSSId& id, unsigned pro pertyIndex, const String& text, bool overwrite, String* oldText, ExceptionCode& ec) 1348 bool InspectorStyleSheet::setPropertyText(const InspectorCSSId& id, unsigned pro pertyIndex, const String& text, bool overwrite, String* oldText, ExceptionCode& ec)
1349 { 1349 {
1350 RefPtr<InspectorStyle> inspectorStyle = inspectorStyleForId(id); 1350 RefPtr<InspectorStyle> inspectorStyle = inspectorStyleForId(id);
1351 if (!inspectorStyle) { 1351 if (!inspectorStyle) {
1352 ec = NotFoundError; 1352 ec = NotFoundError;
1353 return false; 1353 return false;
1354 } 1354 }
(...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after
1809 1809
1810 RefPtr<MutableStylePropertySet> tempDeclaration = MutableStylePropertySet::c reate(); 1810 RefPtr<MutableStylePropertySet> tempDeclaration = MutableStylePropertySet::c reate();
1811 RuleSourceDataList ruleSourceDataResult; 1811 RuleSourceDataList ruleSourceDataResult;
1812 StyleSheetHandler handler(m_styleText, m_element->document(), m_element->doc ument()->elementSheet()->contents(), &ruleSourceDataResult); 1812 StyleSheetHandler handler(m_styleText, m_element->document(), m_element->doc ument()->elementSheet()->contents(), &ruleSourceDataResult);
1813 createCSSParser(m_element->document())->parseDeclaration(tempDeclaration.get (), m_styleText, &handler, m_element->document()->elementSheet()->contents()); 1813 createCSSParser(m_element->document())->parseDeclaration(tempDeclaration.get (), m_styleText, &handler, m_element->document()->elementSheet()->contents());
1814 return ruleSourceDataResult.first().release(); 1814 return ruleSourceDataResult.first().release();
1815 } 1815 }
1816 1816
1817 } // namespace WebCore 1817 } // namespace WebCore
1818 1818
OLDNEW
« no previous file with comments | « Source/core/inspector/InspectorDOMStorageAgent.cpp ('k') | Source/core/loader/appcache/DOMApplicationCache.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698