| 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 19 matching lines...) Expand all Loading... |
| 30 | 30 |
| 31 StyleSheetList::StyleSheetList(TreeScope* treeScope) | 31 StyleSheetList::StyleSheetList(TreeScope* treeScope) |
| 32 : m_treeScope(treeScope) | 32 : m_treeScope(treeScope) |
| 33 { | 33 { |
| 34 } | 34 } |
| 35 | 35 |
| 36 StyleSheetList::~StyleSheetList() | 36 StyleSheetList::~StyleSheetList() |
| 37 { | 37 { |
| 38 } | 38 } |
| 39 | 39 |
| 40 inline const Vector<RefPtr<StyleSheet> >& StyleSheetList::styleSheets() | 40 inline const Vector<RefPtr<CSSStyleSheet> >& StyleSheetList::styleSheets() |
| 41 { | 41 { |
| 42 #if !ENABLE(OILPAN) | 42 #if !ENABLE(OILPAN) |
| 43 if (!m_treeScope) | 43 if (!m_treeScope) |
| 44 return m_detachedStyleSheets; | 44 return m_detachedStyleSheets; |
| 45 #endif | 45 #endif |
| 46 return document()->styleEngine()->styleSheetsForStyleSheetList(*m_treeScope)
; | 46 return document()->styleEngine()->styleSheetsForStyleSheetList(*m_treeScope)
; |
| 47 } | 47 } |
| 48 | 48 |
| 49 void StyleSheetList::detachFromDocument() | 49 void StyleSheetList::detachFromDocument() |
| 50 { | 50 { |
| 51 m_detachedStyleSheets = document()->styleEngine()->styleSheetsForStyleSheetL
ist(*m_treeScope); | 51 m_detachedStyleSheets = document()->styleEngine()->styleSheetsForStyleSheetL
ist(*m_treeScope); |
| 52 m_treeScope = nullptr; | 52 m_treeScope = nullptr; |
| 53 } | 53 } |
| 54 | 54 |
| 55 unsigned StyleSheetList::length() | 55 unsigned StyleSheetList::length() |
| 56 { | 56 { |
| 57 return styleSheets().size(); | 57 return styleSheets().size(); |
| 58 } | 58 } |
| 59 | 59 |
| 60 StyleSheet* StyleSheetList::item(unsigned index) | 60 CSSStyleSheet* StyleSheetList::item(unsigned index) |
| 61 { | 61 { |
| 62 const Vector<RefPtr<StyleSheet> >& sheets = styleSheets(); | 62 const Vector<RefPtr<CSSStyleSheet> >& sheets = styleSheets(); |
| 63 return index < sheets.size() ? sheets[index].get() : 0; | 63 return index < sheets.size() ? sheets[index].get() : 0; |
| 64 } | 64 } |
| 65 | 65 |
| 66 HTMLStyleElement* StyleSheetList::getNamedItem(const AtomicString& name) const | 66 HTMLStyleElement* StyleSheetList::getNamedItem(const AtomicString& name) const |
| 67 { | 67 { |
| 68 #if !ENABLE(OILPAN) | 68 #if !ENABLE(OILPAN) |
| 69 if (!m_treeScope) | 69 if (!m_treeScope) |
| 70 return 0; | 70 return 0; |
| 71 #endif | 71 #endif |
| 72 | 72 |
| 73 // IE also supports retrieving a stylesheet by name, using the name/id of th
e <style> tag | 73 // IE also supports retrieving a stylesheet by name, using the name/id of th
e <style> tag |
| 74 // (this is consistent with all the other collections) | 74 // (this is consistent with all the other collections) |
| 75 // ### Bad implementation because returns a single element (are IDs always u
nique?) | 75 // ### Bad implementation because returns a single element (are IDs always u
nique?) |
| 76 // and doesn't look for name attribute. | 76 // and doesn't look for name attribute. |
| 77 // But unicity of stylesheet ids is good practice anyway ;) | 77 // But unicity of stylesheet ids is good practice anyway ;) |
| 78 // FIXME: We should figure out if we should change this or fix the spec. | 78 // FIXME: We should figure out if we should change this or fix the spec. |
| 79 Element* element = m_treeScope->getElementById(name); | 79 Element* element = m_treeScope->getElementById(name); |
| 80 return isHTMLStyleElement(element) ? toHTMLStyleElement(element) : 0; | 80 return isHTMLStyleElement(element) ? toHTMLStyleElement(element) : 0; |
| 81 } | 81 } |
| 82 | 82 |
| 83 CSSStyleSheet* StyleSheetList::anonymousNamedGetter(const AtomicString& name) | 83 CSSStyleSheet* StyleSheetList::anonymousNamedGetter(const AtomicString& name) |
| 84 { | 84 { |
| 85 HTMLStyleElement* item = getNamedItem(name); | 85 HTMLStyleElement* item = getNamedItem(name); |
| 86 if (!item) | 86 if (!item) |
| 87 return 0; | 87 return 0; |
| 88 return item->sheet(); | 88 return item->sheet(); |
| 89 } | 89 } |
| 90 | 90 |
| 91 } // namespace blink | 91 } // namespace blink |
| OLD | NEW |