| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2003 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 2003 Lars Knoll (knoll@kde.org) |
| 3 * Copyright (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com) | 3 * Copyright (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com) |
| 4 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc.
All rights reserved. | 4 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc.
All rights reserved. |
| 5 * Copyright (C) 2007 Nicholas Shanks <webkit@nickshanks.com> | 5 * Copyright (C) 2007 Nicholas Shanks <webkit@nickshanks.com> |
| 6 * Copyright (C) 2008 Eric Seidel <eric@webkit.org> | 6 * Copyright (C) 2008 Eric Seidel <eric@webkit.org> |
| 7 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo
bile.com/) | 7 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo
bile.com/) |
| 8 * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved. | 8 * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved. |
| 9 * Copyright (C) 2012 Intel Corporation. All rights reserved. | 9 * Copyright (C) 2012 Intel Corporation. All rights reserved. |
| 10 * | 10 * |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 afterEscape = false; | 152 afterEscape = false; |
| 153 } | 153 } |
| 154 } | 154 } |
| 155 buffer[index++] = '\''; | 155 buffer[index++] = '\''; |
| 156 | 156 |
| 157 ASSERT(quotedStringSize == index); | 157 ASSERT(quotedStringSize == index); |
| 158 return String::adopt(buffer); | 158 return String::adopt(buffer); |
| 159 } | 159 } |
| 160 | 160 |
| 161 // We use single quotes for now because markup.cpp uses double quotes. | 161 // We use single quotes for now because markup.cpp uses double quotes. |
| 162 String quoteCSSString(const String& string) | 162 static String quoteCSSString(const String& string) |
| 163 { | 163 { |
| 164 // This function expands each character to at most 3 characters ('\u0010' ->
'\' '1' '0') as well as adds | 164 // This function expands each character to at most 3 characters ('\u0010' ->
'\' '1' '0') as well as adds |
| 165 // 2 quote characters (before and after). Make sure the resulting size (3 *
length + 2) will not overflow unsigned. | 165 // 2 quote characters (before and after). Make sure the resulting size (3 *
length + 2) will not overflow unsigned. |
| 166 | 166 |
| 167 unsigned length = string.length(); | 167 unsigned length = string.length(); |
| 168 | 168 |
| 169 if (!length) | 169 if (!length) |
| 170 return String("\'\'"); | 170 return String("\'\'"); |
| 171 | 171 |
| 172 if (length > std::numeric_limits<unsigned>::max() / 3 - 2) | 172 if (length > std::numeric_limits<unsigned>::max() / 3 - 2) |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 serializeCharacterAsCodePoint(c, appendTo); | 241 serializeCharacterAsCodePoint(c, appendTo); |
| 242 else if (c == 0x22 || c == 0x5c) | 242 else if (c == 0x22 || c == 0x5c) |
| 243 serializeCharacter(c, appendTo); | 243 serializeCharacter(c, appendTo); |
| 244 else | 244 else |
| 245 appendTo.append(c); | 245 appendTo.append(c); |
| 246 } | 246 } |
| 247 | 247 |
| 248 appendTo.append('\"'); | 248 appendTo.append('\"'); |
| 249 } | 249 } |
| 250 | 250 |
| 251 String serializeString(const String& string) |
| 252 { |
| 253 StringBuilder builder; |
| 254 serializeString(string, builder); |
| 255 return builder.toString(); |
| 256 } |
| 257 |
| 251 } // namespace blink | 258 } // namespace blink |
| OLD | NEW |