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