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 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 315 if (m_namedFlows.contains(namedFlow)) { | 315 if (m_namedFlows.contains(namedFlow)) { |
| 316 m_cssAgent->regionLayoutUpdated(namedFlow, documentNodeId); | 316 m_cssAgent->regionLayoutUpdated(namedFlow, documentNodeId); |
| 317 m_namedFlows.remove(namedFlow); | 317 m_namedFlows.remove(namedFlow); |
| 318 } | 318 } |
| 319 } | 319 } |
| 320 | 320 |
| 321 if (!m_namedFlows.isEmpty() && !m_timer.isActive()) | 321 if (!m_namedFlows.isEmpty() && !m_timer.isActive()) |
| 322 m_timer.startOneShot(0); | 322 m_timer.startOneShot(0); |
| 323 } | 323 } |
| 324 | 324 |
| 325 class ChangeRegionOversetTask { | |
|
pfeldman
2013/06/26 14:37:41
I think it is time to spin a Regions agent so that
| |
| 326 public: | |
| 327 ChangeRegionOversetTask(InspectorCSSAgent*); | |
| 328 void scheduleFor(NamedFlow*, int documentNodeId); | |
| 329 void unschedule(NamedFlow*); | |
| 330 void reset(); | |
| 331 void onTimer(Timer<ChangeRegionOversetTask>*); | |
| 332 | |
| 333 private: | |
| 334 InspectorCSSAgent* m_cssAgent; | |
| 335 Timer<ChangeRegionOversetTask> m_timer; | |
| 336 HashMap<NamedFlow*, int> m_namedFlows; | |
| 337 }; | |
| 338 | |
| 339 ChangeRegionOversetTask::ChangeRegionOversetTask(InspectorCSSAgent* cssAgent) | |
| 340 : m_cssAgent(cssAgent) | |
| 341 , m_timer(this, &ChangeRegionOversetTask::onTimer) | |
| 342 { | |
| 343 } | |
| 344 | |
| 345 void ChangeRegionOversetTask::scheduleFor(NamedFlow* namedFlow, int documentNode Id) | |
| 346 { | |
| 347 m_namedFlows.add(namedFlow, documentNodeId); | |
| 348 | |
| 349 if (!m_timer.isActive()) | |
| 350 m_timer.startOneShot(0); | |
| 351 } | |
| 352 | |
| 353 void ChangeRegionOversetTask::unschedule(NamedFlow* namedFlow) | |
| 354 { | |
| 355 m_namedFlows.remove(namedFlow); | |
| 356 } | |
| 357 | |
| 358 void ChangeRegionOversetTask::reset() | |
| 359 { | |
| 360 m_timer.stop(); | |
| 361 m_namedFlows.clear(); | |
| 362 } | |
| 363 | |
| 364 void ChangeRegionOversetTask::onTimer(Timer<ChangeRegionOversetTask>*) | |
| 365 { | |
| 366 // The timer is stopped on m_cssAgent destruction, so this method will never be called after m_cssAgent has been destroyed. | |
| 367 for (HashMap<NamedFlow*, int>::iterator it = m_namedFlows.begin(), end = m_n amedFlows.end(); it != end; ++it) | |
| 368 m_cssAgent->regionOversetChanged(it->key, it->value); | |
| 369 | |
| 370 m_namedFlows.clear(); | |
| 371 } | |
| 372 | |
| 325 class InspectorCSSAgent::StyleSheetAction : public InspectorHistory::Action { | 373 class InspectorCSSAgent::StyleSheetAction : public InspectorHistory::Action { |
| 326 WTF_MAKE_NONCOPYABLE(StyleSheetAction); | 374 WTF_MAKE_NONCOPYABLE(StyleSheetAction); |
| 327 public: | 375 public: |
| 328 StyleSheetAction(const String& name, InspectorStyleSheet* styleSheet) | 376 StyleSheetAction(const String& name, InspectorStyleSheet* styleSheet) |
| 329 : InspectorHistory::Action(name) | 377 : InspectorHistory::Action(name) |
| 330 , m_styleSheet(styleSheet) | 378 , m_styleSheet(styleSheet) |
| 331 { | 379 { |
| 332 } | 380 } |
| 333 | 381 |
| 334 protected: | 382 protected: |
| (...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 773 m_nodeToInspectorStyleSheet.clear(); | 821 m_nodeToInspectorStyleSheet.clear(); |
| 774 m_documentToInspectorStyleSheet.clear(); | 822 m_documentToInspectorStyleSheet.clear(); |
| 775 resetNonPersistentData(); | 823 resetNonPersistentData(); |
| 776 } | 824 } |
| 777 | 825 |
| 778 void InspectorCSSAgent::resetNonPersistentData() | 826 void InspectorCSSAgent::resetNonPersistentData() |
| 779 { | 827 { |
| 780 m_namedFlowCollectionsRequested.clear(); | 828 m_namedFlowCollectionsRequested.clear(); |
| 781 if (m_updateRegionLayoutTask) | 829 if (m_updateRegionLayoutTask) |
| 782 m_updateRegionLayoutTask->reset(); | 830 m_updateRegionLayoutTask->reset(); |
| 831 if (m_changeRegionOversetTask) | |
| 832 m_changeRegionOversetTask->reset(); | |
| 783 resetPseudoStates(); | 833 resetPseudoStates(); |
| 784 } | 834 } |
| 785 | 835 |
| 786 void InspectorCSSAgent::enable(ErrorString*) | 836 void InspectorCSSAgent::enable(ErrorString*) |
| 787 { | 837 { |
| 788 m_state->setBoolean(CSSAgentState::cssAgentEnabled, true); | 838 m_state->setBoolean(CSSAgentState::cssAgentEnabled, true); |
| 789 m_instrumentingAgents->setInspectorCSSAgent(this); | 839 m_instrumentingAgents->setInspectorCSSAgent(this); |
| 790 | 840 |
| 791 if (!m_frontend) | 841 if (!m_frontend) |
| 792 return; | 842 return; |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 854 { | 904 { |
| 855 if (namedFlow->flowState() == NamedFlow::FlowStateNull) | 905 if (namedFlow->flowState() == NamedFlow::FlowStateNull) |
| 856 return; | 906 return; |
| 857 | 907 |
| 858 ErrorString errorString; | 908 ErrorString errorString; |
| 859 RefPtr<NamedFlow> protector(namedFlow); | 909 RefPtr<NamedFlow> protector(namedFlow); |
| 860 | 910 |
| 861 m_frontend->regionLayoutUpdated(buildObjectForNamedFlow(&errorString, namedF low, documentNodeId)); | 911 m_frontend->regionLayoutUpdated(buildObjectForNamedFlow(&errorString, namedF low, documentNodeId)); |
| 862 } | 912 } |
| 863 | 913 |
| 914 void InspectorCSSAgent::didChangeRegionOverset(Document* document, NamedFlow* na medFlow) | |
| 915 { | |
| 916 int documentNodeId = documentNodeWithRequestedFlowsId(document); | |
| 917 if (!documentNodeId) | |
| 918 return; | |
| 919 | |
| 920 if (!m_changeRegionOversetTask) | |
| 921 m_changeRegionOversetTask = adoptPtr(new ChangeRegionOversetTask(this)); | |
| 922 m_changeRegionOversetTask->scheduleFor(namedFlow, documentNodeId); | |
| 923 } | |
| 924 | |
| 925 void InspectorCSSAgent::regionOversetChanged(NamedFlow* namedFlow, int documentN odeId) | |
| 926 { | |
| 927 if (namedFlow->flowState() == NamedFlow::FlowStateNull) | |
| 928 return; | |
| 929 | |
| 930 ErrorString errorString; | |
| 931 RefPtr<NamedFlow> protector(namedFlow); | |
| 932 | |
| 933 m_frontend->regionOversetChanged(buildObjectForNamedFlow(&errorString, named Flow, documentNodeId)); | |
| 934 } | |
| 935 | |
| 864 void InspectorCSSAgent::activeStyleSheetsUpdated(Document* document, const Vecto r<RefPtr<StyleSheet> >& newSheets) | 936 void InspectorCSSAgent::activeStyleSheetsUpdated(Document* document, const Vecto r<RefPtr<StyleSheet> >& newSheets) |
| 865 { | 937 { |
| 866 HashSet<CSSStyleSheet*> removedSheets; | 938 HashSet<CSSStyleSheet*> removedSheets; |
| 867 for (CSSStyleSheetToInspectorStyleSheet::iterator it = m_cssStyleSheetToInsp ectorStyleSheet.begin(); it != m_cssStyleSheetToInspectorStyleSheet.end(); ++it) { | 939 for (CSSStyleSheetToInspectorStyleSheet::iterator it = m_cssStyleSheetToInsp ectorStyleSheet.begin(); it != m_cssStyleSheetToInspectorStyleSheet.end(); ++it) { |
| 868 if (it->value->canBind() && (!it->key->ownerDocument() || it->key->owner Document() == document)) | 940 if (it->value->canBind() && (!it->key->ownerDocument() || it->key->owner Document() == document)) |
| 869 removedSheets.add(it->key); | 941 removedSheets.add(it->key); |
| 870 } | 942 } |
| 871 | 943 |
| 872 Vector<CSSStyleSheet*> newSheetsVector; | 944 Vector<CSSStyleSheet*> newSheetsVector; |
| 873 for (size_t i = 0, size = newSheets.size(); i < size; ++i) { | 945 for (size_t i = 0, size = newSheets.size(); i < size; ++i) { |
| (...skipping 845 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1719 documentsToChange.add(element->ownerDocument()); | 1791 documentsToChange.add(element->ownerDocument()); |
| 1720 } | 1792 } |
| 1721 | 1793 |
| 1722 m_nodeIdToForcedPseudoState.clear(); | 1794 m_nodeIdToForcedPseudoState.clear(); |
| 1723 for (HashSet<Document*>::iterator it = documentsToChange.begin(), end = docu mentsToChange.end(); it != end; ++it) | 1795 for (HashSet<Document*>::iterator it = documentsToChange.begin(), end = docu mentsToChange.end(); it != end; ++it) |
| 1724 (*it)->styleResolverChanged(RecalcStyleImmediately); | 1796 (*it)->styleResolverChanged(RecalcStyleImmediately); |
| 1725 } | 1797 } |
| 1726 | 1798 |
| 1727 } // namespace WebCore | 1799 } // namespace WebCore |
| 1728 | 1800 |
| OLD | NEW |