| 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 810 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 821 if (!inspectorStyleSheet) | 821 if (!inspectorStyleSheet) |
| 822 return; | 822 return; |
| 823 | 823 |
| 824 inspectorStyleSheet->getText(result); | 824 inspectorStyleSheet->getText(result); |
| 825 } | 825 } |
| 826 | 826 |
| 827 void InspectorCSSAgent::setStyleSheetText(ErrorString* errorString, const String
& styleSheetId, const String& text) | 827 void InspectorCSSAgent::setStyleSheetText(ErrorString* errorString, const String
& styleSheetId, const String& text) |
| 828 { | 828 { |
| 829 InspectorStyleSheet* inspectorStyleSheet = assertStyleSheetForId(errorString
, styleSheetId); | 829 InspectorStyleSheet* inspectorStyleSheet = assertStyleSheetForId(errorString
, styleSheetId); |
| 830 if (!inspectorStyleSheet) { | 830 if (!inspectorStyleSheet) { |
| 831 *errorString = "Style sheet with id " + styleSheetId + " not found."; | 831 *errorString = "Style sheet with id " + styleSheetId + " not found"; |
| 832 return; | 832 return; |
| 833 } | 833 } |
| 834 | 834 |
| 835 TrackExceptionState exceptionState; | 835 TrackExceptionState exceptionState; |
| 836 m_domAgent->history()->perform(adoptPtr(new SetStyleSheetTextAction(inspecto
rStyleSheet, text)), exceptionState); | 836 m_domAgent->history()->perform(adoptPtr(new SetStyleSheetTextAction(inspecto
rStyleSheet, text)), exceptionState); |
| 837 *errorString = InspectorDOMAgent::toErrorString(exceptionState); | 837 *errorString = InspectorDOMAgent::toErrorString(exceptionState); |
| 838 } | 838 } |
| 839 | 839 |
| 840 void InspectorCSSAgent::editRangeInStyleSheetText(ErrorString* errorString, cons
t String& styleSheetId, const RefPtr<JSONObject>& range, const String& text) |
| 841 { |
| 842 InspectorStyleSheet* inspectorStyleSheet = assertStyleSheetForId(errorString
, styleSheetId); |
| 843 if (!inspectorStyleSheet) { |
| 844 *errorString = "Style sheet with id " + styleSheetId + " not found"; |
| 845 return; |
| 846 } |
| 847 int startLineNumber; |
| 848 int startColumn; |
| 849 int endLineNumber; |
| 850 int endColumn; |
| 851 if (!range->getNumber("startLine", &startLineNumber)) { |
| 852 *errorString = "range.startLine is not an integer value"; |
| 853 return; |
| 854 } |
| 855 if (!range->getNumber("startColumn", &startColumn)) { |
| 856 *errorString = "range.startColumn is not an integer value"; |
| 857 return; |
| 858 } |
| 859 if (!range->getNumber("endLine", &endLineNumber)) { |
| 860 *errorString = "range.endLine is not an integer value"; |
| 861 return; |
| 862 } |
| 863 if (!range->getNumber("endColumn", &endColumn)) { |
| 864 *errorString = "range.endColumn is not an integer value"; |
| 865 return; |
| 866 } |
| 867 String oldText; |
| 868 if (!inspectorStyleSheet->getText(&oldText)) { |
| 869 *errorString = "Failed to fetch stylesheet text"; |
| 870 return; |
| 871 } |
| 872 |
| 873 unsigned startOffset; |
| 874 unsigned endOffset; |
| 875 bool successConvertion = inspectorStyleSheet->lineNumberAndColumnToOffset(st
artLineNumber, startColumn, &startOffset); |
| 876 successConvertion = successConvertion && inspectorStyleSheet->lineNumberAndC
olumnToOffset(endLineNumber, endColumn, &endOffset); |
| 877 if (!successConvertion || startOffset > oldText.length() || endOffset > oldT
ext.length()) { |
| 878 *errorString = "Specified range is out of bounds"; |
| 879 return; |
| 880 } |
| 881 |
| 882 if (startOffset > endOffset) { |
| 883 *errorString = "Range start must preceed its end"; |
| 884 return; |
| 885 } |
| 886 |
| 887 oldText.replace(startOffset, endOffset - startOffset, text); |
| 888 setStyleSheetText(errorString, styleSheetId, oldText); |
| 889 } |
| 890 |
| 840 void InspectorCSSAgent::setPropertyText(ErrorString* errorString, const RefPtr<J
SONObject>& fullStyleId, int propertyIndex, const String& text, bool overwrite,
RefPtr<TypeBuilder::CSS::CSSStyle>& result) | 891 void InspectorCSSAgent::setPropertyText(ErrorString* errorString, const RefPtr<J
SONObject>& fullStyleId, int propertyIndex, const String& text, bool overwrite,
RefPtr<TypeBuilder::CSS::CSSStyle>& result) |
| 841 { | 892 { |
| 842 InspectorCSSId compoundId(fullStyleId); | 893 InspectorCSSId compoundId(fullStyleId); |
| 843 ASSERT(!compoundId.isEmpty()); | 894 ASSERT(!compoundId.isEmpty()); |
| 844 | 895 |
| 845 InspectorStyleSheet* inspectorStyleSheet = assertStyleSheetForId(errorString
, compoundId.styleSheetId()); | 896 InspectorStyleSheet* inspectorStyleSheet = assertStyleSheetForId(errorString
, compoundId.styleSheetId()); |
| 846 if (!inspectorStyleSheet) | 897 if (!inspectorStyleSheet) |
| 847 return; | 898 return; |
| 848 | 899 |
| 849 TrackExceptionState exceptionState; | 900 TrackExceptionState exceptionState; |
| (...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1320 documentsToChange.add(element->ownerDocument()); | 1371 documentsToChange.add(element->ownerDocument()); |
| 1321 } | 1372 } |
| 1322 | 1373 |
| 1323 m_nodeIdToForcedPseudoState.clear(); | 1374 m_nodeIdToForcedPseudoState.clear(); |
| 1324 for (HashSet<Document*>::iterator it = documentsToChange.begin(), end = docu
mentsToChange.end(); it != end; ++it) | 1375 for (HashSet<Document*>::iterator it = documentsToChange.begin(), end = docu
mentsToChange.end(); it != end; ++it) |
| 1325 (*it)->setNeedsStyleRecalc(SubtreeStyleChange); | 1376 (*it)->setNeedsStyleRecalc(SubtreeStyleChange); |
| 1326 } | 1377 } |
| 1327 | 1378 |
| 1328 } // namespace WebCore | 1379 } // namespace WebCore |
| 1329 | 1380 |
| OLD | NEW |