Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(696)

Side by Side Diff: Source/core/dom/Element.cpp

Issue 189483004: WontFix: Add fast path for id/name/style/class in getAttribute/setAttribute bindings. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: deal with svg Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Source/core/dom/Element.h ('k') | Source/core/dom/Element.idl » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 Element& el ement, const AtomicString& localName)
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')
Inactive 2014/03/11 13:48:33 if localName if an AtomicString, checking its char
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 (!element.isSVGElement() && length == 5 && name[0] == 'c' && name[1] == ' l' && name[2] == 'a' && name[3] == 's' && name[4] == 's')
923 return HTMLNames::classAttr;
924
925 return nullQName();
926 }
927
928 const AtomicString& Element::bindingsGetAttribute(const AtomicString& localName) const
Inactive 2014/03/11 13:48:33 Based on the Changelog on WebKit side, part of the
929 {
930 const QualifiedName& fastName = fastAttributeNameFromString(*this, localName );
931 if (fastName != nullQName())
932 return fastGetAttribute(fastName);
933 return getAttribute(localName);
934 }
935
936 static inline const QualifiedName& principalAttributeNameFromString(const Atomic String& localName)
Inactive 2014/03/11 13:48:33 Sorry, I don't like the fact that we now have 2 fu
937 {
938 unsigned length = localName.length();
939 if (!length)
940 return nullQName();
941 const StringImpl& name = *localName.impl();
942
943 if (length == 2 && name[0] == 'i' && name[1] == 'd')
944 return HTMLNames::idAttr;
945 if (length == 4 && name[0] == 'n' && name[1] == 'a' && name[2] == 'm' && nam e[3] == 'e')
946 return HTMLNames::nameAttr;
947 if (length == 5 && name[0] == 'c' && name[1] == 'l' && name[2] == 'a' && nam e[3] == 's' && name[4] == 's')
948 return HTMLNames::classAttr;
949 if (length == 5 && name[0] == 's' && name[1] == 't' && name[2] == 'y' && nam e[3] == 'l' && name[4] == 'e')
950 return HTMLNames::styleAttr;
951
952 return nullQName();
953 }
954
955 void Element::bindingsSetAttribute(const AtomicString& localName, const AtomicSt ring& newValue, ExceptionState& exceptionState)
Inactive 2014/03/11 13:48:33 localName should be a String. I only asked for new
956 {
957 const QualifiedName& principalAttributeName = principalAttributeNameFromStri ng(localName);
958 if (principalAttributeName != nullQName()) {
959 setAttribute(principalAttributeName, AtomicString(newValue));
Inactive 2014/03/11 13:48:33 Useless AtomicString(). Note that WebKit has a fa
960 return;
961 }
962 setAttribute(localName, newValue, exceptionState);
963 }
964
911 const AtomicString& Element::getAttribute(const AtomicString& localName) const 965 const AtomicString& Element::getAttribute(const AtomicString& localName) const
912 { 966 {
913 if (!elementData()) 967 if (!elementData())
914 return nullAtom; 968 return nullAtom;
915 synchronizeAttribute(localName); 969 synchronizeAttribute(localName);
916 if (const Attribute* attribute = elementData()->getAttributeItem(localName, shouldIgnoreAttributeCase())) 970 if (const Attribute* attribute = elementData()->getAttributeItem(localName, shouldIgnoreAttributeCase()))
917 return attribute->value(); 971 return attribute->value();
918 return nullAtom; 972 return nullAtom;
919 } 973 }
920 974
(...skipping 2619 matching lines...) Expand 10 before | Expand all | Expand 10 after
3540 // Before doing so, we need to resolve issues in HTMLSelectElement::recalcLi stItems 3594 // 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 3595 // and RenderMenuList::setText. See also https://bugs.webkit.org/show_bug.cg i?id=88405
3542 if (hasTagName(optionTag) || hasTagName(optgroupTag)) 3596 if (hasTagName(optionTag) || hasTagName(optgroupTag))
3543 return false; 3597 return false;
3544 if (FullscreenElementStack::isActiveFullScreenElement(this)) 3598 if (FullscreenElementStack::isActiveFullScreenElement(this))
3545 return false; 3599 return false;
3546 return true; 3600 return true;
3547 } 3601 }
3548 3602
3549 } // namespace WebCore 3603 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/dom/Element.h ('k') | Source/core/dom/Element.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698