| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2005, 2006, 2009 Apple Inc. All rights reserved. | 2 * Copyright (C) 2005, 2006, 2009 Apple Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * This library is free software; you can redistribute it and/or | 4 * This library is free software; you can redistribute it and/or |
| 5 * modify it under the terms of the GNU Library General Public | 5 * modify it under the terms of the GNU Library General Public |
| 6 * License as published by the Free Software Foundation; either | 6 * License as published by the Free Software Foundation; either |
| 7 * version 2 of the License, or (at your option) any later version. | 7 * version 2 of the License, or (at your option) any later version. |
| 8 * | 8 * |
| 9 * This library is distributed in the hope that it will be useful, | 9 * This library is distributed in the hope that it will be useful, |
| 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 | 34 |
| 35 namespace blink { | 35 namespace blink { |
| 36 | 36 |
| 37 struct SameSizeAsQualifiedNameImpl : public RefCounted<SameSizeAsQualifiedNameIm
pl> { | 37 struct SameSizeAsQualifiedNameImpl : public RefCounted<SameSizeAsQualifiedNameIm
pl> { |
| 38 unsigned bitfield; | 38 unsigned bitfield; |
| 39 void* pointers[4]; | 39 void* pointers[4]; |
| 40 }; | 40 }; |
| 41 | 41 |
| 42 static_assert(sizeof(QualifiedName::QualifiedNameImpl) == sizeof(SameSizeAsQuali
fiedNameImpl), "QualifiedNameImpl should stay small"); | 42 static_assert(sizeof(QualifiedName::QualifiedNameImpl) == sizeof(SameSizeAsQuali
fiedNameImpl), "QualifiedNameImpl should stay small"); |
| 43 | 43 |
| 44 static const int staticQualifiedNamesCount = HTMLNames::HTMLTagsCount + HTMLName
s::HTMLAttrsCount | 44 using QualifiedNameCache = HashSet<QualifiedName::QualifiedNameImpl*, QualifiedN
ameHash>; |
| 45 + MathMLNames::MathMLTagsCount + MathMLNames::MathMLAttrsCount | |
| 46 + SVGNames::SVGTagsCount + SVGNames::SVGAttrsCount | |
| 47 + XLinkNames::XLinkAttrsCount | |
| 48 + XMLNSNames::XMLNSAttrsCount | |
| 49 + XMLNames::XMLAttrsCount; | |
| 50 | |
| 51 struct QualifiedNameHashTraits : public HashTraits<QualifiedName::QualifiedNameI
mpl*> { | |
| 52 static const unsigned minimumTableSize = WTF::HashTableCapacityForSize<stati
cQualifiedNamesCount>::value; | |
| 53 }; | |
| 54 | |
| 55 typedef HashSet<QualifiedName::QualifiedNameImpl*, QualifiedNameHash, QualifiedN
ameHashTraits> QualifiedNameCache; | |
| 56 | 45 |
| 57 static QualifiedNameCache& qualifiedNameCache() | 46 static QualifiedNameCache& qualifiedNameCache() |
| 58 { | 47 { |
| 59 // This code is lockless and thus assumes it all runs on one thread! | 48 // This code is lockless and thus assumes it all runs on one thread! |
| 60 ASSERT(isMainThread()); | 49 ASSERT(isMainThread()); |
| 61 static QualifiedNameCache* gNameCache = new QualifiedNameCache; | 50 static QualifiedNameCache* gNameCache = new QualifiedNameCache; |
| 62 return *gNameCache; | 51 return *gNameCache; |
| 63 } | 52 } |
| 64 | 53 |
| 65 struct QNameComponentsTranslator { | 54 struct QNameComponentsTranslator { |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 String local = localName(); | 97 String local = localName(); |
| 109 if (hasPrefix()) | 98 if (hasPrefix()) |
| 110 return prefix().string() + ":" + local; | 99 return prefix().string() + ":" + local; |
| 111 return local; | 100 return local; |
| 112 } | 101 } |
| 113 | 102 |
| 114 // Global init routines | 103 // Global init routines |
| 115 DEFINE_GLOBAL(QualifiedName, anyName, nullAtom, starAtom, starAtom) | 104 DEFINE_GLOBAL(QualifiedName, anyName, nullAtom, starAtom, starAtom) |
| 116 DEFINE_GLOBAL(QualifiedName, nullName, nullAtom, nullAtom, nullAtom) | 105 DEFINE_GLOBAL(QualifiedName, nullName, nullAtom, nullAtom, nullAtom) |
| 117 | 106 |
| 118 void QualifiedName::init() | 107 void QualifiedName::initAndReserveCapacityForSize(unsigned size) |
| 119 { | 108 { |
| 120 ASSERT(starAtom.impl()); | 109 ASSERT(starAtom.impl()); |
| 110 qualifiedNameCache().reserveCapacityForSize(size + 2 /*starAtom and nullAtom
*/); |
| 121 new ((void*)&anyName) QualifiedName(nullAtom, starAtom, starAtom, true ); | 111 new ((void*)&anyName) QualifiedName(nullAtom, starAtom, starAtom, true ); |
| 122 new ((void*)&nullName) QualifiedName(nullAtom, nullAtom, nullAtom, true ); | 112 new ((void*)&nullName) QualifiedName(nullAtom, nullAtom, nullAtom, true ); |
| 123 } | 113 } |
| 124 | 114 |
| 125 const QualifiedName& QualifiedName::null() | 115 const QualifiedName& QualifiedName::null() |
| 126 { | 116 { |
| 127 return nullName; | 117 return nullName; |
| 128 } | 118 } |
| 129 | 119 |
| 130 const AtomicString& QualifiedName::localNameUpper() const | 120 const AtomicString& QualifiedName::localNameUpper() const |
| (...skipping 13 matching lines...) Expand all Loading... |
| 144 { | 134 { |
| 145 new (targetAddress) QualifiedName(nullAtom, AtomicString(name), nameNamespac
e, true); | 135 new (targetAddress) QualifiedName(nullAtom, AtomicString(name), nameNamespac
e, true); |
| 146 } | 136 } |
| 147 | 137 |
| 148 void QualifiedName::createStatic(void* targetAddress, StringImpl* name) | 138 void QualifiedName::createStatic(void* targetAddress, StringImpl* name) |
| 149 { | 139 { |
| 150 new (targetAddress) QualifiedName(nullAtom, AtomicString(name), nullAtom, tr
ue); | 140 new (targetAddress) QualifiedName(nullAtom, AtomicString(name), nullAtom, tr
ue); |
| 151 } | 141 } |
| 152 | 142 |
| 153 } | 143 } |
| OLD | NEW |