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

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

Issue 177963004: DevTools: Split creating inspector stylesheet and adding a new rule into stylesheet in protocol. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 9 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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 #include "wtf/CurrentTime.h" 72 #include "wtf/CurrentTime.h"
73 #include "wtf/text/CString.h" 73 #include "wtf/text/CString.h"
74 #include "wtf/text/StringConcatenate.h" 74 #include "wtf/text/StringConcatenate.h"
75 75
76 namespace CSSAgentState { 76 namespace CSSAgentState {
77 static const char cssAgentEnabled[] = "cssAgentEnabled"; 77 static const char cssAgentEnabled[] = "cssAgentEnabled";
78 } 78 }
79 79
80 typedef WebCore::InspectorBackendDispatcher::CSSCommandHandler::EnableCallback E nableCallback; 80 typedef WebCore::InspectorBackendDispatcher::CSSCommandHandler::EnableCallback E nableCallback;
81 81
82 using WebCore::TypeBuilder::CSS::StyleSheetId;
lushnikov 2014/02/28 11:55:59 there's a single use of this type in the file - ca
vsevik 2014/02/28 14:35:28 Done
83
82 namespace WebCore { 84 namespace WebCore {
83 85
84 enum ForcePseudoClassFlags { 86 enum ForcePseudoClassFlags {
85 PseudoNone = 0, 87 PseudoNone = 0,
86 PseudoHover = 1 << 0, 88 PseudoHover = 1 << 0,
87 PseudoFocus = 1 << 1, 89 PseudoFocus = 1 << 1,
88 PseudoActive = 1 << 2, 90 PseudoActive = 1 << 2,
89 PseudoVisited = 1 << 3 91 PseudoVisited = 1 << 3
90 }; 92 };
91 93
(...skipping 773 matching lines...) Expand 10 before | Expand all | Expand 10 after
865 TrackExceptionState exceptionState; 867 TrackExceptionState exceptionState;
866 bool success = m_domAgent->history()->perform(adoptPtr(new SetRuleSelectorAc tion(inspectorStyleSheet, compoundId, selector)), exceptionState); 868 bool success = m_domAgent->history()->perform(adoptPtr(new SetRuleSelectorAc tion(inspectorStyleSheet, compoundId, selector)), exceptionState);
867 869
868 if (success) { 870 if (success) {
869 CSSStyleRule* rule = inspectorStyleSheet->ruleForId(compoundId); 871 CSSStyleRule* rule = inspectorStyleSheet->ruleForId(compoundId);
870 result = inspectorStyleSheet->buildObjectForRule(rule, buildMediaListCha in(rule)); 872 result = inspectorStyleSheet->buildObjectForRule(rule, buildMediaListCha in(rule));
871 } 873 }
872 *errorString = InspectorDOMAgent::toErrorString(exceptionState); 874 *errorString = InspectorDOMAgent::toErrorString(exceptionState);
873 } 875 }
874 876
875 void InspectorCSSAgent::addRule(ErrorString* errorString, const int contextNodeI d, const String& selector, RefPtr<TypeBuilder::CSS::CSSRule>& result) 877 void InspectorCSSAgent::createViaInspectorStyleSheet(ErrorString* errorString, c onst String& frameId, StyleSheetId* outStyleSheetId)
876 { 878 {
877 Node* node = m_domAgent->assertNode(errorString, contextNodeId); 879 LocalFrame* frame = m_pageAgent->frameForId(frameId);
878 if (!node) 880 if (!frame) {
881 *errorString = "Frame not found";
879 return; 882 return;
883 }
880 884
881 InspectorStyleSheet* inspectorStyleSheet = viaInspectorStyleSheet(&node->doc ument(), true); 885 Document* document = frame->document();
886 if (!document) {
887 *errorString = "Frame does not have a document";
888 return;
889 }
890
891 InspectorStyleSheet* inspectorStyleSheet = viaInspectorStyleSheet(document, true);
882 if (!inspectorStyleSheet) { 892 if (!inspectorStyleSheet) {
883 *errorString = "No target stylesheet found"; 893 *errorString = "No target stylesheet found";
884 return; 894 return;
885 } 895 }
886 896
897 *outStyleSheetId = inspectorStyleSheet->id();
898 }
899
900 void InspectorCSSAgent::addRule(ErrorString* errorString, const String& styleShe etId, const String& selector, RefPtr<TypeBuilder::CSS::CSSRule>& result)
901 {
902 InspectorStyleSheet* inspectorStyleSheet = assertStyleSheetForId(errorString , styleSheetId);
903 if (!inspectorStyleSheet)
904 return;
905
887 TrackExceptionState exceptionState; 906 TrackExceptionState exceptionState;
888 OwnPtr<AddRuleAction> action = adoptPtr(new AddRuleAction(inspectorStyleShee t, selector)); 907 OwnPtr<AddRuleAction> action = adoptPtr(new AddRuleAction(inspectorStyleShee t, selector));
889 AddRuleAction* rawAction = action.get(); 908 AddRuleAction* rawAction = action.get();
890 bool success = m_domAgent->history()->perform(action.release(), exceptionSta te); 909 bool success = m_domAgent->history()->perform(action.release(), exceptionSta te);
891 if (!success) { 910 if (!success) {
892 *errorString = InspectorDOMAgent::toErrorString(exceptionState); 911 *errorString = InspectorDOMAgent::toErrorString(exceptionState);
893 return; 912 return;
894 } 913 }
895 914
896 InspectorCSSId ruleId = rawAction->newRuleId(); 915 InspectorCSSId ruleId = rawAction->newRuleId();
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after
1320 documentsToChange.add(element->ownerDocument()); 1339 documentsToChange.add(element->ownerDocument());
1321 } 1340 }
1322 1341
1323 m_nodeIdToForcedPseudoState.clear(); 1342 m_nodeIdToForcedPseudoState.clear();
1324 for (HashSet<Document*>::iterator it = documentsToChange.begin(), end = docu mentsToChange.end(); it != end; ++it) 1343 for (HashSet<Document*>::iterator it = documentsToChange.begin(), end = docu mentsToChange.end(); it != end; ++it)
1325 (*it)->setNeedsStyleRecalc(SubtreeStyleChange); 1344 (*it)->setNeedsStyleRecalc(SubtreeStyleChange);
1326 } 1345 }
1327 1346
1328 } // namespace WebCore 1347 } // namespace WebCore
1329 1348
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698