Chromium Code Reviews| 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 24 matching lines...) Expand all Loading... | |
| 35 : m_treeScope(treeScope) | 35 : m_treeScope(treeScope) |
| 36 { | 36 { |
| 37 } | 37 } |
| 38 | 38 |
| 39 StyleSheetList::~StyleSheetList() | 39 StyleSheetList::~StyleSheetList() |
| 40 { | 40 { |
| 41 } | 41 } |
| 42 | 42 |
| 43 inline const WillBeHeapVector<RefPtrWillBeMember<StyleSheet> >& StyleSheetList:: styleSheets() | 43 inline const WillBeHeapVector<RefPtrWillBeMember<StyleSheet> >& StyleSheetList:: styleSheets() |
| 44 { | 44 { |
| 45 #if !ENABLE(OILPAN) | |
| 45 if (!m_treeScope) | 46 if (!m_treeScope) |
| 46 return m_detachedStyleSheets; | 47 return m_detachedStyleSheets; |
| 48 #endif | |
| 47 return document()->styleEngine()->styleSheetsForStyleSheetList(*m_treeScope) ; | 49 return document()->styleEngine()->styleSheetsForStyleSheetList(*m_treeScope) ; |
| 48 } | 50 } |
| 49 | 51 |
| 52 #if !ENABLE(OILPAN) | |
| 50 void StyleSheetList::detachFromDocument() | 53 void StyleSheetList::detachFromDocument() |
| 51 { | 54 { |
| 52 // FIXME: Oilpan: This is safe currently because the Document is | |
| 53 // *not* in the oilpan heap and the style engine is alive when the | |
| 54 // document dies. When the Document is in the oilpan heap, we need | |
| 55 // the StyleSheetList and the document to die together and get rid | |
| 56 // of the detachedStyleSheets. | |
| 57 m_detachedStyleSheets = document()->styleEngine()->styleSheetsForStyleSheetL ist(*m_treeScope); | 55 m_detachedStyleSheets = document()->styleEngine()->styleSheetsForStyleSheetL ist(*m_treeScope); |
| 58 m_treeScope = 0; | 56 m_treeScope = nullptr; |
| 59 } | 57 } |
| 58 #endif | |
| 60 | 59 |
| 61 unsigned StyleSheetList::length() | 60 unsigned StyleSheetList::length() |
| 62 { | 61 { |
| 63 return styleSheets().size(); | 62 return styleSheets().size(); |
| 64 } | 63 } |
| 65 | 64 |
| 66 StyleSheet* StyleSheetList::item(unsigned index) | 65 StyleSheet* StyleSheetList::item(unsigned index) |
| 67 { | 66 { |
| 68 const WillBeHeapVector<RefPtrWillBeMember<StyleSheet> >& sheets = styleSheet s(); | 67 const WillBeHeapVector<RefPtrWillBeMember<StyleSheet> >& sheets = styleSheet s(); |
| 69 return index < sheets.size() ? sheets[index].get() : 0; | 68 return index < sheets.size() ? sheets[index].get() : 0; |
| 70 } | 69 } |
| 71 | 70 |
| 72 HTMLStyleElement* StyleSheetList::getNamedItem(const AtomicString& name) const | 71 HTMLStyleElement* StyleSheetList::getNamedItem(const AtomicString& name) const |
| 73 { | 72 { |
| 74 if (!m_treeScope) | 73 if (!m_treeScope) |
|
haraken
2014/04/24 04:18:43
Add #if !ENABLE(OILPAN)
Mads Ager (chromium)
2014/04/24 10:57:36
Done.
| |
| 75 return 0; | 74 return 0; |
| 76 | 75 |
| 77 // IE also supports retrieving a stylesheet by name, using the name/id of th e <style> tag | 76 // IE also supports retrieving a stylesheet by name, using the name/id of th e <style> tag |
| 78 // (this is consistent with all the other collections) | 77 // (this is consistent with all the other collections) |
| 79 // ### Bad implementation because returns a single element (are IDs always u nique?) | 78 // ### Bad implementation because returns a single element (are IDs always u nique?) |
| 80 // and doesn't look for name attribute. | 79 // and doesn't look for name attribute. |
| 81 // But unicity of stylesheet ids is good practice anyway ;) | 80 // But unicity of stylesheet ids is good practice anyway ;) |
| 82 // FIXME: We should figure out if we should change this or fix the spec. | 81 // FIXME: We should figure out if we should change this or fix the spec. |
| 83 Element* element = m_treeScope->getElementById(name); | 82 Element* element = m_treeScope->getElementById(name); |
| 84 return isHTMLStyleElement(element) ? toHTMLStyleElement(element) : 0; | 83 return isHTMLStyleElement(element) ? toHTMLStyleElement(element) : 0; |
| 85 } | 84 } |
| 86 | 85 |
| 87 CSSStyleSheet* StyleSheetList::anonymousNamedGetter(const AtomicString& name) | 86 CSSStyleSheet* StyleSheetList::anonymousNamedGetter(const AtomicString& name) |
| 88 { | 87 { |
| 89 HTMLStyleElement* item = getNamedItem(name); | 88 HTMLStyleElement* item = getNamedItem(name); |
| 90 if (!item) | 89 if (!item) |
| 91 return 0; | 90 return 0; |
| 92 return item->sheet(); | 91 return item->sheet(); |
| 93 } | 92 } |
| 94 | 93 |
| 95 void StyleSheetList::trace(Visitor* visitor) | 94 void StyleSheetList::trace(Visitor* visitor) |
| 96 { | 95 { |
| 97 visitor->trace(m_detachedStyleSheets); | 96 visitor->trace(m_treeScope); |
| 98 } | 97 } |
| 99 | 98 |
| 100 } // namespace WebCore | 99 } // namespace WebCore |
| OLD | NEW |