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

Powered by Google App Engine
This is Rietveld 408576698