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, 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 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 const AtomicString& getNameAttribute() const; | 161 const AtomicString& getNameAttribute() const; |
162 const AtomicString& getClassAttribute() const; | 162 const AtomicString& getClassAttribute() const; |
163 | 163 |
164 bool shouldIgnoreAttributeCase() const; | 164 bool shouldIgnoreAttributeCase() const; |
165 | 165 |
166 // Call this to get the value of the id attribute for style resolution purpo
ses. | 166 // Call this to get the value of the id attribute for style resolution purpo
ses. |
167 // The value will already be lowercased if the document is in compatibility
mode, | 167 // The value will already be lowercased if the document is in compatibility
mode, |
168 // so this function is not suitable for non-style uses. | 168 // so this function is not suitable for non-style uses. |
169 const AtomicString& idForStyleResolution() const; | 169 const AtomicString& idForStyleResolution() const; |
170 | 170 |
171 // Internal methods that assume the existence of attribute storage, one shou
ld use hasAttributes() | 171 // Internal method that assumes the existence of attribute storage, one shou
ld use hasAttributes() |
172 // before calling them. This is not a trivial getter and its return value sh
ould be cached for | 172 // before calling it. This is not a trivial getter and its return value shou
ld be cached for |
173 // performance. | 173 // performance. |
174 AttributeCollection attributes() const; | 174 AttributeCollection attributes() const; |
175 const Attribute* findAttributeByName(const QualifiedName&) const; | |
176 size_t findAttributeIndexByName(const QualifiedName& name) const { return el
ementData()->attributes().findIndex(name); } | |
177 size_t findAttributeIndexByName(const AtomicString& name, bool shouldIgnoreA
ttributeCase) const { return elementData()->attributes().findIndex(name, shouldI
gnoreAttributeCase); } | |
178 | 175 |
179 void scrollIntoView(bool alignToTop = true); | 176 void scrollIntoView(bool alignToTop = true); |
180 void scrollIntoViewIfNeeded(bool centerIfNeeded = true); | 177 void scrollIntoViewIfNeeded(bool centerIfNeeded = true); |
181 | 178 |
182 void scrollByLines(int lines); | 179 void scrollByLines(int lines); |
183 void scrollByPages(int pages); | 180 void scrollByPages(int pages); |
184 | 181 |
185 int offsetLeft(); | 182 int offsetLeft(); |
186 int offsetTop(); | 183 int offsetTop(); |
187 int offsetWidth(); | 184 int offsetWidth(); |
(...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
692 | 689 |
693 inline Element* Node::parentElement() const | 690 inline Element* Node::parentElement() const |
694 { | 691 { |
695 ContainerNode* parent = parentNode(); | 692 ContainerNode* parent = parentNode(); |
696 return parent && parent->isElementNode() ? toElement(parent) : 0; | 693 return parent && parent->isElementNode() ? toElement(parent) : 0; |
697 } | 694 } |
698 | 695 |
699 inline bool Element::fastHasAttribute(const QualifiedName& name) const | 696 inline bool Element::fastHasAttribute(const QualifiedName& name) const |
700 { | 697 { |
701 ASSERT(fastAttributeLookupAllowed(name)); | 698 ASSERT(fastAttributeLookupAllowed(name)); |
702 return elementData() && findAttributeByName(name); | 699 return elementData() && attributes().findIndex(name) != kNotFound; |
703 } | 700 } |
704 | 701 |
705 inline const AtomicString& Element::fastGetAttribute(const QualifiedName& name)
const | 702 inline const AtomicString& Element::fastGetAttribute(const QualifiedName& name)
const |
706 { | 703 { |
707 ASSERT(fastAttributeLookupAllowed(name)); | 704 ASSERT(fastAttributeLookupAllowed(name)); |
708 if (elementData()) { | 705 if (elementData()) { |
709 if (const Attribute* attribute = findAttributeByName(name)) | 706 if (const Attribute* attribute = attributes().find(name)) |
710 return attribute->value(); | 707 return attribute->value(); |
711 } | 708 } |
712 return nullAtom; | 709 return nullAtom; |
713 } | 710 } |
714 | 711 |
715 inline AttributeCollection Element::attributes() const | 712 inline AttributeCollection Element::attributes() const |
716 { | 713 { |
717 ASSERT(elementData()); | 714 ASSERT(elementData()); |
718 return elementData()->attributes(); | 715 return elementData()->attributes(); |
719 } | 716 } |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
762 setAttribute(HTMLNames::idAttr, value); | 759 setAttribute(HTMLNames::idAttr, value); |
763 } | 760 } |
764 | 761 |
765 inline const SpaceSplitString& Element::classNames() const | 762 inline const SpaceSplitString& Element::classNames() const |
766 { | 763 { |
767 ASSERT(hasClass()); | 764 ASSERT(hasClass()); |
768 ASSERT(elementData()); | 765 ASSERT(elementData()); |
769 return elementData()->classNames(); | 766 return elementData()->classNames(); |
770 } | 767 } |
771 | 768 |
772 inline const Attribute* Element::findAttributeByName(const QualifiedName& name)
const | |
773 { | |
774 ASSERT(elementData()); | |
775 return elementData()->attributes().find(name); | |
776 } | |
777 | |
778 inline bool Element::hasID() const | 769 inline bool Element::hasID() const |
779 { | 770 { |
780 return elementData() && elementData()->hasID(); | 771 return elementData() && elementData()->hasID(); |
781 } | 772 } |
782 | 773 |
783 inline bool Element::hasClass() const | 774 inline bool Element::hasClass() const |
784 { | 775 { |
785 return elementData() && elementData()->hasClass(); | 776 return elementData() && elementData()->hasClass(); |
786 } | 777 } |
787 | 778 |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
875 static PassRefPtrWillBeRawPtr<T> create(const QualifiedName&, Document&) | 866 static PassRefPtrWillBeRawPtr<T> create(const QualifiedName&, Document&) |
876 #define DEFINE_ELEMENT_FACTORY_WITH_TAGNAME(T) \ | 867 #define DEFINE_ELEMENT_FACTORY_WITH_TAGNAME(T) \ |
877 PassRefPtrWillBeRawPtr<T> T::create(const QualifiedName& tagName, Document&
document) \ | 868 PassRefPtrWillBeRawPtr<T> T::create(const QualifiedName& tagName, Document&
document) \ |
878 { \ | 869 { \ |
879 return adoptRefWillBeNoop(new T(tagName, document)); \ | 870 return adoptRefWillBeNoop(new T(tagName, document)); \ |
880 } | 871 } |
881 | 872 |
882 } // namespace | 873 } // namespace |
883 | 874 |
884 #endif | 875 #endif |
OLD | NEW |