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

Side by Side Diff: Source/core/inspector/InspectorCSSAgent.cpp

Issue 16934003: Inspector: replace generic discardAgents logic with explicit call to discard a listener. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Addressed comments Created 7 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 677 matching lines...) Expand 10 before | Expand all | Expand 10 after
688 , m_domAgent(domAgent) 688 , m_domAgent(domAgent)
689 , m_pageAgent(pageAgent) 689 , m_pageAgent(pageAgent)
690 , m_lastStyleSheetId(1) 690 , m_lastStyleSheetId(1)
691 , m_creatingViaInspectorStyleSheet(false) 691 , m_creatingViaInspectorStyleSheet(false)
692 { 692 {
693 m_domAgent->setDOMListener(this); 693 m_domAgent->setDOMListener(this);
694 } 694 }
695 695
696 InspectorCSSAgent::~InspectorCSSAgent() 696 InspectorCSSAgent::~InspectorCSSAgent()
697 { 697 {
698 ASSERT(!m_domAgent); 698 if (m_domAgent)
699 m_domAgent->setDOMListener(0);
699 reset(); 700 reset();
700 } 701 }
701 702
702 void InspectorCSSAgent::setFrontend(InspectorFrontend* frontend) 703 void InspectorCSSAgent::setFrontend(InspectorFrontend* frontend)
703 { 704 {
704 ASSERT(!m_frontend); 705 ASSERT(!m_frontend);
705 m_frontend = frontend->css(); 706 m_frontend = frontend->css();
706 } 707 }
707 708
708 void InspectorCSSAgent::clearFrontend() 709 void InspectorCSSAgent::clearFrontend()
709 { 710 {
710 ASSERT(m_frontend); 711 ASSERT(m_frontend);
711 m_frontend = 0; 712 m_frontend = 0;
712 resetNonPersistentData(); 713 resetNonPersistentData();
713 stopSelectorProfilerImpl(0, false); 714 stopSelectorProfilerImpl(0, false);
714 } 715 }
715 716
716 void InspectorCSSAgent::discardAgent()
717 {
718 m_domAgent->setDOMListener(0);
719 m_domAgent = 0;
720 }
721
722 void InspectorCSSAgent::restore() 717 void InspectorCSSAgent::restore()
723 { 718 {
724 if (m_state->getBoolean(CSSAgentState::cssAgentEnabled)) { 719 if (m_state->getBoolean(CSSAgentState::cssAgentEnabled)) {
725 ErrorString error; 720 ErrorString error;
726 enable(&error); 721 enable(&error);
727 } 722 }
728 if (m_state->getBoolean(CSSAgentState::isSelectorProfiling)) { 723 if (m_state->getBoolean(CSSAgentState::isSelectorProfiling)) {
729 String errorString; 724 String errorString;
730 startSelectorProfiler(&errorString); 725 startSelectorProfiler(&errorString);
731 } 726 }
(...skipping 813 matching lines...) Expand 10 before | Expand all | Expand 10 after
1545 if (!element) 1540 if (!element)
1546 return; 1541 return;
1547 1542
1548 NodeToInspectorStyleSheet::iterator it = m_nodeToInspectorStyleSheet.find(el ement); 1543 NodeToInspectorStyleSheet::iterator it = m_nodeToInspectorStyleSheet.find(el ement);
1549 if (it == m_nodeToInspectorStyleSheet.end()) 1544 if (it == m_nodeToInspectorStyleSheet.end())
1550 return; 1545 return;
1551 1546
1552 it->value->didModifyElementAttribute(); 1547 it->value->didModifyElementAttribute();
1553 } 1548 }
1554 1549
1550 void InspectorCSSAgent::willDestroyDOMAgent()
1551 {
1552 m_domAgent = 0;
1553 }
1554
1555 void InspectorCSSAgent::styleSheetChanged(InspectorStyleSheet* styleSheet) 1555 void InspectorCSSAgent::styleSheetChanged(InspectorStyleSheet* styleSheet)
1556 { 1556 {
1557 if (m_frontend) 1557 if (m_frontend)
1558 m_frontend->styleSheetChanged(styleSheet->id()); 1558 m_frontend->styleSheetChanged(styleSheet->id());
1559 } 1559 }
1560 1560
1561 void InspectorCSSAgent::resetPseudoStates() 1561 void InspectorCSSAgent::resetPseudoStates()
1562 { 1562 {
1563 HashSet<Document*> documentsToChange; 1563 HashSet<Document*> documentsToChange;
1564 for (NodeIdToForcedPseudoState::iterator it = m_nodeIdToForcedPseudoState.be gin(), end = m_nodeIdToForcedPseudoState.end(); it != end; ++it) { 1564 for (NodeIdToForcedPseudoState::iterator it = m_nodeIdToForcedPseudoState.be gin(), end = m_nodeIdToForcedPseudoState.end(); it != end; ++it) {
1565 Element* element = toElement(m_domAgent->nodeForId(it->key)); 1565 Element* element = toElement(m_domAgent->nodeForId(it->key));
1566 if (element && element->ownerDocument()) 1566 if (element && element->ownerDocument())
1567 documentsToChange.add(element->ownerDocument()); 1567 documentsToChange.add(element->ownerDocument());
1568 } 1568 }
1569 1569
1570 m_nodeIdToForcedPseudoState.clear(); 1570 m_nodeIdToForcedPseudoState.clear();
1571 for (HashSet<Document*>::iterator it = documentsToChange.begin(), end = docu mentsToChange.end(); it != end; ++it) 1571 for (HashSet<Document*>::iterator it = documentsToChange.begin(), end = docu mentsToChange.end(); it != end; ++it)
1572 (*it)->styleResolverChanged(RecalcStyleImmediately); 1572 (*it)->styleResolverChanged(RecalcStyleImmediately);
1573 } 1573 }
1574 1574
1575 } // namespace WebCore 1575 } // namespace WebCore
1576 1576
OLDNEW
« no previous file with comments | « Source/core/inspector/InspectorCSSAgent.h ('k') | Source/core/inspector/InspectorController.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698