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(PassOwnPtr<Action> action) OVERRIDE | 203 virtual void merge(PassRefPtr<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 bool result = m_styleSheet->setPropertyText(m_cssId, m_propertyIndex, m_
text, m_overwrite, &oldText, exceptionState); | 249 bool result = m_styleSheet->setPropertyText(m_cssId, m_propertyIndex, m_
text, m_overwrite, &oldText, exceptionState); |
250 m_oldText = oldText.stripWhiteSpace(); | 250 m_oldText = oldText.stripWhiteSpace(); |
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(PassOwnPtr<Action> action) OVERRIDE | 259 virtual void merge(PassRefPtr<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 555 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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(adoptPtr(new SetStyleSheetTextAction(inspecto
rStyleSheet, text)), exceptionState); | 835 m_domAgent->history()->perform(adoptRef(new SetStyleSheetTextAction(inspecto
rStyleSheet, text)), exceptionState); |
836 *errorString = InspectorDOMAgent::toErrorString(exceptionState); | 836 *errorString = InspectorDOMAgent::toErrorString(exceptionState); |
837 } | 837 } |
838 | 838 |
839 void InspectorCSSAgent::setPropertyText(ErrorString* errorString, const RefPtr<J
SONObject>& fullStyleId, int propertyIndex, const String& text, bool overwrite,
RefPtr<TypeBuilder::CSS::CSSStyle>& result) | 839 void InspectorCSSAgent::setPropertyText(ErrorString* errorString, const RefPtr<J
SONObject>& fullStyleId, int propertyIndex, const String& text, bool overwrite,
RefPtr<TypeBuilder::CSS::CSSStyle>& result) |
840 { | 840 { |
841 InspectorCSSId compoundId(fullStyleId); | 841 InspectorCSSId compoundId(fullStyleId); |
842 ASSERT(!compoundId.isEmpty()); | 842 ASSERT(!compoundId.isEmpty()); |
843 | 843 |
844 InspectorStyleSheetBase* inspectorStyleSheet = assertStyleSheetForId(errorSt
ring, compoundId.styleSheetId()); | 844 InspectorStyleSheetBase* inspectorStyleSheet = assertStyleSheetForId(errorSt
ring, compoundId.styleSheetId()); |
845 if (!inspectorStyleSheet) | 845 if (!inspectorStyleSheet) |
846 return; | 846 return; |
847 | 847 |
848 TrackExceptionState exceptionState; | 848 TrackExceptionState exceptionState; |
849 bool success = m_domAgent->history()->perform(adoptPtr(new SetPropertyTextAc
tion(inspectorStyleSheet, compoundId, propertyIndex, text, overwrite)), exceptio
nState); | 849 bool success = m_domAgent->history()->perform(adoptRef(new SetPropertyTextAc
tion(inspectorStyleSheet, compoundId, propertyIndex, text, overwrite)), exceptio
nState); |
850 if (success) | 850 if (success) |
851 result = inspectorStyleSheet->buildObjectForStyle(inspectorStyleSheet->s
tyleForId(compoundId)); | 851 result = inspectorStyleSheet->buildObjectForStyle(inspectorStyleSheet->s
tyleForId(compoundId)); |
852 *errorString = InspectorDOMAgent::toErrorString(exceptionState); | 852 *errorString = InspectorDOMAgent::toErrorString(exceptionState); |
853 } | 853 } |
854 | 854 |
855 void InspectorCSSAgent::setRuleSelector(ErrorString* errorString, const RefPtr<J
SONObject>& fullRuleId, const String& selector, RefPtr<TypeBuilder::CSS::CSSRule
>& result) | 855 void InspectorCSSAgent::setRuleSelector(ErrorString* errorString, const RefPtr<J
SONObject>& fullRuleId, const String& selector, RefPtr<TypeBuilder::CSS::CSSRule
>& result) |
856 { | 856 { |
857 InspectorCSSId compoundId(fullRuleId); | 857 InspectorCSSId compoundId(fullRuleId); |
858 ASSERT(!compoundId.isEmpty()); | 858 ASSERT(!compoundId.isEmpty()); |
859 | 859 |
860 InspectorStyleSheet* inspectorStyleSheet = assertInspectorStyleSheetForId(er
rorString, compoundId.styleSheetId()); | 860 InspectorStyleSheet* inspectorStyleSheet = assertInspectorStyleSheetForId(er
rorString, compoundId.styleSheetId()); |
861 if (!inspectorStyleSheet) | 861 if (!inspectorStyleSheet) |
862 return; | 862 return; |
863 | 863 |
864 TrackExceptionState exceptionState; | 864 TrackExceptionState exceptionState; |
865 bool success = m_domAgent->history()->perform(adoptPtr(new SetRuleSelectorAc
tion(inspectorStyleSheet, compoundId, selector)), exceptionState); | 865 bool success = m_domAgent->history()->perform(adoptRef(new SetRuleSelectorAc
tion(inspectorStyleSheet, compoundId, selector)), exceptionState); |
866 | 866 |
867 if (success) { | 867 if (success) { |
868 CSSStyleRule* rule = inspectorStyleSheet->ruleForId(compoundId); | 868 CSSStyleRule* rule = inspectorStyleSheet->ruleForId(compoundId); |
869 result = inspectorStyleSheet->buildObjectForRule(rule, buildMediaListCha
in(rule)); | 869 result = inspectorStyleSheet->buildObjectForRule(rule, buildMediaListCha
in(rule)); |
870 } | 870 } |
871 *errorString = InspectorDOMAgent::toErrorString(exceptionState); | 871 *errorString = InspectorDOMAgent::toErrorString(exceptionState); |
872 } | 872 } |
873 | 873 |
874 void InspectorCSSAgent::createStyleSheet(ErrorString* errorString, const String&
frameId, TypeBuilder::CSS::StyleSheetId* outStyleSheetId) | 874 void InspectorCSSAgent::createStyleSheet(ErrorString* errorString, const String&
frameId, TypeBuilder::CSS::StyleSheetId* outStyleSheetId) |
875 { | 875 { |
(...skipping 20 matching lines...) Expand all Loading... |
896 *outStyleSheetId = inspectorStyleSheet->id(); | 896 *outStyleSheetId = inspectorStyleSheet->id(); |
897 } | 897 } |
898 | 898 |
899 void InspectorCSSAgent::addRule(ErrorString* errorString, const String& styleShe
etId, const String& selector, RefPtr<TypeBuilder::CSS::CSSRule>& result) | 899 void InspectorCSSAgent::addRule(ErrorString* errorString, const String& styleShe
etId, const String& selector, RefPtr<TypeBuilder::CSS::CSSRule>& result) |
900 { | 900 { |
901 InspectorStyleSheet* inspectorStyleSheet = assertInspectorStyleSheetForId(er
rorString, styleSheetId); | 901 InspectorStyleSheet* inspectorStyleSheet = assertInspectorStyleSheetForId(er
rorString, styleSheetId); |
902 if (!inspectorStyleSheet) | 902 if (!inspectorStyleSheet) |
903 return; | 903 return; |
904 | 904 |
905 TrackExceptionState exceptionState; | 905 TrackExceptionState exceptionState; |
906 OwnPtr<AddRuleAction> action = adoptPtr(new AddRuleAction(inspectorStyleShee
t, selector)); | 906 RefPtr<AddRuleAction> action = adoptRef(new AddRuleAction(inspectorStyleShee
t, selector)); |
907 AddRuleAction* rawAction = action.get(); | 907 bool success = m_domAgent->history()->perform(action, exceptionState); |
908 bool success = m_domAgent->history()->perform(action.release(), exceptionSta
te); | |
909 if (!success) { | 908 if (!success) { |
910 *errorString = InspectorDOMAgent::toErrorString(exceptionState); | 909 *errorString = InspectorDOMAgent::toErrorString(exceptionState); |
911 return; | 910 return; |
912 } | 911 } |
913 | 912 |
914 InspectorCSSId ruleId = rawAction->newRuleId(); | 913 InspectorCSSId ruleId = action->newRuleId(); |
915 CSSStyleRule* rule = inspectorStyleSheet->ruleForId(ruleId); | 914 CSSStyleRule* rule = inspectorStyleSheet->ruleForId(ruleId); |
916 result = inspectorStyleSheet->buildObjectForRule(rule, buildMediaListChain(r
ule)); | 915 result = inspectorStyleSheet->buildObjectForRule(rule, buildMediaListChain(r
ule)); |
917 } | 916 } |
918 | 917 |
919 void InspectorCSSAgent::forcePseudoState(ErrorString* errorString, int nodeId, c
onst RefPtr<JSONArray>& forcedPseudoClasses) | 918 void InspectorCSSAgent::forcePseudoState(ErrorString* errorString, int nodeId, c
onst RefPtr<JSONArray>& forcedPseudoClasses) |
920 { | 919 { |
921 Element* element = m_domAgent->assertElement(errorString, nodeId); | 920 Element* element = m_domAgent->assertElement(errorString, nodeId); |
922 if (!element) | 921 if (!element) |
923 return; | 922 return; |
924 | 923 |
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1352 documentsToChange.add(element->ownerDocument()); | 1351 documentsToChange.add(element->ownerDocument()); |
1353 } | 1352 } |
1354 | 1353 |
1355 m_nodeIdToForcedPseudoState.clear(); | 1354 m_nodeIdToForcedPseudoState.clear(); |
1356 for (HashSet<Document*>::iterator it = documentsToChange.begin(), end = docu
mentsToChange.end(); it != end; ++it) | 1355 for (HashSet<Document*>::iterator it = documentsToChange.begin(), end = docu
mentsToChange.end(); it != end; ++it) |
1357 (*it)->setNeedsStyleRecalc(SubtreeStyleChange); | 1356 (*it)->setNeedsStyleRecalc(SubtreeStyleChange); |
1358 } | 1357 } |
1359 | 1358 |
1360 } // namespace WebCore | 1359 } // namespace WebCore |
1361 | 1360 |
OLD | NEW |