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

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

Issue 307943002: Oilpan: Prepare moving InspectorController and InspectorAgents to oilpan. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 5 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 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 , m_styleSheetsPendingMutation(0) 350 , m_styleSheetsPendingMutation(0)
351 , m_styleDeclarationPendingMutation(false) 351 , m_styleDeclarationPendingMutation(false)
352 , m_creatingViaInspectorStyleSheet(false) 352 , m_creatingViaInspectorStyleSheet(false)
353 , m_isSettingStyleSheetText(false) 353 , m_isSettingStyleSheetText(false)
354 { 354 {
355 m_domAgent->setDOMListener(this); 355 m_domAgent->setDOMListener(this);
356 } 356 }
357 357
358 InspectorCSSAgent::~InspectorCSSAgent() 358 InspectorCSSAgent::~InspectorCSSAgent()
359 { 359 {
360 #if !ENABLE(OILPAN)
360 ASSERT(!m_domAgent); 361 ASSERT(!m_domAgent);
361 reset(); 362 reset();
363 #endif
362 } 364 }
363 365
364 void InspectorCSSAgent::setFrontend(InspectorFrontend* frontend) 366 void InspectorCSSAgent::setFrontend(InspectorFrontend* frontend)
365 { 367 {
366 ASSERT(!m_frontend); 368 ASSERT(!m_frontend);
367 m_frontend = frontend->css(); 369 m_frontend = frontend->css();
368 } 370 }
369 371
370 void InspectorCSSAgent::clearFrontend() 372 void InspectorCSSAgent::clearFrontend()
371 { 373 {
372 ASSERT(m_frontend); 374 ASSERT(m_frontend);
373 ErrorString error; 375 ErrorString error;
374 disable(&error); 376 disable(&error);
375 m_frontend = 0; 377 m_frontend = 0;
376 } 378 }
377 379
378 void InspectorCSSAgent::discardAgent() 380 void InspectorCSSAgent::discardAgent()
379 { 381 {
380 m_domAgent->setDOMListener(0); 382 m_domAgent->setDOMListener(0);
381 m_domAgent = 0; 383 m_domAgent = nullptr;
382 } 384 }
383 385
384 void InspectorCSSAgent::restore() 386 void InspectorCSSAgent::restore()
385 { 387 {
386 if (m_state->getBoolean(CSSAgentState::cssAgentEnabled)) 388 if (m_state->getBoolean(CSSAgentState::cssAgentEnabled))
387 wasEnabled(); 389 wasEnabled();
388 } 390 }
389 391
390 void InspectorCSSAgent::flushPendingFrontendMessages() 392 void InspectorCSSAgent::flushPendingFrontendMessages()
391 { 393 {
392 if (!m_invalidatedDocuments.size()) 394 if (!m_invalidatedDocuments.size())
393 return; 395 return;
394 HashSet<Document*> invalidatedDocuments; 396 WillBeHeapHashSet<RawPtrWillBeMember<Document> > invalidatedDocuments;
395 m_invalidatedDocuments.swap(&invalidatedDocuments); 397 m_invalidatedDocuments.swap(&invalidatedDocuments);
396 for (HashSet<Document*>::iterator it = invalidatedDocuments.begin(); it != i nvalidatedDocuments.end(); ++it) 398 for (WillBeHeapHashSet<RawPtrWillBeMember<Document> >::iterator it = invalid atedDocuments.begin(); it != invalidatedDocuments.end(); ++it)
397 updateActiveStyleSheets(*it, ExistingFrontendRefresh); 399 updateActiveStyleSheets(*it, ExistingFrontendRefresh);
398 } 400 }
399 401
400 void InspectorCSSAgent::reset() 402 void InspectorCSSAgent::reset()
401 { 403 {
402 m_idToInspectorStyleSheet.clear(); 404 m_idToInspectorStyleSheet.clear();
403 m_idToInspectorStyleSheetForInlineStyle.clear(); 405 m_idToInspectorStyleSheetForInlineStyle.clear();
404 m_cssStyleSheetToInspectorStyleSheet.clear(); 406 m_cssStyleSheetToInspectorStyleSheet.clear();
405 m_documentToCSSStyleSheets.clear(); 407 m_documentToCSSStyleSheets.clear();
406 m_invalidatedDocuments.clear(); 408 m_invalidatedDocuments.clear();
(...skipping 19 matching lines...) Expand all
426 } 428 }
427 429
428 void InspectorCSSAgent::wasEnabled() 430 void InspectorCSSAgent::wasEnabled()
429 { 431 {
430 if (!m_state->getBoolean(CSSAgentState::cssAgentEnabled)) { 432 if (!m_state->getBoolean(CSSAgentState::cssAgentEnabled)) {
431 // We were disabled while fetching resources. 433 // We were disabled while fetching resources.
432 return; 434 return;
433 } 435 }
434 436
435 m_instrumentingAgents->setInspectorCSSAgent(this); 437 m_instrumentingAgents->setInspectorCSSAgent(this);
436 Vector<Document*> documents = m_domAgent->documents(); 438 WillBeHeapVector<RawPtrWillBeMember<Document> > documents = m_domAgent->docu ments();
437 for (Vector<Document*>::iterator it = documents.begin(); it != documents.end (); ++it) 439 for (WillBeHeapVector<RawPtrWillBeMember<Document> >::iterator it = document s.begin(); it != documents.end(); ++it)
438 updateActiveStyleSheets(*it, InitialFrontendLoad); 440 updateActiveStyleSheets(*it, InitialFrontendLoad);
439 } 441 }
440 442
441 void InspectorCSSAgent::disable(ErrorString*) 443 void InspectorCSSAgent::disable(ErrorString*)
442 { 444 {
443 reset(); 445 reset();
444 m_instrumentingAgents->setInspectorCSSAgent(0); 446 m_instrumentingAgents->setInspectorCSSAgent(0);
445 m_state->setBoolean(CSSAgentState::cssAgentEnabled, false); 447 m_state->setBoolean(CSSAgentState::cssAgentEnabled, false);
446 } 448 }
447 449
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
496 if (styleSheetEditInProgress()) 498 if (styleSheetEditInProgress())
497 return; 499 return;
498 500
499 m_invalidatedDocuments.add(document); 501 m_invalidatedDocuments.add(document);
500 if (m_creatingViaInspectorStyleSheet) 502 if (m_creatingViaInspectorStyleSheet)
501 flushPendingFrontendMessages(); 503 flushPendingFrontendMessages();
502 } 504 }
503 505
504 void InspectorCSSAgent::updateActiveStyleSheets(Document* document, StyleSheetsU pdateType styleSheetsUpdateType) 506 void InspectorCSSAgent::updateActiveStyleSheets(Document* document, StyleSheetsU pdateType styleSheetsUpdateType)
505 { 507 {
506 Vector<CSSStyleSheet*> newSheetsVector; 508 WillBeHeapVector<RawPtrWillBeMember<CSSStyleSheet> > newSheetsVector;
507 InspectorCSSAgent::collectAllDocumentStyleSheets(document, newSheetsVector); 509 InspectorCSSAgent::collectAllDocumentStyleSheets(document, newSheetsVector);
508 setActiveStyleSheets(document, newSheetsVector, styleSheetsUpdateType); 510 setActiveStyleSheets(document, newSheetsVector, styleSheetsUpdateType);
509 } 511 }
510 512
511 void InspectorCSSAgent::setActiveStyleSheets(Document* document, const Vector<CS SStyleSheet*>& allSheetsVector, StyleSheetsUpdateType styleSheetsUpdateType) 513 void InspectorCSSAgent::setActiveStyleSheets(Document* document, const WillBeHea pVector<RawPtrWillBeMember<CSSStyleSheet> >& allSheetsVector, StyleSheetsUpdateT ype styleSheetsUpdateType)
512 { 514 {
513 bool isInitialFrontendLoad = styleSheetsUpdateType == InitialFrontendLoad; 515 bool isInitialFrontendLoad = styleSheetsUpdateType == InitialFrontendLoad;
514 516
515 HashSet<CSSStyleSheet*>* documentCSSStyleSheets = m_documentToCSSStyleSheets .get(document); 517 WillBeHeapHashSet<RawPtrWillBeMember<CSSStyleSheet> >* documentCSSStyleSheet s = m_documentToCSSStyleSheets.get(document);
516 if (!documentCSSStyleSheets) { 518 if (!documentCSSStyleSheets) {
517 documentCSSStyleSheets = new HashSet<CSSStyleSheet*>(); 519 documentCSSStyleSheets = new WillBeHeapHashSet<RawPtrWillBeMember<CSSSty leSheet> >();
518 OwnPtr<HashSet<CSSStyleSheet*> > documentCSSStyleSheetsPtr = adoptPtr(do cumentCSSStyleSheets); 520 OwnPtrWillBeRawPtr<WillBeHeapHashSet<RawPtrWillBeMember<CSSStyleSheet> > > documentCSSStyleSheetsPtr = adoptPtrWillBeNoop(documentCSSStyleSheets);
519 m_documentToCSSStyleSheets.set(document, documentCSSStyleSheetsPtr.relea se()); 521 m_documentToCSSStyleSheets.set(document, documentCSSStyleSheetsPtr.relea se());
520 } 522 }
521 523
522 HashSet<CSSStyleSheet*> removedSheets(*documentCSSStyleSheets); 524 WillBeHeapHashSet<RawPtrWillBeMember<CSSStyleSheet> > removedSheets(*documen tCSSStyleSheets);
523 Vector<CSSStyleSheet*> addedSheets; 525 WillBeHeapVector<RawPtrWillBeMember<CSSStyleSheet> > addedSheets;
524 for (Vector<CSSStyleSheet*>::const_iterator it = allSheetsVector.begin(); it != allSheetsVector.end(); ++it) { 526 for (WillBeHeapVector<RawPtrWillBeMember<CSSStyleSheet> >::const_iterator it = allSheetsVector.begin(); it != allSheetsVector.end(); ++it) {
525 CSSStyleSheet* cssStyleSheet = *it; 527 CSSStyleSheet* cssStyleSheet = *it;
526 if (removedSheets.contains(cssStyleSheet)) { 528 if (removedSheets.contains(cssStyleSheet)) {
527 removedSheets.remove(cssStyleSheet); 529 removedSheets.remove(cssStyleSheet);
528 if (isInitialFrontendLoad) 530 if (isInitialFrontendLoad)
529 addedSheets.append(cssStyleSheet); 531 addedSheets.append(cssStyleSheet);
530 } else { 532 } else {
531 addedSheets.append(cssStyleSheet); 533 addedSheets.append(cssStyleSheet);
532 } 534 }
533 } 535 }
534 536
535 for (HashSet<CSSStyleSheet*>::iterator it = removedSheets.begin(); it != rem ovedSheets.end(); ++it) { 537 for (WillBeHeapHashSet<RawPtrWillBeMember<CSSStyleSheet> >::iterator it = re movedSheets.begin(); it != removedSheets.end(); ++it) {
536 CSSStyleSheet* cssStyleSheet = *it; 538 CSSStyleSheet* cssStyleSheet = *it;
537 RefPtr<InspectorStyleSheet> inspectorStyleSheet = m_cssStyleSheetToInspe ctorStyleSheet.get(cssStyleSheet); 539 RefPtrWillBeRawPtr<InspectorStyleSheet> inspectorStyleSheet = m_cssStyle SheetToInspectorStyleSheet.get(cssStyleSheet);
538 ASSERT(inspectorStyleSheet); 540 ASSERT(inspectorStyleSheet);
539 541
540 documentCSSStyleSheets->remove(cssStyleSheet); 542 documentCSSStyleSheets->remove(cssStyleSheet);
541 if (m_idToInspectorStyleSheet.contains(inspectorStyleSheet->id())) { 543 if (m_idToInspectorStyleSheet.contains(inspectorStyleSheet->id())) {
542 String id = unbindStyleSheet(inspectorStyleSheet.get()); 544 String id = unbindStyleSheet(inspectorStyleSheet.get());
543 if (m_frontend && !isInitialFrontendLoad) 545 if (m_frontend && !isInitialFrontendLoad)
544 m_frontend->styleSheetRemoved(id); 546 m_frontend->styleSheetRemoved(id);
545 } 547 }
546 } 548 }
547 549
548 for (Vector<CSSStyleSheet*>::iterator it = addedSheets.begin(); it != addedS heets.end(); ++it) { 550 for (WillBeHeapVector<RawPtrWillBeMember<CSSStyleSheet> >::iterator it = add edSheets.begin(); it != addedSheets.end(); ++it) {
549 CSSStyleSheet* cssStyleSheet = *it; 551 CSSStyleSheet* cssStyleSheet = *it;
550 bool isNew = isInitialFrontendLoad || !m_cssStyleSheetToInspectorStyleSh eet.contains(cssStyleSheet); 552 bool isNew = isInitialFrontendLoad || !m_cssStyleSheetToInspectorStyleSh eet.contains(cssStyleSheet);
551 if (isNew) { 553 if (isNew) {
552 InspectorStyleSheet* newStyleSheet = bindStyleSheet(cssStyleSheet); 554 InspectorStyleSheet* newStyleSheet = bindStyleSheet(cssStyleSheet);
553 documentCSSStyleSheets->add(cssStyleSheet); 555 documentCSSStyleSheets->add(cssStyleSheet);
554 if (m_frontend) 556 if (m_frontend)
555 m_frontend->styleSheetAdded(newStyleSheet->buildObjectForStyleSh eetInfo()); 557 m_frontend->styleSheetAdded(newStyleSheet->buildObjectForStyleSh eetInfo());
556 } 558 }
557 } 559 }
558 560
559 if (documentCSSStyleSheets->isEmpty()) 561 if (documentCSSStyleSheets->isEmpty())
560 m_documentToCSSStyleSheets.remove(document); 562 m_documentToCSSStyleSheets.remove(document);
561 } 563 }
562 564
563 void InspectorCSSAgent::documentDetached(Document* document) 565 void InspectorCSSAgent::documentDetached(Document* document)
564 { 566 {
565 m_invalidatedDocuments.remove(document); 567 m_invalidatedDocuments.remove(document);
566 setActiveStyleSheets(document, Vector<CSSStyleSheet*>(), ExistingFrontendRef resh); 568 setActiveStyleSheets(document, WillBeHeapVector<RawPtrWillBeMember<CSSStyleS heet> >(), ExistingFrontendRefresh);
567 } 569 }
568 570
569 bool InspectorCSSAgent::forcePseudoState(Element* element, CSSSelector::PseudoTy pe pseudoType) 571 bool InspectorCSSAgent::forcePseudoState(Element* element, CSSSelector::PseudoTy pe pseudoType)
570 { 572 {
571 if (m_nodeIdToForcedPseudoState.isEmpty()) 573 if (m_nodeIdToForcedPseudoState.isEmpty())
572 return false; 574 return false;
573 575
574 int nodeId = m_domAgent->boundNodeId(element); 576 int nodeId = m_domAgent->boundNodeId(element);
575 if (!nodeId) 577 if (!nodeId)
576 return false; 578 return false;
(...skipping 548 matching lines...) Expand 10 before | Expand all | Expand 10 after
1125 return 0; 1127 return 0;
1126 } 1128 }
1127 if (!node->isElementNode()) { 1129 if (!node->isElementNode()) {
1128 *errorString = "Not an element node"; 1130 *errorString = "Not an element node";
1129 return 0; 1131 return 0;
1130 } 1132 }
1131 return toElement(node); 1133 return toElement(node);
1132 } 1134 }
1133 1135
1134 // static 1136 // static
1135 void InspectorCSSAgent::collectAllDocumentStyleSheets(Document* document, Vector <CSSStyleSheet*>& result) 1137 void InspectorCSSAgent::collectAllDocumentStyleSheets(Document* document, WillBe HeapVector<RawPtrWillBeMember<CSSStyleSheet> >& result)
1136 { 1138 {
1137 const WillBeHeapVector<RefPtrWillBeMember<CSSStyleSheet> > activeStyleSheets = document->styleEngine()->activeStyleSheetsForInspector(); 1139 const WillBeHeapVector<RefPtrWillBeMember<CSSStyleSheet> > activeStyleSheets = document->styleEngine()->activeStyleSheetsForInspector();
1138 for (WillBeHeapVector<RefPtrWillBeMember<CSSStyleSheet> >::const_iterator it = activeStyleSheets.begin(); it != activeStyleSheets.end(); ++it) { 1140 for (WillBeHeapVector<RefPtrWillBeMember<CSSStyleSheet> >::const_iterator it = activeStyleSheets.begin(); it != activeStyleSheets.end(); ++it) {
1139 CSSStyleSheet* styleSheet = it->get(); 1141 CSSStyleSheet* styleSheet = it->get();
1140 InspectorCSSAgent::collectStyleSheets(styleSheet, result); 1142 InspectorCSSAgent::collectStyleSheets(styleSheet, result);
1141 } 1143 }
1142 } 1144 }
1143 1145
1144 // static 1146 // static
1145 void InspectorCSSAgent::collectStyleSheets(CSSStyleSheet* styleSheet, Vector<CSS StyleSheet*>& result) 1147 void InspectorCSSAgent::collectStyleSheets(CSSStyleSheet* styleSheet, WillBeHeap Vector<RawPtrWillBeMember<CSSStyleSheet> >& result)
1146 { 1148 {
1147 result.append(styleSheet); 1149 result.append(styleSheet);
1148 for (unsigned i = 0, size = styleSheet->length(); i < size; ++i) { 1150 for (unsigned i = 0, size = styleSheet->length(); i < size; ++i) {
1149 CSSRule* rule = styleSheet->item(i); 1151 CSSRule* rule = styleSheet->item(i);
1150 if (rule->type() == CSSRule::IMPORT_RULE) { 1152 if (rule->type() == CSSRule::IMPORT_RULE) {
1151 CSSStyleSheet* importedStyleSheet = toCSSImportRule(rule)->styleShee t(); 1153 CSSStyleSheet* importedStyleSheet = toCSSImportRule(rule)->styleShee t();
1152 if (importedStyleSheet) 1154 if (importedStyleSheet)
1153 InspectorCSSAgent::collectStyleSheets(importedStyleSheet, result ); 1155 InspectorCSSAgent::collectStyleSheets(importedStyleSheet, result );
1154 } 1156 }
1155 } 1157 }
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
1387 } 1389 }
1388 1390
1389 void InspectorCSSAgent::didReparseStyleSheet() 1391 void InspectorCSSAgent::didReparseStyleSheet()
1390 { 1392 {
1391 ASSERT(m_isSettingStyleSheetText); 1393 ASSERT(m_isSettingStyleSheetText);
1392 m_isSettingStyleSheetText = false; 1394 m_isSettingStyleSheetText = false;
1393 } 1395 }
1394 1396
1395 void InspectorCSSAgent::resetPseudoStates() 1397 void InspectorCSSAgent::resetPseudoStates()
1396 { 1398 {
1397 HashSet<Document*> documentsToChange; 1399 WillBeHeapHashSet<RawPtrWillBeMember<Document> > documentsToChange;
1398 for (NodeIdToForcedPseudoState::iterator it = m_nodeIdToForcedPseudoState.be gin(), end = m_nodeIdToForcedPseudoState.end(); it != end; ++it) { 1400 for (NodeIdToForcedPseudoState::iterator it = m_nodeIdToForcedPseudoState.be gin(), end = m_nodeIdToForcedPseudoState.end(); it != end; ++it) {
1399 Element* element = toElement(m_domAgent->nodeForId(it->key)); 1401 Element* element = toElement(m_domAgent->nodeForId(it->key));
1400 if (element && element->ownerDocument()) 1402 if (element && element->ownerDocument())
1401 documentsToChange.add(element->ownerDocument()); 1403 documentsToChange.add(element->ownerDocument());
1402 } 1404 }
1403 1405
1404 m_nodeIdToForcedPseudoState.clear(); 1406 m_nodeIdToForcedPseudoState.clear();
1405 for (HashSet<Document*>::iterator it = documentsToChange.begin(), end = docu mentsToChange.end(); it != end; ++it) 1407 for (WillBeHeapHashSet<RawPtrWillBeMember<Document> >::iterator it = documen tsToChange.begin(), end = documentsToChange.end(); it != end; ++it)
1406 (*it)->setNeedsStyleRecalc(SubtreeStyleChange); 1408 (*it)->setNeedsStyleRecalc(SubtreeStyleChange);
1407 } 1409 }
1408 1410
1411 void InspectorCSSAgent::trace(Visitor* visitor)
1412 {
1413 visitor->trace(m_domAgent);
1414 visitor->trace(m_pageAgent);
1415 visitor->trace(m_resourceAgent);
1416 #if ENABLE(OILPAN)
1417 visitor->trace(m_cssStyleSheetToInspectorStyleSheet);
1418 visitor->trace(m_documentToCSSStyleSheets);
1419 visitor->trace(m_invalidatedDocuments);
1420 visitor->trace(m_documentToViaInspectorStyleSheet);
1421 #endif
1422 visitor->trace(m_inspectorUserAgentStyleSheet);
1423 InspectorBaseAgent::trace(visitor);
1424 }
1425
1409 } // namespace blink 1426 } // namespace blink
1410 1427
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