OLD | NEW |
1 /** | 1 /** |
2 * (C) 1999-2003 Lars Knoll (knoll@kde.org) | 2 * (C) 1999-2003 Lars Knoll (knoll@kde.org) |
3 * Copyright (C) 2004, 2006, 2007 Apple Inc. All rights reserved. | 3 * Copyright (C) 2004, 2006, 2007 Apple Inc. All rights reserved. |
4 * | 4 * |
5 * This library is free software; you can redistribute it and/or | 5 * This library is free software; you can redistribute it and/or |
6 * modify it under the terms of the GNU Library General Public | 6 * modify it under the terms of the GNU Library General Public |
7 * License as published by the Free Software Foundation; either | 7 * License as published by the Free Software Foundation; either |
8 * version 2 of the License, or (at your option) any later version. | 8 * version 2 of the License, or (at your option) any later version. |
9 * | 9 * |
10 * This library is distributed in the hope that it will be useful, | 10 * This library is distributed in the hope that it will be useful, |
(...skipping 30 matching lines...) Expand all Loading... |
41 unsigned StyleSheetList::length() { | 41 unsigned StyleSheetList::length() { |
42 return styleSheets().size(); | 42 return styleSheets().size(); |
43 } | 43 } |
44 | 44 |
45 StyleSheet* StyleSheetList::item(unsigned index) { | 45 StyleSheet* StyleSheetList::item(unsigned index) { |
46 const HeapVector<Member<StyleSheet>>& sheets = styleSheets(); | 46 const HeapVector<Member<StyleSheet>>& sheets = styleSheets(); |
47 return index < sheets.size() ? sheets[index].get() : nullptr; | 47 return index < sheets.size() ? sheets[index].get() : nullptr; |
48 } | 48 } |
49 | 49 |
50 HTMLStyleElement* StyleSheetList::getNamedItem(const AtomicString& name) const { | 50 HTMLStyleElement* StyleSheetList::getNamedItem(const AtomicString& name) const { |
51 // IE also supports retrieving a stylesheet by name, using the name/id of the
<style> tag | 51 // IE also supports retrieving a stylesheet by name, using the name/id of the |
52 // (this is consistent with all the other collections) | 52 // <style> tag (this is consistent with all the other collections) ### Bad |
53 // ### Bad implementation because returns a single element (are IDs always uni
que?) | 53 // implementation because returns a single element (are IDs always unique?) |
54 // and doesn't look for name attribute. | 54 // and doesn't look for name attribute. But unicity of stylesheet ids is good |
55 // But unicity of stylesheet ids is good practice anyway ;) | 55 // practice anyway ;) |
56 // FIXME: We should figure out if we should change this or fix the spec. | 56 // FIXME: We should figure out if we should change this or fix the spec. |
57 Element* element = m_treeScope->getElementById(name); | 57 Element* element = m_treeScope->getElementById(name); |
58 return isHTMLStyleElement(element) ? toHTMLStyleElement(element) : nullptr; | 58 return isHTMLStyleElement(element) ? toHTMLStyleElement(element) : nullptr; |
59 } | 59 } |
60 | 60 |
61 CSSStyleSheet* StyleSheetList::anonymousNamedGetter(const AtomicString& name) { | 61 CSSStyleSheet* StyleSheetList::anonymousNamedGetter(const AtomicString& name) { |
62 if (document()) | 62 if (document()) |
63 UseCounter::count(*document(), | 63 UseCounter::count(*document(), |
64 UseCounter::StyleSheetListAnonymousNamedGetter); | 64 UseCounter::StyleSheetListAnonymousNamedGetter); |
65 HTMLStyleElement* item = getNamedItem(name); | 65 HTMLStyleElement* item = getNamedItem(name); |
66 if (!item) | 66 if (!item) |
67 return nullptr; | 67 return nullptr; |
68 return item->sheet(); | 68 return item->sheet(); |
69 } | 69 } |
70 | 70 |
71 DEFINE_TRACE(StyleSheetList) { | 71 DEFINE_TRACE(StyleSheetList) { |
72 visitor->trace(m_treeScope); | 72 visitor->trace(m_treeScope); |
73 } | 73 } |
74 | 74 |
75 } // namespace blink | 75 } // namespace blink |
OLD | NEW |