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

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

Issue 298873004: Oilpan: Move DOMEditor to the heap (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebased Created 6 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
« no previous file with comments | « Source/core/inspector/DOMEditor.cpp ('k') | Source/core/inspector/InspectorDOMAgent.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 virtual bool redo(ExceptionState& exceptionState) OVERRIDE 194 virtual bool redo(ExceptionState& exceptionState) OVERRIDE
195 { 195 {
196 return m_styleSheet->setText(m_text, exceptionState); 196 return m_styleSheet->setText(m_text, exceptionState);
197 } 197 }
198 198
199 virtual String mergeId() OVERRIDE 199 virtual String mergeId() OVERRIDE
200 { 200 {
201 return String::format("SetStyleSheetText %s", m_styleSheet->id().utf8(). data()); 201 return String::format("SetStyleSheetText %s", m_styleSheet->id().utf8(). data());
202 } 202 }
203 203
204 virtual void merge(PassRefPtr<Action> action) OVERRIDE 204 virtual void merge(PassRefPtrWillBeRawPtr<Action> action) OVERRIDE
205 { 205 {
206 ASSERT(action->mergeId() == mergeId()); 206 ASSERT(action->mergeId() == mergeId());
207 207
208 SetStyleSheetTextAction* other = static_cast<SetStyleSheetTextAction*>(a ction.get()); 208 SetStyleSheetTextAction* other = static_cast<SetStyleSheetTextAction*>(a ction.get());
209 m_text = other->m_text; 209 m_text = other->m_text;
210 } 210 }
211 211
212 private: 212 private:
213 RefPtr<InspectorStyleSheetBase> m_styleSheet; 213 RefPtr<InspectorStyleSheetBase> m_styleSheet;
214 String m_text; 214 String m_text;
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 return false; 250 return false;
251 bool result = m_styleSheet->setPropertyText(m_cssId, m_propertyIndex, m_ text, m_overwrite, exceptionState); 251 bool result = m_styleSheet->setPropertyText(m_cssId, m_propertyIndex, m_ text, m_overwrite, exceptionState);
252 return result; 252 return result;
253 } 253 }
254 254
255 virtual String mergeId() OVERRIDE 255 virtual String mergeId() OVERRIDE
256 { 256 {
257 return String::format("SetPropertyText %s:%u:%s", m_styleSheet->id().utf 8().data(), m_propertyIndex, m_overwrite ? "true" : "false"); 257 return String::format("SetPropertyText %s:%u:%s", m_styleSheet->id().utf 8().data(), m_propertyIndex, m_overwrite ? "true" : "false");
258 } 258 }
259 259
260 virtual void merge(PassRefPtr<Action> action) OVERRIDE 260 virtual void merge(PassRefPtrWillBeRawPtr<Action> action) OVERRIDE
261 { 261 {
262 ASSERT(action->mergeId() == mergeId()); 262 ASSERT(action->mergeId() == mergeId());
263 263
264 SetPropertyTextAction* other = static_cast<SetPropertyTextAction*>(actio n.get()); 264 SetPropertyTextAction* other = static_cast<SetPropertyTextAction*>(actio n.get());
265 m_text = other->m_text; 265 m_text = other->m_text;
266 } 266 }
267 267
268 private: 268 private:
269 RefPtr<InspectorStyleSheetBase> m_styleSheet; 269 RefPtr<InspectorStyleSheetBase> m_styleSheet;
270 InspectorCSSId m_cssId; 270 InspectorCSSId m_cssId;
(...skipping 554 matching lines...) Expand 10 before | Expand all | Expand 10 after
825 825
826 void InspectorCSSAgent::setStyleSheetText(ErrorString* errorString, const String & styleSheetId, const String& text) 826 void InspectorCSSAgent::setStyleSheetText(ErrorString* errorString, const String & styleSheetId, const String& text)
827 { 827 {
828 InspectorStyleSheetBase* inspectorStyleSheet = assertStyleSheetForId(errorSt ring, styleSheetId); 828 InspectorStyleSheetBase* inspectorStyleSheet = assertStyleSheetForId(errorSt ring, styleSheetId);
829 if (!inspectorStyleSheet) { 829 if (!inspectorStyleSheet) {
830 *errorString = "Style sheet with id " + styleSheetId + " not found"; 830 *errorString = "Style sheet with id " + styleSheetId + " not found";
831 return; 831 return;
832 } 832 }
833 833
834 TrackExceptionState exceptionState; 834 TrackExceptionState exceptionState;
835 m_domAgent->history()->perform(adoptRef(new SetStyleSheetTextAction(inspecto rStyleSheet, text)), exceptionState); 835 m_domAgent->history()->perform(adoptRefWillBeNoop(new SetStyleSheetTextActio n(inspectorStyleSheet, text)), exceptionState);
836 *errorString = InspectorDOMAgent::toErrorString(exceptionState); 836 *errorString = InspectorDOMAgent::toErrorString(exceptionState);
837 } 837 }
838 838
839 static bool extractRangeComponent(ErrorString* errorString, const RefPtr<JSONObj ect>& range, const String& component, unsigned& result) 839 static bool extractRangeComponent(ErrorString* errorString, const RefPtr<JSONObj ect>& range, const String& component, unsigned& result)
840 { 840 {
841 int parsedValue; 841 int parsedValue;
842 if (!range->getNumber(component, &parsedValue) || parsedValue < 0) { 842 if (!range->getNumber(component, &parsedValue) || parsedValue < 0) {
843 *errorString = "range." + component + " must be a non-negative integer"; 843 *errorString = "range." + component + " must be a non-negative integer";
844 return false; 844 return false;
845 } 845 }
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
887 return; 887 return;
888 InspectorCSSId compoundId; 888 InspectorCSSId compoundId;
889 unsigned propertyIndex; 889 unsigned propertyIndex;
890 bool overwrite; 890 bool overwrite;
891 if (!inspectorStyleSheet->findPropertyByRange(propertyRange, &compoundId, &p ropertyIndex, &overwrite)) { 891 if (!inspectorStyleSheet->findPropertyByRange(propertyRange, &compoundId, &p ropertyIndex, &overwrite)) {
892 *errorString = "Source range didn't match any existing property source r ange nor any property insertion point"; 892 *errorString = "Source range didn't match any existing property source r ange nor any property insertion point";
893 return; 893 return;
894 } 894 }
895 895
896 TrackExceptionState exceptionState; 896 TrackExceptionState exceptionState;
897 bool success = m_domAgent->history()->perform(adoptRef(new SetPropertyTextAc tion(inspectorStyleSheet, compoundId, propertyIndex, text, overwrite)), exceptio nState); 897 bool success = m_domAgent->history()->perform(adoptRefWillBeNoop(new SetProp ertyTextAction(inspectorStyleSheet, compoundId, propertyIndex, text, overwrite)) , exceptionState);
898 if (success) 898 if (success)
899 result = inspectorStyleSheet->buildObjectForStyle(inspectorStyleSheet->s tyleForId(compoundId)); 899 result = inspectorStyleSheet->buildObjectForStyle(inspectorStyleSheet->s tyleForId(compoundId));
900 *errorString = InspectorDOMAgent::toErrorString(exceptionState); 900 *errorString = InspectorDOMAgent::toErrorString(exceptionState);
901 } 901 }
902 902
903 void InspectorCSSAgent::setRuleSelector(ErrorString* errorString, const String& styleSheetId, const RefPtr<JSONObject>& range, const String& selector, RefPtr<Ty peBuilder::CSS::CSSRule>& result) 903 void InspectorCSSAgent::setRuleSelector(ErrorString* errorString, const String& styleSheetId, const RefPtr<JSONObject>& range, const String& selector, RefPtr<Ty peBuilder::CSS::CSSRule>& result)
904 { 904 {
905 InspectorStyleSheet* inspectorStyleSheet = assertInspectorStyleSheetForId(er rorString, styleSheetId); 905 InspectorStyleSheet* inspectorStyleSheet = assertInspectorStyleSheetForId(er rorString, styleSheetId);
906 if (!inspectorStyleSheet) 906 if (!inspectorStyleSheet)
907 return; 907 return;
908 SourceRange selectorRange; 908 SourceRange selectorRange;
909 if (!jsonRangeToSourceRange(errorString, inspectorStyleSheet, range, &select orRange)) 909 if (!jsonRangeToSourceRange(errorString, inspectorStyleSheet, range, &select orRange))
910 return; 910 return;
911 InspectorCSSId compoundId; 911 InspectorCSSId compoundId;
912 if (!inspectorStyleSheet->findRuleBySelectorRange(selectorRange, &compoundId )) { 912 if (!inspectorStyleSheet->findRuleBySelectorRange(selectorRange, &compoundId )) {
913 *errorString = "Source range didn't match any rule selector source range "; 913 *errorString = "Source range didn't match any rule selector source range ";
914 return; 914 return;
915 } 915 }
916 916
917 TrackExceptionState exceptionState; 917 TrackExceptionState exceptionState;
918 bool success = m_domAgent->history()->perform(adoptRef(new SetRuleSelectorAc tion(inspectorStyleSheet, compoundId, selector)), exceptionState); 918 bool success = m_domAgent->history()->perform(adoptRefWillBeNoop(new SetRule SelectorAction(inspectorStyleSheet, compoundId, selector)), exceptionState);
919 if (success) { 919 if (success) {
920 CSSStyleRule* rule = inspectorStyleSheet->ruleForId(compoundId); 920 CSSStyleRule* rule = inspectorStyleSheet->ruleForId(compoundId);
921 result = inspectorStyleSheet->buildObjectForRule(rule, buildMediaListCha in(rule)); 921 result = inspectorStyleSheet->buildObjectForRule(rule, buildMediaListCha in(rule));
922 } 922 }
923 *errorString = InspectorDOMAgent::toErrorString(exceptionState); 923 *errorString = InspectorDOMAgent::toErrorString(exceptionState);
924 } 924 }
925 925
926 void InspectorCSSAgent::createStyleSheet(ErrorString* errorString, const String& frameId, TypeBuilder::CSS::StyleSheetId* outStyleSheetId) 926 void InspectorCSSAgent::createStyleSheet(ErrorString* errorString, const String& frameId, TypeBuilder::CSS::StyleSheetId* outStyleSheetId)
927 { 927 {
928 LocalFrame* frame = m_pageAgent->frameForId(frameId); 928 LocalFrame* frame = m_pageAgent->frameForId(frameId);
(...skipping 19 matching lines...) Expand all
948 *outStyleSheetId = inspectorStyleSheet->id(); 948 *outStyleSheetId = inspectorStyleSheet->id();
949 } 949 }
950 950
951 void InspectorCSSAgent::addRule(ErrorString* errorString, const String& styleShe etId, const String& selector, RefPtr<TypeBuilder::CSS::CSSRule>& result) 951 void InspectorCSSAgent::addRule(ErrorString* errorString, const String& styleShe etId, const String& selector, RefPtr<TypeBuilder::CSS::CSSRule>& result)
952 { 952 {
953 InspectorStyleSheet* inspectorStyleSheet = assertInspectorStyleSheetForId(er rorString, styleSheetId); 953 InspectorStyleSheet* inspectorStyleSheet = assertInspectorStyleSheetForId(er rorString, styleSheetId);
954 if (!inspectorStyleSheet) 954 if (!inspectorStyleSheet)
955 return; 955 return;
956 956
957 TrackExceptionState exceptionState; 957 TrackExceptionState exceptionState;
958 RefPtr<AddRuleAction> action = adoptRef(new AddRuleAction(inspectorStyleShee t, selector)); 958 RefPtrWillBeRawPtr<AddRuleAction> action = adoptRefWillBeNoop(new AddRuleAct ion(inspectorStyleSheet, selector));
959 bool success = m_domAgent->history()->perform(action, exceptionState); 959 bool success = m_domAgent->history()->perform(action, exceptionState);
960 if (!success) { 960 if (!success) {
961 *errorString = InspectorDOMAgent::toErrorString(exceptionState); 961 *errorString = InspectorDOMAgent::toErrorString(exceptionState);
962 return; 962 return;
963 } 963 }
964 964
965 InspectorCSSId ruleId = action->newRuleId(); 965 InspectorCSSId ruleId = action->newRuleId();
966 CSSStyleRule* rule = inspectorStyleSheet->ruleForId(ruleId); 966 CSSStyleRule* rule = inspectorStyleSheet->ruleForId(ruleId);
967 result = inspectorStyleSheet->buildObjectForRule(rule, buildMediaListChain(r ule)); 967 result = inspectorStyleSheet->buildObjectForRule(rule, buildMediaListChain(r ule));
968 } 968 }
(...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after
1447 documentsToChange.add(element->ownerDocument()); 1447 documentsToChange.add(element->ownerDocument());
1448 } 1448 }
1449 1449
1450 m_nodeIdToForcedPseudoState.clear(); 1450 m_nodeIdToForcedPseudoState.clear();
1451 for (HashSet<Document*>::iterator it = documentsToChange.begin(), end = docu mentsToChange.end(); it != end; ++it) 1451 for (HashSet<Document*>::iterator it = documentsToChange.begin(), end = docu mentsToChange.end(); it != end; ++it)
1452 (*it)->setNeedsStyleRecalc(SubtreeStyleChange); 1452 (*it)->setNeedsStyleRecalc(SubtreeStyleChange);
1453 } 1453 }
1454 1454
1455 } // namespace WebCore 1455 } // namespace WebCore
1456 1456
OLDNEW
« no previous file with comments | « Source/core/inspector/DOMEditor.cpp ('k') | Source/core/inspector/InspectorDOMAgent.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698