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

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

Issue 17848002: Web Inspector: Integrate new regionOversetChange event into inspector (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase 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
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 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 {
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 451 matching lines...) Expand 10 before | Expand all | Expand 10 after
786 m_nodeToInspectorStyleSheet.clear(); 834 m_nodeToInspectorStyleSheet.clear();
787 m_documentToInspectorStyleSheet.clear(); 835 m_documentToInspectorStyleSheet.clear();
788 resetNonPersistentData(); 836 resetNonPersistentData();
789 } 837 }
790 838
791 void InspectorCSSAgent::resetNonPersistentData() 839 void InspectorCSSAgent::resetNonPersistentData()
792 { 840 {
793 m_namedFlowCollectionsRequested.clear(); 841 m_namedFlowCollectionsRequested.clear();
794 if (m_updateRegionLayoutTask) 842 if (m_updateRegionLayoutTask)
795 m_updateRegionLayoutTask->reset(); 843 m_updateRegionLayoutTask->reset();
844 if (m_changeRegionOversetTask)
845 m_changeRegionOversetTask->reset();
796 resetPseudoStates(); 846 resetPseudoStates();
797 } 847 }
798 848
799 void InspectorCSSAgent::enable(ErrorString*) 849 void InspectorCSSAgent::enable(ErrorString*)
800 { 850 {
801 m_state->setBoolean(CSSAgentState::cssAgentEnabled, true); 851 m_state->setBoolean(CSSAgentState::cssAgentEnabled, true);
802 m_instrumentingAgents->setInspectorCSSAgent(this); 852 m_instrumentingAgents->setInspectorCSSAgent(this);
803 853
804 if (!m_frontend) 854 if (!m_frontend)
805 return; 855 return;
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
867 { 917 {
868 if (namedFlow->flowState() == NamedFlow::FlowStateNull) 918 if (namedFlow->flowState() == NamedFlow::FlowStateNull)
869 return; 919 return;
870 920
871 ErrorString errorString; 921 ErrorString errorString;
872 RefPtr<NamedFlow> protector(namedFlow); 922 RefPtr<NamedFlow> protector(namedFlow);
873 923
874 m_frontend->regionLayoutUpdated(buildObjectForNamedFlow(&errorString, namedF low, documentNodeId)); 924 m_frontend->regionLayoutUpdated(buildObjectForNamedFlow(&errorString, namedF low, documentNodeId));
875 } 925 }
876 926
927 void InspectorCSSAgent::didChangeRegionOverset(Document* document, NamedFlow* na medFlow)
928 {
929 int documentNodeId = documentNodeWithRequestedFlowsId(document);
930 if (!documentNodeId)
931 return;
932
933 if (!m_changeRegionOversetTask)
934 m_changeRegionOversetTask = adoptPtr(new ChangeRegionOversetTask(this));
935 m_changeRegionOversetTask->scheduleFor(namedFlow, documentNodeId);
936 }
937
938 void InspectorCSSAgent::regionOversetChanged(NamedFlow* namedFlow, int documentN odeId)
939 {
940 if (namedFlow->flowState() == NamedFlow::FlowStateNull)
941 return;
942
943 ErrorString errorString;
944 RefPtr<NamedFlow> protector(namedFlow);
945
946 m_frontend->regionOversetChanged(buildObjectForNamedFlow(&errorString, named Flow, documentNodeId));
947 }
948
877 void InspectorCSSAgent::activeStyleSheetsUpdated(Document* document, const Vecto r<RefPtr<StyleSheet> >& newSheets) 949 void InspectorCSSAgent::activeStyleSheetsUpdated(Document* document, const Vecto r<RefPtr<StyleSheet> >& newSheets)
878 { 950 {
879 HashSet<CSSStyleSheet*> removedSheets; 951 HashSet<CSSStyleSheet*> removedSheets;
880 for (CSSStyleSheetToInspectorStyleSheet::iterator it = m_cssStyleSheetToInsp ectorStyleSheet.begin(); it != m_cssStyleSheetToInspectorStyleSheet.end(); ++it) { 952 for (CSSStyleSheetToInspectorStyleSheet::iterator it = m_cssStyleSheetToInsp ectorStyleSheet.begin(); it != m_cssStyleSheetToInspectorStyleSheet.end(); ++it) {
881 if (it->value->canBind() && (!it->key->ownerDocument() || it->key->owner Document() == document)) 953 if (it->value->canBind() && (!it->key->ownerDocument() || it->key->owner Document() == document))
882 removedSheets.add(it->key); 954 removedSheets.add(it->key);
883 } 955 }
884 956
885 Vector<CSSStyleSheet*> newSheetsVector; 957 Vector<CSSStyleSheet*> newSheetsVector;
886 for (size_t i = 0, size = newSheets.size(); i < size; ++i) { 958 for (size_t i = 0, size = newSheets.size(); i < size; ++i) {
(...skipping 845 matching lines...) Expand 10 before | Expand all | Expand 10 after
1732 documentsToChange.add(element->ownerDocument()); 1804 documentsToChange.add(element->ownerDocument());
1733 } 1805 }
1734 1806
1735 m_nodeIdToForcedPseudoState.clear(); 1807 m_nodeIdToForcedPseudoState.clear();
1736 for (HashSet<Document*>::iterator it = documentsToChange.begin(), end = docu mentsToChange.end(); it != end; ++it) 1808 for (HashSet<Document*>::iterator it = documentsToChange.begin(), end = docu mentsToChange.end(); it != end; ++it)
1737 (*it)->styleResolverChanged(RecalcStyleImmediately); 1809 (*it)->styleResolverChanged(RecalcStyleImmediately);
1738 } 1810 }
1739 1811
1740 } // namespace WebCore 1812 } // namespace WebCore
1741 1813
OLDNEW
« no previous file with comments | « Source/core/inspector/InspectorCSSAgent.h ('k') | Source/core/inspector/InspectorInstrumentation.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698