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

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

Issue 172593003: DevTools: [CSS] Add CSS.editRangeInStyleSheetText() to the protocol (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 10 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
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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 #include "core/rendering/RenderObject.h" 65 #include "core/rendering/RenderObject.h"
66 #include "core/rendering/RenderText.h" 66 #include "core/rendering/RenderText.h"
67 #include "core/rendering/RenderTextFragment.h" 67 #include "core/rendering/RenderTextFragment.h"
68 #include "platform/fonts/Font.h" 68 #include "platform/fonts/Font.h"
69 #include "platform/fonts/GlyphBuffer.h" 69 #include "platform/fonts/GlyphBuffer.h"
70 #include "platform/fonts/WidthIterator.h" 70 #include "platform/fonts/WidthIterator.h"
71 #include "platform/text/TextRun.h" 71 #include "platform/text/TextRun.h"
72 #include "wtf/CurrentTime.h" 72 #include "wtf/CurrentTime.h"
73 #include "wtf/text/CString.h" 73 #include "wtf/text/CString.h"
74 #include "wtf/text/StringConcatenate.h" 74 #include "wtf/text/StringConcatenate.h"
75 #include "wtf/text/TextPosition.h"
apavlov 2014/02/20 09:58:14 This should not be here
lushnikov 2014/02/20 14:17:04 Done.
75 76
76 namespace CSSAgentState { 77 namespace CSSAgentState {
77 static const char cssAgentEnabled[] = "cssAgentEnabled"; 78 static const char cssAgentEnabled[] = "cssAgentEnabled";
78 } 79 }
79 80
80 typedef WebCore::InspectorBackendDispatcher::CSSCommandHandler::EnableCallback E nableCallback; 81 typedef WebCore::InspectorBackendDispatcher::CSSCommandHandler::EnableCallback E nableCallback;
81 82
82 namespace WebCore { 83 namespace WebCore {
83 84
84 enum ForcePseudoClassFlags { 85 enum ForcePseudoClassFlags {
(...skipping 745 matching lines...) Expand 10 before | Expand all | Expand 10 after
830 if (!inspectorStyleSheet) { 831 if (!inspectorStyleSheet) {
831 *errorString = "Style sheet with id " + styleSheetId + " not found."; 832 *errorString = "Style sheet with id " + styleSheetId + " not found.";
832 return; 833 return;
833 } 834 }
834 835
835 TrackExceptionState exceptionState; 836 TrackExceptionState exceptionState;
836 m_domAgent->history()->perform(adoptPtr(new SetStyleSheetTextAction(inspecto rStyleSheet, text)), exceptionState); 837 m_domAgent->history()->perform(adoptPtr(new SetStyleSheetTextAction(inspecto rStyleSheet, text)), exceptionState);
837 *errorString = InspectorDOMAgent::toErrorString(exceptionState); 838 *errorString = InspectorDOMAgent::toErrorString(exceptionState);
838 } 839 }
839 840
841 void InspectorCSSAgent::replaceRangeInStyleSheetText(ErrorString* errorString, c onst String& styleSheetId, const RefPtr<JSONObject>& range, const String& text)
apavlov 2014/02/20 09:58:14 Is this going to be an undoable operation, like th
pfeldman 2014/02/20 11:29:05 editRangeInStyleSheetText?
lushnikov 2014/02/20 14:17:04 This is essentially a wrapper around setStyleSheet
lushnikov 2014/02/20 14:17:04 Done.
842 {
843 InspectorStyleSheet* inspectorStyleSheet = assertStyleSheetForId(errorString , styleSheetId);
844 if (!inspectorStyleSheet) {
845 *errorString = "Style sheet with id " + styleSheetId + " not found.";
apavlov 2014/02/20 09:58:14 We have a convention to never place periods at the
lushnikov 2014/02/20 14:17:04 Done.
846 return;
847 }
848 int startLineNumber;
849 int startColumn;
850 int endLineNumber;
851 int endColumn;
852 if (!range->getNumber("startLine", &startLineNumber)) {
853 *errorString = "range.startLine is not an integer value.";
854 return;
855 }
856 if (!range->getNumber("startColumn", &startColumn)) {
857 *errorString = "range.startColumn is not an integer value.";
858 return;
859 }
860 if (!range->getNumber("endLine", &endLineNumber)) {
861 *errorString = "range.endLine is not an integer value.";
862 return;
863 }
864 if (!range->getNumber("endColumn", &endColumn)) {
865 *errorString = "range.endColumn is not an integer value.";
866 return;
867 }
868 String oldText;
869 if (!inspectorStyleSheet->getText(&oldText)) {
870 *errorString = "Failed to fetch stylesheet text.";
871 return;
872 }
873
874 TextPosition startPosition(OrdinalNumber::fromZeroBasedInt(startLineNumber), OrdinalNumber::fromZeroBasedInt(startColumn));
apavlov 2014/02/20 09:58:14 This code doesn't seem to belong to ICSSAgent (for
lushnikov 2014/02/20 14:17:04 InspectorStyleSheet soaked all the logic in its li
875 TextPosition endPosition(OrdinalNumber::fromZeroBasedInt(endLineNumber), Ord inalNumber::fromZeroBasedInt(endColumn));
876 OwnPtr<Vector<unsigned> > lineEndings = inspectorStyleSheet->lineEndings();
877 int startOffset = startPosition.toOffsetPosition(*lineEndings.get()).zeroBas edInt();
apavlov 2014/02/20 09:58:14 You don't need .get() here, just (*lineEndings)
lushnikov 2014/02/20 14:17:04 Done.
878 int endOffset = endPosition.toOffsetPosition(*lineEndings.get()).zeroBasedIn t();
apavlov 2014/02/20 09:58:14 ditto
lushnikov 2014/02/20 14:17:04 Done.
879 oldText.replace(startOffset, endOffset - startOffset, text);
880 setStyleSheetText(errorString, styleSheetId, oldText);
881 }
882
840 void InspectorCSSAgent::setPropertyText(ErrorString* errorString, const RefPtr<J SONObject>& fullStyleId, int propertyIndex, const String& text, bool overwrite, RefPtr<TypeBuilder::CSS::CSSStyle>& result) 883 void InspectorCSSAgent::setPropertyText(ErrorString* errorString, const RefPtr<J SONObject>& fullStyleId, int propertyIndex, const String& text, bool overwrite, RefPtr<TypeBuilder::CSS::CSSStyle>& result)
841 { 884 {
842 InspectorCSSId compoundId(fullStyleId); 885 InspectorCSSId compoundId(fullStyleId);
843 ASSERT(!compoundId.isEmpty()); 886 ASSERT(!compoundId.isEmpty());
844 887
845 InspectorStyleSheet* inspectorStyleSheet = assertStyleSheetForId(errorString , compoundId.styleSheetId()); 888 InspectorStyleSheet* inspectorStyleSheet = assertStyleSheetForId(errorString , compoundId.styleSheetId());
846 if (!inspectorStyleSheet) 889 if (!inspectorStyleSheet)
847 return; 890 return;
848 891
849 TrackExceptionState exceptionState; 892 TrackExceptionState exceptionState;
(...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after
1320 documentsToChange.add(element->ownerDocument()); 1363 documentsToChange.add(element->ownerDocument());
1321 } 1364 }
1322 1365
1323 m_nodeIdToForcedPseudoState.clear(); 1366 m_nodeIdToForcedPseudoState.clear();
1324 for (HashSet<Document*>::iterator it = documentsToChange.begin(), end = docu mentsToChange.end(); it != end; ++it) 1367 for (HashSet<Document*>::iterator it = documentsToChange.begin(), end = docu mentsToChange.end(); it != end; ++it)
1325 (*it)->setNeedsStyleRecalc(SubtreeStyleChange); 1368 (*it)->setNeedsStyleRecalc(SubtreeStyleChange);
1326 } 1369 }
1327 1370
1328 } // namespace WebCore 1371 } // namespace WebCore
1329 1372
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698