| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2010 Apple Inc. All rights reserved. | 2 * Copyright (C) 2010 Apple 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 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 310 | 310 |
| 311 return ""; | 311 return ""; |
| 312 } | 312 } |
| 313 | 313 |
| 314 enum Mode { | 314 enum Mode { |
| 315 None, | 315 None, |
| 316 Charset, | 316 Charset, |
| 317 Pragma, | 317 Pragma, |
| 318 }; | 318 }; |
| 319 | 319 |
| 320 WTF::TextEncoding encodingFromMetaAttributes(const HTMLAttributeList& attributes
) | |
| 321 { | |
| 322 bool gotPragma = false; | |
| 323 Mode mode = None; | |
| 324 String charset; | |
| 325 | |
| 326 for (HTMLAttributeList::const_iterator iter = attributes.begin(); iter != at
tributes.end(); ++iter) { | |
| 327 const String& attributeName = iter->first; | |
| 328 const String& attributeValue = AtomicString(iter->second); | |
| 329 | |
| 330 if (threadSafeMatch(attributeName, HTMLNames::http_equivAttr)) { | |
| 331 if (equalIgnoringCase(attributeValue, "content-type")) | |
| 332 gotPragma = true; | |
| 333 } else if (charset.isEmpty()) { | |
| 334 if (threadSafeMatch(attributeName, HTMLNames::charsetAttr)) { | |
| 335 charset = attributeValue; | |
| 336 mode = Charset; | |
| 337 } else if (threadSafeMatch(attributeName, HTMLNames::contentAttr)) { | |
| 338 charset = extractCharset(attributeValue); | |
| 339 if (charset.length()) | |
| 340 mode = Pragma; | |
| 341 } | |
| 342 } | |
| 343 } | |
| 344 | |
| 345 if (mode == Charset || (mode == Pragma && gotPragma)) | |
| 346 return WTF::TextEncoding(stripLeadingAndTrailingHTMLSpaces(charset)); | |
| 347 | |
| 348 return WTF::TextEncoding(); | |
| 349 } | |
| 350 | |
| 351 static bool threadSafeEqual(const StringImpl* a, const StringImpl* b) | 320 static bool threadSafeEqual(const StringImpl* a, const StringImpl* b) |
| 352 { | 321 { |
| 353 if (a == b) | 322 if (a == b) |
| 354 return true; | 323 return true; |
| 355 if (a->hash() != b->hash()) | 324 if (a->hash() != b->hash()) |
| 356 return false; | 325 return false; |
| 357 return equalNonNull(a, b); | 326 return equalNonNull(a, b); |
| 358 } | 327 } |
| 359 | 328 |
| 360 bool threadSafeMatch(const QualifiedName& a, const QualifiedName& b) | 329 bool threadSafeMatch(const QualifiedName& a, const QualifiedName& b) |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 407 string = StringImpl::create8BitIfPossible(characters, size); | 376 string = StringImpl::create8BitIfPossible(characters, size); |
| 408 else if (width == Force8Bit) | 377 else if (width == Force8Bit) |
| 409 string = String::make8BitFrom16BitSource(characters, size); | 378 string = String::make8BitFrom16BitSource(characters, size); |
| 410 else | 379 else |
| 411 string = String(characters, size); | 380 string = String(characters, size); |
| 412 | 381 |
| 413 return string; | 382 return string; |
| 414 } | 383 } |
| 415 | 384 |
| 416 } | 385 } |
| OLD | NEW |