| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 : m_isUnique(false) | 63 : m_isUnique(false) |
| 64 , m_arraySize(arraySize) | 64 , m_arraySize(arraySize) |
| 65 , m_presentationAttributeStyleIsDirty(false) | 65 , m_presentationAttributeStyleIsDirty(false) |
| 66 , m_styleAttributeIsDirty(false) | 66 , m_styleAttributeIsDirty(false) |
| 67 , m_animatedSVGAttributesAreDirty(false) | 67 , m_animatedSVGAttributesAreDirty(false) |
| 68 { | 68 { |
| 69 } | 69 } |
| 70 | 70 |
| 71 ElementData::ElementData(const ElementData& other, bool isUnique) | 71 ElementData::ElementData(const ElementData& other, bool isUnique) |
| 72 : m_isUnique(isUnique) | 72 : m_isUnique(isUnique) |
| 73 , m_arraySize(isUnique ? 0 : other.attributeCount()) | 73 , m_arraySize(isUnique ? 0 : other.attributes().size()) |
| 74 , m_presentationAttributeStyleIsDirty(other.m_presentationAttributeStyleIsDi
rty) | 74 , m_presentationAttributeStyleIsDirty(other.m_presentationAttributeStyleIsDi
rty) |
| 75 , m_styleAttributeIsDirty(other.m_styleAttributeIsDirty) | 75 , m_styleAttributeIsDirty(other.m_styleAttributeIsDirty) |
| 76 , m_animatedSVGAttributesAreDirty(other.m_animatedSVGAttributesAreDirty) | 76 , m_animatedSVGAttributesAreDirty(other.m_animatedSVGAttributesAreDirty) |
| 77 , m_classNames(other.m_classNames) | 77 , m_classNames(other.m_classNames) |
| 78 , m_idForStyleResolution(other.m_idForStyleResolution) | 78 , m_idForStyleResolution(other.m_idForStyleResolution) |
| 79 { | 79 { |
| 80 // NOTE: The inline style is copied by the subclass copy constructor since w
e don't know what to do with it here. | 80 // NOTE: The inline style is copied by the subclass copy constructor since w
e don't know what to do with it here. |
| 81 } | 81 } |
| 82 | 82 |
| 83 #if ENABLE(OILPAN) | 83 #if ENABLE(OILPAN) |
| (...skipping 16 matching lines...) Expand all Loading... |
| 100 | 100 |
| 101 PassRefPtrWillBeRawPtr<UniqueElementData> ElementData::makeUniqueCopy() const | 101 PassRefPtrWillBeRawPtr<UniqueElementData> ElementData::makeUniqueCopy() const |
| 102 { | 102 { |
| 103 if (isUnique()) | 103 if (isUnique()) |
| 104 return adoptRefWillBeNoop(new UniqueElementData(static_cast<const Unique
ElementData&>(*this))); | 104 return adoptRefWillBeNoop(new UniqueElementData(static_cast<const Unique
ElementData&>(*this))); |
| 105 return adoptRefWillBeNoop(new UniqueElementData(static_cast<const ShareableE
lementData&>(*this))); | 105 return adoptRefWillBeNoop(new UniqueElementData(static_cast<const ShareableE
lementData&>(*this))); |
| 106 } | 106 } |
| 107 | 107 |
| 108 bool ElementData::isEquivalent(const ElementData* other) const | 108 bool ElementData::isEquivalent(const ElementData* other) const |
| 109 { | 109 { |
| 110 AttributeCollection attributes = this->attributes(); |
| 110 if (!other) | 111 if (!other) |
| 111 return !hasAttributes(); | 112 return attributes.isEmpty(); |
| 112 | 113 |
| 113 AttributeCollection attributes = this->attributes(); | 114 AttributeCollection otherAttributes = other->attributes(); |
| 114 if (attributes.size() != other->attributeCount()) | 115 if (attributes.size() != otherAttributes.size()) |
| 115 return false; | 116 return false; |
| 116 | 117 |
| 117 AttributeCollection::const_iterator end = attributes.end(); | 118 AttributeCollection::const_iterator end = attributes.end(); |
| 118 for (AttributeCollection::const_iterator it = attributes.begin(); it != end;
++it) { | 119 for (AttributeCollection::const_iterator it = attributes.begin(); it != end;
++it) { |
| 119 const Attribute* otherAttr = other->findAttributeByName(it->name()); | 120 const Attribute* otherAttr = otherAttributes.get(it->name()); |
| 120 if (!otherAttr || it->value() != otherAttr->value()) | 121 if (!otherAttr || it->value() != otherAttr->value()) |
| 121 return false; | 122 return false; |
| 122 } | 123 } |
| 123 return true; | 124 return true; |
| 124 } | 125 } |
| 125 | 126 |
| 126 size_t ElementData::findAttrNodeIndex(Attr* attr) const | 127 size_t AttributeCollection::find(Attr* attr) const |
| 127 { | 128 { |
| 128 // This relies on the fact that Attr's QualifiedName == the Attribute's name
. | 129 // This relies on the fact that Attr's QualifiedName == the Attribute's name
. |
| 129 AttributeCollection attributes = this->attributes(); | 130 const_iterator end = this->end(); |
| 130 AttributeCollection::const_iterator end = attributes.end(); | |
| 131 unsigned index = 0; | 131 unsigned index = 0; |
| 132 for (AttributeCollection::const_iterator it = attributes.begin(); it != end;
++it, ++index) { | 132 for (const_iterator it = begin(); it != end; ++it, ++index) { |
| 133 if (it->name() == attr->qualifiedName()) | 133 if (it->name() == attr->qualifiedName()) |
| 134 return index; | 134 return index; |
| 135 } | 135 } |
| 136 return kNotFound; | 136 return kNotFound; |
| 137 } | 137 } |
| 138 | 138 |
| 139 size_t ElementData::findAttributeIndexByNameSlowCase(const AtomicString& name, b
ool shouldIgnoreAttributeCase) const | 139 size_t AttributeCollection::findSlowCase(const AtomicString& name, bool shouldIg
noreAttributeCase) const |
| 140 { | 140 { |
| 141 // Continue to checking case-insensitively and/or full namespaced names if n
ecessary: | 141 // Continue to checking case-insensitively and/or full namespaced names if n
ecessary: |
| 142 AttributeCollection attributes = this->attributes(); | 142 const_iterator end = this->end(); |
| 143 AttributeCollection::const_iterator end = attributes.end(); | |
| 144 unsigned index = 0; | 143 unsigned index = 0; |
| 145 for (AttributeCollection::const_iterator it = attributes.begin(); it != end;
++it, ++index) { | 144 for (const_iterator it = begin(); it != end; ++it, ++index) { |
| 146 // FIXME: Why check the prefix? Namespace is all that should matter | 145 // FIXME: Why check the prefix? Namespace is all that should matter |
| 147 // and all HTML/SVG attributes have a null namespace! | 146 // and all HTML/SVG attributes have a null namespace! |
| 148 if (!it->name().hasPrefix()) { | 147 if (!it->name().hasPrefix()) { |
| 149 if (shouldIgnoreAttributeCase && equalIgnoringCase(name, it->localNa
me())) | 148 if (shouldIgnoreAttributeCase && equalIgnoringCase(name, it->localNa
me())) |
| 150 return index; | 149 return index; |
| 151 } else { | 150 } else { |
| 152 // FIXME: Would be faster to do this comparison without calling toSt
ring, which | 151 // FIXME: Would be faster to do this comparison without calling toSt
ring, which |
| 153 // generates a temporary string by concatenation. But this branch is
only reached | 152 // generates a temporary string by concatenation. But this branch is
only reached |
| 154 // if the attribute name has a prefix, which is rare in HTML. | 153 // if the attribute name has a prefix, which is rare in HTML. |
| 155 if (equalPossiblyIgnoringCase(name, it->name().toString(), shouldIgn
oreAttributeCase)) | 154 if (equalPossiblyIgnoringCase(name, it->name().toString(), shouldIgn
oreAttributeCase)) |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 220 m_inlineStyle = other.m_inlineStyle ? other.m_inlineStyle->mutableCopy() : n
ullptr; | 219 m_inlineStyle = other.m_inlineStyle ? other.m_inlineStyle->mutableCopy() : n
ullptr; |
| 221 } | 220 } |
| 222 | 221 |
| 223 UniqueElementData::UniqueElementData(const ShareableElementData& other) | 222 UniqueElementData::UniqueElementData(const ShareableElementData& other) |
| 224 : ElementData(other, true) | 223 : ElementData(other, true) |
| 225 { | 224 { |
| 226 // An ShareableElementData should never have a mutable inline StylePropertyS
et attached. | 225 // An ShareableElementData should never have a mutable inline StylePropertyS
et attached. |
| 227 ASSERT(!other.m_inlineStyle || !other.m_inlineStyle->isMutable()); | 226 ASSERT(!other.m_inlineStyle || !other.m_inlineStyle->isMutable()); |
| 228 m_inlineStyle = other.m_inlineStyle; | 227 m_inlineStyle = other.m_inlineStyle; |
| 229 | 228 |
| 230 unsigned length = other.attributeCount(); | 229 unsigned length = other.attributes().size(); |
| 231 m_attributeVector.reserveCapacity(length); | 230 m_attributeVector.reserveCapacity(length); |
| 232 for (unsigned i = 0; i < length; ++i) | 231 for (unsigned i = 0; i < length; ++i) |
| 233 m_attributeVector.uncheckedAppend(other.m_attributeArray[i]); | 232 m_attributeVector.uncheckedAppend(other.m_attributeArray[i]); |
| 234 } | 233 } |
| 235 | 234 |
| 236 PassRefPtrWillBeRawPtr<UniqueElementData> UniqueElementData::create() | 235 PassRefPtrWillBeRawPtr<UniqueElementData> UniqueElementData::create() |
| 237 { | 236 { |
| 238 return adoptRefWillBeNoop(new UniqueElementData); | 237 return adoptRefWillBeNoop(new UniqueElementData); |
| 239 } | 238 } |
| 240 | 239 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 258 return 0; | 257 return 0; |
| 259 } | 258 } |
| 260 | 259 |
| 261 void UniqueElementData::traceAfterDispatch(Visitor* visitor) | 260 void UniqueElementData::traceAfterDispatch(Visitor* visitor) |
| 262 { | 261 { |
| 263 visitor->trace(m_presentationAttributeStyle); | 262 visitor->trace(m_presentationAttributeStyle); |
| 264 ElementData::traceAfterDispatch(visitor); | 263 ElementData::traceAfterDispatch(visitor); |
| 265 } | 264 } |
| 266 | 265 |
| 267 } // namespace WebCore | 266 } // namespace WebCore |
| OLD | NEW |