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

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

Issue 72363002: Rename es => exceptionState in other than bindings/ (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Retry Created 7 years, 1 month 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 529 matching lines...) Expand 10 before | Expand all | Expand 10 after
540 540
541 return result.release(); 541 return result.release();
542 } 542 }
543 543
544 // This method does the following preprocessing of |propertyText| with |overwrit e| == false and |index| past the last active property: 544 // This method does the following preprocessing of |propertyText| with |overwrit e| == false and |index| past the last active property:
545 // - If the last property (if present) has no closing ";", the ";" is prepended to the current |propertyText| value. 545 // - If the last property (if present) has no closing ";", the ";" is prepended to the current |propertyText| value.
546 // - A heuristic formatting is attempted to retain the style structure. 546 // - A heuristic formatting is attempted to retain the style structure.
547 // 547 //
548 // The propertyText (if not empty) is checked to be a valid style declaration (c ontaining at least one property). If not, 548 // The propertyText (if not empty) is checked to be a valid style declaration (c ontaining at least one property). If not,
549 // the method returns false (denoting an error). 549 // the method returns false (denoting an error).
550 bool InspectorStyle::setPropertyText(unsigned index, const String& propertyText, bool overwrite, String* oldText, ExceptionState& es) 550 bool InspectorStyle::setPropertyText(unsigned index, const String& propertyText, bool overwrite, String* oldText, ExceptionState& exceptionState)
551 { 551 {
552 ASSERT(m_parentStyleSheet); 552 ASSERT(m_parentStyleSheet);
553 DEFINE_STATIC_LOCAL(String, bogusPropertyName, ("-webkit-boguz-propertee")); 553 DEFINE_STATIC_LOCAL(String, bogusPropertyName, ("-webkit-boguz-propertee"));
554 554
555 if (!m_parentStyleSheet->ensureParsedDataReady()) { 555 if (!m_parentStyleSheet->ensureParsedDataReady()) {
556 es.throwUninformativeAndGenericDOMException(NotFoundError); 556 exceptionState.throwUninformativeAndGenericDOMException(NotFoundError);
557 return false; 557 return false;
558 } 558 }
559 559
560 if (!propertyText.stripWhiteSpace().isEmpty()) { 560 if (!propertyText.stripWhiteSpace().isEmpty()) {
561 RefPtr<MutableStylePropertySet> tempMutableStyle = MutableStylePropertyS et::create(); 561 RefPtr<MutableStylePropertySet> tempMutableStyle = MutableStylePropertyS et::create();
562 String declarationText = propertyText + " " + bogusPropertyName + ": non e"; 562 String declarationText = propertyText + " " + bogusPropertyName + ": non e";
563 RuleSourceDataList sourceData; 563 RuleSourceDataList sourceData;
564 StyleSheetHandler handler(declarationText, ownerDocument(), m_style->par entStyleSheet()->contents(), &sourceData); 564 StyleSheetHandler handler(declarationText, ownerDocument(), m_style->par entStyleSheet()->contents(), &sourceData);
565 createCSSParser(ownerDocument())->parseDeclaration(tempMutableStyle.get( ), declarationText, &handler, m_style->parentStyleSheet()->contents()); 565 createCSSParser(ownerDocument())->parseDeclaration(tempMutableStyle.get( ), declarationText, &handler, m_style->parentStyleSheet()->contents());
566 Vector<CSSPropertySourceData>& propertyData = sourceData.first()->styleS ourceData->propertyData; 566 Vector<CSSPropertySourceData>& propertyData = sourceData.first()->styleS ourceData->propertyData;
567 unsigned propertyCount = propertyData.size(); 567 unsigned propertyCount = propertyData.size();
568 568
569 // At least one property + the bogus property added just above should be present. 569 // At least one property + the bogus property added just above should be present.
570 if (propertyCount < 2) { 570 if (propertyCount < 2) {
571 es.throwUninformativeAndGenericDOMException(SyntaxError); 571 exceptionState.throwUninformativeAndGenericDOMException(SyntaxError) ;
572 return false; 572 return false;
573 } 573 }
574 574
575 // Check for the proper propertyText termination (the parser could at le ast restore to the PROPERTY_NAME state). 575 // Check for the proper propertyText termination (the parser could at le ast restore to the PROPERTY_NAME state).
576 if (propertyData.at(propertyCount - 1).name != bogusPropertyName) { 576 if (propertyData.at(propertyCount - 1).name != bogusPropertyName) {
577 es.throwUninformativeAndGenericDOMException(SyntaxError); 577 exceptionState.throwUninformativeAndGenericDOMException(SyntaxError) ;
578 return false; 578 return false;
579 } 579 }
580 } 580 }
581 581
582 RefPtr<CSSRuleSourceData> sourceData = extractSourceData(); 582 RefPtr<CSSRuleSourceData> sourceData = extractSourceData();
583 if (!sourceData) { 583 if (!sourceData) {
584 es.throwUninformativeAndGenericDOMException(NotFoundError); 584 exceptionState.throwUninformativeAndGenericDOMException(NotFoundError);
585 return false; 585 return false;
586 } 586 }
587 587
588 String text; 588 String text;
589 bool success = styleText(&text); 589 bool success = styleText(&text);
590 if (!success) { 590 if (!success) {
591 es.throwUninformativeAndGenericDOMException(NotFoundError); 591 exceptionState.throwUninformativeAndGenericDOMException(NotFoundError);
592 return false; 592 return false;
593 } 593 }
594 594
595 Vector<InspectorStyleProperty> allProperties; 595 Vector<InspectorStyleProperty> allProperties;
596 populateAllProperties(allProperties); 596 populateAllProperties(allProperties);
597 597
598 InspectorStyleTextEditor editor(&allProperties, text, newLineAndWhitespaceDe limiters()); 598 InspectorStyleTextEditor editor(&allProperties, text, newLineAndWhitespaceDe limiters());
599 if (overwrite) { 599 if (overwrite) {
600 if (index >= allProperties.size()) { 600 if (index >= allProperties.size()) {
601 es.throwUninformativeAndGenericDOMException(IndexSizeError); 601 exceptionState.throwUninformativeAndGenericDOMException(IndexSizeErr or);
602 return false; 602 return false;
603 } 603 }
604 *oldText = allProperties.at(index).rawText; 604 *oldText = allProperties.at(index).rawText;
605 editor.replaceProperty(index, propertyText); 605 editor.replaceProperty(index, propertyText);
606 } else 606 } else
607 editor.insertProperty(index, propertyText, sourceData->ruleBodyRange.len gth()); 607 editor.insertProperty(index, propertyText, sourceData->ruleBodyRange.len gth());
608 608
609 return applyStyleText(editor.styleText()); 609 return applyStyleText(editor.styleText());
610 } 610 }
611 611
612 bool InspectorStyle::toggleProperty(unsigned index, bool disable, ExceptionState & es) 612 bool InspectorStyle::toggleProperty(unsigned index, bool disable, ExceptionState & exceptionState)
613 { 613 {
614 ASSERT(m_parentStyleSheet); 614 ASSERT(m_parentStyleSheet);
615 if (!m_parentStyleSheet->ensureParsedDataReady()) { 615 if (!m_parentStyleSheet->ensureParsedDataReady()) {
616 es.throwUninformativeAndGenericDOMException(NoModificationAllowedError); 616 exceptionState.throwUninformativeAndGenericDOMException(NoModificationAl lowedError);
617 return false; 617 return false;
618 } 618 }
619 619
620 RefPtr<CSSRuleSourceData> sourceData = extractSourceData(); 620 RefPtr<CSSRuleSourceData> sourceData = extractSourceData();
621 if (!sourceData) { 621 if (!sourceData) {
622 es.throwUninformativeAndGenericDOMException(NotFoundError); 622 exceptionState.throwUninformativeAndGenericDOMException(NotFoundError);
623 return false; 623 return false;
624 } 624 }
625 625
626 String text; 626 String text;
627 bool success = styleText(&text); 627 bool success = styleText(&text);
628 if (!success) { 628 if (!success) {
629 es.throwUninformativeAndGenericDOMException(NotFoundError); 629 exceptionState.throwUninformativeAndGenericDOMException(NotFoundError);
630 return false; 630 return false;
631 } 631 }
632 632
633 Vector<InspectorStyleProperty> allProperties; 633 Vector<InspectorStyleProperty> allProperties;
634 populateAllProperties(allProperties); 634 populateAllProperties(allProperties);
635 if (index >= allProperties.size()) { 635 if (index >= allProperties.size()) {
636 es.throwUninformativeAndGenericDOMException(IndexSizeError); 636 exceptionState.throwUninformativeAndGenericDOMException(IndexSizeError);
637 return false; 637 return false;
638 } 638 }
639 639
640 InspectorStyleProperty& property = allProperties.at(index); 640 InspectorStyleProperty& property = allProperties.at(index);
641 if (property.sourceData.disabled == disable) 641 if (property.sourceData.disabled == disable)
642 return true; // Idempotent operation. 642 return true; // Idempotent operation.
643 643
644 InspectorStyleTextEditor editor(&allProperties, text, newLineAndWhitespaceDe limiters()); 644 InspectorStyleTextEditor editor(&allProperties, text, newLineAndWhitespaceDe limiters());
645 if (disable) 645 if (disable)
646 editor.disableProperty(index); 646 editor.disableProperty(index);
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after
1021 CSSStyleSheet::RuleMutationScope mutationScope(m_pageStyleSheet.get()); 1021 CSSStyleSheet::RuleMutationScope mutationScope(m_pageStyleSheet.get());
1022 m_pageStyleSheet->contents()->parseString(text); 1022 m_pageStyleSheet->contents()->parseString(text);
1023 } 1023 }
1024 1024
1025 if (m_listener) 1025 if (m_listener)
1026 m_listener->didReparseStyleSheet(); 1026 m_listener->didReparseStyleSheet();
1027 fireStyleSheetChanged(); 1027 fireStyleSheetChanged();
1028 m_pageStyleSheet->ownerDocument()->styleResolverChanged(RecalcStyleImmediate ly, FullStyleUpdate); 1028 m_pageStyleSheet->ownerDocument()->styleResolverChanged(RecalcStyleImmediate ly, FullStyleUpdate);
1029 } 1029 }
1030 1030
1031 bool InspectorStyleSheet::setText(const String& text, ExceptionState& es) 1031 bool InspectorStyleSheet::setText(const String& text, ExceptionState& exceptionS tate)
1032 { 1032 {
1033 if (!checkPageStyleSheet(es)) 1033 if (!checkPageStyleSheet(exceptionState))
1034 return false; 1034 return false;
1035 if (!m_parsedStyleSheet) 1035 if (!m_parsedStyleSheet)
1036 return false; 1036 return false;
1037 1037
1038 m_parsedStyleSheet->setText(text); 1038 m_parsedStyleSheet->setText(text);
1039 m_flatRules.clear(); 1039 m_flatRules.clear();
1040 1040
1041 return true; 1041 return true;
1042 } 1042 }
1043 1043
1044 String InspectorStyleSheet::ruleSelector(const InspectorCSSId& id, ExceptionStat e& es) 1044 String InspectorStyleSheet::ruleSelector(const InspectorCSSId& id, ExceptionStat e& exceptionState)
1045 { 1045 {
1046 CSSStyleRule* rule = ruleForId(id); 1046 CSSStyleRule* rule = ruleForId(id);
1047 if (!rule) { 1047 if (!rule) {
1048 es.throwUninformativeAndGenericDOMException(NotFoundError); 1048 exceptionState.throwUninformativeAndGenericDOMException(NotFoundError);
1049 return ""; 1049 return "";
1050 } 1050 }
1051 return rule->selectorText(); 1051 return rule->selectorText();
1052 } 1052 }
1053 1053
1054 bool InspectorStyleSheet::setRuleSelector(const InspectorCSSId& id, const String & selector, ExceptionState& es) 1054 bool InspectorStyleSheet::setRuleSelector(const InspectorCSSId& id, const String & selector, ExceptionState& exceptionState)
1055 { 1055 {
1056 if (!checkPageStyleSheet(es)) 1056 if (!checkPageStyleSheet(exceptionState))
1057 return false; 1057 return false;
1058 CSSStyleRule* rule = ruleForId(id); 1058 CSSStyleRule* rule = ruleForId(id);
1059 if (!rule) { 1059 if (!rule) {
1060 es.throwUninformativeAndGenericDOMException(NotFoundError); 1060 exceptionState.throwUninformativeAndGenericDOMException(NotFoundError);
1061 return false; 1061 return false;
1062 } 1062 }
1063 CSSStyleSheet* styleSheet = rule->parentStyleSheet(); 1063 CSSStyleSheet* styleSheet = rule->parentStyleSheet();
1064 if (!styleSheet || !ensureParsedDataReady()) { 1064 if (!styleSheet || !ensureParsedDataReady()) {
1065 es.throwUninformativeAndGenericDOMException(NotFoundError); 1065 exceptionState.throwUninformativeAndGenericDOMException(NotFoundError);
1066 return false; 1066 return false;
1067 } 1067 }
1068 1068
1069 rule->setSelectorText(selector); 1069 rule->setSelectorText(selector);
1070 RefPtr<CSSRuleSourceData> sourceData = ruleSourceDataFor(rule->style()); 1070 RefPtr<CSSRuleSourceData> sourceData = ruleSourceDataFor(rule->style());
1071 if (!sourceData) { 1071 if (!sourceData) {
1072 es.throwUninformativeAndGenericDOMException(NotFoundError); 1072 exceptionState.throwUninformativeAndGenericDOMException(NotFoundError);
1073 return false; 1073 return false;
1074 } 1074 }
1075 1075
1076 String sheetText = m_parsedStyleSheet->text(); 1076 String sheetText = m_parsedStyleSheet->text();
1077 sheetText.replace(sourceData->ruleHeaderRange.start, sourceData->ruleHeaderR ange.length(), selector); 1077 sheetText.replace(sourceData->ruleHeaderRange.start, sourceData->ruleHeaderR ange.length(), selector);
1078 m_parsedStyleSheet->setText(sheetText); 1078 m_parsedStyleSheet->setText(sheetText);
1079 fireStyleSheetChanged(); 1079 fireStyleSheetChanged();
1080 return true; 1080 return true;
1081 } 1081 }
1082 1082
1083 static bool checkStyleRuleSelector(Document* document, const String& selector) 1083 static bool checkStyleRuleSelector(Document* document, const String& selector)
1084 { 1084 {
1085 CSSSelectorList selectorList; 1085 CSSSelectorList selectorList;
1086 createCSSParser(document)->parseSelector(selector, selectorList); 1086 createCSSParser(document)->parseSelector(selector, selectorList);
1087 return selectorList.isValid(); 1087 return selectorList.isValid();
1088 } 1088 }
1089 1089
1090 CSSStyleRule* InspectorStyleSheet::addRule(const String& selector, ExceptionStat e& es) 1090 CSSStyleRule* InspectorStyleSheet::addRule(const String& selector, ExceptionStat e& exceptionState)
1091 { 1091 {
1092 if (!checkPageStyleSheet(es)) 1092 if (!checkPageStyleSheet(exceptionState))
1093 return 0; 1093 return 0;
1094 if (!checkStyleRuleSelector(m_pageStyleSheet->ownerDocument(), selector)) { 1094 if (!checkStyleRuleSelector(m_pageStyleSheet->ownerDocument(), selector)) {
1095 es.throwUninformativeAndGenericDOMException(SyntaxError); 1095 exceptionState.throwUninformativeAndGenericDOMException(SyntaxError);
1096 return 0; 1096 return 0;
1097 } 1097 }
1098 1098
1099 String text; 1099 String text;
1100 bool success = getText(&text); 1100 bool success = getText(&text);
1101 if (!success) { 1101 if (!success) {
1102 es.throwUninformativeAndGenericDOMException(NotFoundError); 1102 exceptionState.throwUninformativeAndGenericDOMException(NotFoundError);
1103 return 0; 1103 return 0;
1104 } 1104 }
1105 StringBuilder styleSheetText; 1105 StringBuilder styleSheetText;
1106 styleSheetText.append(text); 1106 styleSheetText.append(text);
1107 1107
1108 m_pageStyleSheet->addRule(selector, "", es); 1108 m_pageStyleSheet->addRule(selector, "", exceptionState);
1109 if (es.hadException()) 1109 if (exceptionState.hadException())
1110 return 0; 1110 return 0;
1111 ASSERT(m_pageStyleSheet->length()); 1111 ASSERT(m_pageStyleSheet->length());
1112 unsigned lastRuleIndex = m_pageStyleSheet->length() - 1; 1112 unsigned lastRuleIndex = m_pageStyleSheet->length() - 1;
1113 CSSRule* rule = m_pageStyleSheet->item(lastRuleIndex); 1113 CSSRule* rule = m_pageStyleSheet->item(lastRuleIndex);
1114 ASSERT(rule); 1114 ASSERT(rule);
1115 1115
1116 CSSStyleRule* styleRule = InspectorCSSAgent::asCSSStyleRule(rule); 1116 CSSStyleRule* styleRule = InspectorCSSAgent::asCSSStyleRule(rule);
1117 if (!styleRule) { 1117 if (!styleRule) {
1118 // What we just added has to be a CSSStyleRule - we cannot handle other types of rules yet. 1118 // What we just added has to be a CSSStyleRule - we cannot handle other types of rules yet.
1119 // If it is not a style rule, pretend we never touched the stylesheet. 1119 // If it is not a style rule, pretend we never touched the stylesheet.
1120 m_pageStyleSheet->deleteRule(lastRuleIndex, ASSERT_NO_EXCEPTION); 1120 m_pageStyleSheet->deleteRule(lastRuleIndex, ASSERT_NO_EXCEPTION);
1121 es.throwUninformativeAndGenericDOMException(SyntaxError); 1121 exceptionState.throwUninformativeAndGenericDOMException(SyntaxError);
1122 return 0; 1122 return 0;
1123 } 1123 }
1124 1124
1125 if (!styleSheetText.isEmpty()) 1125 if (!styleSheetText.isEmpty())
1126 styleSheetText.append('\n'); 1126 styleSheetText.append('\n');
1127 1127
1128 styleSheetText.append(selector); 1128 styleSheetText.append(selector);
1129 styleSheetText.appendLiteral(" {}"); 1129 styleSheetText.appendLiteral(" {}");
1130 // Using setText() as this operation changes the style sheet rule set. 1130 // Using setText() as this operation changes the style sheet rule set.
1131 setText(styleSheetText.toString(), ASSERT_NO_EXCEPTION); 1131 setText(styleSheetText.toString(), ASSERT_NO_EXCEPTION);
1132 1132
1133 fireStyleSheetChanged(); 1133 fireStyleSheetChanged();
1134 1134
1135 return styleRule; 1135 return styleRule;
1136 } 1136 }
1137 1137
1138 bool InspectorStyleSheet::deleteRule(const InspectorCSSId& id, ExceptionState& e s) 1138 bool InspectorStyleSheet::deleteRule(const InspectorCSSId& id, ExceptionState& e xceptionState)
1139 { 1139 {
1140 if (!checkPageStyleSheet(es)) 1140 if (!checkPageStyleSheet(exceptionState))
1141 return false; 1141 return false;
1142 RefPtr<CSSStyleRule> rule = ruleForId(id); 1142 RefPtr<CSSStyleRule> rule = ruleForId(id);
1143 if (!rule) { 1143 if (!rule) {
1144 es.throwUninformativeAndGenericDOMException(NotFoundError); 1144 exceptionState.throwUninformativeAndGenericDOMException(NotFoundError);
1145 return false; 1145 return false;
1146 } 1146 }
1147 CSSStyleSheet* styleSheet = rule->parentStyleSheet(); 1147 CSSStyleSheet* styleSheet = rule->parentStyleSheet();
1148 if (!styleSheet || !ensureParsedDataReady()) { 1148 if (!styleSheet || !ensureParsedDataReady()) {
1149 es.throwUninformativeAndGenericDOMException(NotFoundError); 1149 exceptionState.throwUninformativeAndGenericDOMException(NotFoundError);
1150 return false; 1150 return false;
1151 } 1151 }
1152 1152
1153 RefPtr<CSSRuleSourceData> sourceData = ruleSourceDataFor(rule->style()); 1153 RefPtr<CSSRuleSourceData> sourceData = ruleSourceDataFor(rule->style());
1154 if (!sourceData) { 1154 if (!sourceData) {
1155 es.throwUninformativeAndGenericDOMException(NotFoundError); 1155 exceptionState.throwUninformativeAndGenericDOMException(NotFoundError);
1156 return false; 1156 return false;
1157 } 1157 }
1158 1158
1159 styleSheet->deleteRule(id.ordinal(), es); 1159 styleSheet->deleteRule(id.ordinal(), exceptionState);
1160 // |rule| MAY NOT be addressed after this line! 1160 // |rule| MAY NOT be addressed after this line!
1161 1161
1162 if (es.hadException()) 1162 if (exceptionState.hadException())
1163 return false; 1163 return false;
1164 1164
1165 String sheetText = m_parsedStyleSheet->text(); 1165 String sheetText = m_parsedStyleSheet->text();
1166 sheetText.remove(sourceData->ruleHeaderRange.start, sourceData->ruleBodyRang e.end - sourceData->ruleHeaderRange.start + 1); 1166 sheetText.remove(sourceData->ruleHeaderRange.start, sourceData->ruleBodyRang e.end - sourceData->ruleHeaderRange.start + 1);
1167 setText(sheetText, ASSERT_NO_EXCEPTION); 1167 setText(sheetText, ASSERT_NO_EXCEPTION);
1168 fireStyleSheetChanged(); 1168 fireStyleSheetChanged();
1169 return true; 1169 return true;
1170 } 1170 }
1171 1171
1172 CSSStyleRule* InspectorStyleSheet::ruleForId(const InspectorCSSId& id) const 1172 CSSStyleRule* InspectorStyleSheet::ruleForId(const InspectorCSSId& id) const
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
1322 bool success = getText(&sheetText); 1322 bool success = getText(&sheetText);
1323 if (success) { 1323 if (success) {
1324 const SourceRange& bodyRange = sourceData->ruleBodyRange; 1324 const SourceRange& bodyRange = sourceData->ruleBodyRange;
1325 result->setCssText(sheetText.substring(bodyRange.start, bodyRange.en d - bodyRange.start)); 1325 result->setCssText(sheetText.substring(bodyRange.start, bodyRange.en d - bodyRange.start));
1326 } 1326 }
1327 } 1327 }
1328 1328
1329 return result.release(); 1329 return result.release();
1330 } 1330 }
1331 1331
1332 bool InspectorStyleSheet::setStyleText(const InspectorCSSId& id, const String& t ext, String* oldText, ExceptionState& es) 1332 bool InspectorStyleSheet::setStyleText(const InspectorCSSId& id, const String& t ext, String* oldText, ExceptionState& exceptionState)
1333 { 1333 {
1334 RefPtr<InspectorStyle> inspectorStyle = inspectorStyleForId(id); 1334 RefPtr<InspectorStyle> inspectorStyle = inspectorStyleForId(id);
1335 if (!inspectorStyle || !inspectorStyle->cssStyle()) { 1335 if (!inspectorStyle || !inspectorStyle->cssStyle()) {
1336 es.throwUninformativeAndGenericDOMException(NotFoundError); 1336 exceptionState.throwUninformativeAndGenericDOMException(NotFoundError);
1337 return false; 1337 return false;
1338 } 1338 }
1339 1339
1340 bool success = inspectorStyle->styleText(oldText); 1340 bool success = inspectorStyle->styleText(oldText);
1341 if (!success) { 1341 if (!success) {
1342 es.throwUninformativeAndGenericDOMException(NotFoundError); 1342 exceptionState.throwUninformativeAndGenericDOMException(NotFoundError);
1343 return false; 1343 return false;
1344 } 1344 }
1345 1345
1346 success = setStyleText(inspectorStyle->cssStyle(), text); 1346 success = setStyleText(inspectorStyle->cssStyle(), text);
1347 if (success) 1347 if (success)
1348 fireStyleSheetChanged(); 1348 fireStyleSheetChanged();
1349 else 1349 else
1350 es.throwUninformativeAndGenericDOMException(SyntaxError); 1350 exceptionState.throwUninformativeAndGenericDOMException(SyntaxError);
1351 return success; 1351 return success;
1352 } 1352 }
1353 1353
1354 bool InspectorStyleSheet::setPropertyText(const InspectorCSSId& id, unsigned pro pertyIndex, const String& text, bool overwrite, String* oldText, ExceptionState& es) 1354 bool InspectorStyleSheet::setPropertyText(const InspectorCSSId& id, unsigned pro pertyIndex, const String& text, bool overwrite, String* oldText, ExceptionState& exceptionState)
1355 { 1355 {
1356 RefPtr<InspectorStyle> inspectorStyle = inspectorStyleForId(id); 1356 RefPtr<InspectorStyle> inspectorStyle = inspectorStyleForId(id);
1357 if (!inspectorStyle) { 1357 if (!inspectorStyle) {
1358 es.throwUninformativeAndGenericDOMException(NotFoundError); 1358 exceptionState.throwUninformativeAndGenericDOMException(NotFoundError);
1359 return false; 1359 return false;
1360 } 1360 }
1361 1361
1362 bool success = inspectorStyle->setPropertyText(propertyIndex, text, overwrit e, oldText, es); 1362 bool success = inspectorStyle->setPropertyText(propertyIndex, text, overwrit e, oldText, exceptionState);
1363 if (success) 1363 if (success)
1364 fireStyleSheetChanged(); 1364 fireStyleSheetChanged();
1365 return success; 1365 return success;
1366 } 1366 }
1367 1367
1368 bool InspectorStyleSheet::toggleProperty(const InspectorCSSId& id, unsigned prop ertyIndex, bool disable, ExceptionState& es) 1368 bool InspectorStyleSheet::toggleProperty(const InspectorCSSId& id, unsigned prop ertyIndex, bool disable, ExceptionState& exceptionState)
1369 { 1369 {
1370 RefPtr<InspectorStyle> inspectorStyle = inspectorStyleForId(id); 1370 RefPtr<InspectorStyle> inspectorStyle = inspectorStyleForId(id);
1371 if (!inspectorStyle) { 1371 if (!inspectorStyle) {
1372 es.throwUninformativeAndGenericDOMException(NotFoundError); 1372 exceptionState.throwUninformativeAndGenericDOMException(NotFoundError);
1373 return false; 1373 return false;
1374 } 1374 }
1375 1375
1376 bool success = inspectorStyle->toggleProperty(propertyIndex, disable, es); 1376 bool success = inspectorStyle->toggleProperty(propertyIndex, disable, except ionState);
1377 if (success) 1377 if (success)
1378 fireStyleSheetChanged(); 1378 fireStyleSheetChanged();
1379 return success; 1379 return success;
1380 } 1380 }
1381 1381
1382 bool InspectorStyleSheet::getText(String* result) const 1382 bool InspectorStyleSheet::getText(String* result) const
1383 { 1383 {
1384 if (!ensureText()) 1384 if (!ensureText())
1385 return false; 1385 return false;
1386 *result = m_parsedStyleSheet->text(); 1386 *result = m_parsedStyleSheet->text();
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
1533 return UINT_MAX; 1533 return UINT_MAX;
1534 } 1534 }
1535 1535
1536 unsigned InspectorStyleSheet::ruleIndexByRule(const CSSRule* rule) const 1536 unsigned InspectorStyleSheet::ruleIndexByRule(const CSSRule* rule) const
1537 { 1537 {
1538 ensureFlatRules(); 1538 ensureFlatRules();
1539 size_t index = m_flatRules.find(rule); 1539 size_t index = m_flatRules.find(rule);
1540 return index == kNotFound ? UINT_MAX : static_cast<unsigned>(index); 1540 return index == kNotFound ? UINT_MAX : static_cast<unsigned>(index);
1541 } 1541 }
1542 1542
1543 bool InspectorStyleSheet::checkPageStyleSheet(ExceptionState& es) const 1543 bool InspectorStyleSheet::checkPageStyleSheet(ExceptionState& exceptionState) co nst
1544 { 1544 {
1545 if (!m_pageStyleSheet) { 1545 if (!m_pageStyleSheet) {
1546 es.throwUninformativeAndGenericDOMException(NotSupportedError); 1546 exceptionState.throwUninformativeAndGenericDOMException(NotSupportedErro r);
1547 return false; 1547 return false;
1548 } 1548 }
1549 return true; 1549 return true;
1550 } 1550 }
1551 1551
1552 bool InspectorStyleSheet::ensureParsedDataReady() 1552 bool InspectorStyleSheet::ensureParsedDataReady()
1553 { 1553 {
1554 return ensureText() && ensureSourceData(); 1554 return ensureText() && ensureSourceData();
1555 } 1555 }
1556 1556
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
1602 1602
1603 String patchedStyleSheetText; 1603 String patchedStyleSheetText;
1604 bool success = styleSheetTextWithChangedStyle(style, text, &patchedStyleShee tText); 1604 bool success = styleSheetTextWithChangedStyle(style, text, &patchedStyleShee tText);
1605 if (!success) 1605 if (!success)
1606 return false; 1606 return false;
1607 1607
1608 InspectorCSSId id = ruleOrStyleId(style); 1608 InspectorCSSId id = ruleOrStyleId(style);
1609 if (id.isEmpty()) 1609 if (id.isEmpty())
1610 return false; 1610 return false;
1611 1611
1612 TrackExceptionState es; 1612 TrackExceptionState exceptionState;
1613 style->setCSSText(text, es); 1613 style->setCSSText(text, exceptionState);
1614 if (!es.hadException()) 1614 if (!exceptionState.hadException())
1615 m_parsedStyleSheet->setText(patchedStyleSheetText); 1615 m_parsedStyleSheet->setText(patchedStyleSheetText);
1616 1616
1617 return !es.hadException(); 1617 return !exceptionState.hadException();
1618 } 1618 }
1619 1619
1620 bool InspectorStyleSheet::styleSheetTextWithChangedStyle(CSSStyleDeclaration* st yle, const String& newStyleText, String* result) 1620 bool InspectorStyleSheet::styleSheetTextWithChangedStyle(CSSStyleDeclaration* st yle, const String& newStyleText, String* result)
1621 { 1621 {
1622 if (!style) 1622 if (!style)
1623 return false; 1623 return false;
1624 1624
1625 if (!ensureParsedDataReady()) 1625 if (!ensureParsedDataReady())
1626 return false; 1626 return false;
1627 1627
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
1728 m_styleText = elementStyleText(); 1728 m_styleText = elementStyleText();
1729 m_isStyleTextValid = true; 1729 m_isStyleTextValid = true;
1730 } 1730 }
1731 *result = m_styleText; 1731 *result = m_styleText;
1732 return true; 1732 return true;
1733 } 1733 }
1734 1734
1735 bool InspectorStyleSheetForInlineStyle::setStyleText(CSSStyleDeclaration* style, const String& text) 1735 bool InspectorStyleSheetForInlineStyle::setStyleText(CSSStyleDeclaration* style, const String& text)
1736 { 1736 {
1737 ASSERT_UNUSED(style, style == inlineStyle()); 1737 ASSERT_UNUSED(style, style == inlineStyle());
1738 TrackExceptionState es; 1738 TrackExceptionState exceptionState;
1739 1739
1740 { 1740 {
1741 InspectorCSSAgent::InlineStyleOverrideScope overrideScope(m_element->own erDocument()); 1741 InspectorCSSAgent::InlineStyleOverrideScope overrideScope(m_element->own erDocument());
1742 m_element->setAttribute("style", text, es); 1742 m_element->setAttribute("style", text, exceptionState);
1743 } 1743 }
1744 1744
1745 m_styleText = text; 1745 m_styleText = text;
1746 m_isStyleTextValid = true; 1746 m_isStyleTextValid = true;
1747 m_ruleSourceData.clear(); 1747 m_ruleSourceData.clear();
1748 return !es.hadException(); 1748 return !exceptionState.hadException();
1749 } 1749 }
1750 1750
1751 PassOwnPtr<Vector<unsigned> > InspectorStyleSheetForInlineStyle::lineEndings() c onst 1751 PassOwnPtr<Vector<unsigned> > InspectorStyleSheetForInlineStyle::lineEndings() c onst
1752 { 1752 {
1753 return WTF::lineEndings(elementStyleText()); 1753 return WTF::lineEndings(elementStyleText());
1754 } 1754 }
1755 1755
1756 Document* InspectorStyleSheetForInlineStyle::ownerDocument() const 1756 Document* InspectorStyleSheetForInlineStyle::ownerDocument() const
1757 { 1757 {
1758 return &m_element->document(); 1758 return &m_element->document();
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
1812 1812
1813 RefPtr<MutableStylePropertySet> tempDeclaration = MutableStylePropertySet::c reate(); 1813 RefPtr<MutableStylePropertySet> tempDeclaration = MutableStylePropertySet::c reate();
1814 RuleSourceDataList ruleSourceDataResult; 1814 RuleSourceDataList ruleSourceDataResult;
1815 StyleSheetHandler handler(m_styleText, &m_element->document(), m_element->do cument().elementSheet()->contents(), &ruleSourceDataResult); 1815 StyleSheetHandler handler(m_styleText, &m_element->document(), m_element->do cument().elementSheet()->contents(), &ruleSourceDataResult);
1816 createCSSParser(&m_element->document())->parseDeclaration(tempDeclaration.ge t(), m_styleText, &handler, m_element->document().elementSheet()->contents()); 1816 createCSSParser(&m_element->document())->parseDeclaration(tempDeclaration.ge t(), m_styleText, &handler, m_element->document().elementSheet()->contents());
1817 return ruleSourceDataResult.first().release(); 1817 return ruleSourceDataResult.first().release();
1818 } 1818 }
1819 1819
1820 } // namespace WebCore 1820 } // namespace WebCore
1821 1821
OLDNEW
« no previous file with comments | « Source/core/inspector/InspectorIndexedDBAgent.cpp ('k') | Source/core/loader/appcache/ApplicationCache.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698