Chromium Code Reviews| 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 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 ASSERT(!m_domAgent); | 376 ASSERT(!m_domAgent); |
|
haraken
2014/06/12 05:53:00
You need to remove this in oilpan builds.
keishi
2014/06/13 03:37:33
Done.
| |
| 377 reset(); | 377 reset(); |
|
haraken
2014/06/12 05:53:01
This looks dangerous. reset() calls resetPseudoSta
keishi
2014/06/13 03:37:33
Done.
| |
| 378 } | 378 } |
| 379 | 379 |
| 380 void InspectorCSSAgent::setFrontend(InspectorFrontend* frontend) | 380 void InspectorCSSAgent::setFrontend(InspectorFrontend* frontend) |
| 381 { | 381 { |
| 382 ASSERT(!m_frontend); | 382 ASSERT(!m_frontend); |
| 383 m_frontend = frontend->css(); | 383 m_frontend = frontend->css(); |
| 384 } | 384 } |
| 385 | 385 |
| 386 void InspectorCSSAgent::clearFrontend() | 386 void InspectorCSSAgent::clearFrontend() |
| 387 { | 387 { |
| 388 ASSERT(m_frontend); | 388 ASSERT(m_frontend); |
| 389 ErrorString error; | 389 ErrorString error; |
| 390 disable(&error); | 390 disable(&error); |
| 391 m_frontend = 0; | 391 m_frontend = 0; |
| 392 resetNonPersistentData(); | 392 resetNonPersistentData(); |
| 393 } | 393 } |
| 394 | 394 |
| 395 void InspectorCSSAgent::discardAgent() | 395 void InspectorCSSAgent::discardAgent() |
| 396 { | 396 { |
| 397 m_domAgent->setDOMListener(0); | 397 m_domAgent->setDOMListener(0); |
| 398 m_domAgent = 0; | 398 m_domAgent = nullptr; |
| 399 } | 399 } |
| 400 | 400 |
| 401 void InspectorCSSAgent::restore() | 401 void InspectorCSSAgent::restore() |
| 402 { | 402 { |
| 403 if (m_state->getBoolean(CSSAgentState::cssAgentEnabled)) | 403 if (m_state->getBoolean(CSSAgentState::cssAgentEnabled)) |
| 404 wasEnabled(nullptr); | 404 wasEnabled(nullptr); |
| 405 } | 405 } |
| 406 | 406 |
| 407 void InspectorCSSAgent::flushPendingFrontendMessages() | 407 void InspectorCSSAgent::flushPendingFrontendMessages() |
| 408 { | 408 { |
| 409 if (!m_invalidatedDocuments.size()) | 409 if (!m_invalidatedDocuments.size()) |
| 410 return; | 410 return; |
| 411 HashSet<Document*> invalidatedDocuments; | 411 WillBeHeapHashSet<RawPtrWillBeMember<Document> > invalidatedDocuments; |
| 412 m_invalidatedDocuments.swap(&invalidatedDocuments); | 412 m_invalidatedDocuments.swap(&invalidatedDocuments); |
| 413 for (HashSet<Document*>::iterator it = invalidatedDocuments.begin(); it != i nvalidatedDocuments.end(); ++it) | 413 for (WillBeHeapHashSet<RawPtrWillBeMember<Document> >::iterator it = invalid atedDocuments.begin(); it != invalidatedDocuments.end(); ++it) |
| 414 updateActiveStyleSheets(*it, ExistingFrontendRefresh); | 414 updateActiveStyleSheets(*it, ExistingFrontendRefresh); |
| 415 } | 415 } |
| 416 | 416 |
| 417 void InspectorCSSAgent::reset() | 417 void InspectorCSSAgent::reset() |
| 418 { | 418 { |
| 419 m_idToInspectorStyleSheet.clear(); | 419 m_idToInspectorStyleSheet.clear(); |
| 420 m_idToInspectorStyleSheetForInlineStyle.clear(); | 420 m_idToInspectorStyleSheetForInlineStyle.clear(); |
| 421 m_cssStyleSheetToInspectorStyleSheet.clear(); | 421 m_cssStyleSheetToInspectorStyleSheet.clear(); |
| 422 m_documentToCSSStyleSheets.clear(); | 422 m_documentToCSSStyleSheets.clear(); |
| 423 m_invalidatedDocuments.clear(); | 423 m_invalidatedDocuments.clear(); |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 538 { | 538 { |
| 539 if (styleSheetEditInProgress()) | 539 if (styleSheetEditInProgress()) |
| 540 return; | 540 return; |
| 541 m_invalidatedDocuments.add(document); | 541 m_invalidatedDocuments.add(document); |
| 542 if (m_creatingViaInspectorStyleSheet) | 542 if (m_creatingViaInspectorStyleSheet) |
| 543 flushPendingFrontendMessages(); | 543 flushPendingFrontendMessages(); |
| 544 } | 544 } |
| 545 | 545 |
| 546 void InspectorCSSAgent::updateActiveStyleSheets(Document* document, StyleSheetsU pdateType styleSheetsUpdateType) | 546 void InspectorCSSAgent::updateActiveStyleSheets(Document* document, StyleSheetsU pdateType styleSheetsUpdateType) |
| 547 { | 547 { |
| 548 Vector<CSSStyleSheet*> newSheetsVector; | 548 Vector<CSSStyleSheet*> newSheetsVector; |
|
haraken
2014/06/12 05:53:00
This should be WillBeHeapVector<RawPtrWillBeMember
keishi
2014/06/13 03:37:33
Done.
| |
| 549 collectAllDocumentStyleSheets(document, newSheetsVector); | 549 collectAllDocumentStyleSheets(document, newSheetsVector); |
| 550 setActiveStyleSheets(document, newSheetsVector, styleSheetsUpdateType); | 550 setActiveStyleSheets(document, newSheetsVector, styleSheetsUpdateType); |
| 551 } | 551 } |
| 552 | 552 |
| 553 void InspectorCSSAgent::setActiveStyleSheets(Document* document, const Vector<CS SStyleSheet*>& allSheetsVector, StyleSheetsUpdateType styleSheetsUpdateType) | 553 void InspectorCSSAgent::setActiveStyleSheets(Document* document, const Vector<CS SStyleSheet*>& allSheetsVector, StyleSheetsUpdateType styleSheetsUpdateType) |
|
haraken
2014/06/12 05:53:00
Ditto.
keishi
2014/06/13 03:37:33
Done.
| |
| 554 { | 554 { |
| 555 bool isInitialFrontendLoad = styleSheetsUpdateType == InitialFrontendLoad; | 555 bool isInitialFrontendLoad = styleSheetsUpdateType == InitialFrontendLoad; |
| 556 | 556 |
| 557 HashSet<CSSStyleSheet*>* documentCSSStyleSheets = m_documentToCSSStyleSheets .get(document); | 557 WillBeHeapHashSet<RawPtrWillBeMember<CSSStyleSheet> >* documentCSSStyleSheet s = m_documentToCSSStyleSheets.get(document); |
| 558 if (!documentCSSStyleSheets) { | 558 if (!documentCSSStyleSheets) { |
| 559 documentCSSStyleSheets = new HashSet<CSSStyleSheet*>(); | 559 documentCSSStyleSheets = new WillBeHeapHashSet<RawPtrWillBeMember<CSSSty leSheet> >(); |
| 560 OwnPtr<HashSet<CSSStyleSheet*> > documentCSSStyleSheetsPtr = adoptPtr(do cumentCSSStyleSheets); | 560 OwnPtrWillBeRawPtr<WillBeHeapHashSet<RawPtrWillBeMember<CSSStyleSheet> > > documentCSSStyleSheetsPtr = adoptPtrWillBeNoop(documentCSSStyleSheets); |
| 561 m_documentToCSSStyleSheets.set(document, documentCSSStyleSheetsPtr.relea se()); | 561 m_documentToCSSStyleSheets.set(document, documentCSSStyleSheetsPtr.relea se()); |
| 562 } | 562 } |
| 563 | 563 |
| 564 HashSet<CSSStyleSheet*> removedSheets(*documentCSSStyleSheets); | 564 WillBeHeapHashSet<RawPtrWillBeMember<CSSStyleSheet> > removedSheets(*documen tCSSStyleSheets); |
| 565 | 565 |
| 566 HashSet<CSSStyleSheet*> addedSheets; | 566 WillBeHeapHashSet<RawPtrWillBeMember<CSSStyleSheet> > addedSheets; |
| 567 for (Vector<CSSStyleSheet*>::const_iterator it = allSheetsVector.begin(); it != allSheetsVector.end(); ++it) { | 567 for (Vector<CSSStyleSheet*>::const_iterator it = allSheetsVector.begin(); it != allSheetsVector.end(); ++it) { |
| 568 CSSStyleSheet* cssStyleSheet = *it; | 568 CSSStyleSheet* cssStyleSheet = *it; |
| 569 if (removedSheets.contains(cssStyleSheet)) { | 569 if (removedSheets.contains(cssStyleSheet)) { |
| 570 removedSheets.remove(cssStyleSheet); | 570 removedSheets.remove(cssStyleSheet); |
| 571 if (isInitialFrontendLoad) | 571 if (isInitialFrontendLoad) |
| 572 addedSheets.add(cssStyleSheet); | 572 addedSheets.add(cssStyleSheet); |
| 573 } else { | 573 } else { |
| 574 addedSheets.add(cssStyleSheet); | 574 addedSheets.add(cssStyleSheet); |
| 575 } | 575 } |
| 576 } | 576 } |
| 577 | 577 |
| 578 for (HashSet<CSSStyleSheet*>::iterator it = removedSheets.begin(); it != rem ovedSheets.end(); ++it) { | 578 for (WillBeHeapHashSet<RawPtrWillBeMember<CSSStyleSheet> >::iterator it = re movedSheets.begin(); it != removedSheets.end(); ++it) { |
| 579 CSSStyleSheet* cssStyleSheet = *it; | 579 CSSStyleSheet* cssStyleSheet = *it; |
| 580 RefPtr<InspectorStyleSheet> inspectorStyleSheet = m_cssStyleSheetToInspe ctorStyleSheet.get(cssStyleSheet); | 580 RefPtrWillBeRawPtr<InspectorStyleSheet> inspectorStyleSheet = m_cssStyle SheetToInspectorStyleSheet.get(cssStyleSheet); |
| 581 ASSERT(inspectorStyleSheet); | 581 ASSERT(inspectorStyleSheet); |
| 582 | 582 |
| 583 documentCSSStyleSheets->remove(cssStyleSheet); | 583 documentCSSStyleSheets->remove(cssStyleSheet); |
| 584 if (m_idToInspectorStyleSheet.contains(inspectorStyleSheet->id())) { | 584 if (m_idToInspectorStyleSheet.contains(inspectorStyleSheet->id())) { |
| 585 String id = unbindStyleSheet(inspectorStyleSheet.get()); | 585 String id = unbindStyleSheet(inspectorStyleSheet.get()); |
| 586 if (m_frontend && !isInitialFrontendLoad) | 586 if (m_frontend && !isInitialFrontendLoad) |
| 587 m_frontend->styleSheetRemoved(id); | 587 m_frontend->styleSheetRemoved(id); |
| 588 } | 588 } |
| 589 } | 589 } |
| 590 | 590 |
| 591 for (HashSet<CSSStyleSheet*>::iterator it = addedSheets.begin(); it != added Sheets.end(); ++it) { | 591 for (WillBeHeapHashSet<RawPtrWillBeMember<CSSStyleSheet> >::iterator it = ad dedSheets.begin(); it != addedSheets.end(); ++it) { |
| 592 CSSStyleSheet* cssStyleSheet = *it; | 592 CSSStyleSheet* cssStyleSheet = *it; |
| 593 bool isNew = isInitialFrontendLoad || !m_cssStyleSheetToInspectorStyleSh eet.contains(cssStyleSheet); | 593 bool isNew = isInitialFrontendLoad || !m_cssStyleSheetToInspectorStyleSh eet.contains(cssStyleSheet); |
| 594 if (isNew) { | 594 if (isNew) { |
| 595 InspectorStyleSheet* newStyleSheet = bindStyleSheet(cssStyleSheet); | 595 InspectorStyleSheet* newStyleSheet = bindStyleSheet(cssStyleSheet); |
| 596 documentCSSStyleSheets->add(cssStyleSheet); | 596 documentCSSStyleSheets->add(cssStyleSheet); |
| 597 if (m_frontend) | 597 if (m_frontend) |
| 598 m_frontend->styleSheetAdded(newStyleSheet->buildObjectForStyleSh eetInfo()); | 598 m_frontend->styleSheetAdded(newStyleSheet->buildObjectForStyleSh eetInfo()); |
| 599 } | 599 } |
| 600 } | 600 } |
| 601 | 601 |
| (...skipping 831 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1433 } | 1433 } |
| 1434 | 1434 |
| 1435 void InspectorCSSAgent::didReparseStyleSheet() | 1435 void InspectorCSSAgent::didReparseStyleSheet() |
| 1436 { | 1436 { |
| 1437 ASSERT(m_isSettingStyleSheetText); | 1437 ASSERT(m_isSettingStyleSheetText); |
| 1438 m_isSettingStyleSheetText = false; | 1438 m_isSettingStyleSheetText = false; |
| 1439 } | 1439 } |
| 1440 | 1440 |
| 1441 void InspectorCSSAgent::resetPseudoStates() | 1441 void InspectorCSSAgent::resetPseudoStates() |
| 1442 { | 1442 { |
| 1443 HashSet<Document*> documentsToChange; | 1443 HashSet<Document*> documentsToChange; |
|
haraken
2014/06/12 05:53:00
This should be WillBeHeapHashSet<RawPtrWillBeMembe
keishi
2014/06/13 03:37:33
Done.
| |
| 1444 for (NodeIdToForcedPseudoState::iterator it = m_nodeIdToForcedPseudoState.be gin(), end = m_nodeIdToForcedPseudoState.end(); it != end; ++it) { | 1444 for (NodeIdToForcedPseudoState::iterator it = m_nodeIdToForcedPseudoState.be gin(), end = m_nodeIdToForcedPseudoState.end(); it != end; ++it) { |
| 1445 Element* element = toElement(m_domAgent->nodeForId(it->key)); | 1445 Element* element = toElement(m_domAgent->nodeForId(it->key)); |
| 1446 if (element && element->ownerDocument()) | 1446 if (element && element->ownerDocument()) |
| 1447 documentsToChange.add(element->ownerDocument()); | 1447 documentsToChange.add(element->ownerDocument()); |
| 1448 } | 1448 } |
| 1449 | 1449 |
| 1450 m_nodeIdToForcedPseudoState.clear(); | 1450 m_nodeIdToForcedPseudoState.clear(); |
| 1451 for (HashSet<Document*>::iterator it = documentsToChange.begin(), end = docu mentsToChange.end(); it != end; ++it) | 1451 for (HashSet<Document*>::iterator it = documentsToChange.begin(), end = docu mentsToChange.end(); it != end; ++it) |
| 1452 (*it)->setNeedsStyleRecalc(SubtreeStyleChange); | 1452 (*it)->setNeedsStyleRecalc(SubtreeStyleChange); |
| 1453 } | 1453 } |
| 1454 | 1454 |
| 1455 void InspectorCSSAgent::trace(Visitor* visitor) | |
| 1456 { | |
| 1457 visitor->trace(m_domAgent); | |
| 1458 visitor->trace(m_pageAgent); | |
| 1459 visitor->trace(m_resourceAgent); | |
| 1460 visitor->trace(m_cssStyleSheetToInspectorStyleSheet); | |
| 1461 visitor->trace(m_documentToCSSStyleSheets); | |
| 1462 visitor->trace(m_invalidatedDocuments); | |
| 1463 visitor->trace(m_documentToViaInspectorStyleSheet); | |
| 1464 visitor->trace(m_inspectorUserAgentStyleSheet); | |
| 1465 InspectorBaseAgent::trace(visitor); | |
| 1466 } | |
| 1467 | |
| 1455 } // namespace WebCore | 1468 } // namespace WebCore |
| 1456 | 1469 |
| OLD | NEW |