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

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

Issue 23819007: Have Node::document() return a reference instead of a pointer (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase on master Created 7 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/dom/DocumentType.cpp ('k') | Source/core/dom/Element.cpp » ('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 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2013 Appl e Inc. All rights reserved. 6 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2013 Appl e Inc. All rights reserved.
7 * 7 *
8 * This library is free software; you can redistribute it and/or 8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public 9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
(...skipping 866 matching lines...) Expand 10 before | Expand all | Expand 10 after
877 ASSERT(hasID()); 877 ASSERT(hasID());
878 return elementData()->idForStyleResolution(); 878 return elementData()->idForStyleResolution();
879 } 879 }
880 880
881 inline bool Element::isIdAttributeName(const QualifiedName& attributeName) const 881 inline bool Element::isIdAttributeName(const QualifiedName& attributeName) const
882 { 882 {
883 // FIXME: This check is probably not correct for the case where the document has an id attribute 883 // FIXME: This check is probably not correct for the case where the document has an id attribute
884 // with a non-null namespace, because it will return false, a false negative , if the prefixes 884 // with a non-null namespace, because it will return false, a false negative , if the prefixes
885 // don't match but the local name and namespace both do. However, since this has been like this 885 // don't match but the local name and namespace both do. However, since this has been like this
886 // for a while and the code paths may be hot, we'll have to measure performa nce if we fix it. 886 // for a while and the code paths may be hot, we'll have to measure performa nce if we fix it.
887 return attributeName == document()->idAttributeName(); 887 return attributeName == document().idAttributeName();
888 } 888 }
889 889
890 inline const AtomicString& Element::getIdAttribute() const 890 inline const AtomicString& Element::getIdAttribute() const
891 { 891 {
892 return hasID() ? fastGetAttribute(document()->idAttributeName()) : nullAtom; 892 return hasID() ? fastGetAttribute(document().idAttributeName()) : nullAtom;
893 } 893 }
894 894
895 inline const AtomicString& Element::getNameAttribute() const 895 inline const AtomicString& Element::getNameAttribute() const
896 { 896 {
897 return hasName() ? fastGetAttribute(HTMLNames::nameAttr) : nullAtom; 897 return hasName() ? fastGetAttribute(HTMLNames::nameAttr) : nullAtom;
898 } 898 }
899 899
900 inline const AtomicString& Element::getClassAttribute() const 900 inline const AtomicString& Element::getClassAttribute() const
901 { 901 {
902 if (!hasClass()) 902 if (!hasClass())
903 return nullAtom; 903 return nullAtom;
904 if (isSVGElement()) 904 if (isSVGElement())
905 return getAttribute(HTMLNames::classAttr); 905 return getAttribute(HTMLNames::classAttr);
906 return fastGetAttribute(HTMLNames::classAttr); 906 return fastGetAttribute(HTMLNames::classAttr);
907 } 907 }
908 908
909 inline void Element::setIdAttribute(const AtomicString& value) 909 inline void Element::setIdAttribute(const AtomicString& value)
910 { 910 {
911 setAttribute(document()->idAttributeName(), value); 911 setAttribute(document().idAttributeName(), value);
912 } 912 }
913 913
914 inline const SpaceSplitString& Element::classNames() const 914 inline const SpaceSplitString& Element::classNames() const
915 { 915 {
916 ASSERT(hasClass()); 916 ASSERT(hasClass());
917 ASSERT(elementData()); 917 ASSERT(elementData());
918 return elementData()->classNames(); 918 return elementData()->classNames();
919 } 919 }
920 920
921 inline size_t Element::attributeCount() const 921 inline size_t Element::attributeCount() const
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
1086 1086
1087 inline const Attribute* ElementData::attributeItem(unsigned index) const 1087 inline const Attribute* ElementData::attributeItem(unsigned index) const
1088 { 1088 {
1089 RELEASE_ASSERT(index < length()); 1089 RELEASE_ASSERT(index < length());
1090 return attributeBase() + index; 1090 return attributeBase() + index;
1091 } 1091 }
1092 1092
1093 } // namespace 1093 } // namespace
1094 1094
1095 #endif 1095 #endif
OLDNEW
« no previous file with comments | « Source/core/dom/DocumentType.cpp ('k') | Source/core/dom/Element.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698