Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(548)

Side by Side Diff: Source/core/css/StyleSheetList.cpp

Issue 235113002: Oilpan: Remove guardRef and guardDeref from TreeScope. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Address comments. Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/css/StyleSheetList.h ('k') | Source/core/dom/ContainerNode.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 {
73 #if !ENABLE(OILPAN)
74 if (!m_treeScope) 74 if (!m_treeScope)
75 return 0; 75 return 0;
76 #endif
76 77
77 // IE also supports retrieving a stylesheet by name, using the name/id of th e <style> tag 78 // 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) 79 // (this is consistent with all the other collections)
79 // ### Bad implementation because returns a single element (are IDs always u nique?) 80 // ### Bad implementation because returns a single element (are IDs always u nique?)
80 // and doesn't look for name attribute. 81 // and doesn't look for name attribute.
81 // But unicity of stylesheet ids is good practice anyway ;) 82 // But unicity of stylesheet ids is good practice anyway ;)
82 // FIXME: We should figure out if we should change this or fix the spec. 83 // FIXME: We should figure out if we should change this or fix the spec.
83 Element* element = m_treeScope->getElementById(name); 84 Element* element = m_treeScope->getElementById(name);
84 return isHTMLStyleElement(element) ? toHTMLStyleElement(element) : 0; 85 return isHTMLStyleElement(element) ? toHTMLStyleElement(element) : 0;
85 } 86 }
86 87
87 CSSStyleSheet* StyleSheetList::anonymousNamedGetter(const AtomicString& name) 88 CSSStyleSheet* StyleSheetList::anonymousNamedGetter(const AtomicString& name)
88 { 89 {
89 HTMLStyleElement* item = getNamedItem(name); 90 HTMLStyleElement* item = getNamedItem(name);
90 if (!item) 91 if (!item)
91 return 0; 92 return 0;
92 return item->sheet(); 93 return item->sheet();
93 } 94 }
94 95
95 void StyleSheetList::trace(Visitor* visitor) 96 void StyleSheetList::trace(Visitor* visitor)
96 { 97 {
97 visitor->trace(m_detachedStyleSheets); 98 visitor->trace(m_treeScope);
98 } 99 }
99 100
100 } // namespace WebCore 101 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/css/StyleSheetList.h ('k') | Source/core/dom/ContainerNode.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698