| OLD | NEW |
| 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 are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 m_entitiesMap.set(0x0027, "apos"); | 44 m_entitiesMap.set(0x0027, "apos"); |
| 45 m_entitiesMap.set(0x0022, "quot"); | 45 m_entitiesMap.set(0x0022, "quot"); |
| 46 // We add #39 for test-compatibility reason. | 46 // We add #39 for test-compatibility reason. |
| 47 if (!xmlEntities) | 47 if (!xmlEntities) |
| 48 m_entitiesMap.set(0x0027, String("#39")); | 48 m_entitiesMap.set(0x0027, String("#39")); |
| 49 } | 49 } |
| 50 | 50 |
| 51 String WebEntities::entityNameByCode(int code) const { | 51 String WebEntities::entityNameByCode(int code) const { |
| 52 // FIXME: We should use find so we only do one hash lookup. | 52 // FIXME: We should use find so we only do one hash lookup. |
| 53 if (m_entitiesMap.contains(code)) | 53 if (m_entitiesMap.contains(code)) |
| 54 return m_entitiesMap.get(code); | 54 return m_entitiesMap.at(code); |
| 55 return ""; | 55 return ""; |
| 56 } | 56 } |
| 57 | 57 |
| 58 String WebEntities::convertEntitiesInString(const String& value) const { | 58 String WebEntities::convertEntitiesInString(const String& value) const { |
| 59 StringBuilder result; | 59 StringBuilder result; |
| 60 bool didConvertEntity = false; | 60 bool didConvertEntity = false; |
| 61 unsigned length = value.length(); | 61 unsigned length = value.length(); |
| 62 for (unsigned i = 0; i < length; ++i) { | 62 for (unsigned i = 0; i < length; ++i) { |
| 63 UChar c = value[i]; | 63 UChar c = value[i]; |
| 64 // FIXME: We should use find so we only do one hash lookup. | 64 // FIXME: We should use find so we only do one hash lookup. |
| 65 if (m_entitiesMap.contains(c)) { | 65 if (m_entitiesMap.contains(c)) { |
| 66 didConvertEntity = true; | 66 didConvertEntity = true; |
| 67 result.append('&'); | 67 result.append('&'); |
| 68 result.append(m_entitiesMap.get(c)); | 68 result.append(m_entitiesMap.at(c)); |
| 69 result.append(';'); | 69 result.append(';'); |
| 70 } else { | 70 } else { |
| 71 result.append(c); | 71 result.append(c); |
| 72 } | 72 } |
| 73 } | 73 } |
| 74 | 74 |
| 75 if (!didConvertEntity) | 75 if (!didConvertEntity) |
| 76 return value; | 76 return value; |
| 77 | 77 |
| 78 return result.toString(); | 78 return result.toString(); |
| 79 } | 79 } |
| 80 | 80 |
| 81 } // namespace blink | 81 } // namespace blink |
| OLD | NEW |