Chromium Code Reviews| Index: Source/core/dom/Element.cpp |
| diff --git a/Source/core/dom/Element.cpp b/Source/core/dom/Element.cpp |
| index bb3e0aad6f5ef42a05593dfba29040649ea60d5c..a4e914d5af39c69e1ca84ba8eee0aaf65f18ffaf 100644 |
| --- a/Source/core/dom/Element.cpp |
| +++ b/Source/core/dom/Element.cpp |
| @@ -908,6 +908,43 @@ IntRect Element::screenRect() const |
| return document().view()->contentsToScreen(renderer()->absoluteBoundingBoxRectIgnoringTransforms()); |
| } |
| +static inline const QualifiedName& fastAttributeNameFromString(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 (length == 5 && name[0] == 'c' && name[1] == 'l' && name[2] == 'a' && name[3] == 's' && name[4] == 's') |
| + return HTMLNames::classAttr; |
| + if (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(localName); |
| + if (fastName != nullQName()) |
| + return fastGetAttribute(fastName); |
| + return getAttribute(AtomicString(localName)); |
| +} |
| + |
| +void Element::bindingsSetAttribute(const String& localName, const String& newValue, ExceptionState& exceptionState) |
|
Inactive
2014/03/07 13:23:10
Looks like newValue should be an AtomicString.
|
| +{ |
| + const QualifiedName& fastName = fastAttributeNameFromString(localName); |
| + if (fastName != nullQName()) { |
| + setAttribute(fastName, AtomicString(newValue)); |
| + return; |
| + } |
| + setAttribute(AtomicString(localName), AtomicString(newValue), exceptionState); |
| +} |
| + |
| const AtomicString& Element::getAttribute(const AtomicString& localName) const |
| { |
| if (!elementData()) |