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

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: Fixed 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 355 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 , m_styleSheetsPendingMutation(0) 366 , m_styleSheetsPendingMutation(0)
367 , m_styleDeclarationPendingMutation(false) 367 , m_styleDeclarationPendingMutation(false)
368 , m_creatingViaInspectorStyleSheet(false) 368 , m_creatingViaInspectorStyleSheet(false)
369 , m_isSettingStyleSheetText(false) 369 , m_isSettingStyleSheetText(false)
370 { 370 {
371 m_domAgent->setDOMListener(this); 371 m_domAgent->setDOMListener(this);
372 } 372 }
373 373
374 InspectorCSSAgent::~InspectorCSSAgent() 374 InspectorCSSAgent::~InspectorCSSAgent()
375 { 375 {
376 #if !ENABLE(OILPAN)
376 ASSERT(!m_domAgent); 377 ASSERT(!m_domAgent);
377 reset(); 378 reset();
379 #endif
378 } 380 }
379 381
380 void InspectorCSSAgent::setFrontend(InspectorFrontend* frontend) 382 void InspectorCSSAgent::setFrontend(InspectorFrontend* frontend)
381 { 383 {
382 ASSERT(!m_frontend); 384 ASSERT(!m_frontend);
383 m_frontend = frontend->css(); 385 m_frontend = frontend->css();
384 } 386 }
385 387
386 void InspectorCSSAgent::clearFrontend() 388 void InspectorCSSAgent::clearFrontend()
387 { 389 {
388 ASSERT(m_frontend); 390 ASSERT(m_frontend);
389 ErrorString error; 391 ErrorString error;
390 disable(&error); 392 disable(&error);
391 m_frontend = 0; 393 m_frontend = 0;
392 resetNonPersistentData(); 394 resetNonPersistentData();
393 } 395 }
394 396
395 void InspectorCSSAgent::discardAgent() 397 void InspectorCSSAgent::discardAgent()
396 { 398 {
397 m_domAgent->setDOMListener(0); 399 m_domAgent->setDOMListener(0);
398 m_domAgent = 0; 400 m_domAgent = nullptr;
399 } 401 }
400 402
401 void InspectorCSSAgent::restore() 403 void InspectorCSSAgent::restore()
402 { 404 {
403 if (m_state->getBoolean(CSSAgentState::cssAgentEnabled)) 405 if (m_state->getBoolean(CSSAgentState::cssAgentEnabled))
404 wasEnabled(nullptr); 406 wasEnabled(nullptr);
405 } 407 }
406 408
407 void InspectorCSSAgent::flushPendingFrontendMessages() 409 void InspectorCSSAgent::flushPendingFrontendMessages()
408 { 410 {
409 if (!m_invalidatedDocuments.size()) 411 if (!m_invalidatedDocuments.size())
410 return; 412 return;
411 HashSet<Document*> invalidatedDocuments; 413 WillBeHeapHashSet<RawPtrWillBeMember<Document> > invalidatedDocuments;
412 m_invalidatedDocuments.swap(&invalidatedDocuments); 414 m_invalidatedDocuments.swap(&invalidatedDocuments);
413 for (HashSet<Document*>::iterator it = invalidatedDocuments.begin(); it != i nvalidatedDocuments.end(); ++it) 415 for (WillBeHeapHashSet<RawPtrWillBeMember<Document> >::iterator it = invalid atedDocuments.begin(); it != invalidatedDocuments.end(); ++it)
414 updateActiveStyleSheets(*it, ExistingFrontendRefresh); 416 updateActiveStyleSheets(*it, ExistingFrontendRefresh);
415 } 417 }
416 418
417 void InspectorCSSAgent::reset() 419 void InspectorCSSAgent::reset()
418 { 420 {
419 m_idToInspectorStyleSheet.clear(); 421 m_idToInspectorStyleSheet.clear();
420 m_idToInspectorStyleSheetForInlineStyle.clear(); 422 m_idToInspectorStyleSheetForInlineStyle.clear();
421 m_cssStyleSheetToInspectorStyleSheet.clear(); 423 m_cssStyleSheetToInspectorStyleSheet.clear();
422 m_documentToCSSStyleSheets.clear(); 424 m_documentToCSSStyleSheets.clear();
423 m_invalidatedDocuments.clear(); 425 m_invalidatedDocuments.clear();
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
467 } 469 }
468 470
469 void InspectorCSSAgent::wasEnabled(PassRefPtr<EnableCallback> callback) 471 void InspectorCSSAgent::wasEnabled(PassRefPtr<EnableCallback> callback)
470 { 472 {
471 if (!m_state->getBoolean(CSSAgentState::cssAgentEnabled)) { 473 if (!m_state->getBoolean(CSSAgentState::cssAgentEnabled)) {
472 // We were disabled while fetching resources. 474 // We were disabled while fetching resources.
473 return; 475 return;
474 } 476 }
475 477
476 m_instrumentingAgents->setInspectorCSSAgent(this); 478 m_instrumentingAgents->setInspectorCSSAgent(this);
477 Vector<Document*> documents = m_domAgent->documents(); 479 WillBeHeapVector<RawPtrWillBeMember<Document> > documents = m_domAgent->docu ments();
478 for (Vector<Document*>::iterator it = documents.begin(); it != documents.end (); ++it) 480 for (WillBeHeapVector<RawPtrWillBeMember<Document> >::iterator it = document s.begin(); it != documents.end(); ++it)
479 updateActiveStyleSheets(*it, InitialFrontendLoad); 481 updateActiveStyleSheets(*it, InitialFrontendLoad);
480 482
481 if (callback) 483 if (callback)
482 callback->sendSuccess(); 484 callback->sendSuccess();
483 } 485 }
484 486
485 void InspectorCSSAgent::disable(ErrorString*) 487 void InspectorCSSAgent::disable(ErrorString*)
486 { 488 {
487 reset(); 489 reset();
488 m_instrumentingAgents->setInspectorCSSAgent(0); 490 m_instrumentingAgents->setInspectorCSSAgent(0);
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
538 { 540 {
539 if (styleSheetEditInProgress()) 541 if (styleSheetEditInProgress())
540 return; 542 return;
541 m_invalidatedDocuments.add(document); 543 m_invalidatedDocuments.add(document);
542 if (m_creatingViaInspectorStyleSheet) 544 if (m_creatingViaInspectorStyleSheet)
543 flushPendingFrontendMessages(); 545 flushPendingFrontendMessages();
544 } 546 }
545 547
546 void InspectorCSSAgent::updateActiveStyleSheets(Document* document, StyleSheetsU pdateType styleSheetsUpdateType) 548 void InspectorCSSAgent::updateActiveStyleSheets(Document* document, StyleSheetsU pdateType styleSheetsUpdateType)
547 { 549 {
548 Vector<CSSStyleSheet*> newSheetsVector; 550 WillBeHeapVector<RawPtrWillBeMember<CSSStyleSheet> > newSheetsVector;
549 collectAllDocumentStyleSheets(document, newSheetsVector); 551 collectAllDocumentStyleSheets(document, newSheetsVector);
550 setActiveStyleSheets(document, newSheetsVector, styleSheetsUpdateType); 552 setActiveStyleSheets(document, newSheetsVector, styleSheetsUpdateType);
551 } 553 }
552 554
553 void InspectorCSSAgent::setActiveStyleSheets(Document* document, const Vector<CS SStyleSheet*>& allSheetsVector, StyleSheetsUpdateType styleSheetsUpdateType) 555 void InspectorCSSAgent::setActiveStyleSheets(Document* document, const WillBeHea pVector<RawPtrWillBeMember<CSSStyleSheet> >& allSheetsVector, StyleSheetsUpdateT ype styleSheetsUpdateType)
554 { 556 {
555 bool isInitialFrontendLoad = styleSheetsUpdateType == InitialFrontendLoad; 557 bool isInitialFrontendLoad = styleSheetsUpdateType == InitialFrontendLoad;
556 558
557 HashSet<CSSStyleSheet*>* documentCSSStyleSheets = m_documentToCSSStyleSheets .get(document); 559 WillBeHeapHashSet<RawPtrWillBeMember<CSSStyleSheet> >* documentCSSStyleSheet s = m_documentToCSSStyleSheets.get(document);
558 if (!documentCSSStyleSheets) { 560 if (!documentCSSStyleSheets) {
559 documentCSSStyleSheets = new HashSet<CSSStyleSheet*>(); 561 documentCSSStyleSheets = new WillBeHeapHashSet<RawPtrWillBeMember<CSSSty leSheet> >();
560 OwnPtr<HashSet<CSSStyleSheet*> > documentCSSStyleSheetsPtr = adoptPtr(do cumentCSSStyleSheets); 562 OwnPtrWillBeRawPtr<WillBeHeapHashSet<RawPtrWillBeMember<CSSStyleSheet> > > documentCSSStyleSheetsPtr = adoptPtrWillBeNoop(documentCSSStyleSheets);
561 m_documentToCSSStyleSheets.set(document, documentCSSStyleSheetsPtr.relea se()); 563 m_documentToCSSStyleSheets.set(document, documentCSSStyleSheetsPtr.relea se());
562 } 564 }
563 565
564 HashSet<CSSStyleSheet*> removedSheets(*documentCSSStyleSheets); 566 WillBeHeapHashSet<RawPtrWillBeMember<CSSStyleSheet> > removedSheets(*documen tCSSStyleSheets);
565 Vector<CSSStyleSheet*> addedSheets; 567 WillBeHeapVector<RawPtrWillBeMember<CSSStyleSheet> > addedSheets;
566 for (Vector<CSSStyleSheet*>::const_iterator it = allSheetsVector.begin(); it != allSheetsVector.end(); ++it) { 568 for (WillBeHeapVector<RawPtrWillBeMember<CSSStyleSheet> >::const_iterator it = allSheetsVector.begin(); it != allSheetsVector.end(); ++it) {
567 CSSStyleSheet* cssStyleSheet = *it; 569 CSSStyleSheet* cssStyleSheet = *it;
568 if (removedSheets.contains(cssStyleSheet)) { 570 if (removedSheets.contains(cssStyleSheet)) {
569 removedSheets.remove(cssStyleSheet); 571 removedSheets.remove(cssStyleSheet);
570 if (isInitialFrontendLoad) 572 if (isInitialFrontendLoad)
571 addedSheets.append(cssStyleSheet); 573 addedSheets.append(cssStyleSheet);
572 } else { 574 } else {
573 addedSheets.append(cssStyleSheet); 575 addedSheets.append(cssStyleSheet);
574 } 576 }
575 } 577 }
576 578
577 for (HashSet<CSSStyleSheet*>::iterator it = removedSheets.begin(); it != rem ovedSheets.end(); ++it) { 579 for (WillBeHeapHashSet<RawPtrWillBeMember<CSSStyleSheet> >::iterator it = re movedSheets.begin(); it != removedSheets.end(); ++it) {
578 CSSStyleSheet* cssStyleSheet = *it; 580 CSSStyleSheet* cssStyleSheet = *it;
579 RefPtr<InspectorStyleSheet> inspectorStyleSheet = m_cssStyleSheetToInspe ctorStyleSheet.get(cssStyleSheet); 581 RefPtrWillBeRawPtr<InspectorStyleSheet> inspectorStyleSheet = m_cssStyle SheetToInspectorStyleSheet.get(cssStyleSheet);
580 ASSERT(inspectorStyleSheet); 582 ASSERT(inspectorStyleSheet);
581 583
582 documentCSSStyleSheets->remove(cssStyleSheet); 584 documentCSSStyleSheets->remove(cssStyleSheet);
583 if (m_idToInspectorStyleSheet.contains(inspectorStyleSheet->id())) { 585 if (m_idToInspectorStyleSheet.contains(inspectorStyleSheet->id())) {
584 String id = unbindStyleSheet(inspectorStyleSheet.get()); 586 String id = unbindStyleSheet(inspectorStyleSheet.get());
585 if (m_frontend && !isInitialFrontendLoad) 587 if (m_frontend && !isInitialFrontendLoad)
586 m_frontend->styleSheetRemoved(id); 588 m_frontend->styleSheetRemoved(id);
587 } 589 }
588 } 590 }
589 591
590 for (Vector<CSSStyleSheet*>::iterator it = addedSheets.begin(); it != addedS heets.end(); ++it) { 592 for (WillBeHeapVector<RawPtrWillBeMember<CSSStyleSheet> >::iterator it = add edSheets.begin(); it != addedSheets.end(); ++it) {
591 CSSStyleSheet* cssStyleSheet = *it; 593 CSSStyleSheet* cssStyleSheet = *it;
592 bool isNew = isInitialFrontendLoad || !m_cssStyleSheetToInspectorStyleSh eet.contains(cssStyleSheet); 594 bool isNew = isInitialFrontendLoad || !m_cssStyleSheetToInspectorStyleSh eet.contains(cssStyleSheet);
593 if (isNew) { 595 if (isNew) {
594 InspectorStyleSheet* newStyleSheet = bindStyleSheet(cssStyleSheet); 596 InspectorStyleSheet* newStyleSheet = bindStyleSheet(cssStyleSheet);
595 documentCSSStyleSheets->add(cssStyleSheet); 597 documentCSSStyleSheets->add(cssStyleSheet);
596 if (m_frontend) 598 if (m_frontend)
597 m_frontend->styleSheetAdded(newStyleSheet->buildObjectForStyleSh eetInfo()); 599 m_frontend->styleSheetAdded(newStyleSheet->buildObjectForStyleSh eetInfo());
598 } 600 }
599 } 601 }
600 602
601 if (documentCSSStyleSheets->isEmpty()) 603 if (documentCSSStyleSheets->isEmpty())
602 m_documentToCSSStyleSheets.remove(document); 604 m_documentToCSSStyleSheets.remove(document);
603 } 605 }
604 606
605 void InspectorCSSAgent::documentDetached(Document* document) 607 void InspectorCSSAgent::documentDetached(Document* document)
606 { 608 {
607 m_invalidatedDocuments.remove(document); 609 m_invalidatedDocuments.remove(document);
608 setActiveStyleSheets(document, Vector<CSSStyleSheet*>(), ExistingFrontendRef resh); 610 setActiveStyleSheets(document, WillBeHeapVector<RawPtrWillBeMember<CSSStyleS heet> >(), ExistingFrontendRefresh);
609 } 611 }
610 612
611 bool InspectorCSSAgent::forcePseudoState(Element* element, CSSSelector::PseudoTy pe pseudoType) 613 bool InspectorCSSAgent::forcePseudoState(Element* element, CSSSelector::PseudoTy pe pseudoType)
612 { 614 {
613 if (m_nodeIdToForcedPseudoState.isEmpty()) 615 if (m_nodeIdToForcedPseudoState.isEmpty())
614 return false; 616 return false;
615 617
616 int nodeId = m_domAgent->boundNodeId(element); 618 int nodeId = m_domAgent->boundNodeId(element);
617 if (!nodeId) 619 if (!nodeId)
618 return false; 620 return false;
(...skipping 544 matching lines...) Expand 10 before | Expand all | Expand 10 after
1163 } 1165 }
1164 if (!node->isElementNode()) { 1166 if (!node->isElementNode()) {
1165 *errorString = "Not an element node"; 1167 *errorString = "Not an element node";
1166 return 0; 1168 return 0;
1167 } 1169 }
1168 return toElement(node); 1170 return toElement(node);
1169 } 1171 }
1170 1172
1171 void InspectorCSSAgent::collectAllStyleSheets(Vector<InspectorStyleSheet*>& resu lt) 1173 void InspectorCSSAgent::collectAllStyleSheets(Vector<InspectorStyleSheet*>& resu lt)
1172 { 1174 {
1173 Vector<CSSStyleSheet*> cssStyleSheets; 1175 WillBeHeapVector<RawPtrWillBeMember<CSSStyleSheet> > cssStyleSheets;
1174 Vector<Document*> documents = m_domAgent->documents(); 1176 WillBeHeapVector<RawPtrWillBeMember<Document> > documents = m_domAgent->docu ments();
1175 for (Vector<Document*>::iterator it = documents.begin(); it != documents.end (); ++it) 1177 for (WillBeHeapVector<RawPtrWillBeMember<Document> >::iterator it = document s.begin(); it != documents.end(); ++it)
1176 collectAllDocumentStyleSheets(*it, cssStyleSheets); 1178 collectAllDocumentStyleSheets(*it, cssStyleSheets);
1177 for (Vector<CSSStyleSheet*>::iterator it = cssStyleSheets.begin(); it != css StyleSheets.end(); ++it) 1179 for (WillBeHeapVector<RefPtrWillBeMember<CSSStyleSheet> >::iterator it = css StyleSheets.begin(); it != cssStyleSheets.end(); ++it)
1178 result.append(bindStyleSheet(*it)); 1180 result.append(bindStyleSheet(*it));
1179 } 1181 }
1180 1182
1181 void InspectorCSSAgent::collectAllDocumentStyleSheets(Document* document, Vector <CSSStyleSheet*>& result) 1183 void InspectorCSSAgent::collectAllDocumentStyleSheets(Document* document, WillBe HeapVector<RawPtrWillBeMember<CSSStyleSheet> >& result)
1182 { 1184 {
1183 const WillBeHeapVector<RefPtrWillBeMember<CSSStyleSheet> > activeStyleSheets = document->styleEngine()->activeStyleSheetsForInspector(); 1185 const WillBeHeapVector<RefPtrWillBeMember<CSSStyleSheet> > activeStyleSheets = document->styleEngine()->activeStyleSheetsForInspector();
1184 for (WillBeHeapVector<RefPtrWillBeMember<CSSStyleSheet> >::const_iterator it = activeStyleSheets.begin(); it != activeStyleSheets.end(); ++it) { 1186 for (WillBeHeapVector<RefPtrWillBeMember<CSSStyleSheet> >::const_iterator it = activeStyleSheets.begin(); it != activeStyleSheets.end(); ++it) {
1185 CSSStyleSheet* styleSheet = it->get(); 1187 CSSStyleSheet* styleSheet = it->get();
1186 collectStyleSheets(styleSheet, result); 1188 collectStyleSheets(styleSheet, result);
1187 } 1189 }
1188 } 1190 }
1189 1191
1190 void InspectorCSSAgent::collectStyleSheets(CSSStyleSheet* styleSheet, Vector<CSS StyleSheet*>& result) 1192 void InspectorCSSAgent::collectStyleSheets(CSSStyleSheet* styleSheet, WillBeHeap Vector<RawPtrWillBeMember<CSSStyleSheet> >& result)
1191 { 1193 {
1192 result.append(styleSheet); 1194 result.append(styleSheet);
1193 for (unsigned i = 0, size = styleSheet->length(); i < size; ++i) { 1195 for (unsigned i = 0, size = styleSheet->length(); i < size; ++i) {
1194 CSSRule* rule = styleSheet->item(i); 1196 CSSRule* rule = styleSheet->item(i);
1195 if (rule->type() == CSSRule::IMPORT_RULE) { 1197 if (rule->type() == CSSRule::IMPORT_RULE) {
1196 CSSStyleSheet* importedStyleSheet = toCSSImportRule(rule)->styleShee t(); 1198 CSSStyleSheet* importedStyleSheet = toCSSImportRule(rule)->styleShee t();
1197 if (importedStyleSheet) 1199 if (importedStyleSheet)
1198 collectStyleSheets(importedStyleSheet, result); 1200 collectStyleSheets(importedStyleSheet, result);
1199 } 1201 }
1200 } 1202 }
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
1432 } 1434 }
1433 1435
1434 void InspectorCSSAgent::didReparseStyleSheet() 1436 void InspectorCSSAgent::didReparseStyleSheet()
1435 { 1437 {
1436 ASSERT(m_isSettingStyleSheetText); 1438 ASSERT(m_isSettingStyleSheetText);
1437 m_isSettingStyleSheetText = false; 1439 m_isSettingStyleSheetText = false;
1438 } 1440 }
1439 1441
1440 void InspectorCSSAgent::resetPseudoStates() 1442 void InspectorCSSAgent::resetPseudoStates()
1441 { 1443 {
1442 HashSet<Document*> documentsToChange; 1444 WillBeHeapHashSet<RawPtrWillBeMember<Document> > documentsToChange;
1443 for (NodeIdToForcedPseudoState::iterator it = m_nodeIdToForcedPseudoState.be gin(), end = m_nodeIdToForcedPseudoState.end(); it != end; ++it) { 1445 for (NodeIdToForcedPseudoState::iterator it = m_nodeIdToForcedPseudoState.be gin(), end = m_nodeIdToForcedPseudoState.end(); it != end; ++it) {
1444 Element* element = toElement(m_domAgent->nodeForId(it->key)); 1446 Element* element = toElement(m_domAgent->nodeForId(it->key));
1445 if (element && element->ownerDocument()) 1447 if (element && element->ownerDocument())
1446 documentsToChange.add(element->ownerDocument()); 1448 documentsToChange.add(element->ownerDocument());
1447 } 1449 }
1448 1450
1449 m_nodeIdToForcedPseudoState.clear(); 1451 m_nodeIdToForcedPseudoState.clear();
1450 for (HashSet<Document*>::iterator it = documentsToChange.begin(), end = docu mentsToChange.end(); it != end; ++it) 1452 for (WillBeHeapHashSet<RawPtrWillBeMember<Document> >::iterator it = documen tsToChange.begin(), end = documentsToChange.end(); it != end; ++it)
1451 (*it)->setNeedsStyleRecalc(SubtreeStyleChange); 1453 (*it)->setNeedsStyleRecalc(SubtreeStyleChange);
1452 } 1454 }
1453 1455
1456 void InspectorCSSAgent::trace(Visitor* visitor)
1457 {
1458 visitor->trace(m_domAgent);
1459 visitor->trace(m_pageAgent);
1460 visitor->trace(m_resourceAgent);
1461 visitor->trace(m_cssStyleSheetToInspectorStyleSheet);
1462 visitor->trace(m_documentToCSSStyleSheets);
1463 visitor->trace(m_invalidatedDocuments);
1464 visitor->trace(m_documentToViaInspectorStyleSheet);
1465 visitor->trace(m_inspectorUserAgentStyleSheet);
1466 InspectorBaseAgent::trace(visitor);
1467 }
1468
1454 } // namespace WebCore 1469 } // namespace WebCore
1455 1470
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698