| 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 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 421 | 421 |
| 422 void InspectorCSSAgent::discardAgent() | 422 void InspectorCSSAgent::discardAgent() |
| 423 { | 423 { |
| 424 m_domAgent->setDOMListener(0); | 424 m_domAgent->setDOMListener(0); |
| 425 m_domAgent = 0; | 425 m_domAgent = 0; |
| 426 } | 426 } |
| 427 | 427 |
| 428 void InspectorCSSAgent::restore() | 428 void InspectorCSSAgent::restore() |
| 429 { | 429 { |
| 430 if (m_state->getBoolean(CSSAgentState::cssAgentEnabled)) | 430 if (m_state->getBoolean(CSSAgentState::cssAgentEnabled)) |
| 431 wasEnabled(0); | 431 wasEnabled(nullptr); |
| 432 } | 432 } |
| 433 | 433 |
| 434 void InspectorCSSAgent::reset() | 434 void InspectorCSSAgent::reset() |
| 435 { | 435 { |
| 436 m_idToInspectorStyleSheet.clear(); | 436 m_idToInspectorStyleSheet.clear(); |
| 437 m_cssStyleSheetToInspectorStyleSheet.clear(); | 437 m_cssStyleSheetToInspectorStyleSheet.clear(); |
| 438 m_frameToCSSStyleSheets.clear(); | 438 m_frameToCSSStyleSheets.clear(); |
| 439 m_nodeToInspectorStyleSheet.clear(); | 439 m_nodeToInspectorStyleSheet.clear(); |
| 440 m_documentToViaInspectorStyleSheet.clear(); | 440 m_documentToViaInspectorStyleSheet.clear(); |
| 441 resetNonPersistentData(); | 441 resetNonPersistentData(); |
| (...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 730 Element* element = elementForId(errorString, nodeId); | 730 Element* element = elementForId(errorString, nodeId); |
| 731 if (!element) | 731 if (!element) |
| 732 return; | 732 return; |
| 733 | 733 |
| 734 InspectorStyleSheetForInlineStyle* styleSheet = asInspectorStyleSheet(elemen
t); | 734 InspectorStyleSheetForInlineStyle* styleSheet = asInspectorStyleSheet(elemen
t); |
| 735 if (!styleSheet) | 735 if (!styleSheet) |
| 736 return; | 736 return; |
| 737 | 737 |
| 738 inlineStyle = styleSheet->buildObjectForStyle(element->style()); | 738 inlineStyle = styleSheet->buildObjectForStyle(element->style()); |
| 739 RefPtr<TypeBuilder::CSS::CSSStyle> attributes = buildObjectForAttributesStyl
e(element); | 739 RefPtr<TypeBuilder::CSS::CSSStyle> attributes = buildObjectForAttributesStyl
e(element); |
| 740 attributesStyle = attributes ? attributes.release() : 0; | 740 attributesStyle = attributes ? attributes.release() : nullptr; |
| 741 } | 741 } |
| 742 | 742 |
| 743 void InspectorCSSAgent::getComputedStyleForNode(ErrorString* errorString, int no
deId, RefPtr<TypeBuilder::Array<TypeBuilder::CSS::CSSComputedStyleProperty> >& s
tyle) | 743 void InspectorCSSAgent::getComputedStyleForNode(ErrorString* errorString, int no
deId, RefPtr<TypeBuilder::Array<TypeBuilder::CSS::CSSComputedStyleProperty> >& s
tyle) |
| 744 { | 744 { |
| 745 Node* node = m_domAgent->assertNode(errorString, nodeId); | 745 Node* node = m_domAgent->assertNode(errorString, nodeId); |
| 746 if (!node) | 746 if (!node) |
| 747 return; | 747 return; |
| 748 | 748 |
| 749 RefPtr<CSSComputedStyleDeclaration> computedStyleInfo = CSSComputedStyleDecl
aration::create(node, true); | 749 RefPtr<CSSComputedStyleDeclaration> computedStyleInfo = CSSComputedStyleDecl
aration::create(node, true); |
| 750 RefPtr<InspectorStyle> inspectorStyle = InspectorStyle::create(InspectorCSSI
d(), computedStyleInfo, 0); | 750 RefPtr<InspectorStyle> inspectorStyle = InspectorStyle::create(InspectorCSSI
d(), computedStyleInfo, 0); |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 955 RefPtr<TypeBuilder::CSS::SourceRange> mediaRange = inspectorStyleSheet->
ruleHeaderSourceRange(parentRule); | 955 RefPtr<TypeBuilder::CSS::SourceRange> mediaRange = inspectorStyleSheet->
ruleHeaderSourceRange(parentRule); |
| 956 if (mediaRange) | 956 if (mediaRange) |
| 957 mediaObject->setRange(mediaRange); | 957 mediaObject->setRange(mediaRange); |
| 958 } | 958 } |
| 959 return mediaObject.release(); | 959 return mediaObject.release(); |
| 960 } | 960 } |
| 961 | 961 |
| 962 PassRefPtr<TypeBuilder::Array<TypeBuilder::CSS::CSSMedia> > InspectorCSSAgent::b
uildMediaListChain(CSSRule* rule) | 962 PassRefPtr<TypeBuilder::Array<TypeBuilder::CSS::CSSMedia> > InspectorCSSAgent::b
uildMediaListChain(CSSRule* rule) |
| 963 { | 963 { |
| 964 if (!rule) | 964 if (!rule) |
| 965 return 0; | 965 return nullptr; |
| 966 RefPtr<TypeBuilder::Array<TypeBuilder::CSS::CSSMedia> > mediaArray = TypeBui
lder::Array<TypeBuilder::CSS::CSSMedia>::create(); | 966 RefPtr<TypeBuilder::Array<TypeBuilder::CSS::CSSMedia> > mediaArray = TypeBui
lder::Array<TypeBuilder::CSS::CSSMedia>::create(); |
| 967 bool hasItems = false; | 967 bool hasItems = false; |
| 968 MediaList* mediaList; | 968 MediaList* mediaList; |
| 969 CSSRule* parentRule = rule; | 969 CSSRule* parentRule = rule; |
| 970 String sourceURL; | 970 String sourceURL; |
| 971 while (parentRule) { | 971 while (parentRule) { |
| 972 CSSStyleSheet* parentStyleSheet = 0; | 972 CSSStyleSheet* parentStyleSheet = 0; |
| 973 bool isMediaRule = true; | 973 bool isMediaRule = true; |
| 974 if (parentRule->type() == CSSRule::MEDIA_RULE) { | 974 if (parentRule->type() == CSSRule::MEDIA_RULE) { |
| 975 CSSMediaRule* mediaRule = toCSSMediaRule(parentRule); | 975 CSSMediaRule* mediaRule = toCSSMediaRule(parentRule); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1014 mediaArray->addItem(buildMediaObject(mediaList, styleSheet->
ownerNode() ? MediaListSourceLinkedSheet : MediaListSourceInlineSheet, sourceURL
, styleSheet)); | 1014 mediaArray->addItem(buildMediaObject(mediaList, styleSheet->
ownerNode() ? MediaListSourceLinkedSheet : MediaListSourceInlineSheet, sourceURL
, styleSheet)); |
| 1015 hasItems = true; | 1015 hasItems = true; |
| 1016 } | 1016 } |
| 1017 parentRule = styleSheet->ownerRule(); | 1017 parentRule = styleSheet->ownerRule(); |
| 1018 if (parentRule) | 1018 if (parentRule) |
| 1019 break; | 1019 break; |
| 1020 styleSheet = styleSheet->parentStyleSheet(); | 1020 styleSheet = styleSheet->parentStyleSheet(); |
| 1021 } | 1021 } |
| 1022 } | 1022 } |
| 1023 } | 1023 } |
| 1024 return hasItems ? mediaArray : 0; | 1024 return hasItems ? mediaArray : nullptr; |
| 1025 } | 1025 } |
| 1026 | 1026 |
| 1027 InspectorStyleSheetForInlineStyle* InspectorCSSAgent::asInspectorStyleSheet(Elem
ent* element) | 1027 InspectorStyleSheetForInlineStyle* InspectorCSSAgent::asInspectorStyleSheet(Elem
ent* element) |
| 1028 { | 1028 { |
| 1029 NodeToInspectorStyleSheet::iterator it = m_nodeToInspectorStyleSheet.find(el
ement); | 1029 NodeToInspectorStyleSheet::iterator it = m_nodeToInspectorStyleSheet.find(el
ement); |
| 1030 if (it != m_nodeToInspectorStyleSheet.end()) | 1030 if (it != m_nodeToInspectorStyleSheet.end()) |
| 1031 return it->value.get(); | 1031 return it->value.get(); |
| 1032 | 1032 |
| 1033 CSSStyleDeclaration* style = element->isStyledElement() ? element->style() :
0; | 1033 CSSStyleDeclaration* style = element->isStyledElement() ? element->style() :
0; |
| 1034 if (!style) | 1034 if (!style) |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1177 InspectorStyleSheet* viaInspectorStyleSheetForOwner = viaInspectorStyleS
heet(ownerDocument, false); | 1177 InspectorStyleSheet* viaInspectorStyleSheetForOwner = viaInspectorStyleS
heet(ownerDocument, false); |
| 1178 if (viaInspectorStyleSheetForOwner && pageStyleSheet == viaInspectorStyl
eSheetForOwner->pageStyleSheet()) | 1178 if (viaInspectorStyleSheetForOwner && pageStyleSheet == viaInspectorStyl
eSheetForOwner->pageStyleSheet()) |
| 1179 origin = TypeBuilder::CSS::StyleSheetOrigin::Inspector; | 1179 origin = TypeBuilder::CSS::StyleSheetOrigin::Inspector; |
| 1180 } | 1180 } |
| 1181 return origin; | 1181 return origin; |
| 1182 } | 1182 } |
| 1183 | 1183 |
| 1184 PassRefPtr<TypeBuilder::CSS::CSSRule> InspectorCSSAgent::buildObjectForRule(CSSS
tyleRule* rule) | 1184 PassRefPtr<TypeBuilder::CSS::CSSRule> InspectorCSSAgent::buildObjectForRule(CSSS
tyleRule* rule) |
| 1185 { | 1185 { |
| 1186 if (!rule) | 1186 if (!rule) |
| 1187 return 0; | 1187 return nullptr; |
| 1188 | 1188 |
| 1189 // CSSRules returned by StyleResolver::pseudoCSSRulesForElement lack parent
pointers if they are coming from | 1189 // CSSRules returned by StyleResolver::pseudoCSSRulesForElement lack parent
pointers if they are coming from |
| 1190 // user agent stylesheets. To work around this issue, we use CSSOM wrapper c
reated by inspector. | 1190 // user agent stylesheets. To work around this issue, we use CSSOM wrapper c
reated by inspector. |
| 1191 if (!rule->parentStyleSheet()) { | 1191 if (!rule->parentStyleSheet()) { |
| 1192 if (!m_inspectorUserAgentStyleSheet) | 1192 if (!m_inspectorUserAgentStyleSheet) |
| 1193 m_inspectorUserAgentStyleSheet = CSSStyleSheet::create(CSSDefaultSty
leSheets::instance().defaultStyleSheet()); | 1193 m_inspectorUserAgentStyleSheet = CSSStyleSheet::create(CSSDefaultSty
leSheets::instance().defaultStyleSheet()); |
| 1194 rule->setParentStyleSheet(m_inspectorUserAgentStyleSheet.get()); | 1194 rule->setParentStyleSheet(m_inspectorUserAgentStyleSheet.get()); |
| 1195 } | 1195 } |
| 1196 return bindStyleSheet(rule->parentStyleSheet())->buildObjectForRule(rule, bu
ildMediaListChain(rule)); | 1196 return bindStyleSheet(rule->parentStyleSheet())->buildObjectForRule(rule, bu
ildMediaListChain(rule)); |
| 1197 } | 1197 } |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1238 .setMatchingSelectors(matchingSelectors.release()); | 1238 .setMatchingSelectors(matchingSelectors.release()); |
| 1239 result->addItem(match); | 1239 result->addItem(match); |
| 1240 } | 1240 } |
| 1241 | 1241 |
| 1242 return result; | 1242 return result; |
| 1243 } | 1243 } |
| 1244 | 1244 |
| 1245 PassRefPtr<TypeBuilder::CSS::CSSStyle> InspectorCSSAgent::buildObjectForAttribut
esStyle(Element* element) | 1245 PassRefPtr<TypeBuilder::CSS::CSSStyle> InspectorCSSAgent::buildObjectForAttribut
esStyle(Element* element) |
| 1246 { | 1246 { |
| 1247 if (!element->isStyledElement()) | 1247 if (!element->isStyledElement()) |
| 1248 return 0; | 1248 return nullptr; |
| 1249 | 1249 |
| 1250 // FIXME: Ugliness below. | 1250 // FIXME: Ugliness below. |
| 1251 StylePropertySet* attributeStyle = const_cast<StylePropertySet*>(element->pr
esentationAttributeStyle()); | 1251 StylePropertySet* attributeStyle = const_cast<StylePropertySet*>(element->pr
esentationAttributeStyle()); |
| 1252 if (!attributeStyle) | 1252 if (!attributeStyle) |
| 1253 return 0; | 1253 return nullptr; |
| 1254 | 1254 |
| 1255 MutableStylePropertySet* mutableAttributeStyle = toMutableStylePropertySet(a
ttributeStyle); | 1255 MutableStylePropertySet* mutableAttributeStyle = toMutableStylePropertySet(a
ttributeStyle); |
| 1256 | 1256 |
| 1257 RefPtr<InspectorStyle> inspectorStyle = InspectorStyle::create(InspectorCSSI
d(), mutableAttributeStyle->ensureCSSStyleDeclaration(), 0); | 1257 RefPtr<InspectorStyle> inspectorStyle = InspectorStyle::create(InspectorCSSI
d(), mutableAttributeStyle->ensureCSSStyleDeclaration(), 0); |
| 1258 return inspectorStyle->buildObjectForStyle(); | 1258 return inspectorStyle->buildObjectForStyle(); |
| 1259 } | 1259 } |
| 1260 | 1260 |
| 1261 void InspectorCSSAgent::didRemoveDocument(Document* document) | 1261 void InspectorCSSAgent::didRemoveDocument(Document* document) |
| 1262 { | 1262 { |
| 1263 if (document) | 1263 if (document) |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1320 documentsToChange.add(element->ownerDocument()); | 1320 documentsToChange.add(element->ownerDocument()); |
| 1321 } | 1321 } |
| 1322 | 1322 |
| 1323 m_nodeIdToForcedPseudoState.clear(); | 1323 m_nodeIdToForcedPseudoState.clear(); |
| 1324 for (HashSet<Document*>::iterator it = documentsToChange.begin(), end = docu
mentsToChange.end(); it != end; ++it) | 1324 for (HashSet<Document*>::iterator it = documentsToChange.begin(), end = docu
mentsToChange.end(); it != end; ++it) |
| 1325 (*it)->setNeedsStyleRecalc(SubtreeStyleChange); | 1325 (*it)->setNeedsStyleRecalc(SubtreeStyleChange); |
| 1326 } | 1326 } |
| 1327 | 1327 |
| 1328 } // namespace WebCore | 1328 } // namespace WebCore |
| 1329 | 1329 |
| OLD | NEW |