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

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

Powered by Google App Engine
This is Rietveld 408576698