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 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 virtual bool redo(ExceptionState& exceptionState) OVERRIDE | 193 virtual bool redo(ExceptionState& exceptionState) OVERRIDE |
194 { | 194 { |
195 return m_styleSheet->setText(m_text, exceptionState); | 195 return m_styleSheet->setText(m_text, exceptionState); |
196 } | 196 } |
197 | 197 |
198 virtual String mergeId() OVERRIDE | 198 virtual String mergeId() OVERRIDE |
199 { | 199 { |
200 return String::format("SetStyleSheetText %s", m_styleSheet->id().utf8().
data()); | 200 return String::format("SetStyleSheetText %s", m_styleSheet->id().utf8().
data()); |
201 } | 201 } |
202 | 202 |
203 virtual void merge(PassRefPtr<Action> action) OVERRIDE | 203 virtual void merge(PassRefPtrWillBeRawPtr<Action> action) OVERRIDE |
204 { | 204 { |
205 ASSERT(action->mergeId() == mergeId()); | 205 ASSERT(action->mergeId() == mergeId()); |
206 | 206 |
207 SetStyleSheetTextAction* other = static_cast<SetStyleSheetTextAction*>(a
ction.get()); | 207 SetStyleSheetTextAction* other = static_cast<SetStyleSheetTextAction*>(a
ction.get()); |
208 m_text = other->m_text; | 208 m_text = other->m_text; |
209 } | 209 } |
210 | 210 |
211 private: | 211 private: |
212 RefPtr<InspectorStyleSheetBase> m_styleSheet; | 212 RefPtr<InspectorStyleSheetBase> m_styleSheet; |
213 String m_text; | 213 String m_text; |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
249 return false; | 249 return false; |
250 bool result = m_styleSheet->setPropertyText(m_cssId, m_propertyIndex, m_
text, m_overwrite, exceptionState); | 250 bool result = m_styleSheet->setPropertyText(m_cssId, m_propertyIndex, m_
text, m_overwrite, exceptionState); |
251 return result; | 251 return result; |
252 } | 252 } |
253 | 253 |
254 virtual String mergeId() OVERRIDE | 254 virtual String mergeId() OVERRIDE |
255 { | 255 { |
256 return String::format("SetPropertyText %s:%u:%s", m_styleSheet->id().utf
8().data(), m_propertyIndex, m_overwrite ? "true" : "false"); | 256 return String::format("SetPropertyText %s:%u:%s", m_styleSheet->id().utf
8().data(), m_propertyIndex, m_overwrite ? "true" : "false"); |
257 } | 257 } |
258 | 258 |
259 virtual void merge(PassRefPtr<Action> action) OVERRIDE | 259 virtual void merge(PassRefPtrWillBeRawPtr<Action> action) OVERRIDE |
260 { | 260 { |
261 ASSERT(action->mergeId() == mergeId()); | 261 ASSERT(action->mergeId() == mergeId()); |
262 | 262 |
263 SetPropertyTextAction* other = static_cast<SetPropertyTextAction*>(actio
n.get()); | 263 SetPropertyTextAction* other = static_cast<SetPropertyTextAction*>(actio
n.get()); |
264 m_text = other->m_text; | 264 m_text = other->m_text; |
265 } | 265 } |
266 | 266 |
267 private: | 267 private: |
268 RefPtr<InspectorStyleSheetBase> m_styleSheet; | 268 RefPtr<InspectorStyleSheetBase> m_styleSheet; |
269 InspectorCSSId m_cssId; | 269 InspectorCSSId m_cssId; |
(...skipping 539 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
809 | 809 |
810 void InspectorCSSAgent::setStyleSheetText(ErrorString* errorString, const String
& styleSheetId, const String& text) | 810 void InspectorCSSAgent::setStyleSheetText(ErrorString* errorString, const String
& styleSheetId, const String& text) |
811 { | 811 { |
812 InspectorStyleSheetBase* inspectorStyleSheet = assertStyleSheetForId(errorSt
ring, styleSheetId); | 812 InspectorStyleSheetBase* inspectorStyleSheet = assertStyleSheetForId(errorSt
ring, styleSheetId); |
813 if (!inspectorStyleSheet) { | 813 if (!inspectorStyleSheet) { |
814 *errorString = "Style sheet with id " + styleSheetId + " not found"; | 814 *errorString = "Style sheet with id " + styleSheetId + " not found"; |
815 return; | 815 return; |
816 } | 816 } |
817 | 817 |
818 TrackExceptionState exceptionState; | 818 TrackExceptionState exceptionState; |
819 m_domAgent->history()->perform(adoptRef(new SetStyleSheetTextAction(inspecto
rStyleSheet, text)), exceptionState); | 819 m_domAgent->history()->perform(adoptRefWillBeNoop(new SetStyleSheetTextActio
n(inspectorStyleSheet, text)), exceptionState); |
820 *errorString = InspectorDOMAgent::toErrorString(exceptionState); | 820 *errorString = InspectorDOMAgent::toErrorString(exceptionState); |
821 } | 821 } |
822 | 822 |
823 static bool extractRangeComponent(ErrorString* errorString, const RefPtr<JSONObj
ect>& range, const String& component, unsigned& result) | 823 static bool extractRangeComponent(ErrorString* errorString, const RefPtr<JSONObj
ect>& range, const String& component, unsigned& result) |
824 { | 824 { |
825 int parsedValue; | 825 int parsedValue; |
826 if (!range->getNumber(component, &parsedValue) || parsedValue < 0) { | 826 if (!range->getNumber(component, &parsedValue) || parsedValue < 0) { |
827 *errorString = "range." + component + " must be a non-negative integer"; | 827 *errorString = "range." + component + " must be a non-negative integer"; |
828 return false; | 828 return false; |
829 } | 829 } |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
871 return; | 871 return; |
872 InspectorCSSId compoundId; | 872 InspectorCSSId compoundId; |
873 unsigned propertyIndex; | 873 unsigned propertyIndex; |
874 bool overwrite; | 874 bool overwrite; |
875 if (!inspectorStyleSheet->findPropertyByRange(propertyRange, &compoundId, &p
ropertyIndex, &overwrite)) { | 875 if (!inspectorStyleSheet->findPropertyByRange(propertyRange, &compoundId, &p
ropertyIndex, &overwrite)) { |
876 *errorString = "Source range didn't match any existing property source r
ange nor any property insertion point"; | 876 *errorString = "Source range didn't match any existing property source r
ange nor any property insertion point"; |
877 return; | 877 return; |
878 } | 878 } |
879 | 879 |
880 TrackExceptionState exceptionState; | 880 TrackExceptionState exceptionState; |
881 bool success = m_domAgent->history()->perform(adoptRef(new SetPropertyTextAc
tion(inspectorStyleSheet, compoundId, propertyIndex, text, overwrite)), exceptio
nState); | 881 bool success = m_domAgent->history()->perform(adoptRefWillBeNoop(new SetProp
ertyTextAction(inspectorStyleSheet, compoundId, propertyIndex, text, overwrite))
, exceptionState); |
882 if (success) | 882 if (success) |
883 result = inspectorStyleSheet->buildObjectForStyle(inspectorStyleSheet->s
tyleForId(compoundId)); | 883 result = inspectorStyleSheet->buildObjectForStyle(inspectorStyleSheet->s
tyleForId(compoundId)); |
884 *errorString = InspectorDOMAgent::toErrorString(exceptionState); | 884 *errorString = InspectorDOMAgent::toErrorString(exceptionState); |
885 } | 885 } |
886 | 886 |
887 void InspectorCSSAgent::setRuleSelector(ErrorString* errorString, const String&
styleSheetId, const RefPtr<JSONObject>& range, const String& selector, RefPtr<Ty
peBuilder::CSS::CSSRule>& result) | 887 void InspectorCSSAgent::setRuleSelector(ErrorString* errorString, const String&
styleSheetId, const RefPtr<JSONObject>& range, const String& selector, RefPtr<Ty
peBuilder::CSS::CSSRule>& result) |
888 { | 888 { |
889 InspectorStyleSheet* inspectorStyleSheet = assertInspectorStyleSheetForId(er
rorString, styleSheetId); | 889 InspectorStyleSheet* inspectorStyleSheet = assertInspectorStyleSheetForId(er
rorString, styleSheetId); |
890 if (!inspectorStyleSheet) | 890 if (!inspectorStyleSheet) |
891 return; | 891 return; |
892 SourceRange selectorRange; | 892 SourceRange selectorRange; |
893 if (!jsonRangeToSourceRange(errorString, inspectorStyleSheet, range, &select
orRange)) | 893 if (!jsonRangeToSourceRange(errorString, inspectorStyleSheet, range, &select
orRange)) |
894 return; | 894 return; |
895 InspectorCSSId compoundId; | 895 InspectorCSSId compoundId; |
896 if (!inspectorStyleSheet->findRuleBySelectorRange(selectorRange, &compoundId
)) { | 896 if (!inspectorStyleSheet->findRuleBySelectorRange(selectorRange, &compoundId
)) { |
897 *errorString = "Source range didn't match any rule selector source range
"; | 897 *errorString = "Source range didn't match any rule selector source range
"; |
898 return; | 898 return; |
899 } | 899 } |
900 | 900 |
901 TrackExceptionState exceptionState; | 901 TrackExceptionState exceptionState; |
902 bool success = m_domAgent->history()->perform(adoptRef(new SetRuleSelectorAc
tion(inspectorStyleSheet, compoundId, selector)), exceptionState); | 902 bool success = m_domAgent->history()->perform(adoptRefWillBeNoop(new SetRule
SelectorAction(inspectorStyleSheet, compoundId, selector)), exceptionState); |
903 if (success) { | 903 if (success) { |
904 CSSStyleRule* rule = inspectorStyleSheet->ruleForId(compoundId); | 904 CSSStyleRule* rule = inspectorStyleSheet->ruleForId(compoundId); |
905 result = inspectorStyleSheet->buildObjectForRule(rule, buildMediaListCha
in(rule)); | 905 result = inspectorStyleSheet->buildObjectForRule(rule, buildMediaListCha
in(rule)); |
906 } | 906 } |
907 *errorString = InspectorDOMAgent::toErrorString(exceptionState); | 907 *errorString = InspectorDOMAgent::toErrorString(exceptionState); |
908 } | 908 } |
909 | 909 |
910 void InspectorCSSAgent::createStyleSheet(ErrorString* errorString, const String&
frameId, TypeBuilder::CSS::StyleSheetId* outStyleSheetId) | 910 void InspectorCSSAgent::createStyleSheet(ErrorString* errorString, const String&
frameId, TypeBuilder::CSS::StyleSheetId* outStyleSheetId) |
911 { | 911 { |
912 LocalFrame* frame = m_pageAgent->frameForId(frameId); | 912 LocalFrame* frame = m_pageAgent->frameForId(frameId); |
(...skipping 19 matching lines...) Expand all Loading... |
932 *outStyleSheetId = inspectorStyleSheet->id(); | 932 *outStyleSheetId = inspectorStyleSheet->id(); |
933 } | 933 } |
934 | 934 |
935 void InspectorCSSAgent::addRule(ErrorString* errorString, const String& styleShe
etId, const String& selector, RefPtr<TypeBuilder::CSS::CSSRule>& result) | 935 void InspectorCSSAgent::addRule(ErrorString* errorString, const String& styleShe
etId, const String& selector, RefPtr<TypeBuilder::CSS::CSSRule>& result) |
936 { | 936 { |
937 InspectorStyleSheet* inspectorStyleSheet = assertInspectorStyleSheetForId(er
rorString, styleSheetId); | 937 InspectorStyleSheet* inspectorStyleSheet = assertInspectorStyleSheetForId(er
rorString, styleSheetId); |
938 if (!inspectorStyleSheet) | 938 if (!inspectorStyleSheet) |
939 return; | 939 return; |
940 | 940 |
941 TrackExceptionState exceptionState; | 941 TrackExceptionState exceptionState; |
942 RefPtr<AddRuleAction> action = adoptRef(new AddRuleAction(inspectorStyleShee
t, selector)); | 942 RefPtrWillBeRawPtr<AddRuleAction> action = adoptRefWillBeNoop(new AddRuleAct
ion(inspectorStyleSheet, selector)); |
943 bool success = m_domAgent->history()->perform(action, exceptionState); | 943 bool success = m_domAgent->history()->perform(action, exceptionState); |
944 if (!success) { | 944 if (!success) { |
945 *errorString = InspectorDOMAgent::toErrorString(exceptionState); | 945 *errorString = InspectorDOMAgent::toErrorString(exceptionState); |
946 return; | 946 return; |
947 } | 947 } |
948 | 948 |
949 InspectorCSSId ruleId = action->newRuleId(); | 949 InspectorCSSId ruleId = action->newRuleId(); |
950 CSSStyleRule* rule = inspectorStyleSheet->ruleForId(ruleId); | 950 CSSStyleRule* rule = inspectorStyleSheet->ruleForId(ruleId); |
951 result = inspectorStyleSheet->buildObjectForRule(rule, buildMediaListChain(r
ule)); | 951 result = inspectorStyleSheet->buildObjectForRule(rule, buildMediaListChain(r
ule)); |
952 } | 952 } |
(...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1387 documentsToChange.add(element->ownerDocument()); | 1387 documentsToChange.add(element->ownerDocument()); |
1388 } | 1388 } |
1389 | 1389 |
1390 m_nodeIdToForcedPseudoState.clear(); | 1390 m_nodeIdToForcedPseudoState.clear(); |
1391 for (HashSet<Document*>::iterator it = documentsToChange.begin(), end = docu
mentsToChange.end(); it != end; ++it) | 1391 for (HashSet<Document*>::iterator it = documentsToChange.begin(), end = docu
mentsToChange.end(); it != end; ++it) |
1392 (*it)->setNeedsStyleRecalc(SubtreeStyleChange); | 1392 (*it)->setNeedsStyleRecalc(SubtreeStyleChange); |
1393 } | 1393 } |
1394 | 1394 |
1395 } // namespace WebCore | 1395 } // namespace WebCore |
1396 | 1396 |
OLD | NEW |