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

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

Issue 1854423002: ASSERT -> {DCHECK|DCHECK_XX}, ENABLE(ASSERT) -> DCHECK_IS_ON() in dom (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: mark svg/as-image/svg-nested.html crash on win Created 4 years, 8 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
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-2011, 2013, 2014 Apple Inc. All rights reserved. 6 * Copyright (C) 2003-2011, 2013, 2014 Apple 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 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 int getIntegralAttribute(const QualifiedName& attributeName) const; 141 int getIntegralAttribute(const QualifiedName& attributeName) const;
142 void setIntegralAttribute(const QualifiedName& attributeName, int value); 142 void setIntegralAttribute(const QualifiedName& attributeName, int value);
143 void setUnsignedIntegralAttribute(const QualifiedName& attributeName, unsign ed value); 143 void setUnsignedIntegralAttribute(const QualifiedName& attributeName, unsign ed value);
144 double getFloatingPointAttribute(const QualifiedName& attributeName, double fallbackValue = std::numeric_limits<double>::quiet_NaN()) const; 144 double getFloatingPointAttribute(const QualifiedName& attributeName, double fallbackValue = std::numeric_limits<double>::quiet_NaN()) const;
145 void setFloatingPointAttribute(const QualifiedName& attributeName, double va lue); 145 void setFloatingPointAttribute(const QualifiedName& attributeName, double va lue);
146 146
147 // Call this to get the value of an attribute that is known not to be the st yle 147 // Call this to get the value of an attribute that is known not to be the st yle
148 // attribute or one of the SVG animatable attributes. 148 // attribute or one of the SVG animatable attributes.
149 bool fastHasAttribute(const QualifiedName&) const; 149 bool fastHasAttribute(const QualifiedName&) const;
150 const AtomicString& fastGetAttribute(const QualifiedName&) const; 150 const AtomicString& fastGetAttribute(const QualifiedName&) const;
151 #if ENABLE(ASSERT) 151 #if DCHECK_IS_ON()
152 bool fastAttributeLookupAllowed(const QualifiedName&) const; 152 bool fastAttributeLookupAllowed(const QualifiedName&) const;
153 #endif 153 #endif
154 154
155 #ifdef DUMP_NODE_STATISTICS 155 #ifdef DUMP_NODE_STATISTICS
156 bool hasNamedNodeMap() const; 156 bool hasNamedNodeMap() const;
157 #endif 157 #endif
158 bool hasAttributes() const; 158 bool hasAttributes() const;
159 159
160 bool hasAttribute(const AtomicString& name) const; 160 bool hasAttribute(const AtomicString& name) const;
161 bool hasAttributeNS(const AtomicString& namespaceURI, const AtomicString& lo calName) const; 161 bool hasAttributeNS(const AtomicString& namespaceURI, const AtomicString& lo calName) const;
(...skipping 588 matching lines...) Expand 10 before | Expand all | Expand 10 after
750 } 750 }
751 751
752 inline Element* Node::parentElement() const 752 inline Element* Node::parentElement() const
753 { 753 {
754 ContainerNode* parent = parentNode(); 754 ContainerNode* parent = parentNode();
755 return parent && parent->isElementNode() ? toElement(parent) : nullptr; 755 return parent && parent->isElementNode() ? toElement(parent) : nullptr;
756 } 756 }
757 757
758 inline bool Element::fastHasAttribute(const QualifiedName& name) const 758 inline bool Element::fastHasAttribute(const QualifiedName& name) const
759 { 759 {
760 ASSERT(fastAttributeLookupAllowed(name)); 760 #if DCHECK_IS_ON()
761 DCHECK(fastAttributeLookupAllowed(name));
762 #endif
761 return elementData() && elementData()->attributes().findIndex(name) != kNotF ound; 763 return elementData() && elementData()->attributes().findIndex(name) != kNotF ound;
762 } 764 }
763 765
764 inline const AtomicString& Element::fastGetAttribute(const QualifiedName& name) const 766 inline const AtomicString& Element::fastGetAttribute(const QualifiedName& name) const
765 { 767 {
766 ASSERT(fastAttributeLookupAllowed(name)); 768 #if DCHECK_IS_ON()
769 DCHECK(fastAttributeLookupAllowed(name));
770 #endif
767 if (elementData()) { 771 if (elementData()) {
768 if (const Attribute* attribute = elementData()->attributes().find(name)) 772 if (const Attribute* attribute = elementData()->attributes().find(name))
769 return attribute->value(); 773 return attribute->value();
770 } 774 }
771 return nullAtom; 775 return nullAtom;
772 } 776 }
773 777
774 inline AttributeCollection Element::attributes() const 778 inline AttributeCollection Element::attributes() const
775 { 779 {
776 if (!elementData()) 780 if (!elementData())
777 return AttributeCollection(); 781 return AttributeCollection();
778 synchronizeAllAttributes(); 782 synchronizeAllAttributes();
779 return elementData()->attributes(); 783 return elementData()->attributes();
780 } 784 }
781 785
782 inline AttributeCollection Element::attributesWithoutUpdate() const 786 inline AttributeCollection Element::attributesWithoutUpdate() const
783 { 787 {
784 if (!elementData()) 788 if (!elementData())
785 return AttributeCollection(); 789 return AttributeCollection();
786 return elementData()->attributes(); 790 return elementData()->attributes();
787 } 791 }
788 792
789 inline bool Element::hasAttributes() const 793 inline bool Element::hasAttributes() const
790 { 794 {
791 return !attributes().isEmpty(); 795 return !attributes().isEmpty();
792 } 796 }
793 797
794 inline const AtomicString& Element::idForStyleResolution() const 798 inline const AtomicString& Element::idForStyleResolution() const
795 { 799 {
796 ASSERT(hasID()); 800 DCHECK(hasID());
797 return elementData()->idForStyleResolution(); 801 return elementData()->idForStyleResolution();
798 } 802 }
799 803
800 inline const AtomicString& Element::getIdAttribute() const 804 inline const AtomicString& Element::getIdAttribute() const
801 { 805 {
802 return hasID() ? fastGetAttribute(HTMLNames::idAttr) : nullAtom; 806 return hasID() ? fastGetAttribute(HTMLNames::idAttr) : nullAtom;
803 } 807 }
804 808
805 inline const AtomicString& Element::getNameAttribute() const 809 inline const AtomicString& Element::getNameAttribute() const
806 { 810 {
807 return hasName() ? fastGetAttribute(HTMLNames::nameAttr) : nullAtom; 811 return hasName() ? fastGetAttribute(HTMLNames::nameAttr) : nullAtom;
808 } 812 }
809 813
810 inline const AtomicString& Element::getClassAttribute() const 814 inline const AtomicString& Element::getClassAttribute() const
811 { 815 {
812 if (!hasClass()) 816 if (!hasClass())
813 return nullAtom; 817 return nullAtom;
814 if (isSVGElement()) 818 if (isSVGElement())
815 return getAttribute(HTMLNames::classAttr); 819 return getAttribute(HTMLNames::classAttr);
816 return fastGetAttribute(HTMLNames::classAttr); 820 return fastGetAttribute(HTMLNames::classAttr);
817 } 821 }
818 822
819 inline void Element::setIdAttribute(const AtomicString& value) 823 inline void Element::setIdAttribute(const AtomicString& value)
820 { 824 {
821 setAttribute(HTMLNames::idAttr, value); 825 setAttribute(HTMLNames::idAttr, value);
822 } 826 }
823 827
824 inline const SpaceSplitString& Element::classNames() const 828 inline const SpaceSplitString& Element::classNames() const
825 { 829 {
826 ASSERT(hasClass()); 830 DCHECK(hasClass());
827 ASSERT(elementData()); 831 DCHECK(elementData());
828 return elementData()->classNames(); 832 return elementData()->classNames();
829 } 833 }
830 834
831 inline bool Element::hasID() const 835 inline bool Element::hasID() const
832 { 836 {
833 return elementData() && elementData()->hasID(); 837 return elementData() && elementData()->hasID();
834 } 838 }
835 839
836 inline bool Element::hasClass() const 840 inline bool Element::hasClass() const
837 { 841 {
838 return elementData() && elementData()->hasClass(); 842 return elementData() && elementData()->hasClass();
839 } 843 }
840 844
841 inline UniqueElementData& Element::ensureUniqueElementData() 845 inline UniqueElementData& Element::ensureUniqueElementData()
842 { 846 {
843 if (!elementData() || !elementData()->isUnique()) 847 if (!elementData() || !elementData()->isUnique())
844 createUniqueElementData(); 848 createUniqueElementData();
845 return toUniqueElementData(*m_elementData); 849 return toUniqueElementData(*m_elementData);
846 } 850 }
847 851
848 inline Node::InsertionNotificationRequest Node::insertedInto(ContainerNode* inse rtionPoint) 852 inline Node::InsertionNotificationRequest Node::insertedInto(ContainerNode* inse rtionPoint)
849 { 853 {
850 ASSERT(!childNeedsStyleInvalidation()); 854 DCHECK(!childNeedsStyleInvalidation());
851 ASSERT(!needsStyleInvalidation()); 855 DCHECK(!needsStyleInvalidation());
852 ASSERT(insertionPoint->inShadowIncludingDocument() || insertionPoint->isInSh adowTree() || isContainerNode()); 856 DCHECK(insertionPoint->inShadowIncludingDocument() || insertionPoint->isInSh adowTree() || isContainerNode());
853 if (insertionPoint->inShadowIncludingDocument()) { 857 if (insertionPoint->inShadowIncludingDocument()) {
854 setFlag(InDocumentFlag); 858 setFlag(InDocumentFlag);
855 insertionPoint->document().incrementNodeCount(); 859 insertionPoint->document().incrementNodeCount();
856 } 860 }
857 if (parentOrShadowHostNode()->isInShadowTree()) 861 if (parentOrShadowHostNode()->isInShadowTree())
858 setFlag(IsInShadowTreeFlag); 862 setFlag(IsInShadowTreeFlag);
859 if (childNeedsDistributionRecalc() && !insertionPoint->childNeedsDistributio nRecalc()) 863 if (childNeedsDistributionRecalc() && !insertionPoint->childNeedsDistributio nRecalc())
860 insertionPoint->markAncestorsWithChildNeedsDistributionRecalc(); 864 insertionPoint->markAncestorsWithChildNeedsDistributionRecalc();
861 return InsertionDone; 865 return InsertionDone;
862 } 866 }
863 867
864 inline void Node::removedFrom(ContainerNode* insertionPoint) 868 inline void Node::removedFrom(ContainerNode* insertionPoint)
865 { 869 {
866 ASSERT(insertionPoint->inShadowIncludingDocument() || isContainerNode() || i sInShadowTree()); 870 DCHECK(insertionPoint->inShadowIncludingDocument() || isContainerNode() || i sInShadowTree());
867 if (insertionPoint->inShadowIncludingDocument()) { 871 if (insertionPoint->inShadowIncludingDocument()) {
868 clearFlag(InDocumentFlag); 872 clearFlag(InDocumentFlag);
869 insertionPoint->document().decrementNodeCount(); 873 insertionPoint->document().decrementNodeCount();
870 } 874 }
871 if (isInShadowTree() && !treeScope().rootNode().isShadowRoot()) 875 if (isInShadowTree() && !treeScope().rootNode().isShadowRoot())
872 clearFlag(IsInShadowTreeFlag); 876 clearFlag(IsInShadowTreeFlag);
873 if (AXObjectCache* cache = document().existingAXObjectCache()) 877 if (AXObjectCache* cache = document().existingAXObjectCache())
874 cache->remove(this); 878 cache->remove(this);
875 } 879 }
876 880
877 inline void Element::invalidateStyleAttribute() 881 inline void Element::invalidateStyleAttribute()
878 { 882 {
879 ASSERT(elementData()); 883 DCHECK(elementData());
880 elementData()->m_styleAttributeIsDirty = true; 884 elementData()->m_styleAttributeIsDirty = true;
881 } 885 }
882 886
883 inline const StylePropertySet* Element::presentationAttributeStyle() 887 inline const StylePropertySet* Element::presentationAttributeStyle()
884 { 888 {
885 if (!elementData()) 889 if (!elementData())
886 return nullptr; 890 return nullptr;
887 if (elementData()->m_presentationAttributeStyleIsDirty) 891 if (elementData()->m_presentationAttributeStyleIsDirty)
888 updatePresentationAttributeStyle(); 892 updatePresentationAttributeStyle();
889 // Need to call elementData() again since updatePresentationAttributeStyle() 893 // Need to call elementData() again since updatePresentationAttributeStyle()
890 // might swap it with a UniqueElementData. 894 // might swap it with a UniqueElementData.
891 return elementData()->presentationAttributeStyle(); 895 return elementData()->presentationAttributeStyle();
892 } 896 }
893 897
894 inline void Element::setTagNameForCreateElementNS(const QualifiedName& tagName) 898 inline void Element::setTagNameForCreateElementNS(const QualifiedName& tagName)
895 { 899 {
896 // We expect this method to be called only to reset the prefix. 900 // We expect this method to be called only to reset the prefix.
897 ASSERT(tagName.localName() == m_tagName.localName()); 901 DCHECK_EQ(tagName.localName(), m_tagName.localName());
898 ASSERT(tagName.namespaceURI() == m_tagName.namespaceURI()); 902 DCHECK_EQ(tagName.namespaceURI(), m_tagName.namespaceURI());
899 m_tagName = tagName; 903 m_tagName = tagName;
900 } 904 }
901 905
902 inline AtomicString Element::localNameForSelectorMatching() const 906 inline AtomicString Element::localNameForSelectorMatching() const
903 { 907 {
904 if (isHTMLElement() || !document().isHTMLDocument()) 908 if (isHTMLElement() || !document().isHTMLDocument())
905 return localName(); 909 return localName();
906 return localName().lower(); 910 return localName().lower();
907 } 911 }
908 912
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
948 static RawPtr<T> create(const QualifiedName&, Document&) 952 static RawPtr<T> create(const QualifiedName&, Document&)
949 #define DEFINE_ELEMENT_FACTORY_WITH_TAGNAME(T) \ 953 #define DEFINE_ELEMENT_FACTORY_WITH_TAGNAME(T) \
950 RawPtr<T> T::create(const QualifiedName& tagName, Document& document) \ 954 RawPtr<T> T::create(const QualifiedName& tagName, Document& document) \
951 { \ 955 { \
952 return new T(tagName, document); \ 956 return new T(tagName, document); \
953 } 957 }
954 958
955 } // namespace blink 959 } // namespace blink
956 960
957 #endif // Element_h 961 #endif // Element_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/DocumentVisibilityObserver.cpp ('k') | third_party/WebKit/Source/core/dom/Element.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698