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 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 } | 202 } |
203 | 203 |
204 virtual void merge(PassRefPtrWillBeRawPtr<Action> action) OVERRIDE | 204 virtual void merge(PassRefPtrWillBeRawPtr<Action> action) OVERRIDE |
205 { | 205 { |
206 ASSERT(action->mergeId() == mergeId()); | 206 ASSERT(action->mergeId() == mergeId()); |
207 | 207 |
208 SetStyleSheetTextAction* other = static_cast<SetStyleSheetTextAction*>(a
ction.get()); | 208 SetStyleSheetTextAction* other = static_cast<SetStyleSheetTextAction*>(a
ction.get()); |
209 m_text = other->m_text; | 209 m_text = other->m_text; |
210 } | 210 } |
211 | 211 |
| 212 virtual void trace(Visitor* visitor) OVERRIDE |
| 213 { |
| 214 visitor->trace(m_styleSheet); |
| 215 InspectorCSSAgent::StyleSheetAction::trace(visitor); |
| 216 } |
| 217 |
212 private: | 218 private: |
213 RefPtr<InspectorStyleSheetBase> m_styleSheet; | 219 RefPtrWillBeMember<InspectorStyleSheetBase> m_styleSheet; |
214 String m_text; | 220 String m_text; |
215 String m_oldText; | 221 String m_oldText; |
216 }; | 222 }; |
217 | 223 |
218 class InspectorCSSAgent::SetPropertyTextAction FINAL : public InspectorCSSAgent:
:StyleSheetAction { | 224 class InspectorCSSAgent::SetPropertyTextAction FINAL : public InspectorCSSAgent:
:StyleSheetAction { |
219 WTF_MAKE_NONCOPYABLE(SetPropertyTextAction); | 225 WTF_MAKE_NONCOPYABLE(SetPropertyTextAction); |
220 public: | 226 public: |
221 SetPropertyTextAction(InspectorStyleSheetBase* styleSheet, const InspectorCS
SId& cssId, unsigned propertyIndex, const String& text, bool overwrite) | 227 SetPropertyTextAction(InspectorStyleSheetBase* styleSheet, const InspectorCS
SId& cssId, unsigned propertyIndex, const String& text, bool overwrite) |
222 : InspectorCSSAgent::StyleSheetAction("SetPropertyText") | 228 : InspectorCSSAgent::StyleSheetAction("SetPropertyText") |
223 , m_styleSheet(styleSheet) | 229 , m_styleSheet(styleSheet) |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 } | 264 } |
259 | 265 |
260 virtual void merge(PassRefPtrWillBeRawPtr<Action> action) OVERRIDE | 266 virtual void merge(PassRefPtrWillBeRawPtr<Action> action) OVERRIDE |
261 { | 267 { |
262 ASSERT(action->mergeId() == mergeId()); | 268 ASSERT(action->mergeId() == mergeId()); |
263 | 269 |
264 SetPropertyTextAction* other = static_cast<SetPropertyTextAction*>(actio
n.get()); | 270 SetPropertyTextAction* other = static_cast<SetPropertyTextAction*>(actio
n.get()); |
265 m_text = other->m_text; | 271 m_text = other->m_text; |
266 } | 272 } |
267 | 273 |
| 274 virtual void trace(Visitor* visitor) OVERRIDE |
| 275 { |
| 276 visitor->trace(m_styleSheet); |
| 277 InspectorCSSAgent::StyleSheetAction::trace(visitor); |
| 278 } |
| 279 |
268 private: | 280 private: |
269 RefPtr<InspectorStyleSheetBase> m_styleSheet; | 281 RefPtrWillBeMember<InspectorStyleSheetBase> m_styleSheet; |
270 InspectorCSSId m_cssId; | 282 InspectorCSSId m_cssId; |
271 unsigned m_propertyIndex; | 283 unsigned m_propertyIndex; |
272 String m_text; | 284 String m_text; |
273 String m_oldStyleText; | 285 String m_oldStyleText; |
274 bool m_overwrite; | 286 bool m_overwrite; |
275 }; | 287 }; |
276 | 288 |
277 class InspectorCSSAgent::SetRuleSelectorAction FINAL : public InspectorCSSAgent:
:StyleSheetAction { | 289 class InspectorCSSAgent::SetRuleSelectorAction FINAL : public InspectorCSSAgent:
:StyleSheetAction { |
278 WTF_MAKE_NONCOPYABLE(SetRuleSelectorAction); | 290 WTF_MAKE_NONCOPYABLE(SetRuleSelectorAction); |
279 public: | 291 public: |
(...skipping 16 matching lines...) Expand all Loading... |
296 virtual bool undo(ExceptionState& exceptionState) OVERRIDE | 308 virtual bool undo(ExceptionState& exceptionState) OVERRIDE |
297 { | 309 { |
298 return m_styleSheet->setRuleSelector(m_cssId, m_oldSelector, exceptionSt
ate); | 310 return m_styleSheet->setRuleSelector(m_cssId, m_oldSelector, exceptionSt
ate); |
299 } | 311 } |
300 | 312 |
301 virtual bool redo(ExceptionState& exceptionState) OVERRIDE | 313 virtual bool redo(ExceptionState& exceptionState) OVERRIDE |
302 { | 314 { |
303 return m_styleSheet->setRuleSelector(m_cssId, m_selector, exceptionState
); | 315 return m_styleSheet->setRuleSelector(m_cssId, m_selector, exceptionState
); |
304 } | 316 } |
305 | 317 |
| 318 virtual void trace(Visitor* visitor) OVERRIDE |
| 319 { |
| 320 visitor->trace(m_styleSheet); |
| 321 InspectorCSSAgent::StyleSheetAction::trace(visitor); |
| 322 } |
| 323 |
306 private: | 324 private: |
307 RefPtr<InspectorStyleSheet> m_styleSheet; | 325 RefPtrWillBeMember<InspectorStyleSheet> m_styleSheet; |
308 InspectorCSSId m_cssId; | 326 InspectorCSSId m_cssId; |
309 String m_selector; | 327 String m_selector; |
310 String m_oldSelector; | 328 String m_oldSelector; |
311 }; | 329 }; |
312 | 330 |
313 class InspectorCSSAgent::AddRuleAction FINAL : public InspectorCSSAgent::StyleSh
eetAction { | 331 class InspectorCSSAgent::AddRuleAction FINAL : public InspectorCSSAgent::StyleSh
eetAction { |
314 WTF_MAKE_NONCOPYABLE(AddRuleAction); | 332 WTF_MAKE_NONCOPYABLE(AddRuleAction); |
315 public: | 333 public: |
316 AddRuleAction(InspectorStyleSheet* styleSheet, const String& selector) | 334 AddRuleAction(InspectorStyleSheet* styleSheet, const String& selector) |
317 : InspectorCSSAgent::StyleSheetAction("AddRule") | 335 : InspectorCSSAgent::StyleSheetAction("AddRule") |
(...skipping 14 matching lines...) Expand all Loading... |
332 | 350 |
333 virtual bool redo(ExceptionState& exceptionState) OVERRIDE | 351 virtual bool redo(ExceptionState& exceptionState) OVERRIDE |
334 { | 352 { |
335 CSSStyleRule* cssStyleRule = m_styleSheet->addRule(m_selector, exception
State); | 353 CSSStyleRule* cssStyleRule = m_styleSheet->addRule(m_selector, exception
State); |
336 if (exceptionState.hadException()) | 354 if (exceptionState.hadException()) |
337 return false; | 355 return false; |
338 m_newId = m_styleSheet->ruleId(cssStyleRule); | 356 m_newId = m_styleSheet->ruleId(cssStyleRule); |
339 return true; | 357 return true; |
340 } | 358 } |
341 | 359 |
| 360 virtual void trace(Visitor* visitor) OVERRIDE |
| 361 { |
| 362 visitor->trace(m_styleSheet); |
| 363 InspectorCSSAgent::StyleSheetAction::trace(visitor); |
| 364 } |
| 365 |
342 InspectorCSSId newRuleId() { return m_newId; } | 366 InspectorCSSId newRuleId() { return m_newId; } |
343 | 367 |
344 private: | 368 private: |
345 RefPtr<InspectorStyleSheet> m_styleSheet; | 369 RefPtrWillBeMember<InspectorStyleSheet> m_styleSheet; |
346 InspectorCSSId m_newId; | 370 InspectorCSSId m_newId; |
347 String m_selector; | 371 String m_selector; |
348 String m_oldSelector; | 372 String m_oldSelector; |
349 }; | 373 }; |
350 | 374 |
351 // static | 375 // static |
352 CSSStyleRule* InspectorCSSAgent::asCSSStyleRule(CSSRule* rule) | 376 CSSStyleRule* InspectorCSSAgent::asCSSStyleRule(CSSRule* rule) |
353 { | 377 { |
354 if (!rule || rule->type() != CSSRule::STYLE_RULE) | 378 if (!rule || rule->type() != CSSRule::STYLE_RULE) |
355 return 0; | 379 return 0; |
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
634 return forcedPseudoState & PseudoVisited; | 658 return forcedPseudoState & PseudoVisited; |
635 default: | 659 default: |
636 return false; | 660 return false; |
637 } | 661 } |
638 } | 662 } |
639 | 663 |
640 void InspectorCSSAgent::getMediaQueries(ErrorString* errorString, RefPtr<TypeBui
lder::Array<TypeBuilder::CSS::CSSMedia> >& medias) | 664 void InspectorCSSAgent::getMediaQueries(ErrorString* errorString, RefPtr<TypeBui
lder::Array<TypeBuilder::CSS::CSSMedia> >& medias) |
641 { | 665 { |
642 medias = TypeBuilder::Array<TypeBuilder::CSS::CSSMedia>::create(); | 666 medias = TypeBuilder::Array<TypeBuilder::CSS::CSSMedia>::create(); |
643 for (IdToInspectorStyleSheet::iterator it = m_idToInspectorStyleSheet.begin(
); it != m_idToInspectorStyleSheet.end(); ++it) { | 667 for (IdToInspectorStyleSheet::iterator it = m_idToInspectorStyleSheet.begin(
); it != m_idToInspectorStyleSheet.end(); ++it) { |
644 RefPtr<InspectorStyleSheet> styleSheet = it->value; | 668 RefPtrWillBeRawPtr<InspectorStyleSheet> styleSheet = it->value; |
645 collectMediaQueriesFromStyleSheet(styleSheet->pageStyleSheet(), medias.g
et()); | 669 collectMediaQueriesFromStyleSheet(styleSheet->pageStyleSheet(), medias.g
et()); |
646 const CSSRuleVector& flatRules = styleSheet->flatRules(); | 670 const CSSRuleVector& flatRules = styleSheet->flatRules(); |
647 for (unsigned i = 0; i < flatRules.size(); ++i) { | 671 for (unsigned i = 0; i < flatRules.size(); ++i) { |
648 CSSRule* rule = flatRules.at(i).get(); | 672 CSSRule* rule = flatRules.at(i).get(); |
649 if (rule->type() == CSSRule::MEDIA_RULE) | 673 if (rule->type() == CSSRule::MEDIA_RULE) |
650 collectMediaQueriesFromRule(rule, medias.get()); | 674 collectMediaQueriesFromRule(rule, medias.get()); |
651 } | 675 } |
652 } | 676 } |
653 } | 677 } |
654 | 678 |
(...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1142 { | 1166 { |
1143 NodeToInspectorStyleSheet::iterator it = m_nodeToInspectorStyleSheet.find(el
ement); | 1167 NodeToInspectorStyleSheet::iterator it = m_nodeToInspectorStyleSheet.find(el
ement); |
1144 if (it != m_nodeToInspectorStyleSheet.end()) | 1168 if (it != m_nodeToInspectorStyleSheet.end()) |
1145 return it->value.get(); | 1169 return it->value.get(); |
1146 | 1170 |
1147 CSSStyleDeclaration* style = element->isStyledElement() ? element->style() :
0; | 1171 CSSStyleDeclaration* style = element->isStyledElement() ? element->style() :
0; |
1148 if (!style) | 1172 if (!style) |
1149 return 0; | 1173 return 0; |
1150 | 1174 |
1151 String newStyleSheetId = String::number(m_lastStyleSheetId++); | 1175 String newStyleSheetId = String::number(m_lastStyleSheetId++); |
1152 RefPtr<InspectorStyleSheetForInlineStyle> inspectorStyleSheet = InspectorSty
leSheetForInlineStyle::create(newStyleSheetId, element, this); | 1176 RefPtrWillBeRawPtr<InspectorStyleSheetForInlineStyle> inspectorStyleSheet =
InspectorStyleSheetForInlineStyle::create(newStyleSheetId, element, this); |
1153 m_idToInspectorStyleSheetForInlineStyle.set(newStyleSheetId, inspectorStyleS
heet); | 1177 m_idToInspectorStyleSheetForInlineStyle.set(newStyleSheetId, inspectorStyleS
heet); |
1154 m_nodeToInspectorStyleSheet.set(element, inspectorStyleSheet); | 1178 m_nodeToInspectorStyleSheet.set(element, inspectorStyleSheet); |
1155 return inspectorStyleSheet.get(); | 1179 return inspectorStyleSheet.get(); |
1156 } | 1180 } |
1157 | 1181 |
1158 Element* InspectorCSSAgent::elementForId(ErrorString* errorString, int nodeId) | 1182 Element* InspectorCSSAgent::elementForId(ErrorString* errorString, int nodeId) |
1159 { | 1183 { |
1160 Node* node = m_domAgent->nodeForId(nodeId); | 1184 Node* node = m_domAgent->nodeForId(nodeId); |
1161 if (!node) { | 1185 if (!node) { |
1162 *errorString = "No node with given id found"; | 1186 *errorString = "No node with given id found"; |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1196 if (rule->type() == CSSRule::IMPORT_RULE) { | 1220 if (rule->type() == CSSRule::IMPORT_RULE) { |
1197 CSSStyleSheet* importedStyleSheet = toCSSImportRule(rule)->styleShee
t(); | 1221 CSSStyleSheet* importedStyleSheet = toCSSImportRule(rule)->styleShee
t(); |
1198 if (importedStyleSheet) | 1222 if (importedStyleSheet) |
1199 collectStyleSheets(importedStyleSheet, result); | 1223 collectStyleSheets(importedStyleSheet, result); |
1200 } | 1224 } |
1201 } | 1225 } |
1202 } | 1226 } |
1203 | 1227 |
1204 InspectorStyleSheet* InspectorCSSAgent::bindStyleSheet(CSSStyleSheet* styleSheet
) | 1228 InspectorStyleSheet* InspectorCSSAgent::bindStyleSheet(CSSStyleSheet* styleSheet
) |
1205 { | 1229 { |
1206 RefPtr<InspectorStyleSheet> inspectorStyleSheet = m_cssStyleSheetToInspector
StyleSheet.get(styleSheet); | 1230 RefPtrWillBeRawPtr<InspectorStyleSheet> inspectorStyleSheet = m_cssStyleShee
tToInspectorStyleSheet.get(styleSheet); |
1207 if (!inspectorStyleSheet) { | 1231 if (!inspectorStyleSheet) { |
1208 String id = String::number(m_lastStyleSheetId++); | 1232 String id = String::number(m_lastStyleSheetId++); |
1209 Document* document = styleSheet->ownerDocument(); | 1233 Document* document = styleSheet->ownerDocument(); |
1210 inspectorStyleSheet = InspectorStyleSheet::create(m_pageAgent, m_resourc
eAgent, id, styleSheet, detectOrigin(styleSheet, document), InspectorDOMAgent::d
ocumentURLString(document), this); | 1234 inspectorStyleSheet = InspectorStyleSheet::create(m_pageAgent, m_resourc
eAgent, id, styleSheet, detectOrigin(styleSheet, document), InspectorDOMAgent::d
ocumentURLString(document), this); |
1211 m_idToInspectorStyleSheet.set(id, inspectorStyleSheet); | 1235 m_idToInspectorStyleSheet.set(id, inspectorStyleSheet); |
1212 m_cssStyleSheetToInspectorStyleSheet.set(styleSheet, inspectorStyleSheet
); | 1236 m_cssStyleSheetToInspectorStyleSheet.set(styleSheet, inspectorStyleSheet
); |
1213 if (m_creatingViaInspectorStyleSheet) | 1237 if (m_creatingViaInspectorStyleSheet) |
1214 m_documentToViaInspectorStyleSheet.add(document, inspectorStyleSheet
); | 1238 m_documentToViaInspectorStyleSheet.add(document, inspectorStyleSheet
); |
1215 } | 1239 } |
1216 return inspectorStyleSheet.get(); | 1240 return inspectorStyleSheet.get(); |
(...skipping 11 matching lines...) Expand all Loading... |
1228 InspectorStyleSheet* InspectorCSSAgent::viaInspectorStyleSheet(Document* documen
t, bool createIfAbsent) | 1252 InspectorStyleSheet* InspectorCSSAgent::viaInspectorStyleSheet(Document* documen
t, bool createIfAbsent) |
1229 { | 1253 { |
1230 if (!document) { | 1254 if (!document) { |
1231 ASSERT(!createIfAbsent); | 1255 ASSERT(!createIfAbsent); |
1232 return 0; | 1256 return 0; |
1233 } | 1257 } |
1234 | 1258 |
1235 if (!document->isHTMLDocument() && !document->isSVGDocument()) | 1259 if (!document->isHTMLDocument() && !document->isSVGDocument()) |
1236 return 0; | 1260 return 0; |
1237 | 1261 |
1238 RefPtr<InspectorStyleSheet> inspectorStyleSheet = m_documentToViaInspectorSt
yleSheet.get(document); | 1262 RefPtrWillBeRawPtr<InspectorStyleSheet> inspectorStyleSheet = m_documentToVi
aInspectorStyleSheet.get(document); |
1239 if (inspectorStyleSheet || !createIfAbsent) | 1263 if (inspectorStyleSheet || !createIfAbsent) |
1240 return inspectorStyleSheet.get(); | 1264 return inspectorStyleSheet.get(); |
1241 | 1265 |
1242 TrackExceptionState exceptionState; | 1266 TrackExceptionState exceptionState; |
1243 RefPtrWillBeRawPtr<Element> styleElement = document->createElement("style",
exceptionState); | 1267 RefPtrWillBeRawPtr<Element> styleElement = document->createElement("style",
exceptionState); |
1244 if (!exceptionState.hadException()) | 1268 if (!exceptionState.hadException()) |
1245 styleElement->setAttribute("type", "text/css", exceptionState); | 1269 styleElement->setAttribute("type", "text/css", exceptionState); |
1246 if (!exceptionState.hadException()) { | 1270 if (!exceptionState.hadException()) { |
1247 ContainerNode* targetNode; | 1271 ContainerNode* targetNode; |
1248 // HEAD is absent in ImageDocuments, for example. | 1272 // HEAD is absent in ImageDocuments, for example. |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1450 m_nodeIdToForcedPseudoState.clear(); | 1474 m_nodeIdToForcedPseudoState.clear(); |
1451 for (HashSet<Document*>::iterator it = documentsToChange.begin(), end = docu
mentsToChange.end(); it != end; ++it) | 1475 for (HashSet<Document*>::iterator it = documentsToChange.begin(), end = docu
mentsToChange.end(); it != end; ++it) |
1452 (*it)->setNeedsStyleRecalc(SubtreeStyleChange); | 1476 (*it)->setNeedsStyleRecalc(SubtreeStyleChange); |
1453 } | 1477 } |
1454 | 1478 |
1455 void InspectorCSSAgent::trace(Visitor* visitor) | 1479 void InspectorCSSAgent::trace(Visitor* visitor) |
1456 { | 1480 { |
1457 visitor->trace(m_domAgent); | 1481 visitor->trace(m_domAgent); |
1458 visitor->trace(m_pageAgent); | 1482 visitor->trace(m_pageAgent); |
1459 visitor->trace(m_resourceAgent); | 1483 visitor->trace(m_resourceAgent); |
| 1484 visitor->trace(m_idToInspectorStyleSheet); |
| 1485 visitor->trace(m_idToInspectorStyleSheetForInlineStyle); |
| 1486 visitor->trace(m_cssStyleSheetToInspectorStyleSheet); |
| 1487 visitor->trace(m_inspectorUserAgentStyleSheet); |
| 1488 visitor->trace(m_nodeToInspectorStyleSheet); |
1460 visitor->trace(m_documentToViaInspectorStyleSheet); | 1489 visitor->trace(m_documentToViaInspectorStyleSheet); |
1461 visitor->trace(m_inspectorUserAgentStyleSheet); | |
1462 InspectorBaseAgent::trace(visitor); | 1490 InspectorBaseAgent::trace(visitor); |
1463 } | 1491 } |
1464 | 1492 |
1465 } // namespace WebCore | 1493 } // namespace WebCore |
1466 | 1494 |
OLD | NEW |