OLD | NEW |
---|---|
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 Loading... | |
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(); |
haraken
2014/06/17 14:06:17
I'm not quite sure of this. Is it OK to not call r
keishi
2014/06/18 12:31:06
InspectorController::willBeDestroyed calls Inspect
| |
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 Loading... | |
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 Loading... | |
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 | 522 |
521 HashSet<CSSStyleSheet*> addedSheets; | 523 WillBeHeapHashSet<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.add(cssStyleSheet); | 529 addedSheets.add(cssStyleSheet); |
528 } else { | 530 } else { |
529 addedSheets.add(cssStyleSheet); | 531 addedSheets.add(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 (HashSet<CSSStyleSheet*>::iterator it = addedSheets.begin(); it != added Sheets.end(); ++it) { | 548 for (WillBeHeapHashSet<RawPtrWillBeMember<CSSStyleSheet> >::iterator it = ad dedSheets.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 543 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1118 return 0; | 1120 return 0; |
1119 } | 1121 } |
1120 if (!node->isElementNode()) { | 1122 if (!node->isElementNode()) { |
1121 *errorString = "Not an element node"; | 1123 *errorString = "Not an element node"; |
1122 return 0; | 1124 return 0; |
1123 } | 1125 } |
1124 return toElement(node); | 1126 return toElement(node); |
1125 } | 1127 } |
1126 | 1128 |
1127 // static | 1129 // static |
1128 void InspectorCSSAgent::collectAllDocumentStyleSheets(Document* document, Vector <CSSStyleSheet*>& result) | 1130 void InspectorCSSAgent::collectAllDocumentStyleSheets(Document* document, WillBe HeapVector<RawPtrWillBeMember<CSSStyleSheet> >& result) |
1129 { | 1131 { |
1130 const WillBeHeapVector<RefPtrWillBeMember<CSSStyleSheet> > activeStyleSheets = document->styleEngine()->activeStyleSheetsForInspector(); | 1132 const WillBeHeapVector<RefPtrWillBeMember<CSSStyleSheet> > activeStyleSheets = document->styleEngine()->activeStyleSheetsForInspector(); |
1131 for (WillBeHeapVector<RefPtrWillBeMember<CSSStyleSheet> >::const_iterator it = activeStyleSheets.begin(); it != activeStyleSheets.end(); ++it) { | 1133 for (WillBeHeapVector<RefPtrWillBeMember<CSSStyleSheet> >::const_iterator it = activeStyleSheets.begin(); it != activeStyleSheets.end(); ++it) { |
1132 CSSStyleSheet* styleSheet = it->get(); | 1134 CSSStyleSheet* styleSheet = it->get(); |
1133 InspectorCSSAgent::collectStyleSheets(styleSheet, result); | 1135 InspectorCSSAgent::collectStyleSheets(styleSheet, result); |
1134 } | 1136 } |
1135 } | 1137 } |
1136 | 1138 |
1137 // static | 1139 // static |
1138 void InspectorCSSAgent::collectStyleSheets(CSSStyleSheet* styleSheet, Vector<CSS StyleSheet*>& result) | 1140 void InspectorCSSAgent::collectStyleSheets(CSSStyleSheet* styleSheet, WillBeHeap Vector<RawPtrWillBeMember<CSSStyleSheet> >& result) |
1139 { | 1141 { |
1140 result.append(styleSheet); | 1142 result.append(styleSheet); |
1141 for (unsigned i = 0, size = styleSheet->length(); i < size; ++i) { | 1143 for (unsigned i = 0, size = styleSheet->length(); i < size; ++i) { |
1142 CSSRule* rule = styleSheet->item(i); | 1144 CSSRule* rule = styleSheet->item(i); |
1143 if (rule->type() == CSSRule::IMPORT_RULE) { | 1145 if (rule->type() == CSSRule::IMPORT_RULE) { |
1144 CSSStyleSheet* importedStyleSheet = toCSSImportRule(rule)->styleShee t(); | 1146 CSSStyleSheet* importedStyleSheet = toCSSImportRule(rule)->styleShee t(); |
1145 if (importedStyleSheet) | 1147 if (importedStyleSheet) |
1146 InspectorCSSAgent::collectStyleSheets(importedStyleSheet, result ); | 1148 InspectorCSSAgent::collectStyleSheets(importedStyleSheet, result ); |
1147 } | 1149 } |
1148 } | 1150 } |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1380 } | 1382 } |
1381 | 1383 |
1382 void InspectorCSSAgent::didReparseStyleSheet() | 1384 void InspectorCSSAgent::didReparseStyleSheet() |
1383 { | 1385 { |
1384 ASSERT(m_isSettingStyleSheetText); | 1386 ASSERT(m_isSettingStyleSheetText); |
1385 m_isSettingStyleSheetText = false; | 1387 m_isSettingStyleSheetText = false; |
1386 } | 1388 } |
1387 | 1389 |
1388 void InspectorCSSAgent::resetPseudoStates() | 1390 void InspectorCSSAgent::resetPseudoStates() |
1389 { | 1391 { |
1390 HashSet<Document*> documentsToChange; | 1392 WillBeHeapHashSet<RawPtrWillBeMember<Document> > documentsToChange; |
1391 for (NodeIdToForcedPseudoState::iterator it = m_nodeIdToForcedPseudoState.be gin(), end = m_nodeIdToForcedPseudoState.end(); it != end; ++it) { | 1393 for (NodeIdToForcedPseudoState::iterator it = m_nodeIdToForcedPseudoState.be gin(), end = m_nodeIdToForcedPseudoState.end(); it != end; ++it) { |
1392 Element* element = toElement(m_domAgent->nodeForId(it->key)); | 1394 Element* element = toElement(m_domAgent->nodeForId(it->key)); |
1393 if (element && element->ownerDocument()) | 1395 if (element && element->ownerDocument()) |
1394 documentsToChange.add(element->ownerDocument()); | 1396 documentsToChange.add(element->ownerDocument()); |
1395 } | 1397 } |
1396 | 1398 |
1397 m_nodeIdToForcedPseudoState.clear(); | 1399 m_nodeIdToForcedPseudoState.clear(); |
1398 for (HashSet<Document*>::iterator it = documentsToChange.begin(), end = docu mentsToChange.end(); it != end; ++it) | 1400 for (WillBeHeapHashSet<RawPtrWillBeMember<Document> >::iterator it = documen tsToChange.begin(), end = documentsToChange.end(); it != end; ++it) |
1399 (*it)->setNeedsStyleRecalc(SubtreeStyleChange); | 1401 (*it)->setNeedsStyleRecalc(SubtreeStyleChange); |
1400 } | 1402 } |
1401 | 1403 |
1404 void InspectorCSSAgent::trace(Visitor* visitor) | |
1405 { | |
1406 visitor->trace(m_domAgent); | |
1407 visitor->trace(m_pageAgent); | |
1408 visitor->trace(m_resourceAgent); | |
1409 visitor->trace(m_cssStyleSheetToInspectorStyleSheet); | |
1410 visitor->trace(m_documentToCSSStyleSheets); | |
1411 visitor->trace(m_invalidatedDocuments); | |
1412 visitor->trace(m_documentToViaInspectorStyleSheet); | |
1413 visitor->trace(m_inspectorUserAgentStyleSheet); | |
1414 InspectorBaseAgent::trace(visitor); | |
1415 } | |
1416 | |
1402 } // namespace WebCore | 1417 } // namespace WebCore |
1403 | 1418 |
OLD | NEW |