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

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: Comments addressed 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 854 matching lines...) Expand 10 before | Expand all | Expand 10 after
865 TrackExceptionState exceptionState; 865 TrackExceptionState exceptionState;
866 bool success = m_domAgent->history()->perform(adoptPtr(new SetRuleSelectorAc tion(inspectorStyleSheet, compoundId, selector)), exceptionState); 866 bool success = m_domAgent->history()->perform(adoptPtr(new SetRuleSelectorAc tion(inspectorStyleSheet, compoundId, selector)), exceptionState);
867 867
868 if (success) { 868 if (success) {
869 CSSStyleRule* rule = inspectorStyleSheet->ruleForId(compoundId); 869 CSSStyleRule* rule = inspectorStyleSheet->ruleForId(compoundId);
870 result = inspectorStyleSheet->buildObjectForRule(rule, buildMediaListCha in(rule)); 870 result = inspectorStyleSheet->buildObjectForRule(rule, buildMediaListCha in(rule));
871 } 871 }
872 *errorString = InspectorDOMAgent::toErrorString(exceptionState); 872 *errorString = InspectorDOMAgent::toErrorString(exceptionState);
873 } 873 }
874 874
875 void InspectorCSSAgent::addRule(ErrorString* errorString, const int contextNodeI d, const String& selector, RefPtr<TypeBuilder::CSS::CSSRule>& result) 875 void InspectorCSSAgent::createStyleSheet(ErrorString* errorString, const String& frameId, TypeBuilder::CSS::StyleSheetId* outStyleSheetId)
876 { 876 {
877 Node* node = m_domAgent->assertNode(errorString, contextNodeId); 877 LocalFrame* frame = m_pageAgent->frameForId(frameId);
878 if (!node) 878 if (!frame) {
879 *errorString = "Frame not found";
879 return; 880 return;
881 }
880 882
881 InspectorStyleSheet* inspectorStyleSheet = viaInspectorStyleSheet(&node->doc ument(), true); 883 Document* document = frame->document();
884 if (!document) {
885 *errorString = "Frame does not have a document";
886 return;
887 }
888
889 InspectorStyleSheet* inspectorStyleSheet = viaInspectorStyleSheet(document, true);
882 if (!inspectorStyleSheet) { 890 if (!inspectorStyleSheet) {
883 *errorString = "No target stylesheet found"; 891 *errorString = "No target stylesheet found";
884 return; 892 return;
885 } 893 }
886 894
895 *outStyleSheetId = inspectorStyleSheet->id();
896 }
897
898 void InspectorCSSAgent::addRule(ErrorString* errorString, const String& styleShe etId, const String& selector, RefPtr<TypeBuilder::CSS::CSSRule>& result)
899 {
900 InspectorStyleSheet* inspectorStyleSheet = assertStyleSheetForId(errorString , styleSheetId);
901 if (!inspectorStyleSheet)
902 return;
903
887 TrackExceptionState exceptionState; 904 TrackExceptionState exceptionState;
888 OwnPtr<AddRuleAction> action = adoptPtr(new AddRuleAction(inspectorStyleShee t, selector)); 905 OwnPtr<AddRuleAction> action = adoptPtr(new AddRuleAction(inspectorStyleShee t, selector));
889 AddRuleAction* rawAction = action.get(); 906 AddRuleAction* rawAction = action.get();
890 bool success = m_domAgent->history()->perform(action.release(), exceptionSta te); 907 bool success = m_domAgent->history()->perform(action.release(), exceptionSta te);
891 if (!success) { 908 if (!success) {
892 *errorString = InspectorDOMAgent::toErrorString(exceptionState); 909 *errorString = InspectorDOMAgent::toErrorString(exceptionState);
893 return; 910 return;
894 } 911 }
895 912
896 InspectorCSSId ruleId = rawAction->newRuleId(); 913 InspectorCSSId ruleId = rawAction->newRuleId();
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after
1320 documentsToChange.add(element->ownerDocument()); 1337 documentsToChange.add(element->ownerDocument());
1321 } 1338 }
1322 1339
1323 m_nodeIdToForcedPseudoState.clear(); 1340 m_nodeIdToForcedPseudoState.clear();
1324 for (HashSet<Document*>::iterator it = documentsToChange.begin(), end = docu mentsToChange.end(); it != end; ++it) 1341 for (HashSet<Document*>::iterator it = documentsToChange.begin(), end = docu mentsToChange.end(); it != end; ++it)
1325 (*it)->setNeedsStyleRecalc(SubtreeStyleChange); 1342 (*it)->setNeedsStyleRecalc(SubtreeStyleChange);
1326 } 1343 }
1327 1344
1328 } // namespace WebCore 1345 } // namespace WebCore
1329 1346
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698