| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
| 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
| 4 * (C) 2001 Peter Kelly (pmk@post.com) | 4 * (C) 2001 Peter Kelly (pmk@post.com) |
| 5 * (C) 2001 Dirk Mueller (mueller@kde.org) | 5 * (C) 2001 Dirk Mueller (mueller@kde.org) |
| 6 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2013 Appl
e Inc. All rights reserved. | 6 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2013 Appl
e Inc. All rights reserved. |
| 7 * | 7 * |
| 8 * This library is free software; you can redistribute it and/or | 8 * This library is free software; you can redistribute it and/or |
| 9 * modify it under the terms of the GNU Library General Public | 9 * modify it under the terms of the GNU Library General Public |
| 10 * License as published by the Free Software Foundation; either | 10 * License as published by the Free Software Foundation; either |
| (...skipping 1017 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1028 inline const StylePropertySet* ElementData::presentationAttributeStyle() const | 1028 inline const StylePropertySet* ElementData::presentationAttributeStyle() const |
| 1029 { | 1029 { |
| 1030 if (!m_isUnique) | 1030 if (!m_isUnique) |
| 1031 return 0; | 1031 return 0; |
| 1032 return static_cast<const UniqueElementData*>(this)->m_presentationAttributeS
tyle.get(); | 1032 return static_cast<const UniqueElementData*>(this)->m_presentationAttributeS
tyle.get(); |
| 1033 } | 1033 } |
| 1034 | 1034 |
| 1035 inline const Attribute* ElementData::getAttributeItem(const AtomicString& name,
bool shouldIgnoreAttributeCase) const | 1035 inline const Attribute* ElementData::getAttributeItem(const AtomicString& name,
bool shouldIgnoreAttributeCase) const |
| 1036 { | 1036 { |
| 1037 size_t index = getAttributeItemIndex(name, shouldIgnoreAttributeCase); | 1037 size_t index = getAttributeItemIndex(name, shouldIgnoreAttributeCase); |
| 1038 if (index != notFound) | 1038 if (index != kNotFound) |
| 1039 return attributeItem(index); | 1039 return attributeItem(index); |
| 1040 return 0; | 1040 return 0; |
| 1041 } | 1041 } |
| 1042 | 1042 |
| 1043 inline const Attribute* ElementData::attributeBase() const | 1043 inline const Attribute* ElementData::attributeBase() const |
| 1044 { | 1044 { |
| 1045 if (m_isUnique) | 1045 if (m_isUnique) |
| 1046 return static_cast<const UniqueElementData*>(this)->m_attributeVector.be
gin(); | 1046 return static_cast<const UniqueElementData*>(this)->m_attributeVector.be
gin(); |
| 1047 return static_cast<const ShareableElementData*>(this)->m_attributeArray; | 1047 return static_cast<const ShareableElementData*>(this)->m_attributeArray; |
| 1048 } | 1048 } |
| 1049 | 1049 |
| 1050 inline size_t ElementData::getAttributeItemIndex(const QualifiedName& name, bool
shouldIgnoreCase) const | 1050 inline size_t ElementData::getAttributeItemIndex(const QualifiedName& name, bool
shouldIgnoreCase) const |
| 1051 { | 1051 { |
| 1052 const Attribute* begin = attributeBase(); | 1052 const Attribute* begin = attributeBase(); |
| 1053 for (unsigned i = 0; i < length(); ++i) { | 1053 for (unsigned i = 0; i < length(); ++i) { |
| 1054 const Attribute& attribute = begin[i]; | 1054 const Attribute& attribute = begin[i]; |
| 1055 if (attribute.name().matchesPossiblyIgnoringCase(name, shouldIgnoreCase)
) | 1055 if (attribute.name().matchesPossiblyIgnoringCase(name, shouldIgnoreCase)
) |
| 1056 return i; | 1056 return i; |
| 1057 } | 1057 } |
| 1058 return notFound; | 1058 return kNotFound; |
| 1059 } | 1059 } |
| 1060 | 1060 |
| 1061 // We use a boolean parameter instead of calling shouldIgnoreAttributeCase so th
at the caller | 1061 // We use a boolean parameter instead of calling shouldIgnoreAttributeCase so th
at the caller |
| 1062 // can tune the behavior (hasAttribute is case sensitive whereas getAttribute is
not). | 1062 // can tune the behavior (hasAttribute is case sensitive whereas getAttribute is
not). |
| 1063 inline size_t ElementData::getAttributeItemIndex(const AtomicString& name, bool
shouldIgnoreAttributeCase) const | 1063 inline size_t ElementData::getAttributeItemIndex(const AtomicString& name, bool
shouldIgnoreAttributeCase) const |
| 1064 { | 1064 { |
| 1065 unsigned len = length(); | 1065 unsigned len = length(); |
| 1066 bool doSlowCheck = shouldIgnoreAttributeCase; | 1066 bool doSlowCheck = shouldIgnoreAttributeCase; |
| 1067 | 1067 |
| 1068 // Optimize for the case where the attribute exists and its name exactly mat
ches. | 1068 // Optimize for the case where the attribute exists and its name exactly mat
ches. |
| 1069 const Attribute* begin = attributeBase(); | 1069 const Attribute* begin = attributeBase(); |
| 1070 for (unsigned i = 0; i < len; ++i) { | 1070 for (unsigned i = 0; i < len; ++i) { |
| 1071 const Attribute& attribute = begin[i]; | 1071 const Attribute& attribute = begin[i]; |
| 1072 if (!attribute.name().hasPrefix()) { | 1072 if (!attribute.name().hasPrefix()) { |
| 1073 if (name == attribute.localName()) | 1073 if (name == attribute.localName()) |
| 1074 return i; | 1074 return i; |
| 1075 } else | 1075 } else |
| 1076 doSlowCheck = true; | 1076 doSlowCheck = true; |
| 1077 } | 1077 } |
| 1078 | 1078 |
| 1079 if (doSlowCheck) | 1079 if (doSlowCheck) |
| 1080 return getAttributeItemIndexSlowCase(name, shouldIgnoreAttributeCase); | 1080 return getAttributeItemIndexSlowCase(name, shouldIgnoreAttributeCase); |
| 1081 return notFound; | 1081 return kNotFound; |
| 1082 } | 1082 } |
| 1083 | 1083 |
| 1084 inline const Attribute* ElementData::getAttributeItem(const QualifiedName& name)
const | 1084 inline const Attribute* ElementData::getAttributeItem(const QualifiedName& name)
const |
| 1085 { | 1085 { |
| 1086 const Attribute* begin = attributeBase(); | 1086 const Attribute* begin = attributeBase(); |
| 1087 for (unsigned i = 0; i < length(); ++i) { | 1087 for (unsigned i = 0; i < length(); ++i) { |
| 1088 const Attribute& attribute = begin[i]; | 1088 const Attribute& attribute = begin[i]; |
| 1089 if (attribute.name().matches(name)) | 1089 if (attribute.name().matches(name)) |
| 1090 return &attribute; | 1090 return &attribute; |
| 1091 } | 1091 } |
| 1092 return 0; | 1092 return 0; |
| 1093 } | 1093 } |
| 1094 | 1094 |
| 1095 inline const Attribute* ElementData::attributeItem(unsigned index) const | 1095 inline const Attribute* ElementData::attributeItem(unsigned index) const |
| 1096 { | 1096 { |
| 1097 RELEASE_ASSERT(index < length()); | 1097 RELEASE_ASSERT(index < length()); |
| 1098 return attributeBase() + index; | 1098 return attributeBase() + index; |
| 1099 } | 1099 } |
| 1100 | 1100 |
| 1101 } // namespace | 1101 } // namespace |
| 1102 | 1102 |
| 1103 #endif | 1103 #endif |
| OLD | NEW |