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 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 } | 203 } |
204 | 204 |
205 virtual void merge(PassRefPtrWillBeRawPtr<Action> action) OVERRIDE | 205 virtual void merge(PassRefPtrWillBeRawPtr<Action> action) OVERRIDE |
206 { | 206 { |
207 ASSERT(action->mergeId() == mergeId()); | 207 ASSERT(action->mergeId() == mergeId()); |
208 | 208 |
209 SetStyleSheetTextAction* other = static_cast<SetStyleSheetTextAction*>(a
ction.get()); | 209 SetStyleSheetTextAction* other = static_cast<SetStyleSheetTextAction*>(a
ction.get()); |
210 m_text = other->m_text; | 210 m_text = other->m_text; |
211 } | 211 } |
212 | 212 |
| 213 virtual void trace(Visitor* visitor) OVERRIDE |
| 214 { |
| 215 visitor->trace(m_styleSheet); |
| 216 InspectorCSSAgent::StyleSheetAction::trace(visitor); |
| 217 } |
| 218 |
213 private: | 219 private: |
214 RefPtr<InspectorStyleSheetBase> m_styleSheet; | 220 RefPtrWillBeMember<InspectorStyleSheetBase> m_styleSheet; |
215 String m_text; | 221 String m_text; |
216 String m_oldText; | 222 String m_oldText; |
217 }; | 223 }; |
218 | 224 |
219 class InspectorCSSAgent::SetPropertyTextAction FINAL : public InspectorCSSAgent:
:StyleSheetAction { | 225 class InspectorCSSAgent::SetPropertyTextAction FINAL : public InspectorCSSAgent:
:StyleSheetAction { |
220 WTF_MAKE_NONCOPYABLE(SetPropertyTextAction); | 226 WTF_MAKE_NONCOPYABLE(SetPropertyTextAction); |
221 public: | 227 public: |
222 SetPropertyTextAction(InspectorStyleSheetBase* styleSheet, const InspectorCS
SId& cssId, unsigned propertyIndex, const String& text, bool overwrite) | 228 SetPropertyTextAction(InspectorStyleSheetBase* styleSheet, const InspectorCS
SId& cssId, unsigned propertyIndex, const String& text, bool overwrite) |
223 : InspectorCSSAgent::StyleSheetAction("SetPropertyText") | 229 : InspectorCSSAgent::StyleSheetAction("SetPropertyText") |
224 , m_styleSheet(styleSheet) | 230 , m_styleSheet(styleSheet) |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
259 } | 265 } |
260 | 266 |
261 virtual void merge(PassRefPtrWillBeRawPtr<Action> action) OVERRIDE | 267 virtual void merge(PassRefPtrWillBeRawPtr<Action> action) OVERRIDE |
262 { | 268 { |
263 ASSERT(action->mergeId() == mergeId()); | 269 ASSERT(action->mergeId() == mergeId()); |
264 | 270 |
265 SetPropertyTextAction* other = static_cast<SetPropertyTextAction*>(actio
n.get()); | 271 SetPropertyTextAction* other = static_cast<SetPropertyTextAction*>(actio
n.get()); |
266 m_text = other->m_text; | 272 m_text = other->m_text; |
267 } | 273 } |
268 | 274 |
| 275 virtual void trace(Visitor* visitor) OVERRIDE |
| 276 { |
| 277 visitor->trace(m_styleSheet); |
| 278 InspectorCSSAgent::StyleSheetAction::trace(visitor); |
| 279 } |
| 280 |
269 private: | 281 private: |
270 RefPtr<InspectorStyleSheetBase> m_styleSheet; | 282 RefPtrWillBeMember<InspectorStyleSheetBase> m_styleSheet; |
271 InspectorCSSId m_cssId; | 283 InspectorCSSId m_cssId; |
272 unsigned m_propertyIndex; | 284 unsigned m_propertyIndex; |
273 String m_text; | 285 String m_text; |
274 String m_oldStyleText; | 286 String m_oldStyleText; |
275 bool m_overwrite; | 287 bool m_overwrite; |
276 }; | 288 }; |
277 | 289 |
278 class InspectorCSSAgent::SetRuleSelectorAction FINAL : public InspectorCSSAgent:
:StyleSheetAction { | 290 class InspectorCSSAgent::SetRuleSelectorAction FINAL : public InspectorCSSAgent:
:StyleSheetAction { |
279 WTF_MAKE_NONCOPYABLE(SetRuleSelectorAction); | 291 WTF_MAKE_NONCOPYABLE(SetRuleSelectorAction); |
280 public: | 292 public: |
(...skipping 16 matching lines...) Expand all Loading... |
297 virtual bool undo(ExceptionState& exceptionState) OVERRIDE | 309 virtual bool undo(ExceptionState& exceptionState) OVERRIDE |
298 { | 310 { |
299 return m_styleSheet->setRuleSelector(m_cssId, m_oldSelector, exceptionSt
ate); | 311 return m_styleSheet->setRuleSelector(m_cssId, m_oldSelector, exceptionSt
ate); |
300 } | 312 } |
301 | 313 |
302 virtual bool redo(ExceptionState& exceptionState) OVERRIDE | 314 virtual bool redo(ExceptionState& exceptionState) OVERRIDE |
303 { | 315 { |
304 return m_styleSheet->setRuleSelector(m_cssId, m_selector, exceptionState
); | 316 return m_styleSheet->setRuleSelector(m_cssId, m_selector, exceptionState
); |
305 } | 317 } |
306 | 318 |
| 319 virtual void trace(Visitor* visitor) OVERRIDE |
| 320 { |
| 321 visitor->trace(m_styleSheet); |
| 322 InspectorCSSAgent::StyleSheetAction::trace(visitor); |
| 323 } |
| 324 |
307 private: | 325 private: |
308 RefPtr<InspectorStyleSheet> m_styleSheet; | 326 RefPtrWillBeMember<InspectorStyleSheet> m_styleSheet; |
309 InspectorCSSId m_cssId; | 327 InspectorCSSId m_cssId; |
310 String m_selector; | 328 String m_selector; |
311 String m_oldSelector; | 329 String m_oldSelector; |
312 }; | 330 }; |
313 | 331 |
314 class InspectorCSSAgent::AddRuleAction FINAL : public InspectorCSSAgent::StyleSh
eetAction { | 332 class InspectorCSSAgent::AddRuleAction FINAL : public InspectorCSSAgent::StyleSh
eetAction { |
315 WTF_MAKE_NONCOPYABLE(AddRuleAction); | 333 WTF_MAKE_NONCOPYABLE(AddRuleAction); |
316 public: | 334 public: |
317 AddRuleAction(InspectorStyleSheet* styleSheet, const String& selector) | 335 AddRuleAction(InspectorStyleSheet* styleSheet, const String& selector) |
318 : InspectorCSSAgent::StyleSheetAction("AddRule") | 336 : InspectorCSSAgent::StyleSheetAction("AddRule") |
(...skipping 14 matching lines...) Expand all Loading... |
333 | 351 |
334 virtual bool redo(ExceptionState& exceptionState) OVERRIDE | 352 virtual bool redo(ExceptionState& exceptionState) OVERRIDE |
335 { | 353 { |
336 CSSStyleRule* cssStyleRule = m_styleSheet->addRule(m_selector, exception
State); | 354 CSSStyleRule* cssStyleRule = m_styleSheet->addRule(m_selector, exception
State); |
337 if (exceptionState.hadException()) | 355 if (exceptionState.hadException()) |
338 return false; | 356 return false; |
339 m_newId = m_styleSheet->ruleId(cssStyleRule); | 357 m_newId = m_styleSheet->ruleId(cssStyleRule); |
340 return true; | 358 return true; |
341 } | 359 } |
342 | 360 |
| 361 virtual void trace(Visitor* visitor) OVERRIDE |
| 362 { |
| 363 visitor->trace(m_styleSheet); |
| 364 InspectorCSSAgent::StyleSheetAction::trace(visitor); |
| 365 } |
| 366 |
343 InspectorCSSId newRuleId() { return m_newId; } | 367 InspectorCSSId newRuleId() { return m_newId; } |
344 | 368 |
345 private: | 369 private: |
346 RefPtr<InspectorStyleSheet> m_styleSheet; | 370 RefPtrWillBeMember<InspectorStyleSheet> m_styleSheet; |
347 InspectorCSSId m_newId; | 371 InspectorCSSId m_newId; |
348 String m_selector; | 372 String m_selector; |
349 String m_oldSelector; | 373 String m_oldSelector; |
350 }; | 374 }; |
351 | 375 |
352 // static | 376 // static |
353 CSSStyleRule* InspectorCSSAgent::asCSSStyleRule(CSSRule* rule) | 377 CSSStyleRule* InspectorCSSAgent::asCSSStyleRule(CSSRule* rule) |
354 { | 378 { |
355 if (!rule || rule->type() != CSSRule::STYLE_RULE) | 379 if (!rule || rule->type() != CSSRule::STYLE_RULE) |
356 return 0; | 380 return 0; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
389 ASSERT(m_frontend); | 413 ASSERT(m_frontend); |
390 ErrorString error; | 414 ErrorString error; |
391 disable(&error); | 415 disable(&error); |
392 m_frontend = 0; | 416 m_frontend = 0; |
393 resetNonPersistentData(); | 417 resetNonPersistentData(); |
394 } | 418 } |
395 | 419 |
396 void InspectorCSSAgent::discardAgent() | 420 void InspectorCSSAgent::discardAgent() |
397 { | 421 { |
398 m_domAgent->setDOMListener(0); | 422 m_domAgent->setDOMListener(0); |
399 m_domAgent = 0; | 423 m_domAgent = nullptr; |
400 } | 424 } |
401 | 425 |
402 void InspectorCSSAgent::restore() | 426 void InspectorCSSAgent::restore() |
403 { | 427 { |
404 if (m_state->getBoolean(CSSAgentState::cssAgentEnabled)) | 428 if (m_state->getBoolean(CSSAgentState::cssAgentEnabled)) |
405 wasEnabled(nullptr); | 429 wasEnabled(nullptr); |
406 } | 430 } |
407 | 431 |
408 void InspectorCSSAgent::flushPendingFrontendMessages() | 432 void InspectorCSSAgent::flushPendingFrontendMessages() |
409 { | 433 { |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
571 removedSheets.remove(cssStyleSheet); | 595 removedSheets.remove(cssStyleSheet); |
572 if (isInitialFrontendLoad) | 596 if (isInitialFrontendLoad) |
573 addedSheets.add(cssStyleSheet); | 597 addedSheets.add(cssStyleSheet); |
574 } else { | 598 } else { |
575 addedSheets.add(cssStyleSheet); | 599 addedSheets.add(cssStyleSheet); |
576 } | 600 } |
577 } | 601 } |
578 | 602 |
579 for (HashSet<CSSStyleSheet*>::iterator it = removedSheets.begin(); it != rem
ovedSheets.end(); ++it) { | 603 for (HashSet<CSSStyleSheet*>::iterator it = removedSheets.begin(); it != rem
ovedSheets.end(); ++it) { |
580 CSSStyleSheet* cssStyleSheet = *it; | 604 CSSStyleSheet* cssStyleSheet = *it; |
581 RefPtr<InspectorStyleSheet> inspectorStyleSheet = m_cssStyleSheetToInspe
ctorStyleSheet.get(cssStyleSheet); | 605 RefPtrWillBeRawPtr<InspectorStyleSheet> inspectorStyleSheet = m_cssStyle
SheetToInspectorStyleSheet.get(cssStyleSheet); |
582 ASSERT(inspectorStyleSheet); | 606 ASSERT(inspectorStyleSheet); |
583 | 607 |
584 documentCSSStyleSheets->remove(cssStyleSheet); | 608 documentCSSStyleSheets->remove(cssStyleSheet); |
585 if (m_idToInspectorStyleSheet.contains(inspectorStyleSheet->id())) { | 609 if (m_idToInspectorStyleSheet.contains(inspectorStyleSheet->id())) { |
586 String id = unbindStyleSheet(inspectorStyleSheet.get()); | 610 String id = unbindStyleSheet(inspectorStyleSheet.get()); |
587 if (m_frontend && !isInitialFrontendLoad) | 611 if (m_frontend && !isInitialFrontendLoad) |
588 m_frontend->styleSheetRemoved(id); | 612 m_frontend->styleSheetRemoved(id); |
589 } | 613 } |
590 } | 614 } |
591 | 615 |
(...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1083 { | 1107 { |
1084 NodeToInspectorStyleSheet::iterator it = m_nodeToInspectorStyleSheet.find(el
ement); | 1108 NodeToInspectorStyleSheet::iterator it = m_nodeToInspectorStyleSheet.find(el
ement); |
1085 if (it != m_nodeToInspectorStyleSheet.end()) | 1109 if (it != m_nodeToInspectorStyleSheet.end()) |
1086 return it->value.get(); | 1110 return it->value.get(); |
1087 | 1111 |
1088 CSSStyleDeclaration* style = element->isStyledElement() ? element->style() :
0; | 1112 CSSStyleDeclaration* style = element->isStyledElement() ? element->style() :
0; |
1089 if (!style) | 1113 if (!style) |
1090 return 0; | 1114 return 0; |
1091 | 1115 |
1092 String newStyleSheetId = String::number(m_lastStyleSheetId++); | 1116 String newStyleSheetId = String::number(m_lastStyleSheetId++); |
1093 RefPtr<InspectorStyleSheetForInlineStyle> inspectorStyleSheet = InspectorSty
leSheetForInlineStyle::create(newStyleSheetId, element, this); | 1117 RefPtrWillBeRawPtr<InspectorStyleSheetForInlineStyle> inspectorStyleSheet =
InspectorStyleSheetForInlineStyle::create(newStyleSheetId, element, this); |
1094 m_idToInspectorStyleSheetForInlineStyle.set(newStyleSheetId, inspectorStyleS
heet); | 1118 m_idToInspectorStyleSheetForInlineStyle.set(newStyleSheetId, inspectorStyleS
heet); |
1095 m_nodeToInspectorStyleSheet.set(element, inspectorStyleSheet); | 1119 m_nodeToInspectorStyleSheet.set(element, inspectorStyleSheet); |
1096 return inspectorStyleSheet.get(); | 1120 return inspectorStyleSheet.get(); |
1097 } | 1121 } |
1098 | 1122 |
1099 Element* InspectorCSSAgent::elementForId(ErrorString* errorString, int nodeId) | 1123 Element* InspectorCSSAgent::elementForId(ErrorString* errorString, int nodeId) |
1100 { | 1124 { |
1101 Node* node = m_domAgent->nodeForId(nodeId); | 1125 Node* node = m_domAgent->nodeForId(nodeId); |
1102 if (!node) { | 1126 if (!node) { |
1103 *errorString = "No node with given id found"; | 1127 *errorString = "No node with given id found"; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1138 if (rule->type() == CSSRule::IMPORT_RULE) { | 1162 if (rule->type() == CSSRule::IMPORT_RULE) { |
1139 CSSStyleSheet* importedStyleSheet = toCSSImportRule(rule)->styleShee
t(); | 1163 CSSStyleSheet* importedStyleSheet = toCSSImportRule(rule)->styleShee
t(); |
1140 if (importedStyleSheet) | 1164 if (importedStyleSheet) |
1141 collectStyleSheets(importedStyleSheet, result); | 1165 collectStyleSheets(importedStyleSheet, result); |
1142 } | 1166 } |
1143 } | 1167 } |
1144 } | 1168 } |
1145 | 1169 |
1146 InspectorStyleSheet* InspectorCSSAgent::bindStyleSheet(CSSStyleSheet* styleSheet
) | 1170 InspectorStyleSheet* InspectorCSSAgent::bindStyleSheet(CSSStyleSheet* styleSheet
) |
1147 { | 1171 { |
1148 RefPtr<InspectorStyleSheet> inspectorStyleSheet = m_cssStyleSheetToInspector
StyleSheet.get(styleSheet); | 1172 RefPtrWillBeRawPtr<InspectorStyleSheet> inspectorStyleSheet = m_cssStyleShee
tToInspectorStyleSheet.get(styleSheet); |
1149 if (!inspectorStyleSheet) { | 1173 if (!inspectorStyleSheet) { |
1150 String id = String::number(m_lastStyleSheetId++); | 1174 String id = String::number(m_lastStyleSheetId++); |
1151 Document* document = styleSheet->ownerDocument(); | 1175 Document* document = styleSheet->ownerDocument(); |
1152 inspectorStyleSheet = InspectorStyleSheet::create(m_pageAgent, m_resourc
eAgent, id, styleSheet, detectOrigin(styleSheet, document), InspectorDOMAgent::d
ocumentURLString(document), this); | 1176 inspectorStyleSheet = InspectorStyleSheet::create(m_pageAgent, m_resourc
eAgent, id, styleSheet, detectOrigin(styleSheet, document), InspectorDOMAgent::d
ocumentURLString(document), this); |
1153 m_idToInspectorStyleSheet.set(id, inspectorStyleSheet); | 1177 m_idToInspectorStyleSheet.set(id, inspectorStyleSheet); |
1154 m_cssStyleSheetToInspectorStyleSheet.set(styleSheet, inspectorStyleSheet
); | 1178 m_cssStyleSheetToInspectorStyleSheet.set(styleSheet, inspectorStyleSheet
); |
1155 if (m_creatingViaInspectorStyleSheet) | 1179 if (m_creatingViaInspectorStyleSheet) |
1156 m_documentToViaInspectorStyleSheet.add(document, inspectorStyleSheet
); | 1180 m_documentToViaInspectorStyleSheet.add(document, inspectorStyleSheet
); |
1157 } | 1181 } |
1158 return inspectorStyleSheet.get(); | 1182 return inspectorStyleSheet.get(); |
(...skipping 11 matching lines...) Expand all Loading... |
1170 InspectorStyleSheet* InspectorCSSAgent::viaInspectorStyleSheet(Document* documen
t, bool createIfAbsent) | 1194 InspectorStyleSheet* InspectorCSSAgent::viaInspectorStyleSheet(Document* documen
t, bool createIfAbsent) |
1171 { | 1195 { |
1172 if (!document) { | 1196 if (!document) { |
1173 ASSERT(!createIfAbsent); | 1197 ASSERT(!createIfAbsent); |
1174 return 0; | 1198 return 0; |
1175 } | 1199 } |
1176 | 1200 |
1177 if (!document->isHTMLDocument() && !document->isSVGDocument()) | 1201 if (!document->isHTMLDocument() && !document->isSVGDocument()) |
1178 return 0; | 1202 return 0; |
1179 | 1203 |
1180 RefPtr<InspectorStyleSheet> inspectorStyleSheet = m_documentToViaInspectorSt
yleSheet.get(document); | 1204 RefPtrWillBeRawPtr<InspectorStyleSheet> inspectorStyleSheet = m_documentToVi
aInspectorStyleSheet.get(document); |
1181 if (inspectorStyleSheet || !createIfAbsent) | 1205 if (inspectorStyleSheet || !createIfAbsent) |
1182 return inspectorStyleSheet.get(); | 1206 return inspectorStyleSheet.get(); |
1183 | 1207 |
1184 TrackExceptionState exceptionState; | 1208 TrackExceptionState exceptionState; |
1185 RefPtrWillBeRawPtr<Element> styleElement = document->createElement("style",
exceptionState); | 1209 RefPtrWillBeRawPtr<Element> styleElement = document->createElement("style",
exceptionState); |
1186 if (!exceptionState.hadException()) | 1210 if (!exceptionState.hadException()) |
1187 styleElement->setAttribute("type", "text/css", exceptionState); | 1211 styleElement->setAttribute("type", "text/css", exceptionState); |
1188 if (!exceptionState.hadException()) { | 1212 if (!exceptionState.hadException()) { |
1189 ContainerNode* targetNode; | 1213 ContainerNode* targetNode; |
1190 // HEAD is absent in ImageDocuments, for example. | 1214 // HEAD is absent in ImageDocuments, for example. |
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1432 Element* element = toElement(m_domAgent->nodeForId(it->key)); | 1456 Element* element = toElement(m_domAgent->nodeForId(it->key)); |
1433 if (element && element->ownerDocument()) | 1457 if (element && element->ownerDocument()) |
1434 documentsToChange.add(element->ownerDocument()); | 1458 documentsToChange.add(element->ownerDocument()); |
1435 } | 1459 } |
1436 | 1460 |
1437 m_nodeIdToForcedPseudoState.clear(); | 1461 m_nodeIdToForcedPseudoState.clear(); |
1438 for (HashSet<Document*>::iterator it = documentsToChange.begin(), end = docu
mentsToChange.end(); it != end; ++it) | 1462 for (HashSet<Document*>::iterator it = documentsToChange.begin(), end = docu
mentsToChange.end(); it != end; ++it) |
1439 (*it)->setNeedsStyleRecalc(SubtreeStyleChange); | 1463 (*it)->setNeedsStyleRecalc(SubtreeStyleChange); |
1440 } | 1464 } |
1441 | 1465 |
| 1466 void InspectorCSSAgent::trace(Visitor* visitor) |
| 1467 { |
| 1468 visitor->trace(m_domAgent); |
| 1469 visitor->trace(m_pageAgent); |
| 1470 visitor->trace(m_resourceAgent); |
| 1471 visitor->trace(m_idToInspectorStyleSheet); |
| 1472 visitor->trace(m_idToInspectorStyleSheetForInlineStyle); |
| 1473 visitor->trace(m_cssStyleSheetToInspectorStyleSheet); |
| 1474 visitor->trace(m_inspectorUserAgentStyleSheet); |
| 1475 visitor->trace(m_nodeToInspectorStyleSheet); |
| 1476 visitor->trace(m_documentToViaInspectorStyleSheet); |
| 1477 InspectorBaseAgent::trace(visitor); |
| 1478 } |
| 1479 |
1442 } // namespace WebCore | 1480 } // namespace WebCore |
1443 | 1481 |
OLD | NEW |