| 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 1098 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1109 return 0; | 1109 return 0; |
| 1110 ASSERT(m_pageStyleSheet->length()); | 1110 ASSERT(m_pageStyleSheet->length()); |
| 1111 unsigned lastRuleIndex = m_pageStyleSheet->length() - 1; | 1111 unsigned lastRuleIndex = m_pageStyleSheet->length() - 1; |
| 1112 CSSRule* rule = m_pageStyleSheet->item(lastRuleIndex); | 1112 CSSRule* rule = m_pageStyleSheet->item(lastRuleIndex); |
| 1113 ASSERT(rule); | 1113 ASSERT(rule); |
| 1114 | 1114 |
| 1115 CSSStyleRule* styleRule = InspectorCSSAgent::asCSSStyleRule(rule); | 1115 CSSStyleRule* styleRule = InspectorCSSAgent::asCSSStyleRule(rule); |
| 1116 if (!styleRule) { | 1116 if (!styleRule) { |
| 1117 // What we just added has to be a CSSStyleRule - we cannot handle other
types of rules yet. | 1117 // What we just added has to be a CSSStyleRule - we cannot handle other
types of rules yet. |
| 1118 // If it is not a style rule, pretend we never touched the stylesheet. | 1118 // If it is not a style rule, pretend we never touched the stylesheet. |
| 1119 m_pageStyleSheet->deleteRule(lastRuleIndex, ASSERT_NO_EXCEPTION_STATE); | 1119 m_pageStyleSheet->deleteRule(lastRuleIndex, ASSERT_NO_EXCEPTION); |
| 1120 es.throwDOMException(SyntaxError); | 1120 es.throwDOMException(SyntaxError); |
| 1121 return 0; | 1121 return 0; |
| 1122 } | 1122 } |
| 1123 | 1123 |
| 1124 if (!styleSheetText.isEmpty()) | 1124 if (!styleSheetText.isEmpty()) |
| 1125 styleSheetText.append('\n'); | 1125 styleSheetText.append('\n'); |
| 1126 | 1126 |
| 1127 styleSheetText.append(selector); | 1127 styleSheetText.append(selector); |
| 1128 styleSheetText.appendLiteral(" {}"); | 1128 styleSheetText.appendLiteral(" {}"); |
| 1129 // Using setText() as this operation changes the style sheet rule set. | 1129 // Using setText() as this operation changes the style sheet rule set. |
| 1130 setText(styleSheetText.toString(), ASSERT_NO_EXCEPTION_STATE); | 1130 setText(styleSheetText.toString(), ASSERT_NO_EXCEPTION); |
| 1131 | 1131 |
| 1132 fireStyleSheetChanged(); | 1132 fireStyleSheetChanged(); |
| 1133 | 1133 |
| 1134 return styleRule; | 1134 return styleRule; |
| 1135 } | 1135 } |
| 1136 | 1136 |
| 1137 bool InspectorStyleSheet::deleteRule(const InspectorCSSId& id, ExceptionState& e
s) | 1137 bool InspectorStyleSheet::deleteRule(const InspectorCSSId& id, ExceptionState& e
s) |
| 1138 { | 1138 { |
| 1139 if (!checkPageStyleSheet(es)) | 1139 if (!checkPageStyleSheet(es)) |
| 1140 return false; | 1140 return false; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 1156 } | 1156 } |
| 1157 | 1157 |
| 1158 styleSheet->deleteRule(id.ordinal(), es); | 1158 styleSheet->deleteRule(id.ordinal(), es); |
| 1159 // |rule| MAY NOT be addressed after this line! | 1159 // |rule| MAY NOT be addressed after this line! |
| 1160 | 1160 |
| 1161 if (es.hadException()) | 1161 if (es.hadException()) |
| 1162 return false; | 1162 return false; |
| 1163 | 1163 |
| 1164 String sheetText = m_parsedStyleSheet->text(); | 1164 String sheetText = m_parsedStyleSheet->text(); |
| 1165 sheetText.remove(sourceData->ruleHeaderRange.start, sourceData->ruleBodyRang
e.end - sourceData->ruleHeaderRange.start + 1); | 1165 sheetText.remove(sourceData->ruleHeaderRange.start, sourceData->ruleBodyRang
e.end - sourceData->ruleHeaderRange.start + 1); |
| 1166 setText(sheetText, ASSERT_NO_EXCEPTION_STATE); | 1166 setText(sheetText, ASSERT_NO_EXCEPTION); |
| 1167 fireStyleSheetChanged(); | 1167 fireStyleSheetChanged(); |
| 1168 return true; | 1168 return true; |
| 1169 } | 1169 } |
| 1170 | 1170 |
| 1171 CSSStyleRule* InspectorStyleSheet::ruleForId(const InspectorCSSId& id) const | 1171 CSSStyleRule* InspectorStyleSheet::ruleForId(const InspectorCSSId& id) const |
| 1172 { | 1172 { |
| 1173 if (!m_pageStyleSheet) | 1173 if (!m_pageStyleSheet) |
| 1174 return 0; | 1174 return 0; |
| 1175 | 1175 |
| 1176 ASSERT(!id.isEmpty()); | 1176 ASSERT(!id.isEmpty()); |
| (...skipping 634 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1811 | 1811 |
| 1812 RefPtr<MutableStylePropertySet> tempDeclaration = MutableStylePropertySet::c
reate(); | 1812 RefPtr<MutableStylePropertySet> tempDeclaration = MutableStylePropertySet::c
reate(); |
| 1813 RuleSourceDataList ruleSourceDataResult; | 1813 RuleSourceDataList ruleSourceDataResult; |
| 1814 StyleSheetHandler handler(m_styleText, m_element->document(), m_element->doc
ument()->elementSheet()->contents(), &ruleSourceDataResult); | 1814 StyleSheetHandler handler(m_styleText, m_element->document(), m_element->doc
ument()->elementSheet()->contents(), &ruleSourceDataResult); |
| 1815 createCSSParser(m_element->document())->parseDeclaration(tempDeclaration.get
(), m_styleText, &handler, m_element->document()->elementSheet()->contents()); | 1815 createCSSParser(m_element->document())->parseDeclaration(tempDeclaration.get
(), m_styleText, &handler, m_element->document()->elementSheet()->contents()); |
| 1816 return ruleSourceDataResult.first().release(); | 1816 return ruleSourceDataResult.first().release(); |
| 1817 } | 1817 } |
| 1818 | 1818 |
| 1819 } // namespace WebCore | 1819 } // namespace WebCore |
| 1820 | 1820 |
| OLD | NEW |