Chromium Code Reviews| 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"; | |
|
apavlov
2014/02/21 14:37:55
"Stylesheet" ?
lushnikov
2014/02/23 16:07:07
Done.
| |
| 845 return; | |
| 846 } | |
| 847 int startLineNumber; | |
| 848 int startColumn; | |
| 849 int endLineNumber; | |
| 850 int endColumn; | |
| 851 if (!range->getNumber("startLine", &startLineNumber)) { | |
|
apavlov
2014/02/21 14:37:55
This could be extracted:
static bool rangeCompone
lushnikov
2014/02/23 16:07:07
Done.
lushnikov
2014/02/23 16:07:07
Done.
| |
| 852 *errorString = "range.startLine must be an integer value"; | |
|
apavlov
2014/02/21 14:37:55
"...must be an integer" is sufficient (since "inte
lushnikov
2014/02/23 16:07:07
Done.
| |
| 853 return; | |
| 854 } | |
| 855 if (!range->getNumber("startColumn", &startColumn)) { | |
| 856 *errorString = "range.startColumn must be an integer value"; | |
| 857 return; | |
| 858 } | |
| 859 if (!range->getNumber("endLine", &endLineNumber)) { | |
| 860 *errorString = "range.endLine must be an integer value"; | |
| 861 return; | |
| 862 } | |
| 863 if (!range->getNumber("endColumn", &endColumn)) { | |
| 864 *errorString = "range.endColumn must be an integer value"; | |
| 865 return; | |
| 866 } | |
| 867 if (startLineNumber < 0 || startColumn < 0 || endLineNumber < 0 || endColumn < 0) { | |
| 868 *errorString = "Range parameters must be non-negative integer values"; | |
| 869 return; | |
| 870 } | |
| 871 String oldText; | |
| 872 if (!inspectorStyleSheet->getText(&oldText)) { | |
| 873 *errorString = "Failed to fetch stylesheet text"; | |
| 874 return; | |
| 875 } | |
| 876 | |
| 877 unsigned startOffset; | |
| 878 unsigned endOffset; | |
| 879 bool successConvertion = inspectorStyleSheet->lineNumberAndColumnToOffset(st artLineNumber, startColumn, &startOffset); | |
|
apavlov
2014/02/21 14:37:55
successConvertion -> success (or something along t
lushnikov
2014/02/23 16:07:07
Done.
| |
| 880 successConvertion = successConvertion && inspectorStyleSheet->lineNumberAndC olumnToOffset(endLineNumber, endColumn, &endOffset); | |
|
apavlov
2014/02/21 14:37:55
if (successConversion)
successConversion = ...
lushnikov
2014/02/23 16:07:07
This is essentially the same due-to "&&" operation
| |
| 881 if (!successConvertion || startOffset > oldText.length() || endOffset > oldT ext.length()) { | |
|
apavlov
2014/02/21 14:37:55
it does not make any sense to extract a part of li
lushnikov
2014/02/23 16:07:07
Done.
| |
| 882 *errorString = "Specified range is out of bounds"; | |
| 883 return; | |
| 884 } | |
| 885 | |
| 886 if (startOffset > endOffset) { | |
| 887 *errorString = "Range start must preceed its end"; | |
|
apavlov
2014/02/21 14:37:55
"precede"
or, better yet,
"Range start must not
lushnikov
2014/02/23 16:07:07
Done.
| |
| 888 return; | |
| 889 } | |
| 890 | |
| 891 oldText.replace(startOffset, endOffset - startOffset, text); | |
| 892 setStyleSheetText(errorString, styleSheetId, oldText); | |
| 893 } | |
| 894 | |
| 840 void InspectorCSSAgent::setPropertyText(ErrorString* errorString, const RefPtr<J SONObject>& fullStyleId, int propertyIndex, const String& text, bool overwrite, RefPtr<TypeBuilder::CSS::CSSStyle>& result) | 895 void InspectorCSSAgent::setPropertyText(ErrorString* errorString, const RefPtr<J SONObject>& fullStyleId, int propertyIndex, const String& text, bool overwrite, RefPtr<TypeBuilder::CSS::CSSStyle>& result) |
| 841 { | 896 { |
| 842 InspectorCSSId compoundId(fullStyleId); | 897 InspectorCSSId compoundId(fullStyleId); |
| 843 ASSERT(!compoundId.isEmpty()); | 898 ASSERT(!compoundId.isEmpty()); |
| 844 | 899 |
| 845 InspectorStyleSheet* inspectorStyleSheet = assertStyleSheetForId(errorString , compoundId.styleSheetId()); | 900 InspectorStyleSheet* inspectorStyleSheet = assertStyleSheetForId(errorString , compoundId.styleSheetId()); |
| 846 if (!inspectorStyleSheet) | 901 if (!inspectorStyleSheet) |
| 847 return; | 902 return; |
| 848 | 903 |
| 849 TrackExceptionState exceptionState; | 904 TrackExceptionState exceptionState; |
| (...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1320 documentsToChange.add(element->ownerDocument()); | 1375 documentsToChange.add(element->ownerDocument()); |
| 1321 } | 1376 } |
| 1322 | 1377 |
| 1323 m_nodeIdToForcedPseudoState.clear(); | 1378 m_nodeIdToForcedPseudoState.clear(); |
| 1324 for (HashSet<Document*>::iterator it = documentsToChange.begin(), end = docu mentsToChange.end(); it != end; ++it) | 1379 for (HashSet<Document*>::iterator it = documentsToChange.begin(), end = docu mentsToChange.end(); it != end; ++it) |
| 1325 (*it)->setNeedsStyleRecalc(SubtreeStyleChange); | 1380 (*it)->setNeedsStyleRecalc(SubtreeStyleChange); |
| 1326 } | 1381 } |
| 1327 | 1382 |
| 1328 } // namespace WebCore | 1383 } // namespace WebCore |
| 1329 | 1384 |
| OLD | NEW |