Chromium Code Reviews| 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 * (C) 2007 David Smith (catfish.man@gmail.com) | 6 * (C) 2007 David Smith (catfish.man@gmail.com) |
| 7 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012, 2013 Apple Inc. All rights reserved. | 7 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012, 2013 Apple Inc. All rights reserved. |
| 8 * (C) 2007 Eric Seidel (eric@webkit.org) | 8 * (C) 2007 Eric Seidel (eric@webkit.org) |
| 9 * | 9 * |
| 10 * This library is free software; you can redistribute it and/or | 10 * This library is free software; you can redistribute it and/or |
| (...skipping 890 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 901 } | 901 } |
| 902 | 902 |
| 903 IntRect Element::screenRect() const | 903 IntRect Element::screenRect() const |
| 904 { | 904 { |
| 905 if (!renderer()) | 905 if (!renderer()) |
| 906 return IntRect(); | 906 return IntRect(); |
| 907 // FIXME: this should probably respect transforms | 907 // FIXME: this should probably respect transforms |
| 908 return document().view()->contentsToScreen(renderer()->absoluteBoundingBoxRe ctIgnoringTransforms()); | 908 return document().view()->contentsToScreen(renderer()->absoluteBoundingBoxRe ctIgnoringTransforms()); |
| 909 } | 909 } |
| 910 | 910 |
| 911 static inline const QualifiedName& fastAttributeNameFromString(const String& loc alName) | |
|
Inactive
2014/03/10 19:56:23
add "const Element& element" argument.
| |
| 912 { | |
| 913 unsigned length = localName.length(); | |
| 914 if (!length) | |
| 915 return nullQName(); | |
| 916 const StringImpl& name = *localName.impl(); | |
| 917 | |
| 918 if (length == 2 && name[0] == 'i' && name[1] == 'd') | |
| 919 return HTMLNames::idAttr; | |
| 920 if (length == 4 && name[0] == 'n' && name[1] == 'a' && name[2] == 'm' && nam e[3] == 'e') | |
| 921 return HTMLNames::nameAttr; | |
| 922 if (length == 5 && name[0] == 'c' && name[1] == 'l' && name[2] == 'a' && nam e[3] == 's' && name[4] == 's') | |
|
Inactive
2014/03/10 19:56:23
add "!element.isSVGElement() && " condition.
| |
| 923 return HTMLNames::classAttr; | |
|
Inactive
2014/03/10 18:58:26
Technically, I believe we cannot do a fast lookup
| |
| 924 | |
| 925 return nullQName(); | |
| 926 } | |
| 927 | |
| 928 const AtomicString& Element::bindingsGetAttribute(const String& localName) const | |
| 929 { | |
| 930 const QualifiedName& fastName = fastAttributeNameFromString(localName); | |
|
Inactive
2014/03/10 19:56:23
fastAttributeNameFromString(*this, localName);
| |
| 931 if (fastName != nullQName()) | |
| 932 return fastGetAttribute(fastName); | |
| 933 return getAttribute(AtomicString(localName)); | |
| 934 } | |
| 935 | |
| 936 void Element::bindingsSetAttribute(const String& localName, const String& newVal ue, 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
| |
| 937 { | |
| 938 const QualifiedName& fastName = fastAttributeNameFromString(localName); | |
|
Inactive
2014/03/10 19:56:23
fastAttributeNameFromString(*this, localName);
| |
| 939 if (fastName != nullQName()) { | |
| 940 setAttribute(fastName, AtomicString(newValue)); | |
| 941 return; | |
| 942 } | |
| 943 setAttribute(AtomicString(localName), AtomicString(newValue), exceptionState ); | |
| 944 } | |
| 945 | |
| 911 const AtomicString& Element::getAttribute(const AtomicString& localName) const | 946 const AtomicString& Element::getAttribute(const AtomicString& localName) const |
| 912 { | 947 { |
| 913 if (!elementData()) | 948 if (!elementData()) |
| 914 return nullAtom; | 949 return nullAtom; |
| 915 synchronizeAttribute(localName); | 950 synchronizeAttribute(localName); |
| 916 if (const Attribute* attribute = elementData()->getAttributeItem(localName, shouldIgnoreAttributeCase())) | 951 if (const Attribute* attribute = elementData()->getAttributeItem(localName, shouldIgnoreAttributeCase())) |
| 917 return attribute->value(); | 952 return attribute->value(); |
| 918 return nullAtom; | 953 return nullAtom; |
| 919 } | 954 } |
| 920 | 955 |
| (...skipping 2004 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2925 } | 2960 } |
| 2926 } | 2961 } |
| 2927 | 2962 |
| 2928 return true; | 2963 return true; |
| 2929 } | 2964 } |
| 2930 | 2965 |
| 2931 #ifndef NDEBUG | 2966 #ifndef NDEBUG |
| 2932 bool Element::fastAttributeLookupAllowed(const QualifiedName& name) const | 2967 bool Element::fastAttributeLookupAllowed(const QualifiedName& name) const |
| 2933 { | 2968 { |
| 2934 if (name == HTMLNames::styleAttr) | 2969 if (name == HTMLNames::styleAttr) |
| 2935 return false; | 2970 return false; |
|
dshwang
2014/03/10 18:43:20
Blink does not support styleAttr fast path.
| |
| 2936 | 2971 |
| 2937 if (isSVGElement()) | 2972 if (isSVGElement()) |
| 2938 return !toSVGElement(this)->isAnimatableAttribute(name); | 2973 return !toSVGElement(this)->isAnimatableAttribute(name); |
|
dshwang
2014/03/10 19:48:59
Thanks Chris. here is svg consideration.
How abou
Inactive
2014/03/10 19:56:23
No, fastAttributeLookupAllowed() is only available
| |
| 2939 | 2974 |
| 2940 return true; | 2975 return true; |
| 2941 } | 2976 } |
| 2942 #endif | 2977 #endif |
| 2943 | 2978 |
| 2944 #ifdef DUMP_NODE_STATISTICS | 2979 #ifdef DUMP_NODE_STATISTICS |
| 2945 bool Element::hasNamedNodeMap() const | 2980 bool Element::hasNamedNodeMap() const |
| 2946 { | 2981 { |
| 2947 return hasRareData() && elementRareData()->attributeMap(); | 2982 return hasRareData() && elementRareData()->attributeMap(); |
| 2948 } | 2983 } |
| (...skipping 591 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3540 // Before doing so, we need to resolve issues in HTMLSelectElement::recalcLi stItems | 3575 // Before doing so, we need to resolve issues in HTMLSelectElement::recalcLi stItems |
| 3541 // and RenderMenuList::setText. See also https://bugs.webkit.org/show_bug.cg i?id=88405 | 3576 // and RenderMenuList::setText. See also https://bugs.webkit.org/show_bug.cg i?id=88405 |
| 3542 if (hasTagName(optionTag) || hasTagName(optgroupTag)) | 3577 if (hasTagName(optionTag) || hasTagName(optgroupTag)) |
| 3543 return false; | 3578 return false; |
| 3544 if (FullscreenElementStack::isActiveFullScreenElement(this)) | 3579 if (FullscreenElementStack::isActiveFullScreenElement(this)) |
| 3545 return false; | 3580 return false; |
| 3546 return true; | 3581 return true; |
| 3547 } | 3582 } |
| 3548 | 3583 |
| 3549 } // namespace WebCore | 3584 } // namespace WebCore |
| OLD | NEW |