| OLD | NEW |
| 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 537 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 548 // - A heuristic formatting is attempted to retain the style structure. | 548 // - A heuristic formatting is attempted to retain the style structure. |
| 549 // | 549 // |
| 550 // The propertyText (if not empty) is checked to be a valid style declaration (c
ontaining at least one property). If not, | 550 // The propertyText (if not empty) is checked to be a valid style declaration (c
ontaining at least one property). If not, |
| 551 // the method returns false (denoting an error). | 551 // the method returns false (denoting an error). |
| 552 bool InspectorStyle::setPropertyText(unsigned index, const String& propertyText,
bool overwrite, String* oldText, ExceptionState& es) | 552 bool InspectorStyle::setPropertyText(unsigned index, const String& propertyText,
bool overwrite, String* oldText, ExceptionState& es) |
| 553 { | 553 { |
| 554 ASSERT(m_parentStyleSheet); | 554 ASSERT(m_parentStyleSheet); |
| 555 DEFINE_STATIC_LOCAL(String, bogusPropertyName, ("-webkit-boguz-propertee")); | 555 DEFINE_STATIC_LOCAL(String, bogusPropertyName, ("-webkit-boguz-propertee")); |
| 556 | 556 |
| 557 if (!m_parentStyleSheet->ensureParsedDataReady()) { | 557 if (!m_parentStyleSheet->ensureParsedDataReady()) { |
| 558 es.throwDOMException(NotFoundError); | 558 es.throwUninformativeAndGenericDOMException(NotFoundError); |
| 559 return false; | 559 return false; |
| 560 } | 560 } |
| 561 | 561 |
| 562 if (!propertyText.stripWhiteSpace().isEmpty()) { | 562 if (!propertyText.stripWhiteSpace().isEmpty()) { |
| 563 RefPtr<MutableStylePropertySet> tempMutableStyle = MutableStylePropertyS
et::create(); | 563 RefPtr<MutableStylePropertySet> tempMutableStyle = MutableStylePropertyS
et::create(); |
| 564 String declarationText = propertyText + " " + bogusPropertyName + ": non
e"; | 564 String declarationText = propertyText + " " + bogusPropertyName + ": non
e"; |
| 565 RuleSourceDataList sourceData; | 565 RuleSourceDataList sourceData; |
| 566 StyleSheetHandler handler(declarationText, ownerDocument(), m_style->par
entStyleSheet()->contents(), &sourceData); | 566 StyleSheetHandler handler(declarationText, ownerDocument(), m_style->par
entStyleSheet()->contents(), &sourceData); |
| 567 createCSSParser(ownerDocument())->parseDeclaration(tempMutableStyle.get(
), declarationText, &handler, m_style->parentStyleSheet()->contents()); | 567 createCSSParser(ownerDocument())->parseDeclaration(tempMutableStyle.get(
), declarationText, &handler, m_style->parentStyleSheet()->contents()); |
| 568 Vector<CSSPropertySourceData>& propertyData = sourceData.first()->styleS
ourceData->propertyData; | 568 Vector<CSSPropertySourceData>& propertyData = sourceData.first()->styleS
ourceData->propertyData; |
| 569 unsigned propertyCount = propertyData.size(); | 569 unsigned propertyCount = propertyData.size(); |
| 570 | 570 |
| 571 // At least one property + the bogus property added just above should be
present. | 571 // At least one property + the bogus property added just above should be
present. |
| 572 if (propertyCount < 2) { | 572 if (propertyCount < 2) { |
| 573 es.throwDOMException(SyntaxError); | 573 es.throwUninformativeAndGenericDOMException(SyntaxError); |
| 574 return false; | 574 return false; |
| 575 } | 575 } |
| 576 | 576 |
| 577 // Check for the proper propertyText termination (the parser could at le
ast restore to the PROPERTY_NAME state). | 577 // Check for the proper propertyText termination (the parser could at le
ast restore to the PROPERTY_NAME state). |
| 578 if (propertyData.at(propertyCount - 1).name != bogusPropertyName) { | 578 if (propertyData.at(propertyCount - 1).name != bogusPropertyName) { |
| 579 es.throwDOMException(SyntaxError); | 579 es.throwUninformativeAndGenericDOMException(SyntaxError); |
| 580 return false; | 580 return false; |
| 581 } | 581 } |
| 582 } | 582 } |
| 583 | 583 |
| 584 RefPtr<CSSRuleSourceData> sourceData = extractSourceData(); | 584 RefPtr<CSSRuleSourceData> sourceData = extractSourceData(); |
| 585 if (!sourceData) { | 585 if (!sourceData) { |
| 586 es.throwDOMException(NotFoundError); | 586 es.throwUninformativeAndGenericDOMException(NotFoundError); |
| 587 return false; | 587 return false; |
| 588 } | 588 } |
| 589 | 589 |
| 590 String text; | 590 String text; |
| 591 bool success = styleText(&text); | 591 bool success = styleText(&text); |
| 592 if (!success) { | 592 if (!success) { |
| 593 es.throwDOMException(NotFoundError); | 593 es.throwUninformativeAndGenericDOMException(NotFoundError); |
| 594 return false; | 594 return false; |
| 595 } | 595 } |
| 596 | 596 |
| 597 Vector<InspectorStyleProperty> allProperties; | 597 Vector<InspectorStyleProperty> allProperties; |
| 598 populateAllProperties(allProperties); | 598 populateAllProperties(allProperties); |
| 599 | 599 |
| 600 InspectorStyleTextEditor editor(&allProperties, text, newLineAndWhitespaceDe
limiters()); | 600 InspectorStyleTextEditor editor(&allProperties, text, newLineAndWhitespaceDe
limiters()); |
| 601 if (overwrite) { | 601 if (overwrite) { |
| 602 if (index >= allProperties.size()) { | 602 if (index >= allProperties.size()) { |
| 603 es.throwDOMException(IndexSizeError); | 603 es.throwUninformativeAndGenericDOMException(IndexSizeError); |
| 604 return false; | 604 return false; |
| 605 } | 605 } |
| 606 *oldText = allProperties.at(index).rawText; | 606 *oldText = allProperties.at(index).rawText; |
| 607 editor.replaceProperty(index, propertyText); | 607 editor.replaceProperty(index, propertyText); |
| 608 } else | 608 } else |
| 609 editor.insertProperty(index, propertyText, sourceData->ruleBodyRange.len
gth()); | 609 editor.insertProperty(index, propertyText, sourceData->ruleBodyRange.len
gth()); |
| 610 | 610 |
| 611 return applyStyleText(editor.styleText()); | 611 return applyStyleText(editor.styleText()); |
| 612 } | 612 } |
| 613 | 613 |
| 614 bool InspectorStyle::toggleProperty(unsigned index, bool disable, ExceptionState
& es) | 614 bool InspectorStyle::toggleProperty(unsigned index, bool disable, ExceptionState
& es) |
| 615 { | 615 { |
| 616 ASSERT(m_parentStyleSheet); | 616 ASSERT(m_parentStyleSheet); |
| 617 if (!m_parentStyleSheet->ensureParsedDataReady()) { | 617 if (!m_parentStyleSheet->ensureParsedDataReady()) { |
| 618 es.throwDOMException(NoModificationAllowedError); | 618 es.throwUninformativeAndGenericDOMException(NoModificationAllowedError); |
| 619 return false; | 619 return false; |
| 620 } | 620 } |
| 621 | 621 |
| 622 RefPtr<CSSRuleSourceData> sourceData = extractSourceData(); | 622 RefPtr<CSSRuleSourceData> sourceData = extractSourceData(); |
| 623 if (!sourceData) { | 623 if (!sourceData) { |
| 624 es.throwDOMException(NotFoundError); | 624 es.throwUninformativeAndGenericDOMException(NotFoundError); |
| 625 return false; | 625 return false; |
| 626 } | 626 } |
| 627 | 627 |
| 628 String text; | 628 String text; |
| 629 bool success = styleText(&text); | 629 bool success = styleText(&text); |
| 630 if (!success) { | 630 if (!success) { |
| 631 es.throwDOMException(NotFoundError); | 631 es.throwUninformativeAndGenericDOMException(NotFoundError); |
| 632 return false; | 632 return false; |
| 633 } | 633 } |
| 634 | 634 |
| 635 Vector<InspectorStyleProperty> allProperties; | 635 Vector<InspectorStyleProperty> allProperties; |
| 636 populateAllProperties(allProperties); | 636 populateAllProperties(allProperties); |
| 637 if (index >= allProperties.size()) { | 637 if (index >= allProperties.size()) { |
| 638 es.throwDOMException(IndexSizeError); | 638 es.throwUninformativeAndGenericDOMException(IndexSizeError); |
| 639 return false; | 639 return false; |
| 640 } | 640 } |
| 641 | 641 |
| 642 InspectorStyleProperty& property = allProperties.at(index); | 642 InspectorStyleProperty& property = allProperties.at(index); |
| 643 if (property.sourceData.disabled == disable) | 643 if (property.sourceData.disabled == disable) |
| 644 return true; // Idempotent operation. | 644 return true; // Idempotent operation. |
| 645 | 645 |
| 646 InspectorStyleTextEditor editor(&allProperties, text, newLineAndWhitespaceDe
limiters()); | 646 InspectorStyleTextEditor editor(&allProperties, text, newLineAndWhitespaceDe
limiters()); |
| 647 if (disable) | 647 if (disable) |
| 648 editor.disableProperty(index); | 648 editor.disableProperty(index); |
| (...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1043 m_parsedStyleSheet->setText(text); | 1043 m_parsedStyleSheet->setText(text); |
| 1044 m_flatRules.clear(); | 1044 m_flatRules.clear(); |
| 1045 | 1045 |
| 1046 return true; | 1046 return true; |
| 1047 } | 1047 } |
| 1048 | 1048 |
| 1049 String InspectorStyleSheet::ruleSelector(const InspectorCSSId& id, ExceptionStat
e& es) | 1049 String InspectorStyleSheet::ruleSelector(const InspectorCSSId& id, ExceptionStat
e& es) |
| 1050 { | 1050 { |
| 1051 CSSStyleRule* rule = ruleForId(id); | 1051 CSSStyleRule* rule = ruleForId(id); |
| 1052 if (!rule) { | 1052 if (!rule) { |
| 1053 es.throwDOMException(NotFoundError); | 1053 es.throwUninformativeAndGenericDOMException(NotFoundError); |
| 1054 return ""; | 1054 return ""; |
| 1055 } | 1055 } |
| 1056 return rule->selectorText(); | 1056 return rule->selectorText(); |
| 1057 } | 1057 } |
| 1058 | 1058 |
| 1059 bool InspectorStyleSheet::setRuleSelector(const InspectorCSSId& id, const String
& selector, ExceptionState& es) | 1059 bool InspectorStyleSheet::setRuleSelector(const InspectorCSSId& id, const String
& selector, ExceptionState& es) |
| 1060 { | 1060 { |
| 1061 if (!checkPageStyleSheet(es)) | 1061 if (!checkPageStyleSheet(es)) |
| 1062 return false; | 1062 return false; |
| 1063 CSSStyleRule* rule = ruleForId(id); | 1063 CSSStyleRule* rule = ruleForId(id); |
| 1064 if (!rule) { | 1064 if (!rule) { |
| 1065 es.throwDOMException(NotFoundError); | 1065 es.throwUninformativeAndGenericDOMException(NotFoundError); |
| 1066 return false; | 1066 return false; |
| 1067 } | 1067 } |
| 1068 CSSStyleSheet* styleSheet = rule->parentStyleSheet(); | 1068 CSSStyleSheet* styleSheet = rule->parentStyleSheet(); |
| 1069 if (!styleSheet || !ensureParsedDataReady()) { | 1069 if (!styleSheet || !ensureParsedDataReady()) { |
| 1070 es.throwDOMException(NotFoundError); | 1070 es.throwUninformativeAndGenericDOMException(NotFoundError); |
| 1071 return false; | 1071 return false; |
| 1072 } | 1072 } |
| 1073 | 1073 |
| 1074 rule->setSelectorText(selector); | 1074 rule->setSelectorText(selector); |
| 1075 RefPtr<CSSRuleSourceData> sourceData = ruleSourceDataFor(rule->style()); | 1075 RefPtr<CSSRuleSourceData> sourceData = ruleSourceDataFor(rule->style()); |
| 1076 if (!sourceData) { | 1076 if (!sourceData) { |
| 1077 es.throwDOMException(NotFoundError); | 1077 es.throwUninformativeAndGenericDOMException(NotFoundError); |
| 1078 return false; | 1078 return false; |
| 1079 } | 1079 } |
| 1080 | 1080 |
| 1081 String sheetText = m_parsedStyleSheet->text(); | 1081 String sheetText = m_parsedStyleSheet->text(); |
| 1082 sheetText.replace(sourceData->ruleHeaderRange.start, sourceData->ruleHeaderR
ange.length(), selector); | 1082 sheetText.replace(sourceData->ruleHeaderRange.start, sourceData->ruleHeaderR
ange.length(), selector); |
| 1083 m_parsedStyleSheet->setText(sheetText); | 1083 m_parsedStyleSheet->setText(sheetText); |
| 1084 fireStyleSheetChanged(); | 1084 fireStyleSheetChanged(); |
| 1085 return true; | 1085 return true; |
| 1086 } | 1086 } |
| 1087 | 1087 |
| 1088 static bool checkStyleRuleSelector(Document* document, const String& selector) | 1088 static bool checkStyleRuleSelector(Document* document, const String& selector) |
| 1089 { | 1089 { |
| 1090 CSSSelectorList selectorList; | 1090 CSSSelectorList selectorList; |
| 1091 createCSSParser(document)->parseSelector(selector, selectorList); | 1091 createCSSParser(document)->parseSelector(selector, selectorList); |
| 1092 return selectorList.isValid(); | 1092 return selectorList.isValid(); |
| 1093 } | 1093 } |
| 1094 | 1094 |
| 1095 CSSStyleRule* InspectorStyleSheet::addRule(const String& selector, ExceptionStat
e& es) | 1095 CSSStyleRule* InspectorStyleSheet::addRule(const String& selector, ExceptionStat
e& es) |
| 1096 { | 1096 { |
| 1097 if (!checkPageStyleSheet(es)) | 1097 if (!checkPageStyleSheet(es)) |
| 1098 return 0; | 1098 return 0; |
| 1099 if (!checkStyleRuleSelector(m_pageStyleSheet->ownerDocument(), selector)) { | 1099 if (!checkStyleRuleSelector(m_pageStyleSheet->ownerDocument(), selector)) { |
| 1100 es.throwDOMException(SyntaxError); | 1100 es.throwUninformativeAndGenericDOMException(SyntaxError); |
| 1101 return 0; | 1101 return 0; |
| 1102 } | 1102 } |
| 1103 | 1103 |
| 1104 String text; | 1104 String text; |
| 1105 bool success = getText(&text); | 1105 bool success = getText(&text); |
| 1106 if (!success) { | 1106 if (!success) { |
| 1107 es.throwDOMException(NotFoundError); | 1107 es.throwUninformativeAndGenericDOMException(NotFoundError); |
| 1108 return 0; | 1108 return 0; |
| 1109 } | 1109 } |
| 1110 StringBuilder styleSheetText; | 1110 StringBuilder styleSheetText; |
| 1111 styleSheetText.append(text); | 1111 styleSheetText.append(text); |
| 1112 | 1112 |
| 1113 m_pageStyleSheet->addRule(selector, "", es); | 1113 m_pageStyleSheet->addRule(selector, "", es); |
| 1114 if (es.hadException()) | 1114 if (es.hadException()) |
| 1115 return 0; | 1115 return 0; |
| 1116 ASSERT(m_pageStyleSheet->length()); | 1116 ASSERT(m_pageStyleSheet->length()); |
| 1117 unsigned lastRuleIndex = m_pageStyleSheet->length() - 1; | 1117 unsigned lastRuleIndex = m_pageStyleSheet->length() - 1; |
| 1118 CSSRule* rule = m_pageStyleSheet->item(lastRuleIndex); | 1118 CSSRule* rule = m_pageStyleSheet->item(lastRuleIndex); |
| 1119 ASSERT(rule); | 1119 ASSERT(rule); |
| 1120 | 1120 |
| 1121 CSSStyleRule* styleRule = InspectorCSSAgent::asCSSStyleRule(rule); | 1121 CSSStyleRule* styleRule = InspectorCSSAgent::asCSSStyleRule(rule); |
| 1122 if (!styleRule) { | 1122 if (!styleRule) { |
| 1123 // What we just added has to be a CSSStyleRule - we cannot handle other
types of rules yet. | 1123 // What we just added has to be a CSSStyleRule - we cannot handle other
types of rules yet. |
| 1124 // If it is not a style rule, pretend we never touched the stylesheet. | 1124 // If it is not a style rule, pretend we never touched the stylesheet. |
| 1125 m_pageStyleSheet->deleteRule(lastRuleIndex, ASSERT_NO_EXCEPTION); | 1125 m_pageStyleSheet->deleteRule(lastRuleIndex, ASSERT_NO_EXCEPTION); |
| 1126 es.throwDOMException(SyntaxError); | 1126 es.throwUninformativeAndGenericDOMException(SyntaxError); |
| 1127 return 0; | 1127 return 0; |
| 1128 } | 1128 } |
| 1129 | 1129 |
| 1130 if (!styleSheetText.isEmpty()) | 1130 if (!styleSheetText.isEmpty()) |
| 1131 styleSheetText.append('\n'); | 1131 styleSheetText.append('\n'); |
| 1132 | 1132 |
| 1133 styleSheetText.append(selector); | 1133 styleSheetText.append(selector); |
| 1134 styleSheetText.appendLiteral(" {}"); | 1134 styleSheetText.appendLiteral(" {}"); |
| 1135 // Using setText() as this operation changes the style sheet rule set. | 1135 // Using setText() as this operation changes the style sheet rule set. |
| 1136 setText(styleSheetText.toString(), ASSERT_NO_EXCEPTION); | 1136 setText(styleSheetText.toString(), ASSERT_NO_EXCEPTION); |
| 1137 | 1137 |
| 1138 fireStyleSheetChanged(); | 1138 fireStyleSheetChanged(); |
| 1139 | 1139 |
| 1140 return styleRule; | 1140 return styleRule; |
| 1141 } | 1141 } |
| 1142 | 1142 |
| 1143 bool InspectorStyleSheet::deleteRule(const InspectorCSSId& id, ExceptionState& e
s) | 1143 bool InspectorStyleSheet::deleteRule(const InspectorCSSId& id, ExceptionState& e
s) |
| 1144 { | 1144 { |
| 1145 if (!checkPageStyleSheet(es)) | 1145 if (!checkPageStyleSheet(es)) |
| 1146 return false; | 1146 return false; |
| 1147 RefPtr<CSSStyleRule> rule = ruleForId(id); | 1147 RefPtr<CSSStyleRule> rule = ruleForId(id); |
| 1148 if (!rule) { | 1148 if (!rule) { |
| 1149 es.throwDOMException(NotFoundError); | 1149 es.throwUninformativeAndGenericDOMException(NotFoundError); |
| 1150 return false; | 1150 return false; |
| 1151 } | 1151 } |
| 1152 CSSStyleSheet* styleSheet = rule->parentStyleSheet(); | 1152 CSSStyleSheet* styleSheet = rule->parentStyleSheet(); |
| 1153 if (!styleSheet || !ensureParsedDataReady()) { | 1153 if (!styleSheet || !ensureParsedDataReady()) { |
| 1154 es.throwDOMException(NotFoundError); | 1154 es.throwUninformativeAndGenericDOMException(NotFoundError); |
| 1155 return false; | 1155 return false; |
| 1156 } | 1156 } |
| 1157 | 1157 |
| 1158 RefPtr<CSSRuleSourceData> sourceData = ruleSourceDataFor(rule->style()); | 1158 RefPtr<CSSRuleSourceData> sourceData = ruleSourceDataFor(rule->style()); |
| 1159 if (!sourceData) { | 1159 if (!sourceData) { |
| 1160 es.throwDOMException(NotFoundError); | 1160 es.throwUninformativeAndGenericDOMException(NotFoundError); |
| 1161 return false; | 1161 return false; |
| 1162 } | 1162 } |
| 1163 | 1163 |
| 1164 styleSheet->deleteRule(id.ordinal(), es); | 1164 styleSheet->deleteRule(id.ordinal(), es); |
| 1165 // |rule| MAY NOT be addressed after this line! | 1165 // |rule| MAY NOT be addressed after this line! |
| 1166 | 1166 |
| 1167 if (es.hadException()) | 1167 if (es.hadException()) |
| 1168 return false; | 1168 return false; |
| 1169 | 1169 |
| 1170 String sheetText = m_parsedStyleSheet->text(); | 1170 String sheetText = m_parsedStyleSheet->text(); |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1330 } | 1330 } |
| 1331 } | 1331 } |
| 1332 | 1332 |
| 1333 return result.release(); | 1333 return result.release(); |
| 1334 } | 1334 } |
| 1335 | 1335 |
| 1336 bool InspectorStyleSheet::setStyleText(const InspectorCSSId& id, const String& t
ext, String* oldText, ExceptionState& es) | 1336 bool InspectorStyleSheet::setStyleText(const InspectorCSSId& id, const String& t
ext, String* oldText, ExceptionState& es) |
| 1337 { | 1337 { |
| 1338 RefPtr<InspectorStyle> inspectorStyle = inspectorStyleForId(id); | 1338 RefPtr<InspectorStyle> inspectorStyle = inspectorStyleForId(id); |
| 1339 if (!inspectorStyle || !inspectorStyle->cssStyle()) { | 1339 if (!inspectorStyle || !inspectorStyle->cssStyle()) { |
| 1340 es.throwDOMException(NotFoundError); | 1340 es.throwUninformativeAndGenericDOMException(NotFoundError); |
| 1341 return false; | 1341 return false; |
| 1342 } | 1342 } |
| 1343 | 1343 |
| 1344 bool success = inspectorStyle->styleText(oldText); | 1344 bool success = inspectorStyle->styleText(oldText); |
| 1345 if (!success) { | 1345 if (!success) { |
| 1346 es.throwDOMException(NotFoundError); | 1346 es.throwUninformativeAndGenericDOMException(NotFoundError); |
| 1347 return false; | 1347 return false; |
| 1348 } | 1348 } |
| 1349 | 1349 |
| 1350 success = setStyleText(inspectorStyle->cssStyle(), text); | 1350 success = setStyleText(inspectorStyle->cssStyle(), text); |
| 1351 if (success) | 1351 if (success) |
| 1352 fireStyleSheetChanged(); | 1352 fireStyleSheetChanged(); |
| 1353 else | 1353 else |
| 1354 es.throwDOMException(SyntaxError); | 1354 es.throwUninformativeAndGenericDOMException(SyntaxError); |
| 1355 return success; | 1355 return success; |
| 1356 } | 1356 } |
| 1357 | 1357 |
| 1358 bool InspectorStyleSheet::setPropertyText(const InspectorCSSId& id, unsigned pro
pertyIndex, const String& text, bool overwrite, String* oldText, ExceptionState&
es) | 1358 bool InspectorStyleSheet::setPropertyText(const InspectorCSSId& id, unsigned pro
pertyIndex, const String& text, bool overwrite, String* oldText, ExceptionState&
es) |
| 1359 { | 1359 { |
| 1360 RefPtr<InspectorStyle> inspectorStyle = inspectorStyleForId(id); | 1360 RefPtr<InspectorStyle> inspectorStyle = inspectorStyleForId(id); |
| 1361 if (!inspectorStyle) { | 1361 if (!inspectorStyle) { |
| 1362 es.throwDOMException(NotFoundError); | 1362 es.throwUninformativeAndGenericDOMException(NotFoundError); |
| 1363 return false; | 1363 return false; |
| 1364 } | 1364 } |
| 1365 | 1365 |
| 1366 bool success = inspectorStyle->setPropertyText(propertyIndex, text, overwrit
e, oldText, es); | 1366 bool success = inspectorStyle->setPropertyText(propertyIndex, text, overwrit
e, oldText, es); |
| 1367 if (success) | 1367 if (success) |
| 1368 fireStyleSheetChanged(); | 1368 fireStyleSheetChanged(); |
| 1369 return success; | 1369 return success; |
| 1370 } | 1370 } |
| 1371 | 1371 |
| 1372 bool InspectorStyleSheet::toggleProperty(const InspectorCSSId& id, unsigned prop
ertyIndex, bool disable, ExceptionState& es) | 1372 bool InspectorStyleSheet::toggleProperty(const InspectorCSSId& id, unsigned prop
ertyIndex, bool disable, ExceptionState& es) |
| 1373 { | 1373 { |
| 1374 RefPtr<InspectorStyle> inspectorStyle = inspectorStyleForId(id); | 1374 RefPtr<InspectorStyle> inspectorStyle = inspectorStyleForId(id); |
| 1375 if (!inspectorStyle) { | 1375 if (!inspectorStyle) { |
| 1376 es.throwDOMException(NotFoundError); | 1376 es.throwUninformativeAndGenericDOMException(NotFoundError); |
| 1377 return false; | 1377 return false; |
| 1378 } | 1378 } |
| 1379 | 1379 |
| 1380 bool success = inspectorStyle->toggleProperty(propertyIndex, disable, es); | 1380 bool success = inspectorStyle->toggleProperty(propertyIndex, disable, es); |
| 1381 if (success) | 1381 if (success) |
| 1382 fireStyleSheetChanged(); | 1382 fireStyleSheetChanged(); |
| 1383 return success; | 1383 return success; |
| 1384 } | 1384 } |
| 1385 | 1385 |
| 1386 bool InspectorStyleSheet::getText(String* result) const | 1386 bool InspectorStyleSheet::getText(String* result) const |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1540 unsigned InspectorStyleSheet::ruleIndexByRule(const CSSRule* rule) const | 1540 unsigned InspectorStyleSheet::ruleIndexByRule(const CSSRule* rule) const |
| 1541 { | 1541 { |
| 1542 ensureFlatRules(); | 1542 ensureFlatRules(); |
| 1543 size_t index = m_flatRules.find(rule); | 1543 size_t index = m_flatRules.find(rule); |
| 1544 return index == kNotFound ? UINT_MAX : static_cast<unsigned>(index); | 1544 return index == kNotFound ? UINT_MAX : static_cast<unsigned>(index); |
| 1545 } | 1545 } |
| 1546 | 1546 |
| 1547 bool InspectorStyleSheet::checkPageStyleSheet(ExceptionState& es) const | 1547 bool InspectorStyleSheet::checkPageStyleSheet(ExceptionState& es) const |
| 1548 { | 1548 { |
| 1549 if (!m_pageStyleSheet) { | 1549 if (!m_pageStyleSheet) { |
| 1550 es.throwDOMException(NotSupportedError); | 1550 es.throwUninformativeAndGenericDOMException(NotSupportedError); |
| 1551 return false; | 1551 return false; |
| 1552 } | 1552 } |
| 1553 return true; | 1553 return true; |
| 1554 } | 1554 } |
| 1555 | 1555 |
| 1556 bool InspectorStyleSheet::ensureParsedDataReady() | 1556 bool InspectorStyleSheet::ensureParsedDataReady() |
| 1557 { | 1557 { |
| 1558 return ensureText() && ensureSourceData(); | 1558 return ensureText() && ensureSourceData(); |
| 1559 } | 1559 } |
| 1560 | 1560 |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1816 | 1816 |
| 1817 RefPtr<MutableStylePropertySet> tempDeclaration = MutableStylePropertySet::c
reate(); | 1817 RefPtr<MutableStylePropertySet> tempDeclaration = MutableStylePropertySet::c
reate(); |
| 1818 RuleSourceDataList ruleSourceDataResult; | 1818 RuleSourceDataList ruleSourceDataResult; |
| 1819 StyleSheetHandler handler(m_styleText, &m_element->document(), m_element->do
cument().elementSheet()->contents(), &ruleSourceDataResult); | 1819 StyleSheetHandler handler(m_styleText, &m_element->document(), m_element->do
cument().elementSheet()->contents(), &ruleSourceDataResult); |
| 1820 createCSSParser(&m_element->document())->parseDeclaration(tempDeclaration.ge
t(), m_styleText, &handler, m_element->document().elementSheet()->contents()); | 1820 createCSSParser(&m_element->document())->parseDeclaration(tempDeclaration.ge
t(), m_styleText, &handler, m_element->document().elementSheet()->contents()); |
| 1821 return ruleSourceDataResult.first().release(); | 1821 return ruleSourceDataResult.first().release(); |
| 1822 } | 1822 } |
| 1823 | 1823 |
| 1824 } // namespace WebCore | 1824 } // namespace WebCore |
| 1825 | 1825 |
| OLD | NEW |