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..aa505909a6712eca6a0035acc1871195197c7620 100644 |
| --- a/Source/core/dom/Element.cpp |
| +++ b/Source/core/dom/Element.cpp |
| @@ -908,6 +908,41 @@ IntRect Element::screenRect() const |
| return document().view()->contentsToScreen(renderer()->absoluteBoundingBoxRectIgnoringTransforms()); |
| } |
| +static inline const QualifiedName& fastAttributeNameFromString(const String& localName) |
|
Inactive
2014/03/10 19:56:23
add "const Element& element" argument.
|
| +{ |
| + 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') |
|
Inactive
2014/03/10 19:56:23
add "!element.isSVGElement() && " condition.
|
| + return HTMLNames::classAttr; |
|
Inactive
2014/03/10 18:58:26
Technically, I believe we cannot do a fast lookup
|
| + |
| + return nullQName(); |
| +} |
| + |
| +const AtomicString& Element::bindingsGetAttribute(const String& localName) const |
| +{ |
| + const QualifiedName& fastName = fastAttributeNameFromString(localName); |
|
Inactive
2014/03/10 19:56:23
fastAttributeNameFromString(*this, 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/10 18:46:45
I think I made this comment before but newValue sh
Inactive
2014/03/10 20:04:15
To be clear, I only want newValue to be an AtomicS
|
| +{ |
| + const QualifiedName& fastName = fastAttributeNameFromString(localName); |
|
Inactive
2014/03/10 19:56:23
fastAttributeNameFromString(*this, 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()) |