| 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 * 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 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 bool fastHasAttribute(const QualifiedName&) const; | 132 bool fastHasAttribute(const QualifiedName&) const; |
| 133 const AtomicString& fastGetAttribute(const QualifiedName&) const; | 133 const AtomicString& fastGetAttribute(const QualifiedName&) const; |
| 134 #if ENABLE(ASSERT) | 134 #if ENABLE(ASSERT) |
| 135 bool fastAttributeLookupAllowed(const QualifiedName&) const; | 135 bool fastAttributeLookupAllowed(const QualifiedName&) const; |
| 136 #endif | 136 #endif |
| 137 | 137 |
| 138 #ifdef DUMP_NODE_STATISTICS | 138 #ifdef DUMP_NODE_STATISTICS |
| 139 bool hasNamedNodeMap() const; | 139 bool hasNamedNodeMap() const; |
| 140 #endif | 140 #endif |
| 141 bool hasAttributes() const; | 141 bool hasAttributes() const; |
| 142 // This variant will not update the potentially invalid attributes. To be us
ed when not interested | |
| 143 // in style attribute or one of the SVG animation attributes. | |
| 144 bool hasAttributesWithoutUpdate() const; | |
| 145 | 142 |
| 146 bool hasAttribute(const AtomicString& name) const; | 143 bool hasAttribute(const AtomicString& name) const; |
| 147 bool hasAttributeNS(const AtomicString& namespaceURI, const AtomicString& lo
calName) const; | 144 bool hasAttributeNS(const AtomicString& namespaceURI, const AtomicString& lo
calName) const; |
| 148 | 145 |
| 149 const AtomicString& getAttribute(const AtomicString& name) const; | 146 const AtomicString& getAttribute(const AtomicString& name) const; |
| 150 const AtomicString& getAttributeNS(const AtomicString& namespaceURI, const A
tomicString& localName) const; | 147 const AtomicString& getAttributeNS(const AtomicString& namespaceURI, const A
tomicString& localName) const; |
| 151 | 148 |
| 152 void setAttribute(const AtomicString& name, const AtomicString& value, Excep
tionState&); | 149 void setAttribute(const AtomicString& name, const AtomicString& value, Excep
tionState&); |
| 153 static bool parseAttributeName(QualifiedName&, const AtomicString& namespace
URI, const AtomicString& qualifiedName, ExceptionState&); | 150 static bool parseAttributeName(QualifiedName&, const AtomicString& namespace
URI, const AtomicString& qualifiedName, ExceptionState&); |
| 154 void setAttributeNS(const AtomicString& namespaceURI, const AtomicString& qu
alifiedName, const AtomicString& value, ExceptionState&); | 151 void setAttributeNS(const AtomicString& namespaceURI, const AtomicString& qu
alifiedName, const AtomicString& value, ExceptionState&); |
| 155 | 152 |
| 156 bool isIdAttributeName(const QualifiedName&) const; | 153 bool isIdAttributeName(const QualifiedName&) const; |
| 157 const AtomicString& getIdAttribute() const; | 154 const AtomicString& getIdAttribute() const; |
| 158 void setIdAttribute(const AtomicString&); | 155 void setIdAttribute(const AtomicString&); |
| 159 | 156 |
| 160 const AtomicString& getNameAttribute() const; | 157 const AtomicString& getNameAttribute() const; |
| 161 const AtomicString& getClassAttribute() const; | 158 const AtomicString& getClassAttribute() const; |
| 162 | 159 |
| 163 bool shouldIgnoreAttributeCase() const; | 160 bool shouldIgnoreAttributeCase() const; |
| 164 | 161 |
| 165 // Call this to get the value of the id attribute for style resolution purpo
ses. | 162 // Call this to get the value of the id attribute for style resolution purpo
ses. |
| 166 // The value will already be lowercased if the document is in compatibility
mode, | 163 // The value will already be lowercased if the document is in compatibility
mode, |
| 167 // so this function is not suitable for non-style uses. | 164 // so this function is not suitable for non-style uses. |
| 168 const AtomicString& idForStyleResolution() const; | 165 const AtomicString& idForStyleResolution() const; |
| 169 | 166 |
| 170 // Internal method that assumes the existence of attribute storage, one shou
ld use hasAttributes() | 167 // This getter takes care of synchronizing all attributes before returning t
he |
| 171 // before calling it. This is not a trivial getter and its return value shou
ld be cached for | 168 // AttributeCollection. If the Element has no attributes, an empty Attribute
Collection |
| 172 // performance. | 169 // will be returned. This is not a trivial getter and its return value shoul
d be cached |
| 170 // for performance. |
| 173 AttributeCollection attributes() const; | 171 AttributeCollection attributes() const; |
| 172 // This variant will not update the potentially invalid attributes. To be us
ed when not interested |
| 173 // in style attribute or one of the SVG animation attributes. |
| 174 AttributeCollection attributesWithoutUpdate() const; |
| 174 | 175 |
| 175 void scrollIntoView(bool alignToTop = true); | 176 void scrollIntoView(bool alignToTop = true); |
| 176 void scrollIntoViewIfNeeded(bool centerIfNeeded = true); | 177 void scrollIntoViewIfNeeded(bool centerIfNeeded = true); |
| 177 | 178 |
| 178 int offsetLeft(); | 179 int offsetLeft(); |
| 179 int offsetTop(); | 180 int offsetTop(); |
| 180 int offsetWidth(); | 181 int offsetWidth(); |
| 181 int offsetHeight(); | 182 int offsetHeight(); |
| 182 | 183 |
| 183 // FIXME: Replace uses of offsetParent in the platform with calls | 184 // FIXME: Replace uses of offsetParent in the platform with calls |
| (...skipping 500 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 684 | 685 |
| 685 inline Element* Node::parentElement() const | 686 inline Element* Node::parentElement() const |
| 686 { | 687 { |
| 687 ContainerNode* parent = parentNode(); | 688 ContainerNode* parent = parentNode(); |
| 688 return parent && parent->isElementNode() ? toElement(parent) : 0; | 689 return parent && parent->isElementNode() ? toElement(parent) : 0; |
| 689 } | 690 } |
| 690 | 691 |
| 691 inline bool Element::fastHasAttribute(const QualifiedName& name) const | 692 inline bool Element::fastHasAttribute(const QualifiedName& name) const |
| 692 { | 693 { |
| 693 ASSERT(fastAttributeLookupAllowed(name)); | 694 ASSERT(fastAttributeLookupAllowed(name)); |
| 694 return elementData() && attributes().findIndex(name) != kNotFound; | 695 return elementData() && elementData()->attributes().findIndex(name) != kNotF
ound; |
| 695 } | 696 } |
| 696 | 697 |
| 697 inline const AtomicString& Element::fastGetAttribute(const QualifiedName& name)
const | 698 inline const AtomicString& Element::fastGetAttribute(const QualifiedName& name)
const |
| 698 { | 699 { |
| 699 ASSERT(fastAttributeLookupAllowed(name)); | 700 ASSERT(fastAttributeLookupAllowed(name)); |
| 700 if (elementData()) { | 701 if (elementData()) { |
| 701 if (const Attribute* attribute = attributes().find(name)) | 702 if (const Attribute* attribute = elementData()->attributes().find(name)) |
| 702 return attribute->value(); | 703 return attribute->value(); |
| 703 } | 704 } |
| 704 return nullAtom; | 705 return nullAtom; |
| 705 } | 706 } |
| 706 | 707 |
| 707 inline AttributeCollection Element::attributes() const | 708 inline AttributeCollection Element::attributes() const |
| 708 { | 709 { |
| 709 ASSERT(elementData()); | 710 if (!elementData()) |
| 711 return AttributeCollection(); |
| 712 synchronizeAllAttributes(); |
| 710 return elementData()->attributes(); | 713 return elementData()->attributes(); |
| 711 } | 714 } |
| 712 | 715 |
| 713 inline bool Element::hasAttributesWithoutUpdate() const | 716 inline AttributeCollection Element::attributesWithoutUpdate() const |
| 714 { | 717 { |
| 715 return elementData() && !elementData()->attributes().isEmpty(); | 718 if (!elementData()) |
| 719 return AttributeCollection(); |
| 720 return elementData()->attributes(); |
| 721 } |
| 722 |
| 723 inline bool Element::hasAttributes() const |
| 724 { |
| 725 return !attributes().isEmpty(); |
| 716 } | 726 } |
| 717 | 727 |
| 718 inline const AtomicString& Element::idForStyleResolution() const | 728 inline const AtomicString& Element::idForStyleResolution() const |
| 719 { | 729 { |
| 720 ASSERT(hasID()); | 730 ASSERT(hasID()); |
| 721 return elementData()->idForStyleResolution(); | 731 return elementData()->idForStyleResolution(); |
| 722 } | 732 } |
| 723 | 733 |
| 724 inline bool Element::isIdAttributeName(const QualifiedName& attributeName) const | 734 inline bool Element::isIdAttributeName(const QualifiedName& attributeName) const |
| 725 { | 735 { |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 850 static PassRefPtrWillBeRawPtr<T> create(const QualifiedName&, Document&) | 860 static PassRefPtrWillBeRawPtr<T> create(const QualifiedName&, Document&) |
| 851 #define DEFINE_ELEMENT_FACTORY_WITH_TAGNAME(T) \ | 861 #define DEFINE_ELEMENT_FACTORY_WITH_TAGNAME(T) \ |
| 852 PassRefPtrWillBeRawPtr<T> T::create(const QualifiedName& tagName, Document&
document) \ | 862 PassRefPtrWillBeRawPtr<T> T::create(const QualifiedName& tagName, Document&
document) \ |
| 853 { \ | 863 { \ |
| 854 return adoptRefWillBeNoop(new T(tagName, document)); \ | 864 return adoptRefWillBeNoop(new T(tagName, document)); \ |
| 855 } | 865 } |
| 856 | 866 |
| 857 } // namespace | 867 } // namespace |
| 858 | 868 |
| 859 #endif | 869 #endif |
| OLD | NEW |