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, 2008, 2012 Apple Inc. All rights reserv
ed. | 6 * Copyright (C) 2003, 2004, 2005, 2006, 2008, 2012 Apple Inc. All rights |
| 7 * reserved. |
7 * | 8 * |
8 * This library is free software; you can redistribute it and/or | 9 * This library is free software; you can redistribute it and/or |
9 * modify it under the terms of the GNU Library General Public | 10 * modify it under the terms of the GNU Library General Public |
10 * License as published by the Free Software Foundation; either | 11 * License as published by the Free Software Foundation; either |
11 * version 2 of the License, or (at your option) any later version. | 12 * version 2 of the License, or (at your option) any later version. |
12 * | 13 * |
13 * This library is distributed in the hope that it will be useful, | 14 * This library is distributed in the hope that it will be useful, |
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
16 * Library General Public License for more details. | 17 * Library General Public License for more details. |
(...skipping 17 matching lines...) Expand all Loading... |
34 // value. It is distinct from the web-exposed Attr, which also knows of the | 35 // value. It is distinct from the web-exposed Attr, which also knows of the |
35 // element to which it attached, if any. | 36 // element to which it attached, if any. |
36 class Attribute { | 37 class Attribute { |
37 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); | 38 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); |
38 | 39 |
39 public: | 40 public: |
40 Attribute(const QualifiedName& name, const AtomicString& value) | 41 Attribute(const QualifiedName& name, const AtomicString& value) |
41 : m_name(name), m_value(value) {} | 42 : m_name(name), m_value(value) {} |
42 | 43 |
43 // NOTE: The references returned by these functions are only valid for as long | 44 // NOTE: The references returned by these functions are only valid for as long |
44 // as the Attribute stays in place. For example, calling a function that mutat
es | 45 // as the Attribute stays in place. For example, calling a function that |
45 // an Element's internal attribute storage may invalidate them. | 46 // mutates an Element's internal attribute storage may invalidate them. |
46 const AtomicString& value() const { return m_value; } | 47 const AtomicString& value() const { return m_value; } |
47 const AtomicString& prefix() const { return m_name.prefix(); } | 48 const AtomicString& prefix() const { return m_name.prefix(); } |
48 const AtomicString& localName() const { return m_name.localName(); } | 49 const AtomicString& localName() const { return m_name.localName(); } |
49 const AtomicString& namespaceURI() const { return m_name.namespaceURI(); } | 50 const AtomicString& namespaceURI() const { return m_name.namespaceURI(); } |
50 | 51 |
51 const QualifiedName& name() const { return m_name; } | 52 const QualifiedName& name() const { return m_name; } |
52 | 53 |
53 bool isEmpty() const { return m_value.isEmpty(); } | 54 bool isEmpty() const { return m_value.isEmpty(); } |
54 bool matches(const QualifiedName&) const; | 55 bool matches(const QualifiedName&) const; |
55 | 56 |
56 void setValue(const AtomicString& value) { m_value = value; } | 57 void setValue(const AtomicString& value) { m_value = value; } |
57 | 58 |
58 // Note: This API is only for HTMLTreeBuilder. It is not safe to change the | 59 // Note: This API is only for HTMLTreeBuilder. It is not safe to change the |
59 // name of an attribute once parseAttribute has been called as DOM | 60 // name of an attribute once parseAttribute has been called as DOM |
60 // elements may have placed the Attribute in a hash by name. | 61 // elements may have placed the Attribute in a hash by name. |
61 void parserSetName(const QualifiedName& name) { m_name = name; } | 62 void parserSetName(const QualifiedName& name) { m_name = name; } |
62 | 63 |
63 #if COMPILER(MSVC) | 64 #if COMPILER(MSVC) |
64 // NOTE: This constructor is not actually implemented, it's just defined so MS
VC | 65 // NOTE: This constructor is not actually implemented, it's just defined so |
65 // will let us use a zero-length array of Attributes. | 66 // MSVC will let us use a zero-length array of Attributes. |
66 Attribute(); | 67 Attribute(); |
67 #endif | 68 #endif |
68 | 69 |
69 private: | 70 private: |
70 QualifiedName m_name; | 71 QualifiedName m_name; |
71 AtomicString m_value; | 72 AtomicString m_value; |
72 }; | 73 }; |
73 | 74 |
74 inline bool Attribute::matches(const QualifiedName& qualifiedName) const { | 75 inline bool Attribute::matches(const QualifiedName& qualifiedName) const { |
75 if (qualifiedName.localName() != localName()) | 76 if (qualifiedName.localName() != localName()) |
76 return false; | 77 return false; |
77 return qualifiedName.prefix() == starAtom || | 78 return qualifiedName.prefix() == starAtom || |
78 qualifiedName.namespaceURI() == namespaceURI(); | 79 qualifiedName.namespaceURI() == namespaceURI(); |
79 } | 80 } |
80 | 81 |
81 } // namespace blink | 82 } // namespace blink |
82 | 83 |
83 #endif // Attribute_h | 84 #endif // Attribute_h |
OLD | NEW |