| OLD | NEW | 
|---|
| 1 /* | 1 /* | 
| 2  * Copyright (C) 2008 Apple Inc. All Rights Reserved. | 2  * Copyright (C) 2008 Apple Inc. All Rights Reserved. | 
| 3  * Copyright (C) 2009 Torch Mobile, Inc. http://www.torchmobile.com/ | 3  * Copyright (C) 2009 Torch Mobile, Inc. http://www.torchmobile.com/ | 
| 4  * Copyright (C) 2010 Google, Inc. All Rights Reserved. | 4  * Copyright (C) 2010 Google, Inc. All Rights Reserved. | 
| 5  * | 5  * | 
| 6  * Redistribution and use in source and binary forms, with or without | 6  * Redistribution and use in source and binary forms, with or without | 
| 7  * modification, are permitted provided that the following conditions | 7  * modification, are permitted provided that the following conditions | 
| 8  * are met: | 8  * are met: | 
| 9  * 1. Redistributions of source code must retain the above copyright | 9  * 1. Redistributions of source code must retain the above copyright | 
| 10  *    notice, this list of conditions and the following disclaimer. | 10  *    notice, this list of conditions and the following disclaimer. | 
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 108     while (!source.isEmpty()) { | 108     while (!source.isEmpty()) { | 
| 109         cc = source.currentChar(); | 109         cc = source.currentChar(); | 
| 110         entitySearch.advance(cc); | 110         entitySearch.advance(cc); | 
| 111         if (!entitySearch.isEntityPrefix()) | 111         if (!entitySearch.isEntityPrefix()) | 
| 112             break; | 112             break; | 
| 113         consumedCharacters.append(cc); | 113         consumedCharacters.append(cc); | 
| 114         source.advanceAndASSERT(cc); | 114         source.advanceAndASSERT(cc); | 
| 115     } | 115     } | 
| 116     notEnoughCharacters = source.isEmpty(); | 116     notEnoughCharacters = source.isEmpty(); | 
| 117     if (notEnoughCharacters) { | 117     if (notEnoughCharacters) { | 
| 118         // We can't an entity because there might be a longer entity | 118         // We can't decide on an entity because there might be a longer entity | 
| 119         // that we could match if we had more data. | 119         // that we could match if we had more data. | 
| 120         unconsumeCharacters(source, consumedCharacters); | 120         unconsumeCharacters(source, consumedCharacters); | 
| 121         return false; | 121         return false; | 
| 122     } | 122     } | 
| 123     if (!entitySearch.mostRecentMatch()) { | 123     if (!entitySearch.mostRecentMatch()) { | 
| 124         unconsumeCharacters(source, consumedCharacters); | 124         unconsumeCharacters(source, consumedCharacters); | 
| 125         return false; | 125         return false; | 
| 126     } | 126     } | 
| 127     if (entitySearch.mostRecentMatch()->length != entitySearch.currentLength()) 
     { | 127     if (entitySearch.mostRecentMatch()->length != entitySearch.currentLength()) 
     { | 
| 128         // We've consumed too many characters. We need to walk the | 128         // We've consumed too many characters. We need to walk the | 
| 129         // source back to the point at which we had consumed an | 129         // source back to the point at which we had consumed an | 
| 130         // actual entity. | 130         // actual entity. | 
| 131         unconsumeCharacters(source, consumedCharacters); | 131         unconsumeCharacters(source, consumedCharacters); | 
| 132         consumedCharacters.clear(); | 132         consumedCharacters.clear(); | 
| 133         const int length = entitySearch.mostRecentMatch()->length; | 133         const HTMLEntityTableEntry* mostRecent = entitySearch.mostRecentMatch(); | 
| 134         const LChar* reference = entitySearch.mostRecentMatch()->entity; | 134         const int length = mostRecent->length; | 
|  | 135         const LChar* reference = HTMLEntityTable::entityString(*mostRecent); | 
| 135         for (int i = 0; i < length; ++i) { | 136         for (int i = 0; i < length; ++i) { | 
| 136             cc = source.currentChar(); | 137             cc = source.currentChar(); | 
| 137             ASSERT_UNUSED(reference, cc == *reference++); | 138             ASSERT_UNUSED(reference, cc == static_cast<UChar>(*reference++)); | 
| 138             consumedCharacters.append(cc); | 139             consumedCharacters.append(cc); | 
| 139             source.advanceAndASSERT(cc); | 140             source.advanceAndASSERT(cc); | 
| 140             ASSERT(!source.isEmpty()); | 141             ASSERT(!source.isEmpty()); | 
| 141         } | 142         } | 
| 142         cc = source.currentChar(); | 143         cc = source.currentChar(); | 
| 143     } | 144     } | 
| 144     if (entitySearch.mostRecentMatch()->lastCharacter() == ';' | 145     if (entitySearch.mostRecentMatch()->lastCharacter() == ';' | 
| 145         || !additionalAllowedCharacter | 146         || !additionalAllowedCharacter | 
| 146         || !(isAlphaNumeric(cc) || cc == '=')) { | 147         || !(isAlphaNumeric(cc) || cc == '=')) { | 
| 147         decodedEntity.append(entitySearch.mostRecentMatch()->firstValue); | 148         decodedEntity.append(entitySearch.mostRecentMatch()->firstValue); | 
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 295     if (!search.isEntityPrefix()) | 296     if (!search.isEntityPrefix()) | 
| 296         return 0; | 297         return 0; | 
| 297 | 298 | 
| 298     size_t numberOfCodePoints = appendUChar32ToUCharArray(search.mostRecentMatch
     ()->firstValue, result); | 299     size_t numberOfCodePoints = appendUChar32ToUCharArray(search.mostRecentMatch
     ()->firstValue, result); | 
| 299     if (!search.mostRecentMatch()->secondValue) | 300     if (!search.mostRecentMatch()->secondValue) | 
| 300         return numberOfCodePoints; | 301         return numberOfCodePoints; | 
| 301     return numberOfCodePoints + appendUChar32ToUCharArray(search.mostRecentMatch
     ()->secondValue, result + numberOfCodePoints); | 302     return numberOfCodePoints + appendUChar32ToUCharArray(search.mostRecentMatch
     ()->secondValue, result + numberOfCodePoints); | 
| 302 } | 303 } | 
| 303 | 304 | 
| 304 } // namespace WebCore | 305 } // namespace WebCore | 
| OLD | NEW | 
|---|