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

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

Issue 216553004: [Oilpan]: Move CSSPropertySourceData, InspectorStyleProperty, CSSStyleSourceData, and CSSRuleSource… (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase + plugin finds Created 6 years, 8 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
« no previous file with comments | « Source/core/inspector/InspectorStyleTextEditor.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011, Google Inc. All rights reserved. 2 * Copyright (C) 2011, 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 13 matching lines...) Expand all
24 24
25 #include "config.h" 25 #include "config.h"
26 #include "core/inspector/InspectorStyleTextEditor.h" 26 #include "core/inspector/InspectorStyleTextEditor.h"
27 27
28 #include "core/css/CSSPropertySourceData.h" 28 #include "core/css/CSSPropertySourceData.h"
29 #include "core/html/parser/HTMLParserIdioms.h" 29 #include "core/html/parser/HTMLParserIdioms.h"
30 #include "core/inspector/InspectorStyleSheet.h" 30 #include "core/inspector/InspectorStyleSheet.h"
31 31
32 namespace WebCore { 32 namespace WebCore {
33 33
34 InspectorStyleTextEditor::InspectorStyleTextEditor(Vector<InspectorStyleProperty >* allProperties, const String& styleText, const NewLineAndWhitespace& format) 34 InspectorStyleTextEditor::InspectorStyleTextEditor(WillBeHeapVector<InspectorSty leProperty>* allProperties, const String& styleText, const NewLineAndWhitespace& format)
35 : m_allProperties(allProperties) 35 : m_allProperties(allProperties)
36 , m_styleText(styleText) 36 , m_styleText(styleText)
37 , m_format(format) 37 , m_format(format)
38 { 38 {
39 } 39 }
40 40
41 void InspectorStyleTextEditor::insertProperty(unsigned index, const String& prop ertyText, unsigned styleBodyLength) 41 void InspectorStyleTextEditor::insertProperty(unsigned index, const String& prop ertyText, unsigned styleBodyLength)
42 { 42 {
43 long propertyStart = 0; 43 long propertyStart = 0;
44 44
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 } 103 }
104 m_styleText.insert(textToSet, propertyStart); 104 m_styleText.insert(textToSet, propertyStart);
105 } 105 }
106 106
107 void InspectorStyleTextEditor::replaceProperty(unsigned index, const String& new Text) 107 void InspectorStyleTextEditor::replaceProperty(unsigned index, const String& new Text)
108 { 108 {
109 ASSERT_WITH_SECURITY_IMPLICATION(index < m_allProperties->size()); 109 ASSERT_WITH_SECURITY_IMPLICATION(index < m_allProperties->size());
110 internalReplaceProperty(m_allProperties->at(index), newText); 110 internalReplaceProperty(m_allProperties->at(index), newText);
111 } 111 }
112 112
113 void InspectorStyleTextEditor::removeProperty(unsigned index)
114 {
115 replaceProperty(index, "");
116 }
117
118 void InspectorStyleTextEditor::internalReplaceProperty(const InspectorStylePrope rty& property, const String& newText) 113 void InspectorStyleTextEditor::internalReplaceProperty(const InspectorStylePrope rty& property, const String& newText)
119 { 114 {
120 const SourceRange& range = property.sourceData.range; 115 const SourceRange& range = property.sourceData.range;
121 long replaceRangeStart = range.start; 116 long replaceRangeStart = range.start;
122 long replaceRangeEnd = range.end; 117 long replaceRangeEnd = range.end;
123 long newTextLength = newText.length(); 118 long newTextLength = newText.length();
124 String finalNewText = newText; 119 String finalNewText = newText;
125 120
126 // Removing a property - remove preceding prefix. 121 // Removing a property - remove preceding prefix.
127 String fullPrefix = m_format.first + m_format.second; 122 String fullPrefix = m_format.first + m_format.second;
(...skipping 24 matching lines...) Expand all
152 if (fullPrefixLength > replaceRangeStart || m_styleText.substring(replac eRangeStart - fullPrefixLength, fullPrefixLength) != fullPrefix) 147 if (fullPrefixLength > replaceRangeStart || m_styleText.substring(replac eRangeStart - fullPrefixLength, fullPrefixLength) != fullPrefix)
153 finalNewText.insert(fullPrefix, 0); 148 finalNewText.insert(fullPrefix, 0);
154 } 149 }
155 150
156 int replacedLength = replaceRangeEnd - replaceRangeStart; 151 int replacedLength = replaceRangeEnd - replaceRangeStart;
157 m_styleText.replace(replaceRangeStart, replacedLength, finalNewText); 152 m_styleText.replace(replaceRangeStart, replacedLength, finalNewText);
158 } 153 }
159 154
160 } // namespace WebCore 155 } // namespace WebCore
161 156
OLDNEW
« no previous file with comments | « Source/core/inspector/InspectorStyleTextEditor.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698