| 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 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 635 return forcedPseudoState & PseudoVisited; | 659 return forcedPseudoState & PseudoVisited; |
| 636 default: | 660 default: |
| 637 return false; | 661 return false; |
| 638 } | 662 } |
| 639 } | 663 } |
| 640 | 664 |
| 641 void InspectorCSSAgent::getMediaQueries(ErrorString* errorString, RefPtr<TypeBui
lder::Array<TypeBuilder::CSS::CSSMedia> >& medias) | 665 void InspectorCSSAgent::getMediaQueries(ErrorString* errorString, RefPtr<TypeBui
lder::Array<TypeBuilder::CSS::CSSMedia> >& medias) |
| 642 { | 666 { |
| 643 medias = TypeBuilder::Array<TypeBuilder::CSS::CSSMedia>::create(); | 667 medias = TypeBuilder::Array<TypeBuilder::CSS::CSSMedia>::create(); |
| 644 for (IdToInspectorStyleSheet::iterator it = m_idToInspectorStyleSheet.begin(
); it != m_idToInspectorStyleSheet.end(); ++it) { | 668 for (IdToInspectorStyleSheet::iterator it = m_idToInspectorStyleSheet.begin(
); it != m_idToInspectorStyleSheet.end(); ++it) { |
| 645 RefPtr<InspectorStyleSheet> styleSheet = it->value; | 669 RefPtrWillBeRawPtr<InspectorStyleSheet> styleSheet = it->value; |
| 646 collectMediaQueriesFromStyleSheet(styleSheet->pageStyleSheet(), medias.g
et()); | 670 collectMediaQueriesFromStyleSheet(styleSheet->pageStyleSheet(), medias.g
et()); |
| 647 const CSSRuleVector& flatRules = styleSheet->flatRules(); | 671 const CSSRuleVector& flatRules = styleSheet->flatRules(); |
| 648 for (unsigned i = 0; i < flatRules.size(); ++i) { | 672 for (unsigned i = 0; i < flatRules.size(); ++i) { |
| 649 CSSRule* rule = flatRules.at(i).get(); | 673 CSSRule* rule = flatRules.at(i).get(); |
| 650 if (rule->type() == CSSRule::MEDIA_RULE) | 674 if (rule->type() == CSSRule::MEDIA_RULE) |
| 651 collectMediaQueriesFromRule(rule, medias.get()); | 675 collectMediaQueriesFromRule(rule, medias.get()); |
| 652 } | 676 } |
| 653 } | 677 } |
| 654 } | 678 } |
| 655 | 679 |
| (...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1143 { | 1167 { |
| 1144 NodeToInspectorStyleSheet::iterator it = m_nodeToInspectorStyleSheet.find(el
ement); | 1168 NodeToInspectorStyleSheet::iterator it = m_nodeToInspectorStyleSheet.find(el
ement); |
| 1145 if (it != m_nodeToInspectorStyleSheet.end()) | 1169 if (it != m_nodeToInspectorStyleSheet.end()) |
| 1146 return it->value.get(); | 1170 return it->value.get(); |
| 1147 | 1171 |
| 1148 CSSStyleDeclaration* style = element->isStyledElement() ? element->style() :
0; | 1172 CSSStyleDeclaration* style = element->isStyledElement() ? element->style() :
0; |
| 1149 if (!style) | 1173 if (!style) |
| 1150 return 0; | 1174 return 0; |
| 1151 | 1175 |
| 1152 String newStyleSheetId = String::number(m_lastStyleSheetId++); | 1176 String newStyleSheetId = String::number(m_lastStyleSheetId++); |
| 1153 RefPtr<InspectorStyleSheetForInlineStyle> inspectorStyleSheet = InspectorSty
leSheetForInlineStyle::create(newStyleSheetId, element, this); | 1177 RefPtrWillBeRawPtr<InspectorStyleSheetForInlineStyle> inspectorStyleSheet =
InspectorStyleSheetForInlineStyle::create(newStyleSheetId, element, this); |
| 1154 m_idToInspectorStyleSheetForInlineStyle.set(newStyleSheetId, inspectorStyleS
heet); | 1178 m_idToInspectorStyleSheetForInlineStyle.set(newStyleSheetId, inspectorStyleS
heet); |
| 1155 m_nodeToInspectorStyleSheet.set(element, inspectorStyleSheet); | 1179 m_nodeToInspectorStyleSheet.set(element, inspectorStyleSheet); |
| 1156 return inspectorStyleSheet.get(); | 1180 return inspectorStyleSheet.get(); |
| 1157 } | 1181 } |
| 1158 | 1182 |
| 1159 Element* InspectorCSSAgent::elementForId(ErrorString* errorString, int nodeId) | 1183 Element* InspectorCSSAgent::elementForId(ErrorString* errorString, int nodeId) |
| 1160 { | 1184 { |
| 1161 Node* node = m_domAgent->nodeForId(nodeId); | 1185 Node* node = m_domAgent->nodeForId(nodeId); |
| 1162 if (!node) { | 1186 if (!node) { |
| 1163 *errorString = "No node with given id found"; | 1187 *errorString = "No node with given id found"; |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1197 if (rule->type() == CSSRule::IMPORT_RULE) { | 1221 if (rule->type() == CSSRule::IMPORT_RULE) { |
| 1198 CSSStyleSheet* importedStyleSheet = toCSSImportRule(rule)->styleShee
t(); | 1222 CSSStyleSheet* importedStyleSheet = toCSSImportRule(rule)->styleShee
t(); |
| 1199 if (importedStyleSheet) | 1223 if (importedStyleSheet) |
| 1200 collectStyleSheets(importedStyleSheet, result); | 1224 collectStyleSheets(importedStyleSheet, result); |
| 1201 } | 1225 } |
| 1202 } | 1226 } |
| 1203 } | 1227 } |
| 1204 | 1228 |
| 1205 InspectorStyleSheet* InspectorCSSAgent::bindStyleSheet(CSSStyleSheet* styleSheet
) | 1229 InspectorStyleSheet* InspectorCSSAgent::bindStyleSheet(CSSStyleSheet* styleSheet
) |
| 1206 { | 1230 { |
| 1207 RefPtr<InspectorStyleSheet> inspectorStyleSheet = m_cssStyleSheetToInspector
StyleSheet.get(styleSheet); | 1231 RefPtrWillBeRawPtr<InspectorStyleSheet> inspectorStyleSheet = m_cssStyleShee
tToInspectorStyleSheet.get(styleSheet); |
| 1208 if (!inspectorStyleSheet) { | 1232 if (!inspectorStyleSheet) { |
| 1209 String id = String::number(m_lastStyleSheetId++); | 1233 String id = String::number(m_lastStyleSheetId++); |
| 1210 Document* document = styleSheet->ownerDocument(); | 1234 Document* document = styleSheet->ownerDocument(); |
| 1211 inspectorStyleSheet = InspectorStyleSheet::create(m_pageAgent, m_resourc
eAgent, id, styleSheet, detectOrigin(styleSheet, document), InspectorDOMAgent::d
ocumentURLString(document), this); | 1235 inspectorStyleSheet = InspectorStyleSheet::create(m_pageAgent, m_resourc
eAgent, id, styleSheet, detectOrigin(styleSheet, document), InspectorDOMAgent::d
ocumentURLString(document), this); |
| 1212 m_idToInspectorStyleSheet.set(id, inspectorStyleSheet); | 1236 m_idToInspectorStyleSheet.set(id, inspectorStyleSheet); |
| 1213 m_cssStyleSheetToInspectorStyleSheet.set(styleSheet, inspectorStyleSheet
); | 1237 m_cssStyleSheetToInspectorStyleSheet.set(styleSheet, inspectorStyleSheet
); |
| 1214 if (m_creatingViaInspectorStyleSheet) | 1238 if (m_creatingViaInspectorStyleSheet) |
| 1215 m_documentToViaInspectorStyleSheet.add(document, inspectorStyleSheet
); | 1239 m_documentToViaInspectorStyleSheet.add(document, inspectorStyleSheet
); |
| 1216 } | 1240 } |
| 1217 return inspectorStyleSheet.get(); | 1241 return inspectorStyleSheet.get(); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1229 InspectorStyleSheet* InspectorCSSAgent::viaInspectorStyleSheet(Document* documen
t, bool createIfAbsent) | 1253 InspectorStyleSheet* InspectorCSSAgent::viaInspectorStyleSheet(Document* documen
t, bool createIfAbsent) |
| 1230 { | 1254 { |
| 1231 if (!document) { | 1255 if (!document) { |
| 1232 ASSERT(!createIfAbsent); | 1256 ASSERT(!createIfAbsent); |
| 1233 return 0; | 1257 return 0; |
| 1234 } | 1258 } |
| 1235 | 1259 |
| 1236 if (!document->isHTMLDocument() && !document->isSVGDocument()) | 1260 if (!document->isHTMLDocument() && !document->isSVGDocument()) |
| 1237 return 0; | 1261 return 0; |
| 1238 | 1262 |
| 1239 RefPtr<InspectorStyleSheet> inspectorStyleSheet = m_documentToViaInspectorSt
yleSheet.get(document); | 1263 RefPtrWillBeRawPtr<InspectorStyleSheet> inspectorStyleSheet = m_documentToVi
aInspectorStyleSheet.get(document); |
| 1240 if (inspectorStyleSheet || !createIfAbsent) | 1264 if (inspectorStyleSheet || !createIfAbsent) |
| 1241 return inspectorStyleSheet.get(); | 1265 return inspectorStyleSheet.get(); |
| 1242 | 1266 |
| 1243 TrackExceptionState exceptionState; | 1267 TrackExceptionState exceptionState; |
| 1244 RefPtrWillBeRawPtr<Element> styleElement = document->createElement("style",
exceptionState); | 1268 RefPtrWillBeRawPtr<Element> styleElement = document->createElement("style",
exceptionState); |
| 1245 if (!exceptionState.hadException()) | 1269 if (!exceptionState.hadException()) |
| 1246 styleElement->setAttribute("type", "text/css", exceptionState); | 1270 styleElement->setAttribute("type", "text/css", exceptionState); |
| 1247 if (!exceptionState.hadException()) { | 1271 if (!exceptionState.hadException()) { |
| 1248 ContainerNode* targetNode; | 1272 ContainerNode* targetNode; |
| 1249 // HEAD is absent in ImageDocuments, for example. | 1273 // HEAD is absent in ImageDocuments, for example. |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1451 m_nodeIdToForcedPseudoState.clear(); | 1475 m_nodeIdToForcedPseudoState.clear(); |
| 1452 for (WillBeHeapHashSet<RawPtrWillBeMember<Document> >::iterator it = documen
tsToChange.begin(), end = documentsToChange.end(); it != end; ++it) | 1476 for (WillBeHeapHashSet<RawPtrWillBeMember<Document> >::iterator it = documen
tsToChange.begin(), end = documentsToChange.end(); it != end; ++it) |
| 1453 (*it)->setNeedsStyleRecalc(SubtreeStyleChange); | 1477 (*it)->setNeedsStyleRecalc(SubtreeStyleChange); |
| 1454 } | 1478 } |
| 1455 | 1479 |
| 1456 void InspectorCSSAgent::trace(Visitor* visitor) | 1480 void InspectorCSSAgent::trace(Visitor* visitor) |
| 1457 { | 1481 { |
| 1458 visitor->trace(m_domAgent); | 1482 visitor->trace(m_domAgent); |
| 1459 visitor->trace(m_pageAgent); | 1483 visitor->trace(m_pageAgent); |
| 1460 visitor->trace(m_resourceAgent); | 1484 visitor->trace(m_resourceAgent); |
| 1485 visitor->trace(m_idToInspectorStyleSheet); |
| 1486 visitor->trace(m_idToInspectorStyleSheetForInlineStyle); |
| 1461 visitor->trace(m_cssStyleSheetToInspectorStyleSheet); | 1487 visitor->trace(m_cssStyleSheetToInspectorStyleSheet); |
| 1462 visitor->trace(m_documentToCSSStyleSheets); | 1488 visitor->trace(m_documentToCSSStyleSheets); |
| 1463 visitor->trace(m_invalidatedDocuments); | 1489 visitor->trace(m_invalidatedDocuments); |
| 1490 visitor->trace(m_nodeToInspectorStyleSheet); |
| 1464 visitor->trace(m_documentToViaInspectorStyleSheet); | 1491 visitor->trace(m_documentToViaInspectorStyleSheet); |
| 1465 visitor->trace(m_inspectorUserAgentStyleSheet); | 1492 visitor->trace(m_inspectorUserAgentStyleSheet); |
| 1466 InspectorBaseAgent::trace(visitor); | 1493 InspectorBaseAgent::trace(visitor); |
| 1467 } | 1494 } |
| 1468 | 1495 |
| 1469 } // namespace WebCore | 1496 } // namespace WebCore |
| 1470 | 1497 |
| OLD | NEW |