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 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 virtual bool redo(ExceptionState& exceptionState) OVERRIDE | 195 virtual bool redo(ExceptionState& exceptionState) OVERRIDE |
196 { | 196 { |
197 return m_styleSheet->setText(m_text, exceptionState); | 197 return m_styleSheet->setText(m_text, exceptionState); |
198 } | 198 } |
199 | 199 |
200 virtual String mergeId() OVERRIDE | 200 virtual String mergeId() OVERRIDE |
201 { | 201 { |
202 return String::format("SetStyleSheetText %s", m_styleSheet->id().utf8().
data()); | 202 return String::format("SetStyleSheetText %s", m_styleSheet->id().utf8().
data()); |
203 } | 203 } |
204 | 204 |
205 virtual void merge(PassRefPtr<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 26 matching lines...) Expand all Loading... |
251 return false; | 257 return false; |
252 bool result = m_styleSheet->setPropertyText(m_cssId, m_propertyIndex, m_
text, m_overwrite, exceptionState); | 258 bool result = m_styleSheet->setPropertyText(m_cssId, m_propertyIndex, m_
text, m_overwrite, exceptionState); |
253 return result; | 259 return result; |
254 } | 260 } |
255 | 261 |
256 virtual String mergeId() OVERRIDE | 262 virtual String mergeId() OVERRIDE |
257 { | 263 { |
258 return String::format("SetPropertyText %s:%u:%s", m_styleSheet->id().utf
8().data(), m_propertyIndex, m_overwrite ? "true" : "false"); | 264 return String::format("SetPropertyText %s:%u:%s", m_styleSheet->id().utf
8().data(), m_propertyIndex, m_overwrite ? "true" : "false"); |
259 } | 265 } |
260 | 266 |
261 virtual void merge(PassRefPtr<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 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
811 | 835 |
812 void InspectorCSSAgent::setStyleSheetText(ErrorString* errorString, const String
& styleSheetId, const String& text) | 836 void InspectorCSSAgent::setStyleSheetText(ErrorString* errorString, const String
& styleSheetId, const String& text) |
813 { | 837 { |
814 InspectorStyleSheetBase* inspectorStyleSheet = assertStyleSheetForId(errorSt
ring, styleSheetId); | 838 InspectorStyleSheetBase* inspectorStyleSheet = assertStyleSheetForId(errorSt
ring, styleSheetId); |
815 if (!inspectorStyleSheet) { | 839 if (!inspectorStyleSheet) { |
816 *errorString = "Style sheet with id " + styleSheetId + " not found"; | 840 *errorString = "Style sheet with id " + styleSheetId + " not found"; |
817 return; | 841 return; |
818 } | 842 } |
819 | 843 |
820 TrackExceptionState exceptionState; | 844 TrackExceptionState exceptionState; |
821 m_domAgent->history()->perform(adoptRef(new SetStyleSheetTextAction(inspecto
rStyleSheet, text)), exceptionState); | 845 m_domAgent->history()->perform(adoptRefWillBeNoop(new SetStyleSheetTextActio
n(inspectorStyleSheet, text)), exceptionState); |
822 *errorString = InspectorDOMAgent::toErrorString(exceptionState); | 846 *errorString = InspectorDOMAgent::toErrorString(exceptionState); |
823 } | 847 } |
824 | 848 |
825 static bool extractRangeComponent(ErrorString* errorString, const RefPtr<JSONObj
ect>& range, const String& component, unsigned& result) | 849 static bool extractRangeComponent(ErrorString* errorString, const RefPtr<JSONObj
ect>& range, const String& component, unsigned& result) |
826 { | 850 { |
827 int parsedValue; | 851 int parsedValue; |
828 if (!range->getNumber(component, &parsedValue) || parsedValue < 0) { | 852 if (!range->getNumber(component, &parsedValue) || parsedValue < 0) { |
829 *errorString = "range." + component + " must be a non-negative integer"; | 853 *errorString = "range." + component + " must be a non-negative integer"; |
830 return false; | 854 return false; |
831 } | 855 } |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
873 return; | 897 return; |
874 InspectorCSSId compoundId; | 898 InspectorCSSId compoundId; |
875 unsigned propertyIndex; | 899 unsigned propertyIndex; |
876 bool overwrite; | 900 bool overwrite; |
877 if (!inspectorStyleSheet->findPropertyByRange(propertyRange, &compoundId, &p
ropertyIndex, &overwrite)) { | 901 if (!inspectorStyleSheet->findPropertyByRange(propertyRange, &compoundId, &p
ropertyIndex, &overwrite)) { |
878 *errorString = "Source range didn't match any existing property source r
ange nor any property insertion point"; | 902 *errorString = "Source range didn't match any existing property source r
ange nor any property insertion point"; |
879 return; | 903 return; |
880 } | 904 } |
881 | 905 |
882 TrackExceptionState exceptionState; | 906 TrackExceptionState exceptionState; |
883 bool success = m_domAgent->history()->perform(adoptRef(new SetPropertyTextAc
tion(inspectorStyleSheet, compoundId, propertyIndex, text, overwrite)), exceptio
nState); | 907 bool success = m_domAgent->history()->perform(adoptRefWillBeNoop(new SetProp
ertyTextAction(inspectorStyleSheet, compoundId, propertyIndex, text, overwrite))
, exceptionState); |
884 if (success) | 908 if (success) |
885 result = inspectorStyleSheet->buildObjectForStyle(inspectorStyleSheet->s
tyleForId(compoundId)); | 909 result = inspectorStyleSheet->buildObjectForStyle(inspectorStyleSheet->s
tyleForId(compoundId)); |
886 *errorString = InspectorDOMAgent::toErrorString(exceptionState); | 910 *errorString = InspectorDOMAgent::toErrorString(exceptionState); |
887 } | 911 } |
888 | 912 |
889 void InspectorCSSAgent::setRuleSelector(ErrorString* errorString, const String&
styleSheetId, const RefPtr<JSONObject>& range, const String& selector, RefPtr<Ty
peBuilder::CSS::CSSRule>& result) | 913 void InspectorCSSAgent::setRuleSelector(ErrorString* errorString, const String&
styleSheetId, const RefPtr<JSONObject>& range, const String& selector, RefPtr<Ty
peBuilder::CSS::CSSRule>& result) |
890 { | 914 { |
891 InspectorStyleSheet* inspectorStyleSheet = assertInspectorStyleSheetForId(er
rorString, styleSheetId); | 915 InspectorStyleSheet* inspectorStyleSheet = assertInspectorStyleSheetForId(er
rorString, styleSheetId); |
892 if (!inspectorStyleSheet) | 916 if (!inspectorStyleSheet) |
893 return; | 917 return; |
894 SourceRange selectorRange; | 918 SourceRange selectorRange; |
895 if (!jsonRangeToSourceRange(errorString, inspectorStyleSheet, range, &select
orRange)) | 919 if (!jsonRangeToSourceRange(errorString, inspectorStyleSheet, range, &select
orRange)) |
896 return; | 920 return; |
897 InspectorCSSId compoundId; | 921 InspectorCSSId compoundId; |
898 if (!inspectorStyleSheet->findRuleBySelectorRange(selectorRange, &compoundId
)) { | 922 if (!inspectorStyleSheet->findRuleBySelectorRange(selectorRange, &compoundId
)) { |
899 *errorString = "Source range didn't match any rule selector source range
"; | 923 *errorString = "Source range didn't match any rule selector source range
"; |
900 return; | 924 return; |
901 } | 925 } |
902 | 926 |
903 TrackExceptionState exceptionState; | 927 TrackExceptionState exceptionState; |
904 bool success = m_domAgent->history()->perform(adoptRef(new SetRuleSelectorAc
tion(inspectorStyleSheet, compoundId, selector)), exceptionState); | 928 bool success = m_domAgent->history()->perform(adoptRefWillBeNoop(new SetRule
SelectorAction(inspectorStyleSheet, compoundId, selector)), exceptionState); |
905 if (success) { | 929 if (success) { |
906 CSSStyleRule* rule = inspectorStyleSheet->ruleForId(compoundId); | 930 CSSStyleRule* rule = inspectorStyleSheet->ruleForId(compoundId); |
907 result = inspectorStyleSheet->buildObjectForRule(rule, buildMediaListCha
in(rule)); | 931 result = inspectorStyleSheet->buildObjectForRule(rule, buildMediaListCha
in(rule)); |
908 } | 932 } |
909 *errorString = InspectorDOMAgent::toErrorString(exceptionState); | 933 *errorString = InspectorDOMAgent::toErrorString(exceptionState); |
910 } | 934 } |
911 | 935 |
912 void InspectorCSSAgent::createStyleSheet(ErrorString* errorString, const String&
frameId, TypeBuilder::CSS::StyleSheetId* outStyleSheetId) | 936 void InspectorCSSAgent::createStyleSheet(ErrorString* errorString, const String&
frameId, TypeBuilder::CSS::StyleSheetId* outStyleSheetId) |
913 { | 937 { |
914 LocalFrame* frame = m_pageAgent->frameForId(frameId); | 938 LocalFrame* frame = m_pageAgent->frameForId(frameId); |
(...skipping 19 matching lines...) Expand all Loading... |
934 *outStyleSheetId = inspectorStyleSheet->id(); | 958 *outStyleSheetId = inspectorStyleSheet->id(); |
935 } | 959 } |
936 | 960 |
937 void InspectorCSSAgent::addRule(ErrorString* errorString, const String& styleShe
etId, const String& selector, RefPtr<TypeBuilder::CSS::CSSRule>& result) | 961 void InspectorCSSAgent::addRule(ErrorString* errorString, const String& styleShe
etId, const String& selector, RefPtr<TypeBuilder::CSS::CSSRule>& result) |
938 { | 962 { |
939 InspectorStyleSheet* inspectorStyleSheet = assertInspectorStyleSheetForId(er
rorString, styleSheetId); | 963 InspectorStyleSheet* inspectorStyleSheet = assertInspectorStyleSheetForId(er
rorString, styleSheetId); |
940 if (!inspectorStyleSheet) | 964 if (!inspectorStyleSheet) |
941 return; | 965 return; |
942 | 966 |
943 TrackExceptionState exceptionState; | 967 TrackExceptionState exceptionState; |
944 RefPtr<AddRuleAction> action = adoptRef(new AddRuleAction(inspectorStyleShee
t, selector)); | 968 RefPtrWillBeRawPtr<AddRuleAction> action = adoptRefWillBeNoop(new AddRuleAct
ion(inspectorStyleSheet, selector)); |
945 bool success = m_domAgent->history()->perform(action, exceptionState); | 969 bool success = m_domAgent->history()->perform(action, exceptionState); |
946 if (!success) { | 970 if (!success) { |
947 *errorString = InspectorDOMAgent::toErrorString(exceptionState); | 971 *errorString = InspectorDOMAgent::toErrorString(exceptionState); |
948 return; | 972 return; |
949 } | 973 } |
950 | 974 |
951 InspectorCSSId ruleId = action->newRuleId(); | 975 InspectorCSSId ruleId = action->newRuleId(); |
952 CSSStyleRule* rule = inspectorStyleSheet->ruleForId(ruleId); | 976 CSSStyleRule* rule = inspectorStyleSheet->ruleForId(ruleId); |
953 result = inspectorStyleSheet->buildObjectForRule(rule, buildMediaListChain(r
ule)); | 977 result = inspectorStyleSheet->buildObjectForRule(rule, buildMediaListChain(r
ule)); |
954 } | 978 } |
(...skipping 128 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 |