| Index: Source/core/dom/Element.cpp
|
| diff --git a/Source/core/dom/Element.cpp b/Source/core/dom/Element.cpp
|
| index bb3e0aad6f5ef42a05593dfba29040649ea60d5c..c6a0edab66f32e92e4f95083385e3f8388168ee5 100644
|
| --- a/Source/core/dom/Element.cpp
|
| +++ b/Source/core/dom/Element.cpp
|
| @@ -908,6 +908,50 @@ IntRect Element::screenRect() const
|
| return document().view()->contentsToScreen(renderer()->absoluteBoundingBoxRectIgnoringTransforms());
|
| }
|
|
|
| +namespace {
|
| +enum CallerType {
|
| + Getter,
|
| + Setter
|
| +};
|
| +
|
| +template<CallerType caller> static inline const QualifiedName& fastAttributeNameFromString(const Element& element, const String& localName)
|
| +{
|
| + unsigned length = localName.length();
|
| + if (!length)
|
| + return nullQName();
|
| + const StringImpl& name = *localName.impl();
|
| +
|
| + if (length == 2 && name[0] == 'i' && name[1] == 'd')
|
| + return HTMLNames::idAttr;
|
| + if (length == 4 && name[0] == 'n' && name[1] == 'a' && name[2] == 'm' && name[3] == 'e')
|
| + return HTMLNames::nameAttr;
|
| + if ((caller == Setter || !element.isSVGElement()) && length == 5 && name[0] == 'c' && name[1] == 'l' && name[2] == 'a' && name[3] == 's' && name[4] == 's')
|
| + return HTMLNames::classAttr;
|
| + if (caller == Setter && length == 5 && name[0] == 's' && name[1] == 't' && name[2] == 'y' && name[3] == 'l' && name[4] == 'e')
|
| + return HTMLNames::styleAttr;
|
| +
|
| + return nullQName();
|
| +}
|
| +}
|
| +
|
| +const AtomicString& Element::bindingsGetAttribute(const String& localName) const
|
| +{
|
| + const QualifiedName& fastName = fastAttributeNameFromString<Getter>(*this, localName);
|
| + if (fastName != nullQName())
|
| + return fastGetAttribute(fastName);
|
| + return getAttribute(AtomicString(localName));
|
| +}
|
| +
|
| +void Element::bindingsSetAttribute(const String& localName, const AtomicString& newValue, ExceptionState& exceptionState)
|
| +{
|
| + const QualifiedName& fastName = fastAttributeNameFromString<Setter>(*this, localName);
|
| + if (fastName != nullQName()) {
|
| + setAttribute(fastName, newValue);
|
| + return;
|
| + }
|
| + setAttribute(AtomicString(localName), newValue, exceptionState);
|
| +}
|
| +
|
| const AtomicString& Element::getAttribute(const AtomicString& localName) const
|
| {
|
| if (!elementData())
|
|
|