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

Side by Side Diff: Source/bindings/v8/V8StringResource.cpp

Issue 90093002: V8StringResource's v8StringToWebCoreString() should return a StringType (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years 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 | « no previous file | 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) 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2009 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 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 if (encoding == v8::String::ONE_BYTE_ENCODING) 141 if (encoding == v8::String::ONE_BYTE_ENCODING)
142 base = static_cast<WebCoreStringResource8*>(resource); 142 base = static_cast<WebCoreStringResource8*>(resource);
143 else 143 else
144 base = static_cast<WebCoreStringResource16*>(resource); 144 base = static_cast<WebCoreStringResource16*>(resource);
145 return StringTraits<StringType>::fromStringResource(base); 145 return StringTraits<StringType>::fromStringResource(base);
146 } 146 }
147 } 147 }
148 148
149 int length = v8String->Length(); 149 int length = v8String->Length();
150 if (UNLIKELY(!length)) 150 if (UNLIKELY(!length))
151 return String(""); 151 return StringType("");
152 152
153 bool oneByte = v8String->ContainsOnlyOneByte(); 153 bool oneByte = v8String->ContainsOnlyOneByte();
154 StringType result(oneByte ? StringTraits<StringType>::template fromV8String< true>(v8String, length) : StringTraits<StringType>::template fromV8String<false> (v8String, length)); 154 StringType result(oneByte ? StringTraits<StringType>::template fromV8String< true>(v8String, length) : StringTraits<StringType>::template fromV8String<false> (v8String, length));
155 155
156 if (external != Externalize || !v8String->CanMakeExternal()) 156 if (external != Externalize || !v8String->CanMakeExternal())
157 return result; 157 return result;
158 158
159 if (result.is8Bit()) { 159 if (result.is8Bit()) {
160 WebCoreStringResource8* stringResource = new WebCoreStringResource8(resu lt); 160 WebCoreStringResource8* stringResource = new WebCoreStringResource8(resu lt);
161 if (UNLIKELY(!v8String->MakeExternal(stringResource))) 161 if (UNLIKELY(!v8String->MakeExternal(stringResource)))
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 198
199 String int32ToWebCoreString(int value) 199 String int32ToWebCoreString(int value)
200 { 200 {
201 // If we are on the main thread (this should always true for non-workers), c all the faster one. 201 // If we are on the main thread (this should always true for non-workers), c all the faster one.
202 if (isMainThread()) 202 if (isMainThread())
203 return int32ToWebCoreStringFast(value); 203 return int32ToWebCoreStringFast(value);
204 return String::number(value); 204 return String::number(value);
205 } 205 }
206 206
207 } // namespace WebCore 207 } // namespace WebCore
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698