| 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 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 } | 186 } |
| 187 | 187 |
| 188 virtual void merge(PassRefPtrWillBeRawPtr<Action> action) OVERRIDE | 188 virtual void merge(PassRefPtrWillBeRawPtr<Action> action) OVERRIDE |
| 189 { | 189 { |
| 190 ASSERT(action->mergeId() == mergeId()); | 190 ASSERT(action->mergeId() == mergeId()); |
| 191 | 191 |
| 192 SetStyleSheetTextAction* other = static_cast<SetStyleSheetTextAction*>(a
ction.get()); | 192 SetStyleSheetTextAction* other = static_cast<SetStyleSheetTextAction*>(a
ction.get()); |
| 193 m_text = other->m_text; | 193 m_text = other->m_text; |
| 194 } | 194 } |
| 195 | 195 |
| 196 virtual void trace(Visitor* visitor) OVERRIDE |
| 197 { |
| 198 visitor->trace(m_styleSheet); |
| 199 InspectorCSSAgent::StyleSheetAction::trace(visitor); |
| 200 } |
| 201 |
| 196 private: | 202 private: |
| 197 RefPtr<InspectorStyleSheetBase> m_styleSheet; | 203 RefPtrWillBeMember<InspectorStyleSheetBase> m_styleSheet; |
| 198 String m_text; | 204 String m_text; |
| 199 String m_oldText; | 205 String m_oldText; |
| 200 }; | 206 }; |
| 201 | 207 |
| 202 class InspectorCSSAgent::SetPropertyTextAction FINAL : public InspectorCSSAgent:
:StyleSheetAction { | 208 class InspectorCSSAgent::SetPropertyTextAction FINAL : public InspectorCSSAgent:
:StyleSheetAction { |
| 203 WTF_MAKE_NONCOPYABLE(SetPropertyTextAction); | 209 WTF_MAKE_NONCOPYABLE(SetPropertyTextAction); |
| 204 public: | 210 public: |
| 205 SetPropertyTextAction(InspectorStyleSheetBase* styleSheet, const InspectorCS
SId& cssId, unsigned propertyIndex, const String& text, bool overwrite) | 211 SetPropertyTextAction(InspectorStyleSheetBase* styleSheet, const InspectorCS
SId& cssId, unsigned propertyIndex, const String& text, bool overwrite) |
| 206 : InspectorCSSAgent::StyleSheetAction("SetPropertyText") | 212 : InspectorCSSAgent::StyleSheetAction("SetPropertyText") |
| 207 , m_styleSheet(styleSheet) | 213 , m_styleSheet(styleSheet) |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 242 } | 248 } |
| 243 | 249 |
| 244 virtual void merge(PassRefPtrWillBeRawPtr<Action> action) OVERRIDE | 250 virtual void merge(PassRefPtrWillBeRawPtr<Action> action) OVERRIDE |
| 245 { | 251 { |
| 246 ASSERT(action->mergeId() == mergeId()); | 252 ASSERT(action->mergeId() == mergeId()); |
| 247 | 253 |
| 248 SetPropertyTextAction* other = static_cast<SetPropertyTextAction*>(actio
n.get()); | 254 SetPropertyTextAction* other = static_cast<SetPropertyTextAction*>(actio
n.get()); |
| 249 m_text = other->m_text; | 255 m_text = other->m_text; |
| 250 } | 256 } |
| 251 | 257 |
| 258 virtual void trace(Visitor* visitor) OVERRIDE |
| 259 { |
| 260 visitor->trace(m_styleSheet); |
| 261 InspectorCSSAgent::StyleSheetAction::trace(visitor); |
| 262 } |
| 263 |
| 252 private: | 264 private: |
| 253 RefPtr<InspectorStyleSheetBase> m_styleSheet; | 265 RefPtrWillBeMember<InspectorStyleSheetBase> m_styleSheet; |
| 254 InspectorCSSId m_cssId; | 266 InspectorCSSId m_cssId; |
| 255 unsigned m_propertyIndex; | 267 unsigned m_propertyIndex; |
| 256 String m_text; | 268 String m_text; |
| 257 String m_oldStyleText; | 269 String m_oldStyleText; |
| 258 bool m_overwrite; | 270 bool m_overwrite; |
| 259 }; | 271 }; |
| 260 | 272 |
| 261 class InspectorCSSAgent::SetRuleSelectorAction FINAL : public InspectorCSSAgent:
:StyleSheetAction { | 273 class InspectorCSSAgent::SetRuleSelectorAction FINAL : public InspectorCSSAgent:
:StyleSheetAction { |
| 262 WTF_MAKE_NONCOPYABLE(SetRuleSelectorAction); | 274 WTF_MAKE_NONCOPYABLE(SetRuleSelectorAction); |
| 263 public: | 275 public: |
| (...skipping 16 matching lines...) Expand all Loading... |
| 280 virtual bool undo(ExceptionState& exceptionState) OVERRIDE | 292 virtual bool undo(ExceptionState& exceptionState) OVERRIDE |
| 281 { | 293 { |
| 282 return m_styleSheet->setRuleSelector(m_cssId, m_oldSelector, exceptionSt
ate); | 294 return m_styleSheet->setRuleSelector(m_cssId, m_oldSelector, exceptionSt
ate); |
| 283 } | 295 } |
| 284 | 296 |
| 285 virtual bool redo(ExceptionState& exceptionState) OVERRIDE | 297 virtual bool redo(ExceptionState& exceptionState) OVERRIDE |
| 286 { | 298 { |
| 287 return m_styleSheet->setRuleSelector(m_cssId, m_selector, exceptionState
); | 299 return m_styleSheet->setRuleSelector(m_cssId, m_selector, exceptionState
); |
| 288 } | 300 } |
| 289 | 301 |
| 302 virtual void trace(Visitor* visitor) OVERRIDE |
| 303 { |
| 304 visitor->trace(m_styleSheet); |
| 305 InspectorCSSAgent::StyleSheetAction::trace(visitor); |
| 306 } |
| 307 |
| 290 private: | 308 private: |
| 291 RefPtr<InspectorStyleSheet> m_styleSheet; | 309 RefPtrWillBeMember<InspectorStyleSheet> m_styleSheet; |
| 292 InspectorCSSId m_cssId; | 310 InspectorCSSId m_cssId; |
| 293 String m_selector; | 311 String m_selector; |
| 294 String m_oldSelector; | 312 String m_oldSelector; |
| 295 }; | 313 }; |
| 296 | 314 |
| 297 class InspectorCSSAgent::AddRuleAction FINAL : public InspectorCSSAgent::StyleSh
eetAction { | 315 class InspectorCSSAgent::AddRuleAction FINAL : public InspectorCSSAgent::StyleSh
eetAction { |
| 298 WTF_MAKE_NONCOPYABLE(AddRuleAction); | 316 WTF_MAKE_NONCOPYABLE(AddRuleAction); |
| 299 public: | 317 public: |
| 300 AddRuleAction(InspectorStyleSheet* styleSheet, const String& selector) | 318 AddRuleAction(InspectorStyleSheet* styleSheet, const String& selector) |
| 301 : InspectorCSSAgent::StyleSheetAction("AddRule") | 319 : InspectorCSSAgent::StyleSheetAction("AddRule") |
| (...skipping 16 matching lines...) Expand all Loading... |
| 318 { | 336 { |
| 319 CSSStyleRule* cssStyleRule = m_styleSheet->addRule(m_selector, exception
State); | 337 CSSStyleRule* cssStyleRule = m_styleSheet->addRule(m_selector, exception
State); |
| 320 if (exceptionState.hadException()) | 338 if (exceptionState.hadException()) |
| 321 return false; | 339 return false; |
| 322 m_newId = m_styleSheet->ruleId(cssStyleRule); | 340 m_newId = m_styleSheet->ruleId(cssStyleRule); |
| 323 return true; | 341 return true; |
| 324 } | 342 } |
| 325 | 343 |
| 326 InspectorCSSId newRuleId() { return m_newId; } | 344 InspectorCSSId newRuleId() { return m_newId; } |
| 327 | 345 |
| 346 virtual void trace(Visitor* visitor) OVERRIDE |
| 347 { |
| 348 visitor->trace(m_styleSheet); |
| 349 InspectorCSSAgent::StyleSheetAction::trace(visitor); |
| 350 } |
| 351 |
| 328 private: | 352 private: |
| 329 RefPtr<InspectorStyleSheet> m_styleSheet; | 353 RefPtrWillBeMember<InspectorStyleSheet> m_styleSheet; |
| 330 InspectorCSSId m_newId; | 354 InspectorCSSId m_newId; |
| 331 String m_selector; | 355 String m_selector; |
| 332 String m_oldSelector; | 356 String m_oldSelector; |
| 333 }; | 357 }; |
| 334 | 358 |
| 335 // static | 359 // static |
| 336 CSSStyleRule* InspectorCSSAgent::asCSSStyleRule(CSSRule* rule) | 360 CSSStyleRule* InspectorCSSAgent::asCSSStyleRule(CSSRule* rule) |
| 337 { | 361 { |
| 338 if (!rule || rule->type() != CSSRule::STYLE_RULE) | 362 if (!rule || rule->type() != CSSRule::STYLE_RULE) |
| 339 return 0; | 363 return 0; |
| (...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 593 return forcedPseudoState & PseudoVisited; | 617 return forcedPseudoState & PseudoVisited; |
| 594 default: | 618 default: |
| 595 return false; | 619 return false; |
| 596 } | 620 } |
| 597 } | 621 } |
| 598 | 622 |
| 599 void InspectorCSSAgent::getMediaQueries(ErrorString* errorString, RefPtr<TypeBui
lder::Array<TypeBuilder::CSS::CSSMedia> >& medias) | 623 void InspectorCSSAgent::getMediaQueries(ErrorString* errorString, RefPtr<TypeBui
lder::Array<TypeBuilder::CSS::CSSMedia> >& medias) |
| 600 { | 624 { |
| 601 medias = TypeBuilder::Array<TypeBuilder::CSS::CSSMedia>::create(); | 625 medias = TypeBuilder::Array<TypeBuilder::CSS::CSSMedia>::create(); |
| 602 for (IdToInspectorStyleSheet::iterator it = m_idToInspectorStyleSheet.begin(
); it != m_idToInspectorStyleSheet.end(); ++it) { | 626 for (IdToInspectorStyleSheet::iterator it = m_idToInspectorStyleSheet.begin(
); it != m_idToInspectorStyleSheet.end(); ++it) { |
| 603 RefPtr<InspectorStyleSheet> styleSheet = it->value; | 627 RefPtrWillBeRawPtr<InspectorStyleSheet> styleSheet = it->value; |
| 604 collectMediaQueriesFromStyleSheet(styleSheet->pageStyleSheet(), medias.g
et()); | 628 collectMediaQueriesFromStyleSheet(styleSheet->pageStyleSheet(), medias.g
et()); |
| 605 const CSSRuleVector& flatRules = styleSheet->flatRules(); | 629 const CSSRuleVector& flatRules = styleSheet->flatRules(); |
| 606 for (unsigned i = 0; i < flatRules.size(); ++i) { | 630 for (unsigned i = 0; i < flatRules.size(); ++i) { |
| 607 CSSRule* rule = flatRules.at(i).get(); | 631 CSSRule* rule = flatRules.at(i).get(); |
| 608 if (rule->type() == CSSRule::MEDIA_RULE) | 632 if (rule->type() == CSSRule::MEDIA_RULE) |
| 609 collectMediaQueriesFromRule(rule, medias.get()); | 633 collectMediaQueriesFromRule(rule, medias.get()); |
| 610 } | 634 } |
| 611 } | 635 } |
| 612 } | 636 } |
| 613 | 637 |
| (...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1106 { | 1130 { |
| 1107 NodeToInspectorStyleSheet::iterator it = m_nodeToInspectorStyleSheet.find(el
ement); | 1131 NodeToInspectorStyleSheet::iterator it = m_nodeToInspectorStyleSheet.find(el
ement); |
| 1108 if (it != m_nodeToInspectorStyleSheet.end()) | 1132 if (it != m_nodeToInspectorStyleSheet.end()) |
| 1109 return it->value.get(); | 1133 return it->value.get(); |
| 1110 | 1134 |
| 1111 CSSStyleDeclaration* style = element->isStyledElement() ? element->style() :
0; | 1135 CSSStyleDeclaration* style = element->isStyledElement() ? element->style() :
0; |
| 1112 if (!style) | 1136 if (!style) |
| 1113 return 0; | 1137 return 0; |
| 1114 | 1138 |
| 1115 String newStyleSheetId = String::number(m_lastStyleSheetId++); | 1139 String newStyleSheetId = String::number(m_lastStyleSheetId++); |
| 1116 RefPtr<InspectorStyleSheetForInlineStyle> inspectorStyleSheet = InspectorSty
leSheetForInlineStyle::create(newStyleSheetId, element, this); | 1140 RefPtrWillBeRawPtr<InspectorStyleSheetForInlineStyle> inspectorStyleSheet =
InspectorStyleSheetForInlineStyle::create(newStyleSheetId, element, this); |
| 1117 m_idToInspectorStyleSheetForInlineStyle.set(newStyleSheetId, inspectorStyleS
heet); | 1141 m_idToInspectorStyleSheetForInlineStyle.set(newStyleSheetId, inspectorStyleS
heet); |
| 1118 m_nodeToInspectorStyleSheet.set(element, inspectorStyleSheet); | 1142 m_nodeToInspectorStyleSheet.set(element, inspectorStyleSheet); |
| 1119 return inspectorStyleSheet.get(); | 1143 return inspectorStyleSheet.get(); |
| 1120 } | 1144 } |
| 1121 | 1145 |
| 1122 Element* InspectorCSSAgent::elementForId(ErrorString* errorString, int nodeId) | 1146 Element* InspectorCSSAgent::elementForId(ErrorString* errorString, int nodeId) |
| 1123 { | 1147 { |
| 1124 Node* node = m_domAgent->nodeForId(nodeId); | 1148 Node* node = m_domAgent->nodeForId(nodeId); |
| 1125 if (!node) { | 1149 if (!node) { |
| 1126 *errorString = "No node with given id found"; | 1150 *errorString = "No node with given id found"; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 1152 if (rule->type() == CSSRule::IMPORT_RULE) { | 1176 if (rule->type() == CSSRule::IMPORT_RULE) { |
| 1153 CSSStyleSheet* importedStyleSheet = toCSSImportRule(rule)->styleShee
t(); | 1177 CSSStyleSheet* importedStyleSheet = toCSSImportRule(rule)->styleShee
t(); |
| 1154 if (importedStyleSheet) | 1178 if (importedStyleSheet) |
| 1155 InspectorCSSAgent::collectStyleSheets(importedStyleSheet, result
); | 1179 InspectorCSSAgent::collectStyleSheets(importedStyleSheet, result
); |
| 1156 } | 1180 } |
| 1157 } | 1181 } |
| 1158 } | 1182 } |
| 1159 | 1183 |
| 1160 InspectorStyleSheet* InspectorCSSAgent::bindStyleSheet(CSSStyleSheet* styleSheet
) | 1184 InspectorStyleSheet* InspectorCSSAgent::bindStyleSheet(CSSStyleSheet* styleSheet
) |
| 1161 { | 1185 { |
| 1162 RefPtr<InspectorStyleSheet> inspectorStyleSheet = m_cssStyleSheetToInspector
StyleSheet.get(styleSheet); | 1186 RefPtrWillBeRawPtr<InspectorStyleSheet> inspectorStyleSheet = m_cssStyleShee
tToInspectorStyleSheet.get(styleSheet); |
| 1163 if (!inspectorStyleSheet) { | 1187 if (!inspectorStyleSheet) { |
| 1164 String id = String::number(m_lastStyleSheetId++); | 1188 String id = String::number(m_lastStyleSheetId++); |
| 1165 Document* document = styleSheet->ownerDocument(); | 1189 Document* document = styleSheet->ownerDocument(); |
| 1166 inspectorStyleSheet = InspectorStyleSheet::create(m_pageAgent, m_resourc
eAgent, id, styleSheet, detectOrigin(styleSheet, document), InspectorDOMAgent::d
ocumentURLString(document), this); | 1190 inspectorStyleSheet = InspectorStyleSheet::create(m_pageAgent, m_resourc
eAgent, id, styleSheet, detectOrigin(styleSheet, document), InspectorDOMAgent::d
ocumentURLString(document), this); |
| 1167 m_idToInspectorStyleSheet.set(id, inspectorStyleSheet); | 1191 m_idToInspectorStyleSheet.set(id, inspectorStyleSheet); |
| 1168 m_cssStyleSheetToInspectorStyleSheet.set(styleSheet, inspectorStyleSheet
); | 1192 m_cssStyleSheetToInspectorStyleSheet.set(styleSheet, inspectorStyleSheet
); |
| 1169 if (m_creatingViaInspectorStyleSheet) | 1193 if (m_creatingViaInspectorStyleSheet) |
| 1170 m_documentToViaInspectorStyleSheet.add(document, inspectorStyleSheet
); | 1194 m_documentToViaInspectorStyleSheet.add(document, inspectorStyleSheet
); |
| 1171 } | 1195 } |
| 1172 return inspectorStyleSheet.get(); | 1196 return inspectorStyleSheet.get(); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1184 InspectorStyleSheet* InspectorCSSAgent::viaInspectorStyleSheet(Document* documen
t, bool createIfAbsent) | 1208 InspectorStyleSheet* InspectorCSSAgent::viaInspectorStyleSheet(Document* documen
t, bool createIfAbsent) |
| 1185 { | 1209 { |
| 1186 if (!document) { | 1210 if (!document) { |
| 1187 ASSERT(!createIfAbsent); | 1211 ASSERT(!createIfAbsent); |
| 1188 return 0; | 1212 return 0; |
| 1189 } | 1213 } |
| 1190 | 1214 |
| 1191 if (!document->isHTMLDocument() && !document->isSVGDocument()) | 1215 if (!document->isHTMLDocument() && !document->isSVGDocument()) |
| 1192 return 0; | 1216 return 0; |
| 1193 | 1217 |
| 1194 RefPtr<InspectorStyleSheet> inspectorStyleSheet = m_documentToViaInspectorSt
yleSheet.get(document); | 1218 RefPtrWillBeRawPtr<InspectorStyleSheet> inspectorStyleSheet = m_documentToVi
aInspectorStyleSheet.get(document); |
| 1195 if (inspectorStyleSheet || !createIfAbsent) | 1219 if (inspectorStyleSheet || !createIfAbsent) |
| 1196 return inspectorStyleSheet.get(); | 1220 return inspectorStyleSheet.get(); |
| 1197 | 1221 |
| 1198 TrackExceptionState exceptionState; | 1222 TrackExceptionState exceptionState; |
| 1199 RefPtrWillBeRawPtr<Element> styleElement = document->createElement("style",
exceptionState); | 1223 RefPtrWillBeRawPtr<Element> styleElement = document->createElement("style",
exceptionState); |
| 1200 if (!exceptionState.hadException()) | 1224 if (!exceptionState.hadException()) |
| 1201 styleElement->setAttribute("type", "text/css", exceptionState); | 1225 styleElement->setAttribute("type", "text/css", exceptionState); |
| 1202 if (!exceptionState.hadException()) { | 1226 if (!exceptionState.hadException()) { |
| 1203 ContainerNode* targetNode; | 1227 ContainerNode* targetNode; |
| 1204 // HEAD is absent in ImageDocuments, for example. | 1228 // HEAD is absent in ImageDocuments, for example. |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1406 m_nodeIdToForcedPseudoState.clear(); | 1430 m_nodeIdToForcedPseudoState.clear(); |
| 1407 for (WillBeHeapHashSet<RawPtrWillBeMember<Document> >::iterator it = documen
tsToChange.begin(), end = documentsToChange.end(); it != end; ++it) | 1431 for (WillBeHeapHashSet<RawPtrWillBeMember<Document> >::iterator it = documen
tsToChange.begin(), end = documentsToChange.end(); it != end; ++it) |
| 1408 (*it)->setNeedsStyleRecalc(SubtreeStyleChange); | 1432 (*it)->setNeedsStyleRecalc(SubtreeStyleChange); |
| 1409 } | 1433 } |
| 1410 | 1434 |
| 1411 void InspectorCSSAgent::trace(Visitor* visitor) | 1435 void InspectorCSSAgent::trace(Visitor* visitor) |
| 1412 { | 1436 { |
| 1413 visitor->trace(m_domAgent); | 1437 visitor->trace(m_domAgent); |
| 1414 visitor->trace(m_pageAgent); | 1438 visitor->trace(m_pageAgent); |
| 1415 visitor->trace(m_resourceAgent); | 1439 visitor->trace(m_resourceAgent); |
| 1440 visitor->trace(m_idToInspectorStyleSheet); |
| 1441 visitor->trace(m_idToInspectorStyleSheetForInlineStyle); |
| 1416 visitor->trace(m_cssStyleSheetToInspectorStyleSheet); | 1442 visitor->trace(m_cssStyleSheetToInspectorStyleSheet); |
| 1417 visitor->trace(m_documentToCSSStyleSheets); | 1443 visitor->trace(m_documentToCSSStyleSheets); |
| 1418 visitor->trace(m_invalidatedDocuments); | 1444 visitor->trace(m_invalidatedDocuments); |
| 1445 visitor->trace(m_nodeToInspectorStyleSheet); |
| 1419 visitor->trace(m_documentToViaInspectorStyleSheet); | 1446 visitor->trace(m_documentToViaInspectorStyleSheet); |
| 1420 visitor->trace(m_inspectorUserAgentStyleSheet); | 1447 visitor->trace(m_inspectorUserAgentStyleSheet); |
| 1421 InspectorBaseAgent::trace(visitor); | 1448 InspectorBaseAgent::trace(visitor); |
| 1422 } | 1449 } |
| 1423 | 1450 |
| 1424 } // namespace blink | 1451 } // namespace blink |
| 1425 | 1452 |
| OLD | NEW |