| 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 1044 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1055 exceptionState.throwDOMException(SyntaxError, "The rule '" + ruleText +
"' could not be added in media rule."); | 1055 exceptionState.throwDOMException(SyntaxError, "The rule '" + ruleText +
"' could not be added in media rule."); |
| 1056 return nullptr; | 1056 return nullptr; |
| 1057 } | 1057 } |
| 1058 return styleRule; | 1058 return styleRule; |
| 1059 } | 1059 } |
| 1060 | 1060 |
| 1061 CSSStyleRule* InspectorStyleSheet::insertCSSOMRuleBySourceRange(const SourceRang
e& sourceRange, const String& ruleText, ExceptionState& exceptionState) | 1061 CSSStyleRule* InspectorStyleSheet::insertCSSOMRuleBySourceRange(const SourceRang
e& sourceRange, const String& ruleText, ExceptionState& exceptionState) |
| 1062 { | 1062 { |
| 1063 ASSERT(m_sourceData); | 1063 ASSERT(m_sourceData); |
| 1064 | 1064 |
| 1065 RefPtrWillBeRawPtr<CSSRuleSourceData> containingRuleSourceData; | 1065 RefPtrWillBeRawPtr<CSSRuleSourceData> containingRuleSourceData = nullptr; |
| 1066 for (size_t i = 0; i < m_sourceData->size(); ++i) { | 1066 for (size_t i = 0; i < m_sourceData->size(); ++i) { |
| 1067 RefPtrWillBeRawPtr<CSSRuleSourceData> ruleSourceData = m_sourceData->at(
i); | 1067 RefPtrWillBeRawPtr<CSSRuleSourceData> ruleSourceData = m_sourceData->at(
i); |
| 1068 if (ruleSourceData->ruleHeaderRange.start < sourceRange.start && sourceR
ange.start < ruleSourceData->ruleBodyRange.start) { | 1068 if (ruleSourceData->ruleHeaderRange.start < sourceRange.start && sourceR
ange.start < ruleSourceData->ruleBodyRange.start) { |
| 1069 exceptionState.throwDOMException(NotFoundError, "Cannot insert rule
inside rule selector."); | 1069 exceptionState.throwDOMException(NotFoundError, "Cannot insert rule
inside rule selector."); |
| 1070 return nullptr; | 1070 return nullptr; |
| 1071 } | 1071 } |
| 1072 if (sourceRange.start < ruleSourceData->ruleBodyRange.start || ruleSourc
eData->ruleBodyRange.end < sourceRange.start) | 1072 if (sourceRange.start < ruleSourceData->ruleBodyRange.start || ruleSourc
eData->ruleBodyRange.end < sourceRange.start) |
| 1073 continue; | 1073 continue; |
| 1074 if (!containingRuleSourceData || containingRuleSourceData->ruleBodyRange
.length() > ruleSourceData->ruleBodyRange.length()) | 1074 if (!containingRuleSourceData || containingRuleSourceData->ruleBodyRange
.length() > ruleSourceData->ruleBodyRange.length()) |
| 1075 containingRuleSourceData = ruleSourceData; | 1075 containingRuleSourceData = ruleSourceData; |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1189 *newRange = SourceRange(range.start, range.start + text.length()); | 1189 *newRange = SourceRange(range.start, range.start + text.length()); |
| 1190 innerSetText(sheetText, true); | 1190 innerSetText(sheetText, true); |
| 1191 } | 1191 } |
| 1192 | 1192 |
| 1193 void InspectorStyleSheet::innerSetText(const String& text, bool markAsLocallyMod
ified) | 1193 void InspectorStyleSheet::innerSetText(const String& text, bool markAsLocallyMod
ified) |
| 1194 { | 1194 { |
| 1195 OwnPtrWillBeRawPtr<RuleSourceDataList> ruleTree = adoptPtrWillBeNoop(new Rul
eSourceDataList()); | 1195 OwnPtrWillBeRawPtr<RuleSourceDataList> ruleTree = adoptPtrWillBeNoop(new Rul
eSourceDataList()); |
| 1196 RefPtrWillBeRawPtr<StyleSheetContents> styleSheet = StyleSheetContents::crea
te(m_pageStyleSheet->contents()->parserContext()); | 1196 RefPtrWillBeRawPtr<StyleSheetContents> styleSheet = StyleSheetContents::crea
te(m_pageStyleSheet->contents()->parserContext()); |
| 1197 StyleSheetHandler handler(text, m_pageStyleSheet->ownerDocument(), ruleTree.
get()); | 1197 StyleSheetHandler handler(text, m_pageStyleSheet->ownerDocument(), ruleTree.
get()); |
| 1198 CSSParser::parseSheetForInspector(m_pageStyleSheet->contents()->parserContex
t(), styleSheet.get(), text, handler); | 1198 CSSParser::parseSheetForInspector(m_pageStyleSheet->contents()->parserContex
t(), styleSheet.get(), text, handler); |
| 1199 RefPtrWillBeRawPtr<CSSStyleSheet> sourceDataSheet; | 1199 RefPtrWillBeRawPtr<CSSStyleSheet> sourceDataSheet = nullptr; |
| 1200 if (toCSSImportRule(m_pageStyleSheet->ownerRule())) | 1200 if (toCSSImportRule(m_pageStyleSheet->ownerRule())) |
| 1201 sourceDataSheet = CSSStyleSheet::create(styleSheet, toCSSImportRule(m_pa
geStyleSheet->ownerRule())); | 1201 sourceDataSheet = CSSStyleSheet::create(styleSheet, toCSSImportRule(m_pa
geStyleSheet->ownerRule())); |
| 1202 else | 1202 else |
| 1203 sourceDataSheet = CSSStyleSheet::create(styleSheet, m_pageStyleSheet->ow
nerNode()); | 1203 sourceDataSheet = CSSStyleSheet::create(styleSheet, m_pageStyleSheet->ow
nerNode()); |
| 1204 | 1204 |
| 1205 m_parsedFlatRules.clear(); | 1205 m_parsedFlatRules.clear(); |
| 1206 collectFlatRules(sourceDataSheet.get(), &m_parsedFlatRules); | 1206 collectFlatRules(sourceDataSheet.get(), &m_parsedFlatRules); |
| 1207 | 1207 |
| 1208 m_sourceData = adoptPtrWillBeNoop(new RuleSourceDataList()); | 1208 m_sourceData = adoptPtrWillBeNoop(new RuleSourceDataList()); |
| 1209 flattenSourceData(ruleTree.get(), m_sourceData.get()); | 1209 flattenSourceData(ruleTree.get(), m_sourceData.get()); |
| (...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1634 bool InspectorStyleSheetForInlineStyle::getText(String* result) | 1634 bool InspectorStyleSheetForInlineStyle::getText(String* result) |
| 1635 { | 1635 { |
| 1636 *result = elementStyleText(); | 1636 *result = elementStyleText(); |
| 1637 return true; | 1637 return true; |
| 1638 } | 1638 } |
| 1639 | 1639 |
| 1640 PassRefPtrWillBeRawPtr<InspectorStyle> InspectorStyleSheetForInlineStyle::inspec
torStyle(RefPtrWillBeRawPtr<CSSStyleDeclaration> style) | 1640 PassRefPtrWillBeRawPtr<InspectorStyle> InspectorStyleSheetForInlineStyle::inspec
torStyle(RefPtrWillBeRawPtr<CSSStyleDeclaration> style) |
| 1641 { | 1641 { |
| 1642 if (!m_inspectorStyle) { | 1642 if (!m_inspectorStyle) { |
| 1643 const String& text = elementStyleText(); | 1643 const String& text = elementStyleText(); |
| 1644 RefPtrWillBeRawPtr<CSSRuleSourceData> ruleSourceData; | 1644 RefPtrWillBeRawPtr<CSSRuleSourceData> ruleSourceData = nullptr; |
| 1645 if (text.isEmpty()) { | 1645 if (text.isEmpty()) { |
| 1646 ruleSourceData = CSSRuleSourceData::create(StyleRule::Style); | 1646 ruleSourceData = CSSRuleSourceData::create(StyleRule::Style); |
| 1647 ruleSourceData->ruleBodyRange.start = 0; | 1647 ruleSourceData->ruleBodyRange.start = 0; |
| 1648 ruleSourceData->ruleBodyRange.end = 0; | 1648 ruleSourceData->ruleBodyRange.end = 0; |
| 1649 } else { | 1649 } else { |
| 1650 RuleSourceDataList ruleSourceDataResult; | 1650 RuleSourceDataList ruleSourceDataResult; |
| 1651 StyleSheetHandler handler(text, &m_element->document(), &ruleSourceD
ataResult); | 1651 StyleSheetHandler handler(text, &m_element->document(), &ruleSourceD
ataResult); |
| 1652 CSSParser::parseDeclarationListForInspector(parserContextForDocument
(&m_element->document()), text, handler); | 1652 CSSParser::parseDeclarationListForInspector(parserContextForDocument
(&m_element->document()), text, handler); |
| 1653 ruleSourceData = ruleSourceDataResult.first().release(); | 1653 ruleSourceData = ruleSourceDataResult.first().release(); |
| 1654 } | 1654 } |
| (...skipping 13 matching lines...) Expand all Loading... |
| 1668 } | 1668 } |
| 1669 | 1669 |
| 1670 DEFINE_TRACE(InspectorStyleSheetForInlineStyle) | 1670 DEFINE_TRACE(InspectorStyleSheetForInlineStyle) |
| 1671 { | 1671 { |
| 1672 visitor->trace(m_element); | 1672 visitor->trace(m_element); |
| 1673 visitor->trace(m_inspectorStyle); | 1673 visitor->trace(m_inspectorStyle); |
| 1674 InspectorStyleSheetBase::trace(visitor); | 1674 InspectorStyleSheetBase::trace(visitor); |
| 1675 } | 1675 } |
| 1676 | 1676 |
| 1677 } // namespace blink | 1677 } // namespace blink |
| OLD | NEW |