Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(48)

Side by Side Diff: Source/core/inspector/InspectorCSSAgent.cpp

Issue 323043002: Oilpan: Prepare moving InspectorAgent related classes to oilpan (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/inspector/InspectorCSSAgent.h ('k') | Source/core/inspector/InspectorCanvasAgent.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 } 187 }
188 188
189 virtual void merge(PassRefPtrWillBeRawPtr<Action> action) OVERRIDE 189 virtual void merge(PassRefPtrWillBeRawPtr<Action> action) OVERRIDE
190 { 190 {
191 ASSERT(action->mergeId() == mergeId()); 191 ASSERT(action->mergeId() == mergeId());
192 192
193 SetStyleSheetTextAction* other = static_cast<SetStyleSheetTextAction*>(a ction.get()); 193 SetStyleSheetTextAction* other = static_cast<SetStyleSheetTextAction*>(a ction.get());
194 m_text = other->m_text; 194 m_text = other->m_text;
195 } 195 }
196 196
197 virtual void trace(Visitor* visitor) OVERRIDE
198 {
199 visitor->trace(m_styleSheet);
200 InspectorCSSAgent::StyleSheetAction::trace(visitor);
201 }
202
197 private: 203 private:
198 RefPtr<InspectorStyleSheetBase> m_styleSheet; 204 RefPtrWillBeMember<InspectorStyleSheetBase> m_styleSheet;
199 String m_text; 205 String m_text;
200 String m_oldText; 206 String m_oldText;
201 }; 207 };
202 208
203 class InspectorCSSAgent::SetPropertyTextAction FINAL : public InspectorCSSAgent: :StyleSheetAction { 209 class InspectorCSSAgent::SetPropertyTextAction FINAL : public InspectorCSSAgent: :StyleSheetAction {
204 WTF_MAKE_NONCOPYABLE(SetPropertyTextAction); 210 WTF_MAKE_NONCOPYABLE(SetPropertyTextAction);
205 public: 211 public:
206 SetPropertyTextAction(InspectorStyleSheetBase* styleSheet, const InspectorCS SId& cssId, unsigned propertyIndex, const String& text, bool overwrite) 212 SetPropertyTextAction(InspectorStyleSheetBase* styleSheet, const InspectorCS SId& cssId, unsigned propertyIndex, const String& text, bool overwrite)
207 : InspectorCSSAgent::StyleSheetAction("SetPropertyText") 213 : InspectorCSSAgent::StyleSheetAction("SetPropertyText")
208 , m_styleSheet(styleSheet) 214 , m_styleSheet(styleSheet)
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 } 249 }
244 250
245 virtual void merge(PassRefPtrWillBeRawPtr<Action> action) OVERRIDE 251 virtual void merge(PassRefPtrWillBeRawPtr<Action> action) OVERRIDE
246 { 252 {
247 ASSERT(action->mergeId() == mergeId()); 253 ASSERT(action->mergeId() == mergeId());
248 254
249 SetPropertyTextAction* other = static_cast<SetPropertyTextAction*>(actio n.get()); 255 SetPropertyTextAction* other = static_cast<SetPropertyTextAction*>(actio n.get());
250 m_text = other->m_text; 256 m_text = other->m_text;
251 } 257 }
252 258
259 virtual void trace(Visitor* visitor) OVERRIDE
260 {
261 visitor->trace(m_styleSheet);
262 InspectorCSSAgent::StyleSheetAction::trace(visitor);
263 }
264
253 private: 265 private:
254 RefPtr<InspectorStyleSheetBase> m_styleSheet; 266 RefPtrWillBeMember<InspectorStyleSheetBase> m_styleSheet;
255 InspectorCSSId m_cssId; 267 InspectorCSSId m_cssId;
256 unsigned m_propertyIndex; 268 unsigned m_propertyIndex;
257 String m_text; 269 String m_text;
258 String m_oldStyleText; 270 String m_oldStyleText;
259 bool m_overwrite; 271 bool m_overwrite;
260 }; 272 };
261 273
262 class InspectorCSSAgent::SetRuleSelectorAction FINAL : public InspectorCSSAgent: :StyleSheetAction { 274 class InspectorCSSAgent::SetRuleSelectorAction FINAL : public InspectorCSSAgent: :StyleSheetAction {
263 WTF_MAKE_NONCOPYABLE(SetRuleSelectorAction); 275 WTF_MAKE_NONCOPYABLE(SetRuleSelectorAction);
264 public: 276 public:
(...skipping 16 matching lines...) Expand all
281 virtual bool undo(ExceptionState& exceptionState) OVERRIDE 293 virtual bool undo(ExceptionState& exceptionState) OVERRIDE
282 { 294 {
283 return m_styleSheet->setRuleSelector(m_cssId, m_oldSelector, exceptionSt ate); 295 return m_styleSheet->setRuleSelector(m_cssId, m_oldSelector, exceptionSt ate);
284 } 296 }
285 297
286 virtual bool redo(ExceptionState& exceptionState) OVERRIDE 298 virtual bool redo(ExceptionState& exceptionState) OVERRIDE
287 { 299 {
288 return m_styleSheet->setRuleSelector(m_cssId, m_selector, exceptionState ); 300 return m_styleSheet->setRuleSelector(m_cssId, m_selector, exceptionState );
289 } 301 }
290 302
303 virtual void trace(Visitor* visitor) OVERRIDE
304 {
305 visitor->trace(m_styleSheet);
306 InspectorCSSAgent::StyleSheetAction::trace(visitor);
307 }
308
291 private: 309 private:
292 RefPtr<InspectorStyleSheet> m_styleSheet; 310 RefPtrWillBeMember<InspectorStyleSheet> m_styleSheet;
293 InspectorCSSId m_cssId; 311 InspectorCSSId m_cssId;
294 String m_selector; 312 String m_selector;
295 String m_oldSelector; 313 String m_oldSelector;
296 }; 314 };
297 315
298 class InspectorCSSAgent::AddRuleAction FINAL : public InspectorCSSAgent::StyleSh eetAction { 316 class InspectorCSSAgent::AddRuleAction FINAL : public InspectorCSSAgent::StyleSh eetAction {
299 WTF_MAKE_NONCOPYABLE(AddRuleAction); 317 WTF_MAKE_NONCOPYABLE(AddRuleAction);
300 public: 318 public:
301 AddRuleAction(InspectorStyleSheet* styleSheet, const String& selector) 319 AddRuleAction(InspectorStyleSheet* styleSheet, const String& selector)
302 : InspectorCSSAgent::StyleSheetAction("AddRule") 320 : InspectorCSSAgent::StyleSheetAction("AddRule")
(...skipping 16 matching lines...) Expand all
319 { 337 {
320 CSSStyleRule* cssStyleRule = m_styleSheet->addRule(m_selector, exception State); 338 CSSStyleRule* cssStyleRule = m_styleSheet->addRule(m_selector, exception State);
321 if (exceptionState.hadException()) 339 if (exceptionState.hadException())
322 return false; 340 return false;
323 m_newId = m_styleSheet->ruleId(cssStyleRule); 341 m_newId = m_styleSheet->ruleId(cssStyleRule);
324 return true; 342 return true;
325 } 343 }
326 344
327 InspectorCSSId newRuleId() { return m_newId; } 345 InspectorCSSId newRuleId() { return m_newId; }
328 346
347 virtual void trace(Visitor* visitor) OVERRIDE
348 {
349 visitor->trace(m_styleSheet);
350 InspectorCSSAgent::StyleSheetAction::trace(visitor);
351 }
352
329 private: 353 private:
330 RefPtr<InspectorStyleSheet> m_styleSheet; 354 RefPtrWillBeMember<InspectorStyleSheet> m_styleSheet;
331 InspectorCSSId m_newId; 355 InspectorCSSId m_newId;
332 String m_selector; 356 String m_selector;
333 String m_oldSelector; 357 String m_oldSelector;
334 }; 358 };
335 359
336 // static 360 // static
337 CSSStyleRule* InspectorCSSAgent::asCSSStyleRule(CSSRule* rule) 361 CSSStyleRule* InspectorCSSAgent::asCSSStyleRule(CSSRule* rule)
338 { 362 {
339 if (!rule || rule->type() != CSSRule::STYLE_RULE) 363 if (!rule || rule->type() != CSSRule::STYLE_RULE)
340 return 0; 364 return 0;
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
594 return forcedPseudoState & PseudoVisited; 618 return forcedPseudoState & PseudoVisited;
595 default: 619 default:
596 return false; 620 return false;
597 } 621 }
598 } 622 }
599 623
600 void InspectorCSSAgent::getMediaQueries(ErrorString* errorString, RefPtr<TypeBui lder::Array<TypeBuilder::CSS::CSSMedia> >& medias) 624 void InspectorCSSAgent::getMediaQueries(ErrorString* errorString, RefPtr<TypeBui lder::Array<TypeBuilder::CSS::CSSMedia> >& medias)
601 { 625 {
602 medias = TypeBuilder::Array<TypeBuilder::CSS::CSSMedia>::create(); 626 medias = TypeBuilder::Array<TypeBuilder::CSS::CSSMedia>::create();
603 for (IdToInspectorStyleSheet::iterator it = m_idToInspectorStyleSheet.begin( ); it != m_idToInspectorStyleSheet.end(); ++it) { 627 for (IdToInspectorStyleSheet::iterator it = m_idToInspectorStyleSheet.begin( ); it != m_idToInspectorStyleSheet.end(); ++it) {
604 RefPtr<InspectorStyleSheet> styleSheet = it->value; 628 RefPtrWillBeRawPtr<InspectorStyleSheet> styleSheet = it->value;
605 collectMediaQueriesFromStyleSheet(styleSheet->pageStyleSheet(), medias.g et()); 629 collectMediaQueriesFromStyleSheet(styleSheet->pageStyleSheet(), medias.g et());
606 const CSSRuleVector& flatRules = styleSheet->flatRules(); 630 const CSSRuleVector& flatRules = styleSheet->flatRules();
607 for (unsigned i = 0; i < flatRules.size(); ++i) { 631 for (unsigned i = 0; i < flatRules.size(); ++i) {
608 CSSRule* rule = flatRules.at(i).get(); 632 CSSRule* rule = flatRules.at(i).get();
609 if (rule->type() == CSSRule::MEDIA_RULE) 633 if (rule->type() == CSSRule::MEDIA_RULE)
610 collectMediaQueriesFromRule(rule, medias.get()); 634 collectMediaQueriesFromRule(rule, medias.get());
611 } 635 }
612 } 636 }
613 } 637 }
614 638
(...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after
1107 { 1131 {
1108 NodeToInspectorStyleSheet::iterator it = m_nodeToInspectorStyleSheet.find(el ement); 1132 NodeToInspectorStyleSheet::iterator it = m_nodeToInspectorStyleSheet.find(el ement);
1109 if (it != m_nodeToInspectorStyleSheet.end()) 1133 if (it != m_nodeToInspectorStyleSheet.end())
1110 return it->value.get(); 1134 return it->value.get();
1111 1135
1112 CSSStyleDeclaration* style = element->isStyledElement() ? element->style() : 0; 1136 CSSStyleDeclaration* style = element->isStyledElement() ? element->style() : 0;
1113 if (!style) 1137 if (!style)
1114 return 0; 1138 return 0;
1115 1139
1116 String newStyleSheetId = String::number(m_lastStyleSheetId++); 1140 String newStyleSheetId = String::number(m_lastStyleSheetId++);
1117 RefPtr<InspectorStyleSheetForInlineStyle> inspectorStyleSheet = InspectorSty leSheetForInlineStyle::create(newStyleSheetId, element, this); 1141 RefPtrWillBeRawPtr<InspectorStyleSheetForInlineStyle> inspectorStyleSheet = InspectorStyleSheetForInlineStyle::create(newStyleSheetId, element, this);
1118 m_idToInspectorStyleSheetForInlineStyle.set(newStyleSheetId, inspectorStyleS heet); 1142 m_idToInspectorStyleSheetForInlineStyle.set(newStyleSheetId, inspectorStyleS heet);
1119 m_nodeToInspectorStyleSheet.set(element, inspectorStyleSheet); 1143 m_nodeToInspectorStyleSheet.set(element, inspectorStyleSheet);
1120 return inspectorStyleSheet.get(); 1144 return inspectorStyleSheet.get();
1121 } 1145 }
1122 1146
1123 Element* InspectorCSSAgent::elementForId(ErrorString* errorString, int nodeId) 1147 Element* InspectorCSSAgent::elementForId(ErrorString* errorString, int nodeId)
1124 { 1148 {
1125 Node* node = m_domAgent->nodeForId(nodeId); 1149 Node* node = m_domAgent->nodeForId(nodeId);
1126 if (!node) { 1150 if (!node) {
1127 *errorString = "No node with given id found"; 1151 *errorString = "No node with given id found";
(...skipping 25 matching lines...) Expand all
1153 if (rule->type() == CSSRule::IMPORT_RULE) { 1177 if (rule->type() == CSSRule::IMPORT_RULE) {
1154 CSSStyleSheet* importedStyleSheet = toCSSImportRule(rule)->styleShee t(); 1178 CSSStyleSheet* importedStyleSheet = toCSSImportRule(rule)->styleShee t();
1155 if (importedStyleSheet) 1179 if (importedStyleSheet)
1156 InspectorCSSAgent::collectStyleSheets(importedStyleSheet, result ); 1180 InspectorCSSAgent::collectStyleSheets(importedStyleSheet, result );
1157 } 1181 }
1158 } 1182 }
1159 } 1183 }
1160 1184
1161 InspectorStyleSheet* InspectorCSSAgent::bindStyleSheet(CSSStyleSheet* styleSheet ) 1185 InspectorStyleSheet* InspectorCSSAgent::bindStyleSheet(CSSStyleSheet* styleSheet )
1162 { 1186 {
1163 RefPtr<InspectorStyleSheet> inspectorStyleSheet = m_cssStyleSheetToInspector StyleSheet.get(styleSheet); 1187 RefPtrWillBeRawPtr<InspectorStyleSheet> inspectorStyleSheet = m_cssStyleShee tToInspectorStyleSheet.get(styleSheet);
1164 if (!inspectorStyleSheet) { 1188 if (!inspectorStyleSheet) {
1165 String id = String::number(m_lastStyleSheetId++); 1189 String id = String::number(m_lastStyleSheetId++);
1166 Document* document = styleSheet->ownerDocument(); 1190 Document* document = styleSheet->ownerDocument();
1167 inspectorStyleSheet = InspectorStyleSheet::create(m_pageAgent, m_resourc eAgent, id, styleSheet, detectOrigin(styleSheet, document), InspectorDOMAgent::d ocumentURLString(document), this); 1191 inspectorStyleSheet = InspectorStyleSheet::create(m_pageAgent, m_resourc eAgent, id, styleSheet, detectOrigin(styleSheet, document), InspectorDOMAgent::d ocumentURLString(document), this);
1168 m_idToInspectorStyleSheet.set(id, inspectorStyleSheet); 1192 m_idToInspectorStyleSheet.set(id, inspectorStyleSheet);
1169 m_cssStyleSheetToInspectorStyleSheet.set(styleSheet, inspectorStyleSheet ); 1193 m_cssStyleSheetToInspectorStyleSheet.set(styleSheet, inspectorStyleSheet );
1170 if (m_creatingViaInspectorStyleSheet) 1194 if (m_creatingViaInspectorStyleSheet)
1171 m_documentToViaInspectorStyleSheet.add(document, inspectorStyleSheet ); 1195 m_documentToViaInspectorStyleSheet.add(document, inspectorStyleSheet );
1172 } 1196 }
1173 return inspectorStyleSheet.get(); 1197 return inspectorStyleSheet.get();
(...skipping 11 matching lines...) Expand all
1185 InspectorStyleSheet* InspectorCSSAgent::viaInspectorStyleSheet(Document* documen t, bool createIfAbsent) 1209 InspectorStyleSheet* InspectorCSSAgent::viaInspectorStyleSheet(Document* documen t, bool createIfAbsent)
1186 { 1210 {
1187 if (!document) { 1211 if (!document) {
1188 ASSERT(!createIfAbsent); 1212 ASSERT(!createIfAbsent);
1189 return 0; 1213 return 0;
1190 } 1214 }
1191 1215
1192 if (!document->isHTMLDocument() && !document->isSVGDocument()) 1216 if (!document->isHTMLDocument() && !document->isSVGDocument())
1193 return 0; 1217 return 0;
1194 1218
1195 RefPtr<InspectorStyleSheet> inspectorStyleSheet = m_documentToViaInspectorSt yleSheet.get(document); 1219 RefPtrWillBeRawPtr<InspectorStyleSheet> inspectorStyleSheet = m_documentToVi aInspectorStyleSheet.get(document);
1196 if (inspectorStyleSheet || !createIfAbsent) 1220 if (inspectorStyleSheet || !createIfAbsent)
1197 return inspectorStyleSheet.get(); 1221 return inspectorStyleSheet.get();
1198 1222
1199 TrackExceptionState exceptionState; 1223 TrackExceptionState exceptionState;
1200 RefPtrWillBeRawPtr<Element> styleElement = document->createElement("style", exceptionState); 1224 RefPtrWillBeRawPtr<Element> styleElement = document->createElement("style", exceptionState);
1201 if (!exceptionState.hadException()) 1225 if (!exceptionState.hadException())
1202 styleElement->setAttribute("type", "text/css", exceptionState); 1226 styleElement->setAttribute("type", "text/css", exceptionState);
1203 if (!exceptionState.hadException()) { 1227 if (!exceptionState.hadException()) {
1204 ContainerNode* targetNode; 1228 ContainerNode* targetNode;
1205 // HEAD is absent in ImageDocuments, for example. 1229 // HEAD is absent in ImageDocuments, for example.
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
1408 for (WillBeHeapHashSet<RawPtrWillBeMember<Document> >::iterator it = documen tsToChange.begin(), end = documentsToChange.end(); it != end; ++it) 1432 for (WillBeHeapHashSet<RawPtrWillBeMember<Document> >::iterator it = documen tsToChange.begin(), end = documentsToChange.end(); it != end; ++it)
1409 (*it)->setNeedsStyleRecalc(SubtreeStyleChange); 1433 (*it)->setNeedsStyleRecalc(SubtreeStyleChange);
1410 } 1434 }
1411 1435
1412 void InspectorCSSAgent::trace(Visitor* visitor) 1436 void InspectorCSSAgent::trace(Visitor* visitor)
1413 { 1437 {
1414 visitor->trace(m_domAgent); 1438 visitor->trace(m_domAgent);
1415 visitor->trace(m_pageAgent); 1439 visitor->trace(m_pageAgent);
1416 visitor->trace(m_resourceAgent); 1440 visitor->trace(m_resourceAgent);
1417 #if ENABLE(OILPAN) 1441 #if ENABLE(OILPAN)
1442 visitor->trace(m_idToInspectorStyleSheet);
1443 visitor->trace(m_idToInspectorStyleSheetForInlineStyle);
1418 visitor->trace(m_cssStyleSheetToInspectorStyleSheet); 1444 visitor->trace(m_cssStyleSheetToInspectorStyleSheet);
1419 visitor->trace(m_documentToCSSStyleSheets); 1445 visitor->trace(m_documentToCSSStyleSheets);
1420 visitor->trace(m_invalidatedDocuments); 1446 visitor->trace(m_invalidatedDocuments);
1447 visitor->trace(m_nodeToInspectorStyleSheet);
1421 visitor->trace(m_documentToViaInspectorStyleSheet); 1448 visitor->trace(m_documentToViaInspectorStyleSheet);
1422 #endif 1449 #endif
1423 visitor->trace(m_inspectorUserAgentStyleSheet); 1450 visitor->trace(m_inspectorUserAgentStyleSheet);
1424 InspectorBaseAgent::trace(visitor); 1451 InspectorBaseAgent::trace(visitor);
1425 } 1452 }
1426 1453
1427 } // namespace blink 1454 } // namespace blink
1428 1455
OLDNEW
« no previous file with comments | « Source/core/inspector/InspectorCSSAgent.h ('k') | Source/core/inspector/InspectorCanvasAgent.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698